source: src/gui/eventdialog.cpp @ bc88043

qt5
Last change on this file since bc88043 was bc88043, checked in by pavelpa <pavelpa@…>, 12 years ago

'alarm' button is hidden for not MAEMO

  • Property mode set to 100644
File size: 2.7 KB
RevLine 
[707cd31]1#include "eventdialog.h"
[0bb39f5]2#include <conference.h>
[707cd31]3
[1fe2f21]4#include <QScrollBar>
[395d6d3]5
[ce59092]6#ifdef MAEMO
7#include <alarm.h>
8#endif
9
[d4a8bbf]10EventDialog::EventDialog(const int &aEventId, QWidget *aParent)
[707cd31]11    : QDialog(aParent)
[d4a8bbf]12    , mEventId(aEventId)
[707cd31]13{
14    setupUi(this);
[395d6d3]15
[842f5f9]16#ifdef MAEMO
17    showFullScreen();
[bc88043]18#else
19    alarmButton->hide();
[842f5f9]20#endif
21
[0bb39f5]22    Event event = Event::getById(mEventId,Conference::activeConference());
[d4a8bbf]23
24    title->setText(event.title());
[1bcd66f]25    persons->setText(event.persons().join(" and "));
26    abstract->setText(event.abstract());
27    description->setText(event.description());
[6123b48]28    links->setText(static_cast<QStringList>(event.links().values()).join("\n"));
[ce59092]29
30    connect(favouriteButton, SIGNAL(clicked()), SLOT(favouriteClicked()));
31    connect(alarmButton, SIGNAL(clicked()), SLOT(alarmClicked()));
32
33    if(event.isFavourite())
34    {
35        favouriteButton->setIcon(QIcon(":/icons/favourite-onBig.png"));
36    }
37
38    if(event.hasAlarm())
39    {
40        alarmButton->setIcon(QIcon(":/icons/alarm-onBig.png"));
41    }
42}
43
44void EventDialog::favouriteClicked()
45{
[0bb39f5]46    Event event = Event::getById(mEventId,Conference::activeConference());
[ce59092]47
48    if(event.isFavourite())
49    {
50        event.setFavourite(false);
51        favouriteButton->setIcon(QIcon(":/icons/favourite-offBig.png"));
52    }
53    else
54    {
55        event.setFavourite(true);
56        favouriteButton->setIcon(QIcon(":/icons/favourite-onBig.png"));
57    }
58    event.update("favourite");
59    qDebug() << " FAVOURITE [" << event.id() << "] -> " << event.isFavourite();
60    // update EVENT_CONFLICT table
61    event.updateConflicts();
62    // since the Favourite icon has changed, update TreeViews accordingly
63    // all TreeViews have to listen on this signal
64    emit(eventHasChanged(event.id()));
65}
66
67void EventDialog::alarmClicked()
68{
[0bb39f5]69    Event event = Event::getById(mEventId,Conference::activeConference());
[ce59092]70
71    if(event.hasAlarm())
72    {
73        event.setHasAlarm(false); // update DB
74        alarmButton->setIcon(QIcon(":/icons/alarm-offBig.png"));
75#ifdef MAEMO
76        // remove alarm from the 'alarmd' alrms list
77        Alarm alarm;
78        alarm.deleteAlarm(event.id());
79        // TODO: test if removing was successfull
80#endif /* MAEMO */
81    }
82    else
83    {
84        event.setHasAlarm(true);
85        alarmButton->setIcon(QIcon(":/icons/alarm-onBig.png"));
86#ifdef MAEMO
87        // add alarm to the 'alarmd'
88        Alarm alarm;
89        int cookie = alarm.addAlarm(event.id(),QDateTime::currentDateTime().addSecs(10));
90        qDebug() << "cookie: " << cookie;
91#endif /* MAEMO */
92    }
93    event.update("alarm");
94    qDebug() << " ALARM [" << event.id() << "] -> " << event.hasAlarm();
95    // since the Alarm icon has changed, update TreeView accordingly
96    // all TreeViews have to listen on this signal
97    emit(eventHasChanged(event.id()));
[707cd31]98}
99
Note: See TracBrowser for help on using the repository browser.