7 Module implementing a base class for showing a document map. |
7 Module implementing a base class for showing a document map. |
8 """ |
8 """ |
9 |
9 |
10 from __future__ import unicode_literals |
10 from __future__ import unicode_literals |
11 |
11 |
12 from PyQt5.QtCore import Qt, QSize, QRect, QCoreApplication |
12 from PyQt5.QtCore import Qt, QSize, QRect, QCoreApplication, qVersion |
13 from PyQt5.QtGui import QColor, QBrush, QPainter |
13 from PyQt5.QtGui import QColor, QBrush, QPainter |
14 from PyQt5.QtWidgets import QWidget, QAbstractScrollArea |
14 from PyQt5.QtWidgets import QWidget, QAbstractScrollArea |
15 |
15 |
16 |
16 |
17 class E5MapWidget(QWidget): |
17 class E5MapWidget(QWidget): |
217 """ |
217 """ |
218 Protected slot handling mouse wheel events. |
218 Protected slot handling mouse wheel events. |
219 |
219 |
220 @param event reference to the wheel event (QWheelEvent) |
220 @param event reference to the wheel event (QWheelEvent) |
221 """ |
221 """ |
|
222 if qVersion() >= "5.0.0": |
|
223 isVertical = event.angleDelta().x() == 0 |
|
224 else: |
|
225 isVertical = event.orientation() == Qt.Vertical |
222 if self._master and \ |
226 if self._master and \ |
223 event.modifiers() == Qt.NoModifier and \ |
227 event.modifiers() == Qt.NoModifier and \ |
224 event.angleDelta().x() == 0: |
228 isVertical: |
225 # TODO: test angleDelte() with Mac Trackpad |
229 # TODO: test angleDelta() with Mac Trackpad |
226 QCoreApplication.sendEvent(self._master.verticalScrollBar(), event) |
230 QCoreApplication.sendEvent(self._master.verticalScrollBar(), event) |
227 |
231 |
228 def calculateGeometry(self): |
232 def calculateGeometry(self): |
229 """ |
233 """ |
230 Public method to recalculate the map widget's geometry. |
234 Public method to recalculate the map widget's geometry. |