eric6/Plugins/VcsPlugins/vcsSubversion/SvnStatusDialog.py

branch
maintenance
changeset 8176
31965986ecd1
parent 8151
8c1445825e7b
child 8218
7c09585bd960
equal deleted inserted replaced
8153:e01ae92db699 8176:31965986ecd1
52 self.__upToDateColumn = 8 52 self.__upToDateColumn = 8
53 self.__pathColumn = 12 53 self.__pathColumn = 12
54 self.__lastColumn = self.statusList.columnCount() 54 self.__lastColumn = self.statusList.columnCount()
55 55
56 self.refreshButton = self.buttonBox.addButton( 56 self.refreshButton = self.buttonBox.addButton(
57 self.tr("Refresh"), QDialogButtonBox.ActionRole) 57 self.tr("Refresh"), QDialogButtonBox.ButtonRole.ActionRole)
58 self.refreshButton.setToolTip( 58 self.refreshButton.setToolTip(
59 self.tr("Press to refresh the status display")) 59 self.tr("Press to refresh the status display"))
60 self.refreshButton.setEnabled(False) 60 self.refreshButton.setEnabled(False)
61 self.buttonBox.button(QDialogButtonBox.Close).setEnabled(False) 61 self.buttonBox.button(
62 self.buttonBox.button(QDialogButtonBox.Cancel).setDefault(True) 62 QDialogButtonBox.StandardButton.Close).setEnabled(False)
63 self.buttonBox.button(
64 QDialogButtonBox.StandardButton.Cancel).setDefault(True)
63 65
64 self.diff = None 66 self.diff = None
65 self.vcs = vcs 67 self.vcs = vcs
66 self.vcs.committed.connect(self.__committed) 68 self.vcs.committed.connect(self.__committed)
67 69
70 self.process.readyReadStandardOutput.connect(self.__readStdout) 72 self.process.readyReadStandardOutput.connect(self.__readStdout)
71 self.process.readyReadStandardError.connect(self.__readStderr) 73 self.process.readyReadStandardError.connect(self.__readStderr)
72 74
73 self.statusList.headerItem().setText(self.__lastColumn, "") 75 self.statusList.headerItem().setText(self.__lastColumn, "")
74 self.statusList.header().setSortIndicator(self.__pathColumn, 76 self.statusList.header().setSortIndicator(self.__pathColumn,
75 Qt.AscendingOrder) 77 Qt.SortOrder.AscendingOrder)
76 if self.vcs.version < (1, 5, 0): 78 if self.vcs.version < (1, 5, 0):
77 self.statusList.header().hideSection(self.__changelistColumn) 79 self.statusList.header().hideSection(self.__changelistColumn)
78 80
79 self.menuactions = [] 81 self.menuactions = []
80 self.menu = QMenu() 82 self.menu = QMenu()
119 self.tr("Adjust column sizes"), 121 self.tr("Adjust column sizes"),
120 self.__resizeColumns)) 122 self.__resizeColumns))
121 for act in self.menuactions: 123 for act in self.menuactions:
122 act.setEnabled(False) 124 act.setEnabled(False)
123 125
124 self.statusList.setContextMenuPolicy(Qt.CustomContextMenu) 126 self.statusList.setContextMenuPolicy(
127 Qt.ContextMenuPolicy.CustomContextMenu)
125 self.statusList.customContextMenuRequested.connect( 128 self.statusList.customContextMenuRequested.connect(
126 self.__showContextMenu) 129 self.__showContextMenu)
127 130
128 self.modifiedIndicators = [ 131 self.modifiedIndicators = [
129 self.tr('added'), 132 self.tr('added'),
217 220
218 def __resizeColumns(self): 221 def __resizeColumns(self):
219 """ 222 """
220 Private method to resize the list columns. 223 Private method to resize the list columns.
221 """ 224 """
222 self.statusList.header().resizeSections(QHeaderView.ResizeToContents) 225 self.statusList.header().resizeSections(
226 QHeaderView.ResizeMode.ResizeToContents)
223 self.statusList.header().setStretchLastSection(True) 227 self.statusList.header().setStretchLastSection(True)
224 228
225 def __generateItem(self, status, propStatus, locked, history, switched, 229 def __generateItem(self, status, propStatus, locked, history, switched,
226 lockinfo, uptodate, revision, change, author, path): 230 lockinfo, uptodate, revision, change, author, path):
227 """ 231 """
267 except ValueError: 271 except ValueError:
268 chg = change 272 chg = change
269 statusText = self.status[status] 273 statusText = self.status[status]
270 274
271 itm = QTreeWidgetItem(self.statusList) 275 itm = QTreeWidgetItem(self.statusList)
272 itm.setData(0, Qt.DisplayRole, "") 276 itm.setData(0, Qt.ItemDataRole.DisplayRole, "")
273 itm.setData(1, Qt.DisplayRole, self.currentChangelist) 277 itm.setData(1, Qt.ItemDataRole.DisplayRole, self.currentChangelist)
274 itm.setData(2, Qt.DisplayRole, statusText) 278 itm.setData(2, Qt.ItemDataRole.DisplayRole, statusText)
275 itm.setData(3, Qt.DisplayRole, self.propStatus[propStatus]) 279 itm.setData(3, Qt.ItemDataRole.DisplayRole,
276 itm.setData(4, Qt.DisplayRole, self.locked[locked]) 280 self.propStatus[propStatus])
277 itm.setData(5, Qt.DisplayRole, self.history[history]) 281 itm.setData(4, Qt.ItemDataRole.DisplayRole, self.locked[locked])
278 itm.setData(6, Qt.DisplayRole, self.switched[switched]) 282 itm.setData(5, Qt.ItemDataRole.DisplayRole, self.history[history])
279 itm.setData(7, Qt.DisplayRole, self.lockinfo[lockinfo]) 283 itm.setData(6, Qt.ItemDataRole.DisplayRole, self.switched[switched])
280 itm.setData(8, Qt.DisplayRole, self.uptodate[uptodate]) 284 itm.setData(7, Qt.ItemDataRole.DisplayRole, self.lockinfo[lockinfo])
281 itm.setData(9, Qt.DisplayRole, rev) 285 itm.setData(8, Qt.ItemDataRole.DisplayRole, self.uptodate[uptodate])
282 itm.setData(10, Qt.DisplayRole, chg) 286 itm.setData(9, Qt.ItemDataRole.DisplayRole, rev)
283 itm.setData(11, Qt.DisplayRole, author) 287 itm.setData(10, Qt.ItemDataRole.DisplayRole, chg)
284 itm.setData(12, Qt.DisplayRole, path) 288 itm.setData(11, Qt.ItemDataRole.DisplayRole, author)
285 289 itm.setData(12, Qt.ItemDataRole.DisplayRole, path)
286 itm.setTextAlignment(1, Qt.AlignLeft) 290
287 itm.setTextAlignment(2, Qt.AlignHCenter) 291 itm.setTextAlignment(1, Qt.AlignmentFlag.AlignLeft)
288 itm.setTextAlignment(3, Qt.AlignHCenter) 292 itm.setTextAlignment(2, Qt.AlignmentFlag.AlignHCenter)
289 itm.setTextAlignment(4, Qt.AlignHCenter) 293 itm.setTextAlignment(3, Qt.AlignmentFlag.AlignHCenter)
290 itm.setTextAlignment(5, Qt.AlignHCenter) 294 itm.setTextAlignment(4, Qt.AlignmentFlag.AlignHCenter)
291 itm.setTextAlignment(6, Qt.AlignHCenter) 295 itm.setTextAlignment(5, Qt.AlignmentFlag.AlignHCenter)
292 itm.setTextAlignment(7, Qt.AlignHCenter) 296 itm.setTextAlignment(6, Qt.AlignmentFlag.AlignHCenter)
293 itm.setTextAlignment(8, Qt.AlignHCenter) 297 itm.setTextAlignment(7, Qt.AlignmentFlag.AlignHCenter)
294 itm.setTextAlignment(9, Qt.AlignRight) 298 itm.setTextAlignment(8, Qt.AlignmentFlag.AlignHCenter)
295 itm.setTextAlignment(10, Qt.AlignRight) 299 itm.setTextAlignment(9, Qt.AlignmentFlag.AlignRight)
296 itm.setTextAlignment(11, Qt.AlignLeft) 300 itm.setTextAlignment(10, Qt.AlignmentFlag.AlignRight)
297 itm.setTextAlignment(12, Qt.AlignLeft) 301 itm.setTextAlignment(11, Qt.AlignmentFlag.AlignLeft)
302 itm.setTextAlignment(12, Qt.AlignmentFlag.AlignLeft)
298 303
299 if status in "ADM" or propStatus in "M": 304 if status in "ADM" or propStatus in "M":
300 itm.setFlags(itm.flags() | Qt.ItemIsUserCheckable) 305 itm.setFlags(itm.flags() | Qt.ItemFlag.ItemIsUserCheckable)
301 itm.setCheckState(self.__toBeCommittedColumn, Qt.Checked) 306 itm.setCheckState(self.__toBeCommittedColumn,
307 Qt.CheckState.Checked)
302 else: 308 else:
303 itm.setFlags(itm.flags() & ~Qt.ItemIsUserCheckable) 309 itm.setFlags(itm.flags() & ~Qt.ItemFlag.ItemIsUserCheckable)
304 310
305 self.hidePropertyStatusColumn = ( 311 self.hidePropertyStatusColumn = (
306 self.hidePropertyStatusColumn and 312 self.hidePropertyStatusColumn and
307 propStatus == " " 313 propStatus == " "
308 ) 314 )
324 330
325 @param e close event (QCloseEvent) 331 @param e close event (QCloseEvent)
326 """ 332 """
327 if ( 333 if (
328 self.process is not None and 334 self.process is not None and
329 self.process.state() != QProcess.NotRunning 335 self.process.state() != QProcess.ProcessState.NotRunning
330 ): 336 ):
331 self.process.terminate() 337 self.process.terminate()
332 QTimer.singleShot(2000, self.process.kill) 338 QTimer.singleShot(2000, self.process.kill)
333 self.process.waitForFinished(3000) 339 self.process.waitForFinished(3000)
334 340
410 self.tr( 416 self.tr(
411 'The process {0} could not be started. ' 417 'The process {0} could not be started. '
412 'Ensure, that it is in the search path.' 418 'Ensure, that it is in the search path.'
413 ).format('svn')) 419 ).format('svn'))
414 else: 420 else:
415 self.buttonBox.button(QDialogButtonBox.Close).setEnabled(False) 421 self.buttonBox.button(
416 self.buttonBox.button(QDialogButtonBox.Cancel).setEnabled(True) 422 QDialogButtonBox.StandardButton.Close).setEnabled(False)
417 self.buttonBox.button(QDialogButtonBox.Cancel).setDefault(True) 423 self.buttonBox.button(
424 QDialogButtonBox.StandardButton.Cancel).setEnabled(True)
425 self.buttonBox.button(
426 QDialogButtonBox.StandardButton.Cancel).setDefault(True)
418 427
419 self.inputGroup.setEnabled(True) 428 self.inputGroup.setEnabled(True)
420 self.inputGroup.show() 429 self.inputGroup.show()
421 self.refreshButton.setEnabled(False) 430 self.refreshButton.setEnabled(False)
422 431
425 Private slot called when the process finished or the user pressed 434 Private slot called when the process finished or the user pressed
426 the button. 435 the button.
427 """ 436 """
428 if ( 437 if (
429 self.process is not None and 438 self.process is not None and
430 self.process.state() != QProcess.NotRunning 439 self.process.state() != QProcess.ProcessState.NotRunning
431 ): 440 ):
432 self.process.terminate() 441 self.process.terminate()
433 QTimer.singleShot(2000, self.process.kill) 442 QTimer.singleShot(2000, self.process.kill)
434 self.process.waitForFinished(3000) 443 self.process.waitForFinished(3000)
435 444
436 self.buttonBox.button(QDialogButtonBox.Close).setEnabled(True) 445 self.buttonBox.button(
437 self.buttonBox.button(QDialogButtonBox.Cancel).setEnabled(False) 446 QDialogButtonBox.StandardButton.Close).setEnabled(True)
438 self.buttonBox.button(QDialogButtonBox.Close).setDefault(True) 447 self.buttonBox.button(
439 self.buttonBox.button(QDialogButtonBox.Close).setFocus( 448 QDialogButtonBox.StandardButton.Cancel).setEnabled(False)
440 Qt.OtherFocusReason) 449 self.buttonBox.button(
450 QDialogButtonBox.StandardButton.Close).setDefault(True)
451 self.buttonBox.button(
452 QDialogButtonBox.StandardButton.Close).setFocus(
453 Qt.FocusReason.OtherFocusReason)
441 454
442 self.inputGroup.setEnabled(False) 455 self.inputGroup.setEnabled(False)
443 self.inputGroup.hide() 456 self.inputGroup.hide()
444 self.refreshButton.setEnabled(True) 457 self.refreshButton.setEnabled(True)
445 458
475 """ 488 """
476 Private slot called by a button of the button box clicked. 489 Private slot called by a button of the button box clicked.
477 490
478 @param button button that was clicked (QAbstractButton) 491 @param button button that was clicked (QAbstractButton)
479 """ 492 """
480 if button == self.buttonBox.button(QDialogButtonBox.Close): 493 if button == self.buttonBox.button(
494 QDialogButtonBox.StandardButton.Close
495 ):
481 self.close() 496 self.close()
482 elif button == self.buttonBox.button(QDialogButtonBox.Cancel): 497 elif button == self.buttonBox.button(
498 QDialogButtonBox.StandardButton.Cancel
499 ):
483 self.__finish() 500 self.__finish()
484 elif button == self.refreshButton: 501 elif button == self.refreshButton:
485 self.on_refreshButton_clicked() 502 self.on_refreshButton_clicked()
486 503
487 def __procFinished(self, exitCode, exitStatus): 504 def __procFinished(self, exitCode, exitStatus):
499 516
500 It reads the output of the process, formats it and inserts it into 517 It reads the output of the process, formats it and inserts it into
501 the contents pane. 518 the contents pane.
502 """ 519 """
503 if self.process is not None: 520 if self.process is not None:
504 self.process.setReadChannel(QProcess.StandardOutput) 521 self.process.setReadChannel(QProcess.ProcessChannel.StandardOutput)
505 522
506 while self.process.canReadLine(): 523 while self.process.canReadLine():
507 s = str(self.process.readLine(), 524 s = str(self.process.readLine(),
508 Preferences.getSystem("IOEncoding"), 525 Preferences.getSystem("IOEncoding"),
509 'replace') 526 'replace')
554 Private slot to handle the password checkbox toggled. 571 Private slot to handle the password checkbox toggled.
555 572
556 @param isOn flag indicating the status of the check box (boolean) 573 @param isOn flag indicating the status of the check box (boolean)
557 """ 574 """
558 if isOn: 575 if isOn:
559 self.input.setEchoMode(QLineEdit.Password) 576 self.input.setEchoMode(QLineEdit.EchoMode.Password)
560 else: 577 else:
561 self.input.setEchoMode(QLineEdit.Normal) 578 self.input.setEchoMode(QLineEdit.EchoMode.Normal)
562 579
563 @pyqtSlot() 580 @pyqtSlot()
564 def on_sendButton_clicked(self): 581 def on_sendButton_clicked(self):
565 """ 582 """
566 Private slot to send the input to the subversion process. 583 Private slot to send the input to the subversion process.
625 Private method to update the Commit button status. 642 Private method to update the Commit button status.
626 """ 643 """
627 commitable = len(self.__getCommitableItems()) 644 commitable = len(self.__getCommitableItems())
628 self.commitButton.setEnabled(commitable) 645 self.commitButton.setEnabled(commitable)
629 646
630 @pyqtSlot(str) 647 @pyqtSlot(int)
631 def on_statusFilterCombo_activated(self, txt): 648 def on_statusFilterCombo_activated(self, index):
632 """ 649 """
633 Private slot to react to the selection of a status filter. 650 Private slot to react to the selection of a status filter.
634 651
635 @param txt selected status filter (string) 652 @param index index of the selected entry
636 """ 653 @type int
654 """
655 txt = self.statusFilterCombo.itemText(index)
637 if txt == "<{0}>".format(self.tr("all")): 656 if txt == "<{0}>".format(self.tr("all")):
638 for topIndex in range(self.statusList.topLevelItemCount()): 657 for topIndex in range(self.statusList.topLevelItemCount()):
639 topItem = self.statusList.topLevelItem(topIndex) 658 topItem = self.statusList.topLevelItem(topIndex)
640 topItem.setHidden(False) 659 topItem.setHidden(False)
641 else: 660 else:
978 @return list of all items, the user has checked 997 @return list of all items, the user has checked
979 """ 998 """
980 commitableItems = [] 999 commitableItems = []
981 for index in range(self.statusList.topLevelItemCount()): 1000 for index in range(self.statusList.topLevelItemCount()):
982 itm = self.statusList.topLevelItem(index) 1001 itm = self.statusList.topLevelItem(index)
983 if itm.checkState(self.__toBeCommittedColumn) == Qt.Checked: 1002 if (
1003 itm.checkState(self.__toBeCommittedColumn) ==
1004 Qt.CheckState.Checked
1005 ):
984 commitableItems.append(itm) 1006 commitableItems.append(itm)
985 return commitableItems 1007 return commitableItems
986 1008
987 def __getModifiedItems(self): 1009 def __getModifiedItems(self):
988 """ 1010 """
1069 1091
1070 @param selected commit selection state to be set (boolean) 1092 @param selected commit selection state to be set (boolean)
1071 """ 1093 """
1072 for index in range(self.statusList.topLevelItemCount()): 1094 for index in range(self.statusList.topLevelItemCount()):
1073 itm = self.statusList.topLevelItem(index) 1095 itm = self.statusList.topLevelItem(index)
1074 if itm.flags() & Qt.ItemIsUserCheckable: 1096 if itm.flags() & Qt.ItemFlag.ItemIsUserCheckable:
1075 if selected: 1097 if selected:
1076 itm.setCheckState(self.__toBeCommittedColumn, Qt.Checked) 1098 itm.setCheckState(self.__toBeCommittedColumn,
1099 Qt.CheckState.Checked)
1077 else: 1100 else:
1078 itm.setCheckState(self.__toBeCommittedColumn, Qt.Unchecked) 1101 itm.setCheckState(self.__toBeCommittedColumn,
1102 Qt.CheckState.Unchecked)

eric ide

mercurial