8 """ |
8 """ |
9 |
9 |
10 from PyQt4.QtGui import QFont, QGraphicsSimpleTextItem, QStyle |
10 from PyQt4.QtGui import QFont, QGraphicsSimpleTextItem, QStyle |
11 |
11 |
12 from .UMLItem import UMLItem |
12 from .UMLItem import UMLItem |
|
13 |
|
14 import Utilities |
13 |
15 |
14 |
16 |
15 class ClassModel(object): |
17 class ClassModel(object): |
16 """ |
18 """ |
17 Class implementing the class model. |
19 Class implementing the class model. |
240 if methods: |
242 if methods: |
241 entries.append("methods={0}".format("||".join(methods))) |
243 entries.append("methods={0}".format("||".join(methods))) |
242 |
244 |
243 return ", " + ", ".join(entries) |
245 return ", " + ", ".join(entries) |
244 |
246 |
245 def parseItemDataString(self, data): |
247 def parseItemDataString(self, version, data): |
246 """ |
248 """ |
247 Public method to parse the given persistence data. |
249 Public method to parse the given persistence data. |
248 |
250 |
|
251 @param version version of the data (string) |
249 @param data persisted data to be parsed (string) |
252 @param data persisted data to be parsed (string) |
250 """ |
253 @return flag indicating success (boolean) |
251 # TODO: implement this |
254 """ |
|
255 parts = data.split(", ") |
|
256 if len(parts) < 3: |
|
257 return False |
|
258 |
|
259 name = "" |
|
260 attributes = [] |
|
261 methods = [] |
|
262 |
|
263 for part in parts: |
|
264 key, value = part.split("=", 1) |
|
265 if key == "is_external": |
|
266 self.external = Utilities.toBool(value.strip()) |
|
267 elif key == "no_attributes": |
|
268 self.noAttrs = Utilities.toBool(value.strip()) |
|
269 elif key == "name": |
|
270 name = value.strip() |
|
271 elif key == "attributes": |
|
272 attributes = value.strip().split("||") |
|
273 elif key == "methods": |
|
274 methods = value.strip().split("||") |
|
275 else: |
|
276 return False |
|
277 |
|
278 self.model = ClassModel(name, methods, attributes) |
|
279 self.__createTexts() |
|
280 self.__calculateSize() |
|
281 |
|
282 return True |