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);
41 info.append(QString("<h1>%1</h1>\n").arg(event.title()));
44 info += QString("<h2>%1</h2>\n").arg(tr("Persons"));
45 info += QString("<p>%1</p>\n").arg(event.persons().join(", "));
48 info += QString("<h2>%1</h2>\n").arg(tr("Abstract"));
49 info += QString("<p>%1</p>\n").arg(event.abstract());
52 info += QString("<h2>%1</h2>\n").arg(tr("Description"));
53 info += QString("<p>%1</p>\n").arg(event.description());
56 info += QString("<h2>%1</h2>\n<ul>\n").arg(tr("Links"));
57 QMapIterator<QString, QString> i(event.links());
60 QString url(i.value());
61 QString name(i.key());
62 if (url.isEmpty() || url == "http://") continue;
63 if (name.isEmpty()) name = url;
64 info += QString("<li><a href=\"%1\">%2</a></li>\n").arg(url, name);
66 info += QString("</ul>\n");
67 eventInfoTextBrowser->setHtml(info);
69 connect(favouriteButton, SIGNAL(clicked()), SLOT(favouriteClicked()));
70 connect(alarmButton, SIGNAL(clicked()), SLOT(alarmClicked()));
72 if(event.isFavourite())
74 favouriteButton->setIcon(QIcon(":/icons/favourite-on.png"));
79 alarmButton->setIcon(QIcon(":/icons/alarm-on.png"));
83 void EventDialog::favouriteClicked()
85 Event event = Event::getById(mEventId, mConferenceId);
87 QList<Event> conflicts = Event::conflictEvents(event.id(), mConferenceId);
88 if(event.isFavourite())
90 event.setFavourite(false);
91 favouriteButton->setIcon(QIcon(":/icons/favourite-off.png"));
95 event.setFavourite(true);
96 favouriteButton->setIcon(QIcon(":/icons/favourite-on.png"));
98 event.update("favourite");
100 if(event.isFavourite())
102 // event has became 'favourite' and so 'conflicts' list may have changed
103 conflicts = Event::conflictEvents(event.id(), mConferenceId);
106 // have to emit 'eventChanged' signal on all events in conflict
107 for(int i=0; i<conflicts.count(); i++)
108 emit eventChanged(conflicts[i].id(), false);
110 // since the Favourite icon has changed, update TreeViews accordingly
111 // all TreeViews have to listen on this signal
112 emit eventChanged(event.id(), true);
115 void EventDialog::alarmClicked()
117 Event event = Event::getById(mEventId, mConferenceId);
121 event.setHasAlarm(false); // update DB
122 alarmButton->setIcon(QIcon(":/icons/alarm-off.png"));
124 // remove alarm from the 'alarmd' alarms list
126 alarm.deleteAlarm(event.conferenceId(), event.id());
127 // TODO: test if removing was successfull
132 event.setHasAlarm(true);
133 alarmButton->setIcon(QIcon(":/icons/alarm-on.png"));
135 // add alarm to the 'alarmd'
137 alarm.addAlarm(event.conferenceId(), event.id(), event.title(), event.start().addSecs(-AppSettings::preEventAlarmSec()));
140 event.update("alarm");
141 // since the Alarm icon has changed, update TreeView accordingly
142 // all TreeViews have to listen on this signal
143 emit eventChanged(event.id(), false);