[ca90cb1] | 1 | /* |
---|
| 2 | * Copyright (C) 2010 Ixonos Plc. |
---|
[de5d0f1] | 3 | * Copyright (C) 2011-2017 Philipp Spitzer, gregor herrmann, Stefan Stahl |
---|
[ca90cb1] | 4 | * |
---|
[6df32f2] | 5 | * This file is part of ConfClerk. |
---|
[ca90cb1] | 6 | * |
---|
[6df32f2] | 7 | * ConfClerk is free software: you can redistribute it and/or modify it |
---|
[ca90cb1] | 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 | * |
---|
[6df32f2] | 12 | * ConfClerk is distributed in the hope that it will be useful, but |
---|
[ca90cb1] | 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 |
---|
[6df32f2] | 18 | * ConfClerk. If not, see <http://www.gnu.org/licenses/>. |
---|
[ca90cb1] | 19 | */ |
---|
[707cd31] | 20 | #include "eventdialog.h" |
---|
[11d3189] | 21 | #include "conference.h" |
---|
[707cd31] | 22 | |
---|
[1fe2f21] | 23 | #include <QScrollBar> |
---|
[395d6d3] | 24 | |
---|
[ce59092] | 25 | #ifdef MAEMO |
---|
[11d3189] | 26 | #include "alarm.h" |
---|
[5130dc7] | 27 | #include "appsettings.h" |
---|
[ce59092] | 28 | #endif |
---|
| 29 | |
---|
[8bd618c] | 30 | EventDialog::EventDialog(int conferenceId, int eventId, QWidget *parent): QDialog(parent), mConferenceId(conferenceId), mEventId(eventId) { |
---|
[707cd31] | 31 | setupUi(this); |
---|
[395d6d3] | 32 | |
---|
[842f5f9] | 33 | #ifdef MAEMO |
---|
| 34 | showFullScreen(); |
---|
| 35 | #endif |
---|
| 36 | |
---|
[8bd618c] | 37 | Event event = Event::getById(mEventId, mConferenceId); |
---|
[d4a8bbf] | 38 | |
---|
[1aede9a] | 39 | QString info; |
---|
| 40 | // title |
---|
[4b6ae6b] | 41 | info.append(QString("<h1>%1</h1>\n").arg(event.title().toHtmlEscaped())); |
---|
[1aede9a] | 42 | |
---|
| 43 | // persons |
---|
| 44 | info += QString("<h2>%1</h2>\n").arg(tr("Persons")); |
---|
[e249438] | 45 | QStringList persons = event.persons(); |
---|
[4b6ae6b] | 46 | for (int i = 0; i != persons.size(); ++i) persons[i] = persons[i].toHtmlEscaped(); |
---|
[e249438] | 47 | info += QString("<p>%1</p>\n").arg(persons.join(", ")); |
---|
[1aede9a] | 48 | |
---|
| 49 | // abstract |
---|
| 50 | info += QString("<h2>%1</h2>\n").arg(tr("Abstract")); |
---|
[8cb2bc7] | 51 | if (Qt::mightBeRichText(event.abstract())) { |
---|
| 52 | info += event.abstract(); |
---|
| 53 | } else { |
---|
| 54 | info += Qt::convertFromPlainText(event.abstract(), Qt::WhiteSpaceNormal); |
---|
| 55 | } |
---|
[1aede9a] | 56 | |
---|
| 57 | // description |
---|
| 58 | info += QString("<h2>%1</h2>\n").arg(tr("Description")); |
---|
[8cb2bc7] | 59 | if (Qt::mightBeRichText(event.description())) { |
---|
| 60 | info += event.description(); |
---|
| 61 | } else { |
---|
| 62 | info += Qt::convertFromPlainText(event.description(), Qt::WhiteSpaceNormal); |
---|
| 63 | } |
---|
[1aede9a] | 64 | |
---|
| 65 | // links |
---|
| 66 | info += QString("<h2>%1</h2>\n<ul>\n").arg(tr("Links")); |
---|
| 67 | QMapIterator<QString, QString> i(event.links()); |
---|
| 68 | while (i.hasNext()) { |
---|
| 69 | i.next(); |
---|
| 70 | QString url(i.value()); |
---|
| 71 | QString name(i.key()); |
---|
| 72 | if (url.isEmpty() || url == "http://") continue; |
---|
| 73 | if (name.isEmpty()) name = url; |
---|
[4b6ae6b] | 74 | info += QString("<li><a href=\"%1\">%2</a></li>\n").arg(url.toHtmlEscaped(), name.toHtmlEscaped()); |
---|
[1aede9a] | 75 | } |
---|
| 76 | info += QString("</ul>\n"); |
---|
| 77 | eventInfoTextBrowser->setHtml(info); |
---|
[ce59092] | 78 | |
---|
[055231b] | 79 | // make sure colours are the same as usual |
---|
| 80 | eventInfoTextBrowser->setPalette(qApp->palette()); |
---|
| 81 | // reduce font size, on maemo |
---|
| 82 | #ifdef MAEMO |
---|
| 83 | QFont font = eventInfoTextBrowser->font(); |
---|
| 84 | font.setPointSizeF(font.pointSizeF()*0.8); |
---|
| 85 | eventInfoTextBrowser->setFont(font); |
---|
| 86 | #endif |
---|
| 87 | |
---|
[ce59092] | 88 | connect(favouriteButton, SIGNAL(clicked()), SLOT(favouriteClicked())); |
---|
| 89 | connect(alarmButton, SIGNAL(clicked()), SLOT(alarmClicked())); |
---|
| 90 | |
---|
[7b3cd0e] | 91 | updateFavouriteButton(event); |
---|
[ce59092] | 92 | |
---|
| 93 | if(event.hasAlarm()) |
---|
| 94 | { |
---|
[accae6b] | 95 | alarmButton->setIcon(QIcon(":/icons/alarm-on.png")); |
---|
[ce59092] | 96 | } |
---|
| 97 | } |
---|
| 98 | |
---|
| 99 | void EventDialog::favouriteClicked() |
---|
| 100 | { |
---|
[8bd618c] | 101 | Event event = Event::getById(mEventId, mConferenceId); |
---|
[7b3cd0e] | 102 | event.cycleFavourite(); |
---|
[ce59092] | 103 | event.update("favourite"); |
---|
[7b3cd0e] | 104 | updateFavouriteButton(event); |
---|
[412cef6] | 105 | |
---|
[7b3cd0e] | 106 | // 'conflicts' list may have changed |
---|
| 107 | QList<Event> conflicts = Event::conflictEvents(event.id(), mConferenceId); |
---|
[412cef6] | 108 | |
---|
[c81f30a] | 109 | // have to emit 'eventChanged' signal on all events in conflict |
---|
[412cef6] | 110 | for(int i=0; i<conflicts.count(); i++) |
---|
[c81f30a] | 111 | emit eventChanged(conflicts[i].id(), false); |
---|
[872aeaa] | 112 | |
---|
| 113 | // since the Favourite icon has changed, update TreeViews accordingly |
---|
| 114 | // all TreeViews have to listen on this signal |
---|
[c81f30a] | 115 | emit eventChanged(event.id(), true); |
---|
[ce59092] | 116 | } |
---|
| 117 | |
---|
| 118 | void EventDialog::alarmClicked() |
---|
| 119 | { |
---|
[8bd618c] | 120 | Event event = Event::getById(mEventId, mConferenceId); |
---|
[ce59092] | 121 | |
---|
| 122 | if(event.hasAlarm()) |
---|
| 123 | { |
---|
| 124 | event.setHasAlarm(false); // update DB |
---|
[accae6b] | 125 | alarmButton->setIcon(QIcon(":/icons/alarm-off.png")); |
---|
[ce59092] | 126 | #ifdef MAEMO |
---|
[351728e] | 127 | // remove alarm from the 'alarmd' alarms list |
---|
[ce59092] | 128 | Alarm alarm; |
---|
[11d3189] | 129 | alarm.deleteAlarm(event.conferenceId(), event.id()); |
---|
[ce59092] | 130 | // TODO: test if removing was successfull |
---|
| 131 | #endif /* MAEMO */ |
---|
| 132 | } |
---|
| 133 | else |
---|
| 134 | { |
---|
| 135 | event.setHasAlarm(true); |
---|
[accae6b] | 136 | alarmButton->setIcon(QIcon(":/icons/alarm-on.png")); |
---|
[ce59092] | 137 | #ifdef MAEMO |
---|
| 138 | // add alarm to the 'alarmd' |
---|
| 139 | Alarm alarm; |
---|
[3a09de6] | 140 | alarm.addAlarm(event.conferenceId(), event.id(), event.title(), event.start().addSecs(-AppSettings::preEventAlarmSec())); |
---|
[ce59092] | 141 | #endif /* MAEMO */ |
---|
| 142 | } |
---|
| 143 | event.update("alarm"); |
---|
| 144 | // since the Alarm icon has changed, update TreeView accordingly |
---|
| 145 | // all TreeViews have to listen on this signal |
---|
[c81f30a] | 146 | emit eventChanged(event.id(), false); |
---|
[707cd31] | 147 | } |
---|
| 148 | |
---|
[7b3cd0e] | 149 | |
---|
| 150 | void EventDialog::updateFavouriteButton(const Event& event) { |
---|
| 151 | switch (event.favourite()) { |
---|
[81d87d7] | 152 | case Favourite_no: favouriteButton->setIcon(QIcon(":/icons/favourite-no.png")); break; |
---|
[7b3cd0e] | 153 | case Favourite_weak: favouriteButton->setIcon(QIcon(":/icons/favourite-weak.png")); break; |
---|
[81d87d7] | 154 | case Favourite_strong: favouriteButton->setIcon(QIcon(":/icons/favourite-strong.png")); break; |
---|
[7b3cd0e] | 155 | } |
---|
| 156 | } |
---|
| 157 | |
---|