eric6/Tasks/TaskViewer.py

branch
maintenance
changeset 8400
b3eefd7e58d1
parent 8273
698ae46f40a4
parent 8280
17d03699f151
child 8731
c6264a513aa4
diff -r 197414ba11cc -r b3eefd7e58d1 eric6/Tasks/TaskViewer.py
--- a/eric6/Tasks/TaskViewer.py	Sat May 01 14:27:38 2021 +0200
+++ b/eric6/Tasks/TaskViewer.py	Thu Jun 03 11:39:23 2021 +0200
@@ -25,7 +25,7 @@
 from E5Gui import E5MessageBox
 from E5Gui.E5ProgressDialog import E5ProgressDialog
 
-from .Task import Task
+from .Task import Task, TaskType, TaskPriority
 
 import UI.PixmapCache
 
@@ -318,28 +318,39 @@
         """
         self.projectOpen = o
     
-    def addTask(self, summary, priority=1, filename="", lineno=0,
-                completed=False, _time=0, isProjectTask=False,
-                taskType=Task.TypeTodo, description="", uid="",
+    def addTask(self, summary, priority=TaskPriority.NORMAL, filename="",
+                lineno=0, completed=False, _time=0, isProjectTask=False,
+                taskType=TaskType.TODO, description="", uid="",
                 parentTask=None):
         """
         Public slot to add a task.
         
-        @param summary summary text of the task (string)
-        @param priority priority of the task (0=high, 1=normal, 2=low)
-        @param filename filename containing the task (string)
-        @param lineno line number containing the task (integer)
-        @param completed flag indicating completion status (boolean)
-        @param _time creation time of the task (float, if 0 use current time)
+        @param summary summary text of the task
+        @type str
+        @param priority priority of the task
+        @type TaskPriority
+        @param filename filename containing the task
+        @type str
+        @param lineno line number containing the task
+        @type int
+        @param completed flag indicating completion status
+        @type bool
+        @param _time creation time of the task (if 0 use current time)
+        @type float
         @param isProjectTask flag indicating a task related to the current
-            project (boolean)
-        @param taskType type of the task (one of Task.TypeFixme, Task.TypeTodo,
-            Task.TypeWarning, Task.TypeNote)
-        @param description explanatory text of the task (string)
-        @param uid unique id of the task (string)
-        @param parentTask reference to the parent task item (Task) or the
-            UID of the parent task
-        @return reference to the task item (Task)
+            project
+        @type bool
+        @param taskType type of the task
+        @type TaskType
+        @param description explanatory text of the task
+        @type str
+        @param uid unique id of the task
+        @type str
+        @param parentTask reference to the parent task item or the UID of the
+            parent task
+        @type Task or str
+        @return reference to the task item
+        @rtype Task
         """
         if isinstance(parentTask, str):
             # UID of parent task
@@ -377,23 +388,27 @@
         
         return task
     
-    def addFileTask(self, summary, filename, lineno, taskType=Task.TypeTodo,
+    def addFileTask(self, summary, filename, lineno, taskType=TaskType.TODO,
                     description=""):
         """
         Public slot to add a file related task.
         
-        @param summary summary text of the task (string)
-        @param filename filename containing the task (string)
-        @param lineno line number containing the task (integer)
-        @param taskType type of the task (one of Task.TypeFixme, Task.TypeTodo,
-            Task.TypeWarning, Task.TypeNote)
-        @param description explanatory text of the task (string)
+        @param summary summary text of the task
+        @type str
+        @param filename filename containing the task
+        @type str
+        @param lineno line number containing the task
+        @type int
+        @param taskType type of the task
+        @type TaskType
+        @param description explanatory text of the task
+        @type str
         """
         self.addTask(summary, filename=filename, lineno=lineno,
                      isProjectTask=(
                          self.project and
                          self.project.isProjectSource(filename)),
-                     taskType=taskType, description=description)
+                     taskType=TaskType(taskType), description=description)
     
     def getProjectTasks(self):
         """
@@ -478,16 +493,17 @@
         """
         from .TaskPropertiesDialog import TaskPropertiesDialog
         task = self.currentItem()
-        dlg = TaskPropertiesDialog(task, self, self.projectOpen)
-        ro = task.getFilename() != ""
-        if ro:
-            dlg.setReadOnly()
-        if dlg.exec() == QDialog.DialogCode.Accepted and not ro:
-            summary, priority, completed, isProjectTask, description = (
-                dlg.getData()
-            )
+        dlg = TaskPropertiesDialog(task, parent=self,
+                                   projectOpen=self.projectOpen)
+        if (
+            dlg.exec() == QDialog.DialogCode.Accepted and
+            dlg.isManualTaskMode()
+        ):
+            (summary, priority, taskType, completed, isProjectTask,
+             description) = dlg.getData()
             task.setSummary(summary)
             task.setPriority(priority)
+            task.setTaskType(taskType)
             task.setCompleted(completed)
             task.setProjectTask(isProjectTask)
             task.setDescription(description)
@@ -498,13 +514,14 @@
         Private slot to handle the "New Task" context menu entry.
         """
         from .TaskPropertiesDialog import TaskPropertiesDialog
-        dlg = TaskPropertiesDialog(None, self, self.projectOpen)
+        dlg = TaskPropertiesDialog(None, parent=self,
+                                   projectOpen=self.projectOpen)
         if dlg.exec() == QDialog.DialogCode.Accepted:
-            summary, priority, completed, isProjectTask, description = (
-                dlg.getData()
-            )
+            (summary, priority, taskType, completed, isProjectTask,
+             description) = dlg.getData()
             self.addTask(summary, priority, completed=completed,
-                         isProjectTask=isProjectTask, description=description)
+                         isProjectTask=isProjectTask, taskType=taskType,
+                         description=description)
     
     def __newSubTask(self):
         """
@@ -514,15 +531,15 @@
         projectTask = parentTask.isProjectTask()
         
         from .TaskPropertiesDialog import TaskPropertiesDialog
-        dlg = TaskPropertiesDialog(None, self, self.projectOpen)
+        dlg = TaskPropertiesDialog(None, parent=self,
+                                   projectOpen=self.projectOpen)
         dlg.setSubTaskMode(projectTask)
         if dlg.exec() == QDialog.DialogCode.Accepted:
-            summary, priority, completed, isProjectTask, description = (
-                dlg.getData()
-            )
+            (summary, priority, taskType, completed, isProjectTask,
+             description) = dlg.getData()
             self.addTask(summary, priority, completed=completed,
-                         isProjectTask=isProjectTask, description=description,
-                         parentTask=parentTask)
+                         isProjectTask=isProjectTask, taskType=taskType,
+                         description=description, parentTask=parentTask)
     
     def __markCompleted(self):
         """
@@ -816,11 +833,11 @@
     """
     Class implementing a thread to extract tasks related to a project.
     
-    @signal taskFound(str, str, int, int) emitted with the task description,
-        the file name, the line number and task type to signal the presence of
-        a task
+    @signal taskFound(str, str, int, TaskType) emitted with the task
+        description, the file name, the line number and task type to signal
+        the presence of a task
     """
-    taskFound = pyqtSignal(str, str, int, int)
+    taskFound = pyqtSignal(str, str, int, TaskType)
     
     def __init__(self, parent=None):
         """

eric ide

mercurial