444 """ |
444 """ |
445 return { |
445 return { |
446 "project_name": self.project.getProjectName(), |
446 "project_name": self.project.getProjectName(), |
447 "no_modules": self.noModules, |
447 "no_modules": self.noModules, |
448 } |
448 } |
|
449 |
|
450 def fromDict(self, version, data): |
|
451 """ |
|
452 Public method to populate the class with data persisted by 'toDict()'. |
|
453 |
|
454 @param version version of the data |
|
455 @type str |
|
456 @param data dictionary containing the persisted data |
|
457 @type dict |
|
458 @return tuple containing a flag indicating success and an info |
|
459 message in case the diagram belongs to a different project |
|
460 @rtype tuple of (bool, str) |
|
461 """ |
|
462 try: |
|
463 self.noModules = data["no_modules"] |
|
464 |
|
465 if data["project_name"] != self.project.getProjectName(): |
|
466 msg = self.tr( |
|
467 "<p>The diagram belongs to project <b>{0}</b>." |
|
468 " Please open it and try again.</p>" |
|
469 ).format(data["project_name"]) |
|
470 return False, msg |
|
471 except KeyError: |
|
472 return False, "" |
|
473 |
|
474 self.initialize() |
|
475 |
|
476 return True, "" |