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.
129 void defaultSoundEnabled();
131 void soundChanged(QString filename);
134 void changeEvent(QEvent *e);
137 Reimplemented to catch WindowActivate and WindowDeactivate events.
138 Stops refreshing the view when the window is deactivated and resumes it when reactivated.
140 bool event(QEvent *event);
143 Disables all buttons that should only be enabled when a timer is selected.
145 void disableSelectionDependentButtons();
149 Ui::KitchenAlertMainWindow *ui;
151 CurrentAlertsTableModel model_; /*! The model that stores the alerts */
153 QString defaultSaveDirectory_;
156 Returns a QMoldelIndex pointing to the cell in the column 0 of the row that is currently selected.
158 QModelIndex selectedRow();
162 Not used. Would allow getting rid of the default sound if used.
164 void initializeAlertSound();
166 void initializeTimer(Timer * p_timer);
171 #endif // KITCHENALERTMAINWINDOW_H