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