#include <QDateTime>
+#include <QApplication>
+#include <QDir>
+
int Alarm::addAlarm(int aEventId, const QDateTime &aDateTime)
{
cookie_t cookie = 0;
/* Add exec command action */
action = alarm_event_add_actions(event, 1);
- QString command = QString("/home/maemo/work/fosdem-maemo/bin/fosdem %1").arg(QString::number(aEventId));
+ QString command = QDir::currentPath() + "/" + *qApp->argv() + QString(" %1").arg(QString::number(aEventId));
alarm_action_set_exec_command(action, command.toLocal8Bit().data());
action->flags |= ALARM_ACTION_TYPE_EXEC;
action->flags |= ALARM_ACTION_WHEN_TRIGGERED;
// Example: $ ./fosdem 521 13
if(argc==3)
window = new AlarmDialog(argc,argv);
+ else if(argc==2) // display Event dialog automatically
+ window = new MainWindow(atoi(argv[1])); // eventId = argv[1]
else
window = new MainWindow;
#else
#include <event.h>
#include <QDir>
+#include <QProcess>
const int SNOOZE_TIME = 5; // in minutes
void AlarmDialog::runApp()
{
- qWarning("runApp(): NOT IMPLEMENTED YET");
+ QString program = QDir::currentPath() + "/" + *qApp->argv();
+ QProcess::startDetached(program,QStringList()<<QString::number(mEventId));
+ qApp->quit();
}
void AlarmDialog::snooze()
<item>
<widget class="QPushButton" name="stopPB" >
<property name="text" >
- <string>Stop</string>
+ <string>Cancel</string>
</property>
</widget>
</item>
#include <QScrollBar>
-EventDialog::EventDialog(const QModelIndex &aIndex, QWidget *aParent)
+EventDialog::EventDialog(const int &aEventId, QWidget *aParent)
: QDialog(aParent)
- , mIndex(aIndex)
+ , mEventId(aEventId)
{
setupUi(this);
+ const int confId = 1;
+ Event event = Event::getById(aEventId,confId);
+
abstract->setStyleSheet("background-color : transparent;");
description->setStyleSheet("background-color : transparent;");
abstract->verticalScrollBar()->setPalette(p2);
description->verticalScrollBar()->setPalette(p2);
- Event *event = static_cast<Event *>(mIndex.internalPointer());
- title->setText(event->title());
- persons->setText(event->persons().join(" and "));
- abstract->setPlainText(event->abstract());
- description->setPlainText(event->description());
+ title->setText(event.title());
+ persons->setText(event.persons().join(" and "));
+ abstract->setPlainText(event.abstract());
+ description->setPlainText(event.description());
}
#define EVENTDIALOG_H
#include <QDialog>
-#include <QModelIndex>
#include "ui_eventdialog.h"
#include <event.h>
class EventDialog : public QDialog, Ui::EventDialog
{
public:
- EventDialog(const QModelIndex &aIndex, QWidget *aParent = NULL);
+ EventDialog(const int &aEventId, QWidget *aParent = NULL);
~EventDialog() {}
private:
- QModelIndex mIndex;
+ int mEventId;
};
#endif /* EVENTDIALOG_H */
const int confId = 1;
-MainWindow::MainWindow(QWidget *parent)
- : QMainWindow(parent)
+MainWindow::MainWindow(int aEventId, QWidget *aParent)
+ : QMainWindow(aParent)
{
setupUi(this);
connect(tabWidget, SIGNAL(currentChanged(int)), this, SLOT(updateTab(int)));
+ // open dialog for given Event ID
+ // this is used in case Alarm Dialog request application to start
+ if(aEventId)
+ {
+ EventDialog dialog(aEventId,this);
+ dialog.exec();
+ }
}
MainWindow::~MainWindow()
if(!aIndex.parent().isValid()) // time-group
return;
- EventDialog dialog(aIndex,this);
+ EventDialog dialog(static_cast<Event*>(aIndex.internalPointer())->id(),this);
dialog.exec();
}
{
Q_OBJECT
public:
- MainWindow(QWidget *parent = 0);
+ // aEventId is used to inform widget to automatically open
+ // Event dialog for given Event ID
+ MainWindow(int aEventId = 0, QWidget *aParent = NULL);
~MainWindow();
private slots:
void importSchedule();