23 def __init__(self, mode, tagsList, branchesList, bookmarksList, |
23 def __init__(self, mode, tagsList, branchesList, bookmarksList, |
24 parent=None): |
24 parent=None): |
25 """ |
25 """ |
26 Constructor |
26 Constructor |
27 |
27 |
28 @param mode of the dialog (integer) |
28 @param mode of the dialog |
29 @param tagsList list of tags (list of strings) |
29 @type int |
30 @param branchesList list of branches (list of strings) |
30 @param tagsList list of tags |
31 @param bookmarksList list of bookmarks (list of strings) |
31 @type list of str |
32 @param parent reference to the parent widget (QWidget) |
32 @param branchesList list of branches |
|
33 @type list of str |
|
34 @param bookmarksList list of bookmarks |
|
35 @type list of str |
|
36 @param parent parent widget |
|
37 @type QWidget |
33 """ |
38 """ |
34 super().__init__(parent) |
39 super().__init__(parent) |
35 self.setupUi(self) |
40 self.setupUi(self) |
36 |
41 |
37 self.buttonBox.button( |
42 self.buttonBox.button( |
50 |
55 |
51 self.tagCombo.addItems(sorted(tagsList)) |
56 self.tagCombo.addItems(sorted(tagsList)) |
52 self.branchCombo.addItems(["default"] + sorted(branchesList)) |
57 self.branchCombo.addItems(["default"] + sorted(branchesList)) |
53 self.bookmarkCombo.addItems(sorted(bookmarksList)) |
58 self.bookmarkCombo.addItems(sorted(bookmarksList)) |
54 |
59 |
|
60 # connect various radio buttons and input fields |
|
61 self.idButton.toggled.connect(self.__updateOK) |
|
62 self.tagButton.toggled.connect(self.__updateOK) |
|
63 self.branchButton.toggled.connect(self.__updateOK) |
|
64 self.bookmarkButton.toggled.connect(self.__updateOK) |
|
65 self.expressionButton.toggled.connect(self.__updateOK) |
|
66 |
|
67 self.nameCombo.activated.connect(self.__updateOK) |
|
68 self.nameCombo.activated.connect(self.__updateBookmarksCombo) |
|
69 |
|
70 self.nameEdit.textChanged.connect(self.__updateOK) |
|
71 self.idEdit.textChanged.connect(self.__updateOK) |
|
72 self.expressionEdit.textChanged.connect(self.__updateOK) |
|
73 |
|
74 self.tagCombo.editTextChanged.connect(self.__updateOK) |
|
75 self.branchCombo.editTextChanged.connect(self.__updateOK) |
|
76 self.bookmarkCombo.editTextChanged.connect(self.__updateOK) |
|
77 |
55 msh = self.minimumSizeHint() |
78 msh = self.minimumSizeHint() |
56 self.resize(max(self.width(), msh.width()), msh.height()) |
79 self.resize(max(self.width(), msh.width()), msh.height()) |
57 |
80 |
|
81 @pyqtSlot() |
58 def __updateOK(self): |
82 def __updateOK(self): |
59 """ |
83 """ |
60 Private slot to update the OK button. |
84 Private slot to update the OK button. |
61 """ |
85 """ |
62 enabled = ( |
86 enabled = ( |
63 self.nameCombo.currentText() != "" |
87 bool(self.nameCombo.currentText()) |
64 if self.__mode == self.MOVE_MODE else |
88 if self.__mode == self.MOVE_MODE else |
65 self.nameEdit.text() != "" |
89 bool(self.nameEdit.text()) |
66 ) |
90 ) |
|
91 |
67 if self.idButton.isChecked(): |
92 if self.idButton.isChecked(): |
68 enabled = enabled and self.idEdit.text() != "" |
93 enabled = bool(self.idEdit.text()) |
69 elif self.tagButton.isChecked(): |
94 elif self.tagButton.isChecked(): |
70 enabled = enabled and self.tagCombo.currentText() != "" |
95 enabled = bool(self.tagCombo.currentText()) |
71 elif self.branchButton.isChecked(): |
96 elif self.branchButton.isChecked(): |
72 enabled = enabled and self.branchCombo.currentText() != "" |
97 enabled = bool(self.branchCombo.currentText()) |
73 elif self.bookmarkButton.isChecked(): |
98 elif self.bookmarkButton.isChecked(): |
74 enabled = enabled and self.bookmarkCombo.currentText() != "" |
99 enabled = bool(self.bookmarkCombo.currentText()) |
|
100 elif self.expressionButton.isChecked(): |
|
101 enabled = enabled and bool(self.expressionEdit.text()) |
75 |
102 |
76 self.buttonBox.button( |
103 self.buttonBox.button( |
77 QDialogButtonBox.StandardButton.Ok).setEnabled(enabled) |
104 QDialogButtonBox.StandardButton.Ok).setEnabled(enabled) |
78 |
105 |
79 def __updateBookmarksCombo(self): |
106 def __updateBookmarksCombo(self): |
92 if selectedBookmark: |
119 if selectedBookmark: |
93 index = self.bookmarkCombo.findText(selectedBookmark) |
120 index = self.bookmarkCombo.findText(selectedBookmark) |
94 if index > -1: |
121 if index > -1: |
95 self.bookmarkCombo.setCurrentIndex(index) |
122 self.bookmarkCombo.setCurrentIndex(index) |
96 |
123 |
97 @pyqtSlot(int) |
|
98 def on_nameCombo_activated(self, index): |
|
99 """ |
|
100 Private slot to handle changes of the selected bookmark name. |
|
101 |
|
102 @param index index of the selected entry |
|
103 @type int |
|
104 """ |
|
105 self.__updateOK() |
|
106 self.__updateBookmarksCombo() |
|
107 |
|
108 @pyqtSlot(str) |
|
109 def on_nameEdit_textChanged(self, txt): |
|
110 """ |
|
111 Private slot to handle changes of the bookmark name. |
|
112 |
|
113 @param txt text of the edit (string) |
|
114 """ |
|
115 self.__updateOK() |
|
116 |
|
117 @pyqtSlot(bool) |
|
118 def on_idButton_toggled(self, checked): |
|
119 """ |
|
120 Private slot to handle changes of the ID select button. |
|
121 |
|
122 @param checked state of the button (boolean) |
|
123 """ |
|
124 self.__updateOK() |
|
125 |
|
126 @pyqtSlot(bool) |
|
127 def on_tagButton_toggled(self, checked): |
|
128 """ |
|
129 Private slot to handle changes of the Tag select button. |
|
130 |
|
131 @param checked state of the button (boolean) |
|
132 """ |
|
133 self.__updateOK() |
|
134 |
|
135 @pyqtSlot(bool) |
|
136 def on_branchButton_toggled(self, checked): |
|
137 """ |
|
138 Private slot to handle changes of the Branch select button. |
|
139 |
|
140 @param checked state of the button (boolean) |
|
141 """ |
|
142 self.__updateOK() |
|
143 |
|
144 @pyqtSlot(bool) |
|
145 def on_bookmarkButton_toggled(self, checked): |
|
146 """ |
|
147 Private slot to handle changes of the Bookmark select button. |
|
148 |
|
149 @param checked state of the button (boolean) |
|
150 """ |
|
151 self.__updateOK() |
|
152 |
|
153 @pyqtSlot(str) |
|
154 def on_idEdit_textChanged(self, txt): |
|
155 """ |
|
156 Private slot to handle changes of the ID edit. |
|
157 |
|
158 @param txt text of the edit (string) |
|
159 """ |
|
160 self.__updateOK() |
|
161 |
|
162 @pyqtSlot(str) |
|
163 def on_tagCombo_editTextChanged(self, txt): |
|
164 """ |
|
165 Private slot to handle changes of the Tag combo. |
|
166 |
|
167 @param txt text of the combo (string) |
|
168 """ |
|
169 self.__updateOK() |
|
170 |
|
171 @pyqtSlot(str) |
|
172 def on_branchCombo_editTextChanged(self, txt): |
|
173 """ |
|
174 Private slot to handle changes of the Branch combo. |
|
175 |
|
176 @param txt text of the combo (string) |
|
177 """ |
|
178 self.__updateOK() |
|
179 |
|
180 @pyqtSlot(str) |
|
181 def on_bookmarkCombo_editTextChanged(self, txt): |
|
182 """ |
|
183 Private slot to handle changes of the Bookmark combo. |
|
184 |
|
185 @param txt text of the combo (string) |
|
186 """ |
|
187 self.__updateOK() |
|
188 |
|
189 def getData(self): |
124 def getData(self): |
190 """ |
125 """ |
191 Public method to retrieve the entered data. |
126 Public method to retrieve the entered data. |
192 |
127 |
193 @return tuple naming the revision and the bookmark name |
128 @return tuple naming the revision and the bookmark name |
194 (string, string) |
129 @rtype tuple of (str, str) |
195 """ |
130 """ |
196 if self.numberButton.isChecked(): |
131 if self.numberButton.isChecked(): |
197 rev = "rev({0})".format(self.numberSpinBox.value()) |
132 rev = "rev({0})".format(self.numberSpinBox.value()) |
198 elif self.idButton.isChecked(): |
133 elif self.idButton.isChecked(): |
199 rev = "id({0})".format(self.idEdit.text()) |
134 rev = "id({0})".format(self.idEdit.text()) |
201 rev = self.tagCombo.currentText() |
136 rev = self.tagCombo.currentText() |
202 elif self.branchButton.isChecked(): |
137 elif self.branchButton.isChecked(): |
203 rev = self.branchCombo.currentText() |
138 rev = self.branchCombo.currentText() |
204 elif self.bookmarkButton.isChecked(): |
139 elif self.bookmarkButton.isChecked(): |
205 rev = self.bookmarkCombo.currentText() |
140 rev = self.bookmarkCombo.currentText() |
|
141 elif self.expressionButton.isChecked(): |
|
142 rev = self.expressionEdit.text() |
206 else: |
143 else: |
207 rev = "" |
144 rev = "" |
208 |
145 |
209 name = ( |
146 name = ( |
210 self.nameCombo.currentText().replace(" ", "_") |
147 self.nameCombo.currentText().replace(" ", "_") |