5 |
5 |
6 """ |
6 """ |
7 Module implementing a subclass of E5GraphicsView for our diagrams. |
7 Module implementing a subclass of E5GraphicsView for our diagrams. |
8 """ |
8 """ |
9 |
9 |
10 from PyQt4.QtCore import pyqtSignal, Qt, QSignalMapper, QFileInfo |
10 from PyQt4.QtCore import pyqtSignal, Qt, QSignalMapper, QFileInfo, QEvent |
11 from PyQt4.QtGui import QAction, QToolBar, QDialog, QPrinter, QPrintDialog |
11 from PyQt4.QtGui import QAction, QToolBar, QDialog, QPrinter, QPrintDialog |
12 |
12 |
13 from E5Graphics.E5GraphicsView import E5GraphicsView |
13 from E5Graphics.E5GraphicsView import E5GraphicsView |
14 |
14 |
15 from E5Gui import E5MessageBox, E5FileDialog |
15 from E5Gui import E5MessageBox, E5FileDialog |
516 self.zoomIn() |
518 self.zoomIn() |
517 evt.accept() |
519 evt.accept() |
518 return |
520 return |
519 |
521 |
520 super().wheelEvent(evt) |
522 super().wheelEvent(evt) |
|
523 |
|
524 def event(self, evt): |
|
525 """ |
|
526 Protected method handling events. |
|
527 |
|
528 @param evt reference to the event (QEvent) |
|
529 @return flag indicating, if the event was handled (boolean) |
|
530 """ |
|
531 if evt.type() == QEvent.Gesture: |
|
532 self.gestureEvent(evt) |
|
533 return True |
|
534 |
|
535 return super().event(evt) |
|
536 |
|
537 def gestureEvent(self, evt): |
|
538 """ |
|
539 Protected method handling gesture events. |
|
540 |
|
541 @param evt reference to the gesture event (QGestureEvent |
|
542 """ |
|
543 pinch = evt.gesture(Qt.PinchGesture) |
|
544 if pinch: |
|
545 if pinch.state() == Qt.GestureStarted: |
|
546 pinch.setScaleFactor(self.zoom()) |
|
547 else: |
|
548 self.setZoom(pinch.scaleFactor()) |
|
549 evt.accept() |