20 |
20 |
21 import UI.Config |
21 import UI.Config |
22 import UI.PixmapCache |
22 import UI.PixmapCache |
23 |
23 |
24 import Preferences |
24 import Preferences |
|
25 |
25 |
26 |
26 class UMLGraphicsView(E5GraphicsView): |
27 class UMLGraphicsView(E5GraphicsView): |
27 """ |
28 """ |
28 Class implementing a specialized E5GraphicsView for our diagrams. |
29 Class implementing a specialized E5GraphicsView for our diagrams. |
29 |
30 |
30 @signal relayout() emitted to indicate a relayout of the diagram |
31 @signal relayout() emitted to indicate a relayout of the diagram |
31 is requested |
32 is requested |
32 """ |
33 """ |
33 relayout = pyqtSignal() |
34 relayout = pyqtSignal() |
34 |
35 |
35 def __init__(self, scene, diagramName = "Unnamed", parent = None, name = None): |
36 def __init__(self, scene, diagramName="Unnamed", parent=None, name=None): |
36 """ |
37 """ |
37 Constructor |
38 Constructor |
38 |
39 |
39 @param scene reference to the scene object (QGraphicsScene) |
40 @param scene reference to the scene object (QGraphicsScene) |
40 @param diagramName name of the diagram (string) |
41 @param diagramName name of the diagram (string) |
101 self.trUtf8("Zoom reset"), self) |
102 self.trUtf8("Zoom reset"), self) |
102 self.zoomResetAct.triggered[()].connect(self.zoomReset) |
103 self.zoomResetAct.triggered[()].connect(self.zoomReset) |
103 |
104 |
104 self.incWidthAct = \ |
105 self.incWidthAct = \ |
105 QAction(UI.PixmapCache.getIcon("sceneWidthInc.png"), |
106 QAction(UI.PixmapCache.getIcon("sceneWidthInc.png"), |
106 self.trUtf8("Increase width by {0} points").format(self.deltaSize), |
107 self.trUtf8("Increase width by {0} points").format(self.deltaSize), |
107 self) |
108 self) |
108 self.incWidthAct.triggered[()].connect(self.__incWidth) |
109 self.incWidthAct.triggered[()].connect(self.__incWidth) |
109 |
110 |
110 self.incHeightAct = \ |
111 self.incHeightAct = \ |
111 QAction(UI.PixmapCache.getIcon("sceneHeightInc.png"), |
112 QAction(UI.PixmapCache.getIcon("sceneHeightInc.png"), |
112 self.trUtf8("Increase height by {0} points").format(self.deltaSize), |
113 self.trUtf8("Increase height by {0} points").format(self.deltaSize), |
113 self) |
114 self) |
114 self.incHeightAct.triggered[()].connect(self.__incHeight) |
115 self.incHeightAct.triggered[()].connect(self.__incHeight) |
115 |
116 |
116 self.decWidthAct = \ |
117 self.decWidthAct = \ |
117 QAction(UI.PixmapCache.getIcon("sceneWidthDec.png"), |
118 QAction(UI.PixmapCache.getIcon("sceneWidthDec.png"), |
118 self.trUtf8("Decrease width by {0} points").format(self.deltaSize), |
119 self.trUtf8("Decrease width by {0} points").format(self.deltaSize), |
119 self) |
120 self) |
120 self.decWidthAct.triggered[()].connect(self.__decWidth) |
121 self.decWidthAct.triggered[()].connect(self.__decWidth) |
121 |
122 |
122 self.decHeightAct = \ |
123 self.decHeightAct = \ |
123 QAction(UI.PixmapCache.getIcon("sceneHeightDec.png"), |
124 QAction(UI.PixmapCache.getIcon("sceneHeightDec.png"), |
124 self.trUtf8("Decrease height by {0} points").format(self.deltaSize), |
125 self.trUtf8("Decrease height by {0} points").format(self.deltaSize), |
125 self) |
126 self) |
126 self.decHeightAct.triggered[()].connect(self.__decHeight) |
127 self.decHeightAct.triggered[()].connect(self.__decHeight) |
127 |
128 |
128 self.setSizeAct = \ |
129 self.setSizeAct = \ |
129 QAction(UI.PixmapCache.getIcon("sceneSize.png"), |
130 QAction(UI.PixmapCache.getIcon("sceneSize.png"), |
134 QAction(UI.PixmapCache.getIcon("reload.png"), |
135 QAction(UI.PixmapCache.getIcon("reload.png"), |
135 self.trUtf8("Re-Layout"), self) |
136 self.trUtf8("Re-Layout"), self) |
136 self.relayoutAct.triggered[()].connect(self.__relayout) |
137 self.relayoutAct.triggered[()].connect(self.__relayout) |
137 |
138 |
138 self.alignLeftAct = \ |
139 self.alignLeftAct = \ |
139 QAction(UI.PixmapCache.getIcon("shapesAlignLeft.png"), |
140 QAction(UI.PixmapCache.getIcon("shapesAlignLeft.png"), |
140 self.trUtf8("Align Left"), self) |
141 self.trUtf8("Align Left"), self) |
141 self.alignMapper.setMapping(self.alignLeftAct, Qt.AlignLeft) |
142 self.alignMapper.setMapping(self.alignLeftAct, Qt.AlignLeft) |
142 self.alignLeftAct.triggered[()].connect(self.alignMapper.map) |
143 self.alignLeftAct.triggered[()].connect(self.alignMapper.map) |
143 |
144 |
144 self.alignHCenterAct = \ |
145 self.alignHCenterAct = \ |
145 QAction(UI.PixmapCache.getIcon("shapesAlignHCenter.png"), |
146 QAction(UI.PixmapCache.getIcon("shapesAlignHCenter.png"), |
146 self.trUtf8("Align Center Horizontal"), self) |
147 self.trUtf8("Align Center Horizontal"), self) |
147 self.alignMapper.setMapping(self.alignHCenterAct, Qt.AlignHCenter) |
148 self.alignMapper.setMapping(self.alignHCenterAct, Qt.AlignHCenter) |
148 self.alignHCenterAct.triggered[()].connect(self.alignMapper.map) |
149 self.alignHCenterAct.triggered[()].connect(self.alignMapper.map) |
149 |
150 |
150 self.alignRightAct = \ |
151 self.alignRightAct = \ |
151 QAction(UI.PixmapCache.getIcon("shapesAlignRight.png"), |
152 QAction(UI.PixmapCache.getIcon("shapesAlignRight.png"), |
152 self.trUtf8("Align Right"), self) |
153 self.trUtf8("Align Right"), self) |
153 self.alignMapper.setMapping(self.alignRightAct, Qt.AlignRight) |
154 self.alignMapper.setMapping(self.alignRightAct, Qt.AlignRight) |
154 self.alignRightAct.triggered[()].connect(self.alignMapper.map) |
155 self.alignRightAct.triggered[()].connect(self.alignMapper.map) |
155 |
156 |
156 self.alignTopAct = \ |
157 self.alignTopAct = \ |
157 QAction(UI.PixmapCache.getIcon("shapesAlignTop.png"), |
158 QAction(UI.PixmapCache.getIcon("shapesAlignTop.png"), |
158 self.trUtf8("Align Top"), self) |
159 self.trUtf8("Align Top"), self) |
159 self.alignMapper.setMapping(self.alignTopAct, Qt.AlignTop) |
160 self.alignMapper.setMapping(self.alignTopAct, Qt.AlignTop) |
160 self.alignTopAct.triggered[()].connect(self.alignMapper.map) |
161 self.alignTopAct.triggered[()].connect(self.alignMapper.map) |
161 |
162 |
162 self.alignVCenterAct = \ |
163 self.alignVCenterAct = \ |
163 QAction(UI.PixmapCache.getIcon("shapesAlignVCenter.png"), |
164 QAction(UI.PixmapCache.getIcon("shapesAlignVCenter.png"), |
164 self.trUtf8("Align Center Vertical"), self) |
165 self.trUtf8("Align Center Vertical"), self) |
165 self.alignMapper.setMapping(self.alignVCenterAct, Qt.AlignVCenter) |
166 self.alignMapper.setMapping(self.alignVCenterAct, Qt.AlignVCenter) |
166 self.alignVCenterAct.triggered[()].connect(self.alignMapper.map) |
167 self.alignVCenterAct.triggered[()].connect(self.alignMapper.map) |
167 |
168 |
168 self.alignBottomAct = \ |
169 self.alignBottomAct = \ |
169 QAction(UI.PixmapCache.getIcon("shapesAlignBottom.png"), |
170 QAction(UI.PixmapCache.getIcon("shapesAlignBottom.png"), |
170 self.trUtf8("Align Bottom"), self) |
171 self.trUtf8("Align Bottom"), self) |
171 self.alignMapper.setMapping(self.alignBottomAct, Qt.AlignBottom) |
172 self.alignMapper.setMapping(self.alignBottomAct, Qt.AlignBottom) |
172 self.alignBottomAct.triggered[()].connect(self.alignMapper.map) |
173 self.alignBottomAct.triggered[()].connect(self.alignMapper.map) |
173 |
174 |
174 def __checkSizeActions(self): |
175 def __checkSizeActions(self): |