UI/LogView.py

Sun, 02 Aug 2015 12:02:44 +0200

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Sun, 02 Aug 2015 12:02:44 +0200
branch
6_0_x
changeset 4346
c8cb0b0bfe24
parent 4022
f5f42921717e
child 4083
4418377391bc
permissions
-rw-r--r--

Prepared new release.

0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1 # -*- coding: utf-8 -*-
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
2
4022
f5f42921717e Updated copyright for 2015.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3656
diff changeset
3 # Copyright (c) 2006 - 2015 Detlev Offenbach <detlev@die-offenbachs.de>
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
4 #
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
5
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
6 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
7 Module implementing the log viewer widget and the log widget.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
8 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
9
3145
a9de05d4a22f # __IGNORE_WARNING__ added/ removed.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3057
diff changeset
10 from __future__ import unicode_literals
2525
8b507a9a2d40 Script changes: Future import added, super calls modified and unicode behavior for str.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 2409
diff changeset
11
3656
441956d8fce5 Started porting eric5 to PyQt5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3591
diff changeset
12 from PyQt5.QtCore import Qt, pyqtSignal
441956d8fce5 Started porting eric5 to PyQt5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3591
diff changeset
13 from PyQt5.QtGui import QBrush, QTextCursor, QTextDocument
441956d8fce5 Started porting eric5 to PyQt5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3591
diff changeset
14 from PyQt5.QtWidgets import QTextEdit, QApplication, QMenu, QWidget, \
441956d8fce5 Started porting eric5 to PyQt5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3591
diff changeset
15 QHBoxLayout
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
16
55
b5c84934de9c Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 53
diff changeset
17 from E5Gui.E5Application import e5App
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
18
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
19 import UI.PixmapCache
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
20 import Preferences
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
21
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 791
diff changeset
22
1823
21d988eaf1bf Added the capability to search in the recorded log of the log viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
23 class LogViewer(QWidget):
21d988eaf1bf Added the capability to search in the recorded log of the log viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
24 """
21d988eaf1bf Added the capability to search in the recorded log of the log viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
25 Class implementing the containing widget for the log viewer.
21d988eaf1bf Added the capability to search in the recorded log of the log viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
26 """
21d988eaf1bf Added the capability to search in the recorded log of the log viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
27 def __init__(self, parent=None):
21d988eaf1bf Added the capability to search in the recorded log of the log viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
28 """
21d988eaf1bf Added the capability to search in the recorded log of the log viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
29 Constructor
21d988eaf1bf Added the capability to search in the recorded log of the log viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
30
21d988eaf1bf Added the capability to search in the recorded log of the log viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
31 @param parent reference to the parent widget (QWidget)
21d988eaf1bf Added the capability to search in the recorded log of the log viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
32 """
2525
8b507a9a2d40 Script changes: Future import added, super calls modified and unicode behavior for str.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 2409
diff changeset
33 super(LogViewer, self).__init__(parent)
1823
21d988eaf1bf Added the capability to search in the recorded log of the log viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
34
21d988eaf1bf Added the capability to search in the recorded log of the log viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
35 self.setWindowIcon(UI.PixmapCache.getIcon("eric.png"))
21d988eaf1bf Added the capability to search in the recorded log of the log viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
36
21d988eaf1bf Added the capability to search in the recorded log of the log viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
37 self.__logViewer = LogViewerEdit(self)
2409
df3820f08247 Continued implementing the delayed import.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
38 from .SearchWidget import SearchWidget
1823
21d988eaf1bf Added the capability to search in the recorded log of the log viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
39 self.__searchWidget = SearchWidget(self.__logViewer, self)
21d988eaf1bf Added the capability to search in the recorded log of the log viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
40 self.__searchWidget.hide()
21d988eaf1bf Added the capability to search in the recorded log of the log viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
41
21d988eaf1bf Added the capability to search in the recorded log of the log viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
42 self.__layout = QHBoxLayout(self)
1829
fa72a573967f Some fine adjustments to the new search function of the log viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1823
diff changeset
43 self.__layout.setContentsMargins(1, 1, 1, 1)
1823
21d988eaf1bf Added the capability to search in the recorded log of the log viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
44 self.__layout.addWidget(self.__logViewer)
21d988eaf1bf Added the capability to search in the recorded log of the log viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
45 self.__layout.addWidget(self.__searchWidget)
21d988eaf1bf Added the capability to search in the recorded log of the log viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
46
21d988eaf1bf Added the capability to search in the recorded log of the log viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
47 self.__searchWidget.searchNext.connect(self.__logViewer.searchNext)
21d988eaf1bf Added the capability to search in the recorded log of the log viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
48 self.__searchWidget.searchPrevious.connect(self.__logViewer.searchPrev)
3012
d177226027e2 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2965
diff changeset
49 self.__logViewer.searchStringFound.connect(
d177226027e2 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2965
diff changeset
50 self.__searchWidget.searchStringFound)
1823
21d988eaf1bf Added the capability to search in the recorded log of the log viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
51
21d988eaf1bf Added the capability to search in the recorded log of the log viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
52 def appendToStdout(self, txt):
21d988eaf1bf Added the capability to search in the recorded log of the log viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
53 """
21d988eaf1bf Added the capability to search in the recorded log of the log viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
54 Public slot to appand text to the "stdout" tab.
21d988eaf1bf Added the capability to search in the recorded log of the log viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
55
21d988eaf1bf Added the capability to search in the recorded log of the log viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
56 @param txt text to be appended (string)
21d988eaf1bf Added the capability to search in the recorded log of the log viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
57 """
21d988eaf1bf Added the capability to search in the recorded log of the log viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
58 self.__logViewer.appendToStdout(txt)
21d988eaf1bf Added the capability to search in the recorded log of the log viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
59
21d988eaf1bf Added the capability to search in the recorded log of the log viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
60 def appendToStderr(self, txt):
21d988eaf1bf Added the capability to search in the recorded log of the log viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
61 """
21d988eaf1bf Added the capability to search in the recorded log of the log viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
62 Public slot to appand text to the "stderr" tab.
21d988eaf1bf Added the capability to search in the recorded log of the log viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
63
21d988eaf1bf Added the capability to search in the recorded log of the log viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
64 @param txt text to be appended (string)
21d988eaf1bf Added the capability to search in the recorded log of the log viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
65 """
21d988eaf1bf Added the capability to search in the recorded log of the log viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
66 self.__logViewer.appendToStderr(txt)
21d988eaf1bf Added the capability to search in the recorded log of the log viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
67
21d988eaf1bf Added the capability to search in the recorded log of the log viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
68 def preferencesChanged(self):
21d988eaf1bf Added the capability to search in the recorded log of the log viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
69 """
21d988eaf1bf Added the capability to search in the recorded log of the log viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
70 Public slot to handle a change of the preferences.
21d988eaf1bf Added the capability to search in the recorded log of the log viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
71 """
21d988eaf1bf Added the capability to search in the recorded log of the log viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
72 self.__logViewer.preferencesChanged()
21d988eaf1bf Added the capability to search in the recorded log of the log viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
73
21d988eaf1bf Added the capability to search in the recorded log of the log viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
74 def showFind(self, txt=""):
21d988eaf1bf Added the capability to search in the recorded log of the log viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
75 """
21d988eaf1bf Added the capability to search in the recorded log of the log viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
76 Public method to display the search widget.
21d988eaf1bf Added the capability to search in the recorded log of the log viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
77
21d988eaf1bf Added the capability to search in the recorded log of the log viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
78 @param txt text to be shown in the combo (string)
21d988eaf1bf Added the capability to search in the recorded log of the log viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
79 """
1830
f2fccb8c2ab4 Added the capability to search in the output of the terminal window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1829
diff changeset
80 self.__searchWidget.showFind(txt)
1823
21d988eaf1bf Added the capability to search in the recorded log of the log viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
81
21d988eaf1bf Added the capability to search in the recorded log of the log viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
82
21d988eaf1bf Added the capability to search in the recorded log of the log viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
83 class LogViewerEdit(QTextEdit):
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
84 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
85 Class providing a specialized text edit for displaying logging information.
1830
f2fccb8c2ab4 Added the capability to search in the output of the terminal window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1829
diff changeset
86
3012
d177226027e2 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2965
diff changeset
87 @signal searchStringFound(found) emitted to indicate the search result
d177226027e2 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2965
diff changeset
88 (boolean)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
89 """
1830
f2fccb8c2ab4 Added the capability to search in the output of the terminal window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1829
diff changeset
90 searchStringFound = pyqtSignal(bool)
f2fccb8c2ab4 Added the capability to search in the output of the terminal window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1829
diff changeset
91
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 791
diff changeset
92 def __init__(self, parent=None):
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
93 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
94 Constructor
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
95
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
96 @param parent reference to the parent widget (QWidget)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
97 """
2525
8b507a9a2d40 Script changes: Future import added, super calls modified and unicode behavior for str.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 2409
diff changeset
98 super(LogViewerEdit, self).__init__(parent)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
99 self.setAcceptRichText(False)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
100 self.setLineWrapMode(QTextEdit.NoWrap)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
101 self.setReadOnly(True)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
102
1823
21d988eaf1bf Added the capability to search in the recorded log of the log viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
103 self.__mainWindow = parent
21d988eaf1bf Added the capability to search in the recorded log of the log viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
104 self.__lastSearch = ()
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
105
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
106 # create the context menu
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
107 self.__menu = QMenu(self)
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3160
diff changeset
108 self.__menu.addAction(self.tr('Clear'), self.clear)
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3160
diff changeset
109 self.__menu.addAction(self.tr('Copy'), self.copy)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
110 self.__menu.addSeparator()
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3160
diff changeset
111 self.__menu.addAction(self.tr('Find'), self.__find)
1823
21d988eaf1bf Added the capability to search in the recorded log of the log viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
112 self.__menu.addSeparator()
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3160
diff changeset
113 self.__menu.addAction(self.tr('Select All'), self.selectAll)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
114 self.__menu.addSeparator()
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3160
diff changeset
115 self.__menu.addAction(self.tr("Configure..."), self.__configure)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
116
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
117 self.setContextMenuPolicy(Qt.CustomContextMenu)
458
1695e7a2db54 Continued porting signal/slot usage to the new API.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 97
diff changeset
118 self.customContextMenuRequested.connect(self.__handleShowContextMenu)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
119
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
120 self.cNormalFormat = self.currentCharFormat()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
121 self.cErrorFormat = self.currentCharFormat()
3012
d177226027e2 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2965
diff changeset
122 self.cErrorFormat.setForeground(
d177226027e2 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2965
diff changeset
123 QBrush(Preferences.getUI("LogStdErrColour")))
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
124
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
125 def __handleShowContextMenu(self, coord):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
126 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
127 Private slot to show the context menu.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
128
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
129 @param coord the position of the mouse pointer (QPoint)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
130 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
131 coord = self.mapToGlobal(coord)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
132 self.__menu.popup(coord)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
133
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 791
diff changeset
134 def __appendText(self, txt, error=False):
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
135 """
3591
2f2a4a76dd22 Corrected a bunch of source docu issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3484
diff changeset
136 Private method to append text to the end.
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
137
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
138 @param txt text to insert (string)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
139 @param error flag indicating to insert error text (boolean)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
140 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
141 tc = self.textCursor()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
142 tc.movePosition(QTextCursor.End)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
143 self.setTextCursor(tc)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
144 if error:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
145 self.setCurrentCharFormat(self.cErrorFormat)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
146 else:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
147 self.setCurrentCharFormat(self.cNormalFormat)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
148 self.insertPlainText(txt)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
149 self.ensureCursorVisible()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
150
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
151 def appendToStdout(self, txt):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
152 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
153 Public slot to appand text to the "stdout" tab.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
154
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
155 @param txt text to be appended (string)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
156 """
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 791
diff changeset
157 self.__appendText(txt, error=False)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
158 QApplication.processEvents()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
159
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
160 def appendToStderr(self, txt):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
161 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
162 Public slot to appand text to the "stderr" tab.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
163
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
164 @param txt text to be appended (string)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
165 """
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 791
diff changeset
166 self.__appendText(txt, error=True)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
167 QApplication.processEvents()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
168
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
169 def preferencesChanged(self):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
170 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
171 Public slot to handle a change of the preferences.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
172 """
3012
d177226027e2 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2965
diff changeset
173 self.cErrorFormat.setForeground(
d177226027e2 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2965
diff changeset
174 QBrush(Preferences.getUI("LogStdErrColour")))
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
175
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
176 def __configure(self):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
177 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
178 Private method to open the configuration dialog.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
179 """
97
c4086afea02b Finished cleaning up the code supported by py3flakes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 55
diff changeset
180 e5App().getObject("UserInterface").showPreferences("interfacePage")
1823
21d988eaf1bf Added the capability to search in the recorded log of the log viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
181
21d988eaf1bf Added the capability to search in the recorded log of the log viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
182 def __find(self):
21d988eaf1bf Added the capability to search in the recorded log of the log viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
183 """
21d988eaf1bf Added the capability to search in the recorded log of the log viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
184 Private slot to show the find widget.
21d988eaf1bf Added the capability to search in the recorded log of the log viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
185 """
21d988eaf1bf Added the capability to search in the recorded log of the log viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
186 txt = self.textCursor().selectedText()
21d988eaf1bf Added the capability to search in the recorded log of the log viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
187 self.__mainWindow.showFind(txt)
21d988eaf1bf Added the capability to search in the recorded log of the log viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
188
21d988eaf1bf Added the capability to search in the recorded log of the log viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
189 def searchNext(self, txt, caseSensitive, wholeWord):
21d988eaf1bf Added the capability to search in the recorded log of the log viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
190 """
21d988eaf1bf Added the capability to search in the recorded log of the log viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
191 Public method to search the next occurrence of the given text.
2965
d133c7edd88a Continued correcting doc strings by using the new doc string checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2409
diff changeset
192
d133c7edd88a Continued correcting doc strings by using the new doc string checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2409
diff changeset
193 @param txt text to search for (string)
d133c7edd88a Continued correcting doc strings by using the new doc string checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2409
diff changeset
194 @param caseSensitive flag indicating case sensitivity (boolean)
d133c7edd88a Continued correcting doc strings by using the new doc string checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2409
diff changeset
195 @param wholeWord flag indicating a search for the whole word (boolean)
1823
21d988eaf1bf Added the capability to search in the recorded log of the log viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
196 """
21d988eaf1bf Added the capability to search in the recorded log of the log viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
197 self.__lastSearch = (txt, caseSensitive, wholeWord)
21d988eaf1bf Added the capability to search in the recorded log of the log viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
198 flags = QTextDocument.FindFlags()
21d988eaf1bf Added the capability to search in the recorded log of the log viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
199 if caseSensitive:
21d988eaf1bf Added the capability to search in the recorded log of the log viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
200 flags |= QTextDocument.FindCaseSensitively
21d988eaf1bf Added the capability to search in the recorded log of the log viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
201 if wholeWord:
21d988eaf1bf Added the capability to search in the recorded log of the log viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
202 flags |= QTextDocument.FindWholeWords
1830
f2fccb8c2ab4 Added the capability to search in the output of the terminal window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1829
diff changeset
203 ok = self.find(txt, flags)
f2fccb8c2ab4 Added the capability to search in the output of the terminal window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1829
diff changeset
204 self.searchStringFound.emit(ok)
1823
21d988eaf1bf Added the capability to search in the recorded log of the log viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
205
21d988eaf1bf Added the capability to search in the recorded log of the log viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
206 def searchPrev(self, txt, caseSensitive, wholeWord):
21d988eaf1bf Added the capability to search in the recorded log of the log viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
207 """
21d988eaf1bf Added the capability to search in the recorded log of the log viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
208 Public method to search the previous occurrence of the given text.
2965
d133c7edd88a Continued correcting doc strings by using the new doc string checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2409
diff changeset
209
d133c7edd88a Continued correcting doc strings by using the new doc string checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2409
diff changeset
210 @param txt text to search for (string)
d133c7edd88a Continued correcting doc strings by using the new doc string checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2409
diff changeset
211 @param caseSensitive flag indicating case sensitivity (boolean)
d133c7edd88a Continued correcting doc strings by using the new doc string checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2409
diff changeset
212 @param wholeWord flag indicating a search for the whole word (boolean)
1823
21d988eaf1bf Added the capability to search in the recorded log of the log viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
213 """
21d988eaf1bf Added the capability to search in the recorded log of the log viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
214 self.__lastSearch = (txt, caseSensitive, wholeWord)
21d988eaf1bf Added the capability to search in the recorded log of the log viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
215 flags = QTextDocument.FindFlags(QTextDocument.FindBackward)
21d988eaf1bf Added the capability to search in the recorded log of the log viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
216 if caseSensitive:
21d988eaf1bf Added the capability to search in the recorded log of the log viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
217 flags |= QTextDocument.FindCaseSensitively
21d988eaf1bf Added the capability to search in the recorded log of the log viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
218 if wholeWord:
21d988eaf1bf Added the capability to search in the recorded log of the log viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
219 flags |= QTextDocument.FindWholeWords
1830
f2fccb8c2ab4 Added the capability to search in the output of the terminal window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1829
diff changeset
220 ok = self.find(txt, flags)
f2fccb8c2ab4 Added the capability to search in the output of the terminal window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1829
diff changeset
221 self.searchStringFound.emit(ok)
1823
21d988eaf1bf Added the capability to search in the recorded log of the log viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
222
21d988eaf1bf Added the capability to search in the recorded log of the log viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
223 def keyPressEvent(self, evt):
21d988eaf1bf Added the capability to search in the recorded log of the log viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
224 """
21d988eaf1bf Added the capability to search in the recorded log of the log viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
225 Protected method handling key press events.
21d988eaf1bf Added the capability to search in the recorded log of the log viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
226
21d988eaf1bf Added the capability to search in the recorded log of the log viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
227 @param evt key press event (QKeyEvent)
21d988eaf1bf Added the capability to search in the recorded log of the log viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
228 """
21d988eaf1bf Added the capability to search in the recorded log of the log viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
229 if evt.modifiers() == Qt.ControlModifier:
21d988eaf1bf Added the capability to search in the recorded log of the log viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
230 if evt.key() == Qt.Key_F:
21d988eaf1bf Added the capability to search in the recorded log of the log viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
231 self.__find()
21d988eaf1bf Added the capability to search in the recorded log of the log viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
232 evt.accept()
21d988eaf1bf Added the capability to search in the recorded log of the log viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
233 return
21d988eaf1bf Added the capability to search in the recorded log of the log viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
234 elif evt.key() == Qt.Key_C:
21d988eaf1bf Added the capability to search in the recorded log of the log viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
235 self.copy()
21d988eaf1bf Added the capability to search in the recorded log of the log viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
236 evt.accept()
21d988eaf1bf Added the capability to search in the recorded log of the log viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
237 return
21d988eaf1bf Added the capability to search in the recorded log of the log viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
238 elif evt.key() == Qt.Key_A:
21d988eaf1bf Added the capability to search in the recorded log of the log viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
239 self.selectAll()
21d988eaf1bf Added the capability to search in the recorded log of the log viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
240 evt.accept()
21d988eaf1bf Added the capability to search in the recorded log of the log viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
241 return
21d988eaf1bf Added the capability to search in the recorded log of the log viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
242 elif evt.modifiers() == Qt.NoModifier:
21d988eaf1bf Added the capability to search in the recorded log of the log viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
243 if evt.key() == Qt.Key_F3 and self.__lastSearch:
21d988eaf1bf Added the capability to search in the recorded log of the log viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
244 self.searchNext(*self.__lastSearch)
21d988eaf1bf Added the capability to search in the recorded log of the log viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
245 evt.accept()
21d988eaf1bf Added the capability to search in the recorded log of the log viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
246 return
21d988eaf1bf Added the capability to search in the recorded log of the log viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
247 elif evt.modifiers() == Qt.ShiftModifier and self.__lastSearch:
21d988eaf1bf Added the capability to search in the recorded log of the log viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
248 if evt.key() == Qt.Key_F3 and self.__lastSearch:
21d988eaf1bf Added the capability to search in the recorded log of the log viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
249 self.searchPrev(*self.__lastSearch)
21d988eaf1bf Added the capability to search in the recorded log of the log viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
250 evt.accept()
21d988eaf1bf Added the capability to search in the recorded log of the log viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
251 return

eric ide

mercurial