mirror of
https://github.com/qgis/QGIS.git
synced 2025-04-15 00:04:00 -04:00
[pyqgis-console] adds more options to find text in the editor
This commit is contained in:
parent
2df1a20ccb
commit
acacf84845
@ -489,9 +489,22 @@ class PythonConsoleWidget(QWidget):
|
|||||||
self.findPrevButton.setIcon(QgsApplication.getThemeIcon("console/iconSearchPrevEditorConsole.png"))
|
self.findPrevButton.setIcon(QgsApplication.getThemeIcon("console/iconSearchPrevEditorConsole.png"))
|
||||||
self.findPrevButton.setIconSize(QSize(24, 24))
|
self.findPrevButton.setIconSize(QSize(24, 24))
|
||||||
self.findPrevButton.setAutoRaise(True)
|
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.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.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 -------------------------------
|
##------------ Add first Tab in Editor -------------------------------
|
||||||
|
|
||||||
@ -528,20 +541,20 @@ class PythonConsoleWidget(QWidget):
|
|||||||
self.lineEditFind.textChanged.connect(self._textFindChanged)
|
self.lineEditFind.textChanged.connect(self._textFindChanged)
|
||||||
|
|
||||||
def _findText(self):
|
def _findText(self):
|
||||||
self.tabEditorWidget.currentWidget().newEditor.findText()
|
self.tabEditorWidget.currentWidget().newEditor.findText(True)
|
||||||
|
|
||||||
def _findNext(self):
|
def _findNext(self):
|
||||||
self.tabEditorWidget.currentWidget().newEditor.findText()
|
self.tabEditorWidget.currentWidget().newEditor.findText(True)
|
||||||
|
|
||||||
def _findPrev(self):
|
def _findPrev(self):
|
||||||
self.tabEditorWidget.currentWidget().newEditor.findText(True)
|
self.tabEditorWidget.currentWidget().newEditor.findText(False)
|
||||||
self.tabEditorWidget.currentWidget().newEditor.findNext()
|
|
||||||
|
|
||||||
def _textFindChanged(self):
|
def _textFindChanged(self):
|
||||||
if not self.lineEditFind.text().isEmpty():
|
if not self.lineEditFind.text().isEmpty():
|
||||||
self.findNextButton.setEnabled(True)
|
self.findNextButton.setEnabled(True)
|
||||||
self.findPrevButton.setEnabled(True)
|
self.findPrevButton.setEnabled(True)
|
||||||
else:
|
else:
|
||||||
|
self.lineEditFind.setStyleSheet('')
|
||||||
self.findNextButton.setEnabled(False)
|
self.findNextButton.setEnabled(False)
|
||||||
self.findPrevButton.setEnabled(False)
|
self.findPrevButton.setEnabled(False)
|
||||||
|
|
||||||
|
@ -344,21 +344,32 @@ class Editor(QsciScintilla):
|
|||||||
pasteAction.setEnabled(True)
|
pasteAction.setEnabled(True)
|
||||||
action = menu.exec_(self.mapToGlobal(e.pos()))
|
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()
|
line, index = self.getCursorPosition()
|
||||||
text = self.parent.pc.lineEditFind.text()
|
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 not text.isEmpty():
|
||||||
if direction:
|
if not forward:
|
||||||
if not self.findFirst(text, 1, 0, line, index, forward=False):
|
line = lineFrom
|
||||||
msgText = True
|
index = indexFrom
|
||||||
else:
|
## findFirst(QString(), re bool, cs bool, wo bool, wrap, bool, forward=True)
|
||||||
if not self.findFirst(text, 1, 0, line, index):
|
## re = Regular Expression, cs = Case Sensitive, wo = Whole Word, wrap = Wrap Around
|
||||||
msgText = True
|
if not self.findFirst(text, re, cs, wo, wrap, forward, line, index):
|
||||||
if msgText:
|
notFound = True
|
||||||
|
if notFound:
|
||||||
|
styleError = 'QLineEdit {background-color: #d65253; \
|
||||||
|
color: #ffffff;}'
|
||||||
msgText = QCoreApplication.translate('PythonConsole',
|
msgText = QCoreApplication.translate('PythonConsole',
|
||||||
'<b>"%1"</b> was not found.').arg(text)
|
'<b>"%1"</b> was not found.').arg(text)
|
||||||
self.parent.pc.callWidgetMessageBarEditor(msgText, 0, True)
|
self.parent.pc.callWidgetMessageBarEditor(msgText, 0, True)
|
||||||
|
else:
|
||||||
|
styleError = ''
|
||||||
|
self.parent.pc.lineEditFind.setStyleSheet(styleError)
|
||||||
|
|
||||||
def objectListEditor(self):
|
def objectListEditor(self):
|
||||||
listObj = self.parent.pc.listClassMethod
|
listObj = self.parent.pc.listClassMethod
|
||||||
|
Loading…
x
Reference in New Issue
Block a user