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"
27 #include "appsettings.h"
30 EventDialog::EventDialog(int conferenceId, int eventId, QWidget *parent): QDialog(parent), mConferenceId(conferenceId), mEventId(eventId) {
37 Event event = Event::getById(mEventId, mConferenceId);
39 title->setText(event.title());
40 persons->setText(event.persons().join(" and "));
41 abstract->setText(event.abstract());
42 description->setText(event.description());
43 QStringList linksText = static_cast<QStringList>(event.links().values());
44 for (QStringList::iterator linkIterator = linksText.begin(); linkIterator != linksText.end(); ++linkIterator)
45 *linkIterator = QString("<a href=\"%1\">%1</a>").arg(*linkIterator);
46 links->setText(linksText.join("<br/>"));
48 connect(favouriteButton, SIGNAL(clicked()), SLOT(favouriteClicked()));
49 connect(alarmButton, SIGNAL(clicked()), SLOT(alarmClicked()));
51 if(event.isFavourite())
53 favouriteButton->setIcon(QIcon(":/icons/favourite-on.png"));
58 alarmButton->setIcon(QIcon(":/icons/alarm-on.png"));
62 void EventDialog::favouriteClicked()
64 Event event = Event::getById(mEventId, mConferenceId);
66 QList<Event> conflicts = Event::conflictEvents(event.id(), mConferenceId);
67 if(event.isFavourite())
69 event.setFavourite(false);
70 favouriteButton->setIcon(QIcon(":/icons/favourite-off.png"));
74 event.setFavourite(true);
75 favouriteButton->setIcon(QIcon(":/icons/favourite-on.png"));
77 event.update("favourite");
79 if(event.isFavourite())
81 // event has became 'favourite' and so 'conflicts' list may have changed
82 conflicts = Event::conflictEvents(event.id(), mConferenceId);
85 // have to emit 'eventChanged' signal on all events in conflict
86 for(int i=0; i<conflicts.count(); i++)
87 emit eventChanged(conflicts[i].id(), false);
89 // since the Favourite icon has changed, update TreeViews accordingly
90 // all TreeViews have to listen on this signal
91 emit eventChanged(event.id(), true);
94 void EventDialog::alarmClicked()
96 Event event = Event::getById(mEventId, mConferenceId);
100 event.setHasAlarm(false); // update DB
101 alarmButton->setIcon(QIcon(":/icons/alarm-off.png"));
103 // remove alarm from the 'alarmd' alarms list
105 alarm.deleteAlarm(event.conferenceId(), event.id());
106 // TODO: test if removing was successfull
111 event.setHasAlarm(true);
112 alarmButton->setIcon(QIcon(":/icons/alarm-on.png"));
114 // add alarm to the 'alarmd'
116 alarm.addAlarm(event.conferenceId(), event.id(), event.title(), event.start().addSecs(-AppSettings::preEventAlarmSec()));
119 event.update("alarm");
120 // since the Alarm icon has changed, update TreeView accordingly
121 // all TreeViews have to listen on this signal
122 emit eventChanged(event.id(), false);