eric6/Tasks/Task.py

changeset 8278
e647b71b393f
parent 8269
87f521f359d5
child 8280
17d03699f151
equal deleted inserted replaced
8277:ea734702ae94 8278:e647b71b393f
5 5
6 """ 6 """
7 Module implementing a class to store task data. 7 Module implementing a class to store task data.
8 """ 8 """
9 9
10 import contextlib
11 import enum
10 import os 12 import os
11 import time 13 import time
12 import contextlib
13 14
14 from PyQt5.QtCore import Qt, QUuid 15 from PyQt5.QtCore import Qt, QUuid
15 from PyQt5.QtWidgets import QTreeWidgetItem 16 from PyQt5.QtWidgets import QTreeWidgetItem
16 17
17 import UI.PixmapCache 18 import UI.PixmapCache
18 import Preferences 19 import Preferences
20
21
22 class TaskType(enum.IntEnum):
23 """
24 Class defining the task types.
25 """
26 NONE = 255
27 FIXME = 0
28 TODO = 1
29 WARNING = 2
30 NOTE = 3
31 TEST = 4
32 DOCU = 5
19 33
20 34
21 # TODO: separate into Task and TaskItem(QTreeWidgetItem) (eric7) 35 # TODO: separate into Task and TaskItem(QTreeWidgetItem) (eric7)
22 class Task(QTreeWidgetItem): 36 class Task(QTreeWidgetItem):
23 """ 37 """
24 Class implementing the task data structure. 38 Class implementing the task data structure.
25 """ 39 """
26 # TODO: add Enum for priority 40 # TODO: add IntEnum for priority
27 # TODO: convert to Enum
28 TypeNone = -1
29 TypeFixme = 0
30 TypeTodo = 1
31 TypeWarning = 2
32 TypeNote = 3
33 TypeTest = 4
34 TypeDocu = 5
35 41
36 TaskType2IconName = { 42 TaskType2IconName = {
37 TypeFixme: "taskFixme", 43 TaskType.FIXME: "taskFixme", # __NO-TASK__
38 TypeTodo: "taskTodo", 44 TaskType.TODO: "taskTodo", # __NO-TASK__
39 TypeWarning: "taskWarning", 45 TaskType.WARNING: "taskWarning", # __NO-TASK__
40 TypeNote: "taskNote", 46 TaskType.NOTE: "taskNote", # __NO-TASK__
41 TypeTest: "taskTest", 47 TaskType.TEST: "taskTest", # __NO-TASK__
42 TypeDocu: "taskDocu", 48 TaskType.DOCU: "taskDocu", # __NO-TASK__
43 } 49 }
44 TaskType2ColorName = { 50 TaskType2ColorName = {
45 TypeFixme: "TasksFixmeColor", 51 TaskType.FIXME: "TasksFixmeColor", # __NO-TASK__
46 TypeTodo: "TasksTodoColor", 52 TaskType.TODO: "TasksTodoColor", # __NO-TASK__
47 TypeWarning: "TasksWarningColor", 53 TaskType.WARNING: "TasksWarningColor", # __NO-TASK__
48 TypeNote: "TasksNoteColor", 54 TaskType.NOTE: "TasksNoteColor", # __NO-TASK__
49 TypeTest: "TasksTestColor", 55 TaskType.TEST: "TasksTestColor", # __NO-TASK__
50 TypeDocu: "TasksDocuColor", 56 TaskType.DOCU: "TasksDocuColor", # __NO-TASK__
51 } 57 }
52 TaskType2MarkersName = { 58 TaskType2MarkersName = {
53 TypeFixme: "TasksFixmeMarkers", 59 TaskType.FIXME: "TasksFixmeMarkers", # __NO-TASK__
54 TypeTodo: "TasksTodoMarkers", 60 TaskType.TODO: "TasksTodoMarkers", # __NO-TASK__
55 TypeWarning: "TasksWarningMarkers", 61 TaskType.WARNING: "TasksWarningMarkers", # __NO-TASK__
56 TypeNote: "TasksNoteMarkers", 62 TaskType.NOTE: "TasksNoteMarkers", # __NO-TASK__
57 TypeTest: "TasksTestMarkers", 63 TaskType.TEST: "TasksTestMarkers", # __NO-TASK__
58 TypeDocu: "TasksDocuMarkers", 64 TaskType.DOCU: "TasksDocuMarkers", # __NO-TASK__
59 } 65 }
60 66
61 def __init__(self, summary, priority=1, filename="", lineno=0, 67 def __init__(self, summary, priority=1, filename="", lineno=0,
62 completed=False, _time=0, isProjectTask=False, 68 completed=False, _time=0, isProjectTask=False,
63 taskType=TypeTodo, project=None, description="", 69 taskType=TaskType.TODO, project=None, description="",
64 uid="", parentUid=""): 70 uid="", parentUid=""):
65 """ 71 """
66 Constructor 72 Constructor
67 73
68 @param summary summary text of the task (string) 74 @param summary summary text of the task
75 @type str
69 @param priority priority of the task (0=high, 1=normal, 2=low) 76 @param priority priority of the task (0=high, 1=normal, 2=low)
70 @param filename filename containing the task (string) 77 @type int
71 @param lineno line number containing the task (integer) 78 @param filename filename containing the task
72 @param completed flag indicating completion status (boolean) 79 @type str
73 @param _time creation time of the task (float, if 0 use current time) 80 @param lineno line number containing the task
81 @type int
82 @param completed flag indicating completion status
83 @type bool
84 @param _time creation time of the task (if 0 use current time)
85 @type float
74 @param isProjectTask flag indicating a task related to the current 86 @param isProjectTask flag indicating a task related to the current
75 project (boolean) 87 project
76 @param taskType type of the task (one of TypeFixme, TypeTodo, 88 @type bool
77 TypeWarning, TypeNote, TypeTest, TypeDocu) 89 @param taskType type of the task
78 @param project reference to the project object (Project) 90 @type TaskType
79 @param description explanatory text of the task (string) 91 @param project reference to the project object
80 @param uid unique id of the task (string) 92 @type Project
81 @param parentUid unique id of the parent task (string) 93 @param description explanatory text of the task
94 @type str
95 @param uid unique id of the task
96 @type str
97 @param parentUid unique id of the parent task
98 @type str
82 """ 99 """
83 super().__init__() 100 super().__init__()
84 101
85 self.summary = summary 102 self.summary = summary
86 self.description = description 103 self.description = description
306 "description": self.description.strip(), 323 "description": self.description.strip(),
307 "priority": self.priority, 324 "priority": self.priority,
308 "lineno": self.lineno, 325 "lineno": self.lineno,
309 "completed": self.completed, 326 "completed": self.completed,
310 "created": self.created, 327 "created": self.created,
311 "type": self.taskType, 328 "type": self.taskType.value,
312 "uid": self.uid, 329 "uid": self.uid,
313 "parent_uid": self.parentUid, 330 "parent_uid": self.parentUid,
314 "expanded": self.isExpanded(), 331 "expanded": self.isExpanded(),
315 "filename": self.getFilename(), 332 "filename": self.getFilename(),
316 } 333 }

eric ide

mercurial