2 * Copyright (C) 2010 Ixonos Plc.
3 * Copyright (C) 2011-2012 Philipp Spitzer, gregor herrmann, Stefan Stahl
5 * This file is part of ConfClerk.
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)
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
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/>.
20 #include "eventdialog.h"
21 #include "conference.h"
29 EventDialog::EventDialog(int conferenceId, int eventId, QWidget *parent): QDialog(parent), mConferenceId(conferenceId), mEventId(eventId) {
38 Event event = Event::getById(mEventId, mConferenceId);
40 title->setText(event.title());
41 persons->setText(event.persons().join(" and "));
42 abstract->setText(event.abstract());
43 description->setText(event.description());
44 QStringList linksText = static_cast<QStringList>(event.links().values());
45 for (QStringList::iterator linkIterator = linksText.begin(); linkIterator != linksText.end(); ++linkIterator)
46 *linkIterator = QString("<a href=\"%1\">%1</a>").arg(*linkIterator);
47 links->setText(linksText.join("<br/>"));
49 connect(favouriteButton, SIGNAL(clicked()), SLOT(favouriteClicked()));
50 connect(alarmButton, SIGNAL(clicked()), SLOT(alarmClicked()));
52 if(event.isFavourite())
54 favouriteButton->setIcon(QIcon(":/icons/favourite-on.png"));
59 alarmButton->setIcon(QIcon(":/icons/alarm-on.png"));
63 void EventDialog::favouriteClicked()
65 Event event = Event::getById(mEventId, mConferenceId);
67 QList<Event> conflicts = Event::conflictEvents(event.id(), mConferenceId);
68 if(event.isFavourite())
70 event.setFavourite(false);
71 favouriteButton->setIcon(QIcon(":/icons/favourite-off.png"));
75 event.setFavourite(true);
76 favouriteButton->setIcon(QIcon(":/icons/favourite-on.png"));
78 event.update("favourite");
80 if(event.isFavourite())
82 // event has became 'favourite' and so 'conflicts' list may have changed
83 conflicts = Event::conflictEvents(event.id(), mConferenceId);
86 // have to emit 'eventChanged' signal on all events in conflict
87 for(int i=0; i<conflicts.count(); i++)
88 emit eventChanged(conflicts[i].id(), false);
90 // since the Favourite icon has changed, update TreeViews accordingly
91 // all TreeViews have to listen on this signal
92 emit eventChanged(event.id(), true);
95 void EventDialog::alarmClicked()
97 Event event = Event::getById(mEventId, mConferenceId);
101 event.setHasAlarm(false); // update DB
102 alarmButton->setIcon(QIcon(":/icons/alarm-off.png"));
104 // remove alarm from the 'alarmd' alarms list
106 alarm.deleteAlarm(event.conferenceId(), event.id());
107 // TODO: test if removing was successfull
112 event.setHasAlarm(true);
113 alarmButton->setIcon(QIcon(":/icons/alarm-on.png"));
115 // add alarm to the 'alarmd'
117 alarm.addAlarm(event.conferenceId(), event.id(), event.title(), event.start().addSecs(PRE_EVENT_ALARM_SEC));
120 event.update("alarm");
121 // since the Alarm icon has changed, update TreeView accordingly
122 // all TreeViews have to listen on this signal
123 emit eventChanged(event.id(), false);