Sound related changes
[kitchenalert] / src / currentalertstablemodel.h
old mode 100644 (file)
new mode 100755 (executable)
index 32cadc3..0d4bb08
 #define CURRENTALERTSTABLEMODEL_H
 
 #include <QAbstractTableModel>
+#include <QMainWindow>
 #include "timer.h"
 
 
 /*! Class that contains the model that holds the timers'
 
   @author Heli Hyvättinen
-  @date 2010-06-26
-  @version 0.09
+  @date 2011-02-10
+  @version 0.2.0
 
 Class that contains the model that holds the timers
 
@@ -48,33 +49,104 @@ class CurrentAlertsTableModel : public QAbstractTableModel
 public:
     explicit CurrentAlertsTableModel(QObject *parent = 0);
 
+    /*!
+    Returns the number of rows in the model.
+    Used by the view.
+    */
     int rowCount(const QModelIndex &parent) const;
 
+    /*!
+      Returns the (fixed) number of columns in the model.
+      Used by the view.
+    */
     int columnCount(const QModelIndex &parent) const;
 
+    /*!
+    Returns the queried contents of the cell
+    Used by the view.
+    */
     QVariant data(const QModelIndex &index, int role) const;
 
+    /*!
+      Returns the queried header data.
+      As no headers are wanted, it always returns an empty QVariant.
+      Used by the view.
+      */
+    QVariant headerData(int section, Qt::Orientation orientation, int role) const;
+
+    /*!
+      Returns the index in the model of the given timer
+      */
     QModelIndex giveIndexForTimer(Timer * ptimer);
 
-signals:
+    /*!
+      Returns whether the timer in the given position is currently alerting.
+      @param index Any cell from the row of the alert is good here.
+      */
+    bool isThisTimerAlerting(QModelIndex index);
 
-public slots:
 
-    void addTimers(QList <Timer *> timers);
+signals:
 
-    void refreshTimeColumn ();
+public slots:
 
+    /*!
+       Adds the timers to the model
+    @param timers List of timers to be added
+    @param startImmediately If true, the timers will be started after adding to the model.
+    */
+    void addTimers(QList <Timer *> timers, bool startImmediately = true);
+
+    /*!
+     Tells the view to refresh all information in the time and status columns.
+     (The time and status change without user inervention unlike the alert text and thus
+     need to be refreshed.)
+      */
+    void refreshTimeAndStatusColumns ();
+
+    /*!
+      Passes the start command to the timer in the given index.
+      @param index Any cell from the row of the alert is good here.
+      */
     void startTimer(QModelIndex index);
+
+    /*!
+      Passes the snooze command to the timer in the given index.
+      @param index Any cell from the row of the alert is good here.
+      */
     void snoozeTimer(QModelIndex index);
+
+
+    /*!
+      Passes the stop command to the timer in the given index.
+      @param index Any cell from the row of the alert is good here.
+      */
     void stopTimer(QModelIndex index);
 
+/*!
+Sets whether the view should be kept up to date.
+*/
+    void setUpdateViewOnChanges(bool update);
+
+/*!
+  Removes a timer from the model
+  */
+
+    void removeTimer(QModelIndex index);
+
+
+
 private:
-    QList <Timer * > currentTimers_;
+    QList <Timer * > currentTimers_; /*! Holds the timers */
+
+    static const int numberOfColumns_ = 3; /*! The fixed number of columns in the model */
+    static const int alertTextColumnNumber_ = 0; /*! Tells which column contains the alert text */
+    static const int timeRemainingColumnNumber_ = 1; /*! Tells which column contains the time remaining until alert */
+    static const int statusColumnNumber_ = 2; /*! Tells which column contains status information, such as that the timer is alerting  */
+
+
 
-    static const int numberOfColumns_ = 3;
-    static const int alertTextColumnNumber_ = 0;
-    static const int timeRemainingColumnNumber_ = 1;
-    static const int statusColumnNumber_ = 2;
+    bool updateViewOnChanges_; /*! Keeps track on whether the view should be kept up to date. */
 
 };