10 import enum |
10 import enum |
11 |
11 |
12 from PyQt6.QtCore import QPointF, QRectF, QLineF |
12 from PyQt6.QtCore import QPointF, QRectF, QLineF |
13 from PyQt6.QtWidgets import QGraphicsItem |
13 from PyQt6.QtWidgets import QGraphicsItem |
14 |
14 |
15 from E5Graphics.E5ArrowItem import E5ArrowItem, E5ArrowType |
15 from EricGraphics.EricArrowItem import EricArrowItem, EricArrowType |
16 |
16 |
17 import Utilities |
17 import Utilities |
18 |
18 |
19 |
19 |
20 class AssociationType(enum.Enum): |
20 class AssociationType(enum.Enum): |
67 @type tuple of (QColor, QColor) |
67 @type tuple of (QColor, QColor) |
68 @param parent reference to the parent object |
68 @param parent reference to the parent object |
69 @type QGraphicsItem |
69 @type QGraphicsItem |
70 """ |
70 """ |
71 if assocType in (AssociationType.NORMAL, AssociationType.IMPORTS): |
71 if assocType in (AssociationType.NORMAL, AssociationType.IMPORTS): |
72 arrowType = E5ArrowType.NORMAL |
72 arrowType = EricArrowType.NORMAL |
73 arrowFilled = True |
73 arrowFilled = True |
74 elif assocType == AssociationType.GENERALISATION: |
74 elif assocType == AssociationType.GENERALISATION: |
75 arrowType = E5ArrowType.WIDE |
75 arrowType = EricArrowType.WIDE |
76 arrowFilled = False |
76 arrowFilled = False |
77 |
77 |
78 E5ArrowItem.__init__(self, QPointF(0, 0), QPointF(100, 100), |
78 EricArrowItem.__init__(self, QPointF(0, 0), QPointF(100, 100), |
79 arrowFilled, arrowType, colors, parent) |
79 arrowFilled, arrowType, colors, parent) |
80 |
80 |
81 self.setFlag(QGraphicsItem.GraphicsItemFlag.ItemIsMovable, False) |
81 self.setFlag(QGraphicsItem.GraphicsItemFlag.ItemIsMovable, False) |
82 self.setFlag(QGraphicsItem.GraphicsItemFlag.ItemIsSelectable, False) |
82 self.setFlag(QGraphicsItem.GraphicsItemFlag.ItemIsSelectable, False) |
83 |
83 |
553 Public method to unassociate from the widgets. |
553 Public method to unassociate from the widgets. |
554 """ |
554 """ |
555 self.itemA.removeAssociation(self) |
555 self.itemA.removeAssociation(self) |
556 self.itemB.removeAssociation(self) |
556 self.itemB.removeAssociation(self) |
557 |
557 |
558 def buildAssociationItemDataString(self): |
|
559 """ |
|
560 Public method to build a string to persist the specific item data. |
|
561 |
|
562 This string should be built like "attribute=value" with pairs separated |
|
563 by ", ". value must not contain ", " or newlines. |
|
564 |
|
565 @return persistence data |
|
566 @rtype str |
|
567 """ |
|
568 entries = [ |
|
569 "src={0}".format(self.itemA.getId()), |
|
570 "dst={0}".format(self.itemB.getId()), |
|
571 "type={0}".format(self.assocType.value), |
|
572 "topToBottom={0}".format(self.topToBottom) |
|
573 ] |
|
574 return ", ".join(entries) |
|
575 |
|
576 @classmethod |
558 @classmethod |
577 def parseAssociationItemDataString(cls, data): |
559 def parseAssociationItemDataString(cls, data): |
578 """ |
560 """ |
579 Class method to parse the given persistence data. |
561 Class method to parse the given persistence data. |
580 |
562 |