|
1 # -*- coding: utf-8 -*- |
|
2 |
|
3 # Copyright (c) 2005 - 2019 Detlev Offenbach <detlev@die-offenbachs.de> |
|
4 # |
|
5 |
|
6 """ |
|
7 Module implementing the task properties dialog. |
|
8 """ |
|
9 |
|
10 from __future__ import unicode_literals |
|
11 |
|
12 import time |
|
13 |
|
14 from PyQt5.QtWidgets import QDialog |
|
15 |
|
16 from E5Gui.E5Completers import E5FileCompleter |
|
17 |
|
18 from .Ui_TaskPropertiesDialog import Ui_TaskPropertiesDialog |
|
19 |
|
20 |
|
21 class TaskPropertiesDialog(QDialog, Ui_TaskPropertiesDialog): |
|
22 """ |
|
23 Class implementing the task properties dialog. |
|
24 """ |
|
25 def __init__(self, task=None, parent=None, projectOpen=False): |
|
26 """ |
|
27 Constructor |
|
28 |
|
29 @param task the task object to be shown |
|
30 @param parent the parent widget (QWidget) |
|
31 @param projectOpen flag indicating status of the project (boolean) |
|
32 """ |
|
33 super(TaskPropertiesDialog, self).__init__(parent) |
|
34 self.setupUi(self) |
|
35 |
|
36 self.filenameCompleter = E5FileCompleter(self.filenameEdit) |
|
37 |
|
38 if not projectOpen: |
|
39 self.projectCheckBox.setEnabled(False) |
|
40 if task is not None: |
|
41 self.summaryEdit.setText(task.summary) |
|
42 self.descriptionEdit.setText(task.description) |
|
43 self.creationLabel.setText( |
|
44 time.strftime("%Y-%m-%d, %H:%M:%S", |
|
45 time.localtime(task.created))) |
|
46 self.priorityCombo.setCurrentIndex(task.priority) |
|
47 self.projectCheckBox.setChecked(task._isProjectTask) |
|
48 self.completedCheckBox.setChecked(task.completed) |
|
49 self.filenameEdit.setText(task.filename) |
|
50 if task.lineno: |
|
51 self.linenoEdit.setText(str(task.lineno)) |
|
52 else: |
|
53 self.projectCheckBox.setChecked(projectOpen) |
|
54 |
|
55 def setReadOnly(self): |
|
56 """ |
|
57 Public slot to set the dialog to read only mode. |
|
58 """ |
|
59 self.summaryEdit.setReadOnly(True) |
|
60 self.completedCheckBox.setEnabled(False) |
|
61 self.priorityCombo.setEnabled(False) |
|
62 self.projectCheckBox.setEnabled(False) |
|
63 self.descriptionEdit.setEnabled(False) |
|
64 |
|
65 def setSubTaskMode(self, projectTask): |
|
66 """ |
|
67 Public slot to set the sub-task mode. |
|
68 |
|
69 @param projectTask flag indicating a project related task (boolean) |
|
70 """ |
|
71 self.projectCheckBox.setChecked(projectTask) |
|
72 self.projectCheckBox.setEnabled(False) |
|
73 |
|
74 def getData(self): |
|
75 """ |
|
76 Public method to retrieve the dialogs data. |
|
77 |
|
78 @return tuple of description, priority, completion flag, |
|
79 project flag and long text (string, string, boolean, |
|
80 boolean, string) |
|
81 """ |
|
82 return (self.summaryEdit.text(), |
|
83 self.priorityCombo.currentIndex(), |
|
84 self.completedCheckBox.isChecked(), |
|
85 self.projectCheckBox.isChecked(), |
|
86 self.descriptionEdit.toPlainText()) |