Tasks

Sun, 02 May 2021 15:09:14 +0200

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Sun, 02 May 2021 15:09:14 +0200
changeset 8280
17d03699f151
parent 8279
7015247cbb05
child 8281
184ece570a2b

Tasks
- made the task properties dialog adapt to the task kind
- added code to get typed manual tasks

docs/changelog file | annotate | diff | comparison | revisions
eric6/E5XML/TasksReader.py file | annotate | diff | comparison | revisions
eric6/E5XML/TasksWriter.py file | annotate | diff | comparison | revisions
eric6/Tasks/Task.py file | annotate | diff | comparison | revisions
eric6/Tasks/TaskFilter.py file | annotate | diff | comparison | revisions
eric6/Tasks/TaskFilterConfigDialog.py file | annotate | diff | comparison | revisions
eric6/Tasks/TaskPropertiesDialog.py file | annotate | diff | comparison | revisions
eric6/Tasks/TaskPropertiesDialog.ui file | annotate | diff | comparison | revisions
eric6/Tasks/TaskViewer.py file | annotate | diff | comparison | revisions
eric6/Tasks/TasksFile.py file | annotate | diff | comparison | revisions
--- a/docs/changelog	Sun May 02 10:59:00 2021 +0200
+++ b/docs/changelog	Sun May 02 15:09:14 2021 +0200
@@ -2,6 +2,9 @@
 ----------
 Version 21.6:
 - bug fixes
+- Tasks
+  -- made the task properties dialog adapt to the task kind
+  -- added code to get typed manual tasks
 - UML Diagrams
   -- extended the class items to show class attributes
 
--- a/eric6/E5XML/TasksReader.py	Sun May 02 10:59:00 2021 +0200
+++ b/eric6/E5XML/TasksReader.py	Sun May 02 15:09:14 2021 +0200
@@ -15,7 +15,7 @@
 from .Config import tasksFileFormatVersion
 from .XMLStreamReaderBase import XMLStreamReaderBase
 
-from Tasks.Task import TaskType
+from Tasks.Task import TaskType, TaskPriority
 
 import Utilities
 
@@ -80,7 +80,7 @@
         Private method to read the task info.
         """
         task = {"summary": "",
-                "priority": 1,
+                "priority": TaskPriority.NORMAL,
                 "completed": False,
                 "created": 0,
                 "filename": "",
@@ -89,7 +89,9 @@
                 "description": "",
                 "uid": "",
                 }
-        task["priority"] = int(self.attribute("priority", "1"))
+        task["priority"] = TaskPriority(
+            int(self.attribute("priority", str(TaskPriority.NORMAL.value)))
+        )
         task["completed"] = self.toBool(self.attribute("completed", "False"))
         if self.version in ["4.2", "5.0"]:
             isBugfix = self.toBool(self.attribute("bugfix", "False"))
--- a/eric6/E5XML/TasksWriter.py	Sun May 02 10:59:00 2021 +0200
+++ b/eric6/E5XML/TasksWriter.py	Sun May 02 15:09:14 2021 +0200
@@ -74,7 +74,7 @@
         )
         for task in tasks:
             self.writeStartElement("Task")
-            self.writeAttribute("priority", str(task.priority))
+            self.writeAttribute("priority", str(task.priority.value))
             self.writeAttribute("completed", str(task.completed))
             self.writeAttribute("type", str(task.taskType.value))
             self.writeAttribute("uid", task.uid)
--- a/eric6/Tasks/Task.py	Sun May 02 10:59:00 2021 +0200
+++ b/eric6/Tasks/Task.py	Sun May 02 15:09:14 2021 +0200
@@ -32,13 +32,20 @@
     DOCU = 5
 
 
-# TODO: separate into Task and TaskItem(QTreeWidgetItem) (eric7)
+class TaskPriority(enum.IntEnum):
+    """
+    Class defining the task priorities.
+    """
+    HIGH = 0
+    NORMAL = 1
+    LOW = 2
+
+
+# TODO: eric7: separate into Task and TaskItem(QTreeWidgetItem)
 class Task(QTreeWidgetItem):
     """
     Class implementing the task data structure.
     """
-    # TODO: add IntEnum for priority
-    
     TaskType2IconName = {
         TaskType.FIXME: "taskFixme",                # __NO-TASK__
         TaskType.TODO: "taskTodo",                  # __NO-TASK__
@@ -64,8 +71,8 @@
         TaskType.DOCU: "TasksDocuMarkers",          # __NO-TASK__
     }
     
-    def __init__(self, summary, priority=1, filename="", lineno=0,
-                 completed=False, _time=0, isProjectTask=False,
+    def __init__(self, summary, priority=TaskPriority.NORMAL, filename="",
+                 lineno=0, completed=False, _time=0, isProjectTask=False,
                  taskType=TaskType.TODO, project=None, description="",
                  uid="", parentUid=""):
         """
