Event 'details' dialog now contains also 'favourite' and 'alarm'
authorpavelpa <pavelpa@localhost>
Wed, 27 Jan 2010 11:36:29 +0000 (11:36 +0000)
committerpavelpa <pavelpa@localhost>
Wed, 27 Jan 2010 11:36:29 +0000 (11:36 +0000)
buttons, so the user can set/unset the property directly from the dialog

src/gui/eventdialog.cpp
src/gui/eventdialog.h
src/gui/eventdialog.ui
src/gui/tabcontainer.cpp

index 8d11d15..5202663 100644 (file)
@@ -3,6 +3,10 @@
 
 #include <QScrollBar>
 
+#ifdef MAEMO
+#include <alarm.h>
+#endif
+
 DetailsContainer::DetailsContainer(QWidget *aParent)
     : QWidget(aParent)
 {
@@ -55,12 +59,81 @@ EventDialog::EventDialog(const int &aEventId, QWidget *aParent)
     showFullScreen();
 #endif
 
-    Event event = Event::getById(aEventId,AppSettings::confId());
+    Event event = Event::getById(mEventId,AppSettings::confId());
 
     title->setText(event.title());
     mDetails.setPersons(event.persons());
     mDetails.setAbstract(event.abstract());
     mDetails.setDescription(event.description());
     scrollArea->setWidget(&mDetails);
+
+    connect(favouriteButton, SIGNAL(clicked()), SLOT(favouriteClicked()));
+    connect(alarmButton, SIGNAL(clicked()), SLOT(alarmClicked()));
+
+    if(event.isFavourite())
+    {
+        favouriteButton->setIcon(QIcon(":/icons/favourite-onBig.png"));
+    }
+
+    if(event.hasAlarm())
+    {
+        alarmButton->setIcon(QIcon(":/icons/alarm-onBig.png"));
+    }
+}
+
+void EventDialog::favouriteClicked()
+{
+    Event event = Event::getById(mEventId,AppSettings::confId());
+
+    if(event.isFavourite())
+    {
+        event.setFavourite(false);
+        favouriteButton->setIcon(QIcon(":/icons/favourite-offBig.png"));
+    }
+    else
+    {
+        event.setFavourite(true);
+        favouriteButton->setIcon(QIcon(":/icons/favourite-onBig.png"));
+    }
+    event.update("favourite");
+    qDebug() << " FAVOURITE [" << event.id() << "] -> " << event.isFavourite();
+    // update EVENT_CONFLICT table
+    event.updateConflicts();
+    // since the Favourite icon has changed, update TreeViews accordingly
+    // all TreeViews have to listen on this signal
+    emit(eventHasChanged(event.id()));
+}
+
+void EventDialog::alarmClicked()
+{
+    Event event = Event::getById(mEventId,AppSettings::confId());
+
+    if(event.hasAlarm())
+    {
+        event.setHasAlarm(false); // update DB
+        alarmButton->setIcon(QIcon(":/icons/alarm-offBig.png"));
+#ifdef MAEMO
+        // remove alarm from the 'alarmd' alrms list
+        Alarm alarm;
+        alarm.deleteAlarm(event.id());
+        // TODO: test if removing was successfull
+#endif /* MAEMO */
+    }
+    else
+    {
+        event.setHasAlarm(true);
+        alarmButton->setIcon(QIcon(":/icons/alarm-onBig.png"));
+#ifdef MAEMO
+        // add alarm to the 'alarmd'
+        Alarm alarm;
+        int cookie = alarm.addAlarm(event.id(),QDateTime::currentDateTime().addSecs(10));
+        qDebug() << "cookie: " << cookie;
+#endif /* MAEMO */
+    }
+    event.update("alarm");
+    qDebug() << " ALARM [" << event.id() << "] -> " << event.hasAlarm();
+    // since the Alarm icon has changed, update TreeView accordingly
+    // all TreeViews have to listen on this signal
+    emit(eventHasChanged(event.id()));
 }
 
index 0616fda..e9bb332 100644 (file)
@@ -19,12 +19,17 @@ private:
     QLabel mDescription;
 };
 
-
 class EventDialog : public QDialog, Ui::EventDialog
 { 
+    Q_OBJECT
 public:
     EventDialog(const int &aEventId, QWidget *aParent = NULL);
     ~EventDialog() {}
+private slots:
+    void favouriteClicked();
+    void alarmClicked();
+signals:
+    void eventHasChanged(int aEventId); // emited when user changes some event details, eg. sets it Favourite
 private:
     int mEventId;
     DetailsContainer mDetails;
index 3610861..fcc7f5c 100644 (file)
@@ -61,7 +61,7 @@
           <x>0</x>
           <y>0</y>
           <width>418</width>
-          <height>296</height>
+          <height>294</height>
          </rect>
         </property>
        </widget>
      </item>
      <item>
       <layout class="QHBoxLayout" name="horizontalLayout" >
+       <item>
+        <widget class="QToolButton" name="alarmButton" >
+         <property name="text" >
+          <string>...</string>
+         </property>
+         <property name="icon" >
+          <iconset resource="../icons.qrc" >
+           <normaloff>:/icons/alarm-offBig.png</normaloff>:/icons/alarm-offBig.png</iconset>
+         </property>
+        </widget>
+       </item>
+       <item>
+        <widget class="QToolButton" name="favouriteButton" >
+         <property name="text" >
+          <string>...</string>
+         </property>
+         <property name="icon" >
+          <iconset resource="../icons.qrc" >
+           <normaloff>:/icons/favourite-offBig.png</normaloff>:/icons/favourite-offBig.png</iconset>
+         </property>
+        </widget>
+       </item>
        <item>
         <spacer name="horizontalSpacer" >
          <property name="orientation" >
    </item>
   </layout>
  </widget>
- <resources/>
+ <resources>
+  <include location="../icons.qrc" />
+ </resources>
  <connections>
   <connection>
    <sender>okButton</sender>
index 993b9a2..3d3cc7b 100644 (file)
@@ -136,7 +136,9 @@ void TabContainer::itemClicked(const QModelIndex &aIndex)
         return;
 
     EventDialog dialog(static_cast<Event*>(aIndex.internalPointer())->id(),this);
+    connect(&dialog, SIGNAL(eventHasChanged(int)), this, SIGNAL(eventHasChanged(int)));
     dialog.exec();
+    disconnect(&dialog, SIGNAL(eventHasChanged(int)), this, SIGNAL(eventHasChanged(int)));
 }
 
 void TabContainer::displayMap(const QModelIndex &aIndex)