Merge branch 'sticky2'
[kitchenalert] / src / currentalertstablemodel.cpp
index b7afc18..d0e70c3 100644 (file)
@@ -1,7 +1,7 @@
 /**************************************************************************
         KitchenAlert
 
-        Copyright (C) 2010  Heli Hyvättinen
+        Copyright (C) 2010-2011  Heli Hyvättinen
 
         This file is part of KitchenAlert.
 
@@ -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();
 
@@ -325,3 +339,8 @@ void CurrentAlertsTableModel::removeTimer(QModelIndex index)
 
 }
 
+bool CurrentAlertsTableModel::saveTimer(QModelIndex index, QString filename)
+{
+    return currentTimers_.at(index.row())->save(filename);
+}
+