Changeset View
Changeset View
Standalone View
Standalone View
src/common/KReportRenderObjects.cpp
Show All 13 Lines | |||||
14 | * | 14 | * | ||
15 | * You should have received a copy of the GNU Lesser General Public | 15 | * You should have received a copy of the GNU Lesser General Public | ||
16 | * License along with this library. If not, see <http://www.gnu.org/licenses/>. | 16 | * License along with this library. If not, see <http://www.gnu.org/licenses/>. | ||
17 | */ | 17 | */ | ||
18 | #include "KReportRenderObjects.h" | 18 | #include "KReportRenderObjects.h" | ||
19 | 19 | | |||
20 | #include "kreport_debug.h" | 20 | #include "kreport_debug.h" | ||
21 | 21 | | |||
22 | // Helper functions | ||||
23 | static bool xLessThan(OROPrimitive* s1, OROPrimitive* s2) | ||||
staniek: Let's have `static` or use `namespace { }` | |||||
24 | { | ||||
25 | return s1->position().x() < s2->position().x(); | ||||
26 | } | ||||
27 | | ||||
22 | // | 28 | // | ||
23 | // ORODocument | 29 | // ORODocument | ||
24 | // | 30 | // | ||
25 | ORODocument::ORODocument(const QString & pTitle) | 31 | | ||
26 | : m_title(pTitle) | 32 | class Q_DECL_HIDDEN ORODocument::Private | ||
33 | { | ||||
34 | public: | ||||
35 | Private(); | ||||
36 | ~Private(); | ||||
37 | QString title; | ||||
38 | QList<OROPage*> pages; | ||||
39 | QList<OROSection*> sections; | ||||
40 | QPageLayout pageLayout; | ||||
41 | }; | ||||
42 | | ||||
43 | ORODocument::Private::Private() | ||||
44 | { | ||||
45 | | ||||
46 | } | ||||
47 | | ||||
48 | ORODocument::Private::~Private() | ||||
27 | { | 49 | { | ||
50 | qDeleteAll(pages); | ||||
51 | qDeleteAll(sections); | ||||
28 | } | 52 | } | ||
29 | 53 | | |||
30 | ORODocument::~ORODocument() | 54 | | ||
55 | ORODocument::ORODocument(const QString& title) : d(new Private()) | ||||
31 | { | 56 | { | ||
32 | qDeleteAll(m_pages); | 57 | d->title = title; | ||
33 | m_pages.clear(); | 58 | } | ||
34 | 59 | | |||
35 | qDeleteAll(m_sections); | 60 | ORODocument::~ORODocument() | ||
36 | m_sections.clear(); | 61 | { | ||
62 | delete d; | ||||
37 | } | 63 | } | ||
staniek: clear is not really needed | |||||
38 | 64 | | |||
39 | void ORODocument::setTitle(const QString & pTitle) | 65 | void ORODocument::setTitle(const QString &title) | ||
40 | { | 66 | { | ||
staniek: same here | |||||
41 | m_title = pTitle; | 67 | d->title = title; | ||
42 | } | 68 | } | ||
43 | 69 | | |||
44 | OROPage* ORODocument::page(int pnum) | 70 | OROPage* ORODocument::page(int index) | ||
45 | { | 71 | { | ||
46 | if (pnum >= 0 && pnum < m_pages.count()) { | 72 | return d->pages.value(index); | ||
47 | return m_pages.at(pnum); | | |||
48 | } | 73 | } | ||
49 | return Q_NULLPTR; | 74 | | ||
75 | const OROPage * ORODocument::page(int index) const | ||||
76 | { | ||||
77 | return d->pages.value(index); | ||||
staniek: I propose to use just .value() | |||||
staniek: Second arg not needed | |||||
50 | } | 78 | } | ||
51 | 79 | | |||
52 | void ORODocument::addPage(OROPage* p) | 80 | void ORODocument::addPage(OROPage* p) | ||
53 | { | 81 | { | ||
54 | if (p == 0) | 82 | if (p == 0) { | ||
Second arg not needed, default constructed value is returned here, which for Qt is nullptr. staniek: Second arg not needed, default constructed value is returned here, which for Qt is nullptr. | |||||
55 | return; | 83 | return; | ||
84 | } | ||||
56 | 85 | | |||
57 | // check that this page is not already in another document | 86 | if (p->document() != 0 && p->document() != this) { | ||
87 | return; | ||||
88 | } | ||||
58 | 89 | | |||
59 | p->m_document = this; | 90 | p->setDocument(this); | ||
60 | m_pages.append(p); | 91 | d->pages.append(p); | ||
61 | } | 92 | } | ||
62 | 93 | | |||
63 | OROSection* ORODocument::section(int pnum) | 94 | OROSection* ORODocument::section(int pnum) | ||
64 | { | 95 | { | ||
65 | return m_sections.at(pnum); | 96 | return d->sections.value(pnum); | ||
97 | } | ||||
98 | | ||||
99 | const OROSection * ORODocument::section(int index) const | ||||
100 | { | ||||
101 | return d->sections.value(index); | ||||
staniek: `pnum` must be a valid index position in the list
So I propose to use .value() | |||||
staniek: Second arg not needed | |||||
66 | } | 102 | } | ||
67 | 103 | | |||
104 | | ||||
68 | void ORODocument::addSection(OROSection* s) | 105 | void ORODocument::addSection(OROSection* s) | ||
69 | { | 106 | { | ||
staniek: Second arg not needed | |||||
70 | if (s == 0) | 107 | if (s == 0) | ||
71 | return; | 108 | return; | ||
72 | 109 | | |||
73 | // check that this page is not already in another document | 110 | if (s->document() != 0 && s->document() != this) { | ||
staniek: yes, let's implement that | |||||
74 | 111 | return; | |||
75 | s->m_document = this; | 112 | } | ||
76 | m_sections.append(s); | 113 | s->setDocument(this); | ||
114 | d->sections.append(s); | ||||
77 | } | 115 | } | ||
78 | 116 | | |||
79 | void ORODocument::setPageLayout(const QPageLayout & options) | 117 | void ORODocument::setPageLayout(const QPageLayout & options) | ||
80 | { | 118 | { | ||
81 | m_pageLayout = options; | 119 | d->pageLayout = options; | ||
82 | } | 120 | } | ||
83 | 121 | | |||
84 | void ORODocument::notifyChange(int pageNo) | 122 | void ORODocument::notifyChange(int pageNo) | ||
85 | { | 123 | { | ||
86 | emit(updated(pageNo)); | 124 | emit(updated(pageNo)); | ||
87 | } | 125 | } | ||
88 | 126 | | |||
127 | QPageLayout ORODocument::pageLayout() const | ||||
128 | { | ||||
129 | return d->pageLayout; | ||||
130 | } | ||||
131 | | ||||
132 | int ORODocument::pageCount() const | ||||
133 | { | ||||
134 | return d->pages.count(); | ||||
135 | } | ||||
136 | | ||||
137 | int ORODocument::sectionCount() const | ||||
138 | { | ||||
139 | return d->sections.count(); | ||||
140 | } | ||||
141 | | ||||
142 | QString ORODocument::title() const | ||||
143 | { | ||||
144 | return d->title; | ||||
145 | } | ||||
146 | | ||||
147 | void ORODocument::removePage(OROPage* page) | ||||
148 | { | ||||
149 | d->pages.removeOne(page); | ||||
staniek: For symmetry don't we want to also delete page? | |||||
150 | delete page; | ||||
151 | } | ||||
152 | | ||||
153 | void ORODocument::takePage(OROPage* page) | ||||
154 | { | ||||
staniek: For symmetry don't we want to also delete section? | |||||
155 | d->pages.removeOne(page); | ||||
156 | } | ||||
157 | | ||||
158 | void ORODocument::removeSection(OROSection* section) | ||||
159 | { | ||||
staniek: -> QList::indexOf() | |||||
160 | d->sections.removeOne(section); | ||||
161 | delete section; | ||||
162 | } | ||||
163 | | ||||
164 | void ORODocument::takeSection(OROSection* section) | ||||
165 | { | ||||
166 | d->sections.removeOne(section); | ||||
167 | } | ||||
168 | | ||||
169 | int ORODocument::pageIndex(const OROPage* page) const | ||||
170 | { | ||||
171 | return d->pages.indexOf(const_cast<OROPage*>(page)); | ||||
172 | } | ||||
173 | | ||||
89 | // | 174 | // | ||
90 | // OROPage | 175 | // OROPage | ||
91 | // | 176 | // | ||
92 | OROPage::OROPage(ORODocument * pDocument) | 177 | class Q_DECL_HIDDEN OROPage::Private | ||
93 | : m_document(pDocument) | | |||
94 | { | 178 | { | ||
179 | public: | ||||
180 | Private(); | ||||
181 | ~Private(); | ||||
182 | ORODocument *document; | ||||
183 | QList<OROPrimitive*> primitives; | ||||
184 | }; | ||||
95 | 185 | | |||
186 | OROPage::Private::Private() | ||||
187 | { | ||||
96 | } | 188 | } | ||
97 | 189 | | |||
staniek: not really needed | |||||
98 | OROPage::~OROPage() | 190 | OROPage::Private::~Private() | ||
99 | { | 191 | { | ||
100 | if (m_document) { | 192 | qDeleteAll(primitives); | ||
101 | m_document->m_pages.removeOne(this); | | |||
102 | m_document = 0; | | |||
103 | } | 193 | } | ||
104 | 194 | | |||
105 | qDeleteAll(m_primitives); | 195 | OROPage::OROPage(ORODocument * pDocument) | ||
106 | m_primitives.clear(); | 196 | : d(new Private()) | ||
197 | { | ||||
198 | d->document = pDocument; | ||||
107 | } | 199 | } | ||
108 | 200 | | |||
109 | int OROPage::page() const | 201 | OROPage::~OROPage() | ||
110 | { | 202 | { | ||
111 | if (m_document) { | 203 | if (d->document) { | ||
112 | for (int i = 0; i < m_document->m_pages.size(); i++) { | 204 | d->document->takePage(this); | ||
If we add delete to ORODocument::removePage() this line won't be correct. Either:
staniek: If we add `delete` to ORODocument::removePage() this line won't be correct. Either:
- Add void… | |||||
113 | if (m_document->m_pages.at(i) == this) | | |||
114 | return i; | | |||
115 | } | 205 | } | ||
staniek: not really needed | |||||
206 | delete d; | ||||
207 | } | ||||
208 | | ||||
209 | int OROPage::pageNumber() const | ||||
210 | { | ||||
211 | if (d->document) { | ||||
212 | return d->document->pageIndex(this); | ||||
116 | } | 213 | } | ||
117 | return -1; | 214 | return -1; | ||
118 | } | 215 | } | ||
119 | 216 | | |||
staniek: REVIEWED until this line. TODO: later | |||||
120 | OROPrimitive* OROPage::primitive(int idx) | 217 | OROPrimitive* OROPage::primitive(int index) | ||
218 | { | ||||
219 | return d->primitives.value(index); | ||||
220 | } | ||||
221 | | ||||
222 | const OROPrimitive * OROPage::primitive(int index) const | ||||
121 | { | 223 | { | ||
122 | return m_primitives.at(idx); | 224 | return d->primitives.value(index); | ||
staniek: Second arg not needed | |||||
123 | } | 225 | } | ||
124 | 226 | | |||
125 | void OROPage::addPrimitive(OROPrimitive* p, bool atBeginning, bool notify) | 227 | | ||
228 | void OROPage::insertPrimitive(OROPrimitive* p, int index) | ||||
126 | { | 229 | { | ||
staniek: Second arg not needed | |||||
127 | //kreportDebug() << "Adding primitive" << p->type() << "to page" << page(); | 230 | //kreportDebug() << "Adding primitive" << p->type() << "to page" << page(); | ||
128 | if (p == 0) | 231 | if (p == 0) | ||
129 | return; | 232 | return; | ||
130 | 233 | | |||
131 | // check that this primitve is not already in another page | 234 | p->setPage(this); | ||
132 | 235 | if (index == -1) { | |||
133 | p->m_page = this; | 236 | d->primitives.append(p); | ||
134 | if (atBeginning) { | | |||
135 | m_primitives.prepend(p); | | |||
136 | } else { | 237 | } else { | ||
137 | m_primitives.append(p); | 238 | d->primitives.insert(index, p); | ||
138 | } | 239 | } | ||
139 | 240 | | |||
241 | #if 0 | ||||
242 | //TODO | ||||
140 | if (notify) { | 243 | if (notify) { | ||
141 | if (m_document) { | 244 | if (d->document) { | ||
142 | m_document->notifyChange(page()); | 245 | d->document->notifyChange(pageNumber()); | ||
246 | } | ||||
247 | } | ||||
248 | #endif | ||||
249 | } | ||||
250 | | ||||
251 | ORODocument * OROPage::document() | ||||
252 | { | ||||
253 | return d->document; | ||||
254 | } | ||||
255 | | ||||
256 | const ORODocument * OROPage::document() const | ||||
257 | { | ||||
258 | return d->document; | ||||
259 | } | ||||
260 | | ||||
261 | int OROPage::primitiveCount() const | ||||
262 | { | ||||
263 | return d->primitives.count(); | ||||
264 | } | ||||
265 | | ||||
266 | void OROPage::setDocument(ORODocument* doc) | ||||
267 | { | ||||
268 | d->document = doc; | ||||
143 | } | 269 | } | ||
270 | | ||||
271 | void OROPage::removePrimitive(OROPrimitive* primitive) | ||||
272 | { | ||||
273 | d->primitives.removeOne(primitive); | ||||
staniek: For symmetry don't we want to also delete primitive? | |||||
274 | delete primitive; | ||||
144 | } | 275 | } | ||
276 | | ||||
277 | void OROPage::takePrimitive(OROPrimitive* primitive) | ||||
278 | { | ||||
279 | d->primitives.removeOne(primitive); | ||||
145 | } | 280 | } | ||
146 | 281 | | |||
147 | // | 282 | // | ||
148 | // OROSection | 283 | // OROSection | ||
149 | // | 284 | // | ||
150 | OROSection::OROSection(ORODocument * pDocument) | 285 | | ||
151 | : m_document(pDocument) | 286 | class Q_DECL_HIDDEN OROSection::Private | ||
287 | { | ||||
288 | public: | ||||
289 | Private(); | ||||
290 | ~Private(); | ||||
291 | ORODocument * document; | ||||
292 | QList<OROPrimitive*> primitives; | ||||
293 | qint64 row; | ||||
staniek: KReport::recordCount() is qint64 so how about using qint64 here too? | |||||
294 | int height; | ||||
295 | KReportSectionData::Section type; | ||||
296 | QColor backgroundColor; | ||||
297 | }; | ||||
298 | | ||||
299 | OROSection::Private::Private() | ||||
staniek: Let's initialize all members here because it's possible.
| |||||
300 | { | ||||
301 | height = 0; | ||||
302 | backgroundColor = Qt::white; | ||||
303 | } | ||||
304 | | ||||
305 | OROSection::Private::~Private() | ||||
152 | { | 306 | { | ||
153 | m_height = 0; | 307 | qDeleteAll(primitives); | ||
154 | m_backgroundColor = Qt::white; | 308 | primitives.clear(); | ||
309 | } | ||||
310 | | ||||
311 | OROSection::OROSection(ORODocument* doc) : d(new Private()) | ||||
312 | { | ||||
313 | d->document = doc; | ||||
155 | } | 314 | } | ||
156 | 315 | | |||
157 | OROSection::~OROSection() | 316 | OROSection::~OROSection() | ||
158 | { | 317 | { | ||
159 | if (m_document) { | 318 | if (d->document) { | ||
160 | m_document->m_sections.removeOne(this); | 319 | d->document->takeSection(this); | ||
If we add delete to ORODocument::removeSection() this line won't be correct. Either:
staniek: If we add `delete` to ORODocument::removeSection() this line won't be correct. Either:
- Add… | |||||
161 | m_document = 0; | | |||
162 | } | 320 | } | ||
163 | 321 | | |||
164 | qDeleteAll(m_primitives); | 322 | delete d; | ||
165 | m_primitives.clear(); | | |||
166 | } | 323 | } | ||
167 | 324 | | |||
168 | OROPrimitive* OROSection::primitive(int idx) | 325 | OROPrimitive* OROSection::primitive(int index) | ||
169 | { | 326 | { | ||
170 | return m_primitives.at(idx); | 327 | return d->primitives.value(index); | ||
staniek: Second arg not needed | |||||
171 | } | 328 | } | ||
172 | 329 | | |||
173 | void OROSection::addPrimitive(OROPrimitive* p) | 330 | const OROPrimitive * OROSection::primitive(int index) const | ||
174 | { | 331 | { | ||
175 | if (p == 0) | 332 | return d->primitives.value(index); | ||
staniek: Second arg not needed | |||||
333 | } | ||||
334 | | ||||
335 | void OROSection::addPrimitive(OROPrimitive* primitive) | ||||
336 | { | ||||
337 | if (primitive == 0) | ||||
176 | return; | 338 | return; | ||
177 | 339 | | |||
178 | m_primitives.append(p); | 340 | d->primitives.append(primitive); | ||
179 | } | 341 | } | ||
180 | 342 | | |||
181 | void OROSection::setHeight(int h) | 343 | void OROSection::setHeight(int h) | ||
182 | { | 344 | { | ||
183 | m_height = h; | 345 | d->height = h; | ||
184 | } | 346 | } | ||
185 | 347 | | |||
186 | int OROSection::height() | 348 | int OROSection::height() const | ||
187 | { | 349 | { | ||
188 | return m_height; | 350 | return d->height; | ||
189 | } | 351 | } | ||
190 | 352 | | |||
191 | void OROSection::setBackgroundColor(const QColor &c) | 353 | void OROSection::setBackgroundColor(const QColor& color) | ||
192 | { | 354 | { | ||
193 | m_backgroundColor = c; | 355 | d->backgroundColor = color; | ||
194 | } | 356 | } | ||
195 | 357 | | |||
196 | QColor OROSection::backgroundColor() | 358 | QColor OROSection::backgroundColor() const | ||
197 | { | 359 | { | ||
198 | return m_backgroundColor; | 360 | return d->backgroundColor; | ||
199 | } | 361 | } | ||
200 | 362 | | |||
201 | void OROSection::sortPrimatives(Sort s) | 363 | void OROSection::sortPrimitives(Qt::Orientation orientation) | ||
202 | { | 364 | { | ||
203 | if (s == SortX) { | 365 | if (orientation == Qt::Horizontal) { | ||
204 | qSort(m_primitives.begin(), m_primitives.end(), xLessThan); | 366 | qSort(d->primitives.begin(), d->primitives.end(), xLessThan); | ||
205 | } | 367 | } | ||
206 | } | 368 | } | ||
207 | 369 | | |||
208 | bool OROSection::xLessThan(OROPrimitive* s1, OROPrimitive* s2) | 370 | ORODocument * OROSection::document() | ||
209 | { | 371 | { | ||
210 | return s1->position().x() < s2->position().x(); | 372 | return d->document; | ||
373 | } | ||||
374 | | ||||
375 | const ORODocument * OROSection::document() const | ||||
376 | { | ||||
377 | return d->document; | ||||
378 | } | ||||
379 | | ||||
380 | | ||||
381 | int OROSection::primitiveCount() const | ||||
382 | { | ||||
383 | return d->primitives.count(); | ||||
384 | } | ||||
385 | | ||||
386 | void OROSection::setType(KReportSectionData::Section t) | ||||
387 | { | ||||
388 | d->type = t; | ||||
389 | } | ||||
390 | | ||||
391 | KReportSectionData::Section OROSection::type() const | ||||
392 | { | ||||
393 | return d->type; | ||||
394 | } | ||||
395 | | ||||
396 | void OROSection::setDocument(ORODocument* doc) | ||||
397 | { | ||||
398 | d->document = doc; | ||||
211 | } | 399 | } | ||
212 | 400 | | |||
213 | // | 401 | // | ||
214 | // OROPrimitive | 402 | // OROPrimitive | ||
215 | // | 403 | // | ||
216 | OROPrimitive::OROPrimitive(int pType) | 404 | | ||
217 | : m_type(pType) | 405 | class Q_DECL_HIDDEN OROPrimitive::Private | ||
218 | { | 406 | { | ||
219 | m_page = 0; | 407 | public: | ||
408 | OROPage * page; | ||||
409 | QPointF position; | ||||
410 | QSizeF size; | ||||
411 | }; | ||||
412 | | ||||
413 | OROPrimitive::OROPrimitive() | ||||
414 | : d(new Private()) | ||||
415 | { | ||||
416 | d->page = 0; | ||||
220 | } | 417 | } | ||
221 | 418 | | |||
222 | OROPrimitive::~OROPrimitive() | 419 | OROPrimitive::~OROPrimitive() | ||
223 | { | 420 | { | ||
224 | if (m_page) { | 421 | if (d->page) { | ||
225 | m_page->m_primitives.removeAt(m_page->m_primitives.indexOf(this)); | 422 | d->page->takePrimitive(this); | ||
If we add delete to OROPage::removePrimitive() this line won't be correct. Either:
staniek: If we add `delete` to OROPage::removePrimitive() this line won't be correct. Either:
- Add… | |||||
226 | m_page = 0; | | |||
227 | } | 423 | } | ||
424 | | ||||
425 | delete d; | ||||
228 | } | 426 | } | ||
229 | 427 | | |||
230 | void OROPrimitive::setPosition(const QPointF & p) | 428 | void OROPrimitive::setPosition(const QPointF& pos) | ||
231 | { | 429 | { | ||
232 | m_position = p; | 430 | d->position = pos; | ||
233 | } | 431 | } | ||
234 | 432 | | |||
235 | void OROPrimitive::setSize(const QSizeF & s) | 433 | void OROPrimitive::setSize(const QSizeF & s) | ||
236 | { | 434 | { | ||
237 | m_size = s; | 435 | d->size = s; | ||
436 | } | ||||
437 | | ||||
438 | OROPage * OROPrimitive::page() | ||||
439 | { | ||||
440 | return d->page; | ||||
441 | } | ||||
442 | | ||||
443 | const OROPage * OROPrimitive::page() const | ||||
444 | { | ||||
445 | return d->page; | ||||
446 | } | ||||
447 | | ||||
448 | QPointF OROPrimitive::position() const | ||||
449 | { | ||||
450 | return d->position; | ||||
451 | } | ||||
452 | | ||||
453 | QSizeF OROPrimitive::size() const | ||||
454 | { | ||||
455 | return d->size; | ||||
456 | } | ||||
457 | | ||||
458 | void OROPrimitive::setPage(OROPage* page) | ||||
459 | { | ||||
460 | d->page = page; | ||||
238 | } | 461 | } | ||
239 | 462 | | |||
240 | // | 463 | // | ||
241 | // OROTextBox | 464 | // OROTextBox | ||
242 | // | 465 | // | ||
243 | const int OROTextBox::TextBox = 1; | 466 | | ||
244 | OROTextBox::OROTextBox() | 467 | class Q_DECL_HIDDEN OROTextBox::Private | ||
245 | : OROPrimitive(OROTextBox::TextBox) | 468 | { | ||
469 | public: | ||||
470 | Private(); | ||||
471 | ~Private(); | ||||
TODO: rename to KReportTextStyleData, add initialization of KReportTextStyleData::alignment and KReportTextStyleData::backgroundOpacity. staniek: TODO: rename to KReportTextStyleData, add initialization of KReportTextStyleData::alignment and… | |||||
472 | QString text; | ||||
473 | KRTextStyleData textStyle; | ||||
474 | KReportLineStyle lineStyle; | ||||
475 | Qt::Alignment alignment; | ||||
476 | int flags; // Qt::AlignmentFlag and Qt::TextFlag OR'd | ||||
477 | bool wordWrap; | ||||
478 | bool canGrow; | ||||
479 | bool requiresPostProcessing; | ||||
480 | | ||||
481 | }; | ||||
482 | | ||||
483 | OROTextBox::Private::Private() | ||||
246 | { | 484 | { | ||
247 | m_flags = 0; | 485 | flags = 0; | ||
486 | wordWrap = false; | ||||
487 | canGrow = false; | ||||
488 | requiresPostProcessing = false; | ||||
489 | | ||||
490 | lineStyle.setColor(Qt::black); | ||||
491 | lineStyle.setWidth(0); | ||||
492 | lineStyle.setPenStyle(Qt::NoPen); | ||||
493 | } | ||||
Let's initialize all this in Private::Private(). Cleaner and less Coverity warnings. staniek: Let's initialize all this in Private::Private(). Cleaner and less Coverity warnings. | |||||
248 | 494 | | |||
249 | m_lineStyle.setColor(Qt::black); | 495 | OROTextBox::Private::~Private() | ||
250 | m_lineStyle.setWidth(0); | 496 | { | ||
251 | m_lineStyle.setPenStyle(Qt::NoPen); | 497 | } | ||
252 | 498 | | |||
253 | m_requiresPostProcessing = false; | 499 | OROTextBox::OROTextBox() : d(new Private()) | ||
500 | { | ||||
254 | 501 | | |||
255 | m_wordWrap = false; | | |||
256 | m_canGrow = false; | | |||
257 | } | 502 | } | ||
258 | 503 | | |||
259 | OROTextBox::~OROTextBox() | 504 | OROTextBox::~OROTextBox() | ||
260 | { | 505 | { | ||
506 | delete d; | ||||
261 | } | 507 | } | ||
262 | 508 | | |||
263 | void OROTextBox::setText(const QString & s) | 509 | void OROTextBox::setText(const QString & s) | ||
264 | { | 510 | { | ||
265 | m_text = s; | 511 | d->text = s; | ||
266 | } | 512 | } | ||
267 | 513 | | |||
268 | void OROTextBox::setTextStyle(const KRTextStyleData & ts) | 514 | void OROTextBox::setTextStyle(const KRTextStyleData & ts) | ||
269 | { | 515 | { | ||
270 | m_textStyle = ts; | 516 | d->textStyle = ts; | ||
271 | } | 517 | } | ||
272 | 518 | | |||
273 | void OROTextBox::setLineStyle(const KReportLineStyle & ls) | 519 | void OROTextBox::setLineStyle(const KReportLineStyle & ls) | ||
274 | { | 520 | { | ||
275 | m_lineStyle = ls; | 521 | d->lineStyle = ls; | ||
276 | } | 522 | } | ||
277 | 523 | | |||
278 | void OROTextBox::setFont(const QFont & f) | 524 | void OROTextBox::setFont(const QFont & f) | ||
279 | { | 525 | { | ||
280 | m_textStyle.font = f; | 526 | d->textStyle.font = f; | ||
281 | } | 527 | } | ||
282 | 528 | | |||
283 | void OROTextBox::setFlags(int f) | 529 | void OROTextBox::setFlags(int f) | ||
284 | { | 530 | { | ||
285 | m_flags = f; | 531 | d->flags = f; | ||
532 | } | ||||
533 | | ||||
534 | bool OROTextBox::canGrow() const | ||||
535 | { | ||||
536 | return d->canGrow; | ||||
537 | } | ||||
538 | | ||||
539 | int OROTextBox::flags() const | ||||
540 | { | ||||
541 | return d->flags; | ||||
542 | } | ||||
543 | | ||||
544 | KReportLineStyle OROTextBox::lineStyle() const | ||||
545 | { | ||||
546 | return d->lineStyle; | ||||
286 | } | 547 | } | ||
287 | 548 | | |||
288 | OROPrimitive* OROTextBox::clone() | 549 | bool OROTextBox::requiresPostProcessing() const | ||
550 | { | ||||
551 | return d->requiresPostProcessing; | ||||
552 | } | ||||
553 | | ||||
554 | void OROTextBox::setCanGrow(bool grow) | ||||
555 | { | ||||
556 | d->canGrow = grow; | ||||
557 | } | ||||
558 | | ||||
559 | void OROTextBox::setRequiresPostProcessing(bool pp) | ||||
560 | { | ||||
561 | d->requiresPostProcessing = pp; | ||||
562 | } | ||||
563 | | ||||
564 | void OROTextBox::setWordWrap(bool ww) | ||||
565 | { | ||||
566 | d->wordWrap = ww; | ||||
567 | } | ||||
568 | | ||||
569 | QString OROTextBox::text() const | ||||
570 | { | ||||
571 | return d->text; | ||||
572 | } | ||||
573 | | ||||
574 | KRTextStyleData OROTextBox::textStyle() const | ||||
575 | { | ||||
576 | return d->textStyle; | ||||
577 | } | ||||
578 | | ||||
579 | bool OROTextBox::wordWrap() const | ||||
580 | { | ||||
581 | return d->wordWrap; | ||||
582 | } | ||||
583 | | ||||
584 | OROPrimitive* OROTextBox::clone() const | ||||
staniek: can be `clone() const` | |||||
289 | { | 585 | { | ||
290 | OROTextBox *theClone = new OROTextBox(); | 586 | OROTextBox *theClone = new OROTextBox(); | ||
291 | theClone->setSize(m_size); | 587 | theClone->setSize(size()); | ||
292 | theClone->setPosition(m_position); | 588 | theClone->setPosition(position()); | ||
293 | theClone->setText(m_text); | 589 | theClone->setText(text()); | ||
294 | theClone->setTextStyle(m_textStyle); | 590 | theClone->setTextStyle(textStyle()); | ||
295 | theClone->setLineStyle(m_lineStyle); | 591 | theClone->setLineStyle(lineStyle()); | ||
296 | theClone->setFlags(m_alignment); | 592 | theClone->setFlags(flags()); | ||
593 | theClone->setCanGrow(canGrow()); | ||||
594 | theClone->setWordWrap(wordWrap()); | ||||
595 | theClone->setRequiresPostProcessing(requiresPostProcessing()); | ||||
297 | return theClone; | 596 | return theClone; | ||
staniek: Missing copying:
- wordWrap
- canGrow
- requiresPostProcessing | |||||
staniek: TODO | |||||
298 | } | 597 | } | ||
299 | 598 | | |||
300 | 599 | | |||
301 | // | 600 | // | ||
302 | // OROLine | 601 | // OROLine | ||
303 | // | 602 | // | ||
304 | const int OROLine::Line = 2; | | |||
305 | 603 | | |||
306 | OROLine::OROLine() | 604 | class Q_DECL_HIDDEN OROLine::Private | ||
307 | : OROPrimitive(OROLine::Line) | 605 | { | ||
606 | public: | ||||
607 | QPointF endPoint; | ||||
608 | KReportLineStyle lineStyle; | ||||
609 | }; | ||||
610 | | ||||
611 | OROLine::OROLine() : d(new Private()) | ||||
308 | { | 612 | { | ||
309 | 613 | | |||
310 | } | 614 | } | ||
311 | 615 | | |||
312 | OROLine::~OROLine() | 616 | OROLine::~OROLine() | ||
313 | { | 617 | { | ||
618 | delete d; | ||||
314 | } | 619 | } | ||
315 | 620 | | |||
316 | void OROLine::setStartPoint(const QPointF & p) | 621 | void OROLine::setStartPoint(const QPointF & p) | ||
317 | { | 622 | { | ||
318 | setPosition(p); | 623 | setPosition(p); | ||
319 | } | 624 | } | ||
320 | 625 | | |||
321 | void OROLine::setEndPoint(const QPointF & p) | 626 | void OROLine::setEndPoint(const QPointF & p) | ||
322 | { | 627 | { | ||
323 | m_endPoint = p; | 628 | d->endPoint = p; | ||
629 | } | ||||
630 | | ||||
631 | void OROLine::setLineStyle(const KReportLineStyle& style) | ||||
632 | { | ||||
633 | d->lineStyle = style; | ||||
324 | } | 634 | } | ||
325 | 635 | | |||
326 | void OROLine::setLineStyle(const KReportLineStyle& ls) | 636 | QPointF OROLine::endPoint() const | ||
327 | { | 637 | { | ||
328 | m_lineStyle = ls; | 638 | return d->endPoint; | ||
329 | } | 639 | } | ||
330 | 640 | | |||
641 | KReportLineStyle OROLine::lineStyle() const | ||||
642 | { | ||||
643 | return d->lineStyle; | ||||
644 | } | ||||
331 | 645 | | |||
332 | OROPrimitive* OROLine::clone() | 646 | OROPrimitive* OROLine::clone() const | ||
staniek: can be `clone() const` | |||||
333 | { | 647 | { | ||
334 | OROLine *theClone = new OROLine(); | 648 | OROLine *theClone = new OROLine(); | ||
335 | theClone->setStartPoint(m_position); | 649 | theClone->setStartPoint(position()); | ||
336 | theClone->setEndPoint(m_endPoint); | 650 | theClone->setEndPoint(endPoint()); | ||
337 | theClone->setLineStyle(m_lineStyle); | 651 | theClone->setLineStyle(lineStyle()); | ||
338 | return theClone; | 652 | return theClone; | ||
339 | } | 653 | } | ||
340 | 654 | | |||
341 | // | 655 | // | ||
342 | // OROImage | 656 | // OROImage | ||
343 | // | 657 | // | ||
344 | const int OROImage::Image = 3; | | |||
345 | 658 | | |||
346 | OROImage::OROImage() | 659 | class Q_DECL_HIDDEN OROImage::Private | ||
347 | : OROPrimitive(OROImage::Image) | | |||
348 | { | 660 | { | ||
349 | m_scaled = false; | 661 | public: | ||
350 | m_transformFlags = Qt::FastTransformation; | 662 | QImage image; | ||
351 | m_aspectFlags = Qt::IgnoreAspectRatio; | 663 | bool scaled; | ||
664 | Qt::TransformationMode transformFlags; | ||||
665 | Qt::AspectRatioMode aspectFlags; | ||||
666 | }; | ||||
667 | | ||||
668 | OROImage::OROImage() : d(new Private()) | ||||
669 | { | ||||
670 | d->scaled = false; | ||||
671 | d->transformFlags = Qt::FastTransformation; | ||||
672 | d->aspectFlags = Qt::IgnoreAspectRatio; | ||||
352 | } | 673 | } | ||
353 | 674 | | |||
354 | OROImage::~OROImage() | 675 | OROImage::~OROImage() | ||
355 | { | 676 | { | ||
677 | delete d; | ||||
356 | } | 678 | } | ||
357 | 679 | | |||
358 | void OROImage::setImage(const QImage & img) | 680 | void OROImage::setImage(const QImage & img) | ||
359 | { | 681 | { | ||
360 | m_image = img; | 682 | d->image = img; | ||
361 | } | 683 | } | ||
362 | 684 | | |||
363 | void OROImage::setScaled(bool b) | 685 | void OROImage::setScaled(bool b) | ||
364 | { | 686 | { | ||
365 | m_scaled = b; | 687 | d->scaled = b; | ||
688 | } | ||||
689 | | ||||
690 | void OROImage::setTransformationMode(Qt::TransformationMode transformation) | ||||
691 | { | ||||
692 | d->transformFlags = transformation; | ||||
693 | } | ||||
694 | | ||||
695 | void OROImage::setAspectRatioMode(Qt::AspectRatioMode aspectRatioMode) | ||||
696 | { | ||||
697 | d->aspectFlags = aspectRatioMode; | ||||
698 | } | ||||
699 | | ||||
700 | Qt::AspectRatioMode OROImage::aspectRatioMode() const | ||||
701 | { | ||||
702 | return d->aspectFlags; | ||||
703 | } | ||||
704 | | ||||
705 | QImage OROImage::image() const | ||||
706 | { | ||||
707 | return d->image; | ||||
366 | } | 708 | } | ||
367 | 709 | | |||
368 | void OROImage::setTransformationMode(int tm) | 710 | bool OROImage::isScaled() const | ||
369 | { | 711 | { | ||
370 | m_transformFlags = tm; | 712 | return d->scaled; | ||
371 | } | 713 | } | ||
372 | 714 | | |||
373 | void OROImage::setAspectRatioMode(int arm) | 715 | Qt::TransformationMode OROImage::transformationMode() const | ||
374 | { | 716 | { | ||
375 | m_aspectFlags = arm; | 717 | return d->transformFlags; | ||
376 | } | 718 | } | ||
377 | 719 | | |||
378 | OROPrimitive* OROImage::clone() | 720 | OROPrimitive* OROImage::clone() const | ||
staniek: can be `clone() const` | |||||
379 | { | 721 | { | ||
380 | OROImage *theClone = new OROImage(); | 722 | OROImage *theClone = new OROImage(); | ||
381 | theClone->setSize(m_size); | 723 | theClone->setSize(size()); | ||
382 | theClone->setPosition(m_position); | 724 | theClone->setPosition(position()); | ||
383 | theClone->setImage(m_image); | 725 | theClone->setImage(image()); | ||
384 | theClone->setScaled(m_scaled); | 726 | theClone->setScaled(isScaled()); | ||
385 | theClone->setTransformationMode(m_transformFlags); | 727 | theClone->setTransformationMode(transformationMode()); | ||
386 | theClone->setAspectRatioMode(m_aspectFlags); | 728 | theClone->setAspectRatioMode(aspectRatioMode()); | ||
387 | return theClone; | 729 | return theClone; | ||
388 | } | 730 | } | ||
389 | 731 | | |||
390 | // | 732 | // | ||
391 | // OROPicture | 733 | // OROPicture | ||
392 | // | 734 | // | ||
393 | const int OROPicture::Picture = 6; | | |||
394 | 735 | | |||
395 | OROPicture::OROPicture() | 736 | class Q_DECL_HIDDEN OROPicture::Private | ||
396 | : OROPrimitive(OROPicture::Picture) | 737 | { | ||
738 | public: | ||||
739 | QPicture picture; | ||||
740 | }; | ||||
741 | | ||||
742 | OROPicture::OROPicture() : d(new Private()) | ||||
397 | { | 743 | { | ||
398 | 744 | | |||
399 | } | 745 | } | ||
400 | 746 | | |||
401 | OROPicture::~OROPicture() | 747 | OROPicture::~OROPicture() | ||
402 | { | 748 | { | ||
749 | delete d; | ||||
403 | } | 750 | } | ||
404 | 751 | | |||
405 | OROPrimitive* OROPicture::clone() | 752 | OROPrimitive* OROPicture::clone() const | ||
staniek: can be `clone() const` | |||||
406 | { | 753 | { | ||
407 | OROPicture *theClone = new OROPicture(); | 754 | OROPicture *theClone = new OROPicture(); | ||
408 | theClone->setSize(m_size); | 755 | theClone->setSize(size()); | ||
409 | theClone->setPosition(m_position); | 756 | theClone->setPosition(position()); | ||
410 | theClone->setPicture(m_picture); | 757 | // theClone->setPicture(*(picture()ddddddds)); | ||
411 | return theClone; | 758 | return theClone; | ||
412 | } | 759 | } | ||
413 | 760 | | |||
761 | QPicture* OROPicture::picture() | ||||
762 | { | ||||
763 | return &d->picture; | ||||
764 | } | ||||
765 | | ||||
766 | void OROPicture::setPicture(const QPicture& p) | ||||
767 | { | ||||
768 | d->picture = p; | ||||
769 | } | ||||
770 | | ||||
414 | // | 771 | // | ||
415 | // ORORect | 772 | // ORORect | ||
416 | // | 773 | // | ||
417 | const int ORORect::Rect = 4; | | |||
418 | 774 | | |||
419 | ORORect::ORORect() | 775 | class Q_DECL_HIDDEN ORORect::Private | ||
420 | : OROPrimitive(ORORect::Rect) | 776 | { | ||
777 | public: | ||||
778 | QPen pen; | ||||
779 | QBrush brush; | ||||
780 | }; | ||||
781 | | ||||
782 | ORORect::ORORect() : d(new Private()) | ||||
421 | { | 783 | { | ||
422 | } | 784 | } | ||
423 | 785 | | |||
424 | ORORect::~ORORect() | 786 | ORORect::~ORORect() | ||
425 | { | 787 | { | ||
788 | delete d; | ||||
426 | } | 789 | } | ||
427 | 790 | | |||
428 | void ORORect::setRect(const QRectF & r) | 791 | void ORORect::setRect(const QRectF & r) | ||
429 | { | 792 | { | ||
430 | setPosition(r.topLeft()); | 793 | setPosition(r.topLeft()); | ||
431 | setSize(r.size()); | 794 | setSize(r.size()); | ||
432 | } | 795 | } | ||
433 | 796 | | |||
434 | void ORORect::setPen(const QPen & p) | 797 | void ORORect::setPen(const QPen & p) | ||
435 | { | 798 | { | ||
436 | m_pen = p; | 799 | d->pen = p; | ||
437 | } | 800 | } | ||
438 | 801 | | |||
439 | void ORORect::setBrush(const QBrush & b) | 802 | void ORORect::setBrush(const QBrush & b) | ||
440 | { | 803 | { | ||
441 | m_brush = b; | 804 | d->brush = b; | ||
805 | } | ||||
806 | | ||||
807 | QBrush ORORect::brush() const | ||||
808 | { | ||||
809 | return d->brush; | ||||
810 | } | ||||
811 | | ||||
812 | QPen ORORect::pen() const | ||||
813 | { | ||||
814 | return d->pen; | ||||
815 | } | ||||
816 | | ||||
817 | QRectF ORORect::rect() const | ||||
818 | { | ||||
819 | return QRectF(position(), size()); | ||||
442 | } | 820 | } | ||
443 | 821 | | |||
444 | OROPrimitive* ORORect::clone() | 822 | OROPrimitive* ORORect::clone() const | ||
staniek: can be `clone() const` | |||||
445 | { | 823 | { | ||
446 | ORORect *theClone = new ORORect(); | 824 | ORORect *theClone = new ORORect(); | ||
447 | theClone->setSize(m_size); | 825 | theClone->setSize(size()); | ||
448 | theClone->setPosition(m_position); | 826 | theClone->setPosition(position()); | ||
449 | theClone->setPen(m_pen); | 827 | theClone->setPen(pen()); | ||
450 | theClone->setBrush(m_brush); | 828 | theClone->setBrush(brush()); | ||
451 | return theClone; | 829 | return theClone; | ||
452 | } | 830 | } | ||
453 | // | 831 | // | ||
454 | // OROEllipse | 832 | // OROEllipse | ||
455 | // | 833 | // | ||
456 | const int OROEllipse::Ellipse = 5; | | |||
457 | 834 | | |||
458 | OROEllipse::OROEllipse() | 835 | class Q_DECL_HIDDEN OROEllipse::Private | ||
459 | : OROPrimitive(OROEllipse::Ellipse) | 836 | { | ||
837 | public: | ||||
838 | QPen pen; | ||||
839 | QBrush brush; | ||||
840 | }; | ||||
841 | | ||||
842 | OROEllipse::OROEllipse() : d(new Private()) | ||||
460 | { | 843 | { | ||
461 | } | 844 | } | ||
462 | 845 | | |||
463 | OROEllipse::~OROEllipse() | 846 | OROEllipse::~OROEllipse() | ||
464 | { | 847 | { | ||
848 | delete d; | ||||
465 | } | 849 | } | ||
466 | 850 | | |||
467 | void OROEllipse::setRect(const QRectF & r) | 851 | void OROEllipse::setRect(const QRectF & r) | ||
468 | { | 852 | { | ||
469 | setPosition(r.topLeft()); | 853 | setPosition(r.topLeft()); | ||
470 | setSize(r.size()); | 854 | setSize(r.size()); | ||
471 | } | 855 | } | ||
472 | 856 | | |||
473 | void OROEllipse::setPen(const QPen & p) | 857 | void OROEllipse::setPen(const QPen & p) | ||
474 | { | 858 | { | ||
475 | m_pen = p; | 859 | d->pen = p; | ||
476 | } | 860 | } | ||
477 | 861 | | |||
478 | void OROEllipse::setBrush(const QBrush & b) | 862 | void OROEllipse::setBrush(const QBrush & b) | ||
479 | { | 863 | { | ||
480 | m_brush = b; | 864 | d->brush = b; | ||
865 | } | ||||
866 | | ||||
867 | QBrush OROEllipse::brush() const | ||||
868 | { | ||||
869 | return d->brush; | ||||
870 | } | ||||
871 | | ||||
872 | QPen OROEllipse::pen() const | ||||
873 | { | ||||
874 | return d->pen; | ||||
481 | } | 875 | } | ||
482 | 876 | | |||
483 | OROPrimitive* OROEllipse::clone() | 877 | QRectF OROEllipse::rect() const | ||
878 | { | ||||
879 | return QRectF(position(), size()); | ||||
880 | } | ||||
881 | | ||||
882 | OROPrimitive* OROEllipse::clone() const | ||||
staniek: can be `clone() const` | |||||
484 | { | 883 | { | ||
485 | OROEllipse *theClone = new OROEllipse(); | 884 | OROEllipse *theClone = new OROEllipse(); | ||
486 | theClone->setSize(m_size); | 885 | theClone->setSize(size()); | ||
487 | theClone->setPosition(m_position); | 886 | theClone->setPosition(position()); | ||
488 | theClone->setPen(m_pen); | 887 | theClone->setPen(pen()); | ||
489 | theClone->setBrush(m_brush); | 888 | theClone->setBrush(brush()); | ||
490 | return theClone; | 889 | return theClone; | ||
491 | } | 890 | } | ||
492 | 891 | | |||
493 | const int OROCheck::Check = 7; | 892 | // | ||
893 | // OROCheck | ||||
894 | // | ||||
895 | | ||||
896 | class Q_DECL_HIDDEN OROCheckBox::Private | ||||
897 | { | ||||
898 | public: | ||||
899 | OROCheckBox::Type checkType; | ||||
900 | bool value; | ||||
901 | KReportLineStyle lineStyle; | ||||
902 | QColor foregroundColor; | ||||
903 | }; | ||||
904 | | ||||
905 | OROCheckBox::OROCheckBox() : d(new Private()) | ||||
906 | { | ||||
907 | d->value = false; | ||||
908 | } | ||||
909 | | ||||
910 | OROCheckBox::~OROCheckBox() | ||||
911 | { | ||||
912 | delete d; | ||||
913 | } | ||||
494 | 914 | | |||
495 | OROCheck::OROCheck() | 915 | OROCheckBox::Type OROCheckBox::checkType() const | ||
496 | : OROPrimitive(OROCheck::Check) | | |||
497 | , m_value(false) | | |||
498 | { | 916 | { | ||
917 | return d->checkType; | ||||
918 | } | ||||
499 | 919 | | |||
920 | QColor OROCheckBox::foregroundColor() const | ||||
921 | { | ||||
922 | return d->foregroundColor; | ||||
500 | } | 923 | } | ||
501 | 924 | | |||
502 | OROCheck::~OROCheck() | 925 | KReportLineStyle OROCheckBox::lineStyle() const | ||
503 | { | 926 | { | ||
927 | return d->lineStyle; | ||||
928 | } | ||||
504 | 929 | | |||
930 | void OROCheckBox::setForegroundColor(const QColor& fg) | ||||
931 | { | ||||
932 | d->foregroundColor = fg; | ||||
933 | } | ||||
934 | | ||||
935 | void OROCheckBox::setLineStyle(const KReportLineStyle& ls) | ||||
936 | { | ||||
937 | d->lineStyle = ls; | ||||
938 | } | ||||
939 | | ||||
940 | void OROCheckBox::setValue(bool v) | ||||
941 | { | ||||
942 | d->value = v; | ||||
943 | } | ||||
944 | | ||||
945 | bool OROCheckBox::value() const | ||||
946 | { | ||||
947 | return d->value; | ||||
948 | } | ||||
949 | | ||||
950 | void OROCheckBox::setCheckType(Type type) | ||||
951 | { | ||||
952 | if (type == Cross || type == Tick || type == Dot) { | ||||
953 | d->checkType = type; | ||||
954 | } else { | ||||
955 | d->checkType = Cross; | ||||
956 | } | ||||
505 | } | 957 | } | ||
506 | 958 | | |||
507 | OROPrimitive* OROCheck::clone() | 959 | OROPrimitive* OROCheckBox::clone() const | ||
staniek: can be `clone() const` | |||||
508 | { | 960 | { | ||
509 | OROCheck *theClone = new OROCheck(); | 961 | OROCheckBox *theClone = new OROCheckBox(); | ||
510 | theClone->setSize(m_size); | 962 | theClone->setSize(size()); | ||
511 | theClone->setPosition(m_position); | 963 | theClone->setPosition(position()); | ||
512 | theClone->setLineStyle(m_lineStyle); | 964 | theClone->setLineStyle(lineStyle()); | ||
513 | theClone->setForegroundColor(m_fgColor); | 965 | theClone->setForegroundColor(foregroundColor()); | ||
514 | theClone->setValue(m_value); | 966 | theClone->setValue(value()); | ||
967 | theClone->setCheckType(checkType()); | ||||
515 | return theClone; | 968 | return theClone; | ||
staniek: Missing copy for `checkType`. | |||||
staniek: TODO | |||||
516 | } | 969 | } |
Let's have static or use namespace { }