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 """ |