|
1 # -*- coding: utf-8 -*- |
|
2 |
|
3 # Copyright (c) 2006 - 2009 Detlev Offenbach <detlev@die-offenbachs.de> |
|
4 # |
|
5 |
|
6 """ |
|
7 Module implementing the task filter configuration dialog. |
|
8 """ |
|
9 |
|
10 from PyQt4.QtCore import * |
|
11 from PyQt4.QtGui import * |
|
12 |
|
13 from Ui_TaskFilterConfigDialog import Ui_TaskFilterConfigDialog |
|
14 |
|
15 |
|
16 class TaskFilterConfigDialog(QDialog, Ui_TaskFilterConfigDialog): |
|
17 """ |
|
18 Class implementing the task filter configuration dialog. |
|
19 """ |
|
20 def __init__(self, taskFilter, parent = None): |
|
21 """ |
|
22 Constructor |
|
23 |
|
24 @param taskFilter the task filter object to be configured |
|
25 @param parent the parent widget (QWidget) |
|
26 """ |
|
27 QDialog.__init__(self, parent) |
|
28 self.setupUi(self) |
|
29 |
|
30 if taskFilter.descriptionFilter is None or \ |
|
31 not taskFilter.descriptionFilter.pattern(): |
|
32 self.descriptionGroup.setChecked(False) |
|
33 self.descriptionEdit.clear() |
|
34 else: |
|
35 self.descriptionGroup.setChecked(True) |
|
36 self.descriptionEdit.setText(taskFilter.descriptionFilter.pattern()) |
|
37 |
|
38 if taskFilter.filenameFilter is None or \ |
|
39 not taskFilter.filenameFilter.pattern(): |
|
40 self.filenameGroup.setChecked(False) |
|
41 self.filenameEdit.clear() |
|
42 else: |
|
43 self.filenameGroup.setChecked(True) |
|
44 self.filenameEdit.setText(taskFilter.filenameFilter.pattern()) |
|
45 |
|
46 if taskFilter.typeFilter is None: |
|
47 self.typeGroup.setChecked(False) |
|
48 self.standardRadioButton.setChecked(True) |
|
49 else: |
|
50 self.typeGroup.setChecked(True) |
|
51 if taskFilter.typeFilter: |
|
52 self.bugfixRadioButton.setChecked(True) |
|
53 else: |
|
54 self.standardRadioButton.setChecked(True) |
|
55 |
|
56 if taskFilter.scopeFilter is None: |
|
57 self.scopeGroup.setChecked(False) |
|
58 self.globalRadioButton.setChecked(True) |
|
59 else: |
|
60 self.scopeGroup.setChecked(True) |
|
61 if taskFilter.scopeFilter: |
|
62 self.projectRadioButton.setChecked(True) |
|
63 else: |
|
64 self.globalRadioButton.setChecked(True) |
|
65 |
|
66 if taskFilter.statusFilter is None: |
|
67 self.statusGroup.setChecked(False) |
|
68 self.uncompletedRadioButton.setChecked(True) |
|
69 else: |
|
70 self.statusGroup.setChecked(True) |
|
71 if taskFilter.statusFilter: |
|
72 self.completedRadioButton.setChecked(True) |
|
73 else: |
|
74 self.uncompletedRadioButton.setChecked(True) |
|
75 |
|
76 if taskFilter.prioritiesFilter is None: |
|
77 self.priorityGroup.setChecked(False) |
|
78 self.priorityHighCheckBox.setChecked(False) |
|
79 self.priorityNormalCheckBox.setChecked(False) |
|
80 self.priorityLowCheckBox.setChecked(False) |
|
81 else: |
|
82 self.priorityGroup.setChecked(True) |
|
83 self.priorityHighCheckBox.setChecked(0 in taskFilter.prioritiesFilter) |
|
84 self.priorityNormalCheckBox.setChecked(1 in taskFilter.prioritiesFilter) |
|
85 self.priorityLowCheckBox.setChecked(2 in taskFilter.prioritiesFilter) |
|
86 |
|
87 def configureTaskFilter(self, taskFilter): |
|
88 """ |
|
89 Public method to set the parameters of the task filter object.. |
|
90 |
|
91 @param taskFilter the task filter object to be configured |
|
92 """ |
|
93 if self.descriptionGroup.isChecked(): |
|
94 taskFilter.setDescriptionFilter(self.descriptionEdit.text()) |
|
95 else: |
|
96 taskFilter.setDescriptionFilter(None) |
|
97 |
|
98 if self.filenameGroup.isChecked(): |
|
99 taskFilter.setFileNameFilter(self.filenameEdit.text()) |
|
100 else: |
|
101 taskFilter.setFileNameFilter(None) |
|
102 |
|
103 if self.typeGroup.isChecked(): |
|
104 if self.bugfixRadioButton.isChecked(): |
|
105 taskFilter.setTypeFilter(True) |
|
106 else: |
|
107 taskFilter.setTypeFilter(False) |
|
108 else: |
|
109 taskFilter.setTypeFilter(None) |
|
110 |
|
111 if self.scopeGroup.isChecked(): |
|
112 if self.projectRadioButton.isChecked(): |
|
113 taskFilter.setScopeFilter(True) |
|
114 else: |
|
115 taskFilter.setScopeFilter(False) |
|
116 else: |
|
117 taskFilter.setScopeFilter(None) |
|
118 |
|
119 if self.statusGroup.isChecked(): |
|
120 if self.completedRadioButton.isChecked(): |
|
121 taskFilter.setStatusFilter(True) |
|
122 else: |
|
123 taskFilter.setStatusFilter(False) |
|
124 else: |
|
125 taskFilter.setStatusFilter(None) |
|
126 |
|
127 if self.priorityGroup.isChecked(): |
|
128 priorities = [] |
|
129 self.priorityHighCheckBox.isChecked() and priorities.append(0) |
|
130 self.priorityNormalCheckBox.isChecked() and priorities.append(1) |
|
131 self.priorityLowCheckBox.isChecked() and priorities.append(2) |
|
132 taskFilter.setPrioritiesFilter(priorities) |
|
133 else: |
|
134 taskFilter.setPrioritiesFilter(None) |