eric6/UI/SearchWidget.py

Wed, 30 Dec 2020 11:00:05 +0100

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Wed, 30 Dec 2020 11:00:05 +0100
changeset 7923
91e843545d9a
parent 7781
607a6098cb44
child 8143
2c730d5fd177
permissions
-rw-r--r--

Updated copyright for 2021.

1823
21d988eaf1bf Added the capability to search in the recorded log of the log viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1 # -*- coding: utf-8 -*-
21d988eaf1bf Added the capability to search in the recorded log of the log viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
2
7923
91e843545d9a Updated copyright for 2021.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7781
diff changeset
3 # Copyright (c) 2012 - 2021 Detlev Offenbach <detlev@die-offenbachs.de>
1823
21d988eaf1bf Added the capability to search in the recorded log of the log viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
4 #
21d988eaf1bf Added the capability to search in the recorded log of the log viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
5
21d988eaf1bf Added the capability to search in the recorded log of the log viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
6 """
6987
3371a03ed0a7 Performed some interface cleanups.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6942
diff changeset
7 Module implementing the search box for the shell and log viewer.
1823
21d988eaf1bf Added the capability to search in the recorded log of the log viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
8 """
21d988eaf1bf Added the capability to search in the recorded log of the log viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
9
3656
441956d8fce5 Started porting eric5 to PyQt5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3484
diff changeset
10 from PyQt5.QtCore import pyqtSlot, pyqtSignal, Qt
441956d8fce5 Started porting eric5 to PyQt5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3484
diff changeset
11 from PyQt5.QtWidgets import QWidget, QSpacerItem, QSizePolicy
1823
21d988eaf1bf Added the capability to search in the recorded log of the log viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
12
21d988eaf1bf Added the capability to search in the recorded log of the log viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
13 import UI.PixmapCache
21d988eaf1bf Added the capability to search in the recorded log of the log viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
14
21d988eaf1bf Added the capability to search in the recorded log of the log viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
15
5710
b5809b948010 Continued implementing the standalone shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
16 class SearchWidget(QWidget):
1823
21d988eaf1bf Added the capability to search in the recorded log of the log viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
17 """
6987
3371a03ed0a7 Performed some interface cleanups.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6942
diff changeset
18 Class implementing the search box for the shell and log viewer.
1823
21d988eaf1bf Added the capability to search in the recorded log of the log viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
19
6573
ccac2d1f6858 SearchReplaceWidget: changed the regexp search to use QScintilla's POSIX mode
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
20 @signal searchNext(text, caseSensitive, wholeWord, regexp) emitted when the
ccac2d1f6858 SearchReplaceWidget: changed the regexp search to use QScintilla's POSIX mode
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
21 user pressed the next button (string, boolean, boolean)
ccac2d1f6858 SearchReplaceWidget: changed the regexp search to use QScintilla's POSIX mode
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
22 @signal searchPrevious(text, caseSensitive, wholeWord, regexp) emitted when
ccac2d1f6858 SearchReplaceWidget: changed the regexp search to use QScintilla's POSIX mode
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
23 the user pressed the previous button (string, boolean, boolean)
1823
21d988eaf1bf Added the capability to search in the recorded log of the log viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
24 """
6573
ccac2d1f6858 SearchReplaceWidget: changed the regexp search to use QScintilla's POSIX mode
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
25 searchNext = pyqtSignal(str, bool, bool, bool)
ccac2d1f6858 SearchReplaceWidget: changed the regexp search to use QScintilla's POSIX mode
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
26 searchPrevious = pyqtSignal(str, bool, bool, bool)
1823
21d988eaf1bf Added the capability to search in the recorded log of the log viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
27
7206
74666c6679af Removed some obsolete code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6987
diff changeset
28 def __init__(self, mainWindow, parent=None, spacer=True, showLine=False):
1823
21d988eaf1bf Added the capability to search in the recorded log of the log viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
29 """
21d988eaf1bf Added the capability to search in the recorded log of the log viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
30 Constructor
21d988eaf1bf Added the capability to search in the recorded log of the log viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
31
6573
ccac2d1f6858 SearchReplaceWidget: changed the regexp search to use QScintilla's POSIX mode
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
32 @param mainWindow reference to the main window
ccac2d1f6858 SearchReplaceWidget: changed the regexp search to use QScintilla's POSIX mode
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
33 @type QWidget
ccac2d1f6858 SearchReplaceWidget: changed the regexp search to use QScintilla's POSIX mode
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
34 @param parent reference to the parent widget
ccac2d1f6858 SearchReplaceWidget: changed the regexp search to use QScintilla's POSIX mode
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
35 @type QWidget
1833
f7cd855680f1 Added the capability to search in the output of the shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1830
diff changeset
36 @param spacer flag indicating to add a vertical spacer to the
6573
ccac2d1f6858 SearchReplaceWidget: changed the regexp search to use QScintilla's POSIX mode
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
37 main layout
ccac2d1f6858 SearchReplaceWidget: changed the regexp search to use QScintilla's POSIX mode
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
38 @type bool
ccac2d1f6858 SearchReplaceWidget: changed the regexp search to use QScintilla's POSIX mode
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
39 @param showLine flag indicating to show all widget in one row
ccac2d1f6858 SearchReplaceWidget: changed the regexp search to use QScintilla's POSIX mode
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
40 @type bool
1823
21d988eaf1bf Added the capability to search in the recorded log of the log viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
41 """
2525
8b507a9a2d40 Script changes: Future import added, super calls modified and unicode behavior for str.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 2302
diff changeset
42 super(SearchWidget, self).__init__(parent)
5710
b5809b948010 Continued implementing the standalone shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
43
b5809b948010 Continued implementing the standalone shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
44 if showLine:
b5809b948010 Continued implementing the standalone shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
45 from .Ui_SearchWidgetLine import Ui_SearchWidgetLine
b5809b948010 Continued implementing the standalone shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
46 self.__ui = Ui_SearchWidgetLine()
1848
aa5003c03f83 A little enhancement to the new search widget for the shell, terminal and log viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1833
diff changeset
47 else:
5710
b5809b948010 Continued implementing the standalone shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
48 from .Ui_SearchWidget import Ui_SearchWidget
b5809b948010 Continued implementing the standalone shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
49 self.__ui = Ui_SearchWidget()
b5809b948010 Continued implementing the standalone shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
50 self.__ui.setupUi(self)
6573
ccac2d1f6858 SearchReplaceWidget: changed the regexp search to use QScintilla's POSIX mode
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
51
5710
b5809b948010 Continued implementing the standalone shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
52 if not showLine:
b5809b948010 Continued implementing the standalone shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
53 if spacer:
b5809b948010 Continued implementing the standalone shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
54 spacerItem = QSpacerItem(
b5809b948010 Continued implementing the standalone shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
55 20, 1, QSizePolicy.Minimum, QSizePolicy.Expanding)
b5809b948010 Continued implementing the standalone shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
56 self.__ui.verticalLayout.addItem(spacerItem)
b5809b948010 Continued implementing the standalone shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
57 else:
b5809b948010 Continued implementing the standalone shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
58 # change the size policy of the search combo if the spacer is
b5809b948010 Continued implementing the standalone shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
59 # not wanted, i.e. it is below the to be searched widget
b5809b948010 Continued implementing the standalone shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
60 sizePolicy = self.__ui.findtextCombo.sizePolicy()
b5809b948010 Continued implementing the standalone shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
61 sizePolicy.setHorizontalPolicy(QSizePolicy.Expanding)
b5809b948010 Continued implementing the standalone shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
62 self.__ui.findtextCombo.setSizePolicy(sizePolicy)
1823
21d988eaf1bf Added the capability to search in the recorded log of the log viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
63
21d988eaf1bf Added the capability to search in the recorded log of the log viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
64 self.__mainWindow = mainWindow
21d988eaf1bf Added the capability to search in the recorded log of the log viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
65 self.__findBackwards = True
21d988eaf1bf Added the capability to search in the recorded log of the log viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
66
5710
b5809b948010 Continued implementing the standalone shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
67 self.__ui.closeButton.setIcon(
7533
88261c96484b Removed the '.png' extension from all call to get an icon or a pixmap from the PixmapCache because this is not needed anymore.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
68 UI.PixmapCache.getIcon("close"))
5710
b5809b948010 Continued implementing the standalone shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
69 self.__ui.findPrevButton.setIcon(
7533
88261c96484b Removed the '.png' extension from all call to get an icon or a pixmap from the PixmapCache because this is not needed anymore.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
70 UI.PixmapCache.getIcon("1leftarrow"))
5710
b5809b948010 Continued implementing the standalone shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
71 self.__ui.findNextButton.setIcon(
7533
88261c96484b Removed the '.png' extension from all call to get an icon or a pixmap from the PixmapCache because this is not needed anymore.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
72 UI.PixmapCache.getIcon("1rightarrow"))
1823
21d988eaf1bf Added the capability to search in the recorded log of the log viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
73
21d988eaf1bf Added the capability to search in the recorded log of the log viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
74 self.findHistory = []
21d988eaf1bf Added the capability to search in the recorded log of the log viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
75
5710
b5809b948010 Continued implementing the standalone shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
76 self.__ui.findtextCombo.setCompleter(None)
b5809b948010 Continued implementing the standalone shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
77 self.__ui.findtextCombo.lineEdit().returnPressed.connect(
3012
d177226027e2 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2965
diff changeset
78 self.__findByReturnPressed)
3366
6084bb3c3911 Made some changes to have a bunch of dialogs with correct sizes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3190
diff changeset
79
6084bb3c3911 Made some changes to have a bunch of dialogs with correct sizes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3190
diff changeset
80 msh = self.minimumSizeHint()
6084bb3c3911 Made some changes to have a bunch of dialogs with correct sizes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3190
diff changeset
81 self.resize(max(self.width(), msh.width()), msh.height())
1823
21d988eaf1bf Added the capability to search in the recorded log of the log viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
82
21d988eaf1bf Added the capability to search in the recorded log of the log viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
83 @pyqtSlot()
21d988eaf1bf Added the capability to search in the recorded log of the log viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
84 def on_closeButton_clicked(self):
21d988eaf1bf Added the capability to search in the recorded log of the log viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
85 """
21d988eaf1bf Added the capability to search in the recorded log of the log viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
86 Private slot to close the widget.
21d988eaf1bf Added the capability to search in the recorded log of the log viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
87 """
21d988eaf1bf Added the capability to search in the recorded log of the log viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
88 self.close()
21d988eaf1bf Added the capability to search in the recorded log of the log viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
89
21d988eaf1bf Added the capability to search in the recorded log of the log viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
90 def keyPressEvent(self, event):
21d988eaf1bf Added the capability to search in the recorded log of the log viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
91 """
21d988eaf1bf Added the capability to search in the recorded log of the log viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
92 Protected slot to handle key press events.
21d988eaf1bf Added the capability to search in the recorded log of the log viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
93
21d988eaf1bf Added the capability to search in the recorded log of the log viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
94 @param event reference to the key press event (QKeyEvent)
21d988eaf1bf Added the capability to search in the recorded log of the log viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
95 """
21d988eaf1bf Added the capability to search in the recorded log of the log viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
96 if event.key() == Qt.Key_Escape:
21d988eaf1bf Added the capability to search in the recorded log of the log viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
97 self.__mainWindow.setFocus(Qt.ActiveWindowFocusReason)
21d988eaf1bf Added the capability to search in the recorded log of the log viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
98 event.accept()
21d988eaf1bf Added the capability to search in the recorded log of the log viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
99 self.close()
21d988eaf1bf Added the capability to search in the recorded log of the log viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
100
21d988eaf1bf Added the capability to search in the recorded log of the log viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
101 @pyqtSlot()
21d988eaf1bf Added the capability to search in the recorded log of the log viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
102 def on_findNextButton_clicked(self):
21d988eaf1bf Added the capability to search in the recorded log of the log viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
103 """
21d988eaf1bf Added the capability to search in the recorded log of the log viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
104 Private slot to find the next occurrence.
21d988eaf1bf Added the capability to search in the recorded log of the log viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
105 """
5710
b5809b948010 Continued implementing the standalone shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
106 txt = self.__ui.findtextCombo.currentText()
b5809b948010 Continued implementing the standalone shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
107 if not txt and not self.isVisible():
b5809b948010 Continued implementing the standalone shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
108 self.showFind()
b5809b948010 Continued implementing the standalone shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
109 return
b5809b948010 Continued implementing the standalone shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
110
1823
21d988eaf1bf Added the capability to search in the recorded log of the log viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
111 self.__findBackwards = False
21d988eaf1bf Added the capability to search in the recorded log of the log viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
112
21d988eaf1bf Added the capability to search in the recorded log of the log viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
113 # This moves any previous occurrence of this statement to the head
21d988eaf1bf Added the capability to search in the recorded log of the log viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
114 # of the list and updates the combobox
21d988eaf1bf Added the capability to search in the recorded log of the log viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
115 if txt in self.findHistory:
21d988eaf1bf Added the capability to search in the recorded log of the log viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
116 self.findHistory.remove(txt)
21d988eaf1bf Added the capability to search in the recorded log of the log viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
117 self.findHistory.insert(0, txt)
5710
b5809b948010 Continued implementing the standalone shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
118 self.__ui.findtextCombo.clear()
b5809b948010 Continued implementing the standalone shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
119 self.__ui.findtextCombo.addItems(self.findHistory)
1823
21d988eaf1bf Added the capability to search in the recorded log of the log viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
120
3030
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3012
diff changeset
121 self.searchNext.emit(
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3012
diff changeset
122 txt,
5710
b5809b948010 Continued implementing the standalone shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
123 self.__ui.caseCheckBox.isChecked(),
6573
ccac2d1f6858 SearchReplaceWidget: changed the regexp search to use QScintilla's POSIX mode
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
124 self.__ui.wordCheckBox.isChecked(),
ccac2d1f6858 SearchReplaceWidget: changed the regexp search to use QScintilla's POSIX mode
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
125 self.__ui.regexpCheckBox.isChecked(),
ccac2d1f6858 SearchReplaceWidget: changed the regexp search to use QScintilla's POSIX mode
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
126 )
1823
21d988eaf1bf Added the capability to search in the recorded log of the log viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
127
21d988eaf1bf Added the capability to search in the recorded log of the log viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
128 @pyqtSlot()
21d988eaf1bf Added the capability to search in the recorded log of the log viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
129 def on_findPrevButton_clicked(self):
21d988eaf1bf Added the capability to search in the recorded log of the log viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
130 """
21d988eaf1bf Added the capability to search in the recorded log of the log viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
131 Private slot to find the previous occurrence.
21d988eaf1bf Added the capability to search in the recorded log of the log viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
132 """
5710
b5809b948010 Continued implementing the standalone shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
133 txt = self.__ui.findtextCombo.currentText()
b5809b948010 Continued implementing the standalone shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
134 if not txt and not self.isVisible():
b5809b948010 Continued implementing the standalone shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
135 self.showFind()
b5809b948010 Continued implementing the standalone shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
136 return
b5809b948010 Continued implementing the standalone shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
137
1823
21d988eaf1bf Added the capability to search in the recorded log of the log viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
138 self.__findBackwards = True
21d988eaf1bf Added the capability to search in the recorded log of the log viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
139
21d988eaf1bf Added the capability to search in the recorded log of the log viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
140 # This moves any previous occurrence of this statement to the head
21d988eaf1bf Added the capability to search in the recorded log of the log viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
141 # of the list and updates the combobox
21d988eaf1bf Added the capability to search in the recorded log of the log viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
142 if txt in self.findHistory:
21d988eaf1bf Added the capability to search in the recorded log of the log viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
143 self.findHistory.remove(txt)
21d988eaf1bf Added the capability to search in the recorded log of the log viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
144 self.findHistory.insert(0, txt)
5710
b5809b948010 Continued implementing the standalone shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
145 self.__ui.findtextCombo.clear()
b5809b948010 Continued implementing the standalone shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
146 self.__ui.findtextCombo.addItems(self.findHistory)
1823
21d988eaf1bf Added the capability to search in the recorded log of the log viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
147
3030
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3012
diff changeset
148 self.searchPrevious.emit(
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3012
diff changeset
149 txt,
5710
b5809b948010 Continued implementing the standalone shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
150 self.__ui.caseCheckBox.isChecked(),
6573
ccac2d1f6858 SearchReplaceWidget: changed the regexp search to use QScintilla's POSIX mode
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
151 self.__ui.wordCheckBox.isChecked(),
ccac2d1f6858 SearchReplaceWidget: changed the regexp search to use QScintilla's POSIX mode
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
152 self.__ui.regexpCheckBox.isChecked(),
ccac2d1f6858 SearchReplaceWidget: changed the regexp search to use QScintilla's POSIX mode
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
153 )
1823
21d988eaf1bf Added the capability to search in the recorded log of the log viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
154
21d988eaf1bf Added the capability to search in the recorded log of the log viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
155 @pyqtSlot(str)
21d988eaf1bf Added the capability to search in the recorded log of the log viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
156 def on_findtextCombo_editTextChanged(self, txt):
21d988eaf1bf Added the capability to search in the recorded log of the log viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
157 """
21d988eaf1bf Added the capability to search in the recorded log of the log viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
158 Private slot to enable/disable the find buttons.
21d988eaf1bf Added the capability to search in the recorded log of the log viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
159
21d988eaf1bf Added the capability to search in the recorded log of the log viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
160 @param txt text of the combobox (string)
21d988eaf1bf Added the capability to search in the recorded log of the log viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
161 """
21d988eaf1bf Added the capability to search in the recorded log of the log viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
162 self.__setSearchButtons(txt != "")
21d988eaf1bf Added the capability to search in the recorded log of the log viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
163
21d988eaf1bf Added the capability to search in the recorded log of the log viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
164 def __setSearchButtons(self, enabled):
21d988eaf1bf Added the capability to search in the recorded log of the log viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
165 """
21d988eaf1bf Added the capability to search in the recorded log of the log viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
166 Private slot to set the state of the search buttons.
21d988eaf1bf Added the capability to search in the recorded log of the log viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
167
21d988eaf1bf Added the capability to search in the recorded log of the log viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
168 @param enabled flag indicating the state (boolean)
21d988eaf1bf Added the capability to search in the recorded log of the log viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
169 """
5710
b5809b948010 Continued implementing the standalone shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
170 self.__ui.findPrevButton.setEnabled(enabled)
b5809b948010 Continued implementing the standalone shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
171 self.__ui.findNextButton.setEnabled(enabled)
1823
21d988eaf1bf Added the capability to search in the recorded log of the log viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
172
21d988eaf1bf Added the capability to search in the recorded log of the log viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
173 def __findByReturnPressed(self):
21d988eaf1bf Added the capability to search in the recorded log of the log viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
174 """
3012
d177226027e2 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2965
diff changeset
175 Private slot to handle the returnPressed signal of the findtext
d177226027e2 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2965
diff changeset
176 combobox.
1823
21d988eaf1bf Added the capability to search in the recorded log of the log viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
177 """
21d988eaf1bf Added the capability to search in the recorded log of the log viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
178 if self.__findBackwards:
21d988eaf1bf Added the capability to search in the recorded log of the log viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
179 self.on_findPrevButton_clicked()
21d988eaf1bf Added the capability to search in the recorded log of the log viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
180 else:
21d988eaf1bf Added the capability to search in the recorded log of the log viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
181 self.on_findNextButton_clicked()
21d988eaf1bf Added the capability to search in the recorded log of the log viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
182
21d988eaf1bf Added the capability to search in the recorded log of the log viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
183 def showFind(self, txt=""):
21d988eaf1bf Added the capability to search in the recorded log of the log viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
184 """
21d988eaf1bf Added the capability to search in the recorded log of the log viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
185 Public method to display this widget.
21d988eaf1bf Added the capability to search in the recorded log of the log viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
186
21d988eaf1bf Added the capability to search in the recorded log of the log viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
187 @param txt text to be shown in the combo (string)
21d988eaf1bf Added the capability to search in the recorded log of the log viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
188 """
5710
b5809b948010 Continued implementing the standalone shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
189 self.__ui.findtextCombo.clear()
b5809b948010 Continued implementing the standalone shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
190 self.__ui.findtextCombo.addItems(self.findHistory)
b5809b948010 Continued implementing the standalone shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
191 self.__ui.findtextCombo.setEditText(txt)
b5809b948010 Continued implementing the standalone shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
192 self.__ui.findtextCombo.setFocus()
1823
21d988eaf1bf Added the capability to search in the recorded log of the log viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
193
21d988eaf1bf Added the capability to search in the recorded log of the log viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
194 self.__setSearchButtons(txt != "")
21d988eaf1bf Added the capability to search in the recorded log of the log viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
195
21d988eaf1bf Added the capability to search in the recorded log of the log viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
196 self.show()
1830
f2fccb8c2ab4 Added the capability to search in the output of the terminal window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1823
diff changeset
197
f2fccb8c2ab4 Added the capability to search in the output of the terminal window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1823
diff changeset
198 def searchStringFound(self, found):
f2fccb8c2ab4 Added the capability to search in the output of the terminal window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1823
diff changeset
199 """
f2fccb8c2ab4 Added the capability to search in the output of the terminal window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1823
diff changeset
200 Public slot to indicate that the search string was found.
f2fccb8c2ab4 Added the capability to search in the output of the terminal window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1823
diff changeset
201
f2fccb8c2ab4 Added the capability to search in the output of the terminal window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1823
diff changeset
202 @param found flag indicating success (boolean)
f2fccb8c2ab4 Added the capability to search in the output of the terminal window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1823
diff changeset
203 """
f2fccb8c2ab4 Added the capability to search in the output of the terminal window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1823
diff changeset
204 if found:
5710
b5809b948010 Continued implementing the standalone shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
205 self.__ui.statusLabel.clear()
1830
f2fccb8c2ab4 Added the capability to search in the output of the terminal window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1823
diff changeset
206 else:
5710
b5809b948010 Continued implementing the standalone shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
207 txt = self.__ui.findtextCombo.currentText()
b5809b948010 Continued implementing the standalone shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
208 self.__ui.statusLabel.setText(
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3160
diff changeset
209 self.tr("'{0}' was not found.").format(txt))

eric ide

mercurial