Changeset View
Changeset View
Standalone View
Standalone View
src/common/KReportDocument.cpp
Show All 19 Lines | |||||
20 | #include "KReportDetailSectionData.h" | 20 | #include "KReportDetailSectionData.h" | ||
21 | #include "KReportItemBase.h" | 21 | #include "KReportItemBase.h" | ||
22 | #include "KReportDpi.h" | 22 | #include "KReportDpi.h" | ||
23 | 23 | | |||
24 | #include <QDomElement> | 24 | #include <QDomElement> | ||
25 | #include <QApplication> | 25 | #include <QApplication> | ||
26 | #include "kreport_debug.h" | 26 | #include "kreport_debug.h" | ||
27 | 27 | | |||
28 | class KReportDocument::Private | ||||
staniek: -> class Q_DECL_HIDDEN KReportDocument::Private
Please see T4016 | |||||
29 | { | ||||
30 | public: | ||||
31 | bool valid; | ||||
32 | QString title; | ||||
33 | QString name; | ||||
34 | QString query; | ||||
35 | #ifdef KREPORT_SCRIPTING | ||||
36 | QString script; | ||||
37 | QString interpreter; | ||||
38 | #endif | ||||
39 | bool externalData; | ||||
40 | KReportPageOptions page; | ||||
41 | }; | ||||
42 | | ||||
28 | void KReportDocument::init() | 43 | void KReportDocument::init() | ||
29 | { | 44 | { | ||
30 | m_pageHeaderFirst = m_pageHeaderOdd = m_pageHeaderEven = m_pageHeaderLast = m_pageHeaderAny = 0; | 45 | m_pageHeaderFirst = m_pageHeaderOdd = m_pageHeaderEven = m_pageHeaderLast = m_pageHeaderAny = 0; | ||
31 | m_pageFooterFirst = m_pageFooterOdd = m_pageFooterEven = m_pageFooterLast = m_pageFooterAny = 0; | 46 | m_pageFooterFirst = m_pageFooterOdd = m_pageFooterEven = m_pageFooterLast = m_pageFooterAny = 0; | ||
32 | m_reportHeader = m_reportFooter = 0; | 47 | m_reportHeader = m_reportFooter = 0; | ||
33 | } | 48 | } | ||
34 | 49 | | |||
35 | KReportDocument::KReportDocument(QObject *parent) | 50 | KReportDocument::KReportDocument(QObject *parent) | ||
36 | : QObject(parent) | 51 | : QObject(parent), | ||
37 | , m_detailSection(0) | 52 | m_detailSection(0), | ||
53 | d(new Private()) | ||||
38 | { | 54 | { | ||
39 | init(); | 55 | init(); | ||
40 | m_valid = true; | 56 | d->valid = true; | ||
41 | } | 57 | } | ||
42 | 58 | | |||
43 | KReportDocument::KReportDocument(const QDomElement & elemSource, QObject *parent) | 59 | KReportDocument::KReportDocument(const QDomElement & elemSource, QObject *parent) | ||
44 | : QObject(parent) | 60 | : QObject(parent), | ||
45 | , m_detailSection(0) | 61 | m_detailSection(0), | ||
62 | d(new Private()) | ||||
46 | { | 63 | { | ||
47 | m_valid = false; | 64 | d->valid = false; | ||
48 | init(); | 65 | init(); | ||
49 | //kreportDebug(); | 66 | //kreportDebug(); | ||
50 | if (elemSource.tagName() != QLatin1String("report:content")) { | 67 | if (elemSource.tagName() != QLatin1String("report:content")) { | ||
51 | kreportWarning() << "QDomElement is not <report:content> tag" | 68 | kreportWarning() << "QDomElement is not <report:content> tag" | ||
52 | << elemSource.text(); | 69 | << elemSource.text(); | ||
53 | return; | 70 | return; | ||
54 | } | 71 | } | ||
55 | 72 | | |||
56 | const qreal dpiX = KReportDpi::dpiX(); | 73 | const qreal dpiX = KReportDpi::dpiX(); | ||
57 | const qreal dpiY = KReportDpi::dpiY(); | 74 | const qreal dpiY = KReportDpi::dpiY(); | ||
58 | 75 | | |||
59 | 76 | | |||
60 | QDomNodeList sections = elemSource.childNodes(); | 77 | QDomNodeList sections = elemSource.childNodes(); | ||
61 | for (int nodeCounter = 0; nodeCounter < sections.count(); nodeCounter++) { | 78 | for (int nodeCounter = 0; nodeCounter < sections.count(); nodeCounter++) { | ||
62 | QDomElement elemThis = sections.item(nodeCounter).toElement(); | 79 | QDomElement elemThis = sections.item(nodeCounter).toElement(); | ||
63 | if (elemThis.tagName() == QLatin1String("report:title")) { | 80 | if (elemThis.tagName() == QLatin1String("report:title")) { | ||
64 | m_title = elemThis.text(); | 81 | d->title = elemThis.text(); | ||
65 | #ifdef KREPORT_SCRIPTING | 82 | #ifdef KREPORT_SCRIPTING | ||
66 | } else if (elemThis.tagName() == QLatin1String("report:script")) { | 83 | } else if (elemThis.tagName() == QLatin1String("report:script")) { | ||
67 | m_script = elemThis.text(); | 84 | d->script = elemThis.text(); | ||
68 | m_interpreter = elemThis.attribute(QLatin1String("report:script-interpreter")); | 85 | d->interpreter = elemThis.attribute(QLatin1String("report:script-interpreter")); | ||
69 | #endif | 86 | #endif | ||
70 | } else if (elemThis.tagName() == QLatin1String("report:page-style")) { | 87 | } else if (elemThis.tagName() == QLatin1String("report:page-style")) { | ||
71 | QString pagetype = elemThis.firstChild().nodeValue(); | 88 | QString pagetype = elemThis.firstChild().nodeValue(); | ||
72 | 89 | | |||
73 | if (pagetype == QLatin1String("predefined")) { | 90 | if (pagetype == QLatin1String("predefined")) { | ||
74 | page.setPageSize(elemThis.attribute(QLatin1String("report:page-size"), QLatin1String("A4"))); | 91 | d->page.setPageSize(elemThis.attribute(QLatin1String("report:page-size"), QLatin1String("A4"))); | ||
75 | } else if (pagetype == QLatin1String("custom")) { | 92 | } else if (pagetype == QLatin1String("custom")) { | ||
76 | page.setCustomWidth(POINT_TO_INCH(KReportUnit::parseValue(elemThis.attribute(QLatin1String("report:custom-page-width"), QString()))) * dpiX); | 93 | d->page.setCustomWidth(POINT_TO_INCH(KReportUnit::parseValue(elemThis.attribute(QLatin1String("report:custom-page-width"), QString()))) * dpiX); | ||
77 | page.setCustomHeight(POINT_TO_INCH(KReportUnit::parseValue(elemThis.attribute(QLatin1String("report:custom-page-height"), QString()))) * dpiY); | 94 | d->page.setCustomHeight(POINT_TO_INCH(KReportUnit::parseValue(elemThis.attribute(QLatin1String("report:custom-page-height"), QString()))) * dpiY); | ||
78 | page.setPageSize(QLatin1String("Custom")); | 95 | d->page.setPageSize(QLatin1String("Custom")); | ||
79 | } else if (pagetype == QLatin1String("label")) { | 96 | } else if (pagetype == QLatin1String("label")) { | ||
80 | page.setLabelType(elemThis.firstChild().nodeValue()); | 97 | d->page.setLabelType(elemThis.firstChild().nodeValue()); | ||
81 | } | 98 | } | ||
82 | //! @todo add config for default margins or add within templates support | 99 | //! @todo add config for default margins or add within templates support | ||
83 | page.setMarginBottom(POINT_TO_INCH(KReportUnit::parseValue(elemThis.attribute(QLatin1String("fo:margin-bottom"), QLatin1String("1.0cm")))) * dpiY); | 100 | d->page.setMarginBottom(POINT_TO_INCH(KReportUnit::parseValue(elemThis.attribute(QLatin1String("fo:margin-bottom"), QLatin1String("1.0cm")))) * dpiY); | ||
84 | page.setMarginTop(POINT_TO_INCH(KReportUnit::parseValue(elemThis.attribute(QLatin1String("fo:margin-top"), QLatin1String("1.0cm")))) * dpiY); | 101 | d->page.setMarginTop(POINT_TO_INCH(KReportUnit::parseValue(elemThis.attribute(QLatin1String("fo:margin-top"), QLatin1String("1.0cm")))) * dpiY); | ||
85 | page.setMarginLeft(POINT_TO_INCH(KReportUnit::parseValue(elemThis.attribute(QLatin1String("fo:margin-left"), QLatin1String("1.0cm")))) * dpiX); | 102 | d->page.setMarginLeft(POINT_TO_INCH(KReportUnit::parseValue(elemThis.attribute(QLatin1String("fo:margin-left"), QLatin1String("1.0cm")))) * dpiX); | ||
86 | page.setMarginRight(POINT_TO_INCH(KReportUnit::parseValue(elemThis.attribute(QLatin1String("fo:margin-right"), QLatin1String("1.0cm")))) * dpiX); | 103 | d->page.setMarginRight(POINT_TO_INCH(KReportUnit::parseValue(elemThis.attribute(QLatin1String("fo:margin-right"), QLatin1String("1.0cm")))) * dpiX); | ||
87 | 104 | | |||
88 | page.setPortrait(elemThis.attribute(QLatin1String("report:print-orientation"), QLatin1String("portrait")) == QLatin1String("portrait")); | 105 | d->page.setPortrait(elemThis.attribute(QLatin1String("report:print-orientation"), QLatin1String("portrait")) == QLatin1String("portrait")); | ||
89 | 106 | | |||
90 | } else if (elemThis.tagName() == QLatin1String("report:body")) { | 107 | } else if (elemThis.tagName() == QLatin1String("report:body")) { | ||
91 | QDomNodeList sectionlist = elemThis.childNodes(); | 108 | QDomNodeList sectionlist = elemThis.childNodes(); | ||
92 | QDomNode sec; | 109 | QDomNode sec; | ||
93 | 110 | | |||
94 | for (int s = 0; s < sectionlist.count(); ++s) { | 111 | for (int s = 0; s < sectionlist.count(); ++s) { | ||
95 | sec = sectionlist.item(s); | 112 | sec = sectionlist.item(s); | ||
96 | if (sec.isElement()) { | 113 | if (sec.isElement()) { | ||
▲ Show 20 Lines • Show All 59 Lines • ▼ Show 20 Line(s) | 165 | } else if (sn == QLatin1String("report:detail")) { | |||
156 | } | 173 | } | ||
157 | } | 174 | } | ||
158 | } else { | 175 | } else { | ||
159 | kreportWarning() << "Encountered an unknown Element: " << elemThis.tagName(); | 176 | kreportWarning() << "Encountered an unknown Element: " << elemThis.tagName(); | ||
160 | } | 177 | } | ||
161 | } | 178 | } | ||
162 | } | 179 | } | ||
163 | 180 | | |||
164 | m_valid = true; | 181 | d->valid = true; | ||
165 | } | 182 | } | ||
166 | } | 183 | } | ||
167 | 184 | | |||
168 | | ||||
169 | KReportDocument::~KReportDocument() | 185 | KReportDocument::~KReportDocument() | ||
170 | { | 186 | { | ||
187 | delete d; | ||||
171 | } | 188 | } | ||
172 | 189 | | |||
190 | | ||||
staniek: not needed line | |||||
173 | QList<KReportItemBase*> KReportDocument::objects() const | 191 | QList<KReportItemBase*> KReportDocument::objects() const | ||
174 | { | 192 | { | ||
175 | QList<KReportItemBase*> obs; | 193 | QList<KReportItemBase*> obs; | ||
176 | for (int i = 1; i <= KReportSectionData::PageFooterAny; i++) { | 194 | for (int i = 1; i <= KReportSectionData::PageFooterAny; i++) { | ||
177 | KReportSectionData *sec = section((KReportSectionData::Section)i); | 195 | KReportSectionData *sec = section((KReportSectionData::Section)i); | ||
178 | if (sec) { | 196 | if (sec) { | ||
179 | obs << sec->objects(); | 197 | obs << sec->objects(); | ||
180 | } | 198 | } | ||
▲ Show 20 Lines • Show All 114 Lines • ▼ Show 20 Line(s) | 274 | { | |||
295 | default: | 313 | default: | ||
296 | sec = 0; | 314 | sec = 0; | ||
297 | } | 315 | } | ||
298 | return sec; | 316 | return sec; | ||
299 | } | 317 | } | ||
300 | 318 | | |||
301 | KReportPageOptions KReportDocument::pageOptions() const | 319 | KReportPageOptions KReportDocument::pageOptions() const | ||
302 | { | 320 | { | ||
303 | return page; | 321 | return d->page; | ||
322 | } | ||||
323 | | ||||
324 | bool KReportDocument::isValid() const | ||||
325 | { | ||||
326 | return d->valid; | ||||
327 | } | ||||
328 | | ||||
329 | QString KReportDocument::title() const | ||||
330 | { | ||||
331 | return d->title; | ||||
332 | } | ||||
333 | | ||||
334 | bool KReportDocument::externalData() const | ||||
335 | { | ||||
336 | return d->externalData; | ||||
337 | } | ||||
338 | | ||||
339 | QString KReportDocument::interpreter() const | ||||
340 | { | ||||
341 | return d->interpreter; | ||||
342 | } | ||||
343 | | ||||
344 | QString KReportDocument::name() const | ||||
345 | { | ||||
346 | return d->name; | ||||
347 | } | ||||
348 | | ||||
349 | void KReportDocument::setName(const QString& n) | ||||
350 | { | ||||
351 | d->name = n; | ||||
352 | } | ||||
353 | | ||||
354 | QString KReportDocument::query() const | ||||
355 | { | ||||
356 | return d->query; | ||||
357 | } | ||||
358 | | ||||
359 | QString KReportDocument::script() const | ||||
360 | { | ||||
361 | return d->script; | ||||
304 | } | 362 | } |
-> class Q_DECL_HIDDEN KReportDocument::Private
Please see T4016