7 Module implementing a package item. |
7 Module implementing a package item. |
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 UMLModel, UMLItem |
13 |
13 |
14 import Utilities |
14 import Utilities |
15 |
15 |
16 |
16 |
17 class PackageModel(object): |
17 class PackageModel(UMLModel): |
18 """ |
18 """ |
19 Class implementing the package model. |
19 Class implementing the package model. |
20 """ |
20 """ |
21 def __init__(self, name, moduleslist=[]): |
21 def __init__(self, name, moduleslist=[]): |
22 """ |
22 """ |
23 Constructor |
23 Constructor |
24 |
24 |
25 @param name package name (string) |
25 @param name package name (string) |
26 @param moduleslist list of module names (list of strings) |
26 @param moduleslist list of module names (list of strings) |
27 """ |
27 """ |
28 self.name = name |
28 super().__init__(name) |
|
29 |
29 self.moduleslist = moduleslist |
30 self.moduleslist = moduleslist |
30 |
31 |
31 def addModule(self, modulename): |
32 def addModule(self, modulename): |
32 """ |
33 """ |
33 Method to add a module to the package model. |
34 Method to add a module to the package model. |
34 |
35 |
35 @param modulename module name to be added (string) |
36 @param modulename module name to be added (string) |
36 """ |
37 """ |
37 self.moduleslist.append(modulename) |
38 self.moduleslist.append(modulename) |
38 |
39 |
39 def getModules(self): |
40 def getModules(self): |
40 """ |
41 """ |
41 Method to retrieve the modules of the package. |
42 Method to retrieve the modules of the package. |
42 |
43 |
43 @return list of module names (list of strings) |
44 @return list of module names (list of strings) |
44 """ |
45 """ |
45 return self.moduleslist[:] |
46 return self.moduleslist[:] |
46 |
47 |
47 def getName(self): |
|
48 """ |
|
49 Method to retrieve the package name. |
|
50 |
|
51 @return package name (string) |
|
52 """ |
|
53 return self.name |
|
54 |
|
55 |
48 |
56 class PackageItem(UMLItem): |
49 class PackageItem(UMLItem): |
57 """ |
50 """ |
58 Class implementing a package item. |
51 Class implementing a package item. |
59 """ |
52 """ |
62 def __init__(self, model=None, x=0, y=0, rounded=False, |
55 def __init__(self, model=None, x=0, y=0, rounded=False, |
63 noModules=False, parent=None, scene=None): |
56 noModules=False, parent=None, scene=None): |
64 """ |
57 """ |
65 Constructor |
58 Constructor |
66 |
59 |
67 @param model module model containing the module data (ModuleModel) |
60 @param model package model containing the package data (PackageModel) |
68 @param x x-coordinate (integer) |
61 @param x x-coordinate (integer) |
69 @param y y-coordinate (integer) |
62 @param y y-coordinate (integer) |
70 @param rounded flag indicating a rounded corner (boolean) |
63 @param rounded flag indicating a rounded corner (boolean) |
71 @keyparam noModules flag indicating, that no module names should be |
64 @keyparam noModules flag indicating, that no module names should be |
72 shown (boolean) |
65 shown (boolean) |
73 @keyparam parent reference to the parent object (QGraphicsItem) |
66 @keyparam parent reference to the parent object (QGraphicsItem) |
74 @keyparam scene reference to the scene object (QGraphicsScene) |
67 @keyparam scene reference to the scene object (QGraphicsScene) |
75 """ |
68 """ |
76 UMLItem.__init__(self, x, y, rounded, parent) |
69 UMLItem.__init__(self, model, x, y, rounded, parent) |
77 self.model = model |
|
78 self.noModules = noModules |
70 self.noModules = noModules |
79 |
71 |
80 scene.addItem(self) |
72 scene.addItem(self) |
81 |
73 |
82 if self.model: |
74 if self.model: |