13 |
13 |
14 from E5Gui.E5Completers import E5FileCompleter |
14 from E5Gui.E5Completers import E5FileCompleter |
15 |
15 |
16 from .Ui_TaskPropertiesDialog import Ui_TaskPropertiesDialog |
16 from .Ui_TaskPropertiesDialog import Ui_TaskPropertiesDialog |
17 |
17 |
|
18 from .Task import TaskType, TaskPriority |
|
19 |
18 |
20 |
19 class TaskPropertiesDialog(QDialog, Ui_TaskPropertiesDialog): |
21 class TaskPropertiesDialog(QDialog, Ui_TaskPropertiesDialog): |
20 """ |
22 """ |
21 Class implementing the task properties dialog. |
23 Class implementing the task properties dialog. |
22 """ |
24 """ |
23 def __init__(self, task=None, parent=None, projectOpen=False): |
25 def __init__(self, task=None, parent=None, projectOpen=False): |
24 """ |
26 """ |
25 Constructor |
27 Constructor |
26 |
28 |
27 @param task the task object to be shown |
29 @param task the task object to be shown |
28 @param parent the parent widget (QWidget) |
30 @type Task |
29 @param projectOpen flag indicating status of the project (boolean) |
31 @param parent the parent widget |
|
32 @type QWidget |
|
33 @param projectOpen flag indicating status of the project |
|
34 @type bool |
30 """ |
35 """ |
31 super().__init__(parent) |
36 super().__init__(parent) |
32 self.setupUi(self) |
37 self.setupUi(self) |
33 |
38 |
34 self.filenameCompleter = E5FileCompleter(self.filenameEdit) |
39 self.filenameCompleter = E5FileCompleter(self.filenameEdit) |
35 |
40 |
36 if not projectOpen: |
41 self.typeCombo.addItem(self.tr("Bugfix"), TaskType.FIXME) |
37 self.projectCheckBox.setEnabled(False) |
42 self.typeCombo.addItem(self.tr("Warning"), TaskType.WARNING) |
|
43 self.typeCombo.addItem(self.tr("ToDo"), TaskType.TODO) |
|
44 self.typeCombo.addItem(self.tr("Note"), TaskType.NOTE) |
|
45 self.typeCombo.addItem(self.tr("Test"), TaskType.TEST) |
|
46 self.typeCombo.addItem(self.tr("Documentation"), TaskType.DOCU) |
|
47 |
38 if task is not None: |
48 if task is not None: |
39 self.summaryEdit.setText(task.summary) |
49 self.summaryEdit.setText(task.summary) |
40 self.descriptionEdit.setText(task.description) |
50 self.descriptionEdit.setText(task.description) |
41 self.creationLabel.setText( |
51 self.creationLabel.setText( |
42 time.strftime("%Y-%m-%d, %H:%M:%S", |
52 time.strftime("%Y-%m-%d, %H:%M:%S", |
43 time.localtime(task.created))) |
53 time.localtime(task.created))) |
44 self.priorityCombo.setCurrentIndex(task.priority) |
54 self.priorityCombo.setCurrentIndex(task.priority.value) |
45 self.projectCheckBox.setChecked(task._isProjectTask) |
55 self.projectCheckBox.setChecked(task._isProjectTask) |
46 self.completedCheckBox.setChecked(task.completed) |
56 self.completedCheckBox.setChecked(task.completed) |
47 self.filenameEdit.setText(task.filename) |
57 self.filenameEdit.setText(task.filename) |
48 if task.lineno: |
58 if task.lineno: |
49 self.linenoEdit.setText(str(task.lineno)) |
59 self.linenoEdit.setText(str(task.lineno)) |
|
60 index = self.typeCombo.findData(task.taskType) |
|
61 self.typeCombo.setCurrentIndex(index) |
|
62 self.__setMode(bool(task.filename), projectOpen) |
50 else: |
63 else: |
51 self.projectCheckBox.setChecked(projectOpen) |
64 self.projectCheckBox.setChecked(projectOpen) |
|
65 self.typeCombo.setCurrentIndex(2) # TaskType.TODO |
|
66 self.__setMode(False, projectOpen) |
52 |
67 |
53 def setReadOnly(self): |
68 def __setMode(self, isFileTask, projectOpen): |
54 """ |
69 """ |
55 Public slot to set the dialog to read only mode. |
70 Private method to show or hide dialog elements depending on the task |
|
71 kind. |
|
72 |
|
73 @param isFileTask flag indicating a file task (i.e. extracted task) |
|
74 @type bool |
|
75 @param projectOpen flag indicating status of the project |
|
76 @type bool |
56 """ |
77 """ |
57 self.summaryEdit.setReadOnly(True) |
78 self.__isFileTaskMode = isFileTask |
58 self.completedCheckBox.setEnabled(False) |
79 if self.__isFileTaskMode: |
59 self.priorityCombo.setEnabled(False) |
80 self.descriptionEdit.hide() |
60 self.projectCheckBox.setEnabled(False) |
81 self.descriptionLabel.hide() |
61 self.descriptionEdit.setEnabled(False) |
82 self.manualTaskFrame.hide() |
|
83 |
|
84 msh = self.minimumSizeHint() |
|
85 self.resize(max(self.width(), msh.width()), msh.height()) |
|
86 else: |
|
87 self.fileTaskFrame.hide() |
|
88 |
|
89 self.summaryEdit.setReadOnly(isFileTask) |
|
90 self.projectCheckBox.setEnabled(projectOpen and not isFileTask) |
|
91 |
|
92 def isManualTaskMode(self): |
|
93 """ |
|
94 Public method to check, if the dialog is in manual task mode. |
|
95 |
|
96 @return flag indicating manual task mode |
|
97 @rtype bool |
|
98 """ |
|
99 return not self.__isFileTaskMode |
62 |
100 |
63 def setSubTaskMode(self, projectTask): |
101 def setSubTaskMode(self, projectTask): |
64 """ |
102 """ |
65 Public slot to set the sub-task mode. |
103 Public slot to set the sub-task mode. |
66 |
104 |
71 |
109 |
72 def getData(self): |
110 def getData(self): |
73 """ |
111 """ |
74 Public method to retrieve the dialogs data. |
112 Public method to retrieve the dialogs data. |
75 |
113 |
76 @return tuple of description, priority, completion flag, |
114 @return tuple of description, priority, type, completion flag, |
77 project flag and long text (string, string, boolean, |
115 project flag and long text |
78 boolean, string) |
116 @rtype tuple of (str, TaskPriority, TaskType, bool, bool, str) |
79 """ |
117 """ |
80 return (self.summaryEdit.text(), |
118 return (self.summaryEdit.text(), |
81 self.priorityCombo.currentIndex(), |
119 TaskPriority(self.priorityCombo.currentIndex()), |
|
120 TaskType(self.typeCombo.currentData()), |
82 self.completedCheckBox.isChecked(), |
121 self.completedCheckBox.isChecked(), |
83 self.projectCheckBox.isChecked(), |
122 self.projectCheckBox.isChecked(), |
84 self.descriptionEdit.toPlainText()) |
123 self.descriptionEdit.toPlainText()) |