eric6/Graphics/ClassItem.py

Wed, 30 Dec 2020 11:00:44 +0100

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Wed, 30 Dec 2020 11:00:44 +0100
branch
maintenance
changeset 7924
8a96736d465e
parent 7780
41420f82c0ac
child 8143
2c730d5fd177
permissions
-rw-r--r--

Updated copyright for 2021.

0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1 # -*- coding: utf-8 -*-
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
2
7924
8a96736d465e Updated copyright for 2021.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7780
diff changeset
3 # Copyright (c) 2007 - 2021 Detlev Offenbach <detlev@die-offenbachs.de>
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
4 #
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
5
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
6 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
7 Module implementing an UML like class item.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
8 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
9
3656
441956d8fce5 Started porting eric5 to PyQt5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3591
diff changeset
10 from PyQt5.QtGui import QFont
441956d8fce5 Started porting eric5 to PyQt5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3591
diff changeset
11 from PyQt5.QtWidgets import QGraphicsSimpleTextItem, QStyle
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
12
2039
fa41ccd7f7bc Added the capability to rebuild a diagram without losing the current item positions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2034
diff changeset
13 from .UMLItem import UMLModel, UMLItem
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
14
2034
8de0fc1f7fef Implemented functions to load UML graphics from disc.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2033
diff changeset
15 import Utilities
8de0fc1f7fef Implemented functions to load UML graphics from disc.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2033
diff changeset
16
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 791
diff changeset
17
2039
fa41ccd7f7bc Added the capability to rebuild a diagram without losing the current item positions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2034
diff changeset
18 class ClassModel(UMLModel):
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
19 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
20 Class implementing the class model.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
21 """
5651
982465f8389c Fixed a few code style issues related to the usage of mutable types for default arguments.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
22 def __init__(self, name, methods=None, attributes=None):
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
23 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
24 Constructor
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
25
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
26 @param name the class name (string)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
27 @param methods list of method names of the class
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
28 (list of strings)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
29 @param attributes list of attribute names of the class
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
30 (list of strings)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
31 """
2525
8b507a9a2d40 Script changes: Future import added, super calls modified and unicode behavior for str.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 2302
diff changeset
32 super(ClassModel, self).__init__(name)
2039
fa41ccd7f7bc Added the capability to rebuild a diagram without losing the current item positions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2034
diff changeset
33
5651
982465f8389c Fixed a few code style issues related to the usage of mutable types for default arguments.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
34 self.methods = [] if methods is None else methods[:]
982465f8389c Fixed a few code style issues related to the usage of mutable types for default arguments.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
35 self.attributes = [] if attributes is None else attributes[:]
2039
fa41ccd7f7bc Added the capability to rebuild a diagram without losing the current item positions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2034
diff changeset
36
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
37 def addMethod(self, method):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
38 """
3591
2f2a4a76dd22 Corrected a bunch of source docu issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3178
diff changeset
39 Public method to add a method to the class model.
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
40
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
41 @param method method name to be added (string)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
42 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
43 self.methods.append(method)
2039
fa41ccd7f7bc Added the capability to rebuild a diagram without losing the current item positions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2034
diff changeset
44
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
45 def addAttribute(self, attribute):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
46 """
3591
2f2a4a76dd22 Corrected a bunch of source docu issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3178
diff changeset
47 Public method to add an attribute to the class model.
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
48
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
49 @param attribute attribute name to be added (string)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
50 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
51 self.attributes.append(attribute)
2039
fa41ccd7f7bc Added the capability to rebuild a diagram without losing the current item positions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2034
diff changeset
52
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
53 def getMethods(self):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
54 """
3591
2f2a4a76dd22 Corrected a bunch of source docu issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3178
diff changeset
55 Public method to retrieve the methods of the class.
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
56
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
57 @return list of class methods (list of strings)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
58 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
59 return self.methods[:]
2039
fa41ccd7f7bc Added the capability to rebuild a diagram without losing the current item positions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2034
diff changeset
60
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
61 def getAttributes(self):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
62 """
3591
2f2a4a76dd22 Corrected a bunch of source docu issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3178
diff changeset
63 Public method to retrieve the attributes of the class.
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
64
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
65 @return list of class attributes (list of strings)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
66 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
67 return self.attributes[:]
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
68
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 791
diff changeset
69
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
70 class ClassItem(UMLItem):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
71 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
72 Class implementing an UML like class item.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
73 """
2032
704593d042fe Introduced the ItemType class variable for the various UML graphics items.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2030
diff changeset
74 ItemType = "class"
704593d042fe Introduced the ItemType class variable for the various UML graphics items.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2030
diff changeset
75
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 791
diff changeset
76 def __init__(self, model=None, external=False, x=0, y=0,
7529
2b8a0d8ba12a UML Diagrams: added support for dark color scheme.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
77 rounded=False, noAttrs=False, colors=None, parent=None,
2b8a0d8ba12a UML Diagrams: added support for dark color scheme.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
78 scene=None):
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
79 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
80 Constructor
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
81
7529
2b8a0d8ba12a UML Diagrams: added support for dark color scheme.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
82 @param model class model containing the class data
2b8a0d8ba12a UML Diagrams: added support for dark color scheme.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
83 @type ClassModel
2992
dbdf27746da5 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
84 @param external flag indicating a class defined outside our scope
7529
2b8a0d8ba12a UML Diagrams: added support for dark color scheme.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
85 @type boolean
2b8a0d8ba12a UML Diagrams: added support for dark color scheme.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
86 @param x x-coordinate
2b8a0d8ba12a UML Diagrams: added support for dark color scheme.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
87 @type int
2b8a0d8ba12a UML Diagrams: added support for dark color scheme.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
88 @param y y-coordinate
2b8a0d8ba12a UML Diagrams: added support for dark color scheme.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
89 @type int
2b8a0d8ba12a UML Diagrams: added support for dark color scheme.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
90 @param rounded flag indicating a rounded corner
2b8a0d8ba12a UML Diagrams: added support for dark color scheme.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
91 @type bool
2b8a0d8ba12a UML Diagrams: added support for dark color scheme.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
92 @param noAttrs flag indicating, that no attributes should be shown
2b8a0d8ba12a UML Diagrams: added support for dark color scheme.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
93 @type bool
2b8a0d8ba12a UML Diagrams: added support for dark color scheme.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
94 @param colors tuple containing the foreground and background colors
2b8a0d8ba12a UML Diagrams: added support for dark color scheme.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
95 @type tuple of (QColor, QColor)
2b8a0d8ba12a UML Diagrams: added support for dark color scheme.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
96 @param parent reference to the parent object
2b8a0d8ba12a UML Diagrams: added support for dark color scheme.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
97 @type QGraphicsItem
2b8a0d8ba12a UML Diagrams: added support for dark color scheme.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
98 @param scene reference to the scene object
2b8a0d8ba12a UML Diagrams: added support for dark color scheme.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
99 @type QGraphicsScene
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
100 """
7529
2b8a0d8ba12a UML Diagrams: added support for dark color scheme.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
101 UMLItem.__init__(self, model, x, y, rounded, colors, parent)
2039
fa41ccd7f7bc Added the capability to rebuild a diagram without losing the current item positions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2034
diff changeset
102
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
103 self.external = external
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
104 self.noAttrs = noAttrs
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
105
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
106 scene.addItem(self)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
107
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
108 if self.model:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
109 self.__createTexts()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
110 self.__calculateSize()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
111
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
112 def __createTexts(self):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
113 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
114 Private method to create the text items of the class item.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
115 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
116 if self.model is None:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
117 return
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
118
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
119 boldFont = QFont(self.font)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
120 boldFont.setBold(True)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
121
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
122 attrs = self.model.getAttributes()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
123 meths = self.model.getMethods()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
124
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
125 x = self.margin + self.rect().x()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
126 y = self.margin + self.rect().y()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
127 self.header = QGraphicsSimpleTextItem(self)
7529
2b8a0d8ba12a UML Diagrams: added support for dark color scheme.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
128 self.header.setBrush(self._colors[0])
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
129 self.header.setFont(boldFont)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
130 self.header.setText(self.model.getName())
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
131 self.header.setPos(x, y)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
132 y += self.header.boundingRect().height() + self.margin
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
133 if not self.noAttrs and not self.external:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
134 if attrs:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
135 txt = "\n".join(attrs)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
136 else:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
137 txt = " "
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
138 self.attrs = QGraphicsSimpleTextItem(self)
7529
2b8a0d8ba12a UML Diagrams: added support for dark color scheme.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
139 self.attrs.setBrush(self._colors[0])
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
140 self.attrs.setFont(self.font)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
141 self.attrs.setText(txt)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
142 self.attrs.setPos(x, y)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
143 y += self.attrs.boundingRect().height() + self.margin
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
144 else:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
145 self.attrs = None
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
146 if meths:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
147 txt = "\n".join(meths)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
148 else:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
149 txt = " "
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
150 self.meths = QGraphicsSimpleTextItem(self)
7529
2b8a0d8ba12a UML Diagrams: added support for dark color scheme.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
151 self.meths.setBrush(self._colors[0])
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
152 self.meths.setFont(self.font)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
153 self.meths.setText(txt)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
154 self.meths.setPos(x, y)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
155
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
156 def __calculateSize(self):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
157 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
158 Private method to calculate the size of the class item.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
159 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
160 if self.model is None:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
161 return
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
162
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
163 width = self.header.boundingRect().width()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
164 height = self.header.boundingRect().height()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
165 if self.attrs:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
166 width = max(width, self.attrs.boundingRect().width())
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
167 height = height + self.attrs.boundingRect().height() + self.margin
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
168 if self.meths:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
169 width = max(width, self.meths.boundingRect().width())
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
170 height = height + self.meths.boundingRect().height()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
171 self.setSize(width + 2 * self.margin, height + 2 * self.margin)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
172
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
173 def setModel(self, model):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
174 """
3591
2f2a4a76dd22 Corrected a bunch of source docu issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3178
diff changeset
175 Public method to set the class model.
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
176
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
177 @param model class model containing the class data (ClassModel)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
178 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
179 self.scene().removeItem(self.header)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
180 self.header = None
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
181 if self.attrs:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
182 self.scene().removeItem(self.attrs)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
183 self.attrs = None
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
184 if self.meths:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
185 self.scene().removeItem(self.meths)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
186 self.meths = None
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
187 self.model = model
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
188 self.__createTexts()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
189 self.__calculateSize()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
190
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 791
diff changeset
191 def paint(self, painter, option, widget=None):
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
192 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
193 Public method to paint the item in local coordinates.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
194
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
195 @param painter reference to the painter object (QPainter)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
196 @param option style options (QStyleOptionGraphicsItem)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
197 @param widget optional reference to the widget painted on (QWidget)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
198 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
199 pen = self.pen()
7254
f00d825fbdb3 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
200 if (
f00d825fbdb3 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
201 (option.state & QStyle.State_Selected) ==
f00d825fbdb3 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
202 QStyle.State(QStyle.State_Selected)
f00d825fbdb3 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
203 ):
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
204 pen.setWidth(2)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
205 else:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
206 pen.setWidth(1)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
207
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
208 painter.setPen(pen)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
209 painter.setBrush(self.brush())
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
210 painter.setFont(self.font)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
211
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
212 offsetX = self.rect().x()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
213 offsetY = self.rect().y()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
214 w = self.rect().width()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
215 h = self.rect().height()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
216
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
217 painter.drawRect(offsetX, offsetY, w, h)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
218 y = self.margin + self.header.boundingRect().height()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
219 painter.drawLine(offsetX, offsetY + y, offsetX + w - 1, offsetY + y)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
220 if self.attrs:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
221 y += self.margin + self.attrs.boundingRect().height()
2992
dbdf27746da5 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
222 painter.drawLine(offsetX, offsetY + y,
dbdf27746da5 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
223 offsetX + w - 1, offsetY + y)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
224
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
225 self.adjustAssociations()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
226
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
227 def isExternal(self):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
228 """
3591
2f2a4a76dd22 Corrected a bunch of source docu issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3178
diff changeset
229 Public method returning the external state.
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
230
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
231 @return external state (boolean)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
232 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
233 return self.external
2030
db11a2fe9bbc Implemented functions to save the UML graphics to disc.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
234
db11a2fe9bbc Implemented functions to save the UML graphics to disc.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
235 def buildItemDataString(self):
db11a2fe9bbc Implemented functions to save the UML graphics to disc.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
236 """
db11a2fe9bbc Implemented functions to save the UML graphics to disc.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
237 Public method to build a string to persist the specific item data.
db11a2fe9bbc Implemented functions to save the UML graphics to disc.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
238
db11a2fe9bbc Implemented functions to save the UML graphics to disc.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
239 This string must start with ", " and should be built like
2992
dbdf27746da5 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
240 "attribute=value" with pairs separated by ", ". value must not
dbdf27746da5 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
241 contain ", " or newlines.
2030
db11a2fe9bbc Implemented functions to save the UML graphics to disc.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
242
db11a2fe9bbc Implemented functions to save the UML graphics to disc.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
243 @return persistence data (string)
db11a2fe9bbc Implemented functions to save the UML graphics to disc.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
244 """
db11a2fe9bbc Implemented functions to save the UML graphics to disc.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
245 entries = [
db11a2fe9bbc Implemented functions to save the UML graphics to disc.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
246 "is_external={0}".format(self.external),
db11a2fe9bbc Implemented functions to save the UML graphics to disc.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
247 "no_attributes={0}".format(self.noAttrs),
db11a2fe9bbc Implemented functions to save the UML graphics to disc.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
248 "name={0}".format(self.model.getName()),
db11a2fe9bbc Implemented functions to save the UML graphics to disc.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
249 ]
db11a2fe9bbc Implemented functions to save the UML graphics to disc.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
250 attributes = self.model.getAttributes()
db11a2fe9bbc Implemented functions to save the UML graphics to disc.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
251 if attributes:
db11a2fe9bbc Implemented functions to save the UML graphics to disc.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
252 entries.append("attributes={0}".format("||".join(attributes)))
db11a2fe9bbc Implemented functions to save the UML graphics to disc.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
253 methods = self.model.getMethods()
db11a2fe9bbc Implemented functions to save the UML graphics to disc.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
254 if methods:
db11a2fe9bbc Implemented functions to save the UML graphics to disc.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
255 entries.append("methods={0}".format("||".join(methods)))
db11a2fe9bbc Implemented functions to save the UML graphics to disc.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
256
db11a2fe9bbc Implemented functions to save the UML graphics to disc.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
257 return ", " + ", ".join(entries)
db11a2fe9bbc Implemented functions to save the UML graphics to disc.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
258
2034
8de0fc1f7fef Implemented functions to load UML graphics from disc.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2033
diff changeset
259 def parseItemDataString(self, version, data):
2030
db11a2fe9bbc Implemented functions to save the UML graphics to disc.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
260 """
db11a2fe9bbc Implemented functions to save the UML graphics to disc.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
261 Public method to parse the given persistence data.
db11a2fe9bbc Implemented functions to save the UML graphics to disc.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
262
2034
8de0fc1f7fef Implemented functions to load UML graphics from disc.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2033
diff changeset
263 @param version version of the data (string)
2030
db11a2fe9bbc Implemented functions to save the UML graphics to disc.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
264 @param data persisted data to be parsed (string)
2034
8de0fc1f7fef Implemented functions to load UML graphics from disc.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2033
diff changeset
265 @return flag indicating success (boolean)
2030
db11a2fe9bbc Implemented functions to save the UML graphics to disc.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
266 """
2034
8de0fc1f7fef Implemented functions to load UML graphics from disc.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2033
diff changeset
267 parts = data.split(", ")
8de0fc1f7fef Implemented functions to load UML graphics from disc.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2033
diff changeset
268 if len(parts) < 3:
8de0fc1f7fef Implemented functions to load UML graphics from disc.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2033
diff changeset
269 return False
8de0fc1f7fef Implemented functions to load UML graphics from disc.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2033
diff changeset
270
8de0fc1f7fef Implemented functions to load UML graphics from disc.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2033
diff changeset
271 name = ""
8de0fc1f7fef Implemented functions to load UML graphics from disc.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2033
diff changeset
272 attributes = []
8de0fc1f7fef Implemented functions to load UML graphics from disc.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2033
diff changeset
273 methods = []
8de0fc1f7fef Implemented functions to load UML graphics from disc.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2033
diff changeset
274
8de0fc1f7fef Implemented functions to load UML graphics from disc.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2033
diff changeset
275 for part in parts:
8de0fc1f7fef Implemented functions to load UML graphics from disc.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2033
diff changeset
276 key, value = part.split("=", 1)
8de0fc1f7fef Implemented functions to load UML graphics from disc.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2033
diff changeset
277 if key == "is_external":
8de0fc1f7fef Implemented functions to load UML graphics from disc.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2033
diff changeset
278 self.external = Utilities.toBool(value.strip())
8de0fc1f7fef Implemented functions to load UML graphics from disc.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2033
diff changeset
279 elif key == "no_attributes":
8de0fc1f7fef Implemented functions to load UML graphics from disc.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2033
diff changeset
280 self.noAttrs = Utilities.toBool(value.strip())
8de0fc1f7fef Implemented functions to load UML graphics from disc.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2033
diff changeset
281 elif key == "name":
8de0fc1f7fef Implemented functions to load UML graphics from disc.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2033
diff changeset
282 name = value.strip()
8de0fc1f7fef Implemented functions to load UML graphics from disc.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2033
diff changeset
283 elif key == "attributes":
8de0fc1f7fef Implemented functions to load UML graphics from disc.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2033
diff changeset
284 attributes = value.strip().split("||")
8de0fc1f7fef Implemented functions to load UML graphics from disc.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2033
diff changeset
285 elif key == "methods":
8de0fc1f7fef Implemented functions to load UML graphics from disc.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2033
diff changeset
286 methods = value.strip().split("||")
8de0fc1f7fef Implemented functions to load UML graphics from disc.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2033
diff changeset
287 else:
8de0fc1f7fef Implemented functions to load UML graphics from disc.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2033
diff changeset
288 return False
8de0fc1f7fef Implemented functions to load UML graphics from disc.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2033
diff changeset
289
8de0fc1f7fef Implemented functions to load UML graphics from disc.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2033
diff changeset
290 self.model = ClassModel(name, methods, attributes)
8de0fc1f7fef Implemented functions to load UML graphics from disc.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2033
diff changeset
291 self.__createTexts()
8de0fc1f7fef Implemented functions to load UML graphics from disc.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2033
diff changeset
292 self.__calculateSize()
8de0fc1f7fef Implemented functions to load UML graphics from disc.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2033
diff changeset
293
8de0fc1f7fef Implemented functions to load UML graphics from disc.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2033
diff changeset
294 return True

eric ide

mercurial