Graphics/UMLItem.py

changeset 3591
2f2a4a76dd22
parent 3178
f25fc1364c88
child 3621
15f23ed3f216
equal deleted inserted replaced
3590:5280e37405b8 3591:2f2a4a76dd22
27 """ 27 """
28 self.name = name 28 self.name = name
29 29
30 def getName(self): 30 def getName(self):
31 """ 31 """
32 Method to retrieve the model name. 32 Public method to retrieve the model name.
33 33
34 @return model name (string) 34 @return model name (string)
35 """ 35 """
36 return self.name 36 return self.name
37 37
76 # only available for Qt 4.6.0 and newer 76 # only available for Qt 4.6.0 and newer
77 pass 77 pass
78 78
79 def getName(self): 79 def getName(self):
80 """ 80 """
81 Method to retrieve the item name. 81 Public method to retrieve the item name.
82 82
83 @return item name (string) 83 @return item name (string)
84 """ 84 """
85 if self.model: 85 if self.model:
86 return self.model.name 86 return self.model.name
98 rect.setSize(QSizeF(width, height)) 98 rect.setSize(QSizeF(width, height))
99 self.setRect(rect) 99 self.setRect(rect)
100 100
101 def addAssociation(self, assoc): 101 def addAssociation(self, assoc):
102 """ 102 """
103 Method to add an association to this widget. 103 Public method to add an association to this widget.
104 104
105 @param assoc association to be added (AssociationWidget) 105 @param assoc association to be added (AssociationWidget)
106 """ 106 """
107 if assoc and not assoc in self.associations: 107 if assoc and not assoc in self.associations:
108 self.associations.append(assoc) 108 self.associations.append(assoc)
109 109
110 def removeAssociation(self, assoc): 110 def removeAssociation(self, assoc):
111 """ 111 """
112 Method to remove an association to this widget. 112 Public method to remove an association to this widget.
113 113
114 @param assoc association to be removed (AssociationWidget) 114 @param assoc association to be removed (AssociationWidget)
115 """ 115 """
116 if assoc and assoc in self.associations: 116 if assoc and assoc in self.associations:
117 self.associations.remove(assoc) 117 self.associations.remove(assoc)
118 118
119 def removeAssociations(self): 119 def removeAssociations(self):
120 """ 120 """
121 Method to remove all associations of this widget. 121 Public method to remove all associations of this widget.
122 """ 122 """
123 for assoc in self.associations[:]: 123 for assoc in self.associations[:]:
124 assoc.unassociate() 124 assoc.unassociate()
125 assoc.hide() 125 assoc.hide()
126 del assoc 126 del assoc
127 127
128 def adjustAssociations(self): 128 def adjustAssociations(self):
129 """ 129 """
130 Method to adjust the associations to widget movements. 130 Public method to adjust the associations to widget movements.
131 """ 131 """
132 if self.shouldAdjustAssociations: 132 if self.shouldAdjustAssociations:
133 for assoc in self.associations: 133 for assoc in self.associations:
134 assoc.widgetMoved() 134 assoc.widgetMoved()
135 self.shouldAdjustAssociations = False 135 self.shouldAdjustAssociations = False
136 136
137 def moveBy(self, dx, dy): 137 def moveBy(self, dx, dy):
138 """ 138 """
139 Overriden method to move the widget relative. 139 Public overriden method to move the widget relative.
140 140
141 @param dx relative movement in x-direction (float) 141 @param dx relative movement in x-direction (float)
142 @param dy relative movement in y-direction (float) 142 @param dy relative movement in y-direction (float)
143 """ 143 """
144 super(UMLItem, self).moveBy(dx, dy) 144 super(UMLItem, self).moveBy(dx, dy)
145 self.adjustAssociations() 145 self.adjustAssociations()
146 146
147 def setPos(self, x, y): 147 def setPos(self, x, y):
148 """ 148 """
149 Overriden method to set the items position. 149 Public overriden method to set the items position.
150 150
151 @param x absolute x-position (float) 151 @param x absolute x-position (float)
152 @param y absolute y-position (float) 152 @param y absolute y-position (float)
153 """ 153 """
154 super(UMLItem, self).setPos(x, y) 154 super(UMLItem, self).setPos(x, y)
155 self.adjustAssociations() 155 self.adjustAssociations()
156 156
157 def itemChange(self, change, value): 157 def itemChange(self, change, value):
158 """ 158 """
159 Protected method called when an items state changes. 159 Public method called when an items state changes.
160 160
161 @param change the item's change (QGraphicsItem.GraphicsItemChange) 161 @param change the item's change (QGraphicsItem.GraphicsItemChange)
162 @param value the value of the change 162 @param value the value of the change
163 @return adjusted values 163 @return adjusted values
164 """ 164 """

eric ide

mercurial