eric6/Plugins/VcsPlugins/vcsGit/GitLogBrowserDialog.py

branch
maintenance
changeset 8176
31965986ecd1
parent 8043
0acf98cd089a
parent 8151
8c1445825e7b
child 8273
698ae46f40a4
diff -r e01ae92db699 -r 31965986ecd1 eric6/Plugins/VcsPlugins/vcsGit/GitLogBrowserDialog.py
--- a/eric6/Plugins/VcsPlugins/vcsGit/GitLogBrowserDialog.py	Sat Mar 06 10:00:52 2021 +0100
+++ b/eric6/Plugins/VcsPlugins/vcsGit/GitLogBrowserDialog.py	Sun Mar 28 15:00:11 2021 +0200
@@ -73,7 +73,7 @@
         self.setupUi(self)
         
         windowFlags = self.windowFlags()
-        windowFlags |= Qt.WindowContextHelpButtonHint
+        windowFlags |= Qt.WindowType.WindowContextHelpButtonHint
         self.setWindowFlags(windowFlags)
         
         self.mainSplitter.setSizes([300, 400])
@@ -82,17 +82,20 @@
         self.diffSplitter.setStretchFactor(0, 1)
         self.diffSplitter.setStretchFactor(1, 2)
         
-        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(1, Qt.AscendingOrder)
+        self.filesTree.header().setSortIndicator(
+            1, 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 commits"))
         self.refreshButton.setEnabled(False)
@@ -182,17 +185,17 @@
         self.__resetUI()
         
         # roles used in the log tree
-        self.__subjectRole = Qt.UserRole
-        self.__messageRole = Qt.UserRole + 1
-        self.__changesRole = Qt.UserRole + 2
-        self.__edgesRole = Qt.UserRole + 3
-        self.__parentsRole = Qt.UserRole + 4
-        self.__branchesRole = Qt.UserRole + 5
-        self.__authorMailRole = Qt.UserRole + 6
-        self.__committerMailRole = Qt.UserRole + 7
+        self.__subjectRole = Qt.ItemDataRole.UserRole
+        self.__messageRole = Qt.ItemDataRole.UserRole + 1
+        self.__changesRole = Qt.ItemDataRole.UserRole + 2
+        self.__edgesRole = Qt.ItemDataRole.UserRole + 3
+        self.__parentsRole = Qt.ItemDataRole.UserRole + 4
+        self.__branchesRole = Qt.ItemDataRole.UserRole + 5
+        self.__authorMailRole = Qt.ItemDataRole.UserRole + 6
+        self.__committerMailRole = Qt.ItemDataRole.UserRole + 7
         
         # roles used in the file tree
-        self.__diffFileLineRole = Qt.UserRole
+        self.__diffFileLineRole = Qt.ItemDataRole.UserRole
         
         self.__process = E5OverrideCursorProcess()
         self.__process.finished.connect(self.__procFinished)
@@ -384,7 +387,7 @@
         """
         if (
             self.__process is not None and
-            self.__process.state() != QProcess.NotRunning
+            self.__process.state() != QProcess.ProcessState.NotRunning
         ):
             self.__process.terminate()
             QTimer.singleShot(2000, self.__process.kill)
@@ -453,14 +456,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):
@@ -468,7 +473,7 @@
         Private method to resort the changed files tree.
         """
         self.filesTree.setSortingEnabled(True)
-        self.filesTree.sortItems(1, Qt.AscendingOrder)
+        self.filesTree.sortItems(1, Qt.SortOrder.AscendingOrder)
         self.filesTree.setSortingEnabled(False)
     
     def __getColor(self, n):
@@ -571,7 +576,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),
@@ -586,7 +591,7 @@
                     painter.drawLine(x1, dot_y + y1, x2, dot_y + y2)
         
         penradius = 1
-        pencolor = self.logTree.palette().color(QPalette.Text)
+        pencolor = self.logTree.palette().color(QPalette.ColorRole.Text)
         
         dot_y = (h // 2) - radius // 2
         
@@ -765,8 +770,8 @@
             copyfrom,
         ])
         
