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); | ||||
28 | } | 46 | } | ||
29 | 47 | | |||
30 | ORODocument::~ORODocument() | 48 | | ||
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 | } | ||
staniek: clear is not really needed | |||||
38 | 58 | | |||
39 | void ORODocument::setTitle(const QString & pTitle) | 59 | void ORODocument::setTitle(const QString &title) | ||
40 | { | 60 | { | ||
staniek: same here | |||||
41 | m_title = pTitle; | 61 | d->title = title; | ||
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); | ||
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); | ||||
staniek: I propose to use just .value() | |||||
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) { | ||
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; | 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::removeSection(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) | ||
212 | { | ||||
213 | return d->primitives.value(index); | ||||
214 | } | ||||
215 | | ||||
216 | const OROPrimitive * OROPage::primitive(int index) const | ||||
121 | { | 217 | { | ||
122 | return m_primitives.at(idx); | 218 | return d->primitives.value(index); | ||
staniek: Second arg not needed | |||||
123 | } | 219 | } | ||
124 | 220 | | |||
125 | void OROPage::addPrimitive(OROPrimitive* p, bool atBeginning, bool notify) | 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; | ||||
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(); | ||||
258 | } | ||||
259 | | ||||
260 | void OROPage::setDocument(ORODocument* doc) | ||||
261 | { | ||||
262 | d->document = doc; | ||||
143 | } | 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; | ||||
144 | } | 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; | | |||
162 | } | 314 | } | ||
163 | 315 | | |||
164 | qDeleteAll(m_primitives); | 316 | delete d; | ||
165 | m_primitives.clear(); | | |||
166 | } | 317 | } | ||
167 | 318 | | |||
168 | OROPrimitive* OROSection::primitive(int idx) | 319 | OROPrimitive* OROSection::primitive(int index) | ||
169 | { | 320 | { | ||
170 | return m_primitives.at(idx); | 321 | return d->primitives.value(index); | ||
staniek: Second arg not needed | |||||
171 | } | 322 | } | ||
172 | 323 | | |||
173 | void OROSection::addPrimitive(OROPrimitive* p) | 324 | const OROPrimitive * OROSection::primitive(int index) const | ||
174 | { | 325 | { | ||
175 | if (p == 0) | 326 | return d->primitives.value(index); | ||
staniek: Second arg not needed | |||||
327 | } | ||||
328 | | ||||
329 | void OROSection::addPrimitive(OROPrimitive* primitive) | ||||
330 | { | ||||
331 | if (primitive == 0) | ||||
176 | return; | 332 | return; | ||
177 | 333 | | |||
178 | m_primitives.append(p); | 334 | d->primitives.append(primitive); | ||
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(Qt::Orientation orientation) | ||
202 | { | 358 | { | ||
203 | if (s == SortX) { | 359 | if (orientation == Qt::Horizontal) { | ||
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()); | ||
592 | theClone->setCanGrow(canGrow()); | ||||
593 | theClone->setWordWrap(wordWrap()); | ||||
594 | theClone->setRequiresPostProcessing(requiresPostProcessing()); | ||||
297 | return theClone; | 595 | return theClone; | ||
staniek: Missing copying:
- wordWrap
- canGrow
- requiresPostProcessing | |||||
staniek: TODO | |||||
298 | } | 596 | } | ||
299 | 597 | | |||
300 | 598 | | |||
301 | // | 599 | // | ||
302 | // OROLine | 600 | // OROLine | ||
303 | // | 601 | // | ||
304 | const int OROLine::Line = 2; | | |||
305 | 602 | | |||
306 | OROLine::OROLine() | 603 | class Q_DECL_HIDDEN OROLine::Private | ||
307 | : OROPrimitive(OROLine::Line) | 604 | { | ||
605 | public: | ||||
606 | QPointF endPoint; | ||||
607 | KReportLineStyle lineStyle; | ||||
608 | }; | ||||
609 | | ||||
610 | OROLine::OROLine() : d(new Private()) | ||||
308 | { | 611 | { | ||
309 | 612 | | |||
310 | } | 613 | } | ||
311 | 614 | | |||
312 | OROLine::~OROLine() | 615 | OROLine::~OROLine() | ||
313 | { | 616 | { | ||
617 | delete d; | ||||
314 | } | 618 | } | ||
315 | 619 | | |||
316 | void OROLine::setStartPoint(const QPointF & p) | 620 | void OROLine::setStartPoint(const QPointF & p) | ||
317 | { | 621 | { | ||
318 | setPosition(p); | 622 | setPosition(p); | ||
319 | } | 623 | } | ||
320 | 624 | | |||
321 | void OROLine::setEndPoint(const QPointF & p) | 625 | void OROLine::setEndPoint(const QPointF & p) | ||
322 | { | 626 | { | ||
323 | m_endPoint = p; | 627 | d->endPoint = p; | ||
628 | } | ||||
629 | | ||||
630 | void OROLine::setLineStyle(const KReportLineStyle& style) | ||||
631 | { | ||||
632 | d->lineStyle = style; | ||||
324 | } | 633 | } | ||
325 | 634 | | |||
326 | void OROLine::setLineStyle(const KReportLineStyle& ls) | 635 | QPointF OROLine::endPoint() const | ||
327 | { | 636 | { | ||
328 | m_lineStyle = ls; | 637 | return d->endPoint; | ||
329 | } | 638 | } | ||
330 | 639 | | |||
640 | KReportLineStyle OROLine::lineStyle() const | ||||
641 | { | ||||
642 | return d->lineStyle; | ||||
643 | } | ||||
331 | 644 | | |||
332 | OROPrimitive* OROLine::clone() | 645 | OROPrimitive* OROLine::clone() const | ||
staniek: can be `clone() const` | |||||
333 | { | 646 | { | ||
334 | OROLine *theClone = new OROLine(); | 647 | OROLine *theClone = new OROLine(); | ||
335 | theClone->setStartPoint(m_position); | 648 | theClone->setStartPoint(position()); | ||
336 | theClone->setEndPoint(m_endPoint); | 649 | theClone->setEndPoint(endPoint()); | ||
337 | theClone->setLineStyle(m_lineStyle); | 650 | theClone->setLineStyle(lineStyle()); | ||
338 | return theClone; | 651 | return theClone; | ||
339 | } | 652 | } | ||
340 | 653 | | |||
341 | // | 654 | // | ||
342 | // OROImage | 655 | // OROImage | ||
343 | // | 656 | // | ||
344 | const int OROImage::Image = 3; | | |||
345 | 657 | | |||
346 | OROImage::OROImage() | 658 | class Q_DECL_HIDDEN OROImage::Private | ||
347 | : OROPrimitive(OROImage::Image) | | |||
348 | { | 659 | { | ||
349 | m_scaled = false; | 660 | public: | ||
350 | m_transformFlags = Qt::FastTransformation; | 661 | QImage image; | ||
351 | m_aspectFlags = Qt::IgnoreAspectRatio; | 662 | bool scaled; | ||
663 | Qt::TransformationMode transformFlags; | ||||
664 | Qt::AspectRatioMode aspectFlags; | ||||
665 | }; | ||||
666 | | ||||
667 | OROImage::OROImage() : d(new Private()) | ||||
668 | { | ||||
669 | d->scaled = false; | ||||
670 | d->transformFlags = Qt::FastTransformation; | ||||
671 | d->aspectFlags = Qt::IgnoreAspectRatio; | ||||
352 | } | 672 | } | ||
353 | 673 | | |||
354 | OROImage::~OROImage() | 674 | OROImage::~OROImage() | ||
355 | { | 675 | { | ||
676 | delete d; | ||||
356 | } | 677 | } | ||
357 | 678 | | |||
358 | void OROImage::setImage(const QImage & img) | 679 | void OROImage::setImage(const QImage & img) | ||
359 | { | 680 | { | ||
360 | m_image = img; | 681 | d->image = img; | ||
361 | } | 682 | } | ||
362 | 683 | | |||
363 | void OROImage::setScaled(bool b) | 684 | void OROImage::setScaled(bool b) | ||
364 | { | 685 | { | ||
365 | m_scaled = b; | 686 | d->scaled = b; | ||
366 | } | 687 | } | ||
367 | 688 | | |||
368 | void OROImage::setTransformationMode(int tm) | 689 | void OROImage::setTransformationMode(Qt::TransformationMode transformation) | ||
369 | { | 690 | { | ||
370 | m_transformFlags = tm; | 691 | d->transformFlags = transformation; | ||
371 | } | 692 | } | ||
372 | 693 | | |||
373 | void OROImage::setAspectRatioMode(int arm) | 694 | void OROImage::setAspectRatioMode(Qt::AspectRatioMode aspectRatioMode) | ||
374 | { | 695 | { | ||
375 | m_aspectFlags = arm; | 696 | d->aspectFlags = aspectRatioMode; | ||
376 | } | 697 | } | ||
377 | 698 | | |||
378 | OROPrimitive* OROImage::clone() | 699 | Qt::AspectRatioMode OROImage::aspectRatioMode() const | ||
700 | { | ||||
701 | return d->aspectFlags; | ||||
702 | } | ||||
703 | | ||||
704 | QImage OROImage::image() const | ||||
705 | { | ||||
706 | return d->image; | ||||
707 | } | ||||
708 | | ||||
709 | bool OROImage::isScaled() const | ||||
710 | { | ||||
711 | return d->scaled; | ||||
712 | } | ||||
713 | | ||||
714 | Qt::TransformationMode OROImage::transformationMode() const | ||||
715 | { | ||||
716 | return d->transformFlags; | ||||
717 | } | ||||
718 | | ||||
719 | OROPrimitive* OROImage::clone() const | ||||
staniek: can be `clone() const` | |||||
379 | { | 720 | { | ||
380 | OROImage *theClone = new OROImage(); | 721 | OROImage *theClone = new OROImage(); | ||
381 | theClone->setSize(m_size); | 722 | theClone->setSize(size()); | ||
382 | theClone->setPosition(m_position); | 723 | theClone->setPosition(position()); | ||
383 | theClone->setImage(m_image); | 724 | theClone->setImage(image()); | ||
384 | theClone->setScaled(m_scaled); | 725 | theClone->setScaled(isScaled()); | ||
385 | theClone->setTransformationMode(m_transformFlags); | 726 | theClone->setTransformationMode(transformationMode()); | ||
386 | theClone->setAspectRatioMode(m_aspectFlags); | 727 | theClone->setAspectRatioMode(aspectRatioMode()); | ||
387 | return theClone; | 728 | return theClone; | ||
388 | } | 729 | } | ||
389 | 730 | | |||
390 | // | 731 | // | ||
391 | // OROPicture | 732 | // OROPicture | ||
392 | // | 733 | // | ||
393 | const int OROPicture::Picture = 6; | | |||
394 | 734 | | |||
395 | OROPicture::OROPicture() | 735 | class Q_DECL_HIDDEN OROPicture::Private | ||
396 | : OROPrimitive(OROPicture::Picture) | 736 | { | ||
737 | public: | ||||
738 | QPicture picture; | ||||
739 | }; | ||||
740 | | ||||
741 | OROPicture::OROPicture() : d(new Private()) | ||||
397 | { | 742 | { | ||
398 | 743 | | |||
399 | } | 744 | } | ||
400 | 745 | | |||
401 | OROPicture::~OROPicture() | 746 | OROPicture::~OROPicture() | ||
402 | { | 747 | { | ||
748 | delete d; | ||||
403 | } | 749 | } | ||
404 | 750 | | |||
405 | OROPrimitive* OROPicture::clone() | 751 | OROPrimitive* OROPicture::clone() const | ||
staniek: can be `clone() const` | |||||
406 | { | 752 | { | ||
407 | OROPicture *theClone = new OROPicture(); | 753 | OROPicture *theClone = new OROPicture(); | ||
408 | theClone->setSize(m_size); | 754 | theClone->setSize(size()); | ||
409 | theClone->setPosition(m_position); | 755 | theClone->setPosition(position()); | ||
410 | theClone->setPicture(m_picture); | 756 | // theClone->setPicture(*(picture()ddddddds)); | ||
411 | return theClone; | 757 | return theClone; | ||
412 | } | 758 | } | ||
413 | 759 | | |||
760 | QPicture* OROPicture::picture() | ||||
761 | { | ||||
762 | return &d->picture; | ||||
763 | } | ||||
764 | | ||||
765 | void OROPicture::setPicture(const QPicture& p) | ||||
766 | { | ||||
767 | d->picture = p; | ||||
768 | } | ||||
769 | | ||||
414 | // | 770 | // | ||
415 | // ORORect | 771 | // ORORect | ||
416 | // | 772 | // | ||
417 | const int ORORect::Rect = 4; | | |||
418 | 773 | | |||
419 | ORORect::ORORect() | 774 | class Q_DECL_HIDDEN ORORect::Private | ||
420 | : OROPrimitive(ORORect::Rect) | 775 | { | ||
776 | public: | ||||
777 | QPen pen; | ||||
778 | QBrush brush; | ||||
779 | }; | ||||
780 | | ||||
781 | ORORect::ORORect() : d(new Private()) | ||||
421 | { | 782 | { | ||
422 | } | 783 | } | ||
423 | 784 | | |||
424 | ORORect::~ORORect() | 785 | ORORect::~ORORect() | ||
425 | { | 786 | { | ||
787 | delete d; | ||||
426 | } | 788 | } | ||
427 | 789 | | |||
428 | void ORORect::setRect(const QRectF & r) | 790 | void ORORect::setRect(const QRectF & r) | ||
429 | { | 791 | { | ||
430 | setPosition(r.topLeft()); | 792 | setPosition(r.topLeft()); | ||
431 | setSize(r.size()); | 793 | setSize(r.size()); | ||
432 | } | 794 | } | ||
433 | 795 | | |||
434 | void ORORect::setPen(const QPen & p) | 796 | void ORORect::setPen(const QPen & p) | ||
435 | { | 797 | { | ||
436 | m_pen = p; | 798 | d->pen = p; | ||
437 | } | 799 | } | ||
438 | 800 | | |||
439 | void ORORect::setBrush(const QBrush & b) | 801 | void ORORect::setBrush(const QBrush & b) | ||
440 | { | 802 | { | ||
441 | m_brush = b; | 803 | d->brush = b; | ||
442 | } | 804 | } | ||
443 | 805 | | |||
444 | OROPrimitive* ORORect::clone() | 806 | QBrush ORORect::brush() const | ||
807 | { | ||||
808 | return d->brush; | ||||
809 | } | ||||
810 | | ||||
811 | QPen ORORect::pen() const | ||||
812 | { | ||||
813 | return d->pen; | ||||
814 | } | ||||
815 | | ||||
816 | QRectF ORORect::rect() const | ||||
817 | { | ||||
818 | return QRectF(position(), size()); | ||||
819 | } | ||||
820 | | ||||
821 | OROPrimitive* ORORect::clone() const | ||||
staniek: can be `clone() const` | |||||
445 | { | 822 | { | ||
446 | ORORect *theClone = new ORORect(); | 823 | ORORect *theClone = new ORORect(); | ||
447 | theClone->setSize(m_size); | 824 | theClone->setSize(size()); | ||
448 | theClone->setPosition(m_position); | 825 | theClone->setPosition(position()); | ||
449 | theClone->setPen(m_pen); | 826 | theClone->setPen(pen()); | ||
450 | theClone->setBrush(m_brush); | 827 | theClone->setBrush(brush()); | ||
451 | return theClone; | 828 | return theClone; | ||
452 | } | 829 | } | ||
453 | // | 830 | // | ||
454 | // OROEllipse | 831 | // OROEllipse | ||
455 | // | 832 | // | ||
456 | const int OROEllipse::Ellipse = 5; | | |||
457 | 833 | | |||
458 | OROEllipse::OROEllipse() | 834 | class Q_DECL_HIDDEN OROEllipse::Private | ||
459 | : OROPrimitive(OROEllipse::Ellipse) | 835 | { | ||
836 | public: | ||||
837 | QPen pen; | ||||
838 | QBrush brush; | ||||
839 | }; | ||||
840 | | ||||
841 | OROEllipse::OROEllipse() : d(new Private()) | ||||
460 | { | 842 | { | ||
461 | } | 843 | } | ||
462 | 844 | | |||
463 | OROEllipse::~OROEllipse() | 845 | OROEllipse::~OROEllipse() | ||
464 | { | 846 | { | ||
847 | delete d; | ||||
465 | } | 848 | } | ||
466 | 849 | | |||
467 | void OROEllipse::setRect(const QRectF & r) | 850 | void OROEllipse::setRect(const QRectF & r) | ||
468 | { | 851 | { | ||
469 | setPosition(r.topLeft()); | 852 | setPosition(r.topLeft()); | ||
470 | setSize(r.size()); | 853 | setSize(r.size()); | ||
471 | } | 854 | } | ||
472 | 855 | | |||
473 | void OROEllipse::setPen(const QPen & p) | 856 | void OROEllipse::setPen(const QPen & p) | ||
474 | { | 857 | { | ||
475 | m_pen = p; | 858 | d->pen = p; | ||
476 | } | 859 | } | ||
477 | 860 | | |||
478 | void OROEllipse::setBrush(const QBrush & b) | 861 | void OROEllipse::setBrush(const QBrush & b) | ||
479 | { | 862 | { | ||
480 | m_brush = b; | 863 | d->brush = b; | ||
864 | } | ||||
865 | | ||||
866 | QBrush OROEllipse::brush() const | ||||
867 | { | ||||
868 | return d->brush; | ||||
869 | } | ||||
870 | | ||||
871 | QPen OROEllipse::pen() const | ||||
872 | { | ||||
873 | return d->pen; | ||||
481 | } | 874 | } | ||
482 | 875 | | |||
483 | OROPrimitive* OROEllipse::clone() | 876 | QRectF OROEllipse::rect() const | ||
877 | { | ||||
878 | return QRectF(position(), size()); | ||||
879 | } | ||||
880 | | ||||
881 | OROPrimitive* OROEllipse::clone() const | ||||
staniek: can be `clone() const` | |||||
484 | { | 882 | { | ||
485 | OROEllipse *theClone = new OROEllipse(); | 883 | OROEllipse *theClone = new OROEllipse(); | ||
486 | theClone->setSize(m_size); | 884 | theClone->setSize(size()); | ||
487 | theClone->setPosition(m_position); | 885 | theClone->setPosition(position()); | ||
488 | theClone->setPen(m_pen); | 886 | theClone->setPen(pen()); | ||
489 | theClone->setBrush(m_brush); | 887 | theClone->setBrush(brush()); | ||
490 | return theClone; | 888 | return theClone; | ||
491 | } | 889 | } | ||
492 | 890 | | |||
493 | const int OROCheck::Check = 7; | 891 | // | ||
892 | // OROCheck | ||||
893 | // | ||||
894 | | ||||
895 | class Q_DECL_HIDDEN OROCheckBox::Private | ||||
896 | { | ||||
897 | public: | ||||
898 | OROCheckBox::Type checkType; | ||||
899 | bool value; | ||||
900 | KReportLineStyle lineStyle; | ||||
901 | QColor foregroundColor; | ||||
902 | }; | ||||
903 | | ||||
904 | OROCheckBox::OROCheckBox() : d(new Private()) | ||||
905 | { | ||||
906 | d->value = false; | ||||
907 | } | ||||
908 | | ||||
909 | OROCheckBox::~OROCheckBox() | ||||
910 | { | ||||
911 | delete d; | ||||
912 | } | ||||
494 | 913 | | |||
495 | OROCheck::OROCheck() | 914 | OROCheckBox::Type OROCheckBox::checkType() const | ||
496 | : OROPrimitive(OROCheck::Check) | | |||
497 | , m_value(false) | | |||
498 | { | 915 | { | ||
916 | return d->checkType; | ||||
917 | } | ||||
499 | 918 | | |||
919 | QColor OROCheckBox::foregroundColor() const | ||||
920 | { | ||||
921 | return d->foregroundColor; | ||||
500 | } | 922 | } | ||
501 | 923 | | |||
502 | OROCheck::~OROCheck() | 924 | KReportLineStyle OROCheckBox::lineStyle() const | ||
503 | { | 925 | { | ||
926 | return d->lineStyle; | ||||
927 | } | ||||
504 | 928 | | |||
929 | void OROCheckBox::setForegroundColor(const QColor& fg) | ||||
930 | { | ||||
931 | d->foregroundColor = fg; | ||||
932 | } | ||||
933 | | ||||
934 | void OROCheckBox::setLineStyle(const KReportLineStyle& ls) | ||||
935 | { | ||||
936 | d->lineStyle = ls; | ||||
937 | } | ||||
938 | | ||||
939 | void OROCheckBox::setValue(bool v) | ||||
940 | { | ||||
941 | d->value = v; | ||||
942 | } | ||||
943 | | ||||
944 | bool OROCheckBox::value() const | ||||
945 | { | ||||
946 | return d->value; | ||||
947 | } | ||||
948 | | ||||
949 | void OROCheckBox::setCheckType(Type type) | ||||
950 | { | ||||
951 | if (type == Cross || type == Tick || type == Dot) { | ||||
952 | d->checkType = type; | ||||
953 | } else { | ||||
954 | d->checkType = Cross; | ||||
955 | } | ||||
505 | } | 956 | } | ||
506 | 957 | | |||
507 | OROPrimitive* OROCheck::clone() | 958 | OROPrimitive* OROCheckBox::clone() const | ||
staniek: can be `clone() const` | |||||
508 | { | 959 | { | ||
509 | OROCheck *theClone = new OROCheck(); | 960 | OROCheckBox *theClone = new OROCheckBox(); | ||
510 | theClone->setSize(m_size); | 961 | theClone->setSize(size()); | ||
511 | theClone->setPosition(m_position); | 962 | theClone->setPosition(position()); | ||
512 | theClone->setLineStyle(m_lineStyle); | 963 | theClone->setLineStyle(lineStyle()); | ||
513 | theClone->setForegroundColor(m_fgColor); | 964 | theClone->setForegroundColor(foregroundColor()); | ||
514 | theClone->setValue(m_value); | 965 | theClone->setValue(value()); | ||
966 | theClone->setCheckType(checkType()); | ||||
515 | return theClone; | 967 | return theClone; | ||
staniek: Missing copy for `checkType`. | |||||
staniek: TODO | |||||
516 | } | 968 | } |
Let's have static or use namespace { }