eric6/Plugins/VcsPlugins/vcsGit/GitStatusDialog.py

changeset 8143
2c730d5fd177
parent 7923
91e843545d9a
child 8151
8c1445825e7b
--- a/eric6/Plugins/VcsPlugins/vcsGit/GitStatusDialog.py	Mon Mar 01 17:48:43 2021 +0100
+++ b/eric6/Plugins/VcsPlugins/vcsGit/GitStatusDialog.py	Tue Mar 02 17:17:09 2021 +0100
@@ -41,7 +41,7 @@
     """
     ConflictStates = ["AA", "AU", "DD", "DU", "UA", "UD", "UU"]
     
-    ConflictRole = Qt.UserRole
+    ConflictRole = Qt.ItemDataRole.UserRole
     
     def __init__(self, vcs, parent=None):
         """
@@ -60,12 +60,14 @@
         self.__lastColumn = self.statusList.columnCount()
         
         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 status display"))
         self.refreshButton.setEnabled(False)
-        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.diff = None
         self.vcs = vcs
@@ -86,7 +88,7 @@
         
         self.statusList.headerItem().setText(self.__lastColumn, "")
         self.statusList.header().setSortIndicator(
-            self.__pathColumn, Qt.AscendingOrder)
+            self.__pathColumn, Qt.SortOrder.AscendingOrder)
         
         font = Preferences.getEditorOtherFonts("MonospacedFont")
         self.lDiffEdit.document().setDefaultFont(font)
@@ -265,7 +267,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)
@@ -315,7 +317,8 @@
         """
         Private method to resize the list columns.
         """
-        self.statusList.header().resizeSections(QHeaderView.ResizeToContents)
+        self.statusList.header().resizeSections(
+            QHeaderView.ResizeMode.ResizeToContents)
         self.statusList.header().setStretchLastSection(True)
     
     def __generateItem(self, status, path):
@@ -334,18 +337,22 @@
             path,
         ])
         
-        itm.setTextAlignment(self.__statusWorkColumn, Qt.AlignHCenter)
-        itm.setTextAlignment(self.__statusIndexColumn, Qt.AlignHCenter)
-        itm.setTextAlignment(self.__pathColumn, Qt.AlignLeft)
+        itm.setTextAlignment(self.__statusWorkColumn,
+                             Qt.AlignmentFlag.AlignHCenter)
+        itm.setTextAlignment(self.__statusIndexColumn,
+                             Qt.AlignmentFlag.AlignHCenter)
+        itm.setTextAlignment(self.__pathColumn,
+                             Qt.AlignmentFlag.AlignLeft)
     
         if (
             status not in self.ConflictStates + ["??", "!!"] and
             statusIndexText in self.modifiedIndicators
         ):
-            itm.setFlags(itm.flags() | Qt.ItemIsUserCheckable)
-            itm.setCheckState(self.__toBeCommittedColumn, Qt.Checked)
+            itm.setFlags(itm.flags() | Qt.ItemFlag.ItemIsUserCheckable)
+            itm.setCheckState(self.__toBeCommittedColumn,
+                              Qt.CheckState.Checked)
         else:
-            itm.setFlags(itm.flags() & ~Qt.ItemIsUserCheckable)
+            itm.setFlags(itm.flags() & ~Qt.ItemFlag.ItemIsUserCheckable)
         
         if statusWorkText not in self.__statusFilters:
             self.__statusFilters.append(statusWorkText)
@@ -412,9 +419,12 @@
                     'Ensure, that it is in the search path.'
                 ).format('git'))
         else:
-            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)
     
@@ -425,7 +435,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)
@@ -435,11 +445,15 @@
         self.inputGroup.hide()
         self.refreshButton.setEnabled(True)
         
-        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.Close).setFocus(
-            Qt.OtherFocusReason)
+        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.buttonBox.button(
+            QDialogButtonBox.StandardButton.Close).setFocus(
+                Qt.FocusReason.OtherFocusReason)
         
         self.__statusFilters.sort()
         self.__statusFilters.insert(0, "<{0}>".format(self.tr("all")))
@@ -456,9 +470,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.__finish()
         elif button == self.refreshButton:
             self.on_refreshButton_clicked()
@@ -480,7 +498,7 @@
         the contents pane.
         """
         if self.process is not None:
-            self.process.setReadChannel(QProcess.StandardOutput)
+            self.process.setReadChannel(QProcess.ProcessChannel.StandardOutput)
             
             while self.process.canReadLine():
                 line = str(self.process.readLine(), self.__ioEncoding,
@@ -515,9 +533,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):
@@ -903,7 +921,10 @@
         commitableItems = []
         for index in range(self.statusList.topLevelItemCount()):
             itm = self.statusList.topLevelItem(index)
-            if itm.checkState(self.__toBeCommittedColumn) == Qt.Checked:
+            if (
+                itm.checkState(self.__toBeCommittedColumn) ==
+                Qt.CheckState.Checked
+            ):
                 commitableItems.append(itm)
         return commitableItems
     
@@ -918,8 +939,9 @@
         for index in range(self.statusList.topLevelItemCount()):
             itm = self.statusList.topLevelItem(index)
             if (
-                itm.flags() & Qt.ItemIsUserCheckable and
-                itm.checkState(self.__toBeCommittedColumn) == Qt.Unchecked
+                itm.flags() & Qt.ItemFlag.ItemIsUserCheckable and
+                itm.checkState(self.__toBeCommittedColumn) ==
+                Qt.CheckState.Unchecked
             ):
                 items.append(itm)
         return items
@@ -1028,11 +1050,13 @@
         """
         for index in range(self.statusList.topLevelItemCount()):
             itm = self.statusList.topLevelItem(index)
-            if itm.flags() & Qt.ItemIsUserCheckable:
+            if itm.flags() & Qt.ItemFlag.ItemIsUserCheckable:
                 if selected:
-                    itm.setCheckState(self.__toBeCommittedColumn, Qt.Checked)
+                    itm.setCheckState(self.__toBeCommittedColumn,
+                                      Qt.CheckState.Checked)
                 else:
-                    itm.setCheckState(self.__toBeCommittedColumn, Qt.Unchecked)
+                    itm.setCheckState(self.__toBeCommittedColumn,
+                                      Qt.CheckState.Unchecked)
     
     ###########################################################################
     ## Diff handling methods below
@@ -1087,7 +1111,7 @@
         
         for diffEdit in [self.lDiffEdit, self.rDiffEdit]:
             tc = diffEdit.textCursor()
-            tc.movePosition(QTextCursor.Start)
+            tc.movePosition(QTextCursor.MoveOperation.Start)
             diffEdit.setTextCursor(tc)
             diffEdit.ensureCursorVisible()
     

eric ide

mercurial