--- a/UI/LogView.py Thu Nov 01 15:43:03 2018 +0100 +++ b/UI/LogView.py Thu Nov 01 18:46:44 2018 +0100 @@ -9,13 +9,15 @@ from __future__ import unicode_literals -from PyQt5.QtCore import Qt, pyqtSignal +from PyQt5.QtCore import pyqtSignal, Qt, QRegExp from PyQt5.QtGui import QBrush, QTextCursor, QTextDocument from PyQt5.QtWidgets import QTextEdit, QApplication, QMenu, QWidget, \ QHBoxLayout, QSizePolicy from E5Gui.E5Application import e5App +from Globals import qVersionTuple + import UI.PixmapCache import Preferences import Utilities @@ -40,9 +42,10 @@ self.__logViewer = LogViewerEdit(self) from .SearchWidget import SearchWidget - self.__searchWidget = SearchWidget(self.__logViewer, self) - self.__searchWidget.setSizePolicy(QSizePolicy.Fixed, - QSizePolicy.Preferred) + self.__searchWidget = SearchWidget( + self.__logViewer, self, hideRegExp=qVersionTuple() < (5, 3, 0)) + self.__searchWidget.setSizePolicy( + QSizePolicy.Fixed, QSizePolicy.Preferred) self.__searchWidget.hide() self.__layout = QHBoxLayout(self) @@ -236,38 +239,66 @@ txt = self.textCursor().selectedText() self.__mainWindow.showFind(txt) - def searchNext(self, txt, caseSensitive, wholeWord): + def searchNext(self, txt, caseSensitive, wholeWord, regexp): """ Public method to search the next occurrence of the given text. - @param txt text to search for (string) - @param caseSensitive flag indicating case sensitivity (boolean) - @param wholeWord flag indicating a search for the whole word (boolean) + @param txt text to search for + @type str + @param caseSensitive flag indicating to perform a case sensitive + search + @type bool + @param wholeWord flag indicating to search for whole words + only + @type bool + @param regexp flag indicating a regular expression search + @type bool """ - self.__lastSearch = (txt, caseSensitive, wholeWord) + self.__lastSearch = (txt, caseSensitive, wholeWord, regexp) flags = QTextDocument.FindFlags() if caseSensitive: flags |= QTextDocument.FindCaseSensitively if wholeWord: flags |= QTextDocument.FindWholeWords - ok = self.find(txt, flags) + if regexp: + ok = self.find(QRegExp( + txt, + Qt.CaseSensitive if caseSensitive else Qt.CaseInsensitive), + flags + ) + else: + ok = self.find(txt, flags) self.searchStringFound.emit(ok) - def searchPrev(self, txt, caseSensitive, wholeWord): + def searchPrev(self, txt, caseSensitive, wholeWord, regexp): """ Public method to search the previous occurrence of the given text. - @param txt text to search for (string) - @param caseSensitive flag indicating case sensitivity (boolean) - @param wholeWord flag indicating a search for the whole word (boolean) + @param txt text to search for + @type str + @param caseSensitive flag indicating to perform a case sensitive + search + @type bool + @param wholeWord flag indicating to search for whole words + only + @type bool + @param regexp flag indicating a regular expression search + @type bool """ - self.__lastSearch = (txt, caseSensitive, wholeWord) + self.__lastSearch = (txt, caseSensitive, wholeWord, regexp) flags = QTextDocument.FindFlags(QTextDocument.FindBackward) if caseSensitive: flags |= QTextDocument.FindCaseSensitively if wholeWord: flags |= QTextDocument.FindWholeWords - ok = self.find(txt, flags) + if regexp: + ok = self.find(QRegExp( + txt, + Qt.CaseSensitive if caseSensitive else Qt.CaseInsensitive), + flags + ) + else: + ok = self.find(txt, flags) self.searchStringFound.emit(ok) def keyPressEvent(self, evt):