From: pavelpa Date: Wed, 27 Jan 2010 11:36:29 +0000 (+0000) Subject: Event 'details' dialog now contains also 'favourite' and 'alarm' X-Git-Tag: 0.5.0~178 X-Git-Url: https://git.toastfreeware.priv.at/toast/confclerk.git/commitdiff_plain/ce590923dea8a02805b45b9a93852a0041d34ed1?hp=6bc425e607bb0d7b444f28eaeb0d3d96672d2ffb Event 'details' dialog now contains also 'favourite' and 'alarm' buttons, so the user can set/unset the property directly from the dialog --- diff --git a/src/gui/eventdialog.cpp b/src/gui/eventdialog.cpp index 8d11d15..5202663 100644 --- a/src/gui/eventdialog.cpp +++ b/src/gui/eventdialog.cpp @@ -3,6 +3,10 @@ #include +#ifdef MAEMO +#include +#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())); } diff --git a/src/gui/eventdialog.h b/src/gui/eventdialog.h index 0616fda..e9bb332 100644 --- a/src/gui/eventdialog.h +++ b/src/gui/eventdialog.h @@ -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; diff --git a/src/gui/eventdialog.ui b/src/gui/eventdialog.ui index 3610861..fcc7f5c 100644 --- a/src/gui/eventdialog.ui +++ b/src/gui/eventdialog.ui @@ -61,7 +61,7 @@ 0 0 418 - 296 + 294 @@ -69,6 +69,28 @@ + + + + ... + + + + :/icons/alarm-offBig.png:/icons/alarm-offBig.png + + + + + + + ... + + + + :/icons/favourite-offBig.png:/icons/favourite-offBig.png + + + @@ -95,7 +117,9 @@ - + + + okButton diff --git a/src/gui/tabcontainer.cpp b/src/gui/tabcontainer.cpp index 993b9a2..3d3cc7b 100644 --- a/src/gui/tabcontainer.cpp +++ b/src/gui/tabcontainer.cpp @@ -136,7 +136,9 @@ void TabContainer::itemClicked(const QModelIndex &aIndex) return; EventDialog dialog(static_cast(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)