TimeTracker/TimeTrackerWidget.py

changeset 3
ce9309868f8a
parent 2
058c6a316ca8
child 4
c67abfea9955
equal deleted inserted replaced
2:058c6a316ca8 3:ce9309868f8a
15 15
16 class TimeTrackerWidget(QWidget, Ui_TimeTrackerWidget): 16 class TimeTrackerWidget(QWidget, Ui_TimeTrackerWidget):
17 """ 17 """
18 Class implementing the time tracker widget. 18 Class implementing the time tracker widget.
19 """ 19 """
20 DurationColumn = 1
21 TaskColumn = 2
22 CommentColumn = 3
23
20 def __init__(self, tracker, parent=None): 24 def __init__(self, tracker, parent=None):
21 """ 25 """
22 Constructor 26 Constructor
23 27
24 @param tracker reference to the time tracker (TimeTracker) 28 @param tracker reference to the time tracker (TimeTracker)
28 self.setupUi(self) 32 self.setupUi(self)
29 33
30 self.__tracker = tracker 34 self.__tracker = tracker
31 35
32 @pyqtSlot(str) 36 @pyqtSlot(str)
33 def on_taskCombo_editTextChanged(self, p0): 37 def on_taskCombo_editTextChanged(self, txt):
34 """ 38 """
35 Slot documentation goes here. 39 Private slot handling changes of the task description of the current entry.
36 """ 40
37 # TODO: not implemented yet 41 @param txt new task description (string)
38 raise NotImplementedError 42 """
43 itm = self.entriesList.topLevelItem(0)
44 itm.setText(self.TaskColumn, txt)
45 self.entriesList.resizeColumnToContents(self.TaskColumn)
46
47 entry = self.__tracker.getCurrentEntry()
48 entry.setTask(txt)
39 49
40 @pyqtSlot(str) 50 @pyqtSlot(str)
41 def on_commentCombo_editTextChanged(self, p0): 51 def on_commentCombo_editTextChanged(self, txt):
42 """ 52 """
43 Slot documentation goes here. 53 Private slot handling changes of the comment of the current entry.
44 """ 54
45 # TODO: not implemented yet 55 @param txt new comment (string)
46 raise NotImplementedError 56 """
57 itm = self.entriesList.topLevelItem(0)
58 itm.setText(self.CommentColumn, txt)
59 self.entriesList.resizeColumnToContents(self.CommentColumn)
60
61 entry = self.__tracker.getCurrentEntry()
62 entry.setComment(txt)
47 63
48 @pyqtSlot(bool) 64 @pyqtSlot(bool)
49 def on_pauseButton_toggled(self, checked): 65 def on_pauseButton_toggled(self, checked):
50 """ 66 """
51 Slot documentation goes here. 67 Private slot to pause the current timing.
52 """ 68 """
53 # TODO: not implemented yet 69 if checked:
54 raise NotImplementedError 70 self.__tracker.pauseTrackerEntry()
71
72 entry = self.__tracker.getCurrentEntry()
73 duration = entry.getDuration()
74
75 itm = self.entriesList.topLevelItem(0)
76 itm.setText(self.DurationColumn, str(duration))
77 self.entriesList.resizeColumnToContents(self.CommentColumn)
78 else:
79 self.__tracker.continueTrackerEntry()
55 80
56 @pyqtSlot() 81 @pyqtSlot()
57 def on_newButton_clicked(self): 82 def on_newButton_clicked(self):
58 """ 83 """
59 Slot documentation goes here. 84 Slot documentation goes here.
138 if index == -1: 163 if index == -1:
139 self.entriesList.addTopLevelItem(itm) 164 self.entriesList.addTopLevelItem(itm)
140 else: 165 else:
141 self.entriesList.insertTopLevelItem(index, itm) 166 self.entriesList.insertTopLevelItem(index, itm)
142 167
168 def __resizeColumns(self):
169 """
170 Private slot to resize the columns of the entries list.
171 """
172 for column in range(self.entriesList.columnCount()):
173 self.entriesList.resizeColumnToContents(column)
174
143 def showTrackerEntries(self, entries): 175 def showTrackerEntries(self, entries):
144 """ 176 """
145 Public method to show the tracker entries of the current project. 177 Public method to show the tracker entries of the current project.
146 178
147 @param entries list of tracker entries (list of TimeTrackEntry) 179 @param entries list of tracker entries (list of TimeTrackEntry)
148 """ 180 """
149 for entry in entries: 181 for entry in entries:
150 self.__insertEntry(entry) 182 self.__insertEntry(entry)
151 for column in range(self.entriesList.columnCount()): 183 self.__resizeColumns()
152 self.entriesList.resizeColumnToContents(column)
153 184
154 def setCurrentEntry(self, entry): 185 def setCurrentEntry(self, entry):
155 """ 186 """
156 Public method to set the current entry. 187 Public method to set the current entry.
157 188
158 @param entry current entry (TimeTrackEntry) 189 @param entry current entry (TimeTrackEntry)
159 """ 190 """
160 self.__insertEntry(entry, 0) 191 self.__insertEntry(entry, 0)
192 self.__resizeColumns()
193
161 date, time, duration, task, comment, paused = entry.getEntryData() 194 date, time, duration, task, comment, paused = entry.getEntryData()
162 self.startDateTimeEdit.setDateTime(entry.getStartDateTime()) 195 self.startDateTimeEdit.setDateTime(entry.getStartDateTime())
163 self.durationSpinBox.setValue(duration) 196 self.durationSpinBox.setValue(duration)
164 self.taskCombo.setEditText(task) 197 self.taskCombo.setEditText(task)
165 self.commentCombo.setEditText(comment) 198 self.commentCombo.setEditText(comment)

eric ide

mercurial