32 @param patchesList list of patches (list of strings) |
32 @param patchesList list of patches (list of strings) |
33 @param parent reference to the parent widget (QWidget) |
33 @param parent reference to the parent widget (QWidget) |
34 """ |
34 """ |
35 super(HgQueuesDefineGuardsDialog, self).__init__(parent) |
35 super(HgQueuesDefineGuardsDialog, self).__init__(parent) |
36 self.setupUi(self) |
36 self.setupUi(self) |
37 self.setWindowFlags(Qt.Window) |
37 self.setWindowFlags(Qt.WindowType.Window) |
38 |
38 |
39 self.vcs = vcs |
39 self.vcs = vcs |
40 self.extension = extension |
40 self.extension = extension |
41 self.__hgClient = vcs.getClient() |
41 self.__hgClient = vcs.getClient() |
42 |
42 |
80 |
80 |
81 def start(self): |
81 def start(self): |
82 """ |
82 """ |
83 Public slot to start the list command. |
83 Public slot to start the list command. |
84 """ |
84 """ |
85 self.on_patchSelector_activated("") |
85 self.on_patchSelector_activated(0) |
86 |
86 |
87 @pyqtSlot(str) |
87 @pyqtSlot(int) |
88 def on_patchSelector_activated(self, patch): |
88 def on_patchSelector_activated(self, index): |
89 """ |
89 """ |
90 Private slot to get the list of guards defined for the given patch |
90 Private slot to get the list of guards defined for the given patch |
91 name. |
91 name. |
92 |
92 |
93 @param patch selected patch name (empty for current patch) |
93 @param index index of the selected entry |
94 """ |
94 @type int |
|
95 """ |
|
96 patch = self.patchSelector.itemText(index) |
95 if self.__dirtyList: |
97 if self.__dirtyList: |
96 res = E5MessageBox.question( |
98 res = E5MessageBox.question( |
97 self, |
99 self, |
98 self.tr("Unsaved Changes"), |
100 self.tr("Unsaved Changes"), |
99 self.tr("""The guards list has been changed.""" |
101 self.tr("""The guards list has been changed.""" |
135 guard = guard[1:] |
137 guard = guard[1:] |
136 sign = "-" |
138 sign = "-" |
137 else: |
139 else: |
138 continue |
140 continue |
139 itm = QListWidgetItem(icon, guard, self.guardsList) |
141 itm = QListWidgetItem(icon, guard, self.guardsList) |
140 itm.setData(Qt.UserRole, sign) |
142 itm.setData(Qt.ItemDataRole.UserRole, sign) |
141 |
143 |
142 self.on_guardsList_itemSelectionChanged() |
144 self.on_guardsList_itemSelectionChanged() |
143 |
145 |
144 @pyqtSlot() |
146 @pyqtSlot() |
145 def on_guardsList_itemSelectionChanged(self): |
147 def on_guardsList_itemSelectionChanged(self): |
154 Private method to get a reference to a named guard. |
156 Private method to get a reference to a named guard. |
155 |
157 |
156 @param guard name of the guard (string) |
158 @param guard name of the guard (string) |
157 @return reference to the guard item (QListWidgetItem) |
159 @return reference to the guard item (QListWidgetItem) |
158 """ |
160 """ |
159 items = self.guardsList.findItems(guard, Qt.MatchCaseSensitive) |
161 items = self.guardsList.findItems( |
|
162 guard, Qt.MatchFlag.MatchCaseSensitive) |
160 if items: |
163 if items: |
161 return items[0] |
164 return items[0] |
162 else: |
165 else: |
163 return None |
166 return None |
164 |
167 |
190 row = self.guardsList.row(guardItem) |
193 row = self.guardsList.row(guardItem) |
191 itm = self.guardsList.takeItem(row) |
194 itm = self.guardsList.takeItem(row) |
192 del itm |
195 del itm |
193 |
196 |
194 itm = QListWidgetItem(icon, guard, self.guardsList) |
197 itm = QListWidgetItem(icon, guard, self.guardsList) |
195 itm.setData(Qt.UserRole, sign) |
198 itm.setData(Qt.ItemDataRole.UserRole, sign) |
196 self.guardsList.sortItems() |
199 self.guardsList.sortItems() |
197 |
200 |
198 self.__dirtyList = True |
201 self.__dirtyList = True |
199 |
202 |
200 @pyqtSlot() |
203 @pyqtSlot() |
220 """ |
223 """ |
221 Private slot called by a button of the button box clicked. |
224 Private slot called by a button of the button box clicked. |
222 |
225 |
223 @param button button that was clicked (QAbstractButton) |
226 @param button button that was clicked (QAbstractButton) |
224 """ |
227 """ |
225 if button == self.buttonBox.button(QDialogButtonBox.Apply): |
228 if button == self.buttonBox.button( |
|
229 QDialogButtonBox.StandardButton.Apply |
|
230 ): |
226 self.__applyGuards() |
231 self.__applyGuards() |
227 elif button == self.buttonBox.button(QDialogButtonBox.Close): |
232 elif button == self.buttonBox.button( |
|
233 QDialogButtonBox.StandardButton.Close |
|
234 ): |
228 self.close() |
235 self.close() |
229 |
236 |
230 @pyqtSlot() |
237 @pyqtSlot() |
231 def __applyGuards(self): |
238 def __applyGuards(self): |
232 """ |
239 """ |
234 """ |
241 """ |
235 if self.__dirtyList: |
242 if self.__dirtyList: |
236 guardsList = [] |
243 guardsList = [] |
237 for row in range(self.guardsList.count()): |
244 for row in range(self.guardsList.count()): |
238 itm = self.guardsList.item(row) |
245 itm = self.guardsList.item(row) |
239 guard = itm.data(Qt.UserRole) + itm.text() |
246 guard = itm.data(Qt.ItemDataRole.UserRole) + itm.text() |
240 guardsList.append(guard) |
247 guardsList.append(guard) |
241 |
248 |
242 args = self.vcs.initCommand("qguard") |
249 args = self.vcs.initCommand("qguard") |
243 args.append(self.patchNameLabel.text()) |
250 args.append(self.patchNameLabel.text()) |
244 if guardsList: |
251 if guardsList: |
256 self.tr("""<p>The defined guards could not be""" |
263 self.tr("""<p>The defined guards could not be""" |
257 """ applied.</p><p>Reason: {0}</p>""") |
264 """ applied.</p><p>Reason: {0}</p>""") |
258 .format(error)) |
265 .format(error)) |
259 else: |
266 else: |
260 self.__dirtyList = False |
267 self.__dirtyList = False |
261 self.on_patchSelector_activated( |
268 index = self.patchSelector.findText(self.patchNameLabel.text()) |
262 self.patchNameLabel.text()) |
269 if index == -1: |
|
270 index = 0 |
|
271 self.on_patchSelector_activated(index) |