sAlarm 0.5
salarm/scheduler/scheduler.h
00001 /*
00002  * sAlarm - Scheduler
00003  * http://salarm.seberm.com
00004  *
00005  * Copyright (C) 2009-2010 Otto Sabart <seberm[at]gmail[dot]com>
00006  * 
00007  * This program is free software; you can redistribute it and/or
00008  * modify it under the terms of the GNU General Public License
00009  * version 3 as published by the Free Software Foundation.
00010  * 
00011  * This program is distributed in the hope that it will be useful,
00012  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00013  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014  * GNU General Public License for more details.
00015  * 
00016  * You should have received a copy of the GNU General Public License
00017  * along with this program; if not, write to the Free Software
00018  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
00019  */
00020 
00021 
00022 #ifndef SCHEDULER_H
00023 #define SCHEDULER_H
00024 
00025 
00026 #include <QTreeView>
00027 #include <QDateTime>
00028 #include <QTimer>
00029 #include <QList>
00030 #include <QFile>
00031 #include <QSqlDatabase>
00032 
00033 
00034 struct Column {
00035         
00036         int columnID;
00037         QString columnName;
00038 };
00039 
00040 class SchedulerModel;
00041 class SchedulerProxyModel;
00042 class ScheduleDelegate;
00043 class Schedule;
00044 class Database;
00045 
00047 class Scheduler : public QTreeView {
00048         
00049         Q_OBJECT
00050 
00051 public:
00052         
00054 
00057     explicit Scheduler(Database *sqlDb, QWidget *parent = 0);
00058         
00060         ~Scheduler();
00061                         
00063 
00066         void removeSchedule();
00067         
00069 
00077         int addSchedule(const QString &title, const QString &text, const QDateTime &expiration, int categoryID = 0);
00078         
00080         void addSchedule(Schedule *s);
00081         
00083 
00090         void editSchedule(int id, const QString &title, const QString &text, const QDateTime &expiration, int categoryID = 0);
00091         
00093         void makeConnections();
00094         
00096 
00099         void generateXmlToFile(QFile *file);
00100         
00102         void refreshSchedules();
00103         
00105 
00109         int addScheduleCategory(const QString categoryName) const;
00110         
00112 
00115         void removeScheduleCategory(int categoryID) const;
00116         
00118         QList<QPair<int, QString> > scheduleCategories() const;
00120         
00121 public slots:
00122         
00124 
00127         void checkSchedules();
00128         
00130 
00134         void postpone(int id);
00135         
00137 
00140         void markTimeouted(int id);
00141 
00142 signals:
00143         
00145 
00148         void scheduleTimeouted (int);
00149         
00150         
00151 private:
00152 
00154         SchedulerModel *m_model;
00155         
00157         SchedulerProxyModel *m_proxyModel;
00158         
00160         ScheduleDelegate *m_itemDelegate;
00161         
00163         QTimer *m_scheduleTimer;
00164         
00166         Database *m_sqlDb;
00167         
00169         QList<QPair<int, QDateTime> > m_schedules;
00170 };
00171 
00172 #endif // SCHEDULER_H
 All Classes Functions Enumerations