8 """ |
8 """ |
9 |
9 |
10 from __future__ import unicode_literals # __IGNORE_WARNING__ |
10 from __future__ import unicode_literals # __IGNORE_WARNING__ |
11 |
11 |
12 from PyQt4.QtCore import Qt, pyqtSignal |
12 from PyQt4.QtCore import Qt, pyqtSignal |
13 from PyQt4.QtGui import QTextEdit, QBrush, QApplication, QMenu, QTextCursor, QWidget, \ |
13 from PyQt4.QtGui import QTextEdit, QBrush, QApplication, QMenu, QTextCursor, \ |
14 QHBoxLayout, QTextDocument |
14 QWidget, QHBoxLayout, QTextDocument |
15 |
15 |
16 from E5Gui.E5Application import e5App |
16 from E5Gui.E5Application import e5App |
17 |
17 |
18 import UI.PixmapCache |
18 import UI.PixmapCache |
19 import Preferences |
19 import Preferences |
43 self.__layout.addWidget(self.__logViewer) |
43 self.__layout.addWidget(self.__logViewer) |
44 self.__layout.addWidget(self.__searchWidget) |
44 self.__layout.addWidget(self.__searchWidget) |
45 |
45 |
46 self.__searchWidget.searchNext.connect(self.__logViewer.searchNext) |
46 self.__searchWidget.searchNext.connect(self.__logViewer.searchNext) |
47 self.__searchWidget.searchPrevious.connect(self.__logViewer.searchPrev) |
47 self.__searchWidget.searchPrevious.connect(self.__logViewer.searchPrev) |
48 self.__logViewer.searchStringFound.connect(self.__searchWidget.searchStringFound) |
48 self.__logViewer.searchStringFound.connect( |
|
49 self.__searchWidget.searchStringFound) |
49 |
50 |
50 def appendToStdout(self, txt): |
51 def appendToStdout(self, txt): |
51 """ |
52 """ |
52 Public slot to appand text to the "stdout" tab. |
53 Public slot to appand text to the "stdout" tab. |
53 |
54 |
80 |
81 |
81 class LogViewerEdit(QTextEdit): |
82 class LogViewerEdit(QTextEdit): |
82 """ |
83 """ |
83 Class providing a specialized text edit for displaying logging information. |
84 Class providing a specialized text edit for displaying logging information. |
84 |
85 |
85 @signal searchStringFound(found) emitted to indicate the search result (boolean) |
86 @signal searchStringFound(found) emitted to indicate the search result |
|
87 (boolean) |
86 """ |
88 """ |
87 searchStringFound = pyqtSignal(bool) |
89 searchStringFound = pyqtSignal(bool) |
88 |
90 |
89 def __init__(self, parent=None): |
91 def __init__(self, parent=None): |
90 """ |
92 """ |
114 self.setContextMenuPolicy(Qt.CustomContextMenu) |
116 self.setContextMenuPolicy(Qt.CustomContextMenu) |
115 self.customContextMenuRequested.connect(self.__handleShowContextMenu) |
117 self.customContextMenuRequested.connect(self.__handleShowContextMenu) |
116 |
118 |
117 self.cNormalFormat = self.currentCharFormat() |
119 self.cNormalFormat = self.currentCharFormat() |
118 self.cErrorFormat = self.currentCharFormat() |
120 self.cErrorFormat = self.currentCharFormat() |
119 self.cErrorFormat.setForeground(QBrush(Preferences.getUI("LogStdErrColour"))) |
121 self.cErrorFormat.setForeground( |
|
122 QBrush(Preferences.getUI("LogStdErrColour"))) |
120 |
123 |
121 def __handleShowContextMenu(self, coord): |
124 def __handleShowContextMenu(self, coord): |
122 """ |
125 """ |
123 Private slot to show the context menu. |
126 Private slot to show the context menu. |
124 |
127 |
164 |
167 |
165 def preferencesChanged(self): |
168 def preferencesChanged(self): |
166 """ |
169 """ |
167 Public slot to handle a change of the preferences. |
170 Public slot to handle a change of the preferences. |
168 """ |
171 """ |
169 self.cErrorFormat.setForeground(QBrush(Preferences.getUI("LogStdErrColour"))) |
172 self.cErrorFormat.setForeground( |
|
173 QBrush(Preferences.getUI("LogStdErrColour"))) |
170 |
174 |
171 def __configure(self): |
175 def __configure(self): |
172 """ |
176 """ |
173 Private method to open the configuration dialog. |
177 Private method to open the configuration dialog. |
174 """ |
178 """ |
182 self.__mainWindow.showFind(txt) |
186 self.__mainWindow.showFind(txt) |
183 |
187 |
184 def searchNext(self, txt, caseSensitive, wholeWord): |
188 def searchNext(self, txt, caseSensitive, wholeWord): |
185 """ |
189 """ |
186 Public method to search the next occurrence of the given text. |
190 Public method to search the next occurrence of the given text. |
|
191 |
|
192 @param txt text to search for (string) |
|
193 @param caseSensitive flag indicating case sensitivity (boolean) |
|
194 @param wholeWord flag indicating a search for the whole word (boolean) |
187 """ |
195 """ |
188 self.__lastSearch = (txt, caseSensitive, wholeWord) |
196 self.__lastSearch = (txt, caseSensitive, wholeWord) |
189 flags = QTextDocument.FindFlags() |
197 flags = QTextDocument.FindFlags() |
190 if caseSensitive: |
198 if caseSensitive: |
191 flags |= QTextDocument.FindCaseSensitively |
199 flags |= QTextDocument.FindCaseSensitively |
195 self.searchStringFound.emit(ok) |
203 self.searchStringFound.emit(ok) |
196 |
204 |
197 def searchPrev(self, txt, caseSensitive, wholeWord): |
205 def searchPrev(self, txt, caseSensitive, wholeWord): |
198 """ |
206 """ |
199 Public method to search the previous occurrence of the given text. |
207 Public method to search the previous occurrence of the given text. |
|
208 |
|
209 @param txt text to search for (string) |
|
210 @param caseSensitive flag indicating case sensitivity (boolean) |
|
211 @param wholeWord flag indicating a search for the whole word (boolean) |
200 """ |
212 """ |
201 self.__lastSearch = (txt, caseSensitive, wholeWord) |
213 self.__lastSearch = (txt, caseSensitive, wholeWord) |
202 flags = QTextDocument.FindFlags(QTextDocument.FindBackward) |
214 flags = QTextDocument.FindFlags(QTextDocument.FindBackward) |
203 if caseSensitive: |
215 if caseSensitive: |
204 flags |= QTextDocument.FindCaseSensitively |
216 flags |= QTextDocument.FindCaseSensitively |