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 |
135 guard = guard[1:] |
135 guard = guard[1:] |
136 sign = "-" |
136 sign = "-" |
137 else: |
137 else: |
138 continue |
138 continue |
139 itm = QListWidgetItem(icon, guard, self.guardsList) |
139 itm = QListWidgetItem(icon, guard, self.guardsList) |
140 itm.setData(Qt.UserRole, sign) |
140 itm.setData(Qt.ItemDataRole.UserRole, sign) |
141 |
141 |
142 self.on_guardsList_itemSelectionChanged() |
142 self.on_guardsList_itemSelectionChanged() |
143 |
143 |
144 @pyqtSlot() |
144 @pyqtSlot() |
145 def on_guardsList_itemSelectionChanged(self): |
145 def on_guardsList_itemSelectionChanged(self): |
154 Private method to get a reference to a named guard. |
154 Private method to get a reference to a named guard. |
155 |
155 |
156 @param guard name of the guard (string) |
156 @param guard name of the guard (string) |
157 @return reference to the guard item (QListWidgetItem) |
157 @return reference to the guard item (QListWidgetItem) |
158 """ |
158 """ |
159 items = self.guardsList.findItems(guard, Qt.MatchCaseSensitive) |
159 items = self.guardsList.findItems( |
|
160 guard, Qt.MatchFlag.MatchCaseSensitive) |
160 if items: |
161 if items: |
161 return items[0] |
162 return items[0] |
162 else: |
163 else: |
163 return None |
164 return None |
164 |
165 |
190 row = self.guardsList.row(guardItem) |
191 row = self.guardsList.row(guardItem) |
191 itm = self.guardsList.takeItem(row) |
192 itm = self.guardsList.takeItem(row) |
192 del itm |
193 del itm |
193 |
194 |
194 itm = QListWidgetItem(icon, guard, self.guardsList) |
195 itm = QListWidgetItem(icon, guard, self.guardsList) |
195 itm.setData(Qt.UserRole, sign) |
196 itm.setData(Qt.ItemDataRole.UserRole, sign) |
196 self.guardsList.sortItems() |
197 self.guardsList.sortItems() |
197 |
198 |
198 self.__dirtyList = True |
199 self.__dirtyList = True |
199 |
200 |
200 @pyqtSlot() |
201 @pyqtSlot() |
220 """ |
221 """ |
221 Private slot called by a button of the button box clicked. |
222 Private slot called by a button of the button box clicked. |
222 |
223 |
223 @param button button that was clicked (QAbstractButton) |
224 @param button button that was clicked (QAbstractButton) |
224 """ |
225 """ |
225 if button == self.buttonBox.button(QDialogButtonBox.Apply): |
226 if button == self.buttonBox.button( |
|
227 QDialogButtonBox.StandardButton.Apply |
|
228 ): |
226 self.__applyGuards() |
229 self.__applyGuards() |
227 elif button == self.buttonBox.button(QDialogButtonBox.Close): |
230 elif button == self.buttonBox.button( |
|
231 QDialogButtonBox.StandardButton.Close |
|
232 ): |
228 self.close() |
233 self.close() |
229 |
234 |
230 @pyqtSlot() |
235 @pyqtSlot() |
231 def __applyGuards(self): |
236 def __applyGuards(self): |
232 """ |
237 """ |
234 """ |
239 """ |
235 if self.__dirtyList: |
240 if self.__dirtyList: |
236 guardsList = [] |
241 guardsList = [] |
237 for row in range(self.guardsList.count()): |
242 for row in range(self.guardsList.count()): |
238 itm = self.guardsList.item(row) |
243 itm = self.guardsList.item(row) |
239 guard = itm.data(Qt.UserRole) + itm.text() |
244 guard = itm.data(Qt.ItemDataRole.UserRole) + itm.text() |
240 guardsList.append(guard) |
245 guardsList.append(guard) |
241 |
246 |
242 args = self.vcs.initCommand("qguard") |
247 args = self.vcs.initCommand("qguard") |
243 args.append(self.patchNameLabel.text()) |
248 args.append(self.patchNameLabel.text()) |
244 if guardsList: |
249 if guardsList: |