]> ToastFreeware Gitweb - toast/confclerk.git/blobdiff - src/mvc/treeview.cpp
Bump copyright years.
[toast/confclerk.git] / src / mvc / treeview.cpp
index 636ea986474feac904291fd23b11eb848ad1bc73..dfce255bd924b85018bf6cad944d17b8c0bf1c3a 100644 (file)
@@ -1,6 +1,6 @@
 /*
  * Copyright (C) 2010 Ixonos Plc.
- * Copyright (C) 2011 Philipp Spitzer, gregor herrmann
+ * Copyright (C) 2011-2024 Philipp Spitzer, gregor herrmann, Stefan Stahl
  *
  * This file is part of ConfClerk.
  *
@@ -27,6 +27,7 @@
 
 #ifdef MAEMO
 #include "alarm.h"
+#include "appsettings.h"
 #endif
 
 #include <QDebug>
@@ -43,7 +44,7 @@ void TreeView::mouseReleaseEvent(QMouseEvent *aEvent)
     QPoint point = aEvent->pos();
 
     // test whether we have handled the mouse event
-    if(!testForControlClicked(index,point))
+    if(!testForControlClicked(index, point, aEvent->button()))
     {
         // pass the event to the Base class, so item clicks/events are handled correctly
         QTreeView::mouseReleaseEvent(aEvent);
@@ -51,7 +52,7 @@ void TreeView::mouseReleaseEvent(QMouseEvent *aEvent)
 }
 
 // returns bool if some Control was clicked
-bool TreeView::testForControlClicked(const QModelIndex &aIndex, const QPoint &aPoint)
+bool TreeView::testForControlClicked(const QModelIndex &aIndex, const QPoint &aPoint, Qt::MouseButton button)
 {
     bool handled = false;
 
@@ -63,21 +64,19 @@ bool TreeView::testForControlClicked(const QModelIndex &aIndex, const QPoint &aP
     Delegate *delegate = static_cast<Delegate*>(itemDelegate(aIndex));
     switch(delegate->whichControlClicked(aIndex,aPoint))
     {
-        case Delegate::FavouriteControlOn:
-        case Delegate::FavouriteControlOff:
+        case Delegate::FavouriteControlStrong:
+        case Delegate::FavouriteControlWeak:
+        case Delegate::FavouriteControlNo:
             {
                 // handle Favourite Control clicked
                 Event event = Event::getById(aIndex.data().toInt(),confId);
 
                 QList<Event> conflicts = Event::conflictEvents(event.id(),Conference::activeConference());
-                event.setFavourite(!event.isFavourite());
+                event.cycleFavourite(button == Qt::RightButton);
                 event.update("favourite");
 
-                if(event.isFavourite())
-                {
-                    // event has became 'favourite' and so 'conflicts' list may have changed
-                    conflicts = Event::conflictEvents(event.id(),Conference::activeConference());
-                }
+                // event has became 'favourite' and so 'conflicts' list may have changed
+                conflicts = Event::conflictEvents(event.id(),Conference::activeConference());
 
                 // have to emit 'eventChanged' signal on all events in conflict
                 for(int i=0; i<conflicts.count(); i++)
@@ -99,7 +98,7 @@ bool TreeView::testForControlClicked(const QModelIndex &aIndex, const QPoint &aP
                 {
                     event.setHasAlarm(false); // update DB
 #ifdef MAEMO
-                    // remove alarm from the 'alarmd' alrms list
+                    // remove alarm from the 'alarmd' alarms list
                     Alarm alarm;
                     alarm.deleteAlarm(event.conferenceId(), event.id());
 #endif /* MAEMO */
@@ -110,7 +109,7 @@ bool TreeView::testForControlClicked(const QModelIndex &aIndex, const QPoint &aP
 #ifdef MAEMO
                     // add alarm to the 'alarmd'
                     Alarm alarm;
-                    alarm.addAlarm(event.conferenceId(), event.id(), event.title(),event.start().addSecs(PRE_EVENT_ALARM_SEC));
+                    alarm.addAlarm(event.conferenceId(), event.id(), event.title(),event.start().addSecs(-AppSettings::preEventAlarmSec()));
 #endif /* MAEMO */
                 }
                 event.update("alarm");