source: confclerk_git/src/gui/eventdialog.cpp @ 351728e

qt5
Last change on this file since 351728e was 351728e, checked in by gregor herrmann <gregoa@…>, 9 years ago

fix typo in comment

  • Property mode set to 100644
File size: 3.9 KB
Line 
1/*
2 * Copyright (C) 2010 Ixonos Plc.
3 * Copyright (C) 2011-2012 Philipp Spitzer, gregor herrmann, Stefan Stahl
4 *
5 * This file is part of ConfClerk.
6 *
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)
10 * any later version.
11 *
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
15 * more details.
16 *
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/>.
19 */
20#include "eventdialog.h"
21#include "conference.h"
22
23#include <QScrollBar>
24
25#ifdef MAEMO
26#include "alarm.h"
27#endif
28
29EventDialog::EventDialog(int conferenceId, int eventId, QWidget *parent): QDialog(parent), mConferenceId(conferenceId), mEventId(eventId) {
30    setupUi(this);
31
32#ifdef MAEMO
33    showFullScreen();
34#else
35    alarmButton->hide();
36#endif
37
38    Event event = Event::getById(mEventId, mConferenceId);
39
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/>"));
48
49    connect(favouriteButton, SIGNAL(clicked()), SLOT(favouriteClicked()));
50    connect(alarmButton, SIGNAL(clicked()), SLOT(alarmClicked()));
51
52    if(event.isFavourite())
53    {
54        favouriteButton->setIcon(QIcon(":/icons/favourite-on.png"));
55    }
56
57    if(event.hasAlarm())
58    {
59        alarmButton->setIcon(QIcon(":/icons/alarm-on.png"));
60    }
61}
62
63void EventDialog::favouriteClicked()
64{
65    Event event = Event::getById(mEventId, mConferenceId);
66
67    QList<Event> conflicts = Event::conflictEvents(event.id(), mConferenceId);
68    if(event.isFavourite())
69    {
70        event.setFavourite(false);
71        favouriteButton->setIcon(QIcon(":/icons/favourite-off.png"));
72    }
73    else
74    {
75        event.setFavourite(true);
76        favouriteButton->setIcon(QIcon(":/icons/favourite-on.png"));
77    }
78    event.update("favourite");
79
80    if(event.isFavourite())
81    {
82        // event has became 'favourite' and so 'conflicts' list may have changed
83        conflicts = Event::conflictEvents(event.id(), mConferenceId);
84    }
85
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);
89
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);
93}
94
95void EventDialog::alarmClicked()
96{
97    Event event = Event::getById(mEventId, mConferenceId);
98
99    if(event.hasAlarm())
100    {
101        event.setHasAlarm(false); // update DB
102        alarmButton->setIcon(QIcon(":/icons/alarm-off.png"));
103#ifdef MAEMO
104        // remove alarm from the 'alarmd' alarms list
105        Alarm alarm;
106        alarm.deleteAlarm(event.conferenceId(), event.id());
107        // TODO: test if removing was successfull
108#endif /* MAEMO */
109    }
110    else
111    {
112        event.setHasAlarm(true);
113        alarmButton->setIcon(QIcon(":/icons/alarm-on.png"));
114#ifdef MAEMO
115        // add alarm to the 'alarmd'
116        Alarm alarm;
117        alarm.addAlarm(event.conferenceId(), event.id(), event.title(), event.start().addSecs(PRE_EVENT_ALARM_SEC));
118#endif /* MAEMO */
119    }
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);
124}
125
Note: See TracBrowser for help on using the repository browser.