/**************************************************************************** ** ** Copyright (C) 2007 Aleksey Luzin. All rights reserved. ** ** This file may be used under the terms of the GNU General Public ** License version 2.0 as published by the Free Software Foundation ** and appearing in the file LICENSE.GPL included in the packaging of ** this file. Please review the following information to ensure GNU ** General Public Licensing requirements will be met: ** http://www.trolltech.com/products/qt/opensource.html ** ** If you are unsure which license is appropriate for your use, please ** review the following information: ** http://www.trolltech.com/products/qt/licensing.html or contact the ** sales department at sales@trolltech.com. ** ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. ** ****************************************************************************/ #include #include #include #include #include "printpreview.h" #include "qmainwindow.h" PrintPreview::PrintPreview(double paper_width, double paper_height){ setupUi(this); scene = new QGraphicsScene(view); view->setScene(scene); view->setBackgroundRole(QPalette::Window); double ar = paper_width/paper_height; // pr->setRect(QRect(0,0,int(ar*200),200)); pr = scene->addRect(QRect(0,0,int(ar*500)+2, 500+2)); pr->setZValue(0); pr->setBrush(QBrush( Qt::white )); pixmap = new QPixmap(int(ar*500), 500); pixmap->fill(); pixmap1 = scene->addPixmap(*pixmap); pixmap1->setOffset(QPointF(1,1)); pixmap1->setZValue(1); scale = 500.0/paper_height; setWindowTitle(tr("Print Preview")); QTimer::singleShot(0, this, SLOT(addPage())); } void PrintPreview::addPage() { QPainter *p = new QPainter(pixmap); emit request_page(this, 0, scale, p); // QTimer::singleShot(3, this, SLOT(addPage1())); } void PrintPreview::update_preview() { qDebug("AddPage1"); pixmap1->setPixmap(*pixmap); // scene->update(); }