eric6/Graphics/UMLGraphicsView.py

branch
maintenance
changeset 7286
7eb04391adf7
parent 6989
8b8cadf8d7e9
parent 7254
f00d825fbdb3
child 7362
028bf21bb5a2
diff -r babe80d84a3e -r 7eb04391adf7 eric6/Graphics/UMLGraphicsView.py
--- a/eric6/Graphics/UMLGraphicsView.py	Mon Sep 09 18:52:08 2019 +0200
+++ b/eric6/Graphics/UMLGraphicsView.py	Thu Oct 03 11:12:10 2019 +0200
@@ -7,10 +7,10 @@
 Module implementing a subclass of E5GraphicsView for our diagrams.
 """
 
-from __future__ import unicode_literals
 
-from PyQt5.QtCore import pyqtSignal, Qt, QSignalMapper, QFileInfo, QEvent, \
-    QRectF
+from PyQt5.QtCore import (
+    pyqtSignal, Qt, QSignalMapper, QFileInfo, QEvent, QRectF
+)
 from PyQt5.QtWidgets import QGraphicsView, QAction, QToolBar, QDialog
 from PyQt5.QtPrintSupport import QPrinter, QPrintDialog
 
@@ -25,7 +25,6 @@
 import UI.PixmapCache
 
 import Preferences
-from Globals import qVersionTuple
 
 
 class UMLGraphicsView(E5GraphicsView):
@@ -77,87 +76,87 @@
         self.alignMapper = QSignalMapper(self)
         self.alignMapper.mapped[int].connect(self.__alignShapes)
         
-        self.deleteShapeAct = \
-            QAction(UI.PixmapCache.getIcon("deleteShape.png"),
-                    self.tr("Delete shapes"), self)
+        self.deleteShapeAct = QAction(
+            UI.PixmapCache.getIcon("deleteShape.png"),
+            self.tr("Delete shapes"), self)
         self.deleteShapeAct.triggered.connect(self.__deleteShape)
         
-        self.incWidthAct = \
-            QAction(UI.PixmapCache.getIcon("sceneWidthInc.png"),
-                    self.tr("Increase width by {0} points").format(
-                        self.deltaSize),
-                    self)
+        self.incWidthAct = QAction(
+            UI.PixmapCache.getIcon("sceneWidthInc.png"),
+            self.tr("Increase width by {0} points").format(
+                self.deltaSize),
+            self)
         self.incWidthAct.triggered.connect(self.__incWidth)
         
-        self.incHeightAct = \
-            QAction(UI.PixmapCache.getIcon("sceneHeightInc.png"),
-                    self.tr("Increase height by {0} points").format(
-                        self.deltaSize),
-                    self)
+        self.incHeightAct = QAction(
+            UI.PixmapCache.getIcon("sceneHeightInc.png"),
+            self.tr("Increase height by {0} points").format(
+                self.deltaSize),
+            self)
         self.incHeightAct.triggered.connect(self.__incHeight)
         
-        self.decWidthAct = \
-            QAction(UI.PixmapCache.getIcon("sceneWidthDec.png"),
-                    self.tr("Decrease width by {0} points").format(
-                        self.deltaSize),
-                    self)
+        self.decWidthAct = QAction(
+            UI.PixmapCache.getIcon("sceneWidthDec.png"),
+            self.tr("Decrease width by {0} points").format(
+                self.deltaSize),
+            self)
         self.decWidthAct.triggered.connect(self.__decWidth)
         
-        self.decHeightAct = \
-            QAction(UI.PixmapCache.getIcon("sceneHeightDec.png"),
-                    self.tr("Decrease height by {0} points").format(
-                        self.deltaSize),
-                    self)
+        self.decHeightAct = QAction(
+            UI.PixmapCache.getIcon("sceneHeightDec.png"),
+            self.tr("Decrease height by {0} points").format(
+                self.deltaSize),
+            self)
         self.decHeightAct.triggered.connect(self.__decHeight)
         
-        self.setSizeAct = \
-            QAction(UI.PixmapCache.getIcon("sceneSize.png"),
-                    self.tr("Set size"), self)
+        self.setSizeAct = QAction(
+            UI.PixmapCache.getIcon("sceneSize.png"),
+            self.tr("Set size"), self)
         self.setSizeAct.triggered.connect(self.__setSize)
         
-        self.rescanAct = \
-            QAction(UI.PixmapCache.getIcon("rescan.png"),
-                    self.tr("Re-Scan"), self)
+        self.rescanAct = QAction(
+            UI.PixmapCache.getIcon("rescan.png"),
+            self.tr("Re-Scan"), self)
         self.rescanAct.triggered.connect(self.__rescan)
         
-        self.relayoutAct = \
-            QAction(UI.PixmapCache.getIcon("relayout.png"),
-                    self.tr("Re-Layout"), self)
+        self.relayoutAct = QAction(
+            UI.PixmapCache.getIcon("relayout.png"),
+            self.tr("Re-Layout"), self)
         self.relayoutAct.triggered.connect(self.__relayout)
         
-        self.alignLeftAct = \
-            QAction(UI.PixmapCache.getIcon("shapesAlignLeft.png"),
-                    self.tr("Align Left"), self)
+        self.alignLeftAct = QAction(
+            UI.PixmapCache.getIcon("shapesAlignLeft.png"),
+            self.tr("Align Left"), self)
         self.alignMapper.setMapping(self.alignLeftAct, Qt.AlignLeft)
         self.alignLeftAct.triggered.connect(self.alignMapper.map)
         
-        self.alignHCenterAct = \
-            QAction(UI.PixmapCache.getIcon("shapesAlignHCenter.png"),
-                    self.tr("Align Center Horizontal"), self)
+        self.alignHCenterAct = QAction(
+            UI.PixmapCache.getIcon("shapesAlignHCenter.png"),
+            self.tr("Align Center Horizontal"), self)
         self.alignMapper.setMapping(self.alignHCenterAct, Qt.AlignHCenter)
         self.alignHCenterAct.triggered.connect(self.alignMapper.map)
         
-        self.alignRightAct = \
-            QAction(UI.PixmapCache.getIcon("shapesAlignRight.png"),
-                    self.tr("Align Right"), self)
+        self.alignRightAct = QAction(
+            UI.PixmapCache.getIcon("shapesAlignRight.png"),
+            self.tr("Align Right"), self)
         self.alignMapper.setMapping(self.alignRightAct, Qt.AlignRight)
         self.alignRightAct.triggered.connect(self.alignMapper.map)
         
-        self.alignTopAct = \
-            QAction(UI.PixmapCache.getIcon("shapesAlignTop.png"),
-                    self.tr("Align Top"), self)
+        self.alignTopAct = QAction(
+            UI.PixmapCache.getIcon("shapesAlignTop.png"),
+            self.tr("Align Top"), self)
         self.alignMapper.setMapping(self.alignTopAct, Qt.AlignTop)
         self.alignTopAct.triggered.connect(self.alignMapper.map)
         
-        self.alignVCenterAct = \
-            QAction(UI.PixmapCache.getIcon("shapesAlignVCenter.png"),
-                    self.tr("Align Center Vertical"), self)
+        self.alignVCenterAct = QAction(
+            UI.PixmapCache.getIcon("shapesAlignVCenter.png"),
+            self.tr("Align Center Vertical"), self)
         self.alignMapper.setMapping(self.alignVCenterAct, Qt.AlignVCenter)
         self.alignVCenterAct.triggered.connect(self.alignMapper.map)
         
-        self.alignBottomAct = \
-            QAction(UI.PixmapCache.getIcon("shapesAlignBottom.png"),
-                    self.tr("Align Bottom"), self)
+        self.alignBottomAct = QAction(
+            UI.PixmapCache.getIcon("shapesAlignBottom.png"),
+            self.tr("Align Bottom"), self)
         self.alignMapper.setMapping(self.alignBottomAct, Qt.AlignBottom)
         self.alignBottomAct.triggered.connect(self.alignMapper.map)
         
@@ -525,19 +524,27 @@
             if alignment == Qt.AlignLeft:
                 xOffset = rect.x() - itemrect.x()
             elif alignment == Qt.AlignRight:
-                xOffset = (rect.x() + rect.width()) - \
-                          (itemrect.x() + itemrect.width())
+                xOffset = (
+                    (rect.x() + rect.width()) -
+                    (itemrect.x() + itemrect.width())
+                )
             elif alignment == Qt.AlignHCenter:
-                xOffset = (rect.x() + rect.width() // 2) - \
-                          (itemrect.x() + itemrect.width() // 2)
+                xOffset = (
+                    (rect.x() + rect.width() // 2) -
+                    (itemrect.x() + itemrect.width() // 2)
+                )
             elif alignment == Qt.AlignTop:
                 yOffset = rect.y() - itemrect.y()
             elif alignment == Qt.AlignBottom:
-                yOffset = (rect.y() + rect.height()) - \
-                          (itemrect.y() + itemrect.height())
+                yOffset = (
+                    (rect.y() + rect.height()) -
+                    (itemrect.y() + itemrect.height())
+                )
             elif alignment == Qt.AlignVCenter:
-                yOffset = (rect.y() + rect.height() // 2) - \
-                          (itemrect.y() + itemrect.height() // 2)
+                yOffset = (
+                    (rect.y() + rect.height() // 2) -
+                    (itemrect.y() + itemrect.height() // 2)
+                )
             item.moveBy(xOffset, yOffset)
         
         self.scene().update()
@@ -602,10 +609,7 @@
         @param evt reference to the wheel event (QWheelEvent)
         """
         if evt.modifiers() & Qt.ControlModifier:
-            if qVersionTuple() >= (5, 0, 0):
-                delta = evt.angleDelta().y()
-            else:
-                delta = evt.delta()
+            delta = evt.angleDelta().y()
             if delta < 0:
                 self.zoomOut()
             elif delta > 0:
@@ -752,9 +756,10 @@
                 except ValueError:
                     return False, linenum
             elif key == "association":
-                srcId, dstId, assocType, topToBottom = \
+                srcId, dstId, assocType, topToBottom = (
                     AssociationItem.parseAssociationItemDataString(
                         value.strip())
+                )
                 assoc = AssociationItem(umlItems[srcId], umlItems[dstId],
                                         assocType, topToBottom)
                 self.scene().addItem(assoc)

eric ide

mercurial