@@ -73,8 +80,8 @@
         
         @param summary summary text of the task
         @type str
-        @param priority priority of the task (0=high, 1=normal, 2=low)
-        @type int
+        @param priority priority of the task
+        @type TaskPriority
         @param filename filename containing the task
         @type str
         @param lineno line number containing the task
@@ -101,16 +108,11 @@
         
         self.summary = summary
         self.description = description
-        if priority in [0, 1, 2]:
-            self.priority = priority
-        else:
-            self.priority = 1
         self.filename = filename
         self.lineno = lineno
         self.completed = completed
         self.created = _time and _time or time.time()
         self._isProjectTask = isProjectTask
-        self.taskType = taskType
         self.project = project
         if uid:
             self.uid = uid
@@ -138,22 +140,9 @@
             f.setStrikeOut(strikeOut)
             self.setFont(column, f)
         
-        if self.priority == 1:
-            self.setIcon(1, UI.PixmapCache.getIcon("empty"))
-        elif self.priority == 0:
-            self.setIcon(1, UI.PixmapCache.getIcon("taskPrioHigh"))
-        elif self.priority == 2:
-            self.setIcon(1, UI.PixmapCache.getIcon("taskPrioLow"))
-        else:
-            self.setIcon(1, UI.PixmapCache.getIcon("empty"))
+        self.setPriority(priority)
         
-        try:
-            self.setIcon(2, UI.PixmapCache.getIcon(
-                Task.TaskType2IconName[self.taskType]))
-        except KeyError:
-            self.setIcon(2, UI.PixmapCache.getIcon("empty"))
-        
-        self.colorizeTask()
+        self.setTaskType(taskType)
         self.setTextAlignment(4, Qt.AlignmentFlag.AlignRight)
     
     def colorizeTask(self):
@@ -188,7 +177,8 @@
         """
         Public slot to update the description field.
         
-        @param description descriptive text of the task (string)
+        @param description descriptive text of the task
+        @type str
         """
         self.description = description
     
@@ -196,22 +186,37 @@
         """
         Public slot to update the priority.
         
-        @param priority priority of the task (0=high, 1=normal, 2=low)
+        @param priority priority of the task
+        @type TaskPriority
         """
-        if priority in [0, 1, 2]:
-            self.priority = priority
-        else:
-            self.priority = 1
+        self.priority = priority
         
-        if self.priority == 1:
+        if self.priority == TaskPriority.NORMAL:
             self.setIcon(1, UI.PixmapCache.getIcon("empty"))
-        elif self.priority == 0:
+        elif self.priority == TaskPriority.HIGH:
             self.setIcon(1, UI.PixmapCache.getIcon("taskPrioHigh"))
-        elif self.priority == 2:
+        elif self.priority == TaskPriority.LOW:
             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]))
