UI/SearchWidget.py

Sat, 16 Feb 2019 17:40:24 +0100

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Sat, 16 Feb 2019 17:40:24 +0100
branch
conda
changeset 6773
e74931e6b30d
parent 6645
ad476851d7e0
permissions
-rw-r--r--

conda package manager moved to default branch

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
6645
ad476851d7e0 Updated copyright for 2019.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6573
diff changeset
3 # Copyright (c) 2012 - 2019 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 """
3366
6084bb3c3911 Made some changes to have a bunch of dialogs with correct sizes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3190
diff changeset
7 Module implementing the search box for the shell, terminal 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
3145
a9de05d4a22f # __IGNORE_WARNING__ added/ removed.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3058
diff changeset
10 from __future__ import unicode_literals
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
11
3656
441956d8fce5 Started porting eric5 to PyQt5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3484
diff changeset
12 from PyQt5.QtCore import pyqtSlot, pyqtSignal, Qt
441956d8fce5 Started porting eric5 to PyQt5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3484
diff changeset
13 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
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 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
16
21d988eaf1bf Added the capability to search in the recorded log of the log viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
17
5710
b5809b948010 Continued implementing the standalone shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
18 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
19 """
3366
6084bb3c3911 Made some changes to have a bunch of dialogs with correct sizes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3190
diff changeset
20 Class implementing the search box for the shell, terminal 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
21
6573
ccac2d1f6858 SearchReplaceWidget: changed the regexp search to use QScintilla's POSIX mode
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
22 @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
23 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
24 @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
25 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
26 """
6573
ccac2d1f6858 SearchReplaceWidget: changed the regexp search to use QScintilla's POSIX mode
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
27 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
28 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
29
6573
ccac2d1f6858 SearchReplaceWidget: changed the regexp search to use QScintilla's POSIX mode
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
30 def __init__(self, mainWindow, parent=None, spacer=True, showLine=False,
ccac2d1f6858 SearchReplaceWidget: changed the regexp search to use QScintilla's POSIX mode
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
31 hideRegExp=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
32 """
21d988eaf1bf Added the capability to search in the recorded log of the log viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
33 Constructor
21d988eaf1bf Added the capability to search in the recorded log of the log viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
34
6573
ccac2d1f6858 SearchReplaceWidget: changed the regexp search to use QScintilla's POSIX mode
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
35 @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
36 @type QWidget
ccac2d1f6858 SearchReplaceWidget: changed the regexp search to use QScintilla's POSIX mode
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
37 @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
38 @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
39 @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
40 main layout
ccac2d1f6858 SearchReplaceWidget: changed the regexp search to use QScintilla's POSIX mode
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
41 @type bool
ccac2d1f6858 SearchReplaceWidget: changed the regexp search to use QScintilla's POSIX mode
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
42 @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
43 @type bool
ccac2d1f6858 SearchReplaceWidget: changed the regexp search to use QScintilla's POSIX mode
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
44 @param hideRegExp flag indicating to hide the Regexp checkbox
ccac2d1f6858 SearchReplaceWidget: changed the regexp search to use QScintilla's POSIX mode
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
45 @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
46 """
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
47 super(SearchWidget, self).__init__(parent)
5710
b5809b948010 Continued implementing the standalone shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
48
b5809b948010 Continued implementing the standalone shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
49 if showLine:
b5809b948010 Continued implementing the standalone shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
50 from .Ui_SearchWidgetLine import Ui_SearchWidgetLine
b5809b948010 Continued implementing the standalone shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
51 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
52 else:
5710
b5809b948010 Continued implementing the standalone shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
53 from .Ui_SearchWidget import Ui_SearchWidget
b5809b948010 Continued implementing the standalone shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
54 self.__ui = Ui_SearchWidget()
b5809b948010 Continued implementing the standalone shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
55 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
56
ccac2d1f6858 SearchReplaceWidget: changed the regexp search to use QScintilla's POSIX mode
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
57 if hideRegExp:
ccac2d1f6858 SearchReplaceWidget: changed the regexp search to use QScintilla's POSIX mode
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
58 self.__ui.regexpCheckBox.setChecked(False)
ccac2d1f6858 SearchReplaceWidget: changed the regexp search to use QScintilla's POSIX mode
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
59 self.__ui.regexpCheckBox.hide()
ccac2d1f6858 SearchReplaceWidget: changed the regexp search to use QScintilla's POSIX mode
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
60
5710
b5809b948010 Continued implementing the standalone shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
61 if not showLine:
b5809b948010 Continued implementing the standalone shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
62 if spacer:
b5809b948010 Continued implementing the standalone shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
63 spacerItem = QSpacerItem(
b5809b948010 Continued implementing the standalone shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
64 20, 1, QSizePolicy.Minimum, QSizePolicy.Expanding)
b5809b948010 Continued implementing the standalone shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
65 self.__ui.verticalLayout.addItem(spacerItem)
b5809b948010 Continued implementing the standalone shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
66 else:
b5809b948010 Continued implementing the standalone shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
67 # 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
68 # 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
69 sizePolicy = self.__ui.findtextCombo.sizePolicy()
b5809b948010 Continued implementing the standalone shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
70 sizePolicy.setHorizontalPolicy(QSizePolicy.Expanding)
b5809b948010 Continued implementing the standalone shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
71 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
72
21d988eaf1bf Added the capability to search in the recorded log of the log viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
73 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
74 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
75
5710
b5809b948010 Continued implementing the standalone shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
76 self.__ui.closeButton.setIcon(
b5809b948010 Continued implementing the standalone shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
77 UI.PixmapCache.getIcon("close.png"))
b5809b948010 Continued implementing the standalone shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
78 self.__ui.findPrevButton.setIcon(
b5809b948010 Continued implementing the standalone shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
79 UI.PixmapCache.getIcon("1leftarrow.png"))
b5809b948010 Continued implementing the standalone shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
80 self.__ui.findNextButton.setIcon(
b5809b948010 Continued implementing the standalone shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
81 UI.PixmapCache.getIcon("1rightarrow.png"))
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 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
84
5710
b5809b948010 Continued implementing the standalone shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
85 self.__ui.findtextCombo.setCompleter(None)
b5809b948010 Continued implementing the standalone shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
86 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
87 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
88
6084bb3c3911 Made some changes to have a bunch of dialogs with correct sizes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3190
diff changeset
89 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
90 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
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 @pyqtSlot()
21d988eaf1bf Added the capability to search in the recorded log of the log viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
93 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
94 """
21d988eaf1bf Added the capability to search in the recorded log of the log viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
95 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
96 """
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.close()
21d988eaf1bf Added the capability to search in the recorded log of the log viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
98
21d988eaf1bf Added the capability to search in the recorded log of the log viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
99 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
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 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
102
21d988eaf1bf Added the capability to search in the recorded log of the log viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
103 @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
104 """
21d988eaf1bf Added the capability to search in the recorded log of the log viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
105 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
106 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
107 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
108 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
109
21d988eaf1bf Added the capability to search in the recorded log of the log viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
110 @pyqtSlot()
21d988eaf1bf Added the capability to search in the recorded log of the log viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
111 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
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 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
114 """
5710
b5809b948010 Continued implementing the standalone shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
115 txt = self.__ui.findtextCombo.currentText()
b5809b948010 Continued implementing the standalone shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
116 if not txt and not self.isVisible():
b5809b948010 Continued implementing the standalone shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
117 self.showFind()
b5809b948010 Continued implementing the standalone shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
118 return
b5809b948010 Continued implementing the standalone shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
119
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 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
121
21d988eaf1bf Added the capability to search in the recorded log of the log viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
122 # 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
123 # 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
124 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
125 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
126 self.findHistory.insert(0, txt)
5710
b5809b948010 Continued implementing the standalone shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
127 self.__ui.findtextCombo.clear()
b5809b948010 Continued implementing the standalone shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
128 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
129
3030
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3012
diff changeset
130 self.searchNext.emit(
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3012
diff changeset
131 txt,
5710
b5809b948010 Continued implementing the standalone shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
132 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
133 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
134 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
135 )
1823
21d988eaf1bf Added the capability to search in the recorded log of the log viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
136
21d988eaf1bf Added the capability to search in the recorded log of the log viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
137 @pyqtSlot()
21d988eaf1bf Added the capability to search in the recorded log of the log viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
138 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
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 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
141 """
5710
b5809b948010 Continued implementing the standalone shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
142 txt = self.__ui.findtextCombo.currentText()
b5809b948010 Continued implementing the standalone shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
143 if not txt and not self.isVisible():
b5809b948010 Continued implementing the standalone shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
144 self.showFind()
b5809b948010 Continued implementing the standalone shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
145 return
b5809b948010 Continued implementing the standalone shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
146
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 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
148
21d988eaf1bf Added the capability to search in the recorded log of the log viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
149 # 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
150 # 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
151 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
152 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
153 self.findHistory.insert(0, txt)
5710
b5809b948010 Continued implementing the standalone shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
154 self.__ui.findtextCombo.clear()
b5809b948010 Continued implementing the standalone shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
155 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
156
3030
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3012
diff changeset
157 self.searchPrevious.emit(
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3012
diff changeset
158 txt,
5710
b5809b948010 Continued implementing the standalone shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
159 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
160 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
161 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
162 )
1823
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 @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
165 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
166 """
21d988eaf1bf Added the capability to search in the recorded log of the log viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
167 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
168
21d988eaf1bf Added the capability to search in the recorded log of the log viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
169 @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
170 """
21d988eaf1bf Added the capability to search in the recorded log of the log viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
171 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
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 __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
174 """
21d988eaf1bf Added the capability to search in the recorded log of the log viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
175 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
176
21d988eaf1bf Added the capability to search in the recorded log of the log viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
177 @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
178 """
5710
b5809b948010 Continued implementing the standalone shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
179 self.__ui.findPrevButton.setEnabled(enabled)
b5809b948010 Continued implementing the standalone shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
180 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
181
21d988eaf1bf Added the capability to search in the recorded log of the log viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
182 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
183 """
3012
d177226027e2 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2965
diff changeset
184 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
185 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
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 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
188 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
189 else:
21d988eaf1bf Added the capability to search in the recorded log of the log viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
190 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
191
21d988eaf1bf Added the capability to search in the recorded log of the log viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
192 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
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 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
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 @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
197 """
5710
b5809b948010 Continued implementing the standalone shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
198 self.__ui.findtextCombo.clear()
b5809b948010 Continued implementing the standalone shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
199 self.__ui.findtextCombo.addItems(self.findHistory)
b5809b948010 Continued implementing the standalone shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
200 self.__ui.findtextCombo.setEditText(txt)
b5809b948010 Continued implementing the standalone shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
201 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
202
21d988eaf1bf Added the capability to search in the recorded log of the log viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
203 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
204
21d988eaf1bf Added the capability to search in the recorded log of the log viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
205 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
206
f2fccb8c2ab4 Added the capability to search in the output of the terminal window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1823
diff changeset
207 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
208 """
f2fccb8c2ab4 Added the capability to search in the output of the terminal window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1823
diff changeset
209 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
210
f2fccb8c2ab4 Added the capability to search in the output of the terminal window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1823
diff changeset
211 @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
212 """
f2fccb8c2ab4 Added the capability to search in the output of the terminal window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1823
diff changeset
213 if found:
5710
b5809b948010 Continued implementing the standalone shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
214 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
215 else:
5710
b5809b948010 Continued implementing the standalone shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
216 txt = self.__ui.findtextCombo.currentText()
b5809b948010 Continued implementing the standalone shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
217 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
218 self.tr("'{0}' was not found.").format(txt))

eric ide

mercurial