TimeTracker/TimeTrackerWidget.py

changeset 4
c67abfea9955
parent 3
ce9309868f8a
child 5
6633e2836f8f
--- a/TimeTracker/TimeTrackerWidget.py	Fri Oct 19 22:26:57 2012 +0200
+++ b/TimeTracker/TimeTrackerWidget.py	Sat Oct 20 12:34:26 2012 +0200
@@ -73,18 +73,27 @@
             duration = entry.getDuration()
             
             itm = self.entriesList.topLevelItem(0)
-            itm.setText(self.DurationColumn, str(duration))
+            itm.setText(self.DurationColumn, self.tr("{0} min").format(duration))
             self.entriesList.resizeColumnToContents(self.CommentColumn)
+            
+            self.durationSpinBox.setValue(duration)
         else:
             self.__tracker.continueTrackerEntry()
     
     @pyqtSlot()
     def on_newButton_clicked(self):
         """
-        Slot documentation goes here.
+        Private slot to end the current timer and start a new one.
         """
-        # TODO: not implemented yet
-        raise NotImplementedError
+        # stop the current tracker
+        eid, duration = self.__tracker.stopTrackerEntry()
+        itm = self.entriesList.topLevelItem(0)
+        itm.setText(self.DurationColumn, self.tr("{0} min").format(duration))
+        itm.setData(0, Qt.UserRole, eid)
+        self.entriesList.resizeColumnToContents(self.CommentColumn)
+        
+        # start a new one
+        self.__tracker.startTrackerEntry()
     
     @pyqtSlot(QPoint)
     def on_entriesList_customContextMenuRequested(self, pos):
@@ -156,10 +165,12 @@
         @param index index the entry is to be inserted; -1 for at the end
             (integer)
         """
-        date, time, duration, task, comment, paused = entry.getEntryData()
+        eid, date, time, duration, task, comment, paused = entry.getEntryData()
         itm = QTreeWidgetItem(
-            ["{0}, {1}".format(date, time), str(duration), task, comment])
+            [self.tr("{0}, {1}", "date, time").format(date, time),
+             self.tr("{0} min").format(duration), task, comment])
         itm.setTextAlignment(1, Qt.AlignRight)
+        itm.setData(0, Qt.UserRole, eid)
         if index == -1:
             self.entriesList.addTopLevelItem(itm)
         else:
@@ -191,7 +202,7 @@
         self.__insertEntry(entry, 0)
         self.__resizeColumns()
         
-        date, time, duration, task, comment, paused = entry.getEntryData()
+        eid, date, time, duration, task, comment, paused = entry.getEntryData()
         self.startDateTimeEdit.setDateTime(entry.getStartDateTime())
         self.durationSpinBox.setValue(duration)
         self.taskCombo.setEditText(task)

eric ide

mercurial