eric6/UI/FindFileDialog.py

changeset 8220
006ee31b4835
parent 8218
7c09585bd960
child 8235
78e6d29eb773
--- a/eric6/UI/FindFileDialog.py	Sun Apr 11 11:34:32 2021 +0200
+++ b/eric6/UI/FindFileDialog.py	Sun Apr 11 12:38:16 2021 +0200
@@ -502,11 +502,10 @@
         # now go through all the files
         self.__populating = True
         self.findList.setUpdatesEnabled(False)
-        progress = 0
         breakSearch = False
         occurrences = 0
         fileOccurrences = 0
-        for file in files:
+        for progress, file in enumerate(files, start=1):
             self.__lastFileItem = None
             found = False
             if self.__cancelSearch or breakSearch:
@@ -523,17 +522,14 @@
                 text, encoding, hashStr = Utilities.readEncodedFileWithHash(fn)
                 lines = text.splitlines(True)
             except (UnicodeError, OSError):
-                progress += 1
                 self.findProgress.setValue(progress)
                 continue
             
             # now perform the search and display the lines found
-            count = 0
-            for line in lines:
+            for count, line in enumerate(lines, start=1):
                 if self.__cancelSearch:
                     break
                 
-                count += 1
                 contains = search.search(line)
                 if contains:
                     occurrences += 1
@@ -566,7 +562,6 @@
             
             if found:
                 fileOccurrences += 1
-            progress += 1
             self.findProgress.setValue(progress)
         
         if not files:
@@ -678,7 +673,6 @@
         self.findProgress.setMaximum(self.findList.topLevelItemCount())
         self.findProgress.setValue(0)
         
-        progress = 0
         for index in range(self.findList.topLevelItemCount()):
             itm = self.findList.topLevelItem(index)
             if itm.checkState(0) in [Qt.CheckState.PartiallyChecked,
@@ -708,8 +702,7 @@
                             """ Skipping it.</p><p>Reason: {1}</p>""")
                         .format(fn, str(err))
                     )
-                    progress += 1
-                    self.findProgress.setValue(progress)
+                    self.findProgress.setValue(index)
                     continue
                 
                 # Check the original and the current hash. Skip the file,
@@ -724,8 +717,7 @@
                             """</p><p>Hash 1: {1}</p><p>Hash 2: {2}</p>""")
                         .format(fn, origHash, hashStr)
                     )
-                    progress += 1
-                    self.findProgress.setValue(progress)
+                    self.findProgress.setValue(index)
                     continue
                 
                 # replace the lines authorized by the user
@@ -750,8 +742,7 @@
                         .format(fn, str(err))
                     )
             
-            progress += 1
-            self.findProgress.setValue(progress)
+            self.findProgress.setValue(index)
         
         self.findProgressLabel.setPath("")
         

eric ide

mercurial