TimeTracker/TimeTrackEntry.py

changeset 10
64acf4452ac0
parent 8
17d90f9425fc
child 11
1eabdd26c44e
equal deleted inserted replaced
9:1c7fd3151ba2 10:64acf4452ac0
5 5
6 """ 6 """
7 Module implementing the time track entry class. 7 Module implementing the time track entry class.
8 """ 8 """
9 9
10 from PyQt4.QtCore import Qt, QDateTime 10 from PyQt4.QtCore import Qt, QDateTime, QTime
11 11
12 12
13 class TimeTrackEntry(object): 13 class TimeTrackEntry(object):
14 """ 14 """
15 Class implementing the time track entry. 15 Class implementing the time track entry.
109 109
110 def start(self): 110 def start(self):
111 """ 111 """
112 Public method to set the start time of this entry. 112 Public method to set the start time of this entry.
113 """ 113 """
114 self.__startDateTime = QDateTime.currentDateTime() 114 self.__startDateTime = self.__currentDateTime()
115 self.__continueDateTime = QDateTime(self.__startDateTime) 115 self.__continueDateTime = QDateTime(self.__startDateTime)
116 116
117 def stop(self): 117 def stop(self):
118 """ 118 """
119 Public method to stop this entry. 119 Public method to stop this entry.
142 def continue_(self): 142 def continue_(self):
143 """ 143 """
144 Public method to continue the entry. 144 Public method to continue the entry.
145 """ 145 """
146 if self.__paused: 146 if self.__paused:
147 self.__continueDateTime = QDateTime(self.__startDateTime) 147 self.__continueDateTime = self.__currentDateTime()
148 self.__paused = False 148 self.__paused = False
149 149
150 def isPaused(self): 150 def isPaused(self):
151 """ 151 """
152 Public method to check for a paused state. 152 Public method to check for a paused state.
153 153
154 @return flag indicating a paused state (boolean) 154 @return flag indicating a paused state (boolean)
155 """ 155 """
156 return self.__paused 156 return self.__paused
157
158 def __currentDateTime(self):
159 """
160 Private method to get the current date and time without milliseconds.
161
162 @return current date and time (QDateTime)
163 """
164 dt = QDateTime.currentDateTime()
165 t = dt.time()
166 t2 = QTime(t.hour(), t.minute(), t.second())
167 dt.setTime(t2)
168 return dt
157 169
158 def __calculateDuration(self, start, stop): 170 def __calculateDuration(self, start, stop):
159 """ 171 """
160 Private method to calculate the duration in minutes. 172 Private method to calculate the duration in minutes.
161 173

eric ide

mercurial