Trees | Indices | Help |
|
---|
|
1 # -*- coding: utf-8 -*- 2 3 ########################################################################## 4 # editorwidget.py 5 # 6 # Grafiksel Rapor Tasarım Editörü Takımı 7 # 8 # (C) 2007 Likya Yazılım ve Bilişim Hizmetleri Ltd. Şti. 9 ########################################################################## 10 11 from PyQt4.QtCore import * 12 from PyQt4.QtGui import * 13 14 from fieldsmenu import FieldsMenu 15 from propertywindow import PropertyWindow 16 from editor import Editor 17 from ruler import Ruler 18 from flowlayout import FlowLayout 19 from maintoolbar import MainToolBar 20 from editortoolbar import EditorToolBar 21 from alignmenttoolbar import AlignmentToolBar 22 from fittoolbar import FitToolBar 23 from textdrawtoolbar import TextDrawToolBar 24 from gridtoolbar import GridToolBar 25 from framesettings import FrameSettings 26 from designsettings import DesignSettings 27 28 from tools import * 293132033 QWidget.__init__(self, parent) 34 35 self._plugin = plugin 36 self._reportMeta = reportMeta 37 38 self.createDesignEditor() 39 self.createToolBars() 40 self.createFieldsMenu() 41 self.createFrameSettingsDialog() 42 self.createDesignSettingsDialog() 43 self.setButtons() 44 self.associateItems()4547 # Status eventlerini status bar'da gösterir. 48 if e.type() == QEvent.StatusTip: 49 self._statusBar.showMessage(e.tip()) 50 51 return QWidget.event(self, e)52 5860 ''' 61 Tasarım adının yazıldığı widget'ı belirler. 62 ''' 63 self._editor.setDesignNameWidget(designNameWidget)6466 ''' 67 Tasarımın hangi dile ait olduğunu bildirir. 68 ''' 69 self._editor.setLanguageWidget(languageWidget)7072 ''' 73 Özel tasarım türünü belirten widget. 74 ''' 75 self._editor.setSpecialTypeWidget(specialTypeWidget)7678 ''' 79 Tasarım editörünü hazırlar. 80 ''' 81 # Layout'u hazırlıyoruz. 82 layout = QGridLayout(self) 83 layout.setAlignment(Qt.AlignTop) 84 layout.setSpacing(0) 85 layout.setMargin(0) 86 87 # Toolbar'ların gireceği dock alanını ayarlıyoruz. 88 self.toolBarArea = QWidget(self) 89 layout.addWidget(self.toolBarArea, 0, 0) 90 91 # Alanlar, Editör ve Özellikler pencerelerini yöneten splitter'i oluşturuyoruz. 92 self.editorSplitter = QSplitter(Qt.Horizontal, self) 93 self.editorSplitter.setSizePolicy(QSizePolicy( 94 QSizePolicy.Expanding, 95 QSizePolicy.Expanding)) 96 97 # Alanlar penceresini oluşturuyoruz. 98 self._fieldsMenu = FieldsMenu(self.editorSplitter, self._plugin) 99 self._fieldsMenu.setFrameStyle(QFrame.Sunken) 100 self._fieldsMenu.setFrameShape(QFrame.StyledPanel) 101 102 # Editörü ekliyoruz. Editörün soluna ve üstüne cetvel koyacağımız 103 # için, özel bir layout oluşturuyoruz. 104 layoutWidget = QWidget(self.editorSplitter) 105 106 self._editor = Editor(layoutWidget, self._plugin) 107 108 editorLayout = QGridLayout(layoutWidget) 109 editorLayout.setSpacing(0) 110 editorLayout.setMargin(0) 111 editorLayout.addWidget(self._editor, 1, 1) 112 self._leftRuler = Ruler(layoutWidget, self._plugin) 113 self._leftRuler.setOrientation(Ruler.VERTICAL) 114 editorLayout.addWidget(self._leftRuler, 1, 0) 115 self._topRuler = Ruler(layoutWidget, self._plugin) 116 self._topRuler.setOrientation(Ruler.HORIZONTAL) 117 editorLayout.addWidget(self._topRuler, 0, 1) 118 119 # Özellikler penceresini oluşturuyoruz. 120 self._propertyWindow = PropertyWindow(self.editorSplitter, self._editor, self._plugin) 121 122 layout.addWidget(self.editorSplitter, 1, 0) 123 124 # Status Bar'ı oluşturuyoruz. 125 self._statusBar = QStatusBar(self) 126 self._statusBar.setSizeGripEnabled(False) 127 layout.addWidget(self._statusBar, 2, 0)128130 ''' 131 Toolbar'ları oluşturur. 132 ''' 133 flowLayout = FlowLayout(self.toolBarArea, 0, 0) 134 135 self._mainToolBar = MainToolBar(self.toolBarArea, self._editor, self._plugin) 136 self._editorToolBar = EditorToolBar(self.toolBarArea, self._editor, self._plugin) 137 self._alignmentToolBar = AlignmentToolBar(self.toolBarArea, self._editor, self._plugin) 138 self._fitToolBar = FitToolBar(self.toolBarArea, self._editor, self._plugin) 139 140 flowLayout.addWidget(self._mainToolBar) 141 flowLayout.addWidget(self._editorToolBar) 142 flowLayout.addWidget(self._alignmentToolBar) 143 flowLayout.addWidget(self._fitToolBar) 144 145 # Gridsel raporlar için text çizim toolbar'ını ekliyoruz 146 if self._plugin.requiresGridPosition(): 147 self._textDrawToolBar = TextDrawToolBar(self.toolBarArea, self._editor, self._plugin) 148 flowLayout.addWidget(self._textDrawToolBar) 149 150 # Grafik raporlar için grid ayarları toolbar'ını ekliyoruz 151 else: 152 self._gridToolBar = GridToolBar(self.toolBarArea, self._editor, self._plugin) 153 flowLayout.addWidget(self._gridToolBar) 154 155 self.toolBarArea.setLayout(flowLayout)156158 ''' 159 Alanlar menüsünü oluşturur. 160 ''' 161 self._fieldsMenu.createMenu(self._reportMeta) 162 self._editor.setReportMeta(self._reportMeta)163165 ''' 166 Çerçeve ayar penceresini oluşturur. 167 ''' 168 self._frameSettings = FrameSettings(self, Qt.Dialog, self._plugin) 169 self._frameSettings.setModal(True) 170 self._frameSettings.setReportMeta(self._reportMeta) 171 172 self.connect(self._frameSettings, SIGNAL('framesChanged(PyQt_PyObject)'), self._framesChanged) 173 174 # Çerçeve tanımlarını editöre bildiriyoruz. 175 self._editor.setFrameDefinitions(self._frameSettings.allFrames())176178 ''' 179 Tasarım ayar penceresini oluşturur. 180 ''' 181 self._designSettingsDialog = DesignSettings(self._editor.designSettings(), 182 self._editor.plugin(), 183 self, 184 Qt.Dialog) 185 self._designSettingsDialog.setModal(True) 186 187 self.connect(self._designSettingsDialog, SIGNAL('settingsChanged(PyQt_PyObject)'), self._settingsChanged)188190 ''' 191 Yeni tasarım ayarlarını editöre yansıtır. 192 ''' 193 self._editor.changeDesignSettings(newSettings)194196 ''' 197 Seçilen çerçeveleri editöre aktarır ve seçilmeyenleri siler. 198 ''' 199 frameStarts = zip(selectedFrames, map(lambda x: self._frameSettings.frameStart(x), selectedFrames)) 200 201 self._editor.changeActiveFrames(selectedFrames, frameStarts)202204 ''' 205 Çerçeve ayar penceresini açar. 206 ''' 207 self._frameSettings.setActiveFrames(self._editor.activeFrameCodes()) 208 self._frameSettings.setFrameStarts(self._editor.frameStarts()) 209 self._frameSettings.show()210212 ''' 213 Tasarım ayar penceresini açar 214 ''' 215 self._designSettingsDialog.setSettings(self._editor.designSettings()) 216 self._designSettingsDialog.show()217219 ''' 220 Toolbar'daki düğmelerin ekstra ayarlarını yapıyoruz. 221 ''' 222 fieldMenuAction = self._editorToolBar.getAction('fieldsmenu') 223 propertyMenuAction = self._editorToolBar.getAction('properties') 224 frameSettingsMenuAction = self._editorToolBar.getAction('reportframes') 225 designSettingsMenuAction = self._mainToolBar.getAction('settings') 226 227 fieldMenuAction.setCheckable(True) 228 fieldMenuAction.setChecked(True) 229 propertyMenuAction.setCheckable(True) 230 propertyMenuAction.setChecked(True) 231 232 self.connect(fieldMenuAction, SIGNAL('toggled(bool)'), self._fieldsMenu, SLOT('setVisible(bool)')) 233 self.connect(propertyMenuAction, SIGNAL('toggled(bool)'), self._propertyWindow, SLOT('setVisible(bool)')) 234 self.connect(frameSettingsMenuAction, SIGNAL('triggered(bool)'), self.openFrameSettings) 235 self.connect(designSettingsMenuAction, SIGNAL('triggered(bool)'), self.openDesignSettings) 236 237 # Undo ve Redo düğmelerini ayarlıyoruz. 238 undoAction = self._mainToolBar.getAction('editundo') 239 redoAction = self._mainToolBar.getAction('editredo') 240 undoAction.setEnabled(False) 241 redoAction.setEnabled(False) 242 243 undoStack = self._editor.undoStack() 244 self.connect(undoStack, SIGNAL('canUndoChanged(bool)'), undoAction, SLOT('setEnabled(bool)')) 245 self.connect(undoStack, SIGNAL('canRedoChanged(bool)'), redoAction, SLOT('setEnabled(bool)')) 246 self.connect(undoAction, SIGNAL('triggered(bool)'), undoStack, SLOT('undo()')) 247 self.connect(redoAction, SIGNAL('triggered(bool)'), undoStack, SLOT('redo()')) 248 self.connect(undoStack, SIGNAL('undoTextChanged(const QString &)'), self.undoTextChanged) 249 self.connect(undoStack, SIGNAL('redoTextChanged(const QString &)'), self.redoTextChanged)250 251 # Şimdilik alanlar ve özellikler penceresini kapatıyoruz. 252 # fieldMenuAction.setChecked(False) 253 # propertyMenuAction.setChecked(False) 254256 if newText: 257 newText = '-- %s' % newText 258 259 self._mainToolBar.getAction('editundo').setToolTip(('%s (Ctrl+Z) %s' % (tr('Geri Al'), newText)))260262 if newText: 263 newText = ' -- %s' % newText 264 265 self._mainToolBar.getAction('editredo').setToolTip(('%s (Ctrl+Y) %s' % (tr('İleri Al'), newText)))266268 ''' 269 Editör ile diğer nesneleri birbirine bağlar. 270 ''' 271 self.connect(self._editor, SIGNAL('framesOffsetWidthChanged(QPoint, float)'), self._topRuler.setFrameOffsetAndWidth) 272 self.connect(self._editor, SIGNAL('framesHeightsChanged(PyQt_PyObject)'), self._leftRuler.setFrameHeights) 273 self.connect(self._editor, SIGNAL('selectionChanged()'), self.selectionChanged) 274 self.connect(self._propertyWindow, SIGNAL('propertyChanged(PyQt_PyObject, PyQt_PyObject)'), self._editor.propertyChanged) 275 self.connect(self._propertyWindow, SIGNAL('modelDataChanged(PyQt_PyObject, PyQt_PyObject, PyQt_PyObject)'), self._editor.modelDataChanged) 276 277 if not self._plugin.requiresGridPosition(): 278 self.connect(self._gridToolBar, SIGNAL('gridStepChanged()'), self.gridStepChanged)279281 ''' 282 Grid boyları değiştiği zaman gerekli güncellemeleri yapar. 283 ''' 284 self._editor.updateBorder() 285 self._leftRuler.refresh() 286 self._topRuler.refresh()287289 ''' 290 Editördeki nesnelerin seçimlerinde bir değişiklik olduğu zaman çalışır. 291 ''' 292 QTimer.singleShot(0.1, self.reportSelectedItems)293295 ''' 296 Seçilen nesneleri özellik penceresine bildirir. 297 ''' 298 self._propertyWindow.selectionChanged(self._editor.scene().selectedItems())299301 ''' 302 Serialize edilmiş tasarım nesnesini editöre geri yüklenmesini sağlar. 303 304 @param design: Serialize edilmiş durumdaki tasarım nesnesi. 305 @type design: str 306 ''' 307 design = unpackAscii(design) 308 self._editor.loadDesignFromDict(design)309311 ''' 312 Editör'deki tasarımın veritabanına atılacak şekilde serialize edilmiş 313 halini verir. 314 315 @return: Tasarımın serialize edilmiş hali. 316 @rtype: str 317 ''' 318 design = self._editor.saveDesignToDict() 319 return packAscii(design)
Trees | Indices | Help |
|
---|
Generated by Epydoc 3.0.1 on Thu Oct 29 19:47:03 2009 | http://epydoc.sourceforge.net |