Ignore:
Timestamp:
01/27/10 12:36:29 (12 years ago)
Author:
pavelpa <pavelpa@…>
Branches:
master, qt5
Children:
1bcd66f
Parents:
6bc425e
Message:

Event 'details' dialog now contains also 'favourite' and 'alarm'
buttons, so the user can set/unset the property directly from the dialog

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/gui/eventdialog.cpp

    r6bc425e rce59092  
    33
    44#include <QScrollBar>
     5
     6#ifdef MAEMO
     7#include <alarm.h>
     8#endif
    59
    610DetailsContainer::DetailsContainer(QWidget *aParent)
     
    5660#endif
    5761
    58     Event event = Event::getById(aEventId,AppSettings::confId());
     62    Event event = Event::getById(mEventId,AppSettings::confId());
    5963
    6064    title->setText(event.title());
     
    6367    mDetails.setDescription(event.description());
    6468    scrollArea->setWidget(&mDetails);
     69
     70    connect(favouriteButton, SIGNAL(clicked()), SLOT(favouriteClicked()));
     71    connect(alarmButton, SIGNAL(clicked()), SLOT(alarmClicked()));
     72
     73    if(event.isFavourite())
     74    {
     75        favouriteButton->setIcon(QIcon(":/icons/favourite-onBig.png"));
     76    }
     77
     78    if(event.hasAlarm())
     79    {
     80        alarmButton->setIcon(QIcon(":/icons/alarm-onBig.png"));
     81    }
    6582}
    6683
     84void EventDialog::favouriteClicked()
     85{
     86    Event event = Event::getById(mEventId,AppSettings::confId());
     87
     88    if(event.isFavourite())
     89    {
     90        event.setFavourite(false);
     91        favouriteButton->setIcon(QIcon(":/icons/favourite-offBig.png"));
     92    }
     93    else
     94    {
     95        event.setFavourite(true);
     96        favouriteButton->setIcon(QIcon(":/icons/favourite-onBig.png"));
     97    }
     98    event.update("favourite");
     99    qDebug() << " FAVOURITE [" << event.id() << "] -> " << event.isFavourite();
     100    // update EVENT_CONFLICT table
     101    event.updateConflicts();
     102    // since the Favourite icon has changed, update TreeViews accordingly
     103    // all TreeViews have to listen on this signal
     104    emit(eventHasChanged(event.id()));
     105}
     106
     107void EventDialog::alarmClicked()
     108{
     109    Event event = Event::getById(mEventId,AppSettings::confId());
     110
     111    if(event.hasAlarm())
     112    {
     113        event.setHasAlarm(false); // update DB
     114        alarmButton->setIcon(QIcon(":/icons/alarm-offBig.png"));
     115#ifdef MAEMO
     116        // remove alarm from the 'alarmd' alrms list
     117        Alarm alarm;
     118        alarm.deleteAlarm(event.id());
     119        // TODO: test if removing was successfull
     120#endif /* MAEMO */
     121    }
     122    else
     123    {
     124        event.setHasAlarm(true);
     125        alarmButton->setIcon(QIcon(":/icons/alarm-onBig.png"));
     126#ifdef MAEMO
     127        // add alarm to the 'alarmd'
     128        Alarm alarm;
     129        int cookie = alarm.addAlarm(event.id(),QDateTime::currentDateTime().addSecs(10));
     130        qDebug() << "cookie: " << cookie;
     131#endif /* MAEMO */
     132    }
     133    event.update("alarm");
     134    qDebug() << " ALARM [" << event.id() << "] -> " << event.hasAlarm();
     135    // since the Alarm icon has changed, update TreeView accordingly
     136    // all TreeViews have to listen on this signal
     137    emit(eventHasChanged(event.id()));
     138}
     139
Note: See TracChangeset for help on using the changeset viewer.