Trees | Indices | Help |
|
---|
|
1 # -*- coding: utf-8 -*- 2 3 ########################################################################## 4 # viewerwidget.py 5 # 6 # Rapor Gösterim Nesnesi 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 viewer import Viewer 15 from toolbar import ToolBar 16 17 from constants import Constants 182022722 QWidget.__init__(self, parent) 23 24 # Rapor Görünümü 25 self._viewer = Viewer(self) 26 self._viewer.setSizePolicy(QSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding)) 27 28 # Tool Bar 29 self._toolbar = ToolBar(self) 30 self._toolbar.setSizePolicy(QSizePolicy(QSizePolicy.Expanding, QSizePolicy.Maximum)) 31 32 # Status Bar 33 self._statusBar = QStatusBar(self) 34 self._statusBar.setSizePolicy(QSizePolicy(QSizePolicy.Expanding, QSizePolicy.Maximum)) 35 self._statusBar.setSizeGripEnabled(False) 36 37 self._pageSource = None 38 39 self.layoutItems() 40 41 # Sinyaller ve ayarlar. 42 self.initItems()4345 ''' 46 Sinyaller ve ayarlar 47 ''' 48 self.connect(self._toolbar, SIGNAL('resetPages()'), self, SIGNAL('resetPages()')) 49 self.connect(self._toolbar, SIGNAL('print()'), self, SIGNAL('print()')) 50 self.connect(self._toolbar, SIGNAL('setZoom(float)'), self.setZoom) 51 self.connect(self._toolbar, SIGNAL('adjustZoomForPageWidth()'), self.adjustZoomForPageWidth) 52 self.connect(self._toolbar, SIGNAL('adjustZoomForPageHeight()'), self.adjustZoomForPageHeight) 53 self.connect(self._toolbar, SIGNAL('pageOrientationChanged()'), self.pageOrientationChanged) 54 self.connect(self._toolbar, SIGNAL('gotoPage(int)'), self._viewer.gotoPage) 55 self.connect(self._toolbar, SIGNAL('paperTypeChanged(PyQt_PyObject)'), self.paperTypeChanged) 56 self.connect(self._viewer, SIGNAL('setPageNumberText(int)'), self._toolbar.setPageNumberText)5759 ''' 60 Yeni zoom oranını yansıtıyoruz. 61 ''' 62 self._pageSource.setZoom(newRatio) 63 self.emit(SIGNAL('resetPages()'))6466 ''' 67 Sayfa genişliğine göre zoom yapar. 68 ''' 69 pageWidth = self._pageSource.pageWidth(False) + Viewer.MARGIN 70 71 zoomRatio = Viewer.WIDTH / float(pageWidth) 72 zoomRatio = min(abs(zoomRatio), 4) 73 zoomRatio = max(abs(zoomRatio), 0.1) 74 75 self._toolbar.setZoom(zoomRatio)7678 ''' 79 Sayfa yüksekliğine göre zoom yapar. 80 ''' 81 pageHeight = self._pageSource.pageHeight(False) + Viewer.MARGIN 82 83 zoomRatio = Viewer.HEIGHT / float(pageHeight) 84 zoomRatio = min(abs(zoomRatio), 4) 85 zoomRatio = max(abs(zoomRatio), 0.1) 86 87 self._toolbar.setZoom(zoomRatio)88 94 100 106 112 118120 ''' 121 Görünüm ekranındaki nesneleri dizer. 122 ''' 123 layout = QVBoxLayout(self) 124 125 layout.setSpacing(3) 126 layout.setMargin(0) 127 128 layout.addWidget(self._toolbar) 129 layout.addWidget(self._viewer) 130 layout.addWidget(self._statusBar)131133 ''' 134 Rapor sayfalarını ilgili layout'a göre düzgünce yerleştirir. 135 ''' 136 self._viewer.layoutPages()137139 ''' 140 Nesnelerin kapladığı alana göre scroll barları yeniden ayarlar. 141 ''' 142 self._viewer.adjustContentsSize()143145 ''' 146 Kağıt türüne göre uygun sayfa boylarını verir. 147 ''' 148 paperType = self._toolbar.paperType() 149 150 width = None 151 height = None 152 153 if paperType != 'DESIGN' and paperType in Constants.PAPER_SIZES: 154 paperWidth, paperHeight = Constants.PAPER_SIZES[paperType] 155 sideRatio = float(paperWidth) / float(paperHeight) 156 157 pageWidth = None 158 pageHeight = None 159 160 if pageOrientation == Constants.ORIENTATION_PORTRAIT: 161 pageWidth = self._pageSource.pageWidth(False) 162 pageHeight = self._pageSource.pageHeight(False) 163 164 else: 165 pageHeight = self._pageSource.pageWidth(False) 166 pageWidth = self._pageSource.pageHeight(False) 167 168 widthRatiod = (pageWidth, pageWidth / sideRatio) 169 heightRatiod = (pageHeight * sideRatio, pageHeight) 170 171 width, height = max(widthRatiod, heightRatiod) 172 173 return width, height174176 ''' 177 Sayfa yönü değiştiği zaman çalışır. 178 ''' 179 pageOrientation = self._toolbar.pageOrientation() 180 181 self._pageSource.setAbsoluteLengths(None, None) 182 183 if pageOrientation == Constants.ORIENTATION_LANDSCAPE: 184 paperType = self._pageSource.paperType() 185 self._toolbar.setPaperType(paperType) 186 187 width, height = self.getPageSizes(pageOrientation) 188 self._pageSource.setAbsoluteLengths(width, height) 189 190 self._pageSource.setPageOrientation(pageOrientation) 191 192 if pageOrientation == Constants.ORIENTATION_LANDSCAPE: 193 self.adjustZoomForPageHeight() 194 195 else: 196 self.emit(SIGNAL('resetPages()'))197199 ''' 200 Sayfa boyutu değiştiği zaman çalışır. 201 ''' 202 pageOrientation = Constants.ORIENTATION_PORTRAIT 203 204 self._pageSource.setAbsoluteLengths(None, None) 205 206 if paperType != 'DESIGN' and paperType in Constants.PAPER_SIZES: 207 # Eğer yatay baskı ise, görünümü yatay yapıyoruz. 208 pageOrientation = self._pageSource.preferredPageOrientation() 209 210 width, height = self.getPageSizes(pageOrientation) 211 self._pageSource.setAbsoluteLengths(width, height) 212 213 else: 214 self._pageSource.setAbsoluteLengths(None, None) 215 216 self._pageSource.setPageOrientation(pageOrientation) 217 self._toolbar.setPageOrientation(pageOrientation) 218 219 self.emit(SIGNAL('resetPages()'))220222 # Status eventlerini status bar'da gösterir. 223 if e.type() == QEvent.StatusTip: 224 self._statusBar.showMessage(e.tip()) 225 226 return QWidget.event(self, e)
Trees | Indices | Help |
|
---|
Generated by Epydoc 3.0.1 on Thu Oct 29 19:47:03 2009 | http://epydoc.sourceforge.net |