Completed the import functionality.

Sun, 21 Oct 2012 14:53:23 +0200

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Sun, 21 Oct 2012 14:53:23 +0200
changeset 10
64acf4452ac0
parent 9
1c7fd3151ba2
child 11
1eabdd26c44e

Completed the import functionality.

TimeTracker/TimeTrackEntry.py file | annotate | diff | comparison | revisions
TimeTracker/TimeTracker.py file | annotate | diff | comparison | revisions
--- a/TimeTracker/TimeTrackEntry.py	Sat Oct 20 22:46:24 2012 +0200
+++ b/TimeTracker/TimeTrackEntry.py	Sun Oct 21 14:53:23 2012 +0200
@@ -7,7 +7,7 @@
 Module implementing the time track entry class.
 """
 
-from PyQt4.QtCore import Qt, QDateTime
+from PyQt4.QtCore import Qt, QDateTime, QTime
 
 
 class TimeTrackEntry(object):
@@ -111,7 +111,7 @@
         """
         Public method to set the start time of this entry.
         """
-        self.__startDateTime = QDateTime.currentDateTime()
+        self.__startDateTime = self.__currentDateTime()
         self.__continueDateTime = QDateTime(self.__startDateTime)
     
     def stop(self):
@@ -144,7 +144,7 @@
         Public method to continue the entry.
         """
         if self.__paused:
-            self.__continueDateTime = QDateTime(self.__startDateTime)
+            self.__continueDateTime = self.__currentDateTime()
             self.__paused = False
     
     def isPaused(self):
@@ -155,6 +155,18 @@
         """
         return self.__paused
     
+    def __currentDateTime(self):
+        """
+        Private method to get the current date and time without milliseconds.
+        
+        @return current date and time (QDateTime)
+        """
+        dt = QDateTime.currentDateTime()
+        t = dt.time()
+        t2 = QTime(t.hour(), t.minute(), t.second())
+        dt.setTime(t2)
+        return dt
+    
     def __calculateDuration(self, start, stop):
         """
         Private method to calculate the duration in minutes.
--- a/TimeTracker/TimeTracker.py	Sat Oct 20 22:46:24 2012 +0200
+++ b/TimeTracker/TimeTracker.py	Sun Oct 21 14:53:23 2012 +0200
@@ -210,6 +210,10 @@
             E5MessageBox.information(self.__ui,
                 self.trUtf8("Import Time Tracker File"),
                 msg)
+        
+        self.__widget.clear()
+        self.__widget.showTrackerEntries(sorted(self.__entries.values(), reverse=True))
+        self.__widget.setCurrentEntry(self.__currentEntry)
     
     def pauseTrackerEntry(self):
         """

eric ide

mercurial