source: src/gui/eventdialog.cpp @ 055231b

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

Eventdialog: make sure the same colours as everywhere are used.

Additionally adjust font size on maemo.

This should allow to close #48.

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