Changeset ce59092 for src/gui


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

Location:
src/gui
Files:
4 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
  • src/gui/eventdialog.h

    r6bc425e rce59092  
    2020};
    2121
    22 
    2322class EventDialog : public QDialog, Ui::EventDialog
    2423{
     24    Q_OBJECT
    2525public:
    2626    EventDialog(const int &aEventId, QWidget *aParent = NULL);
    2727    ~EventDialog() {}
     28private slots:
     29    void favouriteClicked();
     30    void alarmClicked();
     31signals:
     32    void eventHasChanged(int aEventId); // emited when user changes some event details, eg. sets it Favourite
    2833private:
    2934    int mEventId;
  • src/gui/eventdialog.ui

    r6bc425e rce59092  
    6262          <y>0</y>
    6363          <width>418</width>
    64           <height>296</height>
     64          <height>294</height>
    6565         </rect>
    6666        </property>
     
    7070     <item>
    7171      <layout class="QHBoxLayout" name="horizontalLayout" >
     72       <item>
     73        <widget class="QToolButton" name="alarmButton" >
     74         <property name="text" >
     75          <string>...</string>
     76         </property>
     77         <property name="icon" >
     78          <iconset resource="../icons.qrc" >
     79           <normaloff>:/icons/alarm-offBig.png</normaloff>:/icons/alarm-offBig.png</iconset>
     80         </property>
     81        </widget>
     82       </item>
     83       <item>
     84        <widget class="QToolButton" name="favouriteButton" >
     85         <property name="text" >
     86          <string>...</string>
     87         </property>
     88         <property name="icon" >
     89          <iconset resource="../icons.qrc" >
     90           <normaloff>:/icons/favourite-offBig.png</normaloff>:/icons/favourite-offBig.png</iconset>
     91         </property>
     92        </widget>
     93       </item>
    7294       <item>
    7395        <spacer name="horizontalSpacer" >
     
    96118  </layout>
    97119 </widget>
    98  <resources/>
     120 <resources>
     121  <include location="../icons.qrc" />
     122 </resources>
    99123 <connections>
    100124  <connection>
  • src/gui/tabcontainer.cpp

    r6bc425e rce59092  
    137137
    138138    EventDialog dialog(static_cast<Event*>(aIndex.internalPointer())->id(),this);
     139    connect(&dialog, SIGNAL(eventHasChanged(int)), this, SIGNAL(eventHasChanged(int)));
    139140    dialog.exec();
     141    disconnect(&dialog, SIGNAL(eventHasChanged(int)), this, SIGNAL(eventHasChanged(int)));
    140142}
    141143
Note: See TracChangeset for help on using the changeset viewer.