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