30 NOTE = 3 |
30 NOTE = 3 |
31 TEST = 4 |
31 TEST = 4 |
32 DOCU = 5 |
32 DOCU = 5 |
33 |
33 |
34 |
34 |
35 # TODO: separate into Task and TaskItem(QTreeWidgetItem) (eric7) |
35 class TaskPriority(enum.IntEnum): |
|
36 """ |
|
37 Class defining the task priorities. |
|
38 """ |
|
39 HIGH = 0 |
|
40 NORMAL = 1 |
|
41 LOW = 2 |
|
42 |
|
43 |
|
44 # TODO: eric7: separate into Task and TaskItem(QTreeWidgetItem) |
36 class Task(QTreeWidgetItem): |
45 class Task(QTreeWidgetItem): |
37 """ |
46 """ |
38 Class implementing the task data structure. |
47 Class implementing the task data structure. |
39 """ |
48 """ |
40 # TODO: add IntEnum for priority |
|
41 |
|
42 TaskType2IconName = { |
49 TaskType2IconName = { |
43 TaskType.FIXME: "taskFixme", # __NO-TASK__ |
50 TaskType.FIXME: "taskFixme", # __NO-TASK__ |
44 TaskType.TODO: "taskTodo", # __NO-TASK__ |
51 TaskType.TODO: "taskTodo", # __NO-TASK__ |
45 TaskType.WARNING: "taskWarning", # __NO-TASK__ |
52 TaskType.WARNING: "taskWarning", # __NO-TASK__ |
46 TaskType.NOTE: "taskNote", # __NO-TASK__ |
53 TaskType.NOTE: "taskNote", # __NO-TASK__ |
62 TaskType.NOTE: "TasksNoteMarkers", # __NO-TASK__ |
69 TaskType.NOTE: "TasksNoteMarkers", # __NO-TASK__ |
63 TaskType.TEST: "TasksTestMarkers", # __NO-TASK__ |
70 TaskType.TEST: "TasksTestMarkers", # __NO-TASK__ |
64 TaskType.DOCU: "TasksDocuMarkers", # __NO-TASK__ |
71 TaskType.DOCU: "TasksDocuMarkers", # __NO-TASK__ |
65 } |
72 } |
66 |
73 |
67 def __init__(self, summary, priority=1, filename="", lineno=0, |
74 def __init__(self, summary, priority=TaskPriority.NORMAL, filename="", |
68 completed=False, _time=0, isProjectTask=False, |
75 lineno=0, completed=False, _time=0, isProjectTask=False, |
69 taskType=TaskType.TODO, project=None, description="", |
76 taskType=TaskType.TODO, project=None, description="", |
70 uid="", parentUid=""): |
77 uid="", parentUid=""): |
71 """ |
78 """ |
72 Constructor |
79 Constructor |
73 |
80 |
74 @param summary summary text of the task |
81 @param summary summary text of the task |
75 @type str |
82 @type str |
76 @param priority priority of the task (0=high, 1=normal, 2=low) |
83 @param priority priority of the task |
77 @type int |
84 @type TaskPriority |
78 @param filename filename containing the task |
85 @param filename filename containing the task |
79 @type str |
86 @type str |
80 @param lineno line number containing the task |
87 @param lineno line number containing the task |
81 @type int |
88 @type int |
82 @param completed flag indicating completion status |
89 @param completed flag indicating completion status |
99 """ |
106 """ |
100 super().__init__() |
107 super().__init__() |
101 |
108 |
102 self.summary = summary |
109 self.summary = summary |
103 self.description = description |
110 self.description = description |
104 if priority in [0, 1, 2]: |
|
105 self.priority = priority |
|
106 else: |
|
107 self.priority = 1 |
|
108 self.filename = filename |
111 self.filename = filename |
109 self.lineno = lineno |
112 self.lineno = lineno |
110 self.completed = completed |
113 self.completed = completed |
111 self.created = _time and _time or time.time() |
114 self.created = _time and _time or time.time() |
112 self._isProjectTask = isProjectTask |
115 self._isProjectTask = isProjectTask |
113 self.taskType = taskType |
|
114 self.project = project |
116 self.project = project |
115 if uid: |
117 if uid: |
116 self.uid = uid |
118 self.uid = uid |
117 else: |
119 else: |
118 self.uid = QUuid.createUuid().toString() |
120 self.uid = QUuid.createUuid().toString() |
136 for column in range(2, 5): |
138 for column in range(2, 5): |
137 f = self.font(column) |
139 f = self.font(column) |
138 f.setStrikeOut(strikeOut) |
140 f.setStrikeOut(strikeOut) |
139 self.setFont(column, f) |
141 self.setFont(column, f) |
140 |
142 |
141 if self.priority == 1: |
143 self.setPriority(priority) |
142 self.setIcon(1, UI.PixmapCache.getIcon("empty")) |
144 |
143 elif self.priority == 0: |
145 self.setTaskType(taskType) |
144 self.setIcon(1, UI.PixmapCache.getIcon("taskPrioHigh")) |
|
145 elif self.priority == 2: |
|
146 self.setIcon(1, UI.PixmapCache.getIcon("taskPrioLow")) |
|
147 else: |
|
148 self.setIcon(1, UI.PixmapCache.getIcon("empty")) |
|
149 |
|
150 try: |
|
151 self.setIcon(2, UI.PixmapCache.getIcon( |
|
152 Task.TaskType2IconName[self.taskType])) |
|
153 except KeyError: |
|
154 self.setIcon(2, UI.PixmapCache.getIcon("empty")) |
|
155 |
|
156 self.colorizeTask() |
|
157 self.setTextAlignment(4, Qt.AlignmentFlag.AlignRight) |
146 self.setTextAlignment(4, Qt.AlignmentFlag.AlignRight) |
158 |
147 |
159 def colorizeTask(self): |
148 def colorizeTask(self): |
160 """ |
149 """ |
161 Public slot to set the colors of the task item. |
150 Public slot to set the colors of the task item. |
186 |
175 |
187 def setDescription(self, description): |
176 def setDescription(self, description): |
188 """ |
177 """ |
189 Public slot to update the description field. |
178 Public slot to update the description field. |
190 |
179 |
191 @param description descriptive text of the task (string) |
180 @param description descriptive text of the task |
|
181 @type str |
192 """ |
182 """ |
193 self.description = description |
183 self.description = description |
194 |
184 |
195 def setPriority(self, priority): |
185 def setPriority(self, priority): |
196 """ |
186 """ |
197 Public slot to update the priority. |
187 Public slot to update the priority. |
198 |
188 |
199 @param priority priority of the task (0=high, 1=normal, 2=low) |
189 @param priority priority of the task |
200 """ |
190 @type TaskPriority |
201 if priority in [0, 1, 2]: |
191 """ |
202 self.priority = priority |
192 self.priority = priority |
203 else: |
193 |
204 self.priority = 1 |
194 if self.priority == TaskPriority.NORMAL: |
205 |
|
206 if self.priority == 1: |
|
207 self.setIcon(1, UI.PixmapCache.getIcon("empty")) |
195 self.setIcon(1, UI.PixmapCache.getIcon("empty")) |
208 elif self.priority == 0: |
196 elif self.priority == TaskPriority.HIGH: |
209 self.setIcon(1, UI.PixmapCache.getIcon("taskPrioHigh")) |
197 self.setIcon(1, UI.PixmapCache.getIcon("taskPrioHigh")) |
210 elif self.priority == 2: |
198 elif self.priority == TaskPriority.LOW: |
211 self.setIcon(1, UI.PixmapCache.getIcon("taskPrioLow")) |
199 self.setIcon(1, UI.PixmapCache.getIcon("taskPrioLow")) |
212 else: |
200 else: |
213 self.setIcon(1, UI.PixmapCache.getIcon("empty")) |
201 self.setIcon(1, UI.PixmapCache.getIcon("empty")) |
|
202 |
|
203 def setTaskType(self, taskType): |
|
204 """ |
|
205 Public method to update the task type. |
|
206 |
|
207 @param taskType type of the task |
|
208 @type TaskType |
|
209 """ |
|
210 self.taskType = taskType |
|
211 |
|
212 try: |
|
213 self.setIcon(2, UI.PixmapCache.getIcon( |
|
214 Task.TaskType2IconName[self.taskType])) |
|
215 except KeyError: |
|
216 self.setIcon(2, UI.PixmapCache.getIcon("empty")) |
|
217 |
|
218 self.colorizeTask() |
214 |
219 |
215 def setCompleted(self, completed): |
220 def setCompleted(self, completed): |
216 """ |
221 """ |
217 Public slot to update the completed flag. |
222 Public slot to update the completed flag. |
218 |
223 |
319 @rtype dict |
324 @rtype dict |
320 """ |
325 """ |
321 return { |
326 return { |
322 "summary": self.summary.strip(), |
327 "summary": self.summary.strip(), |
323 "description": self.description.strip(), |
328 "description": self.description.strip(), |
324 "priority": self.priority, |
329 "priority": self.priority.value, |
325 "lineno": self.lineno, |
330 "lineno": self.lineno, |
326 "completed": self.completed, |
331 "completed": self.completed, |
327 "created": self.created, |
332 "created": self.created, |
328 "type": self.taskType.value, |
333 "type": self.taskType.value, |
329 "uid": self.uid, |
334 "uid": self.uid, |