eric6/UI/FindFileDialog.py

branch
maintenance
changeset 8176
31965986ecd1
parent 8043
0acf98cd089a
parent 8149
3fefc0c430f2
child 8273
698ae46f40a4
--- a/eric6/UI/FindFileDialog.py	Sat Mar 06 10:00:52 2021 +0100
+++ b/eric6/UI/FindFileDialog.py	Sun Mar 28 15:00:11 2021 +0200
@@ -41,11 +41,11 @@
     sourceFile = pyqtSignal(str, int, str, int, int)
     designerFile = pyqtSignal(str)
     
-    lineRole = Qt.UserRole + 1
-    startRole = Qt.UserRole + 2
-    endRole = Qt.UserRole + 3
-    replaceRole = Qt.UserRole + 4
-    md5Role = Qt.UserRole + 5
+    lineRole = Qt.ItemDataRole.UserRole + 1
+    startRole = Qt.ItemDataRole.UserRole + 2
+    endRole = Qt.ItemDataRole.UserRole + 3
+    replaceRole = Qt.ItemDataRole.UserRole + 4
+    md5Role = Qt.ItemDataRole.UserRole + 5
     
     def __init__(self, project, replaceMode=False, parent=None):
         """
@@ -57,21 +57,21 @@
         """
         super(FindFileDialog, self).__init__(parent)
         self.setupUi(self)
-        self.setWindowFlags(Qt.Window)
+        self.setWindowFlags(Qt.WindowType.Window)
         
         self.dirPicker.setMode(E5PathPickerModes.DirectoryMode)
-        self.dirPicker.setInsertPolicy(QComboBox.InsertAtTop)
+        self.dirPicker.setInsertPolicy(QComboBox.InsertPolicy.InsertAtTop)
         self.dirPicker.setSizeAdjustPolicy(
-            QComboBox.AdjustToMinimumContentsLength)
+            QComboBox.SizeAdjustPolicy.AdjustToMinimumContentsLengthWithIcon)
         
         self.__replaceMode = replaceMode
         
         self.stopButton = self.buttonBox.addButton(
-            self.tr("Stop"), QDialogButtonBox.ActionRole)
+            self.tr("Stop"), QDialogButtonBox.ButtonRole.ActionRole)
         self.stopButton.setEnabled(False)
         
         self.findButton = self.buttonBox.addButton(
-            self.tr("Find"), QDialogButtonBox.ActionRole)
+            self.tr("Find"), QDialogButtonBox.ButtonRole.ActionRole)
         self.findButton.setEnabled(False)
         self.findButton.setDefault(True)
         
@@ -109,7 +109,7 @@
         self.project = project
         
         self.findList.headerItem().setText(self.findList.columnCount(), "")
-        self.findList.header().setSortIndicator(0, Qt.AscendingOrder)
+        self.findList.header().setSortIndicator(0, Qt.SortOrder.AscendingOrder)
         self.__section0Size = self.findList.header().sectionSize(0)
         self.findList.setExpandsOnDoubleClick(False)
         if self.__replaceMode:
@@ -136,7 +136,7 @@
         self.__lastFileItem = None
         self.__populating = False
         
-        self.setContextMenuPolicy(Qt.CustomContextMenu)
+        self.setContextMenuPolicy(Qt.ContextMenuPolicy.CustomContextMenu)
         self.customContextMenuRequested.connect(self.__contextMenuRequested)
         
     def __createItem(self, file, line, text, start, end, replTxt="", md5=""):
@@ -159,20 +159,22 @@
             if self.__replaceMode:
                 self.__lastFileItem.setFlags(
                     self.__lastFileItem.flags() |
-                    Qt.ItemFlags(Qt.ItemIsUserCheckable | Qt.ItemIsTristate))
+                    Qt.ItemFlags(Qt.ItemFlag.ItemIsUserCheckable |
+                                 Qt.ItemFlag.ItemIsTristate))
             self.__lastFileItem.setData(0, self.md5Role, md5)
         
         itm = QTreeWidgetItem(self.__lastFileItem)
-        itm.setTextAlignment(0, Qt.AlignRight)
-        itm.setData(0, Qt.DisplayRole, line)
-        itm.setData(1, Qt.DisplayRole, text)
+        itm.setTextAlignment(0, Qt.AlignmentFlag.AlignRight)
+        itm.setData(0, Qt.ItemDataRole.DisplayRole, line)
+        itm.setData(1, Qt.ItemDataRole.DisplayRole, text)
         itm.setData(0, self.lineRole, line)
         itm.setData(0, self.startRole, start)
         itm.setData(0, self.endRole, end)
         itm.setData(0, self.replaceRole, replTxt)
         if self.__replaceMode:
-            itm.setFlags(itm.flags() | Qt.ItemFlags(Qt.ItemIsUserCheckable))
-            itm.setCheckState(0, Qt.Checked)
+            itm.setFlags(itm.flags() |
+                         Qt.ItemFlags(Qt.ItemFlag.ItemIsUserCheckable))
+            itm.setCheckState(0, Qt.CheckState.Checked)
             self.replaceButton.setEnabled(True)
         
     def show(self, txt=""):
@@ -275,7 +277,8 @@
              self.filterEdit.text() == "")
         ):
             self.findButton.setEnabled(False)
-            self.buttonBox.button(QDialogButtonBox.Close).setDefault(True)
+            self.buttonBox.button(
+                QDialogButtonBox.StandardButton.Close).setDefault(True)
         else:
             self.findButton.setEnabled(True)
             self.findButton.setDefault(True)
@@ -678,7 +681,8 @@
         progress = 0
         for index in range(self.findList.topLevelItemCount()):
             itm = self.findList.topLevelItem(index)
-            if itm.checkState(0) in [Qt.PartiallyChecked, Qt.Checked]:
+            if itm.checkState(0) in [Qt.CheckState.PartiallyChecked,
+                                     Qt.CheckState.Checked]:
                 file = itm.text(0)
                 origHash = itm.data(0, self.md5Role)
                 
@@ -727,7 +731,7 @@
                 # replace the lines authorized by the user
                 for cindex in range(itm.childCount()):
                     citm = itm.child(cindex)
-                    if citm.checkState(0) == Qt.Checked:
+                    if citm.checkState(0) == Qt.CheckState.Checked:
                         line = citm.data(0, self.lineRole)
                         rline = citm.data(0, self.replaceRole)
                         lines[line - 1] = rline

eric ide

mercurial