Bug 144782 - "Revert and Stop" stops but doesn't revert
Summary: "Revert and Stop" stops but doesn't revert
Status: RESOLVED FIXED
Alias: None
Product: ktimetracker
Classification: Applications
Component: general (show other bugs)
Version: unspecified
Platform: unspecified Linux
: NOR normal
Target Milestone: ---
Assignee: Thorsten Staerk
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2007-04-28 10:53 UTC by Inge Wallin
Modified: 2008-01-04 09:40 UTC (History)
0 users

See Also:
Latest Commit:
Version Fixed In:
Sentry Crash Report:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Inge Wallin 2007-04-28 10:53:06 UTC
Version:           1.6.0 (using KDE KDE 3.5.6)

When i go away from the keyboard for a while, the "away from keyboard" feature kicks in and asks if I want to continue or revert. If I choose "Revert and Stop", the clock stops, but it doesn't revert.  

To be honest, I can't remember if this is for "Revert and Continue" and "Revert and Stop" both, or if it's just one of them.
Comment 1 Thorsten Staerk 2007-04-28 11:22:02 UTC
"Revert and Stop" stops but does not revert.
Comment 2 Thorsten Staerk 2007-04-28 12:29:59 UTC
SVN commit 658731 by tstaerk:

Subtract the time that has been added while the desktop has been idle.
CCBUGS:144782


 M  +1 -0      idletimedetector.cpp  
 M  +12 -6     task.cpp  
 M  +1 -1      taskview.cpp  


--- branches/KDE/3.5/kdepim/karm/idletimedetector.cpp #658730:658731
@@ -81,6 +81,7 @@
     // Revert And Stop
     kdDebug(5970) << "Now it is " << KGlobal::locale()->formatTime(QDateTime::currentDateTime().time()).ascii() << endl;
     kdDebug(5970) << "Reverting timer to " << KGlobal::locale()->formatTime(idleStart.time()).ascii() << endl;
