The state before going to scratchbox
[kitchenalert] / src / kitchenalertmainwindow.h
1 /**************************************************************************
2         KitchenAlert
3
4         Copyright (C) 2010-2011  Heli Hyvättinen
5
6         This file is part of KitchenAlert.
7
8         Kitchen Alert is free software: you can redistribute it and/or modify
9         it under the terms of the GNU General Public License as published by
10         the Free Software Foundation, either version 3 of the License, or
11         (at your option) any later version.
12
13         This program is distributed in the hope that it will be useful,
14         but WITHOUT ANY WARRANTY; without even the implied warranty of
15         MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16         GNU General Public License for more details.
17
18         You should have received a copy of the GNU General Public License
19         along with this program.  If not, see <http://www.gnu.org/licenses/>.
20
21 **************************************************************************/
22
23
24
25 #ifndef KITCHENALERTMAINWINDOW_H
26 #define KITCHENALERTMAINWINDOW_H
27
28 #include <QMainWindow>
29 #include "timer.h"
30 #include "currentalertstablemodel.h"
31 #include <QItemSelection>
32 #include "alertsound.h"
33
34
35 namespace Ui {
36     class KitchenAlertMainWindow;
37 }
38
39
40 /*! The main window class of KitchenAlert'
41
42   @author Heli Hyvättinen
43   @date 2011-01-05
44   @version 0.3.0
45
46 Operates the UI.
47
48 */
49
50 class KitchenAlertMainWindow : public QMainWindow
51 {
52     Q_OBJECT 
53
54
55 public:
56     explicit KitchenAlertMainWindow(QWidget *parent = 0);
57     ~KitchenAlertMainWindow();
58
59
60 public slots:
61    /*!
62    Opens a dialog for creating a new timer
63    Connects the new timer's alert and adds it to the model, starting the timer
64     */
65         void newTimerSequence();
66
67    /*!
68    Opens a dialog for choosing the alert sound
69    Gives the sound filename to AlertSound
70     */
71    void openSelectSoundDialog();
72
73     /*!
74    Shows the application's about box
75    */
76     void openAbout();
77
78 /*! Sounds the alert sound and selects the alarming timer
79   Also bring the application to top and activates it
80   Used by connecting it to the timer's alert signal
81   @param indexOfAlerted The index of the alerting timer in the model.
82
83   */
84     void alert(QModelIndex indexOfAlerted);
85
86 /*!
87     Reacts to selecting of timer in the view.
88     Needs to be connected to the corresponding signal.
89     Sets enabling of buttons as necessary.
90     Does not receive information of clearing the selection (because no signal is sent).
91     Disabling selection dependent buttons must be done manually by everything that clears the selection.
92     It cannot be cleared by the user with the selection policy used.
93
94     @param selected Selection that contains all selected cells (all cells of the row selected).
95 */
96     void timerSelected(QItemSelection selected,QItemSelection);
97
98     /*! Snoozes the timer that is currently selected.
99       Needs to be connected to the associated button.
100     */
101     void snooze();
102
103     /*! Restarts the timer selected.
104       Needs to be connected to the associated button.
105     */
106     void restart();
107
108     /*! Stops the timer selected.
109       Needs to be connected to the associated button.
110     */
111     void stop();
112
113     /*! Removes the timer selected.
114       Needs to be connected to the associated button.
115        */
116     void remove();
117
118     /*! Opens a dialog for saving the selected timer and, if confirmed, saves the timer to a file.
119     */
120     void saveTimer();
121
122     /*! Opens a dialog for reading a timer from a timer file, and if confirmed opens and starts the timer.
123     */
124     void loadTimer();
125
126
127 signals:
128
129     void defaultSoundEnabled();
130
131     void soundChanged(QString filename);
132
133 protected:
134     void changeEvent(QEvent *e);
135
136     /*!
137     Reimplemented to catch WindowActivate and WindowDeactivate events.
138     Stops refreshing the view when the window is deactivated and resumes it when reactivated.
139     */
140     bool event(QEvent *event);
141
142     /*!
143     Disables all buttons that should only be enabled when a timer is selected.
144     */
145     void disableSelectionDependentButtons();
146
147 private:
148
149     Ui::KitchenAlertMainWindow *ui;
150
151     CurrentAlertsTableModel model_; /*! The model that stores the alerts */
152
153     const QString defaultSaveDirectory_;
154
155     /*!
156     Returns a QMoldelIndex pointing to the cell in the column 0 of the row that is currently selected.
157     */
158     QModelIndex selectedRow();
159
160
161     /*!
162     Not used. Would allow getting rid of the default sound if used.
163     */
164     void initializeAlertSound();
165
166     void initializeTimer(Timer * p_timer);
167
168
169 };
170
171 #endif // KITCHENALERTMAINWINDOW_H