Changeset View
Changeset View
Standalone View
Standalone View
libs/koreport/renderer/KoReportPage.cpp
Show All 25 Lines | |||||
26 | #include <KoUnit.h> | 26 | #include <KoUnit.h> | ||
27 | 27 | | |||
28 | #include <renderobjects.h> | 28 | #include <renderobjects.h> | ||
29 | #include <QPainter> | 29 | #include <QPainter> | ||
30 | #include <QTimer> | 30 | #include <QTimer> | ||
31 | 31 | | |||
32 | KoReportPage::KoReportPage(QWidget *parent, ORODocument *document) | 32 | KoReportPage::KoReportPage(QWidget *parent, ORODocument *document) | ||
33 | : QObject(parent), QGraphicsRectItem() | 33 | : QObject(parent), QGraphicsRectItem() | ||
34 | , m_reportDocument(document) | ||||
35 | , m_page(0) | ||||
34 | { | 36 | { | ||
35 | //TODO setAttribute(Qt::WA_NoBackground); | 37 | Q_ASSERT(m_reportDocument); | ||
36 | //kDebug() << "CREATED PAGE"; | | |||
37 | m_reportDocument = document; | | |||
38 | m_page = 0; | | |||
39 | int pageWidth = 0; | | |||
40 | int pageHeight = 0; | | |||
41 | | ||||
42 | if (m_reportDocument) { | | |||
43 | QString pageSize = m_reportDocument->pageOptions().getPageSize(); | | |||
44 | | ||||
45 | 38 | | |||
39 | int pageWidth; | ||||
40 | int pageHeight; | ||||
41 | const QString pageSize = m_reportDocument->pageOptions().getPageSize(); | ||||
46 | if (pageSize == "Custom") { | 42 | if (pageSize == "Custom") { | ||
47 | // if this is custom sized sheet of paper we will just use those values | 43 | // if this is custom sized sheet of paper we will just use those values | ||
48 | pageWidth = (int)(m_reportDocument->pageOptions().getCustomWidth()); | 44 | pageWidth = (int)(m_reportDocument->pageOptions().getCustomWidth()); | ||
49 | pageHeight = (int)(m_reportDocument->pageOptions().getCustomHeight()); | 45 | pageHeight = (int)(m_reportDocument->pageOptions().getCustomHeight()); | ||
50 | } else { | 46 | } else { | ||
51 | // lookup the correct size information for the specified size paper | 47 | // lookup the correct size information for the specified size paper | ||
52 | pageWidth = m_reportDocument->pageOptions().widthPx(); | 48 | pageWidth = m_reportDocument->pageOptions().widthPx(); | ||
53 | pageHeight = m_reportDocument->pageOptions().heightPx(); | 49 | pageHeight = m_reportDocument->pageOptions().heightPx(); | ||
54 | } | 50 | } | ||
55 | } | | |||
56 | setRect(0,0,pageWidth, pageHeight); | 51 | setRect(0, 0, pageWidth, pageHeight); | ||
57 | //kDebug() << "PAGE IS " << pageWidth << "x" << pageHeight; | 52 | | ||
58 | m_pixmap = new QPixmap(pageWidth, pageHeight); | 53 | m_pixmap = new QPixmap(pageWidth, pageHeight); | ||
59 | m_renderer = m_factory.createInstance("screen"); | 54 | m_renderer = m_factory.createInstance("screen"); | ||
60 | connect(m_reportDocument, SIGNAL(updated(int)), this, SLOT(pageUpdated(int))); | 55 | connect(m_reportDocument, SIGNAL(updated(int)), this, SLOT(pageUpdated(int))); | ||
61 | 56 | | |||
62 | m_renderTimer = new QTimer(this); | 57 | m_renderTimer = new QTimer(this); | ||
63 | m_renderTimer->setSingleShot(true); | 58 | m_renderTimer->setSingleShot(true); | ||
64 | connect(m_renderTimer, SIGNAL(timeout()), this, SLOT(renderCurrentPage())); | 59 | connect(m_renderTimer, SIGNAL(timeout()), this, SLOT(renderCurrentPage())); | ||
65 | 60 | | |||
Show All 36 Lines | 91 | { | |||
102 | } | 97 | } | ||
103 | } | 98 | } | ||
104 | 99 | | |||
105 | void KoReportPage::renderCurrentPage() | 100 | void KoReportPage::renderCurrentPage() | ||
106 | { | 101 | { | ||
107 | renderPage(m_page + 1); | 102 | renderPage(m_page + 1); | ||
108 | } | 103 | } | ||
109 | 104 | | |||
110 | | ||||
111 | #include "KoReportPage.moc" | 105 | #include "KoReportPage.moc" |