1 | /* |
---|
2 | * Copyright (C) 2010 Ixonos Plc. |
---|
3 | * |
---|
4 | * This file is part of ConfClerk. |
---|
5 | * |
---|
6 | * ConfClerk is free software: you can redistribute it and/or modify it |
---|
7 | * under the terms of the GNU General Public License as published by the Free |
---|
8 | * Software Foundation, either version 2 of the License, or (at your option) |
---|
9 | * any later version. |
---|
10 | * |
---|
11 | * ConfClerk is distributed in the hope that it will be useful, but |
---|
12 | * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY |
---|
13 | * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for |
---|
14 | * more details. |
---|
15 | * |
---|
16 | * You should have received a copy of the GNU General Public License along with |
---|
17 | * ConfClerk. If not, see <http://www.gnu.org/licenses/>. |
---|
18 | */ |
---|
19 | #include "eventdialog.h" |
---|
20 | #include <conference.h> |
---|
21 | |
---|
22 | #include <QScrollBar> |
---|
23 | |
---|
24 | #ifdef MAEMO |
---|
25 | #include <alarm.h> |
---|
26 | #endif |
---|
27 | |
---|
28 | EventDialog::EventDialog(const int &aEventId, QWidget *aParent) |
---|
29 | : QDialog(aParent) |
---|
30 | , mEventId(aEventId) |
---|
31 | { |
---|
32 | setupUi(this); |
---|
33 | |
---|
34 | #ifdef MAEMO |
---|
35 | showFullScreen(); |
---|
36 | #else |
---|
37 | alarmButton->hide(); |
---|
38 | #endif |
---|
39 | |
---|
40 | Event event = Event::getById(mEventId,Conference::activeConference()); |
---|
41 | |
---|
42 | title->setText(event.title()); |
---|
43 | persons->setText(event.persons().join(" and ")); |
---|
44 | abstract->setText(event.abstract()); |
---|
45 | description->setText(event.description()); |
---|
46 | links->setText(static_cast<QStringList>(event.links().values()).join("\n")); |
---|
47 | |
---|
48 | connect(favouriteButton, SIGNAL(clicked()), SLOT(favouriteClicked())); |
---|
49 | connect(alarmButton, SIGNAL(clicked()), SLOT(alarmClicked())); |
---|
50 | |
---|
51 | if(event.isFavourite()) |
---|
52 | { |
---|
53 | favouriteButton->setIcon(QIcon(":/icons/favourite-onBig.png")); |
---|
54 | } |
---|
55 | |
---|
56 | if(event.hasAlarm()) |
---|
57 | { |
---|
58 | alarmButton->setIcon(QIcon(":/icons/alarm-onBig.png")); |
---|
59 | } |
---|
60 | } |
---|
61 | |
---|
62 | void EventDialog::favouriteClicked() |
---|
63 | { |
---|
64 | Event event = Event::getById(mEventId,Conference::activeConference()); |
---|
65 | |
---|
66 | QList<Event> conflicts = Event::conflictEvents(event.id(),Conference::activeConference()); |
---|
67 | if(event.isFavourite()) |
---|
68 | { |
---|
69 | event.setFavourite(false); |
---|
70 | favouriteButton->setIcon(QIcon(":/icons/favourite-offBig.png")); |
---|
71 | } |
---|
72 | else |
---|
73 | { |
---|
74 | event.setFavourite(true); |
---|
75 | favouriteButton->setIcon(QIcon(":/icons/favourite-onBig.png")); |
---|
76 | } |
---|
77 | event.update("favourite"); |
---|
78 | |
---|
79 | if(event.isFavourite()) |
---|
80 | { |
---|
81 | // event has became 'favourite' and so 'conflicts' list may have changed |
---|
82 | conflicts = Event::conflictEvents(event.id(),Conference::activeConference()); |
---|
83 | } |
---|
84 | |
---|
85 | qDebug() << " FAVOURITE [" << event.id() << "] -> " << event.isFavourite(); |
---|
86 | |
---|
87 | // have to emit 'eventHasChanged' signal on all events in conflict |
---|
88 | for(int i=0; i<conflicts.count(); i++) |
---|
89 | emit(eventHasChanged(conflicts[i].id())); |
---|
90 | |
---|
91 | // since the Favourite icon has changed, update TreeViews accordingly |
---|
92 | // all TreeViews have to listen on this signal |
---|
93 | emit(eventHasChanged(event.id(),true)); |
---|
94 | } |
---|
95 | |
---|
96 | void EventDialog::alarmClicked() |
---|
97 | { |
---|
98 | Event event = Event::getById(mEventId,Conference::activeConference()); |
---|
99 | |
---|
100 | if(event.hasAlarm()) |
---|
101 | { |
---|
102 | event.setHasAlarm(false); // update DB |
---|
103 | alarmButton->setIcon(QIcon(":/icons/alarm-offBig.png")); |
---|
104 | #ifdef MAEMO |
---|
105 | // remove alarm from the 'alarmd' alrms list |
---|
106 | Alarm alarm; |
---|
107 | alarm.deleteAlarm(event.id()); |
---|
108 | // TODO: test if removing was successfull |
---|
109 | #endif /* MAEMO */ |
---|
110 | } |
---|
111 | else |
---|
112 | { |
---|
113 | event.setHasAlarm(true); |
---|
114 | alarmButton->setIcon(QIcon(":/icons/alarm-onBig.png")); |
---|
115 | #ifdef MAEMO |
---|
116 | // add alarm to the 'alarmd' |
---|
117 | Alarm alarm; |
---|
118 | int cookie = alarm.addAlarm(event.id(),QDateTime::currentDateTime().addSecs(10)); |
---|
119 | qDebug() << "cookie: " << cookie; |
---|
120 | #endif /* MAEMO */ |
---|
121 | } |
---|
122 | event.update("alarm"); |
---|
123 | qDebug() << " ALARM [" << event.id() << "] -> " << event.hasAlarm(); |
---|
124 | // since the Alarm icon has changed, update TreeView accordingly |
---|
125 | // all TreeViews have to listen on this signal |
---|
126 | emit(eventHasChanged(event.id())); |
---|
127 | } |
---|
128 | |
---|