7 Module implementing a dialog to search for text in files. |
7 Module implementing a dialog to search for text in files. |
8 """ |
8 """ |
9 |
9 |
10 import os |
10 import os |
11 import re |
11 import re |
|
12 import time |
12 |
13 |
13 from PyQt6.QtCore import pyqtSignal, pyqtSlot, Qt, QPoint, QUrl |
14 from PyQt6.QtCore import pyqtSignal, pyqtSlot, Qt, QPoint, QUrl |
14 from PyQt6.QtGui import QCursor, QDesktopServices, QImageReader |
15 from PyQt6.QtGui import QCursor, QDesktopServices, QImageReader |
15 from PyQt6.QtWidgets import ( |
16 from PyQt6.QtWidgets import ( |
16 QWidget, QApplication, QMenu, QTreeWidgetItem, QComboBox |
17 QWidget, QApplication, QMenu, QTreeWidgetItem, QComboBox |
613 lines = text.splitlines(True) |
614 lines = text.splitlines(True) |
614 except (UnicodeError, OSError): |
615 except (UnicodeError, OSError): |
615 self.findProgress.setValue(progress) |
616 self.findProgress.setValue(progress) |
616 continue |
617 continue |
617 |
618 |
|
619 now = time.monotonic() |
618 # now perform the search and display the lines found |
620 # now perform the search and display the lines found |
619 for count, line in enumerate(lines, start=1): |
621 for count, line in enumerate(lines, start=1): |
620 if self.__cancelSearch: |
622 if self.__cancelSearch: |
621 break |
623 break |
622 |
624 |
639 line = "- {0}\n+ {1}".format( |
641 line = "- {0}\n+ {1}".format( |
640 line, self.__stripEol(rline)) |
642 line, self.__stripEol(rline)) |
641 self.__createItem(file, count, line, start, end, |
643 self.__createItem(file, count, line, start, end, |
642 rline, hashStr) |
644 rline, hashStr) |
643 |
645 |
644 QApplication.processEvents() |
646 if time.monotonic() - now > 0.01: |
|
647 QApplication.processEvents() |
|
648 now = time.monotonic() |
645 |
649 |
646 if found: |
650 if found: |
647 fileOccurrences += 1 |
651 fileOccurrences += 1 |
648 self.findProgress.setValue(progress) |
652 self.findProgress.setValue(progress) |
649 |
653 |