]> ToastFreeware Gitweb - toast/confclerk.git/commitdiff
Merge branch 'master' into qt5
authorgregor herrmann <gregor@toastfreeware.priv.at>
Wed, 30 Aug 2017 18:38:27 +0000 (20:38 +0200)
committergregor herrmann <gregor@toastfreeware.priv.at>
Wed, 30 Aug 2017 18:38:27 +0000 (20:38 +0200)
1  2 
src/gui/eventdialog.cpp
src/gui/mainwindow.h
src/gui/searchhead.h
src/mvc/conferencemodel.h
src/mvc/delegate.cpp
src/mvc/delegate.h
src/mvc/eventmodel.cpp
src/sql/sqlengine.cpp

diff --combined src/gui/eventdialog.cpp
index fe9daba4745d721002c6006e70357d64979c05a9,458a7018bfa79e53a7d9cffd793239a1d687f6c8..90910c85d8834b0be3c6fe5632df8980779c039f
@@@ -1,6 -1,6 +1,6 @@@
  /*
   * Copyright (C) 2010 Ixonos Plc.
-  * Copyright (C) 2011-2015 Philipp Spitzer, gregor herrmann, Stefan Stahl
+  * Copyright (C) 2011-2017 Philipp Spitzer, gregor herrmann, Stefan Stahl
   *
   * This file is part of ConfClerk.
   *
@@@ -38,21 -38,29 +38,29 @@@ EventDialog::EventDialog(int conference
  
      QString info;
      // title
 -    info.append(QString("<h1>%1</h1>\n").arg(Qt::escape(event.title())));
 +    info.append(QString("<h1>%1</h1>\n").arg(event.title().toHtmlEscaped()));
  
      // persons
      info += QString("<h2>%1</h2>\n").arg(tr("Persons"));
      QStringList persons = event.persons();
 -    for (int i = 0; i != persons.size(); ++i) persons[i] = Qt::escape(persons[i]);
 +    for (int i = 0; i != persons.size(); ++i) persons[i] = persons[i].toHtmlEscaped();
      info += QString("<p>%1</p>\n").arg(persons.join(", "));
  
      // abstract
      info += QString("<h2>%1</h2>\n").arg(tr("Abstract"));
-     info += Qt::convertFromPlainText(event.abstract(), Qt::WhiteSpaceNormal);
+     if (Qt::mightBeRichText(event.abstract())) {
+         info += event.abstract();
+     } else {
+         info += Qt::convertFromPlainText(event.abstract(), Qt::WhiteSpaceNormal);
+     }
  
      // description
      info += QString("<h2>%1</h2>\n").arg(tr("Description"));
-     info += Qt::convertFromPlainText(event.description(), Qt::WhiteSpaceNormal);
+     if (Qt::mightBeRichText(event.description())) {
+         info += event.description();
+     } else {
+         info += Qt::convertFromPlainText(event.description(), Qt::WhiteSpaceNormal);
+     }
  
      // links
      info += QString("<h2>%1</h2>\n<ul>\n").arg(tr("Links"));
@@@ -63,7 -71,7 +71,7 @@@
          QString name(i.key());
          if (url.isEmpty() || url == "http://") continue;
          if (name.isEmpty()) name = url;
 -        info += QString("<li><a href=\"%1\">%2</a></li>\n").arg(Qt::escape(url), Qt::escape(name));
 +        info += QString("<li><a href=\"%1\">%2</a></li>\n").arg(url.toHtmlEscaped(), name.toHtmlEscaped());
      }
      info += QString("</ul>\n");
      eventInfoTextBrowser->setHtml(info);
      connect(favouriteButton, SIGNAL(clicked()), SLOT(favouriteClicked()));
      connect(alarmButton, SIGNAL(clicked()), SLOT(alarmClicked()));
  
-     if(event.isFavourite())
-     {
-         favouriteButton->setIcon(QIcon(":/icons/favourite-on.png"));
-     }
+     updateFavouriteButton(event);
  
      if(event.hasAlarm())
      {
  void EventDialog::favouriteClicked()
  {
      Event event = Event::getById(mEventId, mConferenceId);
-     QList<Event> conflicts = Event::conflictEvents(event.id(), mConferenceId);
-     if(event.isFavourite())
-     {
-         event.setFavourite(false);
-         favouriteButton->setIcon(QIcon(":/icons/favourite-off.png"));
-     }
-     else
-     {
-         event.setFavourite(true);
-         favouriteButton->setIcon(QIcon(":/icons/favourite-on.png"));
-     }
+     event.cycleFavourite();
      event.update("favourite");
+     updateFavouriteButton(event);
  
-     if(event.isFavourite())
-     {
-         // event has became 'favourite' and so 'conflicts' list may have changed
-         conflicts = Event::conflictEvents(event.id(), mConferenceId);
-     }
+     // 'conflicts' list may have changed
+     QList<Event> conflicts = Event::conflictEvents(event.id(), mConferenceId);
  
      // have to emit 'eventChanged' signal on all events in conflict
      for(int i=0; i<conflicts.count(); i++)
@@@ -154,3 -146,12 +146,12 @@@ void EventDialog::alarmClicked(
      emit eventChanged(event.id(), false);
  }
  
+ void EventDialog::updateFavouriteButton(const Event& event) {
+     switch (event.favourite()) {
+         case Favourite_no: favouriteButton->setIcon(QIcon(":/icons/favourite-no.png")); break;
+         case Favourite_weak: favouriteButton->setIcon(QIcon(":/icons/favourite-weak.png")); break;
+         case Favourite_strong: favouriteButton->setIcon(QIcon(":/icons/favourite-strong.png")); break;
+     }
+ }
diff --combined src/gui/mainwindow.h
index 5c657721fc23823a88bebbf3b75ff13b57d9a0e4,537d81e793f9cd3961ea1b25c858154951d44122..09203e406aa44bb830040dd102029c66fe7afb2a
@@@ -1,6 -1,6 +1,6 @@@
  /*
   * Copyright (C) 2010 Ixonos Plc.
-  * Copyright (C) 2011-2015 Philipp Spitzer, gregor herrmann, Stefan Stahl
+  * Copyright (C) 2011-2017 Philipp Spitzer, gregor herrmann, Stefan Stahl
   *
   * This file is part of ConfClerk.
   *
@@@ -20,7 -20,8 +20,8 @@@
  #ifndef MAINWINDOW_H
  #define MAINWINDOW_H
  
 -#include <QtGui/QMainWindow>
 +#include <QtWidgets>
+ #include <QSslError>
  
  #include "ui_mainwindow.h"
  
@@@ -51,6 -52,7 +52,7 @@@ private slots
      void onEventChanged(int aEventId, bool favouriteChanged);
      void onSearchResultChanged();
  
+     void sslErrors(QNetworkReply*,const QList<QSslError> &errors);
      void networkQueryFinished(QNetworkReply*);
      void importFromNetwork(const QString&, int conferenceId);
      void importFromFile(const QString&, int conferenceId);
diff --combined src/gui/searchhead.h
index d7ebd29558003e9bb59280329df64f815c465350,ac212bc3d233d573377f8e9abe770bbe77e0317d..2a56d4b76f150035f29b14b95a9b01909399937e
@@@ -1,6 -1,6 +1,6 @@@
  /*
   * Copyright (C) 2010 Ixonos Plc.
-  * Copyright (C) 2011-2015 Philipp Spitzer, gregor herrmann, Stefan Stahl
+  * Copyright (C) 2011-2017 Philipp Spitzer, gregor herrmann, Stefan Stahl
   *
   * This file is part of ConfClerk.
   *
@@@ -20,7 -20,7 +20,7 @@@
  #ifndef SEARCHHEAD_H
  #define SEARCHHEAD_H
  
 -#include <QtGui/QWidget>
 +#include <QtWidgets>
  #include <QDebug>
  #include "ui_searchhead.h"
  
index de4d282fb41b78e05e5ee894674c61e39fc235b7,db646fa72d2e8de76abf31a202dec8bf78135906..b7297ba2c83218a2f2447df376f9596ce572d2cc
@@@ -1,6 -1,6 +1,6 @@@
  /*
   * Copyright (C) 2010 Ixonos Plc.
-  * Copyright (C) 2011-2015 Philipp Spitzer, gregor herrmann, Stefan Stahl
+  * Copyright (C) 2011-2017 Philipp Spitzer, gregor herrmann, Stefan Stahl
   *
   * This file is part of ConfClerk.
   *
@@@ -52,9 -52,8 +52,9 @@@ private
      // reinitialize list from database
      void reinit()
      {
 +        beginResetModel();
          conferences = Conference::getAll();
 -        reset();
 +        endResetModel();
      }
  
      QList<Conference> conferences;
diff --combined src/mvc/delegate.cpp
index e6136598c41dfc9e46b3e297479d89cba7a84033,ebf421111c32e4dbe010cb54e90c1d3c9be5672b..2d1f08524084873ea61ee03ad94879a50a826960
@@@ -1,6 -1,6 +1,6 @@@
  /*
   * Copyright (C) 2010 Ixonos Plc.
-  * Copyright (C) 2011-2015 Philipp Spitzer, gregor herrmann, Stefan Stahl
+  * Copyright (C) 2011-2017 Philipp Spitzer, gregor herrmann, Stefan Stahl
   *
   * This file is part of ConfClerk.
   *
@@@ -60,12 -60,28 +60,28 @@@ void Delegate::paint(QPainter *painter
  
      if(hasParent(index))
      {
+         Event *event = static_cast<Event*>(index.internalPointer());
+         // determine severity of conflict
+         Favourite eventTimeConflict = event->timeConflict(); // cache value as event->timeConflict is expensive
+         enum ConflictSeverity {csNone, csWeak, csStrong} conflictSeverity = csNone;
+         switch (event->favourite()) {
+             case Favourite_strong:
+                 conflictSeverity = (eventTimeConflict == Favourite_strong) ? csStrong : csNone;
+                 break;
+             case Favourite_weak:
+                 conflictSeverity = (eventTimeConflict == Favourite_no) ? csNone : csWeak;
+                 break;
+             case Favourite_no:
+                 conflictSeverity = csNone;
+                 break;
+         }
          // entry horizontal layout:
          // * spacer (aka y position of image)
          // * image
          // * rest is text, which is 1 line of title with big letters and 2 lines of Presenter and Track
-         int aux = option.rect.height() - SPACER - mControls[FavouriteControlOn]->image()->height();
-         Event *event = static_cast<Event*>(index.internalPointer());
+         int aux = option.rect.height() - SPACER - mControls[FavouriteControlStrong]->image()->height();
  
          // font SMALL
          QFont fontSmall = option.font;
          QFontMetrics fmBigB(fontBigB);
  
          // background (in case of time conflicts)
-         if(event->hasTimeConflict()) {
-             painter->setBrush(Qt::yellow);
+         if (conflictSeverity != csNone) {
+             painter->setBrush(conflictSeverity == csStrong ? Qt::yellow : QColor("lightyellow"));
              painter->setPen(Qt::NoPen);
              painter->drawRect(option.rect);
          }
          foreach(Control* c, mControls.values()) {
              c->setEnabled(false);
          }
-         if(event->isFavourite())
-             mControls[FavouriteControlOn]->paint(painter, option.rect);
-         else
-             mControls[FavouriteControlOff]->paint(painter, option.rect);
+         switch (event->favourite()) {
+         case Favourite_strong:
+             mControls[FavouriteControlStrong]->paint(painter, option.rect);
+             break;
+         case Favourite_weak:
+             mControls[FavouriteControlWeak]->paint(painter, option.rect);
+             break;
+         case Favourite_no:
+             mControls[FavouriteControlNo]->paint(painter, option.rect);
+             break;
+         }
  
          if(event->hasAlarm())
              mControls[AlarmControlOn]->paint(painter, option.rect);
          else
              mControls[AlarmControlOff]->paint(painter, option.rect);
  
-         if(event->hasTimeConflict())
+         if(eventTimeConflict != Favourite_no)
              mControls[WarningControl]->paint(painter, option.rect);
  
          // draw texts
          // it starts just below the image
          // ("position of text" is lower-left angle of the first letter,
          //  so the first line is actually at the same height as the image)
-         painter->setPen(QPen(event->hasTimeConflict() ? Qt::black : textColor));
+         painter->setPen(QPen(conflictSeverity != csNone ? Qt::black : textColor));
          QPointF titlePointF(option.rect.x() + SPACER,
-                             option.rect.y() + SPACER + mControls[FavouriteControlOn]->image()->height());
+                             option.rect.y() + SPACER + mControls[FavouriteControlStrong]->image()->height());
          QTime start = event->start().time();
          painter->setFont(fontBig);
          painter->drawText(titlePointF,start.toString("hh:mm") + "-" + start.addSecs(event->duration()).toString("hh:mm") + ", " + event->roomName());
          // draw icons
          painter->setPen(QPen(textColor));
          painter->setFont(fontSmall);
-         QImage *image = mControls[numFav ? FavouriteControlOn : FavouriteControlOff]->image();
+         QImage *image = mControls[numFav ? FavouriteControlStrong : FavouriteControlNo]->image();
          QPoint drawPoint =
              option.rect.topRight()
              - QPoint(
                  option.rect.x()+SPACER,
                  option.rect.y()+option.rect.height()-fmBig.descent());
          painter->setFont(fontBig);
 -        painter->drawText(titlePointF,qVariantValue<QString>(index.data()));
 +        painter->drawText(titlePointF,index.data().value<QString>());
      }
  
      painter->restore();
@@@ -306,18 -329,20 +329,20 @@@ void Delegate::Control::paint(QPainter
  void Delegate::defineControls()
  {
      // FAVOURITE ICONs
-     // on
-     mControls.insert(FavouriteControlOn, new Control(FavouriteControlOn, QString(":icons/favourite-on.png"), NULL));
-     // off
-     mControls.insert(FavouriteControlOff, new Control(FavouriteControlOff, QString(":icons/favourite-off.png"), NULL));
+     // strong
+     mControls.insert(FavouriteControlStrong, new Control(FavouriteControlStrong, QString(":icons/favourite-strong.png"), NULL));
+     // weak
+     mControls.insert(FavouriteControlWeak, new Control(FavouriteControlWeak, QString(":icons/favourite-weak.png"), NULL));
+     // no
+     mControls.insert(FavouriteControlNo, new Control(FavouriteControlNo, QString(":icons/favourite-no.png"), NULL));
  
      // ALARM ICONs
      // on
      mControls.insert(AlarmControlOn,
-                     new Control(AlarmControlOn, QString(":icons/alarm-on.png"), mControls[FavouriteControlOn]));
+                     new Control(AlarmControlOn, QString(":icons/alarm-on.png"), mControls[FavouriteControlStrong]));
      // off
      mControls.insert(AlarmControlOff,
-                     new Control(AlarmControlOff, QString(":icons/alarm-off.png"), mControls[FavouriteControlOff]));
+                     new Control(AlarmControlOff, QString(":icons/alarm-off.png"), mControls[FavouriteControlNo]));
      // WARNING ICON
      mControls.insert(WarningControl,
                      new Control(WarningControl, QString(":icons/dialog-warning.png"), mControls[AlarmControlOff]));
@@@ -338,7 -363,7 +363,7 @@@ int Delegate::numberOfFavourities(cons
  
      int nrofFavs = 0;
      for(int i=0; i<index.model()->rowCount(index); i++)
-         if(static_cast<Event*>(index.child(i,0).internalPointer())->isFavourite())
+         if(static_cast<Event*>(index.child(i,0).internalPointer())->favourite() != Favourite_no)
              nrofFavs++;
  
      return nrofFavs;
diff --combined src/mvc/delegate.h
index 75921215b0c31cb52c38277b4499bc52f05b1f42,21d2839c9968382380718bb0cdb0814631930df5..e9f3439decc305e19f249efc7f4bb43c2a16292e
@@@ -1,6 -1,6 +1,6 @@@
  /*
   * Copyright (C) 2010 Ixonos Plc.
-  * Copyright (C) 2011-2015 Philipp Spitzer, gregor herrmann, Stefan Stahl
+  * Copyright (C) 2011-2017 Philipp Spitzer, gregor herrmann, Stefan Stahl
   *
   * This file is part of ConfClerk.
   *
@@@ -20,7 -20,7 +20,7 @@@
  #ifndef DELEGATE_H
  #define DELEGATE_H
  
 -#include <QtGui>
 +#include <QtWidgets>
  
  class Delegate : public QItemDelegate
  {
@@@ -31,8 -31,9 +31,9 @@@
          enum ControlId
          {
              ControlNone = 0,
-             FavouriteControlOn,
-             FavouriteControlOff,
+             FavouriteControlStrong,
+             FavouriteControlWeak,
+             FavouriteControlNo,
              AlarmControlOn,
              AlarmControlOff,
              WarningControl
diff --combined src/mvc/eventmodel.cpp
index e4e236795a88997cef2be967469b28d14edf92db,39c9d9bafdb0bc99e9e8f855d56a2b64224e2bd5..674bbcd5be62234296f354f199e285649262685a
@@@ -1,6 -1,6 +1,6 @@@
  /*
   * Copyright (C) 2010 Ixonos Plc.
-  * Copyright (C) 2011-2015 Philipp Spitzer, gregor herrmann, Stefan Stahl
+  * Copyright (C) 2011-2017 Philipp Spitzer, gregor herrmann, Stefan Stahl
   *
   * This file is part of ConfClerk.
   *
@@@ -44,8 -44,6 +44,8 @@@ void EventModel::Group::setTitle(const 
  // multiple of one hour.
  void EventModel::createTimeGroups()
  {
 +    beginResetModel();
 +
      mGroups.clear();
      mParents.clear();
      if (mEvents.empty()) return;
@@@ -92,7 -90,7 +92,7 @@@
      // the last group needs a title as well
      mGroups.last().setTitle(mEvents);
  
 -    reset();
 +    endResetModel();
  }
  
  void EventModel::createTrackGroups() {
@@@ -176,7 -174,7 +176,7 @@@ QModelIndex EventModel::index(int row, 
  
      if (!parent.isValid())
      {
 -        return createIndex(row, column, 0);
 +        return createIndex(row, column, (quintptr) 0);
      }
      else if (parent.internalId() == 0)
      {
@@@ -201,7 -199,7 +201,7 @@@ QModelIndex EventModel::parent(const QM
  
          Event * event = static_cast<Event*>(index.internalPointer());
  
 -        return createIndex(mParents[event->id()], 0, 0);
 +        return createIndex(mParents[event->id()], 0, (quintptr) 0);
      }
  
      return QModelIndex();
@@@ -230,11 -228,11 +230,11 @@@ int EventModel::rowCount (const QModelI
  
  void EventModel::clearModel()
  {
 +    beginResetModel();
      mGroups.clear();
      mEvents.clear();
      mParents.clear();
 -
 -    reset();
 +    endResetModel();
  }
  
  
diff --combined src/sql/sqlengine.cpp
index 01b5144c2cb3097be82bca2dd9ebb9c9467b4968,536ed6364e97df5ff9ff5f6395aac20595bc1a4e..8c6294dbe1114219d7296b62f14cee474df25db2
@@@ -1,6 -1,6 +1,6 @@@
  /*
   * Copyright (C) 2010 Ixonos Plc.
-  * Copyright (C) 2011-2015 Philipp Spitzer, gregor herrmann, Stefan Stahl
+  * Copyright (C) 2011-2017 Philipp Spitzer, gregor herrmann, Stefan Stahl
   *
   * This file is part of ConfClerk.
   *
@@@ -23,9 -23,9 +23,9 @@@
  #include <QSqlRecord>
  #include <QVariant>
  #include <QDateTime>
 +#include <QStandardPaths>
  
  #include <QDir>
 -#include <QDesktopServices>
  #include "sqlengine.h"
  #include "track.h"
  #include "conference.h"
@@@ -36,7 -36,7 +36,7 @@@ const QString DATE_FORMAT ("yyyy-MM-dd"
  const QString TIME_FORMAT ("hh:mm");
  
  SqlEngine::SqlEngine(QObject *aParent): QObject(aParent) {
 -    QDir dbPath(QDesktopServices::storageLocation(QDesktopServices::DataLocation));
 +    QDir dbPath(QStandardPaths::writableLocation(QStandardPaths::DataLocation));
      dbFilename = dbPath.absoluteFilePath("ConfClerk.sqlite");
  }
  
@@@ -179,6 -179,7 +179,7 @@@ void SqlEngine::addEventToDB(QHash<QStr
      Track track;
      int trackId;
      QString trackName = aEvent["track"];
+     if (trackName.isEmpty()) trackName = tr("No track");
      try
      {
          track = Track::retrieveByName(conferenceId, trackName);