diff --git a/python/console/console.py b/python/console/console.py index f50965fc8d3..8ba199294a3 100644 --- a/python/console/console.py +++ b/python/console/console.py @@ -489,9 +489,22 @@ class PythonConsoleWidget(QWidget): self.findPrevButton.setIcon(QgsApplication.getThemeIcon("console/iconSearchPrevEditorConsole.png")) self.findPrevButton.setIconSize(QSize(24, 24)) self.findPrevButton.setAutoRaise(True) + self.caseSensitive = QCheckBox() + caseSensTr = QCoreApplication.translate("PythonConsole", "Case Sensitive") + self.caseSensitive.setText(caseSensTr) + self.wholeWord = QCheckBox() + wholeWordTr = QCoreApplication.translate("PythonConsole", "Whole Word") + self.wholeWord.setText(wholeWordTr) + self.wrapAround = QCheckBox() + self.wrapAround.setChecked(True) + wrapAroundTr = QCoreApplication.translate("PythonConsole", "Wrap Around") + self.wrapAround.setText(wrapAroundTr) self.layoutFind.addWidget(self.lineEditFind, 0, 1, 1, 1) - self.layoutFind.addWidget(self.findNextButton, 0, 3, 1, 1) self.layoutFind.addWidget(self.findPrevButton, 0, 2, 1, 1) + self.layoutFind.addWidget(self.findNextButton, 0, 3, 1, 1) + self.layoutFind.addWidget(self.caseSensitive, 0, 4, 1, 1) + self.layoutFind.addWidget(self.wholeWord, 0, 5, 1, 1) + self.layoutFind.addWidget(self.wrapAround, 0, 6, 1, 1) ##------------ Add first Tab in Editor ------------------------------- @@ -528,20 +541,20 @@ class PythonConsoleWidget(QWidget): self.lineEditFind.textChanged.connect(self._textFindChanged) def _findText(self): - self.tabEditorWidget.currentWidget().newEditor.findText() + self.tabEditorWidget.currentWidget().newEditor.findText(True) def _findNext(self): - self.tabEditorWidget.currentWidget().newEditor.findText() + self.tabEditorWidget.currentWidget().newEditor.findText(True) def _findPrev(self): - self.tabEditorWidget.currentWidget().newEditor.findText(True) - self.tabEditorWidget.currentWidget().newEditor.findNext() + self.tabEditorWidget.currentWidget().newEditor.findText(False) def _textFindChanged(self): if not self.lineEditFind.text().isEmpty(): self.findNextButton.setEnabled(True) self.findPrevButton.setEnabled(True) else: + self.lineEditFind.setStyleSheet('') self.findNextButton.setEnabled(False) self.findPrevButton.setEnabled(False) diff --git a/python/console/console_editor.py b/python/console/console_editor.py index cdf79cb81c2..0fa1461fdb9 100644 --- a/python/console/console_editor.py +++ b/python/console/console_editor.py @@ -344,21 +344,32 @@ class Editor(QsciScintilla): pasteAction.setEnabled(True) action = menu.exec_(self.mapToGlobal(e.pos())) - def findText(self, direction=False): + def findText(self, forward): + lineFrom, indexFrom, lineTo, indexTo = self.getSelection() line, index = self.getCursorPosition() text = self.parent.pc.lineEditFind.text() - msgText = False + re = False + wrap = self.parent.pc.wrapAround.isChecked() + cs = self.parent.pc.caseSensitive.isChecked() + wo = self.parent.pc.wholeWord.isChecked() + notFound = False if not text.isEmpty(): - if direction: - if not self.findFirst(text, 1, 0, line, index, forward=False): - msgText = True - else: - if not self.findFirst(text, 1, 0, line, index): - msgText = True - if msgText: + if not forward: + line = lineFrom + index = indexFrom + ## findFirst(QString(), re bool, cs bool, wo bool, wrap, bool, forward=True) + ## re = Regular Expression, cs = Case Sensitive, wo = Whole Word, wrap = Wrap Around + if not self.findFirst(text, re, cs, wo, wrap, forward, line, index): + notFound = True + if notFound: + styleError = 'QLineEdit {background-color: #d65253; \ + color: #ffffff;}' msgText = QCoreApplication.translate('PythonConsole', '"%1" was not found.').arg(text) self.parent.pc.callWidgetMessageBarEditor(msgText, 0, True) + else: + styleError = '' + self.parent.pc.lineEditFind.setStyleSheet(styleError) def objectListEditor(self): listObj = self.parent.pc.listClassMethod