+/*
+ * Copyright (C) 2010 Ixonos Plc.
+ *
+ * This file is part of fosdem-schedule.
+ *
+ * fosdem-schedule is free software: you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the Free
+ * Software Foundation, either version 2 of the License, or (at your option)
+ * any later version.
+ *
+ * fosdem-schedule is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
+ * more details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * fosdem-schedule. If not, see <http://www.gnu.org/licenses/>.
+ */
#include "alarmdialog.h"
+#include <conference.h>
#include <QApplication>
#include <alarm.h>
const int SNOOZE_TIME = 5; // in minutes
-const int confId = 1;
-
AlarmDialog::AlarmDialog(int argc, char *argv[], QWidget *aParent)
: QDialog(aParent)
, mEventId(0)
database.setDatabaseName(QDir::homePath() + "/.fosdem/fosdem.sqlite");
database.open();
+ QString titleStr;
+ QString messageStr;
+ QString timeStr;
+ QString personsStr;
+ QString roomStr;
try
{
- Event event = Event::getById(mEventId,confId);
- message->setText(event.title());
- setWindowTitle(event.title());
+ Event event = Event::getById(mEventId,Conference::activeConference());
+ titleStr = "Event alarm";
+ messageStr = event.title();
+ timeStr = event.start().toString("hh:mm") + "-" + event.start().addSecs(event.duration()).toString("hh:mm");
+ personsStr = event.persons().join(" and ");
+ roomStr = event.room();
}
- catch(OrmNoObjectException*)
+ catch(OrmNoObjectException&)
{
- message->setText(QString("No such event in the DB: %1").arg(QString::number(mEventId)));
- setWindowTitle("ERROR");
+ titleStr = QString("ERROR");
+ messageStr = QString("No such event in the DB: %1").arg(QString::number(mEventId));
}
catch(...) {} // TODO: implement
+ message->setText(messageStr);
+ setWindowTitle(titleStr);
+ time->setText(timeStr);
+ persons->setText(personsStr);
+ room->setText(roomStr);
}
void AlarmDialog::runApp()
{
QString program = QDir::currentPath() + "/" + *qApp->argv();
QProcess::startDetached(program,QStringList()<<QString::number(mEventId));
- qApp->quit();
+ closeDialog();
}
void AlarmDialog::snooze()
// before closing the dialog, it is necessary to remove alarm flag from the DB
try
{
- Event event = Event::getById(mEventId,confId);
+ Event event = Event::getById(mEventId,Conference::activeConference());
event.setHasAlarm(false);
event.update("alarm");
}
- catch(OrmNoObjectException*) {} // TODO: implement
+ catch(OrmNoObjectException &) {} // TODO: implement
catch(...) {} // just close dialog
qApp->quit();
}