+        except KeyError:
+            self.setIcon(2, UI.PixmapCache.getIcon("empty"))
+        
+        self.colorizeTask()
+    
     def setCompleted(self, completed):
         """
         Public slot to update the completed flag.
@@ -321,7 +326,7 @@
         return {
             "summary": self.summary.strip(),
             "description": self.description.strip(),
-            "priority": self.priority,
+            "priority": self.priority.value,
             "lineno": self.lineno,
             "completed": self.completed,
             "created": self.created,
--- a/eric6/Tasks/TaskFilter.py	Sun May 02 10:59:00 2021 +0200
+++ b/eric6/Tasks/TaskFilter.py	Sun May 02 15:09:14 2021 +0200
@@ -35,7 +35,7 @@
         #- not completed (False) or completed (True)
         
         self.prioritiesFilter = None
-        #- list of priorities [0 (high), 1 (normal), 2 (low)]
+        #- list of priorities
     
     def setActive(self, enabled):
         """
@@ -95,7 +95,8 @@
         """
         Public method to set the priorities filter.
         
-        @param priorities list of task priorities (list of integer) or None
+        @param priorities list of task priorities or None
+        @type list of TaskPriority or None
         """
         self.prioritiesFilter = priorities
         
--- a/eric6/Tasks/TaskFilterConfigDialog.py	Sun May 02 10:59:00 2021 +0200
+++ b/eric6/Tasks/TaskFilterConfigDialog.py	Sun May 02 15:09:14 2021 +0200
@@ -9,7 +9,7 @@
 
 from PyQt5.QtWidgets import QDialog
 
-from .Task import TaskType
+from .Task import TaskType, TaskPriority
 
 from .Ui_TaskFilterConfigDialog import Ui_TaskFilterConfigDialog
 
@@ -89,11 +89,11 @@
         else:
             self.priorityGroup.setChecked(True)
             self.priorityHighCheckBox.setChecked(
-                0 in taskFilter.prioritiesFilter)
+                TaskPriority.HIGH in taskFilter.prioritiesFilter)
             self.priorityNormalCheckBox.setChecked(
-                1 in taskFilter.prioritiesFilter)
+                TaskPriority.NORMAL in taskFilter.prioritiesFilter)
             self.priorityLowCheckBox.setChecked(
-                2 in taskFilter.prioritiesFilter)
+                TaskPriority.LOW in taskFilter.prioritiesFilter)
         
         msh = self.minimumSizeHint()
         self.resize(max(self.width(), msh.width()), msh.height())
@@ -141,9 +141,12 @@
         
         if self.priorityGroup.isChecked():
             priorities = []
-            self.priorityHighCheckBox.isChecked() and priorities.append(0)
-            self.priorityNormalCheckBox.isChecked() and priorities.append(1)
-            self.priorityLowCheckBox.isChecked() and priorities.append(2)
+            if self.priorityHighCheckBox.isChecked():
+                priorities.append(TaskPriority.HIGH)
+            if self.priorityNormalCheckBox.isChecked():
+                priorities.append(TaskPriority.NORMAL)
+            if self.priorityLowCheckBox.isChecked():
+                priorities.append(TaskPriority.LOW)
             taskFilter.setPrioritiesFilter(priorities)
         else:
             taskFilter.setPrioritiesFilter(None)
--- a/eric6/Tasks/TaskPropertiesDialog.py	Sun May 02 10:59:00 2021 +0200
+++ b/eric6/Tasks/TaskPropertiesDialog.py	Sun May 02 15:09:14 2021 +0200
@@ -15,6 +15,8 @@
 
 from .Ui_TaskPropertiesDialog import Ui_TaskPropertiesDialog
 
+from .Task import TaskType, TaskPriority
+
 
 class TaskPropertiesDialog(QDialog, Ui_TaskPropertiesDialog):
     """
@@ -25,40 +27,76 @@
         Constructor
         
         @param task the task object to be shown
-        @param parent the parent widget (QWidget)
-        @param projectOpen flag indicating status of the project (boolean)
+        @type Task
+        @param parent the parent widget
+        @type QWidget
+        @param projectOpen flag indicating status of the project
+        @type bool
         """
         super().__init__(parent)
         self.setupUi(self)
         
         self.filenameCompleter = E5FileCompleter(self.filenameEdit)
         
