eric6/Graphics/PackageItem.py

changeset 7529
2b8a0d8ba12a
parent 7360
9190402e4505
child 7780
41420f82c0ac
equal deleted inserted replaced
7528:0345f54d3959 7529:2b8a0d8ba12a
53 Class implementing a package item. 53 Class implementing a package item.
54 """ 54 """
55 ItemType = "package" 55 ItemType = "package"
56 56
57 def __init__(self, model=None, x=0, y=0, rounded=False, 57 def __init__(self, model=None, x=0, y=0, rounded=False,
58 noModules=False, parent=None, scene=None): 58 noModules=False, colors=None, parent=None, scene=None):
59 """ 59 """
60 Constructor 60 Constructor
61 61
62 @param model package model containing the package data (PackageModel) 62 @param model package model containing the package data
63 @param x x-coordinate (integer) 63 @type PackageModel
64 @param y y-coordinate (integer) 64 @param x x-coordinate
65 @param rounded flag indicating a rounded corner (boolean) 65 @type int
66 @keyparam noModules flag indicating, that no module names should be 66 @param y y-coordinate
67 shown (boolean) 67 @type int
68 @keyparam parent reference to the parent object (QGraphicsItem) 68 @param rounded flag indicating a rounded corner
69 @keyparam scene reference to the scene object (QGraphicsScene) 69 @type bool
70 """ 70 @param noModules flag indicating, that no module names should be
71 UMLItem.__init__(self, model, x, y, rounded, parent) 71 shown
72 @type bool
73 @param colors tuple containing the foreground and background colors
74 @type tuple of (QColor, QColor)
75 @param parent reference to the parent object
76 @type QGraphicsItem
77 @param scene reference to the scene object
78 @type QGraphicsScene
79 """
80 UMLItem.__init__(self, model, x, y, rounded, colors, parent)
72 self.noModules = noModules 81 self.noModules = noModules
73 82
74 scene.addItem(self) 83 scene.addItem(self)
75 84
76 if self.model: 85 if self.model:
90 modules = self.model.getModules() 99 modules = self.model.getModules()
91 100
92 x = self.margin + self.rect().x() 101 x = self.margin + self.rect().x()
93 y = self.margin + self.rect().y() 102 y = self.margin + self.rect().y()
94 self.header = QGraphicsSimpleTextItem(self) 103 self.header = QGraphicsSimpleTextItem(self)
104 self.header.setBrush(self._colors[0])
95 self.header.setFont(boldFont) 105 self.header.setFont(boldFont)
96 self.header.setText(self.model.getName()) 106 self.header.setText(self.model.getName())
97 self.header.setPos(x, y) 107 self.header.setPos(x, y)
98 y += self.header.boundingRect().height() + self.margin 108 y += self.header.boundingRect().height() + self.margin
99 109
101 if modules: 111 if modules:
102 txt = "\n".join(modules) 112 txt = "\n".join(modules)
103 else: 113 else:
104 txt = " " 114 txt = " "
105 self.modules = QGraphicsSimpleTextItem(self) 115 self.modules = QGraphicsSimpleTextItem(self)
116 self.modules.setBrush(self._colors[0])
106 self.modules.setFont(self.font) 117 self.modules.setFont(self.font)
107 self.modules.setText(txt) 118 self.modules.setText(txt)
108 self.modules.setPos(x, y) 119 self.modules.setPos(x, y)
109 else: 120 else:
110 self.modules = None 121 self.modules = None

eric ide

mercurial