Changeset View
Changeset View
Standalone View
Standalone View
src/common/KReportDocument.cpp
Show All 35 Lines | |||||
36 | #ifdef KREPORT_SCRIPTING | 36 | #ifdef KREPORT_SCRIPTING | ||
37 | QString script; | 37 | QString script; | ||
38 | QString interpreter; | 38 | QString interpreter; | ||
39 | #endif | 39 | #endif | ||
40 | bool externalData; | 40 | bool externalData; | ||
41 | KReportPrivate::PageLayout pageLayout; | 41 | KReportPrivate::PageLayout pageLayout; | ||
42 | QString pageSize; | 42 | QString pageSize; | ||
43 | QString labelType; | 43 | QString labelType; | ||
44 | }; | | |||
45 | 44 | | |||
46 | void KReportDocument::init() | 45 | KReportSectionData * pageHeaderFirst = nullptr; | ||
47 | { | 46 | KReportSectionData * pageHeaderOdd = nullptr; | ||
48 | m_pageHeaderFirst = m_pageHeaderOdd = m_pageHeaderEven = m_pageHeaderLast = m_pageHeaderAny = nullptr; | 47 | KReportSectionData * pageHeaderEven = nullptr; | ||
49 | m_pageFooterFirst = m_pageFooterOdd = m_pageFooterEven = m_pageFooterLast = m_pageFooterAny = nullptr; | 48 | KReportSectionData * pageHeaderLast = nullptr; | ||
50 | m_reportHeader = m_reportFooter = nullptr; | 49 | KReportSectionData * pageHeaderAny = nullptr; | ||
51 | } | 50 | | ||
51 | KReportSectionData * reportHeader = nullptr; | ||||
52 | KReportSectionData * reportFooter = nullptr; | ||||
53 | | ||||
54 | KReportSectionData * pageFooterFirst = nullptr; | ||||
55 | KReportSectionData * pageFooterOdd = nullptr; | ||||
56 | KReportSectionData * pageFooterEven = nullptr; | ||||
57 | KReportSectionData * pageFooterLast = nullptr; | ||||
58 | KReportSectionData * pageFooterAny = nullptr; | ||||
59 | | ||||
60 | KReportDetailSectionData* detailSection; | ||||
61 | }; | ||||
52 | 62 | | |||
53 | KReportDocument::KReportDocument(QObject *parent) | 63 | KReportDocument::KReportDocument(QObject *parent) | ||
54 | : QObject(parent), | 64 | : QObject(parent), | ||
55 | m_detailSection(nullptr), | | |||
staniek: I miss detailSection initialization for this ctor. Am I right? | |||||
56 | d(new Private()) | 65 | d(new Private()) | ||
57 | { | 66 | { | ||
58 | init(); | | |||
59 | d->valid = true; | 67 | d->valid = true; | ||
60 | } | 68 | } | ||
61 | 69 | | |||
62 | KReportDocument::KReportDocument(const QDomElement & elemSource, QObject *parent) | 70 | KReportDocument::KReportDocument(const QDomElement & elemSource, QObject *parent) | ||
63 | : QObject(parent), | 71 | : QObject(parent), | ||
64 | m_detailSection(nullptr), | | |||
65 | d(new Private()) | 72 | d(new Private()) | ||
66 | { | 73 | { | ||
67 | d->valid = false; | 74 | d->valid = false; | ||
68 | init(); | 75 | | ||
69 | //kreportDebug(); | | |||
70 | if (elemSource.tagName() != QLatin1String("report:content")) { | 76 | if (elemSource.tagName() != QLatin1String("report:content")) { | ||
71 | kreportWarning() << "QDomElement is not <report:content> tag" | 77 | kreportWarning() << "QDomElement is not <report:content> tag" | ||
72 | << elemSource.text(); | 78 | << elemSource.text(); | ||
73 | return; | 79 | return; | ||
74 | } | 80 | } | ||
75 | 81 | | |||
76 | QDomNodeList sections = elemSource.childNodes(); | 82 | QDomNodeList sections = elemSource.childNodes(); | ||
77 | for (int nodeCounter = 0; nodeCounter < sections.count(); nodeCounter++) { | 83 | for (int nodeCounter = 0; nodeCounter < sections.count(); nodeCounter++) { | ||
▲ Show 20 Lines • Show All 42 Lines • ▼ Show 20 Line(s) | 125 | if (sn == QLatin1String("report:section")) { | |||
120 | KReportSectionData * sd = new KReportSectionData(sec.toElement(), this); | 126 | KReportSectionData * sd = new KReportSectionData(sec.toElement(), this); | ||
121 | if (!sd->isValid()) { | 127 | if (!sd->isValid()) { | ||
122 | kreportDebug() << "Invalid section"; | 128 | kreportDebug() << "Invalid section"; | ||
123 | delete sd; | 129 | delete sd; | ||
124 | } else { | 130 | } else { | ||
125 | //kreportDebug() << "Adding section of type " << sd->type(); | 131 | //kreportDebug() << "Adding section of type " << sd->type(); | ||
126 | switch (sd->type()) { | 132 | switch (sd->type()) { | ||
127 | case KReportSectionData::Type::PageHeaderFirst: | 133 | case KReportSectionData::Type::PageHeaderFirst: | ||
128 | m_pageHeaderFirst = sd; | 134 | d->pageHeaderFirst = sd; | ||
129 | break; | 135 | break; | ||
130 | case KReportSectionData::Type::PageHeaderOdd: | 136 | case KReportSectionData::Type::PageHeaderOdd: | ||
131 | m_pageHeaderOdd = sd; | 137 | d->pageHeaderOdd = sd; | ||
132 | break; | 138 | break; | ||
133 | case KReportSectionData::Type::PageHeaderEven: | 139 | case KReportSectionData::Type::PageHeaderEven: | ||
134 | m_pageHeaderEven = sd; | 140 | d->pageHeaderEven = sd; | ||
135 | break; | 141 | break; | ||
136 | case KReportSectionData::Type::PageHeaderLast: | 142 | case KReportSectionData::Type::PageHeaderLast: | ||
137 | m_pageHeaderLast = sd; | 143 | d->pageHeaderLast = sd; | ||
138 | break; | 144 | break; | ||
139 | case KReportSectionData::Type::PageHeaderAny: | 145 | case KReportSectionData::Type::PageHeaderAny: | ||
140 | m_pageHeaderAny = sd; | 146 | d->pageHeaderAny = sd; | ||
141 | break; | 147 | break; | ||
142 | case KReportSectionData::Type::ReportHeader: | 148 | case KReportSectionData::Type::ReportHeader: | ||
143 | m_reportHeader = sd; | 149 | d->reportHeader = sd; | ||
144 | break; | 150 | break; | ||
145 | case KReportSectionData::Type::ReportFooter: | 151 | case KReportSectionData::Type::ReportFooter: | ||
146 | m_reportFooter = sd; | 152 | d->reportFooter = sd; | ||
147 | break; | 153 | break; | ||
148 | case KReportSectionData::Type::PageFooterFirst: | 154 | case KReportSectionData::Type::PageFooterFirst: | ||
149 | m_pageFooterFirst = sd; | 155 | d->pageFooterFirst = sd; | ||
150 | break; | 156 | break; | ||
151 | case KReportSectionData::Type::PageFooterOdd: | 157 | case KReportSectionData::Type::PageFooterOdd: | ||
152 | m_pageFooterOdd = sd; | 158 | d->pageFooterOdd = sd; | ||
153 | break; | 159 | break; | ||
154 | case KReportSectionData::Type::PageFooterEven: | 160 | case KReportSectionData::Type::PageFooterEven: | ||
155 | m_pageFooterEven = sd; | 161 | d->pageFooterEven = sd; | ||
156 | break; | 162 | break; | ||
157 | case KReportSectionData::Type::PageFooterLast: | 163 | case KReportSectionData::Type::PageFooterLast: | ||
158 | m_pageFooterLast = sd; | 164 | d->pageFooterLast = sd; | ||
159 | break; | 165 | break; | ||
160 | case KReportSectionData::Type::PageFooterAny: | 166 | case KReportSectionData::Type::PageFooterAny: | ||
161 | m_pageFooterAny = sd; | 167 | d->pageFooterAny = sd; | ||
162 | break; | 168 | break; | ||
163 | default: | 169 | default: | ||
164 | ; | 170 | ; | ||
165 | } | 171 | } | ||
166 | } | 172 | } | ||
167 | 173 | | |||
168 | } else if (sn == QLatin1String("report:detail")) { | 174 | } else if (sn == QLatin1String("report:detail")) { | ||
169 | KReportDetailSectionData * dsd = new KReportDetailSectionData(sec.toElement(), this); | 175 | KReportDetailSectionData * dsd = new KReportDetailSectionData(sec.toElement(), this); | ||
170 | 176 | | |||
171 | if (dsd->isValid()) { | 177 | if (dsd->isValid()) { | ||
172 | m_detailSection = dsd; | 178 | d->detailSection = dsd; | ||
173 | } else { | 179 | } else { | ||
174 | kreportDebug() << "Invalid detail section"; | 180 | kreportDebug() << "Invalid detail section"; | ||
175 | delete dsd; | 181 | delete dsd; | ||
176 | } | 182 | } | ||
177 | } | 183 | } | ||
178 | } else { | 184 | } else { | ||
179 | kreportWarning() << "Encountered an unknown Element: " << elemThis.tagName(); | 185 | kreportWarning() << "Encountered an unknown Element: " << elemThis.tagName(); | ||
180 | } | 186 | } | ||
Show All 16 Lines | 202 | for (int i = static_cast<int>(KReportSectionData::Type::PageHeaderFirst); | |||
197 | i <= static_cast<int>(KReportSectionData::Type::PageFooterAny); i++) | 203 | i <= static_cast<int>(KReportSectionData::Type::PageFooterAny); i++) | ||
198 | { | 204 | { | ||
199 | KReportSectionData *sec = section(static_cast<KReportSectionData::Type>(i)); | 205 | KReportSectionData *sec = section(static_cast<KReportSectionData::Type>(i)); | ||
200 | if (sec) { | 206 | if (sec) { | ||
201 | obs << sec->objects(); | 207 | obs << sec->objects(); | ||
202 | } | 208 | } | ||
203 | } | 209 | } | ||
204 | 210 | | |||
205 | if (m_detailSection) { | 211 | if (d->detailSection) { | ||
206 | //kreportDebug() << "Number of groups: " << m_detailSection->m_groupList.count(); | 212 | //kreportDebug() << "Number of groups: " << m_detailSection->m_groupList.count(); | ||
207 | foreach(KReportDetailGroupSectionData* g, m_detailSection->groupList) { | 213 | foreach(KReportDetailGroupSectionData* g, d->detailSection->groupList) { | ||
208 | if (g->groupHeader) { | 214 | if (g->groupHeader) { | ||
209 | obs << g->groupHeader->objects(); | 215 | obs << g->groupHeader->objects(); | ||
210 | } | 216 | } | ||
211 | if (g->groupFooter) { | 217 | if (g->groupFooter) { | ||
212 | obs << g->groupFooter->objects(); | 218 | obs << g->groupFooter->objects(); | ||
213 | } | 219 | } | ||
214 | } | 220 | } | ||
215 | if (m_detailSection->detailSection) | 221 | if (d->detailSection->detailSection) | ||
216 | obs << m_detailSection->detailSection->objects(); | 222 | obs << d->detailSection->detailSection->objects(); | ||
217 | } | 223 | } | ||
218 | 224 | | |||
219 | /*kreportDebug() << "Object List:"; | 225 | /*kreportDebug() << "Object List:"; | ||
220 | foreach(KReportItemBase* o, obs) { | 226 | foreach(KReportItemBase* o, obs) { | ||
221 | kreportDebug() << o->entityName(); | 227 | kreportDebug() << o->entityName(); | ||
222 | }*/ | 228 | }*/ | ||
223 | return obs; | 229 | return obs; | ||
224 | } | 230 | } | ||
Show All 17 Lines | 247 | for (int i = static_cast<int>(KReportSectionData::Type::PageHeaderFirst); | |||
242 | i <= static_cast<int>(KReportSectionData::Type::PageFooterAny); i++) | 248 | i <= static_cast<int>(KReportSectionData::Type::PageFooterAny); i++) | ||
243 | { | 249 | { | ||
244 | KReportSectionData *sec = section(static_cast<KReportSectionData::Type>(i)); | 250 | KReportSectionData *sec = section(static_cast<KReportSectionData::Type>(i)); | ||
245 | if (sec) { | 251 | if (sec) { | ||
246 | secs << sec; | 252 | secs << sec; | ||
247 | } | 253 | } | ||
248 | } | 254 | } | ||
249 | 255 | | |||
250 | if (m_detailSection) { | 256 | if (d->detailSection) { | ||
251 | //kreportDebug() << "Number of groups: " << m_detailSection->m_groupList.count(); | 257 | //kreportDebug() << "Number of groups: " << m_detailSection->m_groupList.count(); | ||
252 | foreach(KReportDetailGroupSectionData* g, m_detailSection->groupList) { | 258 | foreach(KReportDetailGroupSectionData* g, d->detailSection->groupList) { | ||
253 | if (g->groupHeader) { | 259 | if (g->groupHeader) { | ||
254 | secs << g->groupHeader; | 260 | secs << g->groupHeader; | ||
255 | } | 261 | } | ||
256 | if (g->groupFooter) { | 262 | if (g->groupFooter) { | ||
257 | secs << g->groupFooter; | 263 | secs << g->groupFooter; | ||
258 | } | 264 | } | ||
259 | } | 265 | } | ||
260 | if (m_detailSection->detailSection) | 266 | if (d->detailSection->detailSection) | ||
261 | secs << m_detailSection->detailSection; | 267 | secs << d->detailSection->detailSection; | ||
262 | } | 268 | } | ||
263 | 269 | | |||
264 | return secs; | 270 | return secs; | ||
265 | } | 271 | } | ||
266 | 272 | | |||
267 | KReportSectionData* KReportDocument::section(const QString& sn) const | 273 | KReportSectionData* KReportDocument::section(const QString& sn) const | ||
268 | { | 274 | { | ||
269 | QList<KReportSectionData*> secs = sections(); | 275 | QList<KReportSectionData*> secs = sections(); | ||
270 | 276 | | |||
271 | foreach(KReportSectionData *sec, secs) { | 277 | foreach(KReportSectionData *sec, secs) { | ||
272 | if (sec->name() == sn) { | 278 | if (sec->name() == sn) { | ||
273 | return sec; | 279 | return sec; | ||
274 | } | 280 | } | ||
275 | } | 281 | } | ||
276 | return nullptr; | 282 | return nullptr; | ||
277 | } | 283 | } | ||
278 | 284 | | |||
279 | KReportSectionData* KReportDocument::section(KReportSectionData::Type type) const | 285 | KReportSectionData* KReportDocument::section(KReportSectionData::Type type) const | ||
280 | { | 286 | { | ||
281 | KReportSectionData *sec; | 287 | KReportSectionData *sec; | ||
282 | switch (type) { | 288 | switch (type) { | ||
283 | case KReportSectionData::Type::PageHeaderAny: | 289 | case KReportSectionData::Type::PageHeaderAny: | ||
284 | sec = m_pageHeaderAny; | 290 | sec = d->pageHeaderAny; | ||
285 | break; | 291 | break; | ||
286 | case KReportSectionData::Type::PageHeaderEven: | 292 | case KReportSectionData::Type::PageHeaderEven: | ||
287 | sec = m_pageHeaderEven; | 293 | sec = d->pageHeaderEven; | ||
288 | break; | 294 | break; | ||
289 | case KReportSectionData::Type::PageHeaderOdd: | 295 | case KReportSectionData::Type::PageHeaderOdd: | ||
290 | sec = m_pageHeaderOdd; | 296 | sec = d->pageHeaderOdd; | ||
291 | break; | 297 | break; | ||
292 | case KReportSectionData::Type::PageHeaderFirst: | 298 | case KReportSectionData::Type::PageHeaderFirst: | ||
293 | sec = m_pageHeaderFirst; | 299 | sec = d->pageHeaderFirst; | ||
294 | break; | 300 | break; | ||
295 | case KReportSectionData::Type::PageHeaderLast: | 301 | case KReportSectionData::Type::PageHeaderLast: | ||
296 | sec = m_pageHeaderLast; | 302 | sec = d->pageHeaderLast; | ||
297 | break; | 303 | break; | ||
298 | case KReportSectionData::Type::PageFooterAny: | 304 | case KReportSectionData::Type::PageFooterAny: | ||
299 | sec = m_pageFooterAny; | 305 | sec = d->pageFooterAny; | ||
300 | break; | 306 | break; | ||
301 | case KReportSectionData::Type::PageFooterEven: | 307 | case KReportSectionData::Type::PageFooterEven: | ||
302 | sec = m_pageFooterEven; | 308 | sec = d->pageFooterEven; | ||
303 | break; | 309 | break; | ||
304 | case KReportSectionData::Type::PageFooterOdd: | 310 | case KReportSectionData::Type::PageFooterOdd: | ||
305 | sec = m_pageFooterOdd; | 311 | sec = d->pageFooterOdd; | ||
306 | break; | 312 | break; | ||
307 | case KReportSectionData::Type::PageFooterFirst: | 313 | case KReportSectionData::Type::PageFooterFirst: | ||
308 | sec = m_pageFooterFirst; | 314 | sec = d->pageFooterFirst; | ||
309 | break; | 315 | break; | ||
310 | case KReportSectionData::Type::PageFooterLast: | 316 | case KReportSectionData::Type::PageFooterLast: | ||
311 | sec = m_pageFooterLast; | 317 | sec = d->pageFooterLast; | ||
312 | break; | 318 | break; | ||
313 | case KReportSectionData::Type::ReportHeader: | 319 | case KReportSectionData::Type::ReportHeader: | ||
314 | sec = m_reportHeader; | 320 | sec = d->reportHeader; | ||
315 | break; | 321 | break; | ||
316 | case KReportSectionData::Type::ReportFooter: | 322 | case KReportSectionData::Type::ReportFooter: | ||
317 | sec = m_reportFooter; | 323 | sec = d->reportFooter; | ||
318 | break; | 324 | break; | ||
319 | default: | 325 | default: | ||
320 | sec = nullptr; | 326 | sec = nullptr; | ||
321 | } | 327 | } | ||
322 | return sec; | 328 | return sec; | ||
323 | } | 329 | } | ||
324 | 330 | | |||
325 | QPageLayout KReportDocument::pageLayout() const | 331 | QPageLayout KReportDocument::pageLayout() const | ||
▲ Show 20 Lines • Show All 55 Lines • ▼ Show 20 Line(s) | |||||
381 | { | 387 | { | ||
382 | return d->labelType; | 388 | return d->labelType; | ||
383 | } | 389 | } | ||
384 | 390 | | |||
385 | void KReportDocument::setLabelType(const QString& label) | 391 | void KReportDocument::setLabelType(const QString& label) | ||
386 | { | 392 | { | ||
387 | d->labelType = label; | 393 | d->labelType = label; | ||
388 | } | 394 | } | ||
395 | | ||||
396 | KReportDetailSectionData * KReportDocument::detail() const | ||||
397 | { | ||||
398 | return d->detailSection; | ||||
399 | } | ||||
400 | |
I miss detailSection initialization for this ctor. Am I right?