Sat, 23 Dec 2023 15:48:12 +0100
Updated copyright for 2024.
3327
1338767b5315
Started implementing support for a marker map in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1 | # -*- coding: utf-8 -*- |
1338767b5315
Started implementing support for a marker map in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
2 | |
10439
21c28b0f9e41
Updated copyright for 2024.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10423
diff
changeset
|
3 | # Copyright (c) 2014 - 2024 Detlev Offenbach <detlev@die-offenbachs.de> |
3327
1338767b5315
Started implementing support for a marker map in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
4 | # |
1338767b5315
Started implementing support for a marker map in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
5 | |
1338767b5315
Started implementing support for a marker map in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
6 | """ |
1338767b5315
Started implementing support for a marker map in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
7 | Module implementing a base class for showing a document map. |
1338767b5315
Started implementing support for a marker map in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
8 | """ |
1338767b5315
Started implementing support for a marker map in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
9 | |
9473
3f23dbf37dbe
Resorted the import statements using isort.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9221
diff
changeset
|
10 | from PyQt6.QtCore import QCoreApplication, QRect, QSize, Qt |
3f23dbf37dbe
Resorted the import statements using isort.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9221
diff
changeset
|
11 | from PyQt6.QtGui import QBrush, QColor, QPainter |
3f23dbf37dbe
Resorted the import statements using isort.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9221
diff
changeset
|
12 | from PyQt6.QtWidgets import QAbstractScrollArea, QWidget |
3327
1338767b5315
Started implementing support for a marker map in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
13 | |
1338767b5315
Started implementing support for a marker map in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
14 | |
8356
68ec9c3d4de5
Renamed the modules and classes of the E5Gui package to have the prefix 'Eric' instead of 'E5'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8319
diff
changeset
|
15 | class EricMapWidget(QWidget): |
3327
1338767b5315
Started implementing support for a marker map in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
16 | """ |
1338767b5315
Started implementing support for a marker map in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
17 | Class implementing a base class for showing a document map. |
1338767b5315
Started implementing support for a marker map in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
18 | """ |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
19 | |
3327
1338767b5315
Started implementing support for a marker map in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
20 | def __init__(self, parent=None): |
1338767b5315
Started implementing support for a marker map in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
21 | """ |
1338767b5315
Started implementing support for a marker map in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
22 | Constructor |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
23 | |
10423
299802979277
Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9972
diff
changeset
|
24 | @param parent reference to the parent widget |
299802979277
Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9972
diff
changeset
|
25 | @type QWidget |
3327
1338767b5315
Started implementing support for a marker map in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
26 | """ |
8218
7c09585bd960
Applied some more code simplifications suggested by the new Simplify checker (super(Foo, self) => super()).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8143
diff
changeset
|
27 | super().__init__(parent) |
8143
2c730d5fd177
Changed the use of PyQt enums because the way they were used previously is deprecated since two years and replaced some deprecated Qt stuff.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7923
diff
changeset
|
28 | self.setAttribute(Qt.WidgetAttribute.WA_OpaquePaintEvent) |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
29 | |
3329
1ee38e29ed4f
Continued implementing support for a marker map in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
3327
diff
changeset
|
30 | self.__width = 14 |
1ee38e29ed4f
Continued implementing support for a marker map in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
3327
diff
changeset
|
31 | self.__lineBorder = 1 |
3327
1338767b5315
Started implementing support for a marker map in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
32 | self.__lineHeight = 2 |
3329
1ee38e29ed4f
Continued implementing support for a marker map in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
3327
diff
changeset
|
33 | self.__backgroundColor = QColor("#e7e7e7") |
3339
d0a603f1bfcd
Added support for wheel events and mouse move events to the map widget and made some adjustments to the representation (colors).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
3329
diff
changeset
|
34 | self.__setSliderColor() |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
35 | |
9971
773ad1f1ed22
Performed some 'ethical' changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9653
diff
changeset
|
36 | self._controller = None |
3327
1338767b5315
Started implementing support for a marker map in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
37 | self.__enabled = False |
6278
13fd8759f981
Editor, E5MapWidget: added a configuration option (Editor->Style page) to show the marker map on the left or right of the editor
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6048
diff
changeset
|
38 | self.__rightSide = True |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
39 | |
3327
1338767b5315
Started implementing support for a marker map in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
40 | if parent is not None and isinstance(parent, QAbstractScrollArea): |
9971
773ad1f1ed22
Performed some 'ethical' changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9653
diff
changeset
|
41 | self.setController(parent) |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
42 | |
3339
d0a603f1bfcd
Added support for wheel events and mouse move events to the map widget and made some adjustments to the representation (colors).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
3329
diff
changeset
|
43 | def __setSliderColor(self): |
d0a603f1bfcd
Added support for wheel events and mouse move events to the map widget and made some adjustments to the representation (colors).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
3329
diff
changeset
|
44 | """ |
3591
2f2a4a76dd22
Corrected a bunch of source docu issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
3484
diff
changeset
|
45 | Private method to set the slider color depending upon the background |
2f2a4a76dd22
Corrected a bunch of source docu issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
3484
diff
changeset
|
46 | color. |
3339
d0a603f1bfcd
Added support for wheel events and mouse move events to the map widget and made some adjustments to the representation (colors).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
3329
diff
changeset
|
47 | """ |
d0a603f1bfcd
Added support for wheel events and mouse move events to the map widget and made some adjustments to the representation (colors).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
3329
diff
changeset
|
48 | if self.__backgroundColor.toHsv().value() < 128: |
d0a603f1bfcd
Added support for wheel events and mouse move events to the map widget and made some adjustments to the representation (colors).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
3329
diff
changeset
|
49 | # dark background, use white slider |
8143
2c730d5fd177
Changed the use of PyQt enums because the way they were used previously is deprecated since two years and replaced some deprecated Qt stuff.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7923
diff
changeset
|
50 | self.__sliderColor = Qt.GlobalColor.white |
3339
d0a603f1bfcd
Added support for wheel events and mouse move events to the map widget and made some adjustments to the representation (colors).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
3329
diff
changeset
|
51 | else: |
d0a603f1bfcd
Added support for wheel events and mouse move events to the map widget and made some adjustments to the representation (colors).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
3329
diff
changeset
|
52 | # light background, use black slider |
8143
2c730d5fd177
Changed the use of PyQt enums because the way they were used previously is deprecated since two years and replaced some deprecated Qt stuff.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7923
diff
changeset
|
53 | self.__sliderColor = Qt.GlobalColor.black |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
54 | |
9971
773ad1f1ed22
Performed some 'ethical' changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9653
diff
changeset
|
55 | def __updateControllerViewportWidth(self): |
3327
1338767b5315
Started implementing support for a marker map in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
56 | """ |
9971
773ad1f1ed22
Performed some 'ethical' changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9653
diff
changeset
|
57 | Private method to update the controller's viewport width. |
3327
1338767b5315
Started implementing support for a marker map in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
58 | """ |
9971
773ad1f1ed22
Performed some 'ethical' changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9653
diff
changeset
|
59 | if self._controller: |
3327
1338767b5315
Started implementing support for a marker map in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
60 | if self.__enabled: |
1338767b5315
Started implementing support for a marker map in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
61 | width = self.__width |
1338767b5315
Started implementing support for a marker map in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
62 | else: |
1338767b5315
Started implementing support for a marker map in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
63 | width = 0 |
6278
13fd8759f981
Editor, E5MapWidget: added a configuration option (Editor->Style page) to show the marker map on the left or right of the editor
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6048
diff
changeset
|
64 | if self.__rightSide: |
9971
773ad1f1ed22
Performed some 'ethical' changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9653
diff
changeset
|
65 | self._controller.setViewportMargins(0, 0, width, 0) |
6278
13fd8759f981
Editor, E5MapWidget: added a configuration option (Editor->Style page) to show the marker map on the left or right of the editor
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6048
diff
changeset
|
66 | else: |
9971
773ad1f1ed22
Performed some 'ethical' changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9653
diff
changeset
|
67 | self._controller.setViewportMargins(width, 0, 0, 0) |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
68 | |
9971
773ad1f1ed22
Performed some 'ethical' changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9653
diff
changeset
|
69 | def setController(self, controller): |
3327
1338767b5315
Started implementing support for a marker map in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
70 | """ |
9971
773ad1f1ed22
Performed some 'ethical' changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9653
diff
changeset
|
71 | Public method to set the map controller widget. |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
72 | |
9971
773ad1f1ed22
Performed some 'ethical' changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9653
diff
changeset
|
73 | @param controller map controller widget |
773ad1f1ed22
Performed some 'ethical' changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9653
diff
changeset
|
74 | @type QAbstractScrollArea |
3327
1338767b5315
Started implementing support for a marker map in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
75 | """ |
9971
773ad1f1ed22
Performed some 'ethical' changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9653
diff
changeset
|
76 | self._controller = controller |
9972
68ac01294544
Corrected some code style and formatting issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9971
diff
changeset
|
77 | self._controller.setVerticalScrollBarPolicy( |
68ac01294544
Corrected some code style and formatting issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9971
diff
changeset
|
78 | Qt.ScrollBarPolicy.ScrollBarAlwaysOn |
68ac01294544
Corrected some code style and formatting issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9971
diff
changeset
|
79 | ) |
9971
773ad1f1ed22
Performed some 'ethical' changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9653
diff
changeset
|
80 | self._controller.verticalScrollBar().valueChanged.connect(self.update) |
773ad1f1ed22
Performed some 'ethical' changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9653
diff
changeset
|
81 | self._controller.verticalScrollBar().rangeChanged.connect(self.update) |
773ad1f1ed22
Performed some 'ethical' changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9653
diff
changeset
|
82 | self.__updateControllerViewportWidth() |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
83 | |
3327
1338767b5315
Started implementing support for a marker map in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
84 | def setWidth(self, width): |
1338767b5315
Started implementing support for a marker map in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
85 | """ |
1338767b5315
Started implementing support for a marker map in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
86 | Public method to set the widget width. |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
87 | |
10423
299802979277
Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9972
diff
changeset
|
88 | @param width widget width |
299802979277
Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9972
diff
changeset
|
89 | @type int |
3327
1338767b5315
Started implementing support for a marker map in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
90 | """ |
3329
1ee38e29ed4f
Continued implementing support for a marker map in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
3327
diff
changeset
|
91 | if width != self.__width: |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
92 | self.__width = max(6, width) # minimum width 6 pixels |
9971
773ad1f1ed22
Performed some 'ethical' changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9653
diff
changeset
|
93 | self.__updateControllerViewportWidth() |
3329
1ee38e29ed4f
Continued implementing support for a marker map in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
3327
diff
changeset
|
94 | self.update() |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
95 | |
3327
1338767b5315
Started implementing support for a marker map in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
96 | def width(self): |
1338767b5315
Started implementing support for a marker map in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
97 | """ |
1338767b5315
Started implementing support for a marker map in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
98 | Public method to get the widget's width. |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
99 | |
10423
299802979277
Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9972
diff
changeset
|
100 | @return widget width |
299802979277
Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9972
diff
changeset
|
101 | @rtype int |
3327
1338767b5315
Started implementing support for a marker map in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
102 | """ |
1338767b5315
Started implementing support for a marker map in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
103 | return self.__width |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
104 | |
6278
13fd8759f981
Editor, E5MapWidget: added a configuration option (Editor->Style page) to show the marker map on the left or right of the editor
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6048
diff
changeset
|
105 | def setMapPosition(self, onRight): |
13fd8759f981
Editor, E5MapWidget: added a configuration option (Editor->Style page) to show the marker map on the left or right of the editor
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6048
diff
changeset
|
106 | """ |
13fd8759f981
Editor, E5MapWidget: added a configuration option (Editor->Style page) to show the marker map on the left or right of the editor
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6048
diff
changeset
|
107 | Public method to set, whether the map should be shown to the right or |
9971
773ad1f1ed22
Performed some 'ethical' changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9653
diff
changeset
|
108 | left of the controller widget. |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
109 | |
6278
13fd8759f981
Editor, E5MapWidget: added a configuration option (Editor->Style page) to show the marker map on the left or right of the editor
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6048
diff
changeset
|
110 | @param onRight flag indicating to show the map on the right side of |
9971
773ad1f1ed22
Performed some 'ethical' changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9653
diff
changeset
|
111 | the controller widget |
6278
13fd8759f981
Editor, E5MapWidget: added a configuration option (Editor->Style page) to show the marker map on the left or right of the editor
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6048
diff
changeset
|
112 | @type bool |
13fd8759f981
Editor, E5MapWidget: added a configuration option (Editor->Style page) to show the marker map on the left or right of the editor
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6048
diff
changeset
|
113 | """ |
13fd8759f981
Editor, E5MapWidget: added a configuration option (Editor->Style page) to show the marker map on the left or right of the editor
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6048
diff
changeset
|
114 | if onRight != self.__rightSide: |
13fd8759f981
Editor, E5MapWidget: added a configuration option (Editor->Style page) to show the marker map on the left or right of the editor
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6048
diff
changeset
|
115 | self.__rightSide = onRight |
9971
773ad1f1ed22
Performed some 'ethical' changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9653
diff
changeset
|
116 | self.__updateControllerViewportWidth() |
6278
13fd8759f981
Editor, E5MapWidget: added a configuration option (Editor->Style page) to show the marker map on the left or right of the editor
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6048
diff
changeset
|
117 | self.update() |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
118 | |
6278
13fd8759f981
Editor, E5MapWidget: added a configuration option (Editor->Style page) to show the marker map on the left or right of the editor
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6048
diff
changeset
|
119 | def isOnRightSide(self): |
13fd8759f981
Editor, E5MapWidget: added a configuration option (Editor->Style page) to show the marker map on the left or right of the editor
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6048
diff
changeset
|
120 | """ |
13fd8759f981
Editor, E5MapWidget: added a configuration option (Editor->Style page) to show the marker map on the left or right of the editor
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6048
diff
changeset
|
121 | Public method to test, if the map is shown on the right side of the |
9971
773ad1f1ed22
Performed some 'ethical' changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9653
diff
changeset
|
122 | controller widget. |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
123 | |
9971
773ad1f1ed22
Performed some 'ethical' changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9653
diff
changeset
|
124 | @return flag indicating that the map is to the right of the controller |
6278
13fd8759f981
Editor, E5MapWidget: added a configuration option (Editor->Style page) to show the marker map on the left or right of the editor
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6048
diff
changeset
|
125 | widget |
6279
7c44be92f8a4
E5MapWidget: fixed a source docu issue
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6278
diff
changeset
|
126 | @rtype bool |
6278
13fd8759f981
Editor, E5MapWidget: added a configuration option (Editor->Style page) to show the marker map on the left or right of the editor
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6048
diff
changeset
|
127 | """ |
13fd8759f981
Editor, E5MapWidget: added a configuration option (Editor->Style page) to show the marker map on the left or right of the editor
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6048
diff
changeset
|
128 | return self.__rightSide |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
129 | |
3327
1338767b5315
Started implementing support for a marker map in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
130 | def setLineDimensions(self, border, height): |
1338767b5315
Started implementing support for a marker map in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
131 | """ |
1338767b5315
Started implementing support for a marker map in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
132 | Public method to set the line (indicator) dimensions. |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
133 | |
10423
299802979277
Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9972
diff
changeset
|
134 | @param border border width on each side in x-direction |
299802979277
Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9972
diff
changeset
|
135 | @type int |
299802979277
Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9972
diff
changeset
|
136 | @param height height of the line in pixels |
299802979277
Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9972
diff
changeset
|
137 | @type int |
3327
1338767b5315
Started implementing support for a marker map in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
138 | """ |
3329
1ee38e29ed4f
Continued implementing support for a marker map in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
3327
diff
changeset
|
139 | if border != self.__lineBorder or height != self.__lineHeight: |
1ee38e29ed4f
Continued implementing support for a marker map in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
3327
diff
changeset
|
140 | self.__lineBorder = max(1, border) # min border 1 pixel |
1ee38e29ed4f
Continued implementing support for a marker map in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
3327
diff
changeset
|
141 | self.__lineHeight = max(1, height) # min height 1 pixel |
1ee38e29ed4f
Continued implementing support for a marker map in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
3327
diff
changeset
|
142 | self.update() |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
143 | |
3327
1338767b5315
Started implementing support for a marker map in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
144 | def lineDimensions(self): |
1338767b5315
Started implementing support for a marker map in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
145 | """ |
1338767b5315
Started implementing support for a marker map in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
146 | Public method to get the line (indicator) dimensions. |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
147 | |
10423
299802979277
Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9972
diff
changeset
|
148 | @return tuple with border width (integer) and line height |
299802979277
Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9972
diff
changeset
|
149 | @rtype int |
3327
1338767b5315
Started implementing support for a marker map in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
150 | """ |
1338767b5315
Started implementing support for a marker map in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
151 | return self.__lineBorder, self.__lineHeight |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
152 | |
3327
1338767b5315
Started implementing support for a marker map in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
153 | def setEnabled(self, enable): |
1338767b5315
Started implementing support for a marker map in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
154 | """ |
1338767b5315
Started implementing support for a marker map in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
155 | Public method to set the enabled state. |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
156 | |
10423
299802979277
Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9972
diff
changeset
|
157 | @param enable flag indicating the enabled state |
299802979277
Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9972
diff
changeset
|
158 | @type bool |
3327
1338767b5315
Started implementing support for a marker map in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
159 | """ |
3329
1ee38e29ed4f
Continued implementing support for a marker map in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
3327
diff
changeset
|
160 | if enable != self.__enabled: |
1ee38e29ed4f
Continued implementing support for a marker map in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
3327
diff
changeset
|
161 | self.__enabled = enable |
1ee38e29ed4f
Continued implementing support for a marker map in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
3327
diff
changeset
|
162 | self.setVisible(enable) |
9971
773ad1f1ed22
Performed some 'ethical' changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9653
diff
changeset
|
163 | self.__updateControllerViewportWidth() |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
164 | |
3327
1338767b5315
Started implementing support for a marker map in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
165 | def isEnabled(self): |
1338767b5315
Started implementing support for a marker map in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
166 | """ |
1338767b5315
Started implementing support for a marker map in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
167 | Public method to check the enabled state. |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
168 | |
10423
299802979277
Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9972
diff
changeset
|
169 | @return flag indicating the enabled state |
299802979277
Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9972
diff
changeset
|
170 | @rtype bool |
3327
1338767b5315
Started implementing support for a marker map in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
171 | """ |
1338767b5315
Started implementing support for a marker map in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
172 | return self.__enabled |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
173 | |
3327
1338767b5315
Started implementing support for a marker map in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
174 | def setBackgroundColor(self, color): |
1338767b5315
Started implementing support for a marker map in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
175 | """ |
1338767b5315
Started implementing support for a marker map in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
176 | Public method to set the widget background color. |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
177 | |
10423
299802979277
Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9972
diff
changeset
|
178 | @param color color for the background |
299802979277
Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9972
diff
changeset
|
179 | @type QColor |
3327
1338767b5315
Started implementing support for a marker map in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
180 | """ |
3329
1ee38e29ed4f
Continued implementing support for a marker map in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
3327
diff
changeset
|
181 | if color != self.__backgroundColor: |
1ee38e29ed4f
Continued implementing support for a marker map in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
3327
diff
changeset
|
182 | self.__backgroundColor = color |
3339
d0a603f1bfcd
Added support for wheel events and mouse move events to the map widget and made some adjustments to the representation (colors).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
3329
diff
changeset
|
183 | self.__setSliderColor() |
3329
1ee38e29ed4f
Continued implementing support for a marker map in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
3327
diff
changeset
|
184 | self.update() |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
185 | |
3327
1338767b5315
Started implementing support for a marker map in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
186 | def backgroundColor(self): |
1338767b5315
Started implementing support for a marker map in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
187 | """ |
1338767b5315
Started implementing support for a marker map in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
188 | Public method to get the background color. |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
189 | |
10423
299802979277
Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9972
diff
changeset
|
190 | @return background color |
299802979277
Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9972
diff
changeset
|
191 | @rtype QColor |
3327
1338767b5315
Started implementing support for a marker map in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
192 | """ |
1338767b5315
Started implementing support for a marker map in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
193 | return QColor(self.__backgroundColor) |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
194 | |
3327
1338767b5315
Started implementing support for a marker map in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
195 | def sizeHint(self): |
1338767b5315
Started implementing support for a marker map in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
196 | """ |
1338767b5315
Started implementing support for a marker map in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
197 | Public method to give an indication about the preferred size. |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
198 | |
10423
299802979277
Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9972
diff
changeset
|
199 | @return preferred size |
299802979277
Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9972
diff
changeset
|
200 | @rtype QSize |
3327
1338767b5315
Started implementing support for a marker map in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
201 | """ |
1338767b5315
Started implementing support for a marker map in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
202 | return QSize(self.__width, 0) |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
203 | |
3327
1338767b5315
Started implementing support for a marker map in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
204 | def paintEvent(self, event): |
1338767b5315
Started implementing support for a marker map in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
205 | """ |
1338767b5315
Started implementing support for a marker map in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
206 | Protected method to handle a paint event. |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
207 | |
10423
299802979277
Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9972
diff
changeset
|
208 | @param event paint event |
299802979277
Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9972
diff
changeset
|
209 | @type QPaintEvent |
3327
1338767b5315
Started implementing support for a marker map in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
210 | """ |
1338767b5315
Started implementing support for a marker map in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
211 | # step 1: fill the whole painting area |
1338767b5315
Started implementing support for a marker map in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
212 | painter = QPainter(self) |
1338767b5315
Started implementing support for a marker map in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
213 | painter.fillRect(event.rect(), self.__backgroundColor) |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
214 | |
3327
1338767b5315
Started implementing support for a marker map in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
215 | # step 2: paint the indicators |
1338767b5315
Started implementing support for a marker map in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
216 | self._paintIt(painter) |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
217 | |
3327
1338767b5315
Started implementing support for a marker map in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
218 | # step 3: paint the slider |
9971
773ad1f1ed22
Performed some 'ethical' changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9653
diff
changeset
|
219 | if self._controller: |
3339
d0a603f1bfcd
Added support for wheel events and mouse move events to the map widget and made some adjustments to the representation (colors).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
3329
diff
changeset
|
220 | penColor = self.__sliderColor |
3327
1338767b5315
Started implementing support for a marker map in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
221 | painter.setPen(penColor) |
8143
2c730d5fd177
Changed the use of PyQt enums because the way they were used previously is deprecated since two years and replaced some deprecated Qt stuff.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7923
diff
changeset
|
222 | brushColor = Qt.GlobalColor.transparent |
3327
1338767b5315
Started implementing support for a marker map in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
223 | painter.setBrush(QBrush(brushColor)) |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
224 | painter.drawRect( |
9971
773ad1f1ed22
Performed some 'ethical' changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9653
diff
changeset
|
225 | self.__generateSliderRange(self._controller.verticalScrollBar()) |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
226 | ) |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
227 | |
3327
1338767b5315
Started implementing support for a marker map in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
228 | def _paintIt(self, painter): |
1338767b5315
Started implementing support for a marker map in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
229 | """ |
1338767b5315
Started implementing support for a marker map in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
230 | Protected method for painting the widget's indicators. |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
231 | |
3327
1338767b5315
Started implementing support for a marker map in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
232 | Note: This method should be implemented by subclasses. |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
233 | |
10423
299802979277
Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9972
diff
changeset
|
234 | @param painter reference to the painter object |
299802979277
Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9972
diff
changeset
|
235 | @type QPainter |
3327
1338767b5315
Started implementing support for a marker map in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
236 | """ |
1338767b5315
Started implementing support for a marker map in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
237 | pass |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
238 | |
3339
d0a603f1bfcd
Added support for wheel events and mouse move events to the map widget and made some adjustments to the representation (colors).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
3329
diff
changeset
|
239 | def mousePressEvent(self, event): |
3327
1338767b5315
Started implementing support for a marker map in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
240 | """ |
3339
d0a603f1bfcd
Added support for wheel events and mouse move events to the map widget and made some adjustments to the representation (colors).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
3329
diff
changeset
|
241 | Protected method to handle a mouse button press. |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
242 | |
10423
299802979277
Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9972
diff
changeset
|
243 | @param event reference to the mouse event |
299802979277
Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9972
diff
changeset
|
244 | @type QMouseEvent |
3327
1338767b5315
Started implementing support for a marker map in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
245 | """ |
9971
773ad1f1ed22
Performed some 'ethical' changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9653
diff
changeset
|
246 | if event.button() == Qt.MouseButton.LeftButton and self._controller: |
773ad1f1ed22
Performed some 'ethical' changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9653
diff
changeset
|
247 | vsb = self._controller.verticalScrollBar() |
8318
962bce857696
Replaced all imports of PyQt5 to PyQt6 and started to replace code using obsoleted methods and adapt to the PyQt6 enum usage.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8312
diff
changeset
|
248 | value = self.position2Value(event.position().toPoint().y() - 1) |
8719
6b316898a2ac
Fixed a Python 3.10 related issue.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8647
diff
changeset
|
249 | vsb.setValue(int(value - 0.5 * vsb.pageStep())) # center on page |
3339
d0a603f1bfcd
Added support for wheel events and mouse move events to the map widget and made some adjustments to the representation (colors).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
3329
diff
changeset
|
250 | self.__mousePressPos = None |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
251 | |
3339
d0a603f1bfcd
Added support for wheel events and mouse move events to the map widget and made some adjustments to the representation (colors).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
3329
diff
changeset
|
252 | def mouseMoveEvent(self, event): |
d0a603f1bfcd
Added support for wheel events and mouse move events to the map widget and made some adjustments to the representation (colors).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
3329
diff
changeset
|
253 | """ |
d0a603f1bfcd
Added support for wheel events and mouse move events to the map widget and made some adjustments to the representation (colors).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
3329
diff
changeset
|
254 | Protected method to handle a mouse moves. |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
255 | |
10423
299802979277
Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9972
diff
changeset
|
256 | @param event reference to the mouse event |
299802979277
Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9972
diff
changeset
|
257 | @type QMouseEvent |
3339
d0a603f1bfcd
Added support for wheel events and mouse move events to the map widget and made some adjustments to the representation (colors).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
3329
diff
changeset
|
258 | """ |
9971
773ad1f1ed22
Performed some 'ethical' changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9653
diff
changeset
|
259 | if event.buttons() & Qt.MouseButton.LeftButton and self._controller: |
773ad1f1ed22
Performed some 'ethical' changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9653
diff
changeset
|
260 | vsb = self._controller.verticalScrollBar() |
8318
962bce857696
Replaced all imports of PyQt5 to PyQt6 and started to replace code using obsoleted methods and adapt to the PyQt6 enum usage.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8312
diff
changeset
|
261 | value = self.position2Value(event.position().toPoint().y() - 1) |
8719
6b316898a2ac
Fixed a Python 3.10 related issue.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8647
diff
changeset
|
262 | vsb.setValue(int(value - 0.5 * vsb.pageStep())) # center on page |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
263 | |
3339
d0a603f1bfcd
Added support for wheel events and mouse move events to the map widget and made some adjustments to the representation (colors).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
3329
diff
changeset
|
264 | def wheelEvent(self, event): |
d0a603f1bfcd
Added support for wheel events and mouse move events to the map widget and made some adjustments to the representation (colors).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
3329
diff
changeset
|
265 | """ |
d0a603f1bfcd
Added support for wheel events and mouse move events to the map widget and made some adjustments to the representation (colors).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
3329
diff
changeset
|
266 | Protected slot handling mouse wheel events. |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
267 | |
10423
299802979277
Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9972
diff
changeset
|
268 | @param event reference to the wheel event |
299802979277
Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9972
diff
changeset
|
269 | @type QWheelEvent |
3339
d0a603f1bfcd
Added support for wheel events and mouse move events to the map widget and made some adjustments to the representation (colors).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
3329
diff
changeset
|
270 | """ |
7198
684261ef2165
Removed the Qt4 runtime stuff.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6942
diff
changeset
|
271 | isVertical = event.angleDelta().x() == 0 |
7252
c5e3705073eb
Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7229
diff
changeset
|
272 | if ( |
9971
773ad1f1ed22
Performed some 'ethical' changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9653
diff
changeset
|
273 | self._controller |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
274 | and event.modifiers() == Qt.KeyboardModifier.NoModifier |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
275 | and isVertical |
7252
c5e3705073eb
Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7229
diff
changeset
|
276 | ): |
9971
773ad1f1ed22
Performed some 'ethical' changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9653
diff
changeset
|
277 | QCoreApplication.sendEvent(self._controller.verticalScrollBar(), event) |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
278 | |
3327
1338767b5315
Started implementing support for a marker map in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
279 | def calculateGeometry(self): |
1338767b5315
Started implementing support for a marker map in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
280 | """ |
1338767b5315
Started implementing support for a marker map in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
281 | Public method to recalculate the map widget's geometry. |
1338767b5315
Started implementing support for a marker map in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
282 | """ |
9971
773ad1f1ed22
Performed some 'ethical' changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9653
diff
changeset
|
283 | if self._controller: |
773ad1f1ed22
Performed some 'ethical' changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9653
diff
changeset
|
284 | cr = self._controller.contentsRect() |
773ad1f1ed22
Performed some 'ethical' changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9653
diff
changeset
|
285 | vsb = self._controller.verticalScrollBar() |
3327
1338767b5315
Started implementing support for a marker map in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
286 | if vsb.isVisible(): |
1338767b5315
Started implementing support for a marker map in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
287 | vsbw = vsb.contentsRect().width() |
1338767b5315
Started implementing support for a marker map in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
288 | else: |
1338767b5315
Started implementing support for a marker map in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
289 | vsbw = 0 |
9971
773ad1f1ed22
Performed some 'ethical' changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9653
diff
changeset
|
290 | margins = self._controller.contentsMargins() |
8319
ea11a3948f40
Continued porting eric to PyQt6.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8318
diff
changeset
|
291 | if margins.right() > vsbw: |
3327
1338767b5315
Started implementing support for a marker map in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
292 | vsbw = 0 |
6278
13fd8759f981
Editor, E5MapWidget: added a configuration option (Editor->Style page) to show the marker map on the left or right of the editor
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6048
diff
changeset
|
293 | if self.__rightSide: |
13fd8759f981
Editor, E5MapWidget: added a configuration option (Editor->Style page) to show the marker map on the left or right of the editor
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6048
diff
changeset
|
294 | self.setGeometry( |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
295 | QRect( |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
296 | cr.right() - self.__width - vsbw, |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
297 | cr.top(), |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
298 | self.__width, |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
299 | cr.height(), |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
300 | ) |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
301 | ) |
6278
13fd8759f981
Editor, E5MapWidget: added a configuration option (Editor->Style page) to show the marker map on the left or right of the editor
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6048
diff
changeset
|
302 | else: |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
303 | self.setGeometry(QRect(0, cr.top(), self.__width, cr.height())) |
4371
e09838aa0a9f
Fixed an issue in the marker map causing its contents to disappear on Mac OS X when the scrollbar got hidden.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4021
diff
changeset
|
304 | self.update() |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
305 | |
3327
1338767b5315
Started implementing support for a marker map in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
306 | def scaleFactor(self, slider=False): |
1338767b5315
Started implementing support for a marker map in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
307 | """ |
1338767b5315
Started implementing support for a marker map in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
308 | Public method to determine the scrollbar's scale factor. |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
309 | |
3327
1338767b5315
Started implementing support for a marker map in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
310 | @param slider flag indicating to calculate the result for the slider |
10423
299802979277
Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9972
diff
changeset
|
311 | @type bool |
299802979277
Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9972
diff
changeset
|
312 | @return scale factor |
299802979277
Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9972
diff
changeset
|
313 | @rtype float |
3327
1338767b5315
Started implementing support for a marker map in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
314 | """ |
9971
773ad1f1ed22
Performed some 'ethical' changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9653
diff
changeset
|
315 | if self._controller: |
3327
1338767b5315
Started implementing support for a marker map in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
316 | delta = 0 if slider else 2 |
9971
773ad1f1ed22
Performed some 'ethical' changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9653
diff
changeset
|
317 | vsb = self._controller.verticalScrollBar() |
3327
1338767b5315
Started implementing support for a marker map in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
318 | posHeight = vsb.height() - delta - 1 |
1338767b5315
Started implementing support for a marker map in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
319 | valHeight = vsb.maximum() - vsb.minimum() + vsb.pageStep() |
3484
645c12de6b0c
Merge with default branch.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
3339
diff
changeset
|
320 | return float(posHeight) / valHeight |
3327
1338767b5315
Started implementing support for a marker map in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
321 | else: |
1338767b5315
Started implementing support for a marker map in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
322 | return 1.0 |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
323 | |
3327
1338767b5315
Started implementing support for a marker map in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
324 | def value2Position(self, value, slider=False): |
1338767b5315
Started implementing support for a marker map in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
325 | """ |
1338767b5315
Started implementing support for a marker map in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
326 | Public method to convert a scrollbar value into a position. |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
327 | |
10423
299802979277
Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9972
diff
changeset
|
328 | @param value value to convert |
299802979277
Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9972
diff
changeset
|
329 | @type int |
3327
1338767b5315
Started implementing support for a marker map in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
330 | @param slider flag indicating to calculate the result for the slider |
10423
299802979277
Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9972
diff
changeset
|
331 | @type bool |
299802979277
Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9972
diff
changeset
|
332 | @return position |
299802979277
Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9972
diff
changeset
|
333 | @rtype int |
3327
1338767b5315
Started implementing support for a marker map in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
334 | """ |
9971
773ad1f1ed22
Performed some 'ethical' changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9653
diff
changeset
|
335 | if self._controller: |
3327
1338767b5315
Started implementing support for a marker map in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
336 | offset = 0 if slider else 1 |
9971
773ad1f1ed22
Performed some 'ethical' changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9653
diff
changeset
|
337 | vsb = self._controller.verticalScrollBar() |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
338 | return int((value - vsb.minimum()) * self.scaleFactor(slider) + offset) |
3327
1338767b5315
Started implementing support for a marker map in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
339 | else: |
1338767b5315
Started implementing support for a marker map in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
340 | return value |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
341 | |
3327
1338767b5315
Started implementing support for a marker map in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
342 | def position2Value(self, position, slider=False): |
1338767b5315
Started implementing support for a marker map in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
343 | """ |
1338767b5315
Started implementing support for a marker map in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
344 | Public method to convert a position into a scrollbar value. |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
345 | |
10423
299802979277
Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9972
diff
changeset
|
346 | @param position scrollbar position to convert |
299802979277
Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9972
diff
changeset
|
347 | @type int |
3327
1338767b5315
Started implementing support for a marker map in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
348 | @param slider flag indicating to calculate the result for the slider |
10423
299802979277
Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9972
diff
changeset
|
349 | |
299802979277
Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9972
diff
changeset
|
350 | @type bool |
299802979277
Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9972
diff
changeset
|
351 | @return scrollbar value |
299802979277
Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9972
diff
changeset
|
352 | @rtype int |
3327
1338767b5315
Started implementing support for a marker map in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
353 | """ |
9971
773ad1f1ed22
Performed some 'ethical' changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9653
diff
changeset
|
354 | if self._controller: |
3327
1338767b5315
Started implementing support for a marker map in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
355 | offset = 0 if slider else 1 |
9971
773ad1f1ed22
Performed some 'ethical' changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9653
diff
changeset
|
356 | vsb = self._controller.verticalScrollBar() |
3327
1338767b5315
Started implementing support for a marker map in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
357 | return vsb.minimum() + max( |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
358 | 0, (position - offset) / self.scaleFactor(slider) |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
359 | ) |
3327
1338767b5315
Started implementing support for a marker map in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
360 | else: |
1338767b5315
Started implementing support for a marker map in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
361 | return position |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
362 | |
3327
1338767b5315
Started implementing support for a marker map in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
363 | def generateIndicatorRect(self, position): |
1338767b5315
Started implementing support for a marker map in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
364 | """ |
1338767b5315
Started implementing support for a marker map in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
365 | Public method to generate an indicator rectangle. |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
366 | |
10423
299802979277
Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9972
diff
changeset
|
367 | @param position indicator position |
299802979277
Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9972
diff
changeset
|
368 | @type int |
299802979277
Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9972
diff
changeset
|
369 | @return indicator rectangle |
299802979277
Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9972
diff
changeset
|
370 | @rtype QRect |
3327
1338767b5315
Started implementing support for a marker map in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
371 | """ |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
372 | return QRect( |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
373 | self.__lineBorder, |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
374 | position - self.__lineHeight // 2, |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
375 | self.__width - self.__lineBorder, |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
376 | self.__lineHeight, |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
377 | ) |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
378 | |
3327
1338767b5315
Started implementing support for a marker map in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
379 | def __generateSliderRange(self, scrollbar): |
1338767b5315
Started implementing support for a marker map in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
380 | """ |
1338767b5315
Started implementing support for a marker map in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
381 | Private method to generate the slider rectangle. |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
382 | |
10423
299802979277
Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9972
diff
changeset
|
383 | @param scrollbar reference to the vertical scrollbar |
299802979277
Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9972
diff
changeset
|
384 | @type QScrollBar |
299802979277
Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9972
diff
changeset
|
385 | @return slider rectangle |
299802979277
Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9972
diff
changeset
|
386 | @rtype QRect |
3327
1338767b5315
Started implementing support for a marker map in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
387 | """ |
1338767b5315
Started implementing support for a marker map in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
388 | pos1 = self.value2Position(scrollbar.value(), slider=True) |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
389 | pos2 = self.value2Position( |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
390 | scrollbar.value() + scrollbar.pageStep(), slider=True |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
391 | ) |
3329
1ee38e29ed4f
Continued implementing support for a marker map in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
3327
diff
changeset
|
392 | return QRect(0, pos1, self.__width - 1, pos2 - pos1) |