UI/SearchWidget.py

changeset 6573
ccac2d1f6858
parent 6048
82ad8ec9548c
child 6645
ad476851d7e0
equal deleted inserted replaced
6572:dd7ed346b052 6573:ccac2d1f6858
17 17
18 class SearchWidget(QWidget): 18 class SearchWidget(QWidget):
19 """ 19 """
20 Class implementing the search box for the shell, terminal and log viewer. 20 Class implementing the search box for the shell, terminal and log viewer.
21 21
22 @signal searchNext(text, caseSensitive, wholeWord) emitted when the user 22 @signal searchNext(text, caseSensitive, wholeWord, regexp) emitted when the
23 pressed the next button (string, boolean, boolean) 23 user pressed the next button (string, boolean, boolean)
24 @signal searchPrevious(text, caseSensitive, wholeWord) emitted when the 24 @signal searchPrevious(text, caseSensitive, wholeWord, regexp) emitted when
25 user pressed the previous button (string, boolean, boolean) 25 the user pressed the previous button (string, boolean, boolean)
26 """ 26 """
27 searchNext = pyqtSignal(str, bool, bool) 27 searchNext = pyqtSignal(str, bool, bool, bool)
28 searchPrevious = pyqtSignal(str, bool, bool) 28 searchPrevious = pyqtSignal(str, bool, bool, bool)
29 29
30 def __init__(self, mainWindow, parent=None, spacer=True, showLine=False): 30 def __init__(self, mainWindow, parent=None, spacer=True, showLine=False,
31 hideRegExp=False):
31 """ 32 """
32 Constructor 33 Constructor
33 34
34 @param mainWindow reference to the main window (QWidget) 35 @param mainWindow reference to the main window
35 @param parent reference to the parent widget (QWidget) 36 @type QWidget
37 @param parent reference to the parent widget
38 @type QWidget
36 @param spacer flag indicating to add a vertical spacer to the 39 @param spacer flag indicating to add a vertical spacer to the
37 main layout (boolean) 40 main layout
38 @param showLine flag indicating to show all widget in one row (boolean) 41 @type bool
42 @param showLine flag indicating to show all widget in one row
43 @type bool
44 @param hideRegExp flag indicating to hide the Regexp checkbox
45 @type bool
39 """ 46 """
40 super(SearchWidget, self).__init__(parent) 47 super(SearchWidget, self).__init__(parent)
41 48
42 if showLine: 49 if showLine:
43 from .Ui_SearchWidgetLine import Ui_SearchWidgetLine 50 from .Ui_SearchWidgetLine import Ui_SearchWidgetLine
44 self.__ui = Ui_SearchWidgetLine() 51 self.__ui = Ui_SearchWidgetLine()
45 else: 52 else:
46 from .Ui_SearchWidget import Ui_SearchWidget 53 from .Ui_SearchWidget import Ui_SearchWidget
47 self.__ui = Ui_SearchWidget() 54 self.__ui = Ui_SearchWidget()
48 self.__ui.setupUi(self) 55 self.__ui.setupUi(self)
56
57 if hideRegExp:
58 self.__ui.regexpCheckBox.setChecked(False)
59 self.__ui.regexpCheckBox.hide()
60
49 if not showLine: 61 if not showLine:
50 if spacer: 62 if spacer:
51 spacerItem = QSpacerItem( 63 spacerItem = QSpacerItem(
52 20, 1, QSizePolicy.Minimum, QSizePolicy.Expanding) 64 20, 1, QSizePolicy.Minimum, QSizePolicy.Expanding)
53 self.__ui.verticalLayout.addItem(spacerItem) 65 self.__ui.verticalLayout.addItem(spacerItem)
116 self.__ui.findtextCombo.addItems(self.findHistory) 128 self.__ui.findtextCombo.addItems(self.findHistory)
117 129
118 self.searchNext.emit( 130 self.searchNext.emit(
119 txt, 131 txt,
120 self.__ui.caseCheckBox.isChecked(), 132 self.__ui.caseCheckBox.isChecked(),
121 self.__ui.wordCheckBox.isChecked()) 133 self.__ui.wordCheckBox.isChecked(),
134 self.__ui.regexpCheckBox.isChecked(),
135 )
122 136
123 @pyqtSlot() 137 @pyqtSlot()
124 def on_findPrevButton_clicked(self): 138 def on_findPrevButton_clicked(self):
125 """ 139 """
126 Private slot to find the previous occurrence. 140 Private slot to find the previous occurrence.
141 self.__ui.findtextCombo.addItems(self.findHistory) 155 self.__ui.findtextCombo.addItems(self.findHistory)
142 156
143 self.searchPrevious.emit( 157 self.searchPrevious.emit(
144 txt, 158 txt,
145 self.__ui.caseCheckBox.isChecked(), 159 self.__ui.caseCheckBox.isChecked(),
146 self.__ui.wordCheckBox.isChecked()) 160 self.__ui.wordCheckBox.isChecked(),
161 self.__ui.regexpCheckBox.isChecked(),
162 )
147 163
148 @pyqtSlot(str) 164 @pyqtSlot(str)
149 def on_findtextCombo_editTextChanged(self, txt): 165 def on_findtextCombo_editTextChanged(self, txt):
150 """ 166 """
151 Private slot to enable/disable the find buttons. 167 Private slot to enable/disable the find buttons.

eric ide

mercurial