21 """ |
21 """ |
22 def __init__(self, name, moduleslist=None): |
22 def __init__(self, name, moduleslist=None): |
23 """ |
23 """ |
24 Constructor |
24 Constructor |
25 |
25 |
26 @param name package name (string) |
26 @param name package name |
27 @param moduleslist list of module names (list of strings) |
27 @type str |
|
28 @param moduleslist list of module names |
|
29 @type list of str |
28 """ |
30 """ |
29 super().__init__(name) |
31 super().__init__(name) |
30 |
32 |
31 self.moduleslist = [] if moduleslist is None else moduleslist[:] |
33 self.moduleslist = [] if moduleslist is None else moduleslist[:] |
32 |
34 |
33 def addModule(self, modulename): |
35 def addModule(self, modulename): |
34 """ |
36 """ |
35 Public method to add a module to the package model. |
37 Public method to add a module to the package model. |
36 |
38 |
37 @param modulename module name to be added (string) |
39 @param modulename module name to be added |
|
40 @type str |
38 """ |
41 """ |
39 self.moduleslist.append(modulename) |
42 self.moduleslist.append(modulename) |
40 |
43 |
41 def getModules(self): |
44 def getModules(self): |
42 """ |
45 """ |
43 Public method to retrieve the modules of the package. |
46 Public method to retrieve the modules of the package. |
44 |
47 |
45 @return list of module names (list of strings) |
48 @return list of module names |
|
49 @rtype list of str |
46 """ |
50 """ |
47 return self.moduleslist[:] |
51 return self.moduleslist[:] |
48 |
52 |
49 |
53 |
50 class PackageItem(UMLItem): |
54 class PackageItem(UMLItem): |
145 |
149 |
146 def setModel(self, model): |
150 def setModel(self, model): |
147 """ |
151 """ |
148 Public method to set the package model. |
152 Public method to set the package model. |
149 |
153 |
150 @param model package model containing the package data (PackageModel) |
154 @param model package model containing the package data |
|
155 @type PackageModel |
151 """ |
156 """ |
152 self.scene().removeItem(self.header) |
157 self.scene().removeItem(self.header) |
153 self.header = None |
158 self.header = None |
154 if self.modules: |
159 if self.modules: |
155 self.scene().removeItem(self.modules) |
160 self.scene().removeItem(self.modules) |
160 |
165 |
161 def paint(self, painter, option, widget=None): |
166 def paint(self, painter, option, widget=None): |
162 """ |
167 """ |
163 Public method to paint the item in local coordinates. |
168 Public method to paint the item in local coordinates. |
164 |
169 |
165 @param painter reference to the painter object (QPainter) |
170 @param painter reference to the painter object |
166 @param option style options (QStyleOptionGraphicsItem) |
171 @type QPainter |
167 @param widget optional reference to the widget painted on (QWidget) |
172 @param option style options |
|
173 @type QStyleOptionGraphicsItem |
|
174 @param widget optional reference to the widget painted on |
|
175 @type QWidget |
168 """ |
176 """ |
169 pen = self.pen() |
177 pen = self.pen() |
170 if ( |
178 if ( |
171 (option.state & QStyle.StateFlag.State_Selected) == |
179 (option.state & QStyle.StateFlag.State_Selected) == |
172 QStyle.State(QStyle.StateFlag.State_Selected) |
180 QStyle.State(QStyle.StateFlag.State_Selected) |
199 |
207 |
200 This string must start with ", " and should be built like |
208 This string must start with ", " and should be built like |
201 "attribute=value" with pairs separated by ", ". value must not |
209 "attribute=value" with pairs separated by ", ". value must not |
202 contain ", " or newlines. |
210 contain ", " or newlines. |
203 |
211 |
204 @return persistence data (string) |
212 @return persistence data |
|
213 @rtype str |
205 """ |
214 """ |
206 entries = [ |
215 entries = [ |
207 "no_modules={0}".format(self.noModules), |
216 "no_modules={0}".format(self.noModules), |
208 "name={0}".format(self.model.getName()), |
217 "name={0}".format(self.model.getName()), |
209 ] |
218 ] |
215 |
224 |
216 def parseItemDataString(self, version, data): |
225 def parseItemDataString(self, version, data): |
217 """ |
226 """ |
218 Public method to parse the given persistence data. |
227 Public method to parse the given persistence data. |
219 |
228 |
220 @param version version of the data (string) |
229 @param version version of the data |
221 @param data persisted data to be parsed (string) |
230 @type str |
222 @return flag indicating success (boolean) |
231 @param data persisted data to be parsed |
|
232 @type str |
|
233 @return flag indicating success |
|
234 @rtype bool |
223 """ |
235 """ |
224 parts = data.split(", ") |
236 parts = data.split(", ") |
225 if len(parts) < 2: |
237 if len(parts) < 2: |
226 return False |
238 return False |
227 |
239 |