|
1 # -*- coding: utf-8 -*- |
|
2 |
|
3 # Copyright (c) 2014 Detlev Offenbach <detlev@die-offenbachs.de> |
|
4 # |
|
5 |
|
6 """ |
|
7 Module implementing a class for showing an editor marker map. |
|
8 """ |
|
9 |
|
10 from PyQt4.QtGui import QColor |
|
11 |
|
12 from E5Gui.E5MapWidget import E5MapWidget |
|
13 |
|
14 |
|
15 class EditorMarkerMap(E5MapWidget): |
|
16 """ |
|
17 Class implementing a class for showing an editor marker map. |
|
18 """ |
|
19 def __init__(self, parent=None): |
|
20 """ |
|
21 Constructor |
|
22 |
|
23 @param parent reference to the parent widget (QWidget) |
|
24 """ |
|
25 super().__init__(parent) |
|
26 |
|
27 # initialize colors for various markers |
|
28 # TODO: make these colors configurable via Preferences |
|
29 self.__bookmarkColor = QColor("#f8c700") |
|
30 self.__errorColor = QColor("#dd0000") |
|
31 self.__warningColor = QColor("#606000") |
|
32 self.__breakpointColor = QColor("#f55c07") |
|
33 self.__taskColor = QColor("#2278f8") |
|
34 self.__coverageColor = QColor("#ad3636") |
|
35 self.__changeColor = QColor("#00b000") |
|
36 self.__currentLineMarker = QColor("#000000") |
|
37 |
|
38 def __drawIndicator(self, line, painter, color): |
|
39 """ |
|
40 Private method to draw an indicator. |
|
41 |
|
42 @param line line number (integer) |
|
43 @param painter reference to the painter (QPainter) |
|
44 @param color color to be used (QColor) |
|
45 """ |
|
46 position = self.value2Position(line) |
|
47 painter.setPen(color.darker(120)) |
|
48 painter.setBrush(color) |
|
49 painter.drawRect(self.generateIndicatorRect(position)) |
|
50 |
|
51 def _paintIt(self, painter): |
|
52 """ |
|
53 Protected method for painting the widget's indicators. |
|
54 |
|
55 @param painter reference to the painter object (QPainter) |
|
56 """ |
|
57 # draw indicators in reverse order of priority |
|
58 |
|
59 # 1. changes |
|
60 for line in self._master.getChangeLines(): |
|
61 self.__drawIndicator(line, painter, self.__changeColor) |
|
62 |
|
63 # 2. coverage |
|
64 for line in self._master.getCoverageLines(): |
|
65 self.__drawIndicator(line, painter, self.__coverageColor) |
|
66 |
|
67 # 3. tasks |
|
68 for line in self._master.getTaskLines(): |
|
69 self.__drawIndicator(line, painter, self.__taskColor) |
|
70 |
|
71 # 4. breakpoints |
|
72 for line in self._master.getBreakpointLines(): |
|
73 self.__drawIndicator(line, painter, self.__breakpointColor) |
|
74 |
|
75 # 5. bookmarks |
|
76 for line in self._master.getBookmarkLines(): |
|
77 self.__drawIndicator(line, painter, self.__bookmarkColor) |
|
78 |
|
79 # 6. warnings |
|
80 for line in self._master.getWarningLines(): |
|
81 self.__drawIndicator(line, painter, self.__warningColor) |
|
82 |
|
83 # 7. errors |
|
84 for line in self._master.getSyntaxErrorLines(): |
|
85 self.__drawIndicator(line, painter, self.__errorColor) |
|
86 |
|
87 # 8. current line |
|
88 self.__drawIndicator(self._master.getCursorPosition()[0], painter, |
|
89 self.__currentLineMarker) |