-        if not projectOpen:
-            self.projectCheckBox.setEnabled(False)
+        self.typeCombo.addItem(self.tr("Bugfix"), TaskType.FIXME)
+        self.typeCombo.addItem(self.tr("Warning"), TaskType.WARNING)
+        self.typeCombo.addItem(self.tr("ToDo"), TaskType.TODO)
+        self.typeCombo.addItem(self.tr("Note"), TaskType.NOTE)
+        self.typeCombo.addItem(self.tr("Test"), TaskType.TEST)
+        self.typeCombo.addItem(self.tr("Documentation"), TaskType.DOCU)
+        
         if task is not None:
             self.summaryEdit.setText(task.summary)
             self.descriptionEdit.setText(task.description)
             self.creationLabel.setText(
                 time.strftime("%Y-%m-%d, %H:%M:%S",
                               time.localtime(task.created)))
-            self.priorityCombo.setCurrentIndex(task.priority)
+            self.priorityCombo.setCurrentIndex(task.priority.value)
             self.projectCheckBox.setChecked(task._isProjectTask)
             self.completedCheckBox.setChecked(task.completed)
             self.filenameEdit.setText(task.filename)
             if task.lineno:
                 self.linenoEdit.setText(str(task.lineno))
+            index = self.typeCombo.findData(task.taskType)
+            self.typeCombo.setCurrentIndex(index)
+            self.__setMode(bool(task.filename), projectOpen)
         else:
             self.projectCheckBox.setChecked(projectOpen)
+            self.typeCombo.setCurrentIndex(2)   # TaskType.TODO
+            self.__setMode(False, projectOpen)
     
-    def setReadOnly(self):
+    def __setMode(self, isFileTask, projectOpen):
         """
-        Public slot to set the dialog to read only mode.
+        Private method to show or hide dialog elements depending on the task
+        kind.
+        
+        @param isFileTask flag indicating a file task (i.e. extracted task)
+        @type bool
+        @param projectOpen flag indicating status of the project
+        @type bool
         """
-        self.summaryEdit.setReadOnly(True)
-        self.completedCheckBox.setEnabled(False)
-        self.priorityCombo.setEnabled(False)
-        self.projectCheckBox.setEnabled(False)
-        self.descriptionEdit.setEnabled(False)
+        self.__isFileTaskMode = isFileTask
+        if self.__isFileTaskMode:
+            self.descriptionEdit.hide()
+            self.descriptionLabel.hide()
+            self.manualTaskFrame.hide()
+            
+            msh = self.minimumSizeHint()
+            self.resize(max(self.width(), msh.width()), msh.height())
+        else:
+            self.fileTaskFrame.hide()
+        
+        self.summaryEdit.setReadOnly(isFileTask)
+        self.projectCheckBox.setEnabled(projectOpen and not isFileTask)
+    
+    def isManualTaskMode(self):
+        """
+        Public method to check, if the dialog is in manual task mode.
+        
+        @return flag indicating manual task mode
+        @rtype bool
+        """
+        return not self.__isFileTaskMode
     
     def setSubTaskMode(self, projectTask):
         """
@@ -73,12 +111,13 @@
         """
         Public method to retrieve the dialogs data.
         
