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