source: src/gui/eventdialog.cpp @ dcefa71

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

Add copyright to source.

  • Property mode set to 100644
File size: 3.9 KB
RevLine 
[ca90cb1]1/*
2 * Copyright (C) 2010 Ixonos Plc.
[68b2df2]3 * Copyright (C) 2011 Philipp Spitzer, gregor herrmann
[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"
[0bb39f5]21#include <conference.h>
[707cd31]22
[1fe2f21]23#include <QScrollBar>
[395d6d3]24
[ce59092]25#ifdef MAEMO
26#include <alarm.h>
27#endif
28
[d4a8bbf]29EventDialog::EventDialog(const int &aEventId, QWidget *aParent)
[707cd31]30    : QDialog(aParent)
[d4a8bbf]31    , mEventId(aEventId)
[707cd31]32{
33    setupUi(this);
[395d6d3]34
[842f5f9]35#ifdef MAEMO
36    showFullScreen();
[bc88043]37#else
38    alarmButton->hide();
[842f5f9]39#endif
40
[0bb39f5]41    Event event = Event::getById(mEventId,Conference::activeConference());
[d4a8bbf]42
43    title->setText(event.title());
[1bcd66f]44    persons->setText(event.persons().join(" and "));
45    abstract->setText(event.abstract());
46    description->setText(event.description());
[6123b48]47    links->setText(static_cast<QStringList>(event.links().values()).join("\n"));
[ce59092]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-onBig.png"));
55    }
56
57    if(event.hasAlarm())
58    {
59        alarmButton->setIcon(QIcon(":/icons/alarm-onBig.png"));
60    }
61}
62
63void EventDialog::favouriteClicked()
64{
[0bb39f5]65    Event event = Event::getById(mEventId,Conference::activeConference());
[ce59092]66
[412cef6]67    QList<Event> conflicts = Event::conflictEvents(event.id(),Conference::activeConference());
[ce59092]68    if(event.isFavourite())
69    {
70        event.setFavourite(false);
71        favouriteButton->setIcon(QIcon(":/icons/favourite-offBig.png"));
72    }
73    else
74    {
75        event.setFavourite(true);
76        favouriteButton->setIcon(QIcon(":/icons/favourite-onBig.png"));
77    }
78    event.update("favourite");
[412cef6]79
80    if(event.isFavourite())
81    {
82        // event has became 'favourite' and so 'conflicts' list may have changed
83        conflicts = Event::conflictEvents(event.id(),Conference::activeConference());
84    }
85
[ce59092]86    qDebug() << " FAVOURITE [" << event.id() << "] -> " << event.isFavourite();
[412cef6]87
88    // have to emit 'eventHasChanged' signal on all events in conflict
89    for(int i=0; i<conflicts.count(); i++)
90        emit(eventHasChanged(conflicts[i].id()));
[872aeaa]91
92    // since the Favourite icon has changed, update TreeViews accordingly
93    // all TreeViews have to listen on this signal
94    emit(eventHasChanged(event.id(),true));
[ce59092]95}
96
97void EventDialog::alarmClicked()
98{
[0bb39f5]99    Event event = Event::getById(mEventId,Conference::activeConference());
[ce59092]100
101    if(event.hasAlarm())
102    {
103        event.setHasAlarm(false); // update DB
104        alarmButton->setIcon(QIcon(":/icons/alarm-offBig.png"));
105#ifdef MAEMO
106        // remove alarm from the 'alarmd' alrms list
107        Alarm alarm;
108        alarm.deleteAlarm(event.id());
109        // TODO: test if removing was successfull
110#endif /* MAEMO */
111    }
112    else
113    {
114        event.setHasAlarm(true);
115        alarmButton->setIcon(QIcon(":/icons/alarm-onBig.png"));
116#ifdef MAEMO
117        // add alarm to the 'alarmd'
118        Alarm alarm;
119        int cookie = alarm.addAlarm(event.id(),QDateTime::currentDateTime().addSecs(10));
120        qDebug() << "cookie: " << cookie;
121#endif /* MAEMO */
122    }
123    event.update("alarm");
124    qDebug() << " ALARM [" << event.id() << "] -> " << event.hasAlarm();
125    // since the Alarm icon has changed, update TreeView accordingly
126    // all TreeViews have to listen on this signal
127    emit(eventHasChanged(event.id()));
[707cd31]128}
129
Note: See TracBrowser for help on using the repository browser.