Tasks/Task.py

changeset 3990
5dd6edf8540a
parent 3656
441956d8fce5
child 4021
195a471c327b
equal deleted inserted replaced
3987:57354896fd29 3990:5dd6edf8540a
10 from __future__ import unicode_literals 10 from __future__ import unicode_literals
11 11
12 import os 12 import os
13 import time 13 import time
14 14
15 from PyQt5.QtCore import Qt 15 from PyQt5.QtCore import Qt, QUuid
16 from PyQt5.QtWidgets import QTreeWidgetItem 16 from PyQt5.QtWidgets import QTreeWidgetItem
17 17
18 import UI.PixmapCache 18 import UI.PixmapCache
19 import Preferences 19 import Preferences
20 20
29 TypeWarning = 2 29 TypeWarning = 2
30 TypeNote = 3 30 TypeNote = 3
31 31
32 def __init__(self, summary, priority=1, filename="", lineno=0, 32 def __init__(self, summary, priority=1, filename="", lineno=0,
33 completed=False, _time=0, isProjectTask=False, 33 completed=False, _time=0, isProjectTask=False,
34 taskType=TypeTodo, project=None, description=""): 34 taskType=TypeTodo, project=None, description="",
35 uid="", parentUid=""):
35 """ 36 """
36 Constructor 37 Constructor
37 38
38 @param summary summary text of the task (string) 39 @param summary summary text of the task (string)
39 @param priority priority of the task (0=high, 1=normal, 2=low) 40 @param priority priority of the task (0=high, 1=normal, 2=low)
45 project (boolean) 46 project (boolean)
46 @param taskType type of the task (one of TypeFixme, TypeTodo, 47 @param taskType type of the task (one of TypeFixme, TypeTodo,
47 TypeWarning, TypeNote) 48 TypeWarning, TypeNote)
48 @param project reference to the project object (Project) 49 @param project reference to the project object (Project)
49 @param description explanatory text of the task (string) 50 @param description explanatory text of the task (string)
51 @param uid unique id of the task (string)
52 @param parentUid unique id of the parent task (string)
50 """ 53 """
51 super(Task, self).__init__() 54 super(Task, self).__init__()
52 55
53 self.summary = summary 56 self.summary = summary
54 self.description = description 57 self.description = description
61 self.completed = completed 64 self.completed = completed
62 self.created = _time and _time or time.time() 65 self.created = _time and _time or time.time()
63 self._isProjectTask = isProjectTask 66 self._isProjectTask = isProjectTask
64 self.taskType = taskType 67 self.taskType = taskType
65 self.project = project 68 self.project = project
69 if uid:
70 self.uid = uid
71 else:
72 self.uid = QUuid.createUuid().toString()
73 self.parentUid = parentUid
66 74
67 if isProjectTask: 75 if isProjectTask:
68 self.filename = self.project.getRelativePath(self.filename) 76 self.filename = self.project.getRelativePath(self.filename)
69 77
70 self.setData(0, Qt.DisplayRole, "") 78 self.setData(0, Qt.DisplayRole, "")
179 strikeOut = False 187 strikeOut = False
180 for column in range(2, 5): 188 for column in range(2, 5):
181 f = self.font(column) 189 f = self.font(column)
182 f.setStrikeOut(strikeOut) 190 f.setStrikeOut(strikeOut)
183 self.setFont(column, f) 191 self.setFont(column, f)
192
193 # set the completion status for all children
194 for index in range(self.childCount()):
195 self.child(index).setCompleted(completed)
184 196
185 def isCompleted(self): 197 def isCompleted(self):
186 """ 198 """
187 Public slot to return the completion status. 199 Public slot to return the completion status.
188 200
190 """ 202 """
191 return self.completed 203 return self.completed
192 204
193 def getFilename(self): 205 def getFilename(self):
194 """ 206 """
195 Public method to retrieve the tasks filename. 207 Public method to retrieve the task's filename.
196 208
197 @return filename (string) 209 @return filename (string)
198 """ 210 """
199 if self._isProjectTask and self.filename: 211 if self._isProjectTask and self.filename:
200 return os.path.join(self.project.getProjectPath(), self.filename) 212 return os.path.join(self.project.getProjectPath(), self.filename)
201 else: 213 else:
202 return self.filename 214 return self.filename
203 215
216 def isFileTask(self):
217 """
218 Public slot to get an indication, if this task is related to a file.
219
220 @return flag indicating a file task (boolean)
221 """
222 return self.filename != ""
223
204 def getLineno(self): 224 def getLineno(self):
205 """ 225 """
206 Public method to retrieve the tasks linenumber. 226 Public method to retrieve the task's linenumber.
207 227
208 @return linenumber (integer) 228 @return linenumber (integer)
209 """ 229 """
210 return self.lineno 230 return self.lineno
231
232 def getUuid(self):
233 """
234 Public method to get the task's uid.
235
236 @return uid (string)
237 """
238 return self.uid
239
240 def getParentUuid(self):
241 """
242 Public method to get the parent task's uid.
243
244 @return parent uid (string)
245 """
246 return self.parentUid
211 247
212 def setProjectTask(self, pt): 248 def setProjectTask(self, pt):
213 """ 249 """
214 Public method to set the project relation flag. 250 Public method to set the project relation flag.
215 251

eric ide

mercurial