source: src/gui/eventdialog.cpp @ 6df32f2

qt5
Last change on this file since 6df32f2 was 6df32f2, checked in by gregor herrmann <gregoa@…>, 10 years ago

Update GPL blurb in source files.

  • Property mode set to 100644
File size: 3.8 KB
RevLine 
[ca90cb1]1/*
2 * Copyright (C) 2010 Ixonos Plc.
3 *
[6df32f2]4 * This file is part of ConfClerk.
[ca90cb1]5 *
[6df32f2]6 * ConfClerk is free software: you can redistribute it and/or modify it
[ca90cb1]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)
9 * any later version.
10 *
[6df32f2]11 * ConfClerk is distributed in the hope that it will be useful, but
[ca90cb1]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
14 * more details.
15 *
16 * You should have received a copy of the GNU General Public License along with
[6df32f2]17 * ConfClerk.  If not, see <http://www.gnu.org/licenses/>.
[ca90cb1]18 */
[707cd31]19#include "eventdialog.h"
[0bb39f5]20#include <conference.h>
[707cd31]21
[1fe2f21]22#include <QScrollBar>
[395d6d3]23
[ce59092]24#ifdef MAEMO
25#include <alarm.h>
26#endif
27
[d4a8bbf]28EventDialog::EventDialog(const int &aEventId, QWidget *aParent)
[707cd31]29    : QDialog(aParent)
[d4a8bbf]30    , mEventId(aEventId)
[707cd31]31{
32    setupUi(this);
[395d6d3]33
[842f5f9]34#ifdef MAEMO
35    showFullScreen();
[bc88043]36#else
37    alarmButton->hide();
[842f5f9]38#endif
39
[0bb39f5]40    Event event = Event::getById(mEventId,Conference::activeConference());
[d4a8bbf]41
42    title->setText(event.title());
[1bcd66f]43    persons->setText(event.persons().join(" and "));
44    abstract->setText(event.abstract());
45    description->setText(event.description());
[6123b48]46    links->setText(static_cast<QStringList>(event.links().values()).join("\n"));
[ce59092]47
48    connect(favouriteButton, SIGNAL(clicked()), SLOT(favouriteClicked()));
49    connect(alarmButton, SIGNAL(clicked()), SLOT(alarmClicked()));
50
51    if(event.isFavourite())
52    {
53        favouriteButton->setIcon(QIcon(":/icons/favourite-onBig.png"));
54    }
55
56    if(event.hasAlarm())
57    {
58        alarmButton->setIcon(QIcon(":/icons/alarm-onBig.png"));
59    }
60}
61
62void EventDialog::favouriteClicked()
63{
[0bb39f5]64    Event event = Event::getById(mEventId,Conference::activeConference());
[ce59092]65
[412cef6]66    QList<Event> conflicts = Event::conflictEvents(event.id(),Conference::activeConference());
[ce59092]67    if(event.isFavourite())
68    {
69        event.setFavourite(false);
70        favouriteButton->setIcon(QIcon(":/icons/favourite-offBig.png"));
71    }
72    else
73    {
74        event.setFavourite(true);
75        favouriteButton->setIcon(QIcon(":/icons/favourite-onBig.png"));
76    }
77    event.update("favourite");
[412cef6]78
79    if(event.isFavourite())
80    {
81        // event has became 'favourite' and so 'conflicts' list may have changed
82        conflicts = Event::conflictEvents(event.id(),Conference::activeConference());
83    }
84
[ce59092]85    qDebug() << " FAVOURITE [" << event.id() << "] -> " << event.isFavourite();
[412cef6]86
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()));
[872aeaa]90
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));
[ce59092]94}
95
96void EventDialog::alarmClicked()
97{
[0bb39f5]98    Event event = Event::getById(mEventId,Conference::activeConference());
[ce59092]99
100    if(event.hasAlarm())
101    {
102        event.setHasAlarm(false); // update DB
103        alarmButton->setIcon(QIcon(":/icons/alarm-offBig.png"));
104#ifdef MAEMO
105        // remove alarm from the 'alarmd' alrms list
106        Alarm alarm;
107        alarm.deleteAlarm(event.id());
108        // TODO: test if removing was successfull
109#endif /* MAEMO */
110    }
111    else
112    {
113        event.setHasAlarm(true);
114        alarmButton->setIcon(QIcon(":/icons/alarm-onBig.png"));
115#ifdef MAEMO
116        // add alarm to the 'alarmd'
117        Alarm alarm;
118        int cookie = alarm.addAlarm(event.id(),QDateTime::currentDateTime().addSecs(10));
119        qDebug() << "cookie: " << cookie;
120#endif /* MAEMO */
121    }
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()));
[707cd31]127}
128
Note: See TracBrowser for help on using the repository browser.