Alarm dbus connection added
[toast/confclerk.git] / src / mvc / treeview.cpp
index f907830..5fd63ee 100644 (file)
@@ -32,13 +32,14 @@ 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)
 {
     bool handled = false;
 
     if(!aIndex.isValid())
         return handled;
 
+    int confId = Conference::activeConference();
     QRect rect = visualRect(aIndex); // visual QRect of selected/clicked item in the list
     Delegate *delegate = static_cast<Delegate*>(itemDelegate(aIndex));
     switch(delegate->whichControlClicked(aIndex,aPoint))
@@ -47,7 +48,7 @@ bool TreeView::testForControlClicked(const QModelIndex &aIndex, const QPoint &aP
         case Delegate::FavouriteControlOff:
             {
                 // handle Favourite Control clicked
-                Event event = Event::getById(aIndex.data().toInt(),1);
+                Event event = Event::getById(aIndex.data().toInt(),confId);
 
                 QList<Event> conflicts = Event::conflictEvents(event.id(),Conference::activeConference());
                 if(event.isFavourite())
@@ -67,7 +68,7 @@ bool TreeView::testForControlClicked(const QModelIndex &aIndex, const QPoint &aP
                 // have to emit 'eventHasChanged' signal on all events in conflict
                 for(int i=0; i<conflicts.count(); i++)
                     emit(eventHasChanged(conflicts[i].id()));
-                
+
                 // since the Favourite icon has changed, update TreeViews accordingly
                 // all TreeViews have to listen on this signal
                 emit(eventHasChanged(event.id(),true));
@@ -79,7 +80,7 @@ bool TreeView::testForControlClicked(const QModelIndex &aIndex, const QPoint &aP
         case Delegate::AlarmControlOff:
             {
                 // handle Alarm Control clicked
-                Event event = Event::getById(aIndex.data().toInt(),1);
+                Event event = Event::getById(aIndex.data().toInt(),confId);
                 if(event.hasAlarm())
                 {
                     event.setHasAlarm(false); // update DB
@@ -96,7 +97,8 @@ bool TreeView::testForControlClicked(const QModelIndex &aIndex, const QPoint &aP
 #ifdef MAEMO
                     // add alarm to the 'alarmd'
                     Alarm alarm;
-                    int cookie = alarm.addAlarm(event.id(),QDateTime::currentDateTime().addSecs(10));
+                    //int cookie = alarm.addAlarm(event.id(),QDateTime::currentDateTime().addSecs(10)); // testing
+                    int cookie = alarm.addAlarm(event.id(),event.start().addSecs(-15*60)); // 15 minutes before real start
                     qDebug() << "cookie: " << cookie;
 #endif /* MAEMO */
                 }
@@ -139,7 +141,7 @@ void TreeView::handleItemClicked(const QModelIndex &index)
 {
     if(!index.parent().isValid()) // time-group
     {
-        if(isExpanded(index)) 
+        if(isExpanded(index))
             setExpanded(index, false);
         else
             setExpanded(index, true);