Stopped timers now show full time and "stopped"
authorHeli Hyvättinen <heli.hyvattinen@kymp.net>
Sun, 14 Aug 2011 11:45:49 +0000 (14:45 +0300)
committerHeli Hyvättinen <heli.hyvattinen@kymp.net>
Sun, 14 Aug 2011 11:45:49 +0000 (14:45 +0300)
...instead of 00:00:00. Never started timers count as stopped.

src/currentalertstablemodel.cpp
src/timer.cpp
src/timer.h

index 62e8327..d0e70c3 100644 (file)
@@ -113,15 +113,26 @@ QVariant CurrentAlertsTableModel::data(const QModelIndex &index, int role) const
                 case timeRemainingColumnNumber_:
 
 
+                    if (currentTimers_.at(index.row())->isRunning()) //timer running
+                    {
+
 
                     allseconds = currentTimers_.at(index.row())->getRemainingTimeInSeconds();
 
 
-                    if (allseconds < 0)
-                    {
-                        timeAsText = tr("-", "negative sign");
-                        allseconds = -allseconds;
+                        if (allseconds < 0)
+                        {
+                            timeAsText = tr("-", "negative sign");
+                            allseconds = -allseconds;
+
+                        }
+                    }
+
+                    else //timer stopped or never started
 
+                    {
+                        //use original time
+                        allseconds = currentTimers_.at(index.row())->getOriginalTimeInSeconds();
                     }
 
                     hoursOnly.setNum( allseconds/(60*60));
@@ -146,7 +157,10 @@ QVariant CurrentAlertsTableModel::data(const QModelIndex &index, int role) const
                 case statusColumnNumber_:
 
                     if (currentTimers_.at(index.row())->isAlerting() == true)
-                        return QString("ALERT!");
+                        return tr("ALERT!");
+
+                    if (!currentTimers_.at(index.row())->isRunning())
+                        return tr("stopped");
 
                     else return QString();
 
index 1a182b9..df73464 100644 (file)
@@ -213,9 +213,9 @@ bool Timer::load(QString filename)
     return true;
 }
 
-//QString Timer::getFilename()
-//{
-//    return filenameWithPath_;
-//}
+bool Timer::isRunning()
+{
+    return _actualTimer.isActive();
+}
 
 
index 0b13656..69ee596 100644 (file)
@@ -82,6 +82,10 @@ public:
     */
     bool load(QString filename);
 
+    /*! Returns wheter the alert is running or not.
+      Alerting timers are considered running. */
+    bool isRunning();
+
 
 signals:
     /*! Emitted when the remaining time in the timer has changed */
@@ -129,6 +133,8 @@ private:
 
 
 
+
+
 };
 
 #endif // TIMER_H