1 /**************************************************************************
4 Copyright (C) 2010-2011 Heli Hyvättinen
6 This file is part of KitchenAlert.
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.
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.
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/>.
21 **************************************************************************/
25 #ifndef KITCHENALERTMAINWINDOW_H
26 #define KITCHENALERTMAINWINDOW_H
28 #include <QMainWindow>
30 #include "currentalertstablemodel.h"
31 #include <QItemSelection>
32 #include "alertsound.h"
36 class KitchenAlertMainWindow;
40 /*! The main window class of KitchenAlert'
42 @author Heli Hyvättinen
50 class KitchenAlertMainWindow : public QMainWindow
56 explicit KitchenAlertMainWindow(QWidget *parent = 0);
57 ~KitchenAlertMainWindow();
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
65 void newTimerSequence();
68 Opens a dialog for choosing the alert sound
69 Gives the sound filename to AlertSound
71 void openSelectSoundDialog();
74 Shows the application's about box
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.
84 void alert(QModelIndex indexOfAlerted);
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.
94 @param selected Selection that contains all selected cells (all cells of the row selected).
96 void timerSelected(QItemSelection selected,QItemSelection);
98 /*! Snoozes the timer that is currently selected.
99 Needs to be connected to the associated button.
103 /*! Restarts the timer selected.
104 Needs to be connected to the associated button.
108 /*! Stops the timer selected.
109 Needs to be connected to the associated button.
113 /*! Removes the timer selected.
114 Needs to be connected to the associated button.
118 /*! Opens a dialog for saving the selected timer and, if confirmed, saves the timer to a file.
122 /*! Opens a dialog for reading a timer from a timer file, and if confirmed opens and starts the timer.
126 /*! Opens a dialog for choosing which timers to preload at start */
127 void openStickyDialog();
131 void defaultSoundEnabled();
133 void soundChanged(QString filename);
136 void changeEvent(QEvent *e);
139 Reimplemented to catch WindowActivate and WindowDeactivate events.
140 Stops refreshing the view when the window is deactivated and resumes it when reactivated.
142 bool event(QEvent *event);
145 Disables all buttons that should only be enabled when a timer is selected.
147 void disableSelectionDependentButtons();
155 Ui::KitchenAlertMainWindow *ui;
157 CurrentAlertsTableModel model_; /*! The model that stores the alerts */
159 QString defaultSaveDirectory_;
162 Returns a QMoldelIndex pointing to the cell in the column 0 of the row that is currently selected.
164 QModelIndex selectedRow();
168 Not used. Would allow getting rid of the default sound if used.
170 void initializeAlertSound();
172 void initializeTimer(Timer * p_timer, bool startImmediately = true);
174 //Adds the timer to the model and optionally starts it on success, gives an error message on failure
175 bool loadTimer(QString filename, bool startImmediately);
178 #endif // KITCHENALERTMAINWINDOW_H