+    emit(extractTime(idleMinutes+diff)); // we need to subtract the time that has been added during idleness.
     emit(stopAllTimersAt(idleStart));
   }
   else if (id == 1) {
--- branches/KDE/3.5/kdepim/karm/task.cpp #658730:658731
@@ -96,11 +96,14 @@
 
 void Task::setRunning( bool on, KarmStorage* storage, QDateTime whenStarted, QDateTime whenStopped  )
 // Sets a task running or stopped. If the task is to be stopped, whenStarted is not evaluated.
+// on=true if the task shall be started on=false if the task shall be stopped
 {
-  kdDebug(5970) << "Entering Task::setRunning" << endl;
-  if ( on ) {
+  kdDebug(5970) << "Entering Task::setRunning " << "on=" << on << "whenStarted=" << whenStarted << " whenStopped=" << whenStopped << endl;
+  if ( on ) 
+  {
     if (isComplete()) return; // don't start if its marked complete
-    if (!_timer->isActive()) {
+    if (!_timer->isActive()) 
+    {
       _timer->start(1000);
       storage->startTimer(this);
       _currentPic=7;
@@ -108,10 +111,13 @@
       updateActiveIcon();
     }
   }
-  else {
-    if (_timer->isActive()) {
+  else 
+  {
+    if (_timer->isActive()) 
+    {
       _timer->stop();
-      if ( ! _removing ) {
+      if ( ! _removing ) 
+      {
         storage->stopTimer(this, whenStopped);
         setPixmap(1, UserIcon(QString::fromLatin1("empty-watch.xpm")));
       }
--- branches/KDE/3.5/kdepim/karm/taskview.cpp #658730:658731
@@ -421,7 +421,7 @@
 // stops all timers for the time qdt. This makes sense, if the idletimedetector detected
 // the last work has been done 50 minutes ago.
 {
-  kdDebug(5970) << "Entering TaskView::stopAllTimersAt" << endl;
+  kdDebug(5970) << "Entering TaskView::stopAllTimersAt " << qdt << endl;
   for ( unsigned int i = 0; i < activeTasks.count(); i++ )
   {
     activeTasks.at(i)->setRunning(false, _storage, qdt, qdt);
Comment 3 Thorsten Staerk 2007-04-28 13:58:16 UTC
SVN commit 658742 by tstaerk:

Do not store the reduction of time, only subtract it in memory.
CCBUGS:144782



 M  +8 -6      idletimedetector.cpp  
 M  +6 -1      taskview.cpp  
 M  +4 -1      taskview.h  


--- branches/KDE/3.5/kdepim/karm/idletimedetector.cpp #658741:658742
@@ -59,8 +59,7 @@
 void IdleTimeDetector::informOverrun(int idleMinutes)
 {
   if (!_overAllIdleDetect)
-    return; // In the preferences the user has indicated that he do not
-            // want idle detection.
+    return; // preferences say the user does not want idle detection.
 
   _timer->stop();
 
@@ -77,19 +76,22 @@
   QDateTime end = QDateTime::currentDateTime();
   int diff = start.secsTo(end)/secsPerMinute;
 
-  if (id == 0) {
+  if (id == 0) 
+  {
     // Revert And Stop
-    kdDebug(5970) << "Now it is " << KGlobal::locale()->formatTime(QDateTime::currentDateTime().time()).ascii() << endl;
+    kdDebug(5970) << "Now it is " << QDateTime::currentDateTime() << endl;
     kdDebug(5970) << "Reverting timer to " << KGlobal::locale()->formatTime(idleStart.time()).ascii() << endl;
     emit(extractTime(idleMinutes+diff)); // we need to subtract the time that has been added during idleness.
     emit(stopAllTimersAt(idleStart));
   }
-  else if (id == 1) {
+  else if (id == 1) 
+  {
     // Revert and Continue
     emit(extractTime(idleMinutes+diff));
     _timer->start(testInterval);
   }
-  else {
+  else 
+  {
     // Continue
     _timer->start(testInterval);
   }
--- branches/KDE/3.5/kdepim/karm/taskview.cpp #658741:658742
@@ -696,9 +696,14 @@
 }
 
 void TaskView::extractTime(int minutes)
+// This procedure subtracts ''minutes'' from the active task's time in the memory.
+// It is called by the idletimedetector class.
+// When the desktop has been idle for the past 20 minutes, the past 20 minutes have 
+// already been added to the task's time in order for the time to be displayed correctly.
+// That is why idletimedetector needs to subtract this time first.
 {
   kdDebug(5970) << "Entering extractTime" << endl;
-  addTimeToActiveTasks(-minutes);
+  addTimeToActiveTasks(-minutes,false); // subtract minutes, but do not store it
 }
 
 void TaskView::autoSaveChanged(bool on)
--- branches/KDE/3.5/kdepim/karm/taskview.h #658741:658742
@@ -157,7 +157,10 @@
     void markTaskAsComplete();
     void markTaskAsIncomplete();
 
-    /** Subtracts time from all active tasks, and does not log event. */
+    /** Subtracts time from all active tasks, and does not log event. 
+     * The time is stored in memory and in X-KDE-karm-duration. It is
+     * increased automatically every minute to display the right duration.
+     */
     void extractTime( int minutes );
     void taskTotalTimesChanged( long session, long total)
                                 { emit totalTimesChanged( session, total); };
Comment 4 Thorsten Staerk 2007-04-28 22:25:18 UTC
I produced this bug by fixing https://bugs.kde.org/show_bug.cgi?id=135002. This is a complicated topic.
Comment 5 Thorsten Staerk 2007-04-29 10:40:51 UTC
SVN commit 659014 by tstaerk:

Revert time.
CCBUGS:144782


 M  +1 -1      idletimedetector.cpp  
 M  +1 -1      taskview.cpp  


--- trunk/KDE/kdepim/ktimetracker/idletimedetector.cpp #659013:659014
@@ -86,7 +86,7 @@
   kDebug(5970) << "Entering IdleTimeDetector::revert" << endl;
   QDateTime end = QDateTime::currentDateTime();
   int diff = start.secsTo(end)/secsPerMinute;
-  //emit(extractTime(idleminutes+diff));
+  emit(extractTime(idleminutes+diff)); // subtract the time that has been added on the display
   emit(stopAllTimers(idlestart));
 }
 
--- trunk/KDE/kdepim/ktimetracker/taskview.cpp #659013:659014
@@ -938,7 +938,7 @@
 
 void TaskView::extractTime(int minutes)
 {
-  addTimeToActiveTasks(-minutes);
+  addTimeToActiveTasks(-minutes,false); // subtract time in memory, but do not store it
 }
 
 void TaskView::autoSaveChanged(bool on)
Comment 6 Thorsten Staerk 2007-06-12 22:22:57 UTC
*** Bug has been marked as fixed ***.
Comment 7 Pradeepto K. Bhattacharya 2008-01-04 08:20:58 UTC
SVN commit 757105 by pradeepto:

Merged revisions 658731 via svnmerge from 
svn+ssh://pradeepto@svn.kde.org/home/kde/branches/KDE/3.5/kdepim

........
  r658731 | tstaerk | 2007-04-28 15:59:49 +0530 (Sat, 28 Apr 2007) | 3 lines
  
  Subtract the time that has been added while the desktop has been idle.
  CCBUGS:144782
........


 _M            . (directory)  


WebSVN link: http://websvn.kde.org/?view=rev&revision=757105
Comment 8 Pradeepto K. Bhattacharya 2008-01-04 09:40:20 UTC
SVN commit 757111 by pradeepto:

Merged revisions 658742 via svnmerge from 
svn+ssh://pradeepto@svn.kde.org/home/kde/branches/KDE/3.5/kdepim

........
  r658742 | tstaerk | 2007-04-28 17:28:08 +0530 (Sat, 28 Apr 2007) | 4 lines
  
  Do not store the reduction of time, only subtract it in memory.
  CCBUGS:144782
........


 _M            . (directory)  


WebSVN link: http://websvn.kde.org/?view=rev&revision=757111