src/eric7/Tasks/Task.py

branch
eric7
changeset 9221
bf71ee032bb4
parent 9209
b99e7fd55fd3
child 9413
80c06d472826
--- a/src/eric7/Tasks/Task.py	Wed Jul 13 11:16:20 2022 +0200
+++ b/src/eric7/Tasks/Task.py	Wed Jul 13 14:55:47 2022 +0200
@@ -23,6 +23,7 @@
     """
     Class defining the task types.
     """
+
     NONE = 255
     FIXME = 0
     TODO = 1
@@ -36,6 +37,7 @@
     """
     Class defining the task priorities.
     """
+
     HIGH = 0
     NORMAL = 1
     LOW = 2
@@ -45,38 +47,50 @@
     """
     Class implementing the task data structure.
     """
+
     TaskType2IconName = {
-        TaskType.FIXME: "taskFixme",                # __NO-TASK__
-        TaskType.TODO: "taskTodo",                  # __NO-TASK__
-        TaskType.WARNING: "taskWarning",            # __NO-TASK__
-        TaskType.NOTE: "taskNote",                  # __NO-TASK__
-        TaskType.TEST: "taskTest",                  # __NO-TASK__
-        TaskType.DOCU: "taskDocu",                  # __NO-TASK__
+        TaskType.FIXME: "taskFixme",  # __NO-TASK__
+        TaskType.TODO: "taskTodo",  # __NO-TASK__
+        TaskType.WARNING: "taskWarning",  # __NO-TASK__
+        TaskType.NOTE: "taskNote",  # __NO-TASK__
+        TaskType.TEST: "taskTest",  # __NO-TASK__
+        TaskType.DOCU: "taskDocu",  # __NO-TASK__
     }
     TaskType2ColorName = {
-        TaskType.FIXME: "TasksFixmeColor",          # __NO-TASK__
-        TaskType.TODO: "TasksTodoColor",            # __NO-TASK__
-        TaskType.WARNING: "TasksWarningColor",      # __NO-TASK__
-        TaskType.NOTE: "TasksNoteColor",            # __NO-TASK__
-        TaskType.TEST: "TasksTestColor",            # __NO-TASK__
-        TaskType.DOCU: "TasksDocuColor",            # __NO-TASK__
+        TaskType.FIXME: "TasksFixmeColor",  # __NO-TASK__
+        TaskType.TODO: "TasksTodoColor",  # __NO-TASK__
+        TaskType.WARNING: "TasksWarningColor",  # __NO-TASK__
+        TaskType.NOTE: "TasksNoteColor",  # __NO-TASK__
+        TaskType.TEST: "TasksTestColor",  # __NO-TASK__
+        TaskType.DOCU: "TasksDocuColor",  # __NO-TASK__
     }
     TaskType2MarkersName = {
-        TaskType.FIXME: "TasksFixmeMarkers",        # __NO-TASK__
-        TaskType.TODO: "TasksTodoMarkers",          # __NO-TASK__
-        TaskType.WARNING: "TasksWarningMarkers",    # __NO-TASK__
-        TaskType.NOTE: "TasksNoteMarkers",          # __NO-TASK__
-        TaskType.TEST: "TasksTestMarkers",          # __NO-TASK__
-        TaskType.DOCU: "TasksDocuMarkers",          # __NO-TASK__
+        TaskType.FIXME: "TasksFixmeMarkers",  # __NO-TASK__
+        TaskType.TODO: "TasksTodoMarkers",  # __NO-TASK__
+        TaskType.WARNING: "TasksWarningMarkers",  # __NO-TASK__
+        TaskType.NOTE: "TasksNoteMarkers",  # __NO-TASK__
+        TaskType.TEST: "TasksTestMarkers",  # __NO-TASK__
+        TaskType.DOCU: "TasksDocuMarkers",  # __NO-TASK__
     }
-    
-    def __init__(self, summary, priority=TaskPriority.NORMAL, filename="",
-                 lineno=0, completed=False, _time=0, isProjectTask=False,
-                 taskType=TaskType.TODO, project=None, description="",
-                 uid="", parentUid=""):
+
+    def __init__(
+        self,
+        summary,
+        priority=TaskPriority.NORMAL,
+        filename="",
+        lineno=0,
+        completed=False,
+        _time=0,
+        isProjectTask=False,
+        taskType=TaskType.TODO,
+        project=None,
+        description="",
+        uid="",
+        parentUid="",
+    ):
         """
         Constructor
-        
+
         @param summary summary text of the task
         @type str
         @param priority priority of the task
@@ -104,7 +118,7 @@
         @type str
         """
         super().__init__()
-        
+
         self.summary = summary
         self.description = description
         self.filename = filename
@@ -118,16 +132,16 @@
         else:
             self.uid = QUuid.createUuid().toString()
         self.parentUid = parentUid
-        
+
         if isProjectTask:
             self.filename = self.project.getRelativePath(self.filename)
