source: src/gui/eventdialog.cpp @ 11f3f87

qt5
Last change on this file since 11f3f87 was 11f3f87, checked in by gregor herrmann <gregoa@…>, 8 years ago

Update copyright notices.

  • Property mode set to 100644
File size: 4.9 KB
Line 
1/*
2 * Copyright (C) 2010 Ixonos Plc.
3 * Copyright (C) 2011-2014 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#include "appsettings.h"
28#endif
29
30EventDialog::EventDialog(int conferenceId, int eventId, QWidget *parent): QDialog(parent), mConferenceId(conferenceId), mEventId(eventId) {
31    setupUi(this);
32
33#ifdef MAEMO
34    showFullScreen();
35#endif
36
37    Event event = Event::getById(mEventId, mConferenceId);
38
39    QString info;
40    // title
41    info.append(QString("<h1>%1</h1>\n").arg(Qt::escape(event.title())));
42
43    // persons
44    info += QString("<h2>%1</h2>\n").arg(tr("Persons"));
45    QStringList persons = event.persons();
46    for (int i = 0; i != persons.size(); ++i) persons[i] = Qt::escape(persons[i]);
47    info += QString("<p>%1</p>\n").arg(persons.join(", "));
48
49    // abstract
50    info += QString("<h2>%1</h2>\n").arg(tr("Abstract"));
51    info += Qt::convertFromPlainText(event.abstract(), Qt::WhiteSpaceNormal);
52
53    // description
54    info += QString("<h2>%1</h2>\n").arg(tr("Description"));
55    info += Qt::convertFromPlainText(event.description(), Qt::WhiteSpaceNormal);
56
57    // links
58    info += QString("<h2>%1</h2>\n<ul>\n").arg(tr("Links"));
59    QMapIterator<QString, QString> i(event.links());
60    while (i.hasNext()) {
61        i.next();
62        QString url(i.value());
63        QString name(i.key());
64        if (url.isEmpty() || url == "http://") continue;
65        if (name.isEmpty()) name = url;
66        info += QString("<li><a href=\"%1\">%2</a></li>\n").arg(Qt::escape(url), Qt::escape(name));
67    }
68    info += QString("</ul>\n");
69    eventInfoTextBrowser->setHtml(info);
70
71    // make sure colours are the same as usual
72    eventInfoTextBrowser->setPalette(qApp->palette());
73    // reduce font size, on maemo
74#ifdef MAEMO
75    QFont font = eventInfoTextBrowser->font();
76    font.setPointSizeF(font.pointSizeF()*0.8);
77    eventInfoTextBrowser->setFont(font);
78#endif
79
80    connect(favouriteButton, SIGNAL(clicked()), SLOT(favouriteClicked()));
81    connect(alarmButton, SIGNAL(clicked()), SLOT(alarmClicked()));
82
83    if(event.isFavourite())
84    {
85        favouriteButton->setIcon(QIcon(":/icons/favourite-on.png"));
86    }
87
88    if(event.hasAlarm())
89    {
90        alarmButton->setIcon(QIcon(":/icons/alarm-on.png"));
91    }
92}
93
94void EventDialog::favouriteClicked()
95{
96    Event event = Event::getById(mEventId, mConferenceId);
97
98    QList<Event> conflicts = Event::conflictEvents(event.id(), mConferenceId);
99    if(event.isFavourite())
100    {
101        event.setFavourite(false);
102        favouriteButton->setIcon(QIcon(":/icons/favourite-off.png"));
103    }
104    else
105    {
106        event.setFavourite(true);
107        favouriteButton->setIcon(QIcon(":/icons/favourite-on.png"));
108    }
109    event.update("favourite");
110
111    if(event.isFavourite())
112    {
113        // event has became 'favourite' and so 'conflicts' list may have changed
114        conflicts = Event::conflictEvents(event.id(), mConferenceId);
115    }
116
117    // have to emit 'eventChanged' signal on all events in conflict
118    for(int i=0; i<conflicts.count(); i++)
119        emit eventChanged(conflicts[i].id(), false);
120
121    // since the Favourite icon has changed, update TreeViews accordingly
122    // all TreeViews have to listen on this signal
123    emit eventChanged(event.id(), true);
124}
125
126void EventDialog::alarmClicked()
127{
128    Event event = Event::getById(mEventId, mConferenceId);
129
130    if(event.hasAlarm())
131    {
132        event.setHasAlarm(false); // update DB
133        alarmButton->setIcon(QIcon(":/icons/alarm-off.png"));
134#ifdef MAEMO
135        // remove alarm from the 'alarmd' alarms list
136        Alarm alarm;
137        alarm.deleteAlarm(event.conferenceId(), event.id());
138        // TODO: test if removing was successfull
139#endif /* MAEMO */
140    }
141    else
142    {
143        event.setHasAlarm(true);
144        alarmButton->setIcon(QIcon(":/icons/alarm-on.png"));
145#ifdef MAEMO
146        // add alarm to the 'alarmd'
147        Alarm alarm;
148        alarm.addAlarm(event.conferenceId(), event.id(), event.title(), event.start().addSecs(-AppSettings::preEventAlarmSec()));
149#endif /* MAEMO */
150    }
151    event.update("alarm");
152    // since the Alarm icon has changed, update TreeView accordingly
153    // all TreeViews have to listen on this signal
154    emit eventChanged(event.id(), false);
155}
156
Note: See TracBrowser for help on using the repository browser.