From 9a8fb00226033122ffb6cc51e14d50f5958dfd08 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Heli=20Hyv=C3=A4ttinen?= Date: Sun, 14 Aug 2011 14:45:49 +0300 Subject: [PATCH] Stopped timers now show full time and "stopped" ...instead of 00:00:00. Never started timers count as stopped. --- src/currentalertstablemodel.cpp | 24 +++++++++++++++++++----- src/timer.cpp | 8 ++++---- src/timer.h | 6 ++++++ 3 files changed, 29 insertions(+), 9 deletions(-) diff --git a/src/currentalertstablemodel.cpp b/src/currentalertstablemodel.cpp index 62e8327..d0e70c3 100644 --- a/src/currentalertstablemodel.cpp +++ b/src/currentalertstablemodel.cpp @@ -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(); diff --git a/src/timer.cpp b/src/timer.cpp index 1a182b9..df73464 100644 --- a/src/timer.cpp +++ b/src/timer.cpp @@ -213,9 +213,9 @@ bool Timer::load(QString filename) return true; } -//QString Timer::getFilename() -//{ -// return filenameWithPath_; -//} +bool Timer::isRunning() +{ + return _actualTimer.isActive(); +} diff --git a/src/timer.h b/src/timer.h index 0b13656..69ee596 100644 --- a/src/timer.h +++ b/src/timer.h @@ -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 -- 1.7.9.5