-        @return tuple of description, priority, completion flag,
-                project flag and long text (string, string, boolean,
-                boolean, string)
+        @return tuple of description, priority, type, completion flag,
+                project flag and long text
+        @rtype tuple of (str, TaskPriority, TaskType, bool, bool, str)
         """
         return (self.summaryEdit.text(),
-                self.priorityCombo.currentIndex(),
+                TaskPriority(self.priorityCombo.currentIndex()),
+                TaskType(self.typeCombo.currentData()),
                 self.completedCheckBox.isChecked(),
                 self.projectCheckBox.isChecked(),
                 self.descriptionEdit.toPlainText())
--- a/eric6/Tasks/TaskPropertiesDialog.ui	Sun May 02 10:59:00 2021 +0200
+++ b/eric6/Tasks/TaskPropertiesDialog.ui	Sun May 02 15:09:14 2021 +0200
@@ -6,8 +6,8 @@
    <rect>
     <x>0</x>
     <y>0</y>
-    <width>579</width>
-    <height>297</height>
+    <width>600</width>
+    <height>400</height>
    </rect>
   </property>
   <property name="windowTitle">
@@ -16,7 +16,7 @@
   <property name="sizeGripEnabled">
    <bool>true</bool>
   </property>
-  <layout class="QGridLayout">
+  <layout class="QGridLayout" name="gridLayout_2">
    <item row="0" column="0">
     <widget class="QLabel" name="label">
      <property name="text">
@@ -27,7 +27,7 @@
      </property>
     </widget>
    </item>
-   <item row="0" column="1" colspan="3">
+   <item row="0" column="1">
     <widget class="QLineEdit" name="summaryEdit">
      <property name="toolTip">
       <string>Enter the task summary</string>
@@ -35,7 +35,7 @@
     </widget>
    </item>
    <item row="1" column="0">
-    <widget class="QLabel" name="textLabel1">
+    <widget class="QLabel" name="descriptionLabel">
      <property name="text">
       <string>&amp;Description:</string>
      </property>
@@ -47,66 +47,129 @@
      </property>
     </widget>
    </item>
-   <item row="1" column="1" colspan="3">
+   <item row="1" column="1">
     <widget class="QTextEdit" name="descriptionEdit">
      <property name="toolTip">
       <string>Enter the task description</string>
      </property>
     </widget>
    </item>
-   <item row="2" column="0">
-    <widget class="QLabel" name="textLabel2">
-     <property name="text">
-      <string>Creation Time:</string>
+   <item row="2" column="0" colspan="2">
+    <widget class="QFrame" name="manualTaskFrame">
+     <property name="frameShape">
+      <enum>QFrame::NoFrame</enum>
+     </property>
+     <property name="frameShadow">
+      <enum>QFrame::Plain</enum>
      </property>
-    </widget>
-   </item>
-   <item row="2" column="1" colspan="3">
-    <widget class="QLabel" name="creationLabel">
-     <property name="sizePolicy">
-      <sizepolicy hsizetype="Expanding" vsizetype="Preferred">
-       <horstretch>0</horstretch>
-       <verstretch>0</verstretch>
-      </sizepolicy>
-     </property>
-    </widget>
-   </item>
-   <item row="3" column="0">
-    <widget class="QLabel" name="textLabel4">
-     <property name="text">
-      <string>&amp;Priority:</string>
-     </property>
-     <property name="buddy">
-      <cstring>priorityCombo</cstring>
-     </property>
+     <layout class="QVBoxLayout" name="verticalLayout">
+      <item>
+       <layout class="QHBoxLayout" name="horizontalLayout_2">
+        <item>
+         <widget class="QLabel" name="textLabel2">
+          <property name="text">
+           <string>Creation Time:</string>
+          </property>
+         </widget>
+        </item>
+        <item>
+         <widget class="QLabel" name="creationLabel">
+          <property name="sizePolicy">
+           <sizepolicy hsizetype="Expanding" vsizetype="Preferred">
+            <horstretch>0</horstretch>
+            <verstretch>0</verstretch>
+           </sizepolicy>
+          </property>
+         </widget>
+        </item>
+       </layout>
+      </item>
+      <item>
+       <layout class="QHBoxLayout" name="horizontalLayout">
+        <item>
+         <widget class="QLabel" name="textLabel4">
+          <property name="text">
+           <string>&amp;Priority:</string>
+          </property>
+          <property name="buddy">
+           <cstring>priorityCombo</cstring>
+          </property>
+         </widget>
+        </item>
+        <item>
+         <widget class="QComboBox" name="priorityCombo">
+          <property name="toolTip">
+           <string>Select the task priority</string>
+          </property>
+          <property name="currentIndex">
+           <number>1</number>
+          </property>
+          <item>
+           <property name="text">
+            <string>High</string>
+           </property>
+          </item>
+          <item>
+           <property name="text">
+            <string>Normal</string>
+           </property>
+          </item>
+          <item>
+           <property name="text">
+            <string>Low</string>
+           </property>
+          </item>
+         </widget>
+        </item>
+        <item>
+         <widget class="QLabel" name="label_2">
+          <property name="text">
+           <string>Type:</string>
+          </property>
+         </widget>
+        </item>
+        <item>
+         <widget class="QComboBox" name="typeCombo">
+          <property name="toolTip">
+           <string>Select the task type</string>
+          </property>
+         </widget>
+        </item>
+        <item>
+         <spacer name="horizontalSpacer">
+          <property name="orientation">
+           <enum>Qt::Horizontal</enum>
+          </property>
+          <property name="sizeHint" stdset="0">
+           <size>
+            <width>40</width>
+            <height>20</height>
+           </size>
+          </property>
+         </spacer>
+        </item>
+       </layout>
+      </item>
+      <item>
+       <widget class="QCheckBox" name="completedCheckBox">
+        <property name="sizePolicy">
+         <sizepolicy hsizetype="Expanding" vsizetype="Fixed">
+          <horstretch>0</horstretch>
+          <verstretch>0</verstretch>
+         </sizepolicy>
+        </property>
+        <property name="toolTip">
+         <string>Select to mark this task as completed</string>
+        </property>
+        <property name="text">
+         <string>T&amp;ask completed</string>
+        </property>
+       </widget>
+      </item>
+     </layout>
     </widget>
    </item>
-   <item row="3" column="1">
-    <widget class="QComboBox" name="priorityCombo">
-     <property name="toolTip">
-      <string>Select the task priority</string>
-     </property>
-     <property name="currentIndex">
-      <number>1</number>
-     </property>
-     <item>
-      <property name="text">
-       <string>High</string>
-      </property>
-     </item>
-     <item>
-      <property name="text">
-       <string>Normal</string>
-      </property>
-     </item>
-     <item>
-      <property name="text">
-       <string>Low</string>
-      </property>
-     </item>
-    </widget>
-   </item>
-   <item row="3" column="2">
+   <item row="3" column="0" colspan="2">
     <widget class="QCheckBox" name="projectCheckBox">
      <property name="toolTip">
       <string>Select to indicate a task related to the current project</string>
@@ -116,57 +179,65 @@
      </property>
     </widget>
    </item>
-   <item row="3" column="3">
-    <widget class="QCheckBox" name="completedCheckBox">
-     <property name="sizePolicy">
-      <sizepolicy hsizetype="Expanding" vsizetype="Fixed">
-       <horstretch>0</horstretch>
-       <verstretch>0</verstretch>
-      </sizepolicy>
+   <item row="4" column="0" colspan="2">
+    <widget class="QFrame" name="fileTaskFrame">
+     <property name="frameShape">
+      <enum>QFrame::NoFrame</enum>
      </property>
-     <property name="toolTip">
-      <string>Select to mark this task as completed</string>
+     <property name="frameShadow">
+      <enum>QFrame::Plain</enum>
      </property>
-     <property name="text">
-      <string>T&amp;ask completed</string>
-     </property>
-    </widget>
-   </item>
-   <item row="4" column="0">
-    <widget class="QLabel" name="textLabel5">
-     <property name="text">
-      <string>Filename:</string>
-     </property>
+     <layout class="QGridLayout" name="gridLayout">
+      <property name="leftMargin">
+       <number>0</number>
+      </property>
+      <property name="topMargin">
+       <number>0</number>
+      </property>
+      <property name="rightMargin">
+       <number>0</number>
+      </property>
+      <property name="bottomMargin">
+       <number>0</number>
+      </property>
+      <item row="1" column="1">
+       <widget class="QLineEdit" name="linenoEdit">
+        <property name="focusPolicy">
+         <enum>Qt::NoFocus</enum>
+        </property>
+        <property name="readOnly">
+         <bool>true</bool>
+        </property>
+       </widget>
+      </item>
+      <item row="1" column="0">
+       <widget class="QLabel" name="linenoLabel">
+        <property name="text">
+         <string>Line:</string>
+        </property>
+       </widget>
+      </item>
+      <item row="0" column="0">
+       <widget class="QLabel" name="filenameLabel">
+        <property name="text">
+         <string>Filename:</string>
+        </property>
+       </widget>
+      </item>
+      <item row="0" column="1">
+       <widget class="QLineEdit" name="filenameEdit">
+        <property name="focusPolicy">
+         <enum>Qt::NoFocus</enum>
+        </property>
+        <property name="readOnly">
+         <bool>true</bool>
+        </property>
+       </widget>
+      </item>
+     </layout>
     </widget>
    </item>
-   <item row="4" column="1" colspan="3">
-    <widget class="QLineEdit" name="filenameEdit">
-     <property name="focusPolicy">
-      <enum>Qt::NoFocus</enum>
-     </property>
-     <property name="readOnly">
-      <bool>true</bool>
-     </property>
-    </widget>
-   </item>
-   <item row="5" column="0">
-    <widget class="QLabel" name="textLabel6">
-     <property name="text">
-      <string>Line:</string>
-     </property>
-    </widget>
-   </item>
-   <item row="5" column="1" colspan="3">
-    <widget class="QLineEdit" name="linenoEdit">
-     <property name="focusPolicy">
-      <enum>Qt::NoFocus</enum>
-     </property>
-     <property name="readOnly">
-      <bool>true</bool>
-     </property>
-    </widget>
-   </item>
-   <item row="6" column="0" colspan="4">
+   <item row="5" column="0" colspan="2">
     <widget class="QDialogButtonBox" name="buttonBox">
      <property name="orientation">
       <enum>Qt::Horizontal</enum>
@@ -183,9 +254,9 @@
   <tabstop>summaryEdit</tabstop>
   <tabstop>descriptionEdit</tabstop>
   <tabstop>priorityCombo</tabstop>
-  <tabstop>projectCheckBox</tabstop>
+  <tabstop>typeCombo</tabstop>
   <tabstop>completedCheckBox</tabstop>
-  <tabstop>buttonBox</tabstop>
+  <tabstop>projectCheckBox</tabstop>
  </tabstops>
  <resources/>
  <connections>
--- a/eric6/Tasks/TaskViewer.py	Sun May 02 10:59:00 2021 +0200
+++ b/eric6/Tasks/TaskViewer.py	Sun May 02 15:09:14 2021 +0200
@@ -25,7 +25,7 @@
 from E5Gui import E5MessageBox
 from E5Gui.E5ProgressDialog import E5ProgressDialog
 
-from .Task import Task, TaskType
+from .Task import Task, TaskType, TaskPriority
 
 import UI.PixmapCache
 
@@ -318,8 +318,8 @@
         """
         self.projectOpen = o
     
