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