[707cd31] | 1 | #include "eventdialog.h" |
---|
[0bb39f5] | 2 | #include <conference.h> |
---|
[707cd31] | 3 | |
---|
[1fe2f21] | 4 | #include <QScrollBar> |
---|
[395d6d3] | 5 | |
---|
[ce59092] | 6 | #ifdef MAEMO |
---|
| 7 | #include <alarm.h> |
---|
| 8 | #endif |
---|
| 9 | |
---|
[d4a8bbf] | 10 | EventDialog::EventDialog(const int &aEventId, QWidget *aParent) |
---|
[707cd31] | 11 | : QDialog(aParent) |
---|
[d4a8bbf] | 12 | , mEventId(aEventId) |
---|
[707cd31] | 13 | { |
---|
| 14 | setupUi(this); |
---|
[395d6d3] | 15 | |
---|
[842f5f9] | 16 | #ifdef MAEMO |
---|
| 17 | showFullScreen(); |
---|
| 18 | #endif |
---|
| 19 | |
---|
[0bb39f5] | 20 | Event event = Event::getById(mEventId,Conference::activeConference()); |
---|
[d4a8bbf] | 21 | |
---|
| 22 | title->setText(event.title()); |
---|
[1bcd66f] | 23 | persons->setText(event.persons().join(" and ")); |
---|
| 24 | abstract->setText(event.abstract()); |
---|
| 25 | description->setText(event.description()); |
---|
[6123b48] | 26 | links->setText(static_cast<QStringList>(event.links().values()).join("\n")); |
---|
[ce59092] | 27 | |
---|
| 28 | connect(favouriteButton, SIGNAL(clicked()), SLOT(favouriteClicked())); |
---|
| 29 | connect(alarmButton, SIGNAL(clicked()), SLOT(alarmClicked())); |
---|
| 30 | |
---|
| 31 | if(event.isFavourite()) |
---|
| 32 | { |
---|
| 33 | favouriteButton->setIcon(QIcon(":/icons/favourite-onBig.png")); |
---|
| 34 | } |
---|
| 35 | |
---|
| 36 | if(event.hasAlarm()) |
---|
| 37 | { |
---|
| 38 | alarmButton->setIcon(QIcon(":/icons/alarm-onBig.png")); |
---|
| 39 | } |
---|
| 40 | } |
---|
| 41 | |
---|
| 42 | void EventDialog::favouriteClicked() |
---|
| 43 | { |
---|
[0bb39f5] | 44 | Event event = Event::getById(mEventId,Conference::activeConference()); |
---|
[ce59092] | 45 | |
---|
| 46 | if(event.isFavourite()) |
---|
| 47 | { |
---|
| 48 | event.setFavourite(false); |
---|
| 49 | favouriteButton->setIcon(QIcon(":/icons/favourite-offBig.png")); |
---|
| 50 | } |
---|
| 51 | else |
---|
| 52 | { |
---|
| 53 | event.setFavourite(true); |
---|
| 54 | favouriteButton->setIcon(QIcon(":/icons/favourite-onBig.png")); |
---|
| 55 | } |
---|
| 56 | event.update("favourite"); |
---|
| 57 | qDebug() << " FAVOURITE [" << event.id() << "] -> " << event.isFavourite(); |
---|
| 58 | // update EVENT_CONFLICT table |
---|
| 59 | event.updateConflicts(); |
---|
| 60 | // since the Favourite icon has changed, update TreeViews accordingly |
---|
| 61 | // all TreeViews have to listen on this signal |
---|
| 62 | emit(eventHasChanged(event.id())); |
---|
| 63 | } |
---|
| 64 | |
---|
| 65 | void EventDialog::alarmClicked() |
---|
| 66 | { |
---|
[0bb39f5] | 67 | Event event = Event::getById(mEventId,Conference::activeConference()); |
---|
[ce59092] | 68 | |
---|
| 69 | if(event.hasAlarm()) |
---|
| 70 | { |
---|
| 71 | event.setHasAlarm(false); // update DB |
---|
| 72 | alarmButton->setIcon(QIcon(":/icons/alarm-offBig.png")); |
---|
| 73 | #ifdef MAEMO |
---|
| 74 | // remove alarm from the 'alarmd' alrms list |
---|
| 75 | Alarm alarm; |
---|
| 76 | alarm.deleteAlarm(event.id()); |
---|
| 77 | // TODO: test if removing was successfull |
---|
| 78 | #endif /* MAEMO */ |
---|
| 79 | } |
---|
| 80 | else |
---|
| 81 | { |
---|
| 82 | event.setHasAlarm(true); |
---|
| 83 | alarmButton->setIcon(QIcon(":/icons/alarm-onBig.png")); |
---|
| 84 | #ifdef MAEMO |
---|
| 85 | // add alarm to the 'alarmd' |
---|
| 86 | Alarm alarm; |
---|
| 87 | int cookie = alarm.addAlarm(event.id(),QDateTime::currentDateTime().addSecs(10)); |
---|
| 88 | qDebug() << "cookie: " << cookie; |
---|
| 89 | #endif /* MAEMO */ |
---|
| 90 | } |
---|
| 91 | event.update("alarm"); |
---|
| 92 | qDebug() << " ALARM [" << event.id() << "] -> " << event.hasAlarm(); |
---|
| 93 | // since the Alarm icon has changed, update TreeView accordingly |
---|
| 94 | // all TreeViews have to listen on this signal |
---|
| 95 | emit(eventHasChanged(event.id())); |
---|
[707cd31] | 96 | } |
---|
| 97 | |
---|