Changeset d4a8bbf


Ignore:
Timestamp:
01/20/10 16:27:11 (12 years ago)
Author:
pavelpa <pavelpa@…>
Branches:
master, qt5
Children:
a5c1179
Parents:
f2ef735
Message:

MAEMO: work on alarm

  • snooze alarm
  • cancel alarm
  • run application which automatically display Event dialog for given Event ID
Location:
src
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • src/alarm/alarm.cpp

    rf2ef735 rd4a8bbf  
    22
    33#include <QDateTime>
     4
     5#include <QApplication>
     6#include <QDir>
    47
    58int Alarm::addAlarm(int aEventId, const QDateTime &aDateTime)
     
    1922    /* Add exec command action */
    2023    action = alarm_event_add_actions(event, 1);
    21     QString command = QString("/home/maemo/work/fosdem-maemo/bin/fosdem %1").arg(QString::number(aEventId));
     24    QString command = QDir::currentPath() + "/" + *qApp->argv() + QString(" %1").arg(QString::number(aEventId));
    2225    alarm_action_set_exec_command(action, command.toLocal8Bit().data());
    2326    action->flags |= ALARM_ACTION_TYPE_EXEC;
  • src/app/main.cpp

    rf2ef735 rd4a8bbf  
    2323    if(argc==3)
    2424        window = new AlarmDialog(argc,argv);
     25    else if(argc==2) // display Event dialog automatically
     26        window = new MainWindow(atoi(argv[1])); // eventId = argv[1]
    2527    else
    2628        window = new MainWindow;
  • src/gui/alarmdialog.cpp

    rf2ef735 rd4a8bbf  
    66
    77#include <QDir>
     8#include <QProcess>
    89
    910const int SNOOZE_TIME = 5; // in minutes
     
    4849void AlarmDialog::runApp()
    4950{
    50     qWarning("runApp(): NOT IMPLEMENTED YET");
     51    QString program = QDir::currentPath() + "/" + *qApp->argv();
     52    QProcess::startDetached(program,QStringList()<<QString::number(mEventId));
     53    qApp->quit();
    5154}
    5255
  • src/gui/alarmdialog.ui

    rf2ef735 rd4a8bbf  
    6969        <widget class="QPushButton" name="stopPB" >
    7070         <property name="text" >
    71           <string>Stop</string>
     71          <string>Cancel</string>
    7272         </property>
    7373        </widget>
  • src/gui/eventdialog.cpp

    rf2ef735 rd4a8bbf  
    33#include <QScrollBar>
    44
    5 EventDialog::EventDialog(const QModelIndex &aIndex, QWidget *aParent)
     5EventDialog::EventDialog(const int &aEventId, QWidget *aParent)
    66    : QDialog(aParent)
    7     , mIndex(aIndex)
     7    , mEventId(aEventId)
    88{
    99    setupUi(this);
     10
     11    const int confId = 1;
     12    Event event = Event::getById(aEventId,confId);
    1013
    1114    abstract->setStyleSheet("background-color : transparent;");
     
    2831    description->verticalScrollBar()->setPalette(p2);
    2932
    30     Event *event = static_cast<Event *>(mIndex.internalPointer());
    31     title->setText(event->title());
    32     persons->setText(event->persons().join(" and "));
    33     abstract->setPlainText(event->abstract());
    34     description->setPlainText(event->description());
     33    title->setText(event.title());
     34    persons->setText(event.persons().join(" and "));
     35    abstract->setPlainText(event.abstract());
     36    description->setPlainText(event.description());
    3537}
    3638
  • src/gui/eventdialog.h

    rf2ef735 rd4a8bbf  
    33
    44#include <QDialog>
    5 #include <QModelIndex>
    65#include "ui_eventdialog.h"
    76#include <event.h>
     
    109{
    1110public:
    12     EventDialog(const QModelIndex &aIndex, QWidget *aParent = NULL);
     11    EventDialog(const int &aEventId, QWidget *aParent = NULL);
    1312    ~EventDialog() {}
    1413private:
    15     QModelIndex mIndex;
     14    int mEventId;
    1615};
    1716
  • src/gui/mainwindow.cpp

    rf2ef735 rd4a8bbf  
    2121const int confId = 1;
    2222
    23 MainWindow::MainWindow(QWidget *parent)
    24     : QMainWindow(parent)
     23MainWindow::MainWindow(int aEventId, QWidget *aParent)
     24    : QMainWindow(aParent)
    2525{
    2626    setupUi(this);
     
    116116    connect(tabWidget, SIGNAL(currentChanged(int)), this, SLOT(updateTab(int)));
    117117
     118    // open dialog for given Event ID
     119    // this is used in case Alarm Dialog request application to start
     120    if(aEventId)
     121    {
     122        EventDialog dialog(aEventId,this);
     123        dialog.exec();
     124    }
    118125}
    119126
     
    229236        return;
    230237
    231     EventDialog dialog(aIndex,this);
     238    EventDialog dialog(static_cast<Event*>(aIndex.internalPointer())->id(),this);
    232239    dialog.exec();
    233240}
  • src/gui/mainwindow.h

    rf2ef735 rd4a8bbf  
    1313    Q_OBJECT
    1414public:
    15     MainWindow(QWidget *parent = 0);
     15    // aEventId is used to inform widget to automatically open
     16    // Event dialog for given Event ID
     17    MainWindow(int aEventId = 0, QWidget *aParent = NULL);
    1618    ~MainWindow();
    1719private slots:
Note: See TracChangeset for help on using the changeset viewer.