2 * Copyright (C) 2010 Ixonos Plc.
4 * This file is part of ConfClerk.
6 * ConfClerk is free software: you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License as published by the Free
8 * Software Foundation, either version 2 of the License, or (at your option)
11 * ConfClerk is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
13 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
16 * You should have received a copy of the GNU General Public License along with
17 * ConfClerk. If not, see <http://www.gnu.org/licenses/>.
19 #include "eventdialog.h"
20 #include <conference.h>
28 EventDialog::EventDialog(const int &aEventId, QWidget *aParent)
40 Event event = Event::getById(mEventId,Conference::activeConference());
42 title->setText(event.title());
43 persons->setText(event.persons().join(" and "));
44 abstract->setText(event.abstract());
45 description->setText(event.description());
46 links->setText(static_cast<QStringList>(event.links().values()).join("\n"));
48 connect(favouriteButton, SIGNAL(clicked()), SLOT(favouriteClicked()));
49 connect(alarmButton, SIGNAL(clicked()), SLOT(alarmClicked()));
51 if(event.isFavourite())
53 favouriteButton->setIcon(QIcon(":/icons/favourite-onBig.png"));
58 alarmButton->setIcon(QIcon(":/icons/alarm-onBig.png"));
62 void EventDialog::favouriteClicked()
64 Event event = Event::getById(mEventId,Conference::activeConference());
66 QList<Event> conflicts = Event::conflictEvents(event.id(),Conference::activeConference());
67 if(event.isFavourite())
69 event.setFavourite(false);
70 favouriteButton->setIcon(QIcon(":/icons/favourite-offBig.png"));
74 event.setFavourite(true);
75 favouriteButton->setIcon(QIcon(":/icons/favourite-onBig.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(),Conference::activeConference());
85 qDebug() << " FAVOURITE [" << event.id() << "] -> " << event.isFavourite();
87 // have to emit 'eventHasChanged' signal on all events in conflict
88 for(int i=0; i<conflicts.count(); i++)
89 emit(eventHasChanged(conflicts[i].id()));
91 // since the Favourite icon has changed, update TreeViews accordingly
92 // all TreeViews have to listen on this signal
93 emit(eventHasChanged(event.id(),true));
96 void EventDialog::alarmClicked()
98 Event event = Event::getById(mEventId,Conference::activeConference());
102 event.setHasAlarm(false); // update DB
103 alarmButton->setIcon(QIcon(":/icons/alarm-offBig.png"));
105 // remove alarm from the 'alarmd' alrms list
107 alarm.deleteAlarm(event.id());
108 // TODO: test if removing was successfull
113 event.setHasAlarm(true);
114 alarmButton->setIcon(QIcon(":/icons/alarm-onBig.png"));
116 // add alarm to the 'alarmd'
118 int cookie = alarm.addAlarm(event.id(),QDateTime::currentDateTime().addSecs(10));
119 qDebug() << "cookie: " << cookie;
122 event.update("alarm");
123 qDebug() << " ALARM [" << event.id() << "] -> " << event.hasAlarm();
124 // since the Alarm icon has changed, update TreeView accordingly
125 // all TreeViews have to listen on this signal
126 emit(eventHasChanged(event.id()));