-            
+
         self.setData(0, Qt.ItemDataRole.DisplayRole, "")
         self.setData(1, Qt.ItemDataRole.DisplayRole, "")
         self.setData(2, Qt.ItemDataRole.DisplayRole, self.summary)
         self.setData(3, Qt.ItemDataRole.DisplayRole, self.filename)
         self.setData(4, Qt.ItemDataRole.DisplayRole, self.lineno or "")
-        
+
         if self.completed:
             self.setIcon(0, UI.PixmapCache.getIcon("taskCompleted"))
             strikeOut = True
@@ -138,12 +152,12 @@
             f = self.font(column)
             f.setStrikeOut(strikeOut)
             self.setFont(column, f)
-        
+
         self.setPriority(priority)
-        
+
         self.setTaskType(taskType)
         self.setTextAlignment(4, Qt.AlignmentFlag.AlignRight)
-    
+
     def colorizeTask(self):
         """
         Public slot to set the colors of the task item.
@@ -155,41 +169,41 @@
         for col in range(5):
             with contextlib.suppress(KeyError):
                 self.setBackground(
-                    col, Preferences.getTasks(
-                        Task.TaskType2ColorName[self.taskType]))
-            
+                    col, Preferences.getTasks(Task.TaskType2ColorName[self.taskType])
+                )
+
             if self._isProjectTask:
                 self.setFont(col, boldFont)
             else:
                 self.setFont(col, nonBoldFont)
-    
+
     def setSummary(self, summary):
         """
         Public slot to update the description.
-        
+
         @param summary summary text of the task (string)
         """
         self.summary = summary
         self.setText(2, self.summary)
-    
+
     def setDescription(self, description):
         """
         Public slot to update the description field.
-        
+
         @param description descriptive text of the task
         @type str
         """
         self.description = description
-    
+
     def setPriority(self, priority):
         """
         Public slot to update the priority.
-        
+
         @param priority priority of the task
         @type TaskPriority
         """
         self.priority = priority
-        
+
         if self.priority == TaskPriority.NORMAL:
             self.setIcon(1, UI.PixmapCache.getIcon("empty"))
         elif self.priority == TaskPriority.HIGH:
@@ -198,28 +212,29 @@
             self.setIcon(1, UI.PixmapCache.getIcon("taskPrioLow"))
         else:
             self.setIcon(1, UI.PixmapCache.getIcon("empty"))
-    
+
     def setTaskType(self, taskType):
         """
         Public method to update the task type.
-        
+
         @param taskType type of the task
         @type TaskType
         """
         self.taskType = taskType
-        
+
         try:
-            self.setIcon(2, UI.PixmapCache.getIcon(
-                Task.TaskType2IconName[self.taskType]))
+            self.setIcon(
+                2, UI.PixmapCache.getIcon(Task.TaskType2IconName[self.taskType])
+            )
         except KeyError:
             self.setIcon(2, UI.PixmapCache.getIcon("empty"))
-        
+
         self.colorizeTask()
-    
+
     def setCompleted(self, completed):
         """
         Public slot to update the completed flag.
-        
+
         @param completed flag indicating completion status (boolean)
         """
         self.completed = completed
@@ -233,92 +248,92 @@
             f = self.font(column)
             f.setStrikeOut(strikeOut)
             self.setFont(column, f)
-        
+
         # set the completion status for all children
         for index in range(self.childCount()):
             self.child(index).setCompleted(completed)
-    
+
     def isCompleted(self):
         """
         Public slot to return the completion status.
-        
+
         @return flag indicating the completion status (boolean)
         """
         return self.completed
-    
+
     def getFilename(self):
         """
         Public method to retrieve the task's filename.
-        
+
         @return filename (string)
         """
         if self._isProjectTask and self.filename:
             return os.path.join(self.project.getProjectPath(), self.filename)
         else:
             return self.filename
-    
+
     def isFileTask(self):
         """
         Public slot to get an indication, if this task is related to a file.
-        
+
         @return flag indicating a file task (boolean)
         """
         return self.filename != ""
-    
+
     def getLineno(self):
         """
         Public method to retrieve the task's linenumber.
-        
+
         @return linenumber (integer)
         """
         return self.lineno
-    
+
     def getUuid(self):
         """
         Public method to get the task's uid.
-        
+
         @return uid (string)
         """
         return self.uid
-    
+
     def getParentUuid(self):
         """
         Public method to get the parent task's uid.
-        
+
         @return parent uid (string)
         """
         return self.parentUid
-    
+
     def setProjectTask(self, pt):
         """
         Public method to set the project relation flag.
-        
+
         @param pt flag indicating a project task (boolean)
         """
         self._isProjectTask = pt
         self.colorizeTask()
-    
+
     def isProjectTask(self):
         """
         Public slot to return the project relation status.
-        
+
         @return flag indicating the project relation status (boolean)
         """
         return self._isProjectTask
-    
+
     def isProjectFileTask(self):
         """
         Public slot to get an indication, if this task is related to a
         project file.
-        
+
         @return flag indicating a project file task (boolean)
         """
         return self._isProjectTask and self.filename != ""
-    
+
     def toDict(self):
         """
         Public method to convert the task data to a dictionary.
-        
+
         @return dictionary containing the task data
         @rtype dict
         """

eric ide

mercurial