19 """ |
19 """ |
20 def __init__(self, name, classlist=None): |
20 def __init__(self, name, classlist=None): |
21 """ |
21 """ |
22 Constructor |
22 Constructor |
23 |
23 |
24 @param name the module name (string) |
24 @param name the module name |
25 @param classlist list of class names (list of strings) |
25 @type str |
|
26 @param classlist list of class names |
|
27 @type list of str |
26 """ |
28 """ |
27 super().__init__(name) |
29 super().__init__(name) |
28 |
30 |
29 self.classlist = [] if classlist is None else classlist[:] |
31 self.classlist = [] if classlist is None else classlist[:] |
30 |
32 |
31 def addClass(self, classname): |
33 def addClass(self, classname): |
32 """ |
34 """ |
33 Public method to add a class to the module model. |
35 Public method to add a class to the module model. |
34 |
36 |
35 @param classname class name to be added (string) |
37 @param classname class name to be added |
|
38 @type str |
36 """ |
39 """ |
37 self.classlist.append(classname) |
40 self.classlist.append(classname) |
38 |
41 |
39 def getClasses(self): |
42 def getClasses(self): |
40 """ |
43 """ |
41 Public method to retrieve the classes of the module. |
44 Public method to retrieve the classes of the module. |
42 |
45 |
43 @return list of class names (list of strings) |
46 @return list of class names |
|
47 @rtype list of str |
44 """ |
48 """ |
45 return self.classlist[:] |
49 return self.classlist[:] |
46 |
50 |
47 |
51 |
48 class ModuleItem(UMLItem): |
52 class ModuleItem(UMLItem): |
122 |
126 |
123 def setModel(self, model): |
127 def setModel(self, model): |
124 """ |
128 """ |
125 Public method to set the module model. |
129 Public method to set the module model. |
126 |
130 |
127 @param model module model containing the module data (ModuleModel) |
131 @param model module model containing the module data |
|
132 @type ModuleModel |
128 """ |
133 """ |
129 self.scene().removeItem(self.header) |
134 self.scene().removeItem(self.header) |
130 self.header = None |
135 self.header = None |
131 if self.classes: |
136 if self.classes: |
132 self.scene().removeItem(self.classes) |
137 self.scene().removeItem(self.classes) |
137 |
142 |
138 def paint(self, painter, option, widget=None): |
143 def paint(self, painter, option, widget=None): |
139 """ |
144 """ |
140 Public method to paint the item in local coordinates. |
145 Public method to paint the item in local coordinates. |
141 |
146 |
142 @param painter reference to the painter object (QPainter) |
147 @param painter reference to the painter object |
143 @param option style options (QStyleOptionGraphicsItem) |
148 @type QPainter |
144 @param widget optional reference to the widget painted on (QWidget) |
149 @param option style options |
|
150 @type QStyleOptionGraphicsItem |
|
151 @param widget optional reference to the widget painted on |
|
152 @type QWidget |
145 """ |
153 """ |
146 pen = self.pen() |
154 pen = self.pen() |
147 if ( |
155 if ( |
148 (option.state & QStyle.StateFlag.State_Selected) == |
156 (option.state & QStyle.StateFlag.State_Selected) == |
149 QStyle.State(QStyle.StateFlag.State_Selected) |
157 QStyle.State(QStyle.StateFlag.State_Selected) |
173 |
181 |
174 This string must start with ", " and should be built like |
182 This string must start with ", " and should be built like |
175 "attribute=value" with pairs separated by ", ". value must not |
183 "attribute=value" with pairs separated by ", ". value must not |
176 contain ", " or newlines. |
184 contain ", " or newlines. |
177 |
185 |
178 @return persistence data (string) |
186 @return persistence data |
|
187 @rtype str |
179 """ |
188 """ |
180 entries = [ |
189 entries = [ |
181 "name={0}".format(self.model.getName()), |
190 "name={0}".format(self.model.getName()), |
182 ] |
191 ] |
183 classes = self.model.getClasses() |
192 classes = self.model.getClasses() |
188 |
197 |
189 def parseItemDataString(self, version, data): |
198 def parseItemDataString(self, version, data): |
190 """ |
199 """ |
191 Public method to parse the given persistence data. |
200 Public method to parse the given persistence data. |
192 |
201 |
193 @param version version of the data (string) |
202 @param version version of the data |
194 @param data persisted data to be parsed (string) |
203 @type str |
195 @return flag indicating success (boolean) |
204 @param data persisted data to be parsed |
|
205 @type str |
|
206 @return flag indicating success |
|
207 @rtype bool |
196 """ |
208 """ |
197 parts = data.split(", ") |
209 parts = data.split(", ") |
198 if len(parts) < 1: |
210 if len(parts) < 1: |
199 return False |
211 return False |
200 |
212 |