2 * Copyright (C) 2010 Ixonos Plc.
3 * Copyright (C) 2011-2013 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) {
36 Event event = Event::getById(mEventId, mConferenceId);
38 title->setText(event.title());
39 persons->setText(event.persons().join(" and "));
40 abstract->setText(event.abstract());
41 description->setText(event.description());
42 QStringList linksText = static_cast<QStringList>(event.links().values());
43 for (QStringList::iterator linkIterator = linksText.begin(); linkIterator != linksText.end(); ++linkIterator)
44 *linkIterator = QString("<a href=\"%1\">%1</a>").arg(*linkIterator);
45 links->setText(linksText.join("<br/>"));
47 connect(favouriteButton, SIGNAL(clicked()), SLOT(favouriteClicked()));
48 connect(alarmButton, SIGNAL(clicked()), SLOT(alarmClicked()));
50 if(event.isFavourite())
52 favouriteButton->setIcon(QIcon(":/icons/favourite-on.png"));
57 alarmButton->setIcon(QIcon(":/icons/alarm-on.png"));
61 void EventDialog::favouriteClicked()
63 Event event = Event::getById(mEventId, mConferenceId);
65 QList<Event> conflicts = Event::conflictEvents(event.id(), mConferenceId);
66 if(event.isFavourite())
68 event.setFavourite(false);
69 favouriteButton->setIcon(QIcon(":/icons/favourite-off.png"));
73 event.setFavourite(true);
74 favouriteButton->setIcon(QIcon(":/icons/favourite-on.png"));
76 event.update("favourite");
78 if(event.isFavourite())
80 // event has became 'favourite' and so 'conflicts' list may have changed
81 conflicts = Event::conflictEvents(event.id(), mConferenceId);
84 // have to emit 'eventChanged' signal on all events in conflict
85 for(int i=0; i<conflicts.count(); i++)
86 emit eventChanged(conflicts[i].id(), false);
88 // since the Favourite icon has changed, update TreeViews accordingly
89 // all TreeViews have to listen on this signal
90 emit eventChanged(event.id(), true);
93 void EventDialog::alarmClicked()
95 Event event = Event::getById(mEventId, mConferenceId);
99 event.setHasAlarm(false); // update DB
100 alarmButton->setIcon(QIcon(":/icons/alarm-off.png"));
102 // remove alarm from the 'alarmd' alarms list
104 alarm.deleteAlarm(event.conferenceId(), event.id());
105 // TODO: test if removing was successfull
110 event.setHasAlarm(true);
111 alarmButton->setIcon(QIcon(":/icons/alarm-on.png"));
113 // add alarm to the 'alarmd'
115 alarm.addAlarm(event.conferenceId(), event.id(), event.title(), event.start().addSecs(-AppSettings::preEventAlarmSec()));
118 event.update("alarm");
119 // since the Alarm icon has changed, update TreeView accordingly
120 // all TreeViews have to listen on this signal
121 emit eventChanged(event.id(), false);