150 image = QImage(filename) |
150 image = QImage(filename) |
151 if image.isNull(): |
151 if image.isNull(): |
152 E5MessageBox.warning( |
152 E5MessageBox.warning( |
153 self, |
153 self, |
154 self.trUtf8("Pixmap-Viewer"), |
154 self.trUtf8("Pixmap-Viewer"), |
155 self.trUtf8("""<p>The file <b>{0}</b> cannot be displayed.""" |
155 self.trUtf8( |
|
156 """<p>The file <b>{0}</b> cannot be displayed.""" |
156 """ The format is not supported.</p>""").format(filename)) |
157 """ The format is not supported.</p>""").format(filename)) |
157 return False |
158 return False |
158 |
159 |
159 self.pixmapLabel.setPixmap(QPixmap.fromImage(image)) |
160 self.pixmapLabel.setPixmap(QPixmap.fromImage(image)) |
160 self.pixmapLabel.adjustSize() |
161 self.pixmapLabel.adjustSize() |
379 s = self.trUtf8("Diagram: {0}").format(self.getDiagramName()) |
380 s = self.trUtf8("Diagram: {0}").format(self.getDiagramName()) |
380 tc = QColor(50, 50, 50) |
381 tc = QColor(50, 50, 50) |
381 painter.setPen(tc) |
382 painter.setPen(tc) |
382 painter.drawRect(marginX, marginY, width, height) |
383 painter.drawRect(marginX, marginY, width, height) |
383 painter.drawLine(marginX, marginY + height + 2, |
384 painter.drawLine(marginX, marginY + height + 2, |
384 marginX + width, marginY + height + 2) |
385 marginX + width, marginY + height + 2) |
385 painter.setFont(font) |
386 painter.setFont(font) |
386 painter.drawText(marginX, marginY + height + 4, width, |
387 painter.drawText(marginX, marginY + height + 4, width, |
387 fontHeight, Qt.AlignRight, s) |
388 fontHeight, Qt.AlignRight, s) |
388 |
389 |
389 # render the diagram |
390 # render the diagram |
390 size = self.pixmapLabel.pixmap().size() |
391 size = self.pixmapLabel.pixmap().size() |
391 size.scale(QSize(width - 10, height - 10), # 5 px inner margin |
392 size.scale(QSize(width - 10, height - 10), # 5 px inner margin |
392 Qt.KeepAspectRatio) |
393 Qt.KeepAspectRatio) |
393 painter.setViewport(marginX + 5, marginY + 5, |
394 painter.setViewport(marginX + 5, marginY + 5, |
394 size.width(), size.height()) |
395 size.width(), size.height()) |
395 painter.setWindow(self.pixmapLabel.pixmap().rect()) |
396 painter.setWindow(self.pixmapLabel.pixmap().rect()) |
396 painter.drawPixmap(0, 0, self.pixmapLabel.pixmap()) |
397 painter.drawPixmap(0, 0, self.pixmapLabel.pixmap()) |
397 painter.end() |
398 painter.end() |