Graphics/UMLGraphicsView.py

changeset 1518
e6e21910210d
parent 1509
c0b5e693b0eb
child 1588
dccffd13be8d
equal deleted inserted replaced
1516:7c0b621e537d 1518:e6e21910210d
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
52 self.deltaSize = 100.0 52 self.deltaSize = 100.0
53 53
54 self.__initActions() 54 self.__initActions()
55 55
56 scene.changed.connect(self.__sceneChanged) 56 scene.changed.connect(self.__sceneChanged)
57
58 self.grabGesture(Qt.PinchGesture)
57 59
58 def __initActions(self): 60 def __initActions(self):
59 """ 61 """
60 Private method to initialize the view actions. 62 Private method to initialize the view actions.
61 """ 63 """
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()

eric ide

mercurial