source: src/gui/eventdialog.cpp @ 07ae23a

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

implemented 'links' in Event/EventDialog?

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