--- a/eric6/Plugins/VcsPlugins/vcsMercurial/HgLogBrowserDialog.py Sat Mar 06 10:00:52 2021 +0100 +++ b/eric6/Plugins/VcsPlugins/vcsMercurial/HgLogBrowserDialog.py Sun Mar 28 15:00:11 2021 +0200 @@ -79,7 +79,7 @@ self.setupUi(self) windowFlags = self.windowFlags() - windowFlags |= Qt.WindowContextHelpButtonHint + windowFlags |= Qt.WindowType.WindowContextHelpButtonHint self.setWindowFlags(windowFlags) self.mainSplitter.setSizes([300, 400]) @@ -103,17 +103,20 @@ elif mode == "full_log": self.setWindowTitle(self.tr("Mercurial Full Log")) - self.buttonBox.button(QDialogButtonBox.Close).setEnabled(False) - self.buttonBox.button(QDialogButtonBox.Cancel).setDefault(True) + self.buttonBox.button( + QDialogButtonBox.StandardButton.Close).setEnabled(False) + self.buttonBox.button( + QDialogButtonBox.StandardButton.Cancel).setDefault(True) self.filesTree.headerItem().setText(self.filesTree.columnCount(), "") - self.filesTree.header().setSortIndicator(0, Qt.AscendingOrder) + self.filesTree.header().setSortIndicator( + 0, Qt.SortOrder.AscendingOrder) self.upButton.setIcon(UI.PixmapCache.getIcon("1uparrow")) self.downButton.setIcon(UI.PixmapCache.getIcon("1downarrow")) self.refreshButton = self.buttonBox.addButton( - self.tr("&Refresh"), QDialogButtonBox.ActionRole) + self.tr("&Refresh"), QDialogButtonBox.ButtonRole.ActionRole) self.refreshButton.setToolTip( self.tr("Press to refresh the list of changesets")) self.refreshButton.setEnabled(False) @@ -191,15 +194,15 @@ self.__resetUI() # roles used in the log tree - self.__messageRole = Qt.UserRole - self.__changesRole = Qt.UserRole + 1 - self.__edgesRole = Qt.UserRole + 2 - self.__parentsRole = Qt.UserRole + 3 - self.__latestTagRole = Qt.UserRole + 4 - self.__incomingRole = Qt.UserRole + 5 + self.__messageRole = Qt.ItemDataRole.UserRole + self.__changesRole = Qt.ItemDataRole.UserRole + 1 + self.__edgesRole = Qt.ItemDataRole.UserRole + 2 + self.__parentsRole = Qt.ItemDataRole.UserRole + 3 + self.__latestTagRole = Qt.ItemDataRole.UserRole + 4 + self.__incomingRole = Qt.ItemDataRole.UserRole + 5 # roles used in the file tree - self.__diffFileLineRole = Qt.UserRole + self.__diffFileLineRole = Qt.ItemDataRole.UserRole self.flags = { 'A': self.tr('Added'), @@ -499,14 +502,16 @@ """ Private method to resize the log tree columns. """ - self.logTree.header().resizeSections(QHeaderView.ResizeToContents) + self.logTree.header().resizeSections( + QHeaderView.ResizeMode.ResizeToContents) self.logTree.header().setStretchLastSection(True) def __resizeColumnsFiles(self): """ Private method to resize the changed files tree columns. """ - self.filesTree.header().resizeSections(QHeaderView.ResizeToContents) + self.filesTree.header().resizeSections( + QHeaderView.ResizeMode.ResizeToContents) self.filesTree.header().setStretchLastSection(True) def __resortFiles(self): @@ -630,7 +635,7 @@ """ return int(1.2 * radius) * col + radius // 2 + 3 - textColor = self.logTree.palette().color(QPalette.Text) + textColor = self.logTree.palette().color(QPalette.ColorRole.Text) radius = self.__dotRadius w = len(bottomedges) * radius + 20 @@ -642,7 +647,7 @@ pix = QPixmap(w, h) pix.fill(QColor(0, 0, 0, 0)) # draw transparent background painter = QPainter(pix) - painter.setRenderHint(QPainter.Antialiasing) + painter.setRenderHint(QPainter.RenderHint.Antialiasing) # draw the revision history lines for y1, y2, lines in ((0, h, bottomedges), @@ -977,9 +982,12 @@ @param startRev revision number to start from (integer, string) @param noEntries number of entries to get (0 = default) (int) """ - self.buttonBox.button(QDialogButtonBox.Close).setEnabled(False) - self.buttonBox.button(QDialogButtonBox.Cancel).setEnabled(True) - self.buttonBox.button(QDialogButtonBox.Cancel).setDefault(True) + self.buttonBox.button( + QDialogButtonBox.StandardButton.Close).setEnabled(False) + self.buttonBox.button( + QDialogButtonBox.StandardButton.Cancel).setEnabled(True) + self.buttonBox.button( + QDialogButtonBox.StandardButton.Cancel).setDefault(True) QApplication.processEvents() with E5OverrideCursor(): @@ -1115,9 +1123,12 @@ Private slot called when the process finished or the user pressed the button. """ - self.buttonBox.button(QDialogButtonBox.Close).setEnabled(True) - self.buttonBox.button(QDialogButtonBox.Cancel).setEnabled(False) - self.buttonBox.button(QDialogButtonBox.Close).setDefault(True) + self.buttonBox.button( + QDialogButtonBox.StandardButton.Close).setEnabled(True) + self.buttonBox.button( + QDialogButtonBox.StandardButton.Cancel).setEnabled(False) + self.buttonBox.button( + QDialogButtonBox.StandardButton.Close).setDefault(True) self.refreshButton.setEnabled(True) @@ -1238,7 +1249,7 @@ log["parents"], log["branches"], log["tags"], log["phase"], log["bookmarks"], log["latesttag"], canPush=canPush) - dt = QDate.fromString(log["date"], Qt.ISODate) + dt = QDate.fromString(log["date"], Qt.DateFormat.ISODate) if ( not self.__maxDate.isValid() and not self.__minDate.isValid() @@ -1262,7 +1273,7 @@ # we are really done if self.__selectedRevisions: foundItems = self.logTree.findItems( - self.__selectedRevisions[0], Qt.MatchExactly, + self.__selectedRevisions[0], Qt.MatchFlag.MatchExactly, self.RevisionColumn) if foundItems: self.logTree.setCurrentItem(foundItems[0]) @@ -1274,7 +1285,8 @@ # rev string format must match with the format of the # __generateLogItem() method items = self.logTree.findItems( - "{0:>7}:".format(rev), Qt.MatchStartsWith, + "{0:>7}:".format(rev), + Qt.MatchFlag.MatchStartsWith, self.RevisionColumn) if items: self.logTree.setCurrentItem(items[0]) @@ -1324,7 +1336,7 @@ # we are really done for revision in self.__selectedRevisions: items = self.logTree.findItems( - revision, Qt.MatchExactly, self.RevisionColumn) + revision, Qt.MatchFlag.MatchExactly, self.RevisionColumn) if items: items[0].setSelected(True) self.__selectedRevisions = [] @@ -1345,9 +1357,13 @@ @param button button that was clicked (QAbstractButton) """ - if button == self.buttonBox.button(QDialogButtonBox.Close): + if button == self.buttonBox.button( + QDialogButtonBox.StandardButton.Close + ): self.close() - elif button == self.buttonBox.button(QDialogButtonBox.Cancel): + elif button == self.buttonBox.button( + QDialogButtonBox.StandardButton.Cancel + ): self.cancelled = True self.__hgClient.cancel() elif button == self.refreshButton: @@ -1778,22 +1794,24 @@ if self.__actionMode() == "filter": self.__filterLogs() - @pyqtSlot(str) - def on_branchCombo_activated(self, txt): + @pyqtSlot(int) + def on_branchCombo_activated(self, index): """ Private slot called, when a new branch is selected. - @param txt text of the selected branch (string) + @param index index of the selected entry + @type int """ if self.__actionMode() == "filter": self.__filterLogs() - @pyqtSlot(str) - def on_fieldCombo_activated(self, txt): + @pyqtSlot(int) + def on_fieldCombo_activated(self, index): """ Private slot called, when a new filter field is selected. - @param txt text of the selected field (string) + @param index index of the selected entry + @type int """ if self.__actionMode() == "filter": self.__filterLogs() @@ -1920,9 +1938,12 @@ well @type bool """ - self.buttonBox.button(QDialogButtonBox.Close).setEnabled(False) - self.buttonBox.button(QDialogButtonBox.Cancel).setEnabled(True) - self.buttonBox.button(QDialogButtonBox.Cancel).setDefault(True) + self.buttonBox.button( + QDialogButtonBox.StandardButton.Close).setEnabled(False) + self.buttonBox.button( + QDialogButtonBox.StandardButton.Cancel).setEnabled(True) + self.buttonBox.button( + QDialogButtonBox.StandardButton.Cancel).setDefault(True) self.refreshButton.setEnabled(False) @@ -2093,7 +2114,7 @@ self.tr("Define Bookmark"), self.tr('Enter bookmark name for changeset "{0}":').format( changeset), - QLineEdit.Normal) + QLineEdit.EchoMode.Normal) if ok and bool(bookmark): self.vcs.hgBookmarkDefine( revision="rev({0})".format(rev), @@ -2458,8 +2479,8 @@ rev = url.path() searchStr = "{0:>7}:".format(rev) # format must be in sync with item generation format - items = self.logTree.findItems(searchStr, Qt.MatchStartsWith, - self.RevisionColumn) + items = self.logTree.findItems( + searchStr, Qt.MatchFlag.MatchStartsWith, self.RevisionColumn) if items: itm = items[0] if itm.isHidden(): @@ -2556,13 +2577,13 @@ for fileName in (oldFileName, newFileName): if fileName != "__NULL__": items = self.filesTree.findItems( - fileName, Qt.MatchExactly, 1) + fileName, Qt.MatchFlag.MatchExactly, 1) for item in items: item.setData(0, self.__diffFileLineRole, lineNumber) tc = self.diffEdit.textCursor() - tc.movePosition(QTextCursor.Start) + tc.movePosition(QTextCursor.MoveOperation.Start) self.diffEdit.setTextCursor(tc) self.diffEdit.ensureCursorVisible() @@ -2579,26 +2600,26 @@ if para is not None: if para == 0: tc = self.diffEdit.textCursor() - tc.movePosition(QTextCursor.Start) + tc.movePosition(QTextCursor.MoveOperation.Start) self.diffEdit.setTextCursor(tc) self.diffEdit.ensureCursorVisible() elif para == -1: tc = self.diffEdit.textCursor() - tc.movePosition(QTextCursor.End) + tc.movePosition(QTextCursor.MoveOperation.End) self.diffEdit.setTextCursor(tc) self.diffEdit.ensureCursorVisible() else: # step 1: move cursor to end tc = self.diffEdit.textCursor() - tc.movePosition(QTextCursor.End) + tc.movePosition(QTextCursor.MoveOperation.End) self.diffEdit.setTextCursor(tc) self.diffEdit.ensureCursorVisible() # step 2: move cursor to desired line tc = self.diffEdit.textCursor() delta = tc.blockNumber() - para - tc.movePosition(QTextCursor.PreviousBlock, - QTextCursor.MoveAnchor, delta) + tc.movePosition(QTextCursor.MoveOperation.PreviousBlock, + QTextCursor.MoveMode.MoveAnchor, delta) self.diffEdit.setTextCursor(tc) self.diffEdit.ensureCursorVisible()