Initial commit: added current sources
[kitchenalert] / src / timer.h
1 /**************************************************************************
2         KitchenAlert v.0.01
3
4         Copyright (C) 2010  Heli Hyvättinen
5
6         This program is free software: you can redistribute it and/or modify
7         it under the terms of the GNU General Public License as published by
8         the Free Software Foundation, either version 3 of the License, or
9         (at your option) any later version.
10
11         This program is distributed in the hope that it will be useful,
12         but WITHOUT ANY WARRANTY; without even the implied warranty of
13         MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14         GNU General Public License for more details.
15
16         You should have received a copy of the GNU General Public License
17         along with this program.  If not, see <http://www.gnu.org/licenses/>.
18
19 **************************************************************************/
20
21
22
23
24
25 #ifndef TIMER_H
26 #define TIMER_H
27
28 #include <QObject>
29 #include <QString>
30 #include <QTimer>
31
32
33 #include <QModelIndex>
34
35 class Timer : public QObject
36 {
37     Q_OBJECT
38 public:
39     explicit Timer(QObject *parent = 0);
40
41     int getOriginalTimeInSeconds();
42     void setOriginalTimeInSeconds(int seconds);
43
44     int getRemainingTimeInSeconds();
45
46     QString getAlertText();
47     void setAlertText(QString text);
48
49     bool isAlerting();
50
51
52 signals:
53
54     void remainingTimeChanged();
55     void alert(QModelIndex indexOfAlerter);
56
57 public slots:
58     void secondPassed();
59     void start();
60     void stop();
61     void snooze();
62
63
64
65 private:
66     int _originalTime; //seconds!
67     int _remainingTime; //seconds!
68     QString _alertText;
69     QTimer _actualTimer;
70     bool alerting_;
71
72     QModelIndex whereAmI();
73
74 };
75
76 #endif // TIMER_H