7 Module implementing a module item. |
7 Module implementing a module 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 |
14 |
15 class ModuleModel(object): |
15 class ModuleModel(UMLModel): |
16 """ |
16 """ |
17 Class implementing the module model. |
17 Class implementing the module model. |
18 """ |
18 """ |
19 def __init__(self, name, classlist=[]): |
19 def __init__(self, name, classlist=[]): |
20 """ |
20 """ |
21 Constructor |
21 Constructor |
22 |
22 |
23 @param name the module name (string) |
23 @param name the module name (string) |
24 @param classlist list of class names (list of strings) |
24 @param classlist list of class names (list of strings) |
25 """ |
25 """ |
26 self.name = name |
26 super().__init__(name) |
|
27 |
27 self.classlist = classlist |
28 self.classlist = classlist |
28 |
29 |
29 def addClass(self, classname): |
30 def addClass(self, classname): |
30 """ |
31 """ |
31 Method to add a class to the module model. |
32 Method to add a class to the module model. |
32 |
33 |
33 @param classname class name to be added (string) |
34 @param classname class name to be added (string) |
34 """ |
35 """ |
35 self.classlist.append(classname) |
36 self.classlist.append(classname) |
36 |
37 |
37 def getClasses(self): |
38 def getClasses(self): |
38 """ |
39 """ |
39 Method to retrieve the classes of the module. |
40 Method to retrieve the classes of the module. |
40 |
41 |
41 @return list of class names (list of strings) |
42 @return list of class names (list of strings) |
42 """ |
43 """ |
43 return self.classlist[:] |
44 return self.classlist[:] |
44 |
45 |
45 def getName(self): |
|
46 """ |
|
47 Method to retrieve the module name. |
|
48 |
|
49 @return module name (string) |
|
50 """ |
|
51 return self.name |
|
52 |
|
53 |
46 |
54 class ModuleItem(UMLItem): |
47 class ModuleItem(UMLItem): |
55 """ |
48 """ |
56 Class implementing a module item. |
49 Class implementing a module item. |
57 """ |
50 """ |
67 @param y y-coordinate (integer) |
60 @param y y-coordinate (integer) |
68 @keyparam rounded flag indicating a rounded corner (boolean) |
61 @keyparam rounded flag indicating a rounded corner (boolean) |
69 @keyparam parent reference to the parent object (QGraphicsItem) |
62 @keyparam parent reference to the parent object (QGraphicsItem) |
70 @keyparam scene reference to the scene object (QGraphicsScene) |
63 @keyparam scene reference to the scene object (QGraphicsScene) |
71 """ |
64 """ |
72 UMLItem.__init__(self, x, y, rounded, parent) |
65 UMLItem.__init__(self, model, x, y, rounded, parent) |
73 self.model = model |
|
74 |
66 |
75 scene.addItem(self) |
67 scene.addItem(self) |
76 |
68 |
77 if self.model: |
69 if self.model: |
78 self.__createTexts() |
70 self.__createTexts() |