-    def addTask(self, summary, priority=1, filename="", lineno=0,
-                completed=False, _time=0, isProjectTask=False,
+    def addTask(self, summary, priority=TaskPriority.NORMAL, filename="",
+                lineno=0, completed=False, _time=0, isProjectTask=False,
                 taskType=TaskType.TODO, description="", uid="",
                 parentTask=None):
         """
@@ -327,8 +327,8 @@
         
         @param summary summary text of the task
         @type str
-        @param priority priority of the task (0=high, 1=normal, 2=low)
-        @type int
+        @param priority priority of the task
+        @type TaskPriority
         @param filename filename containing the task
         @type str
         @param lineno line number containing the task
@@ -493,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)
@@ -513,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):
         """
@@ -529,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):
         """
--- a/eric6/Tasks/TasksFile.py	Sun May 02 10:59:00 2021 +0200
+++ b/eric6/Tasks/TasksFile.py	Sun May 02 15:09:14 2021 +0200
@@ -18,7 +18,7 @@
 
 import Preferences
 
-from .Task import TaskType
+from .Task import TaskType, TaskPriority
 
 
 class TasksFile(QObject):
@@ -137,7 +137,7 @@
         addedTasks = []
         for task in tasksDict["Tasks"]:
             addedTask = viewer.addTask(
-                task["summary"], priority=task["priority"],
+                task["summary"], priority=TaskPriority(task["priority"]),
                 filename=task["filename"], lineno=task["lineno"],
                 completed=task["completed"], _time=task["created"],
                 isProjectTask=not self.__isGlobal,

eric ide

mercurial