-        itm.setTextAlignment(2, Qt.AlignRight)
-        itm.setTextAlignment(3, Qt.AlignRight)
+        itm.setTextAlignment(2, Qt.AlignmentFlag.AlignRight)
+        itm.setTextAlignment(3, Qt.AlignmentFlag.AlignRight)
         
         return itm
     
@@ -777,9 +782,12 @@
         @param skip number of log entries to skip (integer)
         @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()
         
         self.buf = []
@@ -879,15 +887,18 @@
         """
         if (
             self.__process is not None and
-            self.__process.state() != QProcess.NotRunning
+            self.__process.state() != QProcess.ProcessState.NotRunning
         ):
             self.__process.terminate()
             QTimer.singleShot(2000, self.__process.kill)
             self.__process.waitForFinished(3000)
         
-        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.inputGroup.setEnabled(False)
         self.inputGroup.hide()
@@ -911,7 +922,7 @@
             logEntry["authormail"], logEntry["committermail"]
         )
         for date in [logEntry["authordate"], logEntry["committerdate"]]:
-            dt = QDate.fromString(date, Qt.ISODate)
+            dt = QDate.fromString(date, Qt.DateFormat.ISODate)
             if (
                 not self.__maxDate.isValid() and
                 not self.__minDate.isValid()
@@ -1003,7 +1014,7 @@
         if self.__started:
             if self.__selectedCommitIDs:
                 self.logTree.setCurrentItem(self.logTree.findItems(
-                    self.__selectedCommitIDs[0], Qt.MatchExactly,
+                    self.__selectedCommitIDs[0], Qt.MatchFlag.MatchExactly,
                     self.CommitIdColumn)[0])
             else:
                 self.logTree.setCurrentItem(self.logTree.topLevelItem(0))
@@ -1036,7 +1047,7 @@
         if self.__selectedCommitIDs:
             for commitID in self.__selectedCommitIDs:
                 items = self.logTree.findItems(
-                    commitID, Qt.MatchExactly, self.CommitIdColumn)
+                    commitID, Qt.MatchFlag.MatchExactly, self.CommitIdColumn)
                 if items:
                     items[0].setSelected(True)
             self.__selectedCommitIDs = []
@@ -1047,7 +1058,7 @@
         
         It reads the output of the process and inserts it into a buffer.
         """
-        self.__process.setReadChannel(QProcess.StandardOutput)
+        self.__process.setReadChannel(QProcess.ProcessChannel.StandardOutput)
         
         while self.__process.canReadLine():
             line = str(self.__process.readLine(),
@@ -1088,9 +1099,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.__finish()
         elif button == self.refreshButton:
@@ -1101,9 +1116,12 @@
         """
         Private slot to refresh the log.
         """
-        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)
         
@@ -1122,9 +1140,9 @@
         @param isOn flag indicating the status of the check box (boolean)
         """
         if isOn:
-            self.input.setEchoMode(QLineEdit.Password)
+            self.input.setEchoMode(QLineEdit.EchoMode.Password)
         else:
-            self.input.setEchoMode(QLineEdit.Normal)
+            self.input.setEchoMode(QLineEdit.EchoMode.Normal)
     
     @pyqtSlot()
     def on_sendButton_clicked(self):
@@ -1632,12 +1650,13 @@
         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()
@@ -2066,8 +2085,8 @@
         if url.scheme() == "rev":
             # a commit ID was clicked, show the respective item
             commitId = url.path()
-            items = self.logTree.findItems(commitId, Qt.MatchStartsWith,
-                                           self.CommitIdColumn)
+            items = self.logTree.findItems(
+                commitId, Qt.MatchFlag.MatchStartsWith, self.CommitIdColumn)
             if items:
                 itm = items[0]
                 if itm.isHidden():
@@ -2169,13 +2188,13 @@
                 for fileName in (oldFileName, newFileName):
                     if fileName != "/dev/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()
     
@@ -2210,26 +2229,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()
     

eric ide

mercurial