eric6/Plugins/VcsPlugins/vcsPySvn/SvnStatusDialog.py

changeset 8143
2c730d5fd177
parent 7923
91e843545d9a
child 8151
8c1445825e7b
equal deleted inserted replaced
8141:27f636beebad 8143:2c730d5fd177
60 self.__upToDateColumn = 8 60 self.__upToDateColumn = 8
61 self.__pathColumn = 12 61 self.__pathColumn = 12
62 self.__lastColumn = self.statusList.columnCount() 62 self.__lastColumn = self.statusList.columnCount()
63 63
64 self.refreshButton = self.buttonBox.addButton( 64 self.refreshButton = self.buttonBox.addButton(
65 self.tr("Refresh"), QDialogButtonBox.ActionRole) 65 self.tr("Refresh"), QDialogButtonBox.ButtonRole.ActionRole)
66 self.refreshButton.setToolTip( 66 self.refreshButton.setToolTip(
67 self.tr("Press to refresh the status display")) 67 self.tr("Press to refresh the status display"))
68 self.refreshButton.setEnabled(False) 68 self.refreshButton.setEnabled(False)
69 self.buttonBox.button(QDialogButtonBox.Close).setEnabled(False) 69 self.buttonBox.button(
70 self.buttonBox.button(QDialogButtonBox.Cancel).setDefault(True) 70 QDialogButtonBox.StandardButton.Close).setEnabled(False)
71 self.buttonBox.button(
72 QDialogButtonBox.StandardButton.Cancel).setDefault(True)
71 73
72 self.diff = None 74 self.diff = None
73 self.vcs = vcs 75 self.vcs = vcs
74 self.vcs.committed.connect(self.__committed) 76 self.vcs.committed.connect(self.__committed)
75 77
76 self.statusList.headerItem().setText(self.__lastColumn, "") 78 self.statusList.headerItem().setText(self.__lastColumn, "")
77 self.statusList.header().setSortIndicator(self.__pathColumn, 79 self.statusList.header().setSortIndicator(self.__pathColumn,
78 Qt.AscendingOrder) 80 Qt.SortOrder.AscendingOrder)
79 if pysvn.svn_version < (1, 5, 0) or pysvn.version < (1, 6, 0): 81 if pysvn.svn_version < (1, 5, 0) or pysvn.version < (1, 6, 0):
80 self.statusList.header().hideSection(self.__changelistColumn) 82 self.statusList.header().hideSection(self.__changelistColumn)
81 83
82 self.menuactions = [] 84 self.menuactions = []
83 self.menu = QMenu() 85 self.menu = QMenu()
122 self.tr("Adjust column sizes"), 124 self.tr("Adjust column sizes"),
123 self.__resizeColumns)) 125 self.__resizeColumns))
124 for act in self.menuactions: 126 for act in self.menuactions:
125 act.setEnabled(False) 127 act.setEnabled(False)
126 128
127 self.statusList.setContextMenuPolicy(Qt.CustomContextMenu) 129 self.statusList.setContextMenuPolicy(
130 Qt.ContextMenuPolicy.CustomContextMenu)
128 self.statusList.customContextMenuRequested.connect( 131 self.statusList.customContextMenuRequested.connect(
129 self.__showContextMenu) 132 self.__showContextMenu)
130 133
131 self.modifiedIndicators = [ 134 self.modifiedIndicators = [
132 self.tr(svnStatusMap[pysvn.wc_status_kind.added]), 135 self.tr(svnStatusMap[pysvn.wc_status_kind.added]),
188 191
189 def __resizeColumns(self): 192 def __resizeColumns(self):
190 """ 193 """
191 Private method to resize the list columns. 194 Private method to resize the list columns.
192 """ 195 """
193 self.statusList.header().resizeSections(QHeaderView.ResizeToContents) 196 self.statusList.header().resizeSections(
197 QHeaderView.ResizeMode.ResizeToContents)
194 self.statusList.header().setStretchLastSection(True) 198 self.statusList.header().setStretchLastSection(True)
195 199
196 def __generateItem(self, changelist, status, propStatus, locked, history, 200 def __generateItem(self, changelist, status, propStatus, locked, history,
197 switched, lockinfo, uptodate, revision, change, author, 201 switched, lockinfo, uptodate, revision, change, author,
198 path): 202 path):
212 @param author author of the last change (string) 216 @param author author of the last change (string)
213 @param path path of the file or directory (string) 217 @param path path of the file or directory (string)
214 """ 218 """
215 statusText = self.tr(svnStatusMap[status]) 219 statusText = self.tr(svnStatusMap[status])
216 itm = QTreeWidgetItem(self.statusList) 220 itm = QTreeWidgetItem(self.statusList)
217 itm.setData(0, Qt.DisplayRole, "") 221 itm.setData(0, Qt.ItemDataRole.DisplayRole, "")
218 itm.setData(1, Qt.DisplayRole, changelist) 222 itm.setData(1, Qt.ItemDataRole.DisplayRole, changelist)
219 itm.setData(2, Qt.DisplayRole, statusText) 223 itm.setData(2, Qt.ItemDataRole.DisplayRole, statusText)
220 itm.setData(3, Qt.DisplayRole, self.tr(svnStatusMap[propStatus])) 224 itm.setData(3, Qt.ItemDataRole.DisplayRole,
221 itm.setData(4, Qt.DisplayRole, self.yesno[locked]) 225 self.tr(svnStatusMap[propStatus]))
222 itm.setData(5, Qt.DisplayRole, self.yesno[history]) 226 itm.setData(4, Qt.ItemDataRole.DisplayRole, self.yesno[locked])
223 itm.setData(6, Qt.DisplayRole, self.yesno[switched]) 227 itm.setData(5, Qt.ItemDataRole.DisplayRole, self.yesno[history])
224 itm.setData(7, Qt.DisplayRole, self.lockinfo[lockinfo]) 228 itm.setData(6, Qt.ItemDataRole.DisplayRole, self.yesno[switched])
225 itm.setData(8, Qt.DisplayRole, self.yesno[uptodate]) 229 itm.setData(7, Qt.ItemDataRole.DisplayRole, self.lockinfo[lockinfo])
226 itm.setData(9, Qt.DisplayRole, revision) 230 itm.setData(8, Qt.ItemDataRole.DisplayRole, self.yesno[uptodate])
227 itm.setData(10, Qt.DisplayRole, change) 231 itm.setData(9, Qt.ItemDataRole.DisplayRole, revision)
228 itm.setData(11, Qt.DisplayRole, author) 232 itm.setData(10, Qt.ItemDataRole.DisplayRole, change)
229 itm.setData(12, Qt.DisplayRole, path) 233 itm.setData(11, Qt.ItemDataRole.DisplayRole, author)
230 234 itm.setData(12, Qt.ItemDataRole.DisplayRole, path)
231 itm.setTextAlignment(1, Qt.AlignLeft) 235
232 itm.setTextAlignment(2, Qt.AlignHCenter) 236 itm.setTextAlignment(1, Qt.AlignmentFlag.AlignLeft)
233 itm.setTextAlignment(3, Qt.AlignHCenter) 237 itm.setTextAlignment(2, Qt.AlignmentFlag.AlignHCenter)
234 itm.setTextAlignment(4, Qt.AlignHCenter) 238 itm.setTextAlignment(3, Qt.AlignmentFlag.AlignHCenter)
235 itm.setTextAlignment(5, Qt.AlignHCenter) 239 itm.setTextAlignment(4, Qt.AlignmentFlag.AlignHCenter)
236 itm.setTextAlignment(6, Qt.AlignHCenter) 240 itm.setTextAlignment(5, Qt.AlignmentFlag.AlignHCenter)
237 itm.setTextAlignment(7, Qt.AlignHCenter) 241 itm.setTextAlignment(6, Qt.AlignmentFlag.AlignHCenter)
238 itm.setTextAlignment(8, Qt.AlignHCenter) 242 itm.setTextAlignment(7, Qt.AlignmentFlag.AlignHCenter)
239 itm.setTextAlignment(9, Qt.AlignRight) 243 itm.setTextAlignment(8, Qt.AlignmentFlag.AlignHCenter)
240 itm.setTextAlignment(10, Qt.AlignRight) 244 itm.setTextAlignment(9, Qt.AlignmentFlag.AlignRight)
241 itm.setTextAlignment(11, Qt.AlignLeft) 245 itm.setTextAlignment(10, Qt.AlignmentFlag.AlignRight)
242 itm.setTextAlignment(12, Qt.AlignLeft) 246 itm.setTextAlignment(11, Qt.AlignmentFlag.AlignLeft)
247 itm.setTextAlignment(12, Qt.AlignmentFlag.AlignLeft)
243 248
244 if ( 249 if (
245 status in [pysvn.wc_status_kind.added, 250 status in [pysvn.wc_status_kind.added,
246 pysvn.wc_status_kind.deleted, 251 pysvn.wc_status_kind.deleted,
247 pysvn.wc_status_kind.modified] or 252 pysvn.wc_status_kind.modified] or
248 propStatus in [pysvn.wc_status_kind.added, 253 propStatus in [pysvn.wc_status_kind.added,
249 pysvn.wc_status_kind.deleted, 254 pysvn.wc_status_kind.deleted,
250 pysvn.wc_status_kind.modified] 255 pysvn.wc_status_kind.modified]
251 ): 256 ):
252 itm.setFlags(itm.flags() | Qt.ItemIsUserCheckable) 257 itm.setFlags(itm.flags() | Qt.ItemFlag.ItemIsUserCheckable)
253 itm.setCheckState(self.__toBeCommittedColumn, Qt.Checked) 258 itm.setCheckState(self.__toBeCommittedColumn,
259 Qt.CheckState.Checked)
254 else: 260 else:
255 itm.setFlags(itm.flags() & ~Qt.ItemIsUserCheckable) 261 itm.setFlags(itm.flags() & ~Qt.ItemFlag.ItemIsUserCheckable)
256 262
257 if statusText not in self.__statusFilters: 263 if statusText not in self.__statusFilters:
258 self.__statusFilters.append(statusText) 264 self.__statusFilters.append(statusText)
259 265
260 def start(self, fn): 266 def start(self, fn):
279 self.statusFilterCombo.clear() 285 self.statusFilterCombo.clear()
280 self.__statusFilters = [] 286 self.__statusFilters = []
281 self.statusList.clear() 287 self.statusList.clear()
282 self.shouldCancel = False 288 self.shouldCancel = False
283 289
284 self.buttonBox.button(QDialogButtonBox.Close).setEnabled(False) 290 self.buttonBox.button(
285 self.buttonBox.button(QDialogButtonBox.Cancel).setEnabled(True) 291 QDialogButtonBox.StandardButton.Close).setEnabled(False)
286 self.buttonBox.button(QDialogButtonBox.Cancel).setDefault(True) 292 self.buttonBox.button(
293 QDialogButtonBox.StandardButton.Cancel).setEnabled(True)
294 self.buttonBox.button(
295 QDialogButtonBox.StandardButton.Cancel).setDefault(True)
287 self.refreshButton.setEnabled(False) 296 self.refreshButton.setEnabled(False)
288 297
289 self.args = fn 298 self.args = fn
290 299
291 self.setWindowTitle(self.tr('Subversion Status')) 300 self.setWindowTitle(self.tr('Subversion Status'))
462 def __finish(self): 471 def __finish(self):
463 """ 472 """
464 Private slot called when the process finished or the user pressed 473 Private slot called when the process finished or the user pressed
465 the button. 474 the button.
466 """ 475 """
467 self.buttonBox.button(QDialogButtonBox.Close).setEnabled(True) 476 self.buttonBox.button(
468 self.buttonBox.button(QDialogButtonBox.Cancel).setEnabled(False) 477 QDialogButtonBox.StandardButton.Close).setEnabled(True)
469 self.buttonBox.button(QDialogButtonBox.Close).setDefault(True) 478 self.buttonBox.button(
479 QDialogButtonBox.StandardButton.Cancel).setEnabled(False)
480 self.buttonBox.button(
481 QDialogButtonBox.StandardButton.Close).setDefault(True)
470 482
471 self.refreshButton.setEnabled(True) 483 self.refreshButton.setEnabled(True)
472 self.__updateButtons() 484 self.__updateButtons()
473 self.__updateCommitButton() 485 self.__updateCommitButton()
474 486
488 """ 500 """
489 Private slot called by a button of the button box clicked. 501 Private slot called by a button of the button box clicked.
490 502
491 @param button button that was clicked (QAbstractButton) 503 @param button button that was clicked (QAbstractButton)
492 """ 504 """
493 if button == self.buttonBox.button(QDialogButtonBox.Close): 505 if button == self.buttonBox.button(
506 QDialogButtonBox.StandardButton.Close
507 ):
494 self.close() 508 self.close()
495 elif button == self.buttonBox.button(QDialogButtonBox.Cancel): 509 elif button == self.buttonBox.button(
510 QDialogButtonBox.StandardButton.Cancel
511 ):
496 self.__finish() 512 self.__finish()
497 elif button == self.refreshButton: 513 elif button == self.refreshButton:
498 self.on_refreshButton_clicked() 514 self.on_refreshButton_clicked()
499 515
500 @pyqtSlot() 516 @pyqtSlot()
886 @return list of all items, the user has checked 902 @return list of all items, the user has checked
887 """ 903 """
888 commitableItems = [] 904 commitableItems = []
889 for index in range(self.statusList.topLevelItemCount()): 905 for index in range(self.statusList.topLevelItemCount()):
890 itm = self.statusList.topLevelItem(index) 906 itm = self.statusList.topLevelItem(index)
891 if itm.checkState(self.__toBeCommittedColumn) == Qt.Checked: 907 if (
908 itm.checkState(self.__toBeCommittedColumn) ==
909 Qt.CheckState.Checked
910 ):
892 commitableItems.append(itm) 911 commitableItems.append(itm)
893 return commitableItems 912 return commitableItems
894 913
895 def __getModifiedItems(self): 914 def __getModifiedItems(self):
896 """ 915 """
977 996
978 @param selected commit selection state to be set (boolean) 997 @param selected commit selection state to be set (boolean)
979 """ 998 """
980 for index in range(self.statusList.topLevelItemCount()): 999 for index in range(self.statusList.topLevelItemCount()):
981 itm = self.statusList.topLevelItem(index) 1000 itm = self.statusList.topLevelItem(index)
982 if itm.flags() & Qt.ItemIsUserCheckable: 1001 if itm.flags() & Qt.ItemFlag.ItemIsUserCheckable:
983 if selected: 1002 if selected:
984 itm.setCheckState(self.__toBeCommittedColumn, Qt.Checked) 1003 itm.setCheckState(
1004 self.__toBeCommittedColumn, Qt.CheckState.Checked)
985 else: 1005 else:
986 itm.setCheckState(self.__toBeCommittedColumn, Qt.Unchecked) 1006 itm.setCheckState(
1007 self.__toBeCommittedColumn, Qt.CheckState.Unchecked)

eric ide

mercurial