1 | // Copyright (C) 2020 The Qt Company Ltd. |
2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 |
3 | |
4 | // THIS FILE IS AUTOMATICALLY GENERATED. DO NOT EDIT! |
5 | |
6 | #include "ui4.h" |
7 | |
8 | |
9 | QT_BEGIN_NAMESPACE |
10 | |
11 | using namespace Qt::StringLiterals; |
12 | |
13 | #ifdef QFORMINTERNAL_NAMESPACE |
14 | using namespace QFormInternal; |
15 | #endif |
16 | |
17 | /******************************************************************************* |
18 | ** Implementations |
19 | */ |
20 | |
21 | DomUI::~DomUI() |
22 | { |
23 | delete m_widget; |
24 | delete m_layoutDefault; |
25 | delete m_layoutFunction; |
26 | delete m_customWidgets; |
27 | delete m_tabStops; |
28 | delete m_includes; |
29 | delete m_resources; |
30 | delete m_connections; |
31 | delete m_designerdata; |
32 | delete m_slots; |
33 | delete m_buttonGroups; |
34 | } |
35 | |
36 | void DomUI::read(QXmlStreamReader &reader) |
37 | { |
38 | const QXmlStreamAttributes &attributes = reader.attributes(); |
39 | for (const QXmlStreamAttribute &attribute : attributes) { |
40 | const auto name = attribute.name(); |
41 | if (name == u"version"_s ) { |
42 | setAttributeVersion(attribute.value().toString()); |
43 | continue; |
44 | } |
45 | if (name == u"language"_s ) { |
46 | setAttributeLanguage(attribute.value().toString()); |
47 | continue; |
48 | } |
49 | if (name == u"displayname"_s ) { |
50 | setAttributeDisplayname(attribute.value().toString()); |
51 | continue; |
52 | } |
53 | if (name == u"idbasedtr"_s ) { |
54 | setAttributeIdbasedtr(attribute.value() == u"true"_s ); |
55 | continue; |
56 | } |
57 | if (name == u"connectslotsbyname"_s ) { |
58 | setAttributeConnectslotsbyname(attribute.value() == u"true"_s ); |
59 | continue; |
60 | } |
61 | if (name == u"stdsetdef"_s ) { |
62 | setAttributeStdsetdef(attribute.value().toInt()); |
63 | continue; |
64 | } |
65 | if (name == u"stdSetDef"_s ) { |
66 | setAttributeStdSetDef(attribute.value().toInt()); |
67 | continue; |
68 | } |
69 | reader.raiseError(message: "Unexpected attribute "_L1 + name); |
70 | } |
71 | |
72 | while (!reader.hasError()) { |
73 | switch (reader.readNext()) { |
74 | case QXmlStreamReader::StartElement : { |
75 | const auto tag = reader.name(); |
76 | if (!tag.compare(other: u"author"_s , cs: Qt::CaseInsensitive)) { |
77 | setElementAuthor(reader.readElementText()); |
78 | continue; |
79 | } |
80 | if (!tag.compare(other: u"comment"_s , cs: Qt::CaseInsensitive)) { |
81 | setElementComment(reader.readElementText()); |
82 | continue; |
83 | } |
84 | if (!tag.compare(other: u"exportmacro"_s , cs: Qt::CaseInsensitive)) { |
85 | setElementExportMacro(reader.readElementText()); |
86 | continue; |
87 | } |
88 | if (!tag.compare(other: u"class"_s , cs: Qt::CaseInsensitive)) { |
89 | setElementClass(reader.readElementText()); |
90 | continue; |
91 | } |
92 | if (!tag.compare(other: u"widget"_s , cs: Qt::CaseInsensitive)) { |
93 | auto *v = new DomWidget(); |
94 | v->read(reader); |
95 | setElementWidget(v); |
96 | continue; |
97 | } |
98 | if (!tag.compare(other: u"layoutdefault"_s , cs: Qt::CaseInsensitive)) { |
99 | auto *v = new DomLayoutDefault(); |
100 | v->read(reader); |
101 | setElementLayoutDefault(v); |
102 | continue; |
103 | } |
104 | if (!tag.compare(other: u"layoutfunction"_s , cs: Qt::CaseInsensitive)) { |
105 | auto *v = new DomLayoutFunction(); |
106 | v->read(reader); |
107 | setElementLayoutFunction(v); |
108 | continue; |
109 | } |
110 | if (!tag.compare(other: u"pixmapfunction"_s , cs: Qt::CaseInsensitive)) { |
111 | setElementPixmapFunction(reader.readElementText()); |
112 | continue; |
113 | } |
114 | if (!tag.compare(other: u"customwidgets"_s , cs: Qt::CaseInsensitive)) { |
115 | auto *v = new DomCustomWidgets(); |
116 | v->read(reader); |
117 | setElementCustomWidgets(v); |
118 | continue; |
119 | } |
120 | if (!tag.compare(other: u"tabstops"_s , cs: Qt::CaseInsensitive)) { |
121 | auto *v = new DomTabStops(); |
122 | v->read(reader); |
123 | setElementTabStops(v); |
124 | continue; |
125 | } |
126 | if (!tag.compare(other: u"images"_s , cs: Qt::CaseInsensitive)) { |
127 | qWarning(msg: "Omitting deprecated element <images>." ); |
128 | reader.skipCurrentElement(); |
129 | continue; |
130 | } |
131 | if (!tag.compare(other: u"includes"_s , cs: Qt::CaseInsensitive)) { |
132 | auto *v = new DomIncludes(); |
133 | v->read(reader); |
134 | setElementIncludes(v); |
135 | continue; |
136 | } |
137 | if (!tag.compare(other: u"resources"_s , cs: Qt::CaseInsensitive)) { |
138 | auto *v = new DomResources(); |
139 | v->read(reader); |
140 | setElementResources(v); |
141 | continue; |
142 | } |
143 | if (!tag.compare(other: u"connections"_s , cs: Qt::CaseInsensitive)) { |
144 | auto *v = new DomConnections(); |
145 | v->read(reader); |
146 | setElementConnections(v); |
147 | continue; |
148 | } |
149 | if (!tag.compare(other: u"designerdata"_s , cs: Qt::CaseInsensitive)) { |
150 | auto *v = new DomDesignerData(); |
151 | v->read(reader); |
152 | setElementDesignerdata(v); |
153 | continue; |
154 | } |
155 | if (!tag.compare(other: u"slots"_s , cs: Qt::CaseInsensitive)) { |
156 | auto *v = new DomSlots(); |
157 | v->read(reader); |
158 | setElementSlots(v); |
159 | continue; |
160 | } |
161 | if (!tag.compare(other: u"buttongroups"_s , cs: Qt::CaseInsensitive)) { |
162 | auto *v = new DomButtonGroups(); |
163 | v->read(reader); |
164 | setElementButtonGroups(v); |
165 | continue; |
166 | } |
167 | reader.raiseError(message: "Unexpected element "_L1 + tag); |
168 | } |
169 | break; |
170 | case QXmlStreamReader::EndElement : |
171 | return; |
172 | default : |
173 | break; |
174 | } |
175 | } |
176 | } |
177 | |
178 | void DomUI::write(QXmlStreamWriter &writer, const QString &tagName) const |
179 | { |
180 | writer.writeStartElement(qualifiedName: tagName.isEmpty() ? QStringLiteral("ui" ) : tagName.toLower()); |
181 | |
182 | if (hasAttributeVersion()) |
183 | writer.writeAttribute(qualifiedName: u"version"_s , value: attributeVersion()); |
184 | |
185 | if (hasAttributeLanguage()) |
186 | writer.writeAttribute(qualifiedName: u"language"_s , value: attributeLanguage()); |
187 | |
188 | if (hasAttributeDisplayname()) |
189 | writer.writeAttribute(qualifiedName: u"displayname"_s , value: attributeDisplayname()); |
190 | |
191 | if (hasAttributeIdbasedtr()) |
192 | writer.writeAttribute(qualifiedName: u"idbasedtr"_s , value: (attributeIdbasedtr() ? u"true"_s : u"false"_s )); |
193 | |
194 | if (hasAttributeConnectslotsbyname()) |
195 | writer.writeAttribute(qualifiedName: u"connectslotsbyname"_s , value: (attributeConnectslotsbyname() ? u"true"_s : u"false"_s )); |
196 | |
197 | if (hasAttributeStdsetdef()) |
198 | writer.writeAttribute(qualifiedName: u"stdsetdef"_s , value: QString::number(attributeStdsetdef())); |
199 | |
200 | if (hasAttributeStdSetDef()) |
201 | writer.writeAttribute(qualifiedName: u"stdsetdef"_s , value: QString::number(attributeStdSetDef())); |
202 | |
203 | if (m_children & Author) |
204 | writer.writeTextElement(qualifiedName: u"author"_s , text: m_author); |
205 | |
206 | if (m_children & Comment) |
207 | writer.writeTextElement(qualifiedName: u"comment"_s , text: m_comment); |
208 | |
209 | if (m_children & ExportMacro) |
210 | writer.writeTextElement(qualifiedName: u"exportmacro"_s , text: m_exportMacro); |
211 | |
212 | if (m_children & Class) |
213 | writer.writeTextElement(qualifiedName: u"class"_s , text: m_class); |
214 | |
215 | if (m_children & Widget) |
216 | m_widget->write(writer, tagName: u"widget"_s ); |
217 | |
218 | if (m_children & LayoutDefault) |
219 | m_layoutDefault->write(writer, tagName: u"layoutdefault"_s ); |
220 | |
221 | if (m_children & LayoutFunction) |
222 | m_layoutFunction->write(writer, tagName: u"layoutfunction"_s ); |
223 | |
224 | if (m_children & PixmapFunction) |
225 | writer.writeTextElement(qualifiedName: u"pixmapfunction"_s , text: m_pixmapFunction); |
226 | |
227 | if (m_children & CustomWidgets) |
228 | m_customWidgets->write(writer, tagName: u"customwidgets"_s ); |
229 | |
230 | if (m_children & TabStops) |
231 | m_tabStops->write(writer, tagName: u"tabstops"_s ); |
232 | |
233 | if (m_children & Includes) |
234 | m_includes->write(writer, tagName: u"includes"_s ); |
235 | |
236 | if (m_children & Resources) |
237 | m_resources->write(writer, tagName: u"resources"_s ); |
238 | |
239 | if (m_children & Connections) |
240 | m_connections->write(writer, tagName: u"connections"_s ); |
241 | |
242 | if (m_children & Designerdata) |
243 | m_designerdata->write(writer, tagName: u"designerdata"_s ); |
244 | |
245 | if (m_children & Slots) |
246 | m_slots->write(writer, tagName: u"slots"_s ); |
247 | |
248 | if (m_children & ButtonGroups) |
249 | m_buttonGroups->write(writer, tagName: u"buttongroups"_s ); |
250 | |
251 | writer.writeEndElement(); |
252 | } |
253 | |
254 | void DomUI::setElementAuthor(const QString &a) |
255 | { |
256 | m_children |= Author; |
257 | m_author = a; |
258 | } |
259 | |
260 | void DomUI::(const QString &a) |
261 | { |
262 | m_children |= Comment; |
263 | m_comment = a; |
264 | } |
265 | |
266 | void DomUI::setElementExportMacro(const QString &a) |
267 | { |
268 | m_children |= ExportMacro; |
269 | m_exportMacro = a; |
270 | } |
271 | |
272 | void DomUI::setElementClass(const QString &a) |
273 | { |
274 | m_children |= Class; |
275 | m_class = a; |
276 | } |
277 | |
278 | DomWidget *DomUI::takeElementWidget() |
279 | { |
280 | DomWidget *a = m_widget; |
281 | m_widget = nullptr; |
282 | m_children ^= Widget; |
283 | return a; |
284 | } |
285 | |
286 | void DomUI::setElementWidget(DomWidget *a) |
287 | { |
288 | delete m_widget; |
289 | m_children |= Widget; |
290 | m_widget = a; |
291 | } |
292 | |
293 | DomLayoutDefault *DomUI::takeElementLayoutDefault() |
294 | { |
295 | DomLayoutDefault *a = m_layoutDefault; |
296 | m_layoutDefault = nullptr; |
297 | m_children ^= LayoutDefault; |
298 | return a; |
299 | } |
300 | |
301 | void DomUI::setElementLayoutDefault(DomLayoutDefault *a) |
302 | { |
303 | delete m_layoutDefault; |
304 | m_children |= LayoutDefault; |
305 | m_layoutDefault = a; |
306 | } |
307 | |
308 | DomLayoutFunction *DomUI::takeElementLayoutFunction() |
309 | { |
310 | DomLayoutFunction *a = m_layoutFunction; |
311 | m_layoutFunction = nullptr; |
312 | m_children ^= LayoutFunction; |
313 | return a; |
314 | } |
315 | |
316 | void DomUI::setElementLayoutFunction(DomLayoutFunction *a) |
317 | { |
318 | delete m_layoutFunction; |
319 | m_children |= LayoutFunction; |
320 | m_layoutFunction = a; |
321 | } |
322 | |
323 | void DomUI::setElementPixmapFunction(const QString &a) |
324 | { |
325 | m_children |= PixmapFunction; |
326 | m_pixmapFunction = a; |
327 | } |
328 | |
329 | DomCustomWidgets *DomUI::takeElementCustomWidgets() |
330 | { |
331 | DomCustomWidgets *a = m_customWidgets; |
332 | m_customWidgets = nullptr; |
333 | m_children ^= CustomWidgets; |
334 | return a; |
335 | } |
336 | |
337 | void DomUI::setElementCustomWidgets(DomCustomWidgets *a) |
338 | { |
339 | delete m_customWidgets; |
340 | m_children |= CustomWidgets; |
341 | m_customWidgets = a; |
342 | } |
343 | |
344 | DomTabStops *DomUI::takeElementTabStops() |
345 | { |
346 | DomTabStops *a = m_tabStops; |
347 | m_tabStops = nullptr; |
348 | m_children ^= TabStops; |
349 | return a; |
350 | } |
351 | |
352 | void DomUI::setElementTabStops(DomTabStops *a) |
353 | { |
354 | delete m_tabStops; |
355 | m_children |= TabStops; |
356 | m_tabStops = a; |
357 | } |
358 | |
359 | DomIncludes *DomUI::takeElementIncludes() |
360 | { |
361 | DomIncludes *a = m_includes; |
362 | m_includes = nullptr; |
363 | m_children ^= Includes; |
364 | return a; |
365 | } |
366 | |
367 | void DomUI::setElementIncludes(DomIncludes *a) |
368 | { |
369 | delete m_includes; |
370 | m_children |= Includes; |
371 | m_includes = a; |
372 | } |
373 | |
374 | DomResources *DomUI::takeElementResources() |
375 | { |
376 | DomResources *a = m_resources; |
377 | m_resources = nullptr; |
378 | m_children ^= Resources; |
379 | return a; |
380 | } |
381 | |
382 | void DomUI::setElementResources(DomResources *a) |
383 | { |
384 | delete m_resources; |
385 | m_children |= Resources; |
386 | m_resources = a; |
387 | } |
388 | |
389 | DomConnections *DomUI::takeElementConnections() |
390 | { |
391 | DomConnections *a = m_connections; |
392 | m_connections = nullptr; |
393 | m_children ^= Connections; |
394 | return a; |
395 | } |
396 | |
397 | void DomUI::setElementConnections(DomConnections *a) |
398 | { |
399 | delete m_connections; |
400 | m_children |= Connections; |
401 | m_connections = a; |
402 | } |
403 | |
404 | DomDesignerData *DomUI::takeElementDesignerdata() |
405 | { |
406 | DomDesignerData *a = m_designerdata; |
407 | m_designerdata = nullptr; |
408 | m_children ^= Designerdata; |
409 | return a; |
410 | } |
411 | |
412 | void DomUI::setElementDesignerdata(DomDesignerData *a) |
413 | { |
414 | delete m_designerdata; |
415 | m_children |= Designerdata; |
416 | m_designerdata = a; |
417 | } |
418 | |
419 | DomSlots *DomUI::takeElementSlots() |
420 | { |
421 | DomSlots *a = m_slots; |
422 | m_slots = nullptr; |
423 | m_children ^= Slots; |
424 | return a; |
425 | } |
426 | |
427 | void DomUI::setElementSlots(DomSlots *a) |
428 | { |
429 | delete m_slots; |
430 | m_children |= Slots; |
431 | m_slots = a; |
432 | } |
433 | |
434 | DomButtonGroups *DomUI::takeElementButtonGroups() |
435 | { |
436 | DomButtonGroups *a = m_buttonGroups; |
437 | m_buttonGroups = nullptr; |
438 | m_children ^= ButtonGroups; |
439 | return a; |
440 | } |
441 | |
442 | void DomUI::setElementButtonGroups(DomButtonGroups *a) |
443 | { |
444 | delete m_buttonGroups; |
445 | m_children |= ButtonGroups; |
446 | m_buttonGroups = a; |
447 | } |
448 | |
449 | void DomUI::clearElementAuthor() |
450 | { |
451 | m_children &= ~Author; |
452 | } |
453 | |
454 | void DomUI::() |
455 | { |
456 | m_children &= ~Comment; |
457 | } |
458 | |
459 | void DomUI::clearElementExportMacro() |
460 | { |
461 | m_children &= ~ExportMacro; |
462 | } |
463 | |
464 | void DomUI::clearElementClass() |
465 | { |
466 | m_children &= ~Class; |
467 | } |
468 | |
469 | void DomUI::clearElementWidget() |
470 | { |
471 | delete m_widget; |
472 | m_widget = nullptr; |
473 | m_children &= ~Widget; |
474 | } |
475 | |
476 | void DomUI::clearElementLayoutDefault() |
477 | { |
478 | delete m_layoutDefault; |
479 | m_layoutDefault = nullptr; |
480 | m_children &= ~LayoutDefault; |
481 | } |
482 | |
483 | void DomUI::clearElementLayoutFunction() |
484 | { |
485 | delete m_layoutFunction; |
486 | m_layoutFunction = nullptr; |
487 | m_children &= ~LayoutFunction; |
488 | } |
489 | |
490 | void DomUI::clearElementPixmapFunction() |
491 | { |
492 | m_children &= ~PixmapFunction; |
493 | } |
494 | |
495 | void DomUI::clearElementCustomWidgets() |
496 | { |
497 | delete m_customWidgets; |
498 | m_customWidgets = nullptr; |
499 | m_children &= ~CustomWidgets; |
500 | } |
501 | |
502 | void DomUI::clearElementTabStops() |
503 | { |
504 | delete m_tabStops; |
505 | m_tabStops = nullptr; |
506 | m_children &= ~TabStops; |
507 | } |
508 | |
509 | void DomUI::clearElementIncludes() |
510 | { |
511 | delete m_includes; |
512 | m_includes = nullptr; |
513 | m_children &= ~Includes; |
514 | } |
515 | |
516 | void DomUI::clearElementResources() |
517 | { |
518 | delete m_resources; |
519 | m_resources = nullptr; |
520 | m_children &= ~Resources; |
521 | } |
522 | |
523 | void DomUI::clearElementConnections() |
524 | { |
525 | delete m_connections; |
526 | m_connections = nullptr; |
527 | m_children &= ~Connections; |
528 | } |
529 | |
530 | void DomUI::clearElementDesignerdata() |
531 | { |
532 | delete m_designerdata; |
533 | m_designerdata = nullptr; |
534 | m_children &= ~Designerdata; |
535 | } |
536 | |
537 | void DomUI::clearElementSlots() |
538 | { |
539 | delete m_slots; |
540 | m_slots = nullptr; |
541 | m_children &= ~Slots; |
542 | } |
543 | |
544 | void DomUI::clearElementButtonGroups() |
545 | { |
546 | delete m_buttonGroups; |
547 | m_buttonGroups = nullptr; |
548 | m_children &= ~ButtonGroups; |
549 | } |
550 | |
551 | DomIncludes::~DomIncludes() |
552 | { |
553 | qDeleteAll(c: m_include); |
554 | m_include.clear(); |
555 | } |
556 | |
557 | void DomIncludes::read(QXmlStreamReader &reader) |
558 | { |
559 | while (!reader.hasError()) { |
560 | switch (reader.readNext()) { |
561 | case QXmlStreamReader::StartElement : { |
562 | const auto tag = reader.name(); |
563 | if (!tag.compare(other: u"include"_s , cs: Qt::CaseInsensitive)) { |
564 | auto *v = new DomInclude(); |
565 | v->read(reader); |
566 | m_include.append(t: v); |
567 | continue; |
568 | } |
569 | reader.raiseError(message: "Unexpected element "_L1 + tag); |
570 | } |
571 | break; |
572 | case QXmlStreamReader::EndElement : |
573 | return; |
574 | default : |
575 | break; |
576 | } |
577 | } |
578 | } |
579 | |
580 | void DomIncludes::write(QXmlStreamWriter &writer, const QString &tagName) const |
581 | { |
582 | writer.writeStartElement(qualifiedName: tagName.isEmpty() ? QStringLiteral("includes" ) : tagName.toLower()); |
583 | |
584 | for (DomInclude *v : m_include) |
585 | v->write(writer, tagName: u"include"_s ); |
586 | |
587 | writer.writeEndElement(); |
588 | } |
589 | |
590 | void DomIncludes::setElementInclude(const QList<DomInclude *> &a) |
591 | { |
592 | m_children |= Include; |
593 | m_include = a; |
594 | } |
595 | |
596 | DomInclude::~DomInclude() = default; |
597 | |
598 | void DomInclude::read(QXmlStreamReader &reader) |
599 | { |
600 | const QXmlStreamAttributes &attributes = reader.attributes(); |
601 | for (const QXmlStreamAttribute &attribute : attributes) { |
602 | const auto name = attribute.name(); |
603 | if (name == u"location"_s ) { |
604 | setAttributeLocation(attribute.value().toString()); |
605 | continue; |
606 | } |
607 | if (name == u"impldecl"_s ) { |
608 | setAttributeImpldecl(attribute.value().toString()); |
609 | continue; |
610 | } |
611 | reader.raiseError(message: "Unexpected attribute "_L1 + name); |
612 | } |
613 | |
614 | while (!reader.hasError()) { |
615 | switch (reader.readNext()) { |
616 | case QXmlStreamReader::StartElement : { |
617 | const auto tag = reader.name(); |
618 | reader.raiseError(message: "Unexpected element "_L1 + tag); |
619 | } |
620 | break; |
621 | case QXmlStreamReader::EndElement : |
622 | return; |
623 | case QXmlStreamReader::Characters : |
624 | if (!reader.isWhitespace()) |
625 | m_text.append(s: reader.text().toString()); |
626 | break; |
627 | default : |
628 | break; |
629 | } |
630 | } |
631 | } |
632 | |
633 | void DomInclude::write(QXmlStreamWriter &writer, const QString &tagName) const |
634 | { |
635 | writer.writeStartElement(qualifiedName: tagName.isEmpty() ? QStringLiteral("include" ) : tagName.toLower()); |
636 | |
637 | if (hasAttributeLocation()) |
638 | writer.writeAttribute(qualifiedName: u"location"_s , value: attributeLocation()); |
639 | |
640 | if (hasAttributeImpldecl()) |
641 | writer.writeAttribute(qualifiedName: u"impldecl"_s , value: attributeImpldecl()); |
642 | |
643 | if (!m_text.isEmpty()) |
644 | writer.writeCharacters(text: m_text); |
645 | |
646 | writer.writeEndElement(); |
647 | } |
648 | |
649 | DomResources::~DomResources() |
650 | { |
651 | qDeleteAll(c: m_include); |
652 | m_include.clear(); |
653 | } |
654 | |
655 | void DomResources::read(QXmlStreamReader &reader) |
656 | { |
657 | const QXmlStreamAttributes &attributes = reader.attributes(); |
658 | for (const QXmlStreamAttribute &attribute : attributes) { |
659 | const auto name = attribute.name(); |
660 | if (name == u"name"_s ) { |
661 | setAttributeName(attribute.value().toString()); |
662 | continue; |
663 | } |
664 | reader.raiseError(message: "Unexpected attribute "_L1 + name); |
665 | } |
666 | |
667 | while (!reader.hasError()) { |
668 | switch (reader.readNext()) { |
669 | case QXmlStreamReader::StartElement : { |
670 | const auto tag = reader.name(); |
671 | if (!tag.compare(other: u"include"_s , cs: Qt::CaseInsensitive)) { |
672 | auto *v = new DomResource(); |
673 | v->read(reader); |
674 | m_include.append(t: v); |
675 | continue; |
676 | } |
677 | reader.raiseError(message: "Unexpected element "_L1 + tag); |
678 | } |
679 | break; |
680 | case QXmlStreamReader::EndElement : |
681 | return; |
682 | default : |
683 | break; |
684 | } |
685 | } |
686 | } |
687 | |
688 | void DomResources::write(QXmlStreamWriter &writer, const QString &tagName) const |
689 | { |
690 | writer.writeStartElement(qualifiedName: tagName.isEmpty() ? QStringLiteral("resources" ) : tagName.toLower()); |
691 | |
692 | if (hasAttributeName()) |
693 | writer.writeAttribute(qualifiedName: u"name"_s , value: attributeName()); |
694 | |
695 | for (DomResource *v : m_include) |
696 | v->write(writer, tagName: u"include"_s ); |
697 | |
698 | writer.writeEndElement(); |
699 | } |
700 | |
701 | void DomResources::setElementInclude(const QList<DomResource *> &a) |
702 | { |
703 | m_children |= Include; |
704 | m_include = a; |
705 | } |
706 | |
707 | DomResource::~DomResource() = default; |
708 | |
709 | void DomResource::read(QXmlStreamReader &reader) |
710 | { |
711 | const QXmlStreamAttributes &attributes = reader.attributes(); |
712 | for (const QXmlStreamAttribute &attribute : attributes) { |
713 | const auto name = attribute.name(); |
714 | if (name == u"location"_s ) { |
715 | setAttributeLocation(attribute.value().toString()); |
716 | continue; |
717 | } |
718 | reader.raiseError(message: "Unexpected attribute "_L1 + name); |
719 | } |
720 | |
721 | while (!reader.hasError()) { |
722 | switch (reader.readNext()) { |
723 | case QXmlStreamReader::StartElement : { |
724 | const auto tag = reader.name(); |
725 | reader.raiseError(message: "Unexpected element "_L1 + tag); |
726 | } |
727 | break; |
728 | case QXmlStreamReader::EndElement : |
729 | return; |
730 | default : |
731 | break; |
732 | } |
733 | } |
734 | } |
735 | |
736 | void DomResource::write(QXmlStreamWriter &writer, const QString &tagName) const |
737 | { |
738 | writer.writeStartElement(qualifiedName: tagName.isEmpty() ? QStringLiteral("resource" ) : tagName.toLower()); |
739 | |
740 | if (hasAttributeLocation()) |
741 | writer.writeAttribute(qualifiedName: u"location"_s , value: attributeLocation()); |
742 | |
743 | writer.writeEndElement(); |
744 | } |
745 | |
746 | DomActionGroup::~DomActionGroup() |
747 | { |
748 | qDeleteAll(c: m_action); |
749 | m_action.clear(); |
750 | qDeleteAll(c: m_actionGroup); |
751 | m_actionGroup.clear(); |
752 | qDeleteAll(c: m_property); |
753 | m_property.clear(); |
754 | qDeleteAll(c: m_attribute); |
755 | m_attribute.clear(); |
756 | } |
757 | |
758 | void DomActionGroup::read(QXmlStreamReader &reader) |
759 | { |
760 | const QXmlStreamAttributes &attributes = reader.attributes(); |
761 | for (const QXmlStreamAttribute &attribute : attributes) { |
762 | const auto name = attribute.name(); |
763 | if (name == u"name"_s ) { |
764 | setAttributeName(attribute.value().toString()); |
765 | continue; |
766 | } |
767 | reader.raiseError(message: "Unexpected attribute "_L1 + name); |
768 | } |
769 | |
770 | while (!reader.hasError()) { |
771 | switch (reader.readNext()) { |
772 | case QXmlStreamReader::StartElement : { |
773 | const auto tag = reader.name(); |
774 | if (!tag.compare(other: u"action"_s , cs: Qt::CaseInsensitive)) { |
775 | auto *v = new DomAction(); |
776 | v->read(reader); |
777 | m_action.append(t: v); |
778 | continue; |
779 | } |
780 | if (!tag.compare(other: u"actiongroup"_s , cs: Qt::CaseInsensitive)) { |
781 | auto *v = new DomActionGroup(); |
782 | v->read(reader); |
783 | m_actionGroup.append(t: v); |
784 | continue; |
785 | } |
786 | if (!tag.compare(other: u"property"_s , cs: Qt::CaseInsensitive)) { |
787 | auto *v = new DomProperty(); |
788 | v->read(reader); |
789 | m_property.append(t: v); |
790 | continue; |
791 | } |
792 | if (!tag.compare(other: u"attribute"_s , cs: Qt::CaseInsensitive)) { |
793 | auto *v = new DomProperty(); |
794 | v->read(reader); |
795 | m_attribute.append(t: v); |
796 | continue; |
797 | } |
798 | reader.raiseError(message: "Unexpected element "_L1 + tag); |
799 | } |
800 | break; |
801 | case QXmlStreamReader::EndElement : |
802 | return; |
803 | default : |
804 | break; |
805 | } |
806 | } |
807 | } |
808 | |
809 | void DomActionGroup::write(QXmlStreamWriter &writer, const QString &tagName) const |
810 | { |
811 | writer.writeStartElement(qualifiedName: tagName.isEmpty() ? QStringLiteral("actiongroup" ) : tagName.toLower()); |
812 | |
813 | if (hasAttributeName()) |
814 | writer.writeAttribute(qualifiedName: u"name"_s , value: attributeName()); |
815 | |
816 | for (DomAction *v : m_action) |
817 | v->write(writer, tagName: u"action"_s ); |
818 | |
819 | for (DomActionGroup *v : m_actionGroup) |
820 | v->write(writer, tagName: u"actiongroup"_s ); |
821 | |
822 | for (DomProperty *v : m_property) |
823 | v->write(writer, tagName: u"property"_s ); |
824 | |
825 | for (DomProperty *v : m_attribute) |
826 | v->write(writer, tagName: u"attribute"_s ); |
827 | |
828 | writer.writeEndElement(); |
829 | } |
830 | |
831 | void DomActionGroup::setElementAction(const QList<DomAction *> &a) |
832 | { |
833 | m_children |= Action; |
834 | m_action = a; |
835 | } |
836 | |
837 | void DomActionGroup::setElementActionGroup(const QList<DomActionGroup *> &a) |
838 | { |
839 | m_children |= ActionGroup; |
840 | m_actionGroup = a; |
841 | } |
842 | |
843 | void DomActionGroup::setElementProperty(const QList<DomProperty *> &a) |
844 | { |
845 | m_children |= Property; |
846 | m_property = a; |
847 | } |
848 | |
849 | void DomActionGroup::setElementAttribute(const QList<DomProperty *> &a) |
850 | { |
851 | m_children |= Attribute; |
852 | m_attribute = a; |
853 | } |
854 | |
855 | DomAction::~DomAction() |
856 | { |
857 | qDeleteAll(c: m_property); |
858 | m_property.clear(); |
859 | qDeleteAll(c: m_attribute); |
860 | m_attribute.clear(); |
861 | } |
862 | |
863 | void DomAction::read(QXmlStreamReader &reader) |
864 | { |
865 | const QXmlStreamAttributes &attributes = reader.attributes(); |
866 | for (const QXmlStreamAttribute &attribute : attributes) { |
867 | const auto name = attribute.name(); |
868 | if (name == u"name"_s ) { |
869 | setAttributeName(attribute.value().toString()); |
870 | continue; |
871 | } |
872 | if (name == u"menu"_s ) { |
873 | setAttributeMenu(attribute.value().toString()); |
874 | continue; |
875 | } |
876 | reader.raiseError(message: "Unexpected attribute "_L1 + name); |
877 | } |
878 | |
879 | while (!reader.hasError()) { |
880 | switch (reader.readNext()) { |
881 | case QXmlStreamReader::StartElement : { |
882 | const auto tag = reader.name(); |
883 | if (!tag.compare(other: u"property"_s , cs: Qt::CaseInsensitive)) { |
884 | auto *v = new DomProperty(); |
885 | v->read(reader); |
886 | m_property.append(t: v); |
887 | continue; |
888 | } |
889 | if (!tag.compare(other: u"attribute"_s , cs: Qt::CaseInsensitive)) { |
890 | auto *v = new DomProperty(); |
891 | v->read(reader); |
892 | m_attribute.append(t: v); |
893 | continue; |
894 | } |
895 | reader.raiseError(message: "Unexpected element "_L1 + tag); |
896 | } |
897 | break; |
898 | case QXmlStreamReader::EndElement : |
899 | return; |
900 | default : |
901 | break; |
902 | } |
903 | } |
904 | } |
905 | |
906 | void DomAction::write(QXmlStreamWriter &writer, const QString &tagName) const |
907 | { |
908 | writer.writeStartElement(qualifiedName: tagName.isEmpty() ? QStringLiteral("action" ) : tagName.toLower()); |
909 | |
910 | if (hasAttributeName()) |
911 | writer.writeAttribute(qualifiedName: u"name"_s , value: attributeName()); |
912 | |
913 | if (hasAttributeMenu()) |
914 | writer.writeAttribute(qualifiedName: u"menu"_s , value: attributeMenu()); |
915 | |
916 | for (DomProperty *v : m_property) |
917 | v->write(writer, tagName: u"property"_s ); |
918 | |
919 | for (DomProperty *v : m_attribute) |
920 | v->write(writer, tagName: u"attribute"_s ); |
921 | |
922 | writer.writeEndElement(); |
923 | } |
924 | |
925 | void DomAction::setElementProperty(const QList<DomProperty *> &a) |
926 | { |
927 | m_children |= Property; |
928 | m_property = a; |
929 | } |
930 | |
931 | void DomAction::setElementAttribute(const QList<DomProperty *> &a) |
932 | { |
933 | m_children |= Attribute; |
934 | m_attribute = a; |
935 | } |
936 | |
937 | DomActionRef::~DomActionRef() = default; |
938 | |
939 | void DomActionRef::read(QXmlStreamReader &reader) |
940 | { |
941 | const QXmlStreamAttributes &attributes = reader.attributes(); |
942 | for (const QXmlStreamAttribute &attribute : attributes) { |
943 | const auto name = attribute.name(); |
944 | if (name == u"name"_s ) { |
945 | setAttributeName(attribute.value().toString()); |
946 | continue; |
947 | } |
948 | reader.raiseError(message: "Unexpected attribute "_L1 + name); |
949 | } |
950 | |
951 | while (!reader.hasError()) { |
952 | switch (reader.readNext()) { |
953 | case QXmlStreamReader::StartElement : { |
954 | const auto tag = reader.name(); |
955 | reader.raiseError(message: "Unexpected element "_L1 + tag); |
956 | } |
957 | break; |
958 | case QXmlStreamReader::EndElement : |
959 | return; |
960 | default : |
961 | break; |
962 | } |
963 | } |
964 | } |
965 | |
966 | void DomActionRef::write(QXmlStreamWriter &writer, const QString &tagName) const |
967 | { |
968 | writer.writeStartElement(qualifiedName: tagName.isEmpty() ? QStringLiteral("actionref" ) : tagName.toLower()); |
969 | |
970 | if (hasAttributeName()) |
971 | writer.writeAttribute(qualifiedName: u"name"_s , value: attributeName()); |
972 | |
973 | writer.writeEndElement(); |
974 | } |
975 | |
976 | DomButtonGroup::~DomButtonGroup() |
977 | { |
978 | qDeleteAll(c: m_property); |
979 | m_property.clear(); |
980 | qDeleteAll(c: m_attribute); |
981 | m_attribute.clear(); |
982 | } |
983 | |
984 | void DomButtonGroup::read(QXmlStreamReader &reader) |
985 | { |
986 | const QXmlStreamAttributes &attributes = reader.attributes(); |
987 | for (const QXmlStreamAttribute &attribute : attributes) { |
988 | const auto name = attribute.name(); |
989 | if (name == u"name"_s ) { |
990 | setAttributeName(attribute.value().toString()); |
991 | continue; |
992 | } |
993 | reader.raiseError(message: "Unexpected attribute "_L1 + name); |
994 | } |
995 | |
996 | while (!reader.hasError()) { |
997 | switch (reader.readNext()) { |
998 | case QXmlStreamReader::StartElement : { |
999 | const auto tag = reader.name(); |
1000 | if (!tag.compare(other: u"property"_s , cs: Qt::CaseInsensitive)) { |
1001 | auto *v = new DomProperty(); |
1002 | v->read(reader); |
1003 | m_property.append(t: v); |
1004 | continue; |
1005 | } |
1006 | if (!tag.compare(other: u"attribute"_s , cs: Qt::CaseInsensitive)) { |
1007 | auto *v = new DomProperty(); |
1008 | v->read(reader); |
1009 | m_attribute.append(t: v); |
1010 | continue; |
1011 | } |
1012 | reader.raiseError(message: "Unexpected element "_L1 + tag); |
1013 | } |
1014 | break; |
1015 | case QXmlStreamReader::EndElement : |
1016 | return; |
1017 | default : |
1018 | break; |
1019 | } |
1020 | } |
1021 | } |
1022 | |
1023 | void DomButtonGroup::write(QXmlStreamWriter &writer, const QString &tagName) const |
1024 | { |
1025 | writer.writeStartElement(qualifiedName: tagName.isEmpty() ? QStringLiteral("buttongroup" ) : tagName.toLower()); |
1026 | |
1027 | if (hasAttributeName()) |
1028 | writer.writeAttribute(qualifiedName: u"name"_s , value: attributeName()); |
1029 | |
1030 | for (DomProperty *v : m_property) |
1031 | v->write(writer, tagName: u"property"_s ); |
1032 | |
1033 | for (DomProperty *v : m_attribute) |
1034 | v->write(writer, tagName: u"attribute"_s ); |
1035 | |
1036 | writer.writeEndElement(); |
1037 | } |
1038 | |
1039 | void DomButtonGroup::setElementProperty(const QList<DomProperty *> &a) |
1040 | { |
1041 | m_children |= Property; |
1042 | m_property = a; |
1043 | } |
1044 | |
1045 | void DomButtonGroup::setElementAttribute(const QList<DomProperty *> &a) |
1046 | { |
1047 | m_children |= Attribute; |
1048 | m_attribute = a; |
1049 | } |
1050 | |
1051 | DomButtonGroups::~DomButtonGroups() |
1052 | { |
1053 | qDeleteAll(c: m_buttonGroup); |
1054 | m_buttonGroup.clear(); |
1055 | } |
1056 | |
1057 | void DomButtonGroups::read(QXmlStreamReader &reader) |
1058 | { |
1059 | while (!reader.hasError()) { |
1060 | switch (reader.readNext()) { |
1061 | case QXmlStreamReader::StartElement : { |
1062 | const auto tag = reader.name(); |
1063 | if (!tag.compare(other: u"buttongroup"_s , cs: Qt::CaseInsensitive)) { |
1064 | auto *v = new DomButtonGroup(); |
1065 | v->read(reader); |
1066 | m_buttonGroup.append(t: v); |
1067 | continue; |
1068 | } |
1069 | reader.raiseError(message: "Unexpected element "_L1 + tag); |
1070 | } |
1071 | break; |
1072 | case QXmlStreamReader::EndElement : |
1073 | return; |
1074 | default : |
1075 | break; |
1076 | } |
1077 | } |
1078 | } |
1079 | |
1080 | void DomButtonGroups::write(QXmlStreamWriter &writer, const QString &tagName) const |
1081 | { |
1082 | writer.writeStartElement(qualifiedName: tagName.isEmpty() ? QStringLiteral("buttongroups" ) : tagName.toLower()); |
1083 | |
1084 | for (DomButtonGroup *v : m_buttonGroup) |
1085 | v->write(writer, tagName: u"buttongroup"_s ); |
1086 | |
1087 | writer.writeEndElement(); |
1088 | } |
1089 | |
1090 | void DomButtonGroups::setElementButtonGroup(const QList<DomButtonGroup *> &a) |
1091 | { |
1092 | m_children |= ButtonGroup; |
1093 | m_buttonGroup = a; |
1094 | } |
1095 | |
1096 | DomCustomWidgets::~DomCustomWidgets() |
1097 | { |
1098 | qDeleteAll(c: m_customWidget); |
1099 | m_customWidget.clear(); |
1100 | } |
1101 | |
1102 | void DomCustomWidgets::read(QXmlStreamReader &reader) |
1103 | { |
1104 | while (!reader.hasError()) { |
1105 | switch (reader.readNext()) { |
1106 | case QXmlStreamReader::StartElement : { |
1107 | const auto tag = reader.name(); |
1108 | if (!tag.compare(other: u"customwidget"_s , cs: Qt::CaseInsensitive)) { |
1109 | auto *v = new DomCustomWidget(); |
1110 | v->read(reader); |
1111 | m_customWidget.append(t: v); |
1112 | continue; |
1113 | } |
1114 | reader.raiseError(message: "Unexpected element "_L1 + tag); |
1115 | } |
1116 | break; |
1117 | case QXmlStreamReader::EndElement : |
1118 | return; |
1119 | default : |
1120 | break; |
1121 | } |
1122 | } |
1123 | } |
1124 | |
1125 | void DomCustomWidgets::write(QXmlStreamWriter &writer, const QString &tagName) const |
1126 | { |
1127 | writer.writeStartElement(qualifiedName: tagName.isEmpty() ? QStringLiteral("customwidgets" ) : tagName.toLower()); |
1128 | |
1129 | for (DomCustomWidget *v : m_customWidget) |
1130 | v->write(writer, tagName: u"customwidget"_s ); |
1131 | |
1132 | writer.writeEndElement(); |
1133 | } |
1134 | |
1135 | void DomCustomWidgets::setElementCustomWidget(const QList<DomCustomWidget *> &a) |
1136 | { |
1137 | m_children |= CustomWidget; |
1138 | m_customWidget = a; |
1139 | } |
1140 | |
1141 | DomHeader::() = default; |
1142 | |
1143 | void DomHeader::(QXmlStreamReader &reader) |
1144 | { |
1145 | const QXmlStreamAttributes &attributes = reader.attributes(); |
1146 | for (const QXmlStreamAttribute &attribute : attributes) { |
1147 | const auto name = attribute.name(); |
1148 | if (name == u"location"_s ) { |
1149 | setAttributeLocation(attribute.value().toString()); |
1150 | continue; |
1151 | } |
1152 | reader.raiseError(message: "Unexpected attribute "_L1 + name); |
1153 | } |
1154 | |
1155 | while (!reader.hasError()) { |
1156 | switch (reader.readNext()) { |
1157 | case QXmlStreamReader::StartElement : { |
1158 | const auto tag = reader.name(); |
1159 | reader.raiseError(message: "Unexpected element "_L1 + tag); |
1160 | } |
1161 | break; |
1162 | case QXmlStreamReader::EndElement : |
1163 | return; |
1164 | case QXmlStreamReader::Characters : |
1165 | if (!reader.isWhitespace()) |
1166 | m_text.append(s: reader.text().toString()); |
1167 | break; |
1168 | default : |
1169 | break; |
1170 | } |
1171 | } |
1172 | } |
1173 | |
1174 | void DomHeader::(QXmlStreamWriter &writer, const QString &tagName) const |
1175 | { |
1176 | writer.writeStartElement(qualifiedName: tagName.isEmpty() ? QStringLiteral("header" ) : tagName.toLower()); |
1177 | |
1178 | if (hasAttributeLocation()) |
1179 | writer.writeAttribute(qualifiedName: u"location"_s , value: attributeLocation()); |
1180 | |
1181 | if (!m_text.isEmpty()) |
1182 | writer.writeCharacters(text: m_text); |
1183 | |
1184 | writer.writeEndElement(); |
1185 | } |
1186 | |
1187 | DomCustomWidget::~DomCustomWidget() |
1188 | { |
1189 | delete m_header; |
1190 | delete m_sizeHint; |
1191 | delete m_slots; |
1192 | delete m_propertyspecifications; |
1193 | } |
1194 | |
1195 | void DomCustomWidget::read(QXmlStreamReader &reader) |
1196 | { |
1197 | while (!reader.hasError()) { |
1198 | switch (reader.readNext()) { |
1199 | case QXmlStreamReader::StartElement : { |
1200 | const auto tag = reader.name(); |
1201 | if (!tag.compare(other: u"class"_s , cs: Qt::CaseInsensitive)) { |
1202 | setElementClass(reader.readElementText()); |
1203 | continue; |
1204 | } |
1205 | if (!tag.compare(other: u"extends"_s , cs: Qt::CaseInsensitive)) { |
1206 | setElementExtends(reader.readElementText()); |
1207 | continue; |
1208 | } |
1209 | if (!tag.compare(other: u"header"_s , cs: Qt::CaseInsensitive)) { |
1210 | auto *v = new DomHeader(); |
1211 | v->read(reader); |
1212 | setElementHeader(v); |
1213 | continue; |
1214 | } |
1215 | if (!tag.compare(other: u"sizehint"_s , cs: Qt::CaseInsensitive)) { |
1216 | auto *v = new DomSize(); |
1217 | v->read(reader); |
1218 | setElementSizeHint(v); |
1219 | continue; |
1220 | } |
1221 | if (!tag.compare(other: u"addpagemethod"_s , cs: Qt::CaseInsensitive)) { |
1222 | setElementAddPageMethod(reader.readElementText()); |
1223 | continue; |
1224 | } |
1225 | if (!tag.compare(other: u"container"_s , cs: Qt::CaseInsensitive)) { |
1226 | setElementContainer(reader.readElementText().toInt()); |
1227 | continue; |
1228 | } |
1229 | if (!tag.compare(other: u"sizepolicy"_s , cs: Qt::CaseInsensitive)) { |
1230 | qWarning(msg: "Omitting deprecated element <sizepolicy>." ); |
1231 | reader.skipCurrentElement(); |
1232 | continue; |
1233 | } |
1234 | if (!tag.compare(other: u"pixmap"_s , cs: Qt::CaseInsensitive)) { |
1235 | setElementPixmap(reader.readElementText()); |
1236 | continue; |
1237 | } |
1238 | if (!tag.compare(other: u"script"_s , cs: Qt::CaseInsensitive)) { |
1239 | qWarning(msg: "Omitting deprecated element <script>." ); |
1240 | reader.skipCurrentElement(); |
1241 | continue; |
1242 | } |
1243 | if (!tag.compare(other: u"properties"_s , cs: Qt::CaseInsensitive)) { |
1244 | qWarning(msg: "Omitting deprecated element <properties>." ); |
1245 | reader.skipCurrentElement(); |
1246 | continue; |
1247 | } |
1248 | if (!tag.compare(other: u"slots"_s , cs: Qt::CaseInsensitive)) { |
1249 | auto *v = new DomSlots(); |
1250 | v->read(reader); |
1251 | setElementSlots(v); |
1252 | continue; |
1253 | } |
1254 | if (!tag.compare(other: u"propertyspecifications"_s , cs: Qt::CaseInsensitive)) { |
1255 | auto *v = new DomPropertySpecifications(); |
1256 | v->read(reader); |
1257 | setElementPropertyspecifications(v); |
1258 | continue; |
1259 | } |
1260 | reader.raiseError(message: "Unexpected element "_L1 + tag); |
1261 | } |
1262 | break; |
1263 | case QXmlStreamReader::EndElement : |
1264 | return; |
1265 | default : |
1266 | break; |
1267 | } |
1268 | } |
1269 | } |
1270 | |
1271 | void DomCustomWidget::write(QXmlStreamWriter &writer, const QString &tagName) const |
1272 | { |
1273 | writer.writeStartElement(qualifiedName: tagName.isEmpty() ? QStringLiteral("customwidget" ) : tagName.toLower()); |
1274 | |
1275 | if (m_children & Class) |
1276 | writer.writeTextElement(qualifiedName: u"class"_s , text: m_class); |
1277 | |
1278 | if (m_children & Extends) |
1279 | writer.writeTextElement(qualifiedName: u"extends"_s , text: m_extends); |
1280 | |
1281 | if (m_children & Header) |
1282 | m_header->write(writer, tagName: u"header"_s ); |
1283 | |
1284 | if (m_children & SizeHint) |
1285 | m_sizeHint->write(writer, tagName: u"sizehint"_s ); |
1286 | |
1287 | if (m_children & AddPageMethod) |
1288 | writer.writeTextElement(qualifiedName: u"addpagemethod"_s , text: m_addPageMethod); |
1289 | |
1290 | if (m_children & Container) |
1291 | writer.writeTextElement(qualifiedName: u"container"_s , text: QString::number(m_container)); |
1292 | |
1293 | if (m_children & Pixmap) |
1294 | writer.writeTextElement(qualifiedName: u"pixmap"_s , text: m_pixmap); |
1295 | |
1296 | if (m_children & Slots) |
1297 | m_slots->write(writer, tagName: u"slots"_s ); |
1298 | |
1299 | if (m_children & Propertyspecifications) |
1300 | m_propertyspecifications->write(writer, tagName: u"propertyspecifications"_s ); |
1301 | |
1302 | writer.writeEndElement(); |
1303 | } |
1304 | |
1305 | void DomCustomWidget::setElementClass(const QString &a) |
1306 | { |
1307 | m_children |= Class; |
1308 | m_class = a; |
1309 | } |
1310 | |
1311 | void DomCustomWidget::setElementExtends(const QString &a) |
1312 | { |
1313 | m_children |= Extends; |
1314 | m_extends = a; |
1315 | } |
1316 | |
1317 | DomHeader *DomCustomWidget::() |
1318 | { |
1319 | DomHeader *a = m_header; |
1320 | m_header = nullptr; |
1321 | m_children ^= Header; |
1322 | return a; |
1323 | } |
1324 | |
1325 | void DomCustomWidget::(DomHeader *a) |
1326 | { |
1327 | delete m_header; |
1328 | m_children |= Header; |
1329 | m_header = a; |
1330 | } |
1331 | |
1332 | DomSize *DomCustomWidget::takeElementSizeHint() |
1333 | { |
1334 | DomSize *a = m_sizeHint; |
1335 | m_sizeHint = nullptr; |
1336 | m_children ^= SizeHint; |
1337 | return a; |
1338 | } |
1339 | |
1340 | void DomCustomWidget::setElementSizeHint(DomSize *a) |
1341 | { |
1342 | delete m_sizeHint; |
1343 | m_children |= SizeHint; |
1344 | m_sizeHint = a; |
1345 | } |
1346 | |
1347 | void DomCustomWidget::setElementAddPageMethod(const QString &a) |
1348 | { |
1349 | m_children |= AddPageMethod; |
1350 | m_addPageMethod = a; |
1351 | } |
1352 | |
1353 | void DomCustomWidget::setElementContainer(int a) |
1354 | { |
1355 | m_children |= Container; |
1356 | m_container = a; |
1357 | } |
1358 | |
1359 | void DomCustomWidget::setElementPixmap(const QString &a) |
1360 | { |
1361 | m_children |= Pixmap; |
1362 | m_pixmap = a; |
1363 | } |
1364 | |
1365 | DomSlots *DomCustomWidget::takeElementSlots() |
1366 | { |
1367 | DomSlots *a = m_slots; |
1368 | m_slots = nullptr; |
1369 | m_children ^= Slots; |
1370 | return a; |
1371 | } |
1372 | |
1373 | void DomCustomWidget::setElementSlots(DomSlots *a) |
1374 | { |
1375 | delete m_slots; |
1376 | m_children |= Slots; |
1377 | m_slots = a; |
1378 | } |
1379 | |
1380 | DomPropertySpecifications *DomCustomWidget::takeElementPropertyspecifications() |
1381 | { |
1382 | DomPropertySpecifications *a = m_propertyspecifications; |
1383 | m_propertyspecifications = nullptr; |
1384 | m_children ^= Propertyspecifications; |
1385 | return a; |
1386 | } |
1387 | |
1388 | void DomCustomWidget::setElementPropertyspecifications(DomPropertySpecifications *a) |
1389 | { |
1390 | delete m_propertyspecifications; |
1391 | m_children |= Propertyspecifications; |
1392 | m_propertyspecifications = a; |
1393 | } |
1394 | |
1395 | void DomCustomWidget::clearElementClass() |
1396 | { |
1397 | m_children &= ~Class; |
1398 | } |
1399 | |
1400 | void DomCustomWidget::clearElementExtends() |
1401 | { |
1402 | m_children &= ~Extends; |
1403 | } |
1404 | |
1405 | void DomCustomWidget::() |
1406 | { |
1407 | delete m_header; |
1408 | m_header = nullptr; |
1409 | m_children &= ~Header; |
1410 | } |
1411 | |
1412 | void DomCustomWidget::clearElementSizeHint() |
1413 | { |
1414 | delete m_sizeHint; |
1415 | m_sizeHint = nullptr; |
1416 | m_children &= ~SizeHint; |
1417 | } |
1418 | |
1419 | void DomCustomWidget::clearElementAddPageMethod() |
1420 | { |
1421 | m_children &= ~AddPageMethod; |
1422 | } |
1423 | |
1424 | void DomCustomWidget::clearElementContainer() |
1425 | { |
1426 | m_children &= ~Container; |
1427 | } |
1428 | |
1429 | void DomCustomWidget::clearElementPixmap() |
1430 | { |
1431 | m_children &= ~Pixmap; |
1432 | } |
1433 | |
1434 | void DomCustomWidget::clearElementSlots() |
1435 | { |
1436 | delete m_slots; |
1437 | m_slots = nullptr; |
1438 | m_children &= ~Slots; |
1439 | } |
1440 | |
1441 | void DomCustomWidget::clearElementPropertyspecifications() |
1442 | { |
1443 | delete m_propertyspecifications; |
1444 | m_propertyspecifications = nullptr; |
1445 | m_children &= ~Propertyspecifications; |
1446 | } |
1447 | |
1448 | DomLayoutDefault::~DomLayoutDefault() = default; |
1449 | |
1450 | void DomLayoutDefault::read(QXmlStreamReader &reader) |
1451 | { |
1452 | const QXmlStreamAttributes &attributes = reader.attributes(); |
1453 | for (const QXmlStreamAttribute &attribute : attributes) { |
1454 | const auto name = attribute.name(); |
1455 | if (name == u"spacing"_s ) { |
1456 | setAttributeSpacing(attribute.value().toInt()); |
1457 | continue; |
1458 | } |
1459 | if (name == u"margin"_s ) { |
1460 | setAttributeMargin(attribute.value().toInt()); |
1461 | continue; |
1462 | } |
1463 | reader.raiseError(message: "Unexpected attribute "_L1 + name); |
1464 | } |
1465 | |
1466 | while (!reader.hasError()) { |
1467 | switch (reader.readNext()) { |
1468 | case QXmlStreamReader::StartElement : { |
1469 | const auto tag = reader.name(); |
1470 | reader.raiseError(message: "Unexpected element "_L1 + tag); |
1471 | } |
1472 | break; |
1473 | case QXmlStreamReader::EndElement : |
1474 | return; |
1475 | default : |
1476 | break; |
1477 | } |
1478 | } |
1479 | } |
1480 | |
1481 | void DomLayoutDefault::write(QXmlStreamWriter &writer, const QString &tagName) const |
1482 | { |
1483 | writer.writeStartElement(qualifiedName: tagName.isEmpty() ? QStringLiteral("layoutdefault" ) : tagName.toLower()); |
1484 | |
1485 | if (hasAttributeSpacing()) |
1486 | writer.writeAttribute(qualifiedName: u"spacing"_s , value: QString::number(attributeSpacing())); |
1487 | |
1488 | if (hasAttributeMargin()) |
1489 | writer.writeAttribute(qualifiedName: u"margin"_s , value: QString::number(attributeMargin())); |
1490 | |
1491 | writer.writeEndElement(); |
1492 | } |
1493 | |
1494 | DomLayoutFunction::~DomLayoutFunction() = default; |
1495 | |
1496 | void DomLayoutFunction::read(QXmlStreamReader &reader) |
1497 | { |
1498 | const QXmlStreamAttributes &attributes = reader.attributes(); |
1499 | for (const QXmlStreamAttribute &attribute : attributes) { |
1500 | const auto name = attribute.name(); |
1501 | if (name == u"spacing"_s ) { |
1502 | setAttributeSpacing(attribute.value().toString()); |
1503 | continue; |
1504 | } |
1505 | if (name == u"margin"_s ) { |
1506 | setAttributeMargin(attribute.value().toString()); |
1507 | continue; |
1508 | } |
1509 | reader.raiseError(message: "Unexpected attribute "_L1 + name); |
1510 | } |
1511 | |
1512 | while (!reader.hasError()) { |
1513 | switch (reader.readNext()) { |
1514 | case QXmlStreamReader::StartElement : { |
1515 | const auto tag = reader.name(); |
1516 | reader.raiseError(message: "Unexpected element "_L1 + tag); |
1517 | } |
1518 | break; |
1519 | case QXmlStreamReader::EndElement : |
1520 | return; |
1521 | default : |
1522 | break; |
1523 | } |
1524 | } |
1525 | } |
1526 | |
1527 | void DomLayoutFunction::write(QXmlStreamWriter &writer, const QString &tagName) const |
1528 | { |
1529 | writer.writeStartElement(qualifiedName: tagName.isEmpty() ? QStringLiteral("layoutfunction" ) : tagName.toLower()); |
1530 | |
1531 | if (hasAttributeSpacing()) |
1532 | writer.writeAttribute(qualifiedName: u"spacing"_s , value: attributeSpacing()); |
1533 | |
1534 | if (hasAttributeMargin()) |
1535 | writer.writeAttribute(qualifiedName: u"margin"_s , value: attributeMargin()); |
1536 | |
1537 | writer.writeEndElement(); |
1538 | } |
1539 | |
1540 | DomTabStops::~DomTabStops() |
1541 | { |
1542 | m_tabStop.clear(); |
1543 | } |
1544 | |
1545 | void DomTabStops::read(QXmlStreamReader &reader) |
1546 | { |
1547 | while (!reader.hasError()) { |
1548 | switch (reader.readNext()) { |
1549 | case QXmlStreamReader::StartElement : { |
1550 | const auto tag = reader.name(); |
1551 | if (!tag.compare(other: u"tabstop"_s , cs: Qt::CaseInsensitive)) { |
1552 | m_tabStop.append(t: reader.readElementText()); |
1553 | continue; |
1554 | } |
1555 | reader.raiseError(message: "Unexpected element "_L1 + tag); |
1556 | } |
1557 | break; |
1558 | case QXmlStreamReader::EndElement : |
1559 | return; |
1560 | default : |
1561 | break; |
1562 | } |
1563 | } |
1564 | } |
1565 | |
1566 | void DomTabStops::write(QXmlStreamWriter &writer, const QString &tagName) const |
1567 | { |
1568 | writer.writeStartElement(qualifiedName: tagName.isEmpty() ? QStringLiteral("tabstops" ) : tagName.toLower()); |
1569 | |
1570 | for (const QString &v : m_tabStop) |
1571 | writer.writeTextElement(qualifiedName: u"tabstop"_s , text: v); |
1572 | |
1573 | writer.writeEndElement(); |
1574 | } |
1575 | |
1576 | void DomTabStops::setElementTabStop(const QStringList &a) |
1577 | { |
1578 | m_children |= TabStop; |
1579 | m_tabStop = a; |
1580 | } |
1581 | |
1582 | DomLayout::~DomLayout() |
1583 | { |
1584 | qDeleteAll(c: m_property); |
1585 | m_property.clear(); |
1586 | qDeleteAll(c: m_attribute); |
1587 | m_attribute.clear(); |
1588 | qDeleteAll(c: m_item); |
1589 | m_item.clear(); |
1590 | } |
1591 | |
1592 | void DomLayout::read(QXmlStreamReader &reader) |
1593 | { |
1594 | const QXmlStreamAttributes &attributes = reader.attributes(); |
1595 | for (const QXmlStreamAttribute &attribute : attributes) { |
1596 | const auto name = attribute.name(); |
1597 | if (name == u"class"_s ) { |
1598 | setAttributeClass(attribute.value().toString()); |
1599 | continue; |
1600 | } |
1601 | if (name == u"name"_s ) { |
1602 | setAttributeName(attribute.value().toString()); |
1603 | continue; |
1604 | } |
1605 | if (name == u"stretch"_s ) { |
1606 | setAttributeStretch(attribute.value().toString()); |
1607 | continue; |
1608 | } |
1609 | if (name == u"rowstretch"_s ) { |
1610 | setAttributeRowStretch(attribute.value().toString()); |
1611 | continue; |
1612 | } |
1613 | if (name == u"columnstretch"_s ) { |
1614 | setAttributeColumnStretch(attribute.value().toString()); |
1615 | continue; |
1616 | } |
1617 | if (name == u"rowminimumheight"_s ) { |
1618 | setAttributeRowMinimumHeight(attribute.value().toString()); |
1619 | continue; |
1620 | } |
1621 | if (name == u"columnminimumwidth"_s ) { |
1622 | setAttributeColumnMinimumWidth(attribute.value().toString()); |
1623 | continue; |
1624 | } |
1625 | reader.raiseError(message: "Unexpected attribute "_L1 + name); |
1626 | } |
1627 | |
1628 | while (!reader.hasError()) { |
1629 | switch (reader.readNext()) { |
1630 | case QXmlStreamReader::StartElement : { |
1631 | const auto tag = reader.name(); |
1632 | if (!tag.compare(other: u"property"_s , cs: Qt::CaseInsensitive)) { |
1633 | auto *v = new DomProperty(); |
1634 | v->read(reader); |
1635 | m_property.append(t: v); |
1636 | continue; |
1637 | } |
1638 | if (!tag.compare(other: u"attribute"_s , cs: Qt::CaseInsensitive)) { |
1639 | auto *v = new DomProperty(); |
1640 | v->read(reader); |
1641 | m_attribute.append(t: v); |
1642 | continue; |
1643 | } |
1644 | if (!tag.compare(other: u"item"_s , cs: Qt::CaseInsensitive)) { |
1645 | auto *v = new DomLayoutItem(); |
1646 | v->read(reader); |
1647 | m_item.append(t: v); |
1648 | continue; |
1649 | } |
1650 | reader.raiseError(message: "Unexpected element "_L1 + tag); |
1651 | } |
1652 | break; |
1653 | case QXmlStreamReader::EndElement : |
1654 | return; |
1655 | default : |
1656 | break; |
1657 | } |
1658 | } |
1659 | } |
1660 | |
1661 | void DomLayout::write(QXmlStreamWriter &writer, const QString &tagName) const |
1662 | { |
1663 | writer.writeStartElement(qualifiedName: tagName.isEmpty() ? QStringLiteral("layout" ) : tagName.toLower()); |
1664 | |
1665 | if (hasAttributeClass()) |
1666 | writer.writeAttribute(qualifiedName: u"class"_s , value: attributeClass()); |
1667 | |
1668 | if (hasAttributeName()) |
1669 | writer.writeAttribute(qualifiedName: u"name"_s , value: attributeName()); |
1670 | |
1671 | if (hasAttributeStretch()) |
1672 | writer.writeAttribute(qualifiedName: u"stretch"_s , value: attributeStretch()); |
1673 | |
1674 | if (hasAttributeRowStretch()) |
1675 | writer.writeAttribute(qualifiedName: u"rowstretch"_s , value: attributeRowStretch()); |
1676 | |
1677 | if (hasAttributeColumnStretch()) |
1678 | writer.writeAttribute(qualifiedName: u"columnstretch"_s , value: attributeColumnStretch()); |
1679 | |
1680 | if (hasAttributeRowMinimumHeight()) |
1681 | writer.writeAttribute(qualifiedName: u"rowminimumheight"_s , value: attributeRowMinimumHeight()); |
1682 | |
1683 | if (hasAttributeColumnMinimumWidth()) |
1684 | writer.writeAttribute(qualifiedName: u"columnminimumwidth"_s , value: attributeColumnMinimumWidth()); |
1685 | |
1686 | for (DomProperty *v : m_property) |
1687 | v->write(writer, tagName: u"property"_s ); |
1688 | |
1689 | for (DomProperty *v : m_attribute) |
1690 | v->write(writer, tagName: u"attribute"_s ); |
1691 | |
1692 | for (DomLayoutItem *v : m_item) |
1693 | v->write(writer, tagName: u"item"_s ); |
1694 | |
1695 | writer.writeEndElement(); |
1696 | } |
1697 | |
1698 | void DomLayout::setElementProperty(const QList<DomProperty *> &a) |
1699 | { |
1700 | m_children |= Property; |
1701 | m_property = a; |
1702 | } |
1703 | |
1704 | void DomLayout::setElementAttribute(const QList<DomProperty *> &a) |
1705 | { |
1706 | m_children |= Attribute; |
1707 | m_attribute = a; |
1708 | } |
1709 | |
1710 | void DomLayout::setElementItem(const QList<DomLayoutItem *> &a) |
1711 | { |
1712 | m_children |= Item; |
1713 | m_item = a; |
1714 | } |
1715 | |
1716 | DomLayoutItem::~DomLayoutItem() |
1717 | { |
1718 | delete m_widget; |
1719 | delete m_layout; |
1720 | delete m_spacer; |
1721 | } |
1722 | |
1723 | void DomLayoutItem::clear() |
1724 | { |
1725 | delete m_widget; |
1726 | delete m_layout; |
1727 | delete m_spacer; |
1728 | |
1729 | m_kind = Unknown; |
1730 | |
1731 | m_widget = nullptr; |
1732 | m_layout = nullptr; |
1733 | m_spacer = nullptr; |
1734 | } |
1735 | |
1736 | void DomLayoutItem::read(QXmlStreamReader &reader) |
1737 | { |
1738 | const QXmlStreamAttributes &attributes = reader.attributes(); |
1739 | for (const QXmlStreamAttribute &attribute : attributes) { |
1740 | const auto name = attribute.name(); |
1741 | if (name == u"row"_s ) { |
1742 | setAttributeRow(attribute.value().toInt()); |
1743 | continue; |
1744 | } |
1745 | if (name == u"column"_s ) { |
1746 | setAttributeColumn(attribute.value().toInt()); |
1747 | continue; |
1748 | } |
1749 | if (name == u"rowspan"_s ) { |
1750 | setAttributeRowSpan(attribute.value().toInt()); |
1751 | continue; |
1752 | } |
1753 | if (name == u"colspan"_s ) { |
1754 | setAttributeColSpan(attribute.value().toInt()); |
1755 | continue; |
1756 | } |
1757 | if (name == u"alignment"_s ) { |
1758 | setAttributeAlignment(attribute.value().toString()); |
1759 | continue; |
1760 | } |
1761 | reader.raiseError(message: "Unexpected attribute "_L1 + name); |
1762 | } |
1763 | |
1764 | while (!reader.hasError()) { |
1765 | switch (reader.readNext()) { |
1766 | case QXmlStreamReader::StartElement : { |
1767 | const auto tag = reader.name(); |
1768 | if (!tag.compare(other: u"widget"_s , cs: Qt::CaseInsensitive)) { |
1769 | auto *v = new DomWidget(); |
1770 | v->read(reader); |
1771 | setElementWidget(v); |
1772 | continue; |
1773 | } |
1774 | if (!tag.compare(other: u"layout"_s , cs: Qt::CaseInsensitive)) { |
1775 | auto *v = new DomLayout(); |
1776 | v->read(reader); |
1777 | setElementLayout(v); |
1778 | continue; |
1779 | } |
1780 | if (!tag.compare(other: u"spacer"_s , cs: Qt::CaseInsensitive)) { |
1781 | auto *v = new DomSpacer(); |
1782 | v->read(reader); |
1783 | setElementSpacer(v); |
1784 | continue; |
1785 | } |
1786 | reader.raiseError(message: "Unexpected element "_L1 + tag); |
1787 | } |
1788 | break; |
1789 | case QXmlStreamReader::EndElement : |
1790 | return; |
1791 | default : |
1792 | break; |
1793 | } |
1794 | } |
1795 | } |
1796 | |
1797 | void DomLayoutItem::write(QXmlStreamWriter &writer, const QString &tagName) const |
1798 | { |
1799 | writer.writeStartElement(qualifiedName: tagName.isEmpty() ? QStringLiteral("layoutitem" ) : tagName.toLower()); |
1800 | |
1801 | if (hasAttributeRow()) |
1802 | writer.writeAttribute(qualifiedName: u"row"_s , value: QString::number(attributeRow())); |
1803 | |
1804 | if (hasAttributeColumn()) |
1805 | writer.writeAttribute(qualifiedName: u"column"_s , value: QString::number(attributeColumn())); |
1806 | |
1807 | if (hasAttributeRowSpan()) |
1808 | writer.writeAttribute(qualifiedName: u"rowspan"_s , value: QString::number(attributeRowSpan())); |
1809 | |
1810 | if (hasAttributeColSpan()) |
1811 | writer.writeAttribute(qualifiedName: u"colspan"_s , value: QString::number(attributeColSpan())); |
1812 | |
1813 | if (hasAttributeAlignment()) |
1814 | writer.writeAttribute(qualifiedName: u"alignment"_s , value: attributeAlignment()); |
1815 | |
1816 | switch (kind()) { |
1817 | case Widget: |
1818 | if (m_widget != nullptr) |
1819 | m_widget->write(writer, tagName: u"widget"_s ); |
1820 | break; |
1821 | |
1822 | case Layout: |
1823 | if (m_layout != nullptr) |
1824 | m_layout->write(writer, tagName: u"layout"_s ); |
1825 | break; |
1826 | |
1827 | case Spacer: |
1828 | if (m_spacer != nullptr) |
1829 | m_spacer->write(writer, tagName: u"spacer"_s ); |
1830 | break; |
1831 | |
1832 | default: |
1833 | break; |
1834 | } |
1835 | writer.writeEndElement(); |
1836 | } |
1837 | |
1838 | DomWidget *DomLayoutItem::takeElementWidget() |
1839 | { |
1840 | DomWidget *a = m_widget; |
1841 | m_widget = nullptr; |
1842 | return a; |
1843 | } |
1844 | |
1845 | void DomLayoutItem::setElementWidget(DomWidget *a) |
1846 | { |
1847 | clear(); |
1848 | m_kind = Widget; |
1849 | m_widget = a; |
1850 | } |
1851 | |
1852 | DomLayout *DomLayoutItem::takeElementLayout() |
1853 | { |
1854 | DomLayout *a = m_layout; |
1855 | m_layout = nullptr; |
1856 | return a; |
1857 | } |
1858 | |
1859 | void DomLayoutItem::setElementLayout(DomLayout *a) |
1860 | { |
1861 | clear(); |
1862 | m_kind = Layout; |
1863 | m_layout = a; |
1864 | } |
1865 | |
1866 | DomSpacer *DomLayoutItem::takeElementSpacer() |
1867 | { |
1868 | DomSpacer *a = m_spacer; |
1869 | m_spacer = nullptr; |
1870 | return a; |
1871 | } |
1872 | |
1873 | void DomLayoutItem::setElementSpacer(DomSpacer *a) |
1874 | { |
1875 | clear(); |
1876 | m_kind = Spacer; |
1877 | m_spacer = a; |
1878 | } |
1879 | |
1880 | DomRow::~DomRow() |
1881 | { |
1882 | qDeleteAll(c: m_property); |
1883 | m_property.clear(); |
1884 | } |
1885 | |
1886 | void DomRow::read(QXmlStreamReader &reader) |
1887 | { |
1888 | while (!reader.hasError()) { |
1889 | switch (reader.readNext()) { |
1890 | case QXmlStreamReader::StartElement : { |
1891 | const auto tag = reader.name(); |
1892 | if (!tag.compare(other: u"property"_s , cs: Qt::CaseInsensitive)) { |
1893 | auto *v = new DomProperty(); |
1894 | v->read(reader); |
1895 | m_property.append(t: v); |
1896 | continue; |
1897 | } |
1898 | reader.raiseError(message: "Unexpected element "_L1 + tag); |
1899 | } |
1900 | break; |
1901 | case QXmlStreamReader::EndElement : |
1902 | return; |
1903 | default : |
1904 | break; |
1905 | } |
1906 | } |
1907 | } |
1908 | |
1909 | void DomRow::write(QXmlStreamWriter &writer, const QString &tagName) const |
1910 | { |
1911 | writer.writeStartElement(qualifiedName: tagName.isEmpty() ? QStringLiteral("row" ) : tagName.toLower()); |
1912 | |
1913 | for (DomProperty *v : m_property) |
1914 | v->write(writer, tagName: u"property"_s ); |
1915 | |
1916 | writer.writeEndElement(); |
1917 | } |
1918 | |
1919 | void DomRow::setElementProperty(const QList<DomProperty *> &a) |
1920 | { |
1921 | m_children |= Property; |
1922 | m_property = a; |
1923 | } |
1924 | |
1925 | DomColumn::~DomColumn() |
1926 | { |
1927 | qDeleteAll(c: m_property); |
1928 | m_property.clear(); |
1929 | } |
1930 | |
1931 | void DomColumn::read(QXmlStreamReader &reader) |
1932 | { |
1933 | while (!reader.hasError()) { |
1934 | switch (reader.readNext()) { |
1935 | case QXmlStreamReader::StartElement : { |
1936 | const auto tag = reader.name(); |
1937 | if (!tag.compare(other: u"property"_s , cs: Qt::CaseInsensitive)) { |
1938 | auto *v = new DomProperty(); |
1939 | v->read(reader); |
1940 | m_property.append(t: v); |
1941 | continue; |
1942 | } |
1943 | reader.raiseError(message: "Unexpected element "_L1 + tag); |
1944 | } |
1945 | break; |
1946 | case QXmlStreamReader::EndElement : |
1947 | return; |
1948 | default : |
1949 | break; |
1950 | } |
1951 | } |
1952 | } |
1953 | |
1954 | void DomColumn::write(QXmlStreamWriter &writer, const QString &tagName) const |
1955 | { |
1956 | writer.writeStartElement(qualifiedName: tagName.isEmpty() ? QStringLiteral("column" ) : tagName.toLower()); |
1957 | |
1958 | for (DomProperty *v : m_property) |
1959 | v->write(writer, tagName: u"property"_s ); |
1960 | |
1961 | writer.writeEndElement(); |
1962 | } |
1963 | |
1964 | void DomColumn::setElementProperty(const QList<DomProperty *> &a) |
1965 | { |
1966 | m_children |= Property; |
1967 | m_property = a; |
1968 | } |
1969 | |
1970 | DomItem::~DomItem() |
1971 | { |
1972 | qDeleteAll(c: m_property); |
1973 | m_property.clear(); |
1974 | qDeleteAll(c: m_item); |
1975 | m_item.clear(); |
1976 | } |
1977 | |
1978 | void DomItem::read(QXmlStreamReader &reader) |
1979 | { |
1980 | const QXmlStreamAttributes &attributes = reader.attributes(); |
1981 | for (const QXmlStreamAttribute &attribute : attributes) { |
1982 | const auto name = attribute.name(); |
1983 | if (name == u"row"_s ) { |
1984 | setAttributeRow(attribute.value().toInt()); |
1985 | continue; |
1986 | } |
1987 | if (name == u"column"_s ) { |
1988 | setAttributeColumn(attribute.value().toInt()); |
1989 | continue; |
1990 | } |
1991 | reader.raiseError(message: "Unexpected attribute "_L1 + name); |
1992 | } |
1993 | |
1994 | while (!reader.hasError()) { |
1995 | switch (reader.readNext()) { |
1996 | case QXmlStreamReader::StartElement : { |
1997 | const auto tag = reader.name(); |
1998 | if (!tag.compare(other: u"property"_s , cs: Qt::CaseInsensitive)) { |
1999 | auto *v = new DomProperty(); |
2000 | v->read(reader); |
2001 | m_property.append(t: v); |
2002 | continue; |
2003 | } |
2004 | if (!tag.compare(other: u"item"_s , cs: Qt::CaseInsensitive)) { |
2005 | auto *v = new DomItem(); |
2006 | v->read(reader); |
2007 | m_item.append(t: v); |
2008 | continue; |
2009 | } |
2010 | reader.raiseError(message: "Unexpected element "_L1 + tag); |
2011 | } |
2012 | break; |
2013 | case QXmlStreamReader::EndElement : |
2014 | return; |
2015 | default : |
2016 | break; |
2017 | } |
2018 | } |
2019 | } |
2020 | |
2021 | void DomItem::write(QXmlStreamWriter &writer, const QString &tagName) const |
2022 | { |
2023 | writer.writeStartElement(qualifiedName: tagName.isEmpty() ? QStringLiteral("item" ) : tagName.toLower()); |
2024 | |
2025 | if (hasAttributeRow()) |
2026 | writer.writeAttribute(qualifiedName: u"row"_s , value: QString::number(attributeRow())); |
2027 | |
2028 | if (hasAttributeColumn()) |
2029 | writer.writeAttribute(qualifiedName: u"column"_s , value: QString::number(attributeColumn())); |
2030 | |
2031 | for (DomProperty *v : m_property) |
2032 | v->write(writer, tagName: u"property"_s ); |
2033 | |
2034 | for (DomItem *v : m_item) |
2035 | v->write(writer, tagName: u"item"_s ); |
2036 | |
2037 | writer.writeEndElement(); |
2038 | } |
2039 | |
2040 | void DomItem::setElementProperty(const QList<DomProperty *> &a) |
2041 | { |
2042 | m_children |= Property; |
2043 | m_property = a; |
2044 | } |
2045 | |
2046 | void DomItem::setElementItem(const QList<DomItem *> &a) |
2047 | { |
2048 | m_children |= Item; |
2049 | m_item = a; |
2050 | } |
2051 | |
2052 | DomWidget::~DomWidget() |
2053 | { |
2054 | m_class.clear(); |
2055 | qDeleteAll(c: m_property); |
2056 | m_property.clear(); |
2057 | qDeleteAll(c: m_attribute); |
2058 | m_attribute.clear(); |
2059 | qDeleteAll(c: m_row); |
2060 | m_row.clear(); |
2061 | qDeleteAll(c: m_column); |
2062 | m_column.clear(); |
2063 | qDeleteAll(c: m_item); |
2064 | m_item.clear(); |
2065 | qDeleteAll(c: m_layout); |
2066 | m_layout.clear(); |
2067 | qDeleteAll(c: m_widget); |
2068 | m_widget.clear(); |
2069 | qDeleteAll(c: m_action); |
2070 | m_action.clear(); |
2071 | qDeleteAll(c: m_actionGroup); |
2072 | m_actionGroup.clear(); |
2073 | qDeleteAll(c: m_addAction); |
2074 | m_addAction.clear(); |
2075 | m_zOrder.clear(); |
2076 | } |
2077 | |
2078 | void DomWidget::read(QXmlStreamReader &reader) |
2079 | { |
2080 | const QXmlStreamAttributes &attributes = reader.attributes(); |
2081 | for (const QXmlStreamAttribute &attribute : attributes) { |
2082 | const auto name = attribute.name(); |
2083 | if (name == u"class"_s ) { |
2084 | setAttributeClass(attribute.value().toString()); |
2085 | continue; |
2086 | } |
2087 | if (name == u"name"_s ) { |
2088 | setAttributeName(attribute.value().toString()); |
2089 | continue; |
2090 | } |
2091 | if (name == u"native"_s ) { |
2092 | setAttributeNative(attribute.value() == u"true"_s ); |
2093 | continue; |
2094 | } |
2095 | reader.raiseError(message: "Unexpected attribute "_L1 + name); |
2096 | } |
2097 | |
2098 | while (!reader.hasError()) { |
2099 | switch (reader.readNext()) { |
2100 | case QXmlStreamReader::StartElement : { |
2101 | const auto tag = reader.name(); |
2102 | if (!tag.compare(other: u"class"_s , cs: Qt::CaseInsensitive)) { |
2103 | m_class.append(t: reader.readElementText()); |
2104 | continue; |
2105 | } |
2106 | if (!tag.compare(other: u"property"_s , cs: Qt::CaseInsensitive)) { |
2107 | auto *v = new DomProperty(); |
2108 | v->read(reader); |
2109 | m_property.append(t: v); |
2110 | continue; |
2111 | } |
2112 | if (!tag.compare(other: u"script"_s , cs: Qt::CaseInsensitive)) { |
2113 | qWarning(msg: "Omitting deprecated element <script>." ); |
2114 | reader.skipCurrentElement(); |
2115 | continue; |
2116 | } |
2117 | if (!tag.compare(other: u"widgetdata"_s , cs: Qt::CaseInsensitive)) { |
2118 | qWarning(msg: "Omitting deprecated element <widgetdata>." ); |
2119 | reader.skipCurrentElement(); |
2120 | continue; |
2121 | } |
2122 | if (!tag.compare(other: u"attribute"_s , cs: Qt::CaseInsensitive)) { |
2123 | auto *v = new DomProperty(); |
2124 | v->read(reader); |
2125 | m_attribute.append(t: v); |
2126 | continue; |
2127 | } |
2128 | if (!tag.compare(other: u"row"_s , cs: Qt::CaseInsensitive)) { |
2129 | auto *v = new DomRow(); |
2130 | v->read(reader); |
2131 | m_row.append(t: v); |
2132 | continue; |
2133 | } |
2134 | if (!tag.compare(other: u"column"_s , cs: Qt::CaseInsensitive)) { |
2135 | auto *v = new DomColumn(); |
2136 | v->read(reader); |
2137 | m_column.append(t: v); |
2138 | continue; |
2139 | } |
2140 | if (!tag.compare(other: u"item"_s , cs: Qt::CaseInsensitive)) { |
2141 | auto *v = new DomItem(); |
2142 | v->read(reader); |
2143 | m_item.append(t: v); |
2144 | continue; |
2145 | } |
2146 | if (!tag.compare(other: u"layout"_s , cs: Qt::CaseInsensitive)) { |
2147 | auto *v = new DomLayout(); |
2148 | v->read(reader); |
2149 | m_layout.append(t: v); |
2150 | continue; |
2151 | } |
2152 | if (!tag.compare(other: u"widget"_s , cs: Qt::CaseInsensitive)) { |
2153 | auto *v = new DomWidget(); |
2154 | v->read(reader); |
2155 | m_widget.append(t: v); |
2156 | continue; |
2157 | } |
2158 | if (!tag.compare(other: u"action"_s , cs: Qt::CaseInsensitive)) { |
2159 | auto *v = new DomAction(); |
2160 | v->read(reader); |
2161 | m_action.append(t: v); |
2162 | continue; |
2163 | } |
2164 | if (!tag.compare(other: u"actiongroup"_s , cs: Qt::CaseInsensitive)) { |
2165 | auto *v = new DomActionGroup(); |
2166 | v->read(reader); |
2167 | m_actionGroup.append(t: v); |
2168 | continue; |
2169 | } |
2170 | if (!tag.compare(other: u"addaction"_s , cs: Qt::CaseInsensitive)) { |
2171 | auto *v = new DomActionRef(); |
2172 | v->read(reader); |
2173 | m_addAction.append(t: v); |
2174 | continue; |
2175 | } |
2176 | if (!tag.compare(other: u"zorder"_s , cs: Qt::CaseInsensitive)) { |
2177 | m_zOrder.append(t: reader.readElementText()); |
2178 | continue; |
2179 | } |
2180 | reader.raiseError(message: "Unexpected element "_L1 + tag); |
2181 | } |
2182 | break; |
2183 | case QXmlStreamReader::EndElement : |
2184 | return; |
2185 | default : |
2186 | break; |
2187 | } |
2188 | } |
2189 | } |
2190 | |
2191 | void DomWidget::write(QXmlStreamWriter &writer, const QString &tagName) const |
2192 | { |
2193 | writer.writeStartElement(qualifiedName: tagName.isEmpty() ? QStringLiteral("widget" ) : tagName.toLower()); |
2194 | |
2195 | if (hasAttributeClass()) |
2196 | writer.writeAttribute(qualifiedName: u"class"_s , value: attributeClass()); |
2197 | |
2198 | if (hasAttributeName()) |
2199 | writer.writeAttribute(qualifiedName: u"name"_s , value: attributeName()); |
2200 | |
2201 | if (hasAttributeNative()) |
2202 | writer.writeAttribute(qualifiedName: u"native"_s , value: (attributeNative() ? u"true"_s : u"false"_s )); |
2203 | |
2204 | for (const QString &v : m_class) |
2205 | writer.writeTextElement(qualifiedName: u"class"_s , text: v); |
2206 | |
2207 | for (DomProperty *v : m_property) |
2208 | v->write(writer, tagName: u"property"_s ); |
2209 | |
2210 | for (DomProperty *v : m_attribute) |
2211 | v->write(writer, tagName: u"attribute"_s ); |
2212 | |
2213 | for (DomRow *v : m_row) |
2214 | v->write(writer, tagName: u"row"_s ); |
2215 | |
2216 | for (DomColumn *v : m_column) |
2217 | v->write(writer, tagName: u"column"_s ); |
2218 | |
2219 | for (DomItem *v : m_item) |
2220 | v->write(writer, tagName: u"item"_s ); |
2221 | |
2222 | for (DomLayout *v : m_layout) |
2223 | v->write(writer, tagName: u"layout"_s ); |
2224 | |
2225 | for (DomWidget *v : m_widget) |
2226 | v->write(writer, tagName: u"widget"_s ); |
2227 | |
2228 | for (DomAction *v : m_action) |
2229 | v->write(writer, tagName: u"action"_s ); |
2230 | |
2231 | for (DomActionGroup *v : m_actionGroup) |
2232 | v->write(writer, tagName: u"actiongroup"_s ); |
2233 | |
2234 | for (DomActionRef *v : m_addAction) |
2235 | v->write(writer, tagName: u"addaction"_s ); |
2236 | |
2237 | for (const QString &v : m_zOrder) |
2238 | writer.writeTextElement(qualifiedName: u"zorder"_s , text: v); |
2239 | |
2240 | writer.writeEndElement(); |
2241 | } |
2242 | |
2243 | void DomWidget::setElementClass(const QStringList &a) |
2244 | { |
2245 | m_children |= Class; |
2246 | m_class = a; |
2247 | } |
2248 | |
2249 | void DomWidget::setElementProperty(const QList<DomProperty *> &a) |
2250 | { |
2251 | m_children |= Property; |
2252 | m_property = a; |
2253 | } |
2254 | |
2255 | void DomWidget::setElementAttribute(const QList<DomProperty *> &a) |
2256 | { |
2257 | m_children |= Attribute; |
2258 | m_attribute = a; |
2259 | } |
2260 | |
2261 | void DomWidget::setElementRow(const QList<DomRow *> &a) |
2262 | { |
2263 | m_children |= Row; |
2264 | m_row = a; |
2265 | } |
2266 | |
2267 | void DomWidget::setElementColumn(const QList<DomColumn *> &a) |
2268 | { |
2269 | m_children |= Column; |
2270 | m_column = a; |
2271 | } |
2272 | |
2273 | void DomWidget::setElementItem(const QList<DomItem *> &a) |
2274 | { |
2275 | m_children |= Item; |
2276 | m_item = a; |
2277 | } |
2278 | |
2279 | void DomWidget::setElementLayout(const QList<DomLayout *> &a) |
2280 | { |
2281 | m_children |= Layout; |
2282 | m_layout = a; |
2283 | } |
2284 | |
2285 | void DomWidget::setElementWidget(const QList<DomWidget *> &a) |
2286 | { |
2287 | m_children |= Widget; |
2288 | m_widget = a; |
2289 | } |
2290 | |
2291 | void DomWidget::setElementAction(const QList<DomAction *> &a) |
2292 | { |
2293 | m_children |= Action; |
2294 | m_action = a; |
2295 | } |
2296 | |
2297 | void DomWidget::setElementActionGroup(const QList<DomActionGroup *> &a) |
2298 | { |
2299 | m_children |= ActionGroup; |
2300 | m_actionGroup = a; |
2301 | } |
2302 | |
2303 | void DomWidget::setElementAddAction(const QList<DomActionRef *> &a) |
2304 | { |
2305 | m_children |= AddAction; |
2306 | m_addAction = a; |
2307 | } |
2308 | |
2309 | void DomWidget::setElementZOrder(const QStringList &a) |
2310 | { |
2311 | m_children |= ZOrder; |
2312 | m_zOrder = a; |
2313 | } |
2314 | |
2315 | DomSpacer::~DomSpacer() |
2316 | { |
2317 | qDeleteAll(c: m_property); |
2318 | m_property.clear(); |
2319 | } |
2320 | |
2321 | void DomSpacer::read(QXmlStreamReader &reader) |
2322 | { |
2323 | const QXmlStreamAttributes &attributes = reader.attributes(); |
2324 | for (const QXmlStreamAttribute &attribute : attributes) { |
2325 | const auto name = attribute.name(); |
2326 | if (name == u"name"_s ) { |
2327 | setAttributeName(attribute.value().toString()); |
2328 | continue; |
2329 | } |
2330 | reader.raiseError(message: "Unexpected attribute "_L1 + name); |
2331 | } |
2332 | |
2333 | while (!reader.hasError()) { |
2334 | switch (reader.readNext()) { |
2335 | case QXmlStreamReader::StartElement : { |
2336 | const auto tag = reader.name(); |
2337 | if (!tag.compare(other: u"property"_s , cs: Qt::CaseInsensitive)) { |
2338 | auto *v = new DomProperty(); |
2339 | v->read(reader); |
2340 | m_property.append(t: v); |
2341 | continue; |
2342 | } |
2343 | reader.raiseError(message: "Unexpected element "_L1 + tag); |
2344 | } |
2345 | break; |
2346 | case QXmlStreamReader::EndElement : |
2347 | return; |
2348 | default : |
2349 | break; |
2350 | } |
2351 | } |
2352 | } |
2353 | |
2354 | void DomSpacer::write(QXmlStreamWriter &writer, const QString &tagName) const |
2355 | { |
2356 | writer.writeStartElement(qualifiedName: tagName.isEmpty() ? QStringLiteral("spacer" ) : tagName.toLower()); |
2357 | |
2358 | if (hasAttributeName()) |
2359 | writer.writeAttribute(qualifiedName: u"name"_s , value: attributeName()); |
2360 | |
2361 | for (DomProperty *v : m_property) |
2362 | v->write(writer, tagName: u"property"_s ); |
2363 | |
2364 | writer.writeEndElement(); |
2365 | } |
2366 | |
2367 | void DomSpacer::setElementProperty(const QList<DomProperty *> &a) |
2368 | { |
2369 | m_children |= Property; |
2370 | m_property = a; |
2371 | } |
2372 | |
2373 | DomColor::~DomColor() = default; |
2374 | |
2375 | void DomColor::read(QXmlStreamReader &reader) |
2376 | { |
2377 | const QXmlStreamAttributes &attributes = reader.attributes(); |
2378 | for (const QXmlStreamAttribute &attribute : attributes) { |
2379 | const auto name = attribute.name(); |
2380 | if (name == u"alpha"_s ) { |
2381 | setAttributeAlpha(attribute.value().toInt()); |
2382 | continue; |
2383 | } |
2384 | reader.raiseError(message: "Unexpected attribute "_L1 + name); |
2385 | } |
2386 | |
2387 | while (!reader.hasError()) { |
2388 | switch (reader.readNext()) { |
2389 | case QXmlStreamReader::StartElement : { |
2390 | const auto tag = reader.name(); |
2391 | if (!tag.compare(other: u"red"_s , cs: Qt::CaseInsensitive)) { |
2392 | setElementRed(reader.readElementText().toInt()); |
2393 | continue; |
2394 | } |
2395 | if (!tag.compare(other: u"green"_s , cs: Qt::CaseInsensitive)) { |
2396 | setElementGreen(reader.readElementText().toInt()); |
2397 | continue; |
2398 | } |
2399 | if (!tag.compare(other: u"blue"_s , cs: Qt::CaseInsensitive)) { |
2400 | setElementBlue(reader.readElementText().toInt()); |
2401 | continue; |
2402 | } |
2403 | reader.raiseError(message: "Unexpected element "_L1 + tag); |
2404 | } |
2405 | break; |
2406 | case QXmlStreamReader::EndElement : |
2407 | return; |
2408 | default : |
2409 | break; |
2410 | } |
2411 | } |
2412 | } |
2413 | |
2414 | void DomColor::write(QXmlStreamWriter &writer, const QString &tagName) const |
2415 | { |
2416 | writer.writeStartElement(qualifiedName: tagName.isEmpty() ? QStringLiteral("color" ) : tagName.toLower()); |
2417 | |
2418 | if (hasAttributeAlpha()) |
2419 | writer.writeAttribute(qualifiedName: u"alpha"_s , value: QString::number(attributeAlpha())); |
2420 | |
2421 | if (m_children & Red) |
2422 | writer.writeTextElement(qualifiedName: u"red"_s , text: QString::number(m_red)); |
2423 | |
2424 | if (m_children & Green) |
2425 | writer.writeTextElement(qualifiedName: u"green"_s , text: QString::number(m_green)); |
2426 | |
2427 | if (m_children & Blue) |
2428 | writer.writeTextElement(qualifiedName: u"blue"_s , text: QString::number(m_blue)); |
2429 | |
2430 | writer.writeEndElement(); |
2431 | } |
2432 | |
2433 | void DomColor::setElementRed(int a) |
2434 | { |
2435 | m_children |= Red; |
2436 | m_red = a; |
2437 | } |
2438 | |
2439 | void DomColor::setElementGreen(int a) |
2440 | { |
2441 | m_children |= Green; |
2442 | m_green = a; |
2443 | } |
2444 | |
2445 | void DomColor::setElementBlue(int a) |
2446 | { |
2447 | m_children |= Blue; |
2448 | m_blue = a; |
2449 | } |
2450 | |
2451 | void DomColor::clearElementRed() |
2452 | { |
2453 | m_children &= ~Red; |
2454 | } |
2455 | |
2456 | void DomColor::clearElementGreen() |
2457 | { |
2458 | m_children &= ~Green; |
2459 | } |
2460 | |
2461 | void DomColor::clearElementBlue() |
2462 | { |
2463 | m_children &= ~Blue; |
2464 | } |
2465 | |
2466 | DomGradientStop::~DomGradientStop() |
2467 | { |
2468 | delete m_color; |
2469 | } |
2470 | |
2471 | void DomGradientStop::read(QXmlStreamReader &reader) |
2472 | { |
2473 | const QXmlStreamAttributes &attributes = reader.attributes(); |
2474 | for (const QXmlStreamAttribute &attribute : attributes) { |
2475 | const auto name = attribute.name(); |
2476 | if (name == u"position"_s ) { |
2477 | setAttributePosition(attribute.value().toDouble()); |
2478 | continue; |
2479 | } |
2480 | reader.raiseError(message: "Unexpected attribute "_L1 + name); |
2481 | } |
2482 | |
2483 | while (!reader.hasError()) { |
2484 | switch (reader.readNext()) { |
2485 | case QXmlStreamReader::StartElement : { |
2486 | const auto tag = reader.name(); |
2487 | if (!tag.compare(other: u"color"_s , cs: Qt::CaseInsensitive)) { |
2488 | auto *v = new DomColor(); |
2489 | v->read(reader); |
2490 | setElementColor(v); |
2491 | continue; |
2492 | } |
2493 | reader.raiseError(message: "Unexpected element "_L1 + tag); |
2494 | } |
2495 | break; |
2496 | case QXmlStreamReader::EndElement : |
2497 | return; |
2498 | default : |
2499 | break; |
2500 | } |
2501 | } |
2502 | } |
2503 | |
2504 | void DomGradientStop::write(QXmlStreamWriter &writer, const QString &tagName) const |
2505 | { |
2506 | writer.writeStartElement(qualifiedName: tagName.isEmpty() ? QStringLiteral("gradientstop" ) : tagName.toLower()); |
2507 | |
2508 | if (hasAttributePosition()) |
2509 | writer.writeAttribute(qualifiedName: u"position"_s , value: QString::number(attributePosition(), format: 'f', precision: 15)); |
2510 | |
2511 | if (m_children & Color) |
2512 | m_color->write(writer, tagName: u"color"_s ); |
2513 | |
2514 | writer.writeEndElement(); |
2515 | } |
2516 | |
2517 | DomColor *DomGradientStop::takeElementColor() |
2518 | { |
2519 | DomColor *a = m_color; |
2520 | m_color = nullptr; |
2521 | m_children ^= Color; |
2522 | return a; |
2523 | } |
2524 | |
2525 | void DomGradientStop::setElementColor(DomColor *a) |
2526 | { |
2527 | delete m_color; |
2528 | m_children |= Color; |
2529 | m_color = a; |
2530 | } |
2531 | |
2532 | void DomGradientStop::clearElementColor() |
2533 | { |
2534 | delete m_color; |
2535 | m_color = nullptr; |
2536 | m_children &= ~Color; |
2537 | } |
2538 | |
2539 | DomGradient::~DomGradient() |
2540 | { |
2541 | qDeleteAll(c: m_gradientStop); |
2542 | m_gradientStop.clear(); |
2543 | } |
2544 | |
2545 | void DomGradient::read(QXmlStreamReader &reader) |
2546 | { |
2547 | const QXmlStreamAttributes &attributes = reader.attributes(); |
2548 | for (const QXmlStreamAttribute &attribute : attributes) { |
2549 | const auto name = attribute.name(); |
2550 | if (name == u"startx"_s ) { |
2551 | setAttributeStartX(attribute.value().toDouble()); |
2552 | continue; |
2553 | } |
2554 | if (name == u"starty"_s ) { |
2555 | setAttributeStartY(attribute.value().toDouble()); |
2556 | continue; |
2557 | } |
2558 | if (name == u"endx"_s ) { |
2559 | setAttributeEndX(attribute.value().toDouble()); |
2560 | continue; |
2561 | } |
2562 | if (name == u"endy"_s ) { |
2563 | setAttributeEndY(attribute.value().toDouble()); |
2564 | continue; |
2565 | } |
2566 | if (name == u"centralx"_s ) { |
2567 | setAttributeCentralX(attribute.value().toDouble()); |
2568 | continue; |
2569 | } |
2570 | if (name == u"centraly"_s ) { |
2571 | setAttributeCentralY(attribute.value().toDouble()); |
2572 | continue; |
2573 | } |
2574 | if (name == u"focalx"_s ) { |
2575 | setAttributeFocalX(attribute.value().toDouble()); |
2576 | continue; |
2577 | } |
2578 | if (name == u"focaly"_s ) { |
2579 | setAttributeFocalY(attribute.value().toDouble()); |
2580 | continue; |
2581 | } |
2582 | if (name == u"radius"_s ) { |
2583 | setAttributeRadius(attribute.value().toDouble()); |
2584 | continue; |
2585 | } |
2586 | if (name == u"angle"_s ) { |
2587 | setAttributeAngle(attribute.value().toDouble()); |
2588 | continue; |
2589 | } |
2590 | if (name == u"type"_s ) { |
2591 | setAttributeType(attribute.value().toString()); |
2592 | continue; |
2593 | } |
2594 | if (name == u"spread"_s ) { |
2595 | setAttributeSpread(attribute.value().toString()); |
2596 | continue; |
2597 | } |
2598 | if (name == u"coordinatemode"_s ) { |
2599 | setAttributeCoordinateMode(attribute.value().toString()); |
2600 | continue; |
2601 | } |
2602 | reader.raiseError(message: "Unexpected attribute "_L1 + name); |
2603 | } |
2604 | |
2605 | while (!reader.hasError()) { |
2606 | switch (reader.readNext()) { |
2607 | case QXmlStreamReader::StartElement : { |
2608 | const auto tag = reader.name(); |
2609 | if (!tag.compare(other: u"gradientstop"_s , cs: Qt::CaseInsensitive)) { |
2610 | auto *v = new DomGradientStop(); |
2611 | v->read(reader); |
2612 | m_gradientStop.append(t: v); |
2613 | continue; |
2614 | } |
2615 | reader.raiseError(message: "Unexpected element "_L1 + tag); |
2616 | } |
2617 | break; |
2618 | case QXmlStreamReader::EndElement : |
2619 | return; |
2620 | default : |
2621 | break; |
2622 | } |
2623 | } |
2624 | } |
2625 | |
2626 | void DomGradient::write(QXmlStreamWriter &writer, const QString &tagName) const |
2627 | { |
2628 | writer.writeStartElement(qualifiedName: tagName.isEmpty() ? QStringLiteral("gradient" ) : tagName.toLower()); |
2629 | |
2630 | if (hasAttributeStartX()) |
2631 | writer.writeAttribute(qualifiedName: u"startx"_s , value: QString::number(attributeStartX(), format: 'f', precision: 15)); |
2632 | |
2633 | if (hasAttributeStartY()) |
2634 | writer.writeAttribute(qualifiedName: u"starty"_s , value: QString::number(attributeStartY(), format: 'f', precision: 15)); |
2635 | |
2636 | if (hasAttributeEndX()) |
2637 | writer.writeAttribute(qualifiedName: u"endx"_s , value: QString::number(attributeEndX(), format: 'f', precision: 15)); |
2638 | |
2639 | if (hasAttributeEndY()) |
2640 | writer.writeAttribute(qualifiedName: u"endy"_s , value: QString::number(attributeEndY(), format: 'f', precision: 15)); |
2641 | |
2642 | if (hasAttributeCentralX()) |
2643 | writer.writeAttribute(qualifiedName: u"centralx"_s , value: QString::number(attributeCentralX(), format: 'f', precision: 15)); |
2644 | |
2645 | if (hasAttributeCentralY()) |
2646 | writer.writeAttribute(qualifiedName: u"centraly"_s , value: QString::number(attributeCentralY(), format: 'f', precision: 15)); |
2647 | |
2648 | if (hasAttributeFocalX()) |
2649 | writer.writeAttribute(qualifiedName: u"focalx"_s , value: QString::number(attributeFocalX(), format: 'f', precision: 15)); |
2650 | |
2651 | if (hasAttributeFocalY()) |
2652 | writer.writeAttribute(qualifiedName: u"focaly"_s , value: QString::number(attributeFocalY(), format: 'f', precision: 15)); |
2653 | |
2654 | if (hasAttributeRadius()) |
2655 | writer.writeAttribute(qualifiedName: u"radius"_s , value: QString::number(attributeRadius(), format: 'f', precision: 15)); |
2656 | |
2657 | if (hasAttributeAngle()) |
2658 | writer.writeAttribute(qualifiedName: u"angle"_s , value: QString::number(attributeAngle(), format: 'f', precision: 15)); |
2659 | |
2660 | if (hasAttributeType()) |
2661 | writer.writeAttribute(qualifiedName: u"type"_s , value: attributeType()); |
2662 | |
2663 | if (hasAttributeSpread()) |
2664 | writer.writeAttribute(qualifiedName: u"spread"_s , value: attributeSpread()); |
2665 | |
2666 | if (hasAttributeCoordinateMode()) |
2667 | writer.writeAttribute(qualifiedName: u"coordinatemode"_s , value: attributeCoordinateMode()); |
2668 | |
2669 | for (DomGradientStop *v : m_gradientStop) |
2670 | v->write(writer, tagName: u"gradientstop"_s ); |
2671 | |
2672 | writer.writeEndElement(); |
2673 | } |
2674 | |
2675 | void DomGradient::setElementGradientStop(const QList<DomGradientStop *> &a) |
2676 | { |
2677 | m_children |= GradientStop; |
2678 | m_gradientStop = a; |
2679 | } |
2680 | |
2681 | DomBrush::~DomBrush() |
2682 | { |
2683 | delete m_color; |
2684 | delete m_texture; |
2685 | delete m_gradient; |
2686 | } |
2687 | |
2688 | void DomBrush::clear() |
2689 | { |
2690 | delete m_color; |
2691 | delete m_texture; |
2692 | delete m_gradient; |
2693 | |
2694 | m_kind = Unknown; |
2695 | |
2696 | m_color = nullptr; |
2697 | m_texture = nullptr; |
2698 | m_gradient = nullptr; |
2699 | } |
2700 | |
2701 | void DomBrush::read(QXmlStreamReader &reader) |
2702 | { |
2703 | const QXmlStreamAttributes &attributes = reader.attributes(); |
2704 | for (const QXmlStreamAttribute &attribute : attributes) { |
2705 | const auto name = attribute.name(); |
2706 | if (name == u"brushstyle"_s ) { |
2707 | setAttributeBrushStyle(attribute.value().toString()); |
2708 | continue; |
2709 | } |
2710 | reader.raiseError(message: "Unexpected attribute "_L1 + name); |
2711 | } |
2712 | |
2713 | while (!reader.hasError()) { |
2714 | switch (reader.readNext()) { |
2715 | case QXmlStreamReader::StartElement : { |
2716 | const auto tag = reader.name(); |
2717 | if (!tag.compare(other: u"color"_s , cs: Qt::CaseInsensitive)) { |
2718 | auto *v = new DomColor(); |
2719 | v->read(reader); |
2720 | setElementColor(v); |
2721 | continue; |
2722 | } |
2723 | if (!tag.compare(other: u"texture"_s , cs: Qt::CaseInsensitive)) { |
2724 | auto *v = new DomProperty(); |
2725 | v->read(reader); |
2726 | setElementTexture(v); |
2727 | continue; |
2728 | } |
2729 | if (!tag.compare(other: u"gradient"_s , cs: Qt::CaseInsensitive)) { |
2730 | auto *v = new DomGradient(); |
2731 | v->read(reader); |
2732 | setElementGradient(v); |
2733 | continue; |
2734 | } |
2735 | reader.raiseError(message: "Unexpected element "_L1 + tag); |
2736 | } |
2737 | break; |
2738 | case QXmlStreamReader::EndElement : |
2739 | return; |
2740 | default : |
2741 | break; |
2742 | } |
2743 | } |
2744 | } |
2745 | |
2746 | void DomBrush::write(QXmlStreamWriter &writer, const QString &tagName) const |
2747 | { |
2748 | writer.writeStartElement(qualifiedName: tagName.isEmpty() ? QStringLiteral("brush" ) : tagName.toLower()); |
2749 | |
2750 | if (hasAttributeBrushStyle()) |
2751 | writer.writeAttribute(qualifiedName: u"brushstyle"_s , value: attributeBrushStyle()); |
2752 | |
2753 | switch (kind()) { |
2754 | case Color: |
2755 | if (m_color != nullptr) |
2756 | m_color->write(writer, tagName: u"color"_s ); |
2757 | break; |
2758 | |
2759 | case Texture: |
2760 | if (m_texture != nullptr) |
2761 | m_texture->write(writer, tagName: u"texture"_s ); |
2762 | break; |
2763 | |
2764 | case Gradient: |
2765 | if (m_gradient != nullptr) |
2766 | m_gradient->write(writer, tagName: u"gradient"_s ); |
2767 | break; |
2768 | |
2769 | default: |
2770 | break; |
2771 | } |
2772 | writer.writeEndElement(); |
2773 | } |
2774 | |
2775 | DomColor *DomBrush::takeElementColor() |
2776 | { |
2777 | DomColor *a = m_color; |
2778 | m_color = nullptr; |
2779 | return a; |
2780 | } |
2781 | |
2782 | void DomBrush::setElementColor(DomColor *a) |
2783 | { |
2784 | clear(); |
2785 | m_kind = Color; |
2786 | m_color = a; |
2787 | } |
2788 | |
2789 | DomProperty *DomBrush::takeElementTexture() |
2790 | { |
2791 | DomProperty *a = m_texture; |
2792 | m_texture = nullptr; |
2793 | return a; |
2794 | } |
2795 | |
2796 | void DomBrush::setElementTexture(DomProperty *a) |
2797 | { |
2798 | clear(); |
2799 | m_kind = Texture; |
2800 | m_texture = a; |
2801 | } |
2802 | |
2803 | DomGradient *DomBrush::takeElementGradient() |
2804 | { |
2805 | DomGradient *a = m_gradient; |
2806 | m_gradient = nullptr; |
2807 | return a; |
2808 | } |
2809 | |
2810 | void DomBrush::setElementGradient(DomGradient *a) |
2811 | { |
2812 | clear(); |
2813 | m_kind = Gradient; |
2814 | m_gradient = a; |
2815 | } |
2816 | |
2817 | DomColorRole::~DomColorRole() |
2818 | { |
2819 | delete m_brush; |
2820 | } |
2821 | |
2822 | void DomColorRole::read(QXmlStreamReader &reader) |
2823 | { |
2824 | const QXmlStreamAttributes &attributes = reader.attributes(); |
2825 | for (const QXmlStreamAttribute &attribute : attributes) { |
2826 | const auto name = attribute.name(); |
2827 | if (name == u"role"_s ) { |
2828 | setAttributeRole(attribute.value().toString()); |
2829 | continue; |
2830 | } |
2831 | reader.raiseError(message: "Unexpected attribute "_L1 + name); |
2832 | } |
2833 | |
2834 | while (!reader.hasError()) { |
2835 | switch (reader.readNext()) { |
2836 | case QXmlStreamReader::StartElement : { |
2837 | const auto tag = reader.name(); |
2838 | if (!tag.compare(other: u"brush"_s , cs: Qt::CaseInsensitive)) { |
2839 | auto *v = new DomBrush(); |
2840 | v->read(reader); |
2841 | setElementBrush(v); |
2842 | continue; |
2843 | } |
2844 | reader.raiseError(message: "Unexpected element "_L1 + tag); |
2845 | } |
2846 | break; |
2847 | case QXmlStreamReader::EndElement : |
2848 | return; |
2849 | default : |
2850 | break; |
2851 | } |
2852 | } |
2853 | } |
2854 | |
2855 | void DomColorRole::write(QXmlStreamWriter &writer, const QString &tagName) const |
2856 | { |
2857 | writer.writeStartElement(qualifiedName: tagName.isEmpty() ? QStringLiteral("colorrole" ) : tagName.toLower()); |
2858 | |
2859 | if (hasAttributeRole()) |
2860 | writer.writeAttribute(qualifiedName: u"role"_s , value: attributeRole()); |
2861 | |
2862 | if (m_children & Brush) |
2863 | m_brush->write(writer, tagName: u"brush"_s ); |
2864 | |
2865 | writer.writeEndElement(); |
2866 | } |
2867 | |
2868 | DomBrush *DomColorRole::takeElementBrush() |
2869 | { |
2870 | DomBrush *a = m_brush; |
2871 | m_brush = nullptr; |
2872 | m_children ^= Brush; |
2873 | return a; |
2874 | } |
2875 | |
2876 | void DomColorRole::setElementBrush(DomBrush *a) |
2877 | { |
2878 | delete m_brush; |
2879 | m_children |= Brush; |
2880 | m_brush = a; |
2881 | } |
2882 | |
2883 | void DomColorRole::clearElementBrush() |
2884 | { |
2885 | delete m_brush; |
2886 | m_brush = nullptr; |
2887 | m_children &= ~Brush; |
2888 | } |
2889 | |
2890 | DomColorGroup::~DomColorGroup() |
2891 | { |
2892 | qDeleteAll(c: m_colorRole); |
2893 | m_colorRole.clear(); |
2894 | qDeleteAll(c: m_color); |
2895 | m_color.clear(); |
2896 | } |
2897 | |
2898 | void DomColorGroup::read(QXmlStreamReader &reader) |
2899 | { |
2900 | while (!reader.hasError()) { |
2901 | switch (reader.readNext()) { |
2902 | case QXmlStreamReader::StartElement : { |
2903 | const auto tag = reader.name(); |
2904 | if (!tag.compare(other: u"colorrole"_s , cs: Qt::CaseInsensitive)) { |
2905 | auto *v = new DomColorRole(); |
2906 | v->read(reader); |
2907 | m_colorRole.append(t: v); |
2908 | continue; |
2909 | } |
2910 | if (!tag.compare(other: u"color"_s , cs: Qt::CaseInsensitive)) { |
2911 | auto *v = new DomColor(); |
2912 | v->read(reader); |
2913 | m_color.append(t: v); |
2914 | continue; |
2915 | } |
2916 | reader.raiseError(message: "Unexpected element "_L1 + tag); |
2917 | } |
2918 | break; |
2919 | case QXmlStreamReader::EndElement : |
2920 | return; |
2921 | default : |
2922 | break; |
2923 | } |
2924 | } |
2925 | } |
2926 | |
2927 | void DomColorGroup::write(QXmlStreamWriter &writer, const QString &tagName) const |
2928 | { |
2929 | writer.writeStartElement(qualifiedName: tagName.isEmpty() ? QStringLiteral("colorgroup" ) : tagName.toLower()); |
2930 | |
2931 | for (DomColorRole *v : m_colorRole) |
2932 | v->write(writer, tagName: u"colorrole"_s ); |
2933 | |
2934 | for (DomColor *v : m_color) |
2935 | v->write(writer, tagName: u"color"_s ); |
2936 | |
2937 | writer.writeEndElement(); |
2938 | } |
2939 | |
2940 | void DomColorGroup::setElementColorRole(const QList<DomColorRole *> &a) |
2941 | { |
2942 | m_children |= ColorRole; |
2943 | m_colorRole = a; |
2944 | } |
2945 | |
2946 | void DomColorGroup::setElementColor(const QList<DomColor *> &a) |
2947 | { |
2948 | m_children |= Color; |
2949 | m_color = a; |
2950 | } |
2951 | |
2952 | DomPalette::~DomPalette() |
2953 | { |
2954 | delete m_active; |
2955 | delete m_inactive; |
2956 | delete m_disabled; |
2957 | } |
2958 | |
2959 | void DomPalette::read(QXmlStreamReader &reader) |
2960 | { |
2961 | while (!reader.hasError()) { |
2962 | switch (reader.readNext()) { |
2963 | case QXmlStreamReader::StartElement : { |
2964 | const auto tag = reader.name(); |
2965 | if (!tag.compare(other: u"active"_s , cs: Qt::CaseInsensitive)) { |
2966 | auto *v = new DomColorGroup(); |
2967 | v->read(reader); |
2968 | setElementActive(v); |
2969 | continue; |
2970 | } |
2971 | if (!tag.compare(other: u"inactive"_s , cs: Qt::CaseInsensitive)) { |
2972 | auto *v = new DomColorGroup(); |
2973 | v->read(reader); |
2974 | setElementInactive(v); |
2975 | continue; |
2976 | } |
2977 | if (!tag.compare(other: u"disabled"_s , cs: Qt::CaseInsensitive)) { |
2978 | auto *v = new DomColorGroup(); |
2979 | v->read(reader); |
2980 | setElementDisabled(v); |
2981 | continue; |
2982 | } |
2983 | reader.raiseError(message: "Unexpected element "_L1 + tag); |
2984 | } |
2985 | break; |
2986 | case QXmlStreamReader::EndElement : |
2987 | return; |
2988 | default : |
2989 | break; |
2990 | } |
2991 | } |
2992 | } |
2993 | |
2994 | void DomPalette::write(QXmlStreamWriter &writer, const QString &tagName) const |
2995 | { |
2996 | writer.writeStartElement(qualifiedName: tagName.isEmpty() ? QStringLiteral("palette" ) : tagName.toLower()); |
2997 | |
2998 | if (m_children & Active) |
2999 | m_active->write(writer, tagName: u"active"_s ); |
3000 | |
3001 | if (m_children & Inactive) |
3002 | m_inactive->write(writer, tagName: u"inactive"_s ); |
3003 | |
3004 | if (m_children & Disabled) |
3005 | m_disabled->write(writer, tagName: u"disabled"_s ); |
3006 | |
3007 | writer.writeEndElement(); |
3008 | } |
3009 | |
3010 | DomColorGroup *DomPalette::takeElementActive() |
3011 | { |
3012 | DomColorGroup *a = m_active; |
3013 | m_active = nullptr; |
3014 | m_children ^= Active; |
3015 | return a; |
3016 | } |
3017 | |
3018 | void DomPalette::setElementActive(DomColorGroup *a) |
3019 | { |
3020 | delete m_active; |
3021 | m_children |= Active; |
3022 | m_active = a; |
3023 | } |
3024 | |
3025 | DomColorGroup *DomPalette::takeElementInactive() |
3026 | { |
3027 | DomColorGroup *a = m_inactive; |
3028 | m_inactive = nullptr; |
3029 | m_children ^= Inactive; |
3030 | return a; |
3031 | } |
3032 | |
3033 | void DomPalette::setElementInactive(DomColorGroup *a) |
3034 | { |
3035 | delete m_inactive; |
3036 | m_children |= Inactive; |
3037 | m_inactive = a; |
3038 | } |
3039 | |
3040 | DomColorGroup *DomPalette::takeElementDisabled() |
3041 | { |
3042 | DomColorGroup *a = m_disabled; |
3043 | m_disabled = nullptr; |
3044 | m_children ^= Disabled; |
3045 | return a; |
3046 | } |
3047 | |
3048 | void DomPalette::setElementDisabled(DomColorGroup *a) |
3049 | { |
3050 | delete m_disabled; |
3051 | m_children |= Disabled; |
3052 | m_disabled = a; |
3053 | } |
3054 | |
3055 | void DomPalette::clearElementActive() |
3056 | { |
3057 | delete m_active; |
3058 | m_active = nullptr; |
3059 | m_children &= ~Active; |
3060 | } |
3061 | |
3062 | void DomPalette::clearElementInactive() |
3063 | { |
3064 | delete m_inactive; |
3065 | m_inactive = nullptr; |
3066 | m_children &= ~Inactive; |
3067 | } |
3068 | |
3069 | void DomPalette::clearElementDisabled() |
3070 | { |
3071 | delete m_disabled; |
3072 | m_disabled = nullptr; |
3073 | m_children &= ~Disabled; |
3074 | } |
3075 | |
3076 | DomFont::~DomFont() = default; |
3077 | |
3078 | void DomFont::read(QXmlStreamReader &reader) |
3079 | { |
3080 | while (!reader.hasError()) { |
3081 | switch (reader.readNext()) { |
3082 | case QXmlStreamReader::StartElement : { |
3083 | const auto tag = reader.name(); |
3084 | if (!tag.compare(other: u"family"_s , cs: Qt::CaseInsensitive)) { |
3085 | setElementFamily(reader.readElementText()); |
3086 | continue; |
3087 | } |
3088 | if (!tag.compare(other: u"pointsize"_s , cs: Qt::CaseInsensitive)) { |
3089 | setElementPointSize(reader.readElementText().toInt()); |
3090 | continue; |
3091 | } |
3092 | if (!tag.compare(other: u"weight"_s , cs: Qt::CaseInsensitive)) { |
3093 | setElementWeight(reader.readElementText().toInt()); |
3094 | continue; |
3095 | } |
3096 | if (!tag.compare(other: u"italic"_s , cs: Qt::CaseInsensitive)) { |
3097 | setElementItalic(reader.readElementText() == u"true"_s ); |
3098 | continue; |
3099 | } |
3100 | if (!tag.compare(other: u"bold"_s , cs: Qt::CaseInsensitive)) { |
3101 | setElementBold(reader.readElementText() == u"true"_s ); |
3102 | continue; |
3103 | } |
3104 | if (!tag.compare(other: u"underline"_s , cs: Qt::CaseInsensitive)) { |
3105 | setElementUnderline(reader.readElementText() == u"true"_s ); |
3106 | continue; |
3107 | } |
3108 | if (!tag.compare(other: u"strikeout"_s , cs: Qt::CaseInsensitive)) { |
3109 | setElementStrikeOut(reader.readElementText() == u"true"_s ); |
3110 | continue; |
3111 | } |
3112 | if (!tag.compare(other: u"antialiasing"_s , cs: Qt::CaseInsensitive)) { |
3113 | setElementAntialiasing(reader.readElementText() == u"true"_s ); |
3114 | continue; |
3115 | } |
3116 | if (!tag.compare(other: u"stylestrategy"_s , cs: Qt::CaseInsensitive)) { |
3117 | setElementStyleStrategy(reader.readElementText()); |
3118 | continue; |
3119 | } |
3120 | if (!tag.compare(other: u"kerning"_s , cs: Qt::CaseInsensitive)) { |
3121 | setElementKerning(reader.readElementText() == u"true"_s ); |
3122 | continue; |
3123 | } |
3124 | if (!tag.compare(other: u"hintingpreference"_s , cs: Qt::CaseInsensitive)) { |
3125 | setElementHintingPreference(reader.readElementText()); |
3126 | continue; |
3127 | } |
3128 | if (!tag.compare(other: u"fontweight"_s , cs: Qt::CaseInsensitive)) { |
3129 | setElementFontWeight(reader.readElementText()); |
3130 | continue; |
3131 | } |
3132 | reader.raiseError(message: "Unexpected element "_L1 + tag); |
3133 | } |
3134 | break; |
3135 | case QXmlStreamReader::EndElement : |
3136 | return; |
3137 | default : |
3138 | break; |
3139 | } |
3140 | } |
3141 | } |
3142 | |
3143 | void DomFont::write(QXmlStreamWriter &writer, const QString &tagName) const |
3144 | { |
3145 | writer.writeStartElement(qualifiedName: tagName.isEmpty() ? QStringLiteral("font" ) : tagName.toLower()); |
3146 | |
3147 | if (m_children & Family) |
3148 | writer.writeTextElement(qualifiedName: u"family"_s , text: m_family); |
3149 | |
3150 | if (m_children & PointSize) |
3151 | writer.writeTextElement(qualifiedName: u"pointsize"_s , text: QString::number(m_pointSize)); |
3152 | |
3153 | if (m_children & Weight) |
3154 | writer.writeTextElement(qualifiedName: u"weight"_s , text: QString::number(m_weight)); |
3155 | |
3156 | if (m_children & Italic) |
3157 | writer.writeTextElement(qualifiedName: u"italic"_s , text: (m_italic ? u"true"_s : u"false"_s )); |
3158 | |
3159 | if (m_children & Bold) |
3160 | writer.writeTextElement(qualifiedName: u"bold"_s , text: (m_bold ? u"true"_s : u"false"_s )); |
3161 | |
3162 | if (m_children & Underline) |
3163 | writer.writeTextElement(qualifiedName: u"underline"_s , text: (m_underline ? u"true"_s : u"false"_s )); |
3164 | |
3165 | if (m_children & StrikeOut) |
3166 | writer.writeTextElement(qualifiedName: u"strikeout"_s , text: (m_strikeOut ? u"true"_s : u"false"_s )); |
3167 | |
3168 | if (m_children & Antialiasing) |
3169 | writer.writeTextElement(qualifiedName: u"antialiasing"_s , text: (m_antialiasing ? u"true"_s : u"false"_s )); |
3170 | |
3171 | if (m_children & StyleStrategy) |
3172 | writer.writeTextElement(qualifiedName: u"stylestrategy"_s , text: m_styleStrategy); |
3173 | |
3174 | if (m_children & Kerning) |
3175 | writer.writeTextElement(qualifiedName: u"kerning"_s , text: (m_kerning ? u"true"_s : u"false"_s )); |
3176 | |
3177 | if (m_children & HintingPreference) |
3178 | writer.writeTextElement(qualifiedName: u"hintingpreference"_s , text: m_hintingPreference); |
3179 | |
3180 | if (m_children & FontWeight) |
3181 | writer.writeTextElement(qualifiedName: u"fontweight"_s , text: m_fontWeight); |
3182 | |
3183 | writer.writeEndElement(); |
3184 | } |
3185 | |
3186 | void DomFont::setElementFamily(const QString &a) |
3187 | { |
3188 | m_children |= Family; |
3189 | m_family = a; |
3190 | } |
3191 | |
3192 | void DomFont::setElementPointSize(int a) |
3193 | { |
3194 | m_children |= PointSize; |
3195 | m_pointSize = a; |
3196 | } |
3197 | |
3198 | void DomFont::setElementWeight(int a) |
3199 | { |
3200 | m_children |= Weight; |
3201 | m_weight = a; |
3202 | } |
3203 | |
3204 | void DomFont::setElementItalic(bool a) |
3205 | { |
3206 | m_children |= Italic; |
3207 | m_italic = a; |
3208 | } |
3209 | |
3210 | void DomFont::setElementBold(bool a) |
3211 | { |
3212 | m_children |= Bold; |
3213 | m_bold = a; |
3214 | } |
3215 | |
3216 | void DomFont::setElementUnderline(bool a) |
3217 | { |
3218 | m_children |= Underline; |
3219 | m_underline = a; |
3220 | } |
3221 | |
3222 | void DomFont::setElementStrikeOut(bool a) |
3223 | { |
3224 | m_children |= StrikeOut; |
3225 | m_strikeOut = a; |
3226 | } |
3227 | |
3228 | void DomFont::setElementAntialiasing(bool a) |
3229 | { |
3230 | m_children |= Antialiasing; |
3231 | m_antialiasing = a; |
3232 | } |
3233 | |
3234 | void DomFont::setElementStyleStrategy(const QString &a) |
3235 | { |
3236 | m_children |= StyleStrategy; |
3237 | m_styleStrategy = a; |
3238 | } |
3239 | |
3240 | void DomFont::setElementKerning(bool a) |
3241 | { |
3242 | m_children |= Kerning; |
3243 | m_kerning = a; |
3244 | } |
3245 | |
3246 | void DomFont::setElementHintingPreference(const QString &a) |
3247 | { |
3248 | m_children |= HintingPreference; |
3249 | m_hintingPreference = a; |
3250 | } |
3251 | |
3252 | void DomFont::setElementFontWeight(const QString &a) |
3253 | { |
3254 | m_children |= FontWeight; |
3255 | m_fontWeight = a; |
3256 | } |
3257 | |
3258 | void DomFont::clearElementFamily() |
3259 | { |
3260 | m_children &= ~Family; |
3261 | } |
3262 | |
3263 | void DomFont::clearElementPointSize() |
3264 | { |
3265 | m_children &= ~PointSize; |
3266 | } |
3267 | |
3268 | void DomFont::clearElementWeight() |
3269 | { |
3270 | m_children &= ~Weight; |
3271 | } |
3272 | |
3273 | void DomFont::clearElementItalic() |
3274 | { |
3275 | m_children &= ~Italic; |
3276 | } |
3277 | |
3278 | void DomFont::clearElementBold() |
3279 | { |
3280 | m_children &= ~Bold; |
3281 | } |
3282 | |
3283 | void DomFont::clearElementUnderline() |
3284 | { |
3285 | m_children &= ~Underline; |
3286 | } |
3287 | |
3288 | void DomFont::clearElementStrikeOut() |
3289 | { |
3290 | m_children &= ~StrikeOut; |
3291 | } |
3292 | |
3293 | void DomFont::clearElementAntialiasing() |
3294 | { |
3295 | m_children &= ~Antialiasing; |
3296 | } |
3297 | |
3298 | void DomFont::clearElementStyleStrategy() |
3299 | { |
3300 | m_children &= ~StyleStrategy; |
3301 | } |
3302 | |
3303 | void DomFont::clearElementKerning() |
3304 | { |
3305 | m_children &= ~Kerning; |
3306 | } |
3307 | |
3308 | void DomFont::clearElementHintingPreference() |
3309 | { |
3310 | m_children &= ~HintingPreference; |
3311 | } |
3312 | |
3313 | void DomFont::clearElementFontWeight() |
3314 | { |
3315 | m_children &= ~FontWeight; |
3316 | } |
3317 | |
3318 | DomPoint::~DomPoint() = default; |
3319 | |
3320 | void DomPoint::read(QXmlStreamReader &reader) |
3321 | { |
3322 | while (!reader.hasError()) { |
3323 | switch (reader.readNext()) { |
3324 | case QXmlStreamReader::StartElement : { |
3325 | const auto tag = reader.name(); |
3326 | if (!tag.compare(other: u"x"_s , cs: Qt::CaseInsensitive)) { |
3327 | setElementX(reader.readElementText().toInt()); |
3328 | continue; |
3329 | } |
3330 | if (!tag.compare(other: u"y"_s , cs: Qt::CaseInsensitive)) { |
3331 | setElementY(reader.readElementText().toInt()); |
3332 | continue; |
3333 | } |
3334 | reader.raiseError(message: "Unexpected element "_L1 + tag); |
3335 | } |
3336 | break; |
3337 | case QXmlStreamReader::EndElement : |
3338 | return; |
3339 | default : |
3340 | break; |
3341 | } |
3342 | } |
3343 | } |
3344 | |
3345 | void DomPoint::write(QXmlStreamWriter &writer, const QString &tagName) const |
3346 | { |
3347 | writer.writeStartElement(qualifiedName: tagName.isEmpty() ? QStringLiteral("point" ) : tagName.toLower()); |
3348 | |
3349 | if (m_children & X) |
3350 | writer.writeTextElement(qualifiedName: u"x"_s , text: QString::number(m_x)); |
3351 | |
3352 | if (m_children & Y) |
3353 | writer.writeTextElement(qualifiedName: u"y"_s , text: QString::number(m_y)); |
3354 | |
3355 | writer.writeEndElement(); |
3356 | } |
3357 | |
3358 | void DomPoint::setElementX(int a) |
3359 | { |
3360 | m_children |= X; |
3361 | m_x = a; |
3362 | } |
3363 | |
3364 | void DomPoint::setElementY(int a) |
3365 | { |
3366 | m_children |= Y; |
3367 | m_y = a; |
3368 | } |
3369 | |
3370 | void DomPoint::clearElementX() |
3371 | { |
3372 | m_children &= ~X; |
3373 | } |
3374 | |
3375 | void DomPoint::clearElementY() |
3376 | { |
3377 | m_children &= ~Y; |
3378 | } |
3379 | |
3380 | DomRect::~DomRect() = default; |
3381 | |
3382 | void DomRect::read(QXmlStreamReader &reader) |
3383 | { |
3384 | while (!reader.hasError()) { |
3385 | switch (reader.readNext()) { |
3386 | case QXmlStreamReader::StartElement : { |
3387 | const auto tag = reader.name(); |
3388 | if (!tag.compare(other: u"x"_s , cs: Qt::CaseInsensitive)) { |
3389 | setElementX(reader.readElementText().toInt()); |
3390 | continue; |
3391 | } |
3392 | if (!tag.compare(other: u"y"_s , cs: Qt::CaseInsensitive)) { |
3393 | setElementY(reader.readElementText().toInt()); |
3394 | continue; |
3395 | } |
3396 | if (!tag.compare(other: u"width"_s , cs: Qt::CaseInsensitive)) { |
3397 | setElementWidth(reader.readElementText().toInt()); |
3398 | continue; |
3399 | } |
3400 | if (!tag.compare(other: u"height"_s , cs: Qt::CaseInsensitive)) { |
3401 | setElementHeight(reader.readElementText().toInt()); |
3402 | continue; |
3403 | } |
3404 | reader.raiseError(message: "Unexpected element "_L1 + tag); |
3405 | } |
3406 | break; |
3407 | case QXmlStreamReader::EndElement : |
3408 | return; |
3409 | default : |
3410 | break; |
3411 | } |
3412 | } |
3413 | } |
3414 | |
3415 | void DomRect::write(QXmlStreamWriter &writer, const QString &tagName) const |
3416 | { |
3417 | writer.writeStartElement(qualifiedName: tagName.isEmpty() ? QStringLiteral("rect" ) : tagName.toLower()); |
3418 | |
3419 | if (m_children & X) |
3420 | writer.writeTextElement(qualifiedName: u"x"_s , text: QString::number(m_x)); |
3421 | |
3422 | if (m_children & Y) |
3423 | writer.writeTextElement(qualifiedName: u"y"_s , text: QString::number(m_y)); |
3424 | |
3425 | if (m_children & Width) |
3426 | writer.writeTextElement(qualifiedName: u"width"_s , text: QString::number(m_width)); |
3427 | |
3428 | if (m_children & Height) |
3429 | writer.writeTextElement(qualifiedName: u"height"_s , text: QString::number(m_height)); |
3430 | |
3431 | writer.writeEndElement(); |
3432 | } |
3433 | |
3434 | void DomRect::setElementX(int a) |
3435 | { |
3436 | m_children |= X; |
3437 | m_x = a; |
3438 | } |
3439 | |
3440 | void DomRect::setElementY(int a) |
3441 | { |
3442 | m_children |= Y; |
3443 | m_y = a; |
3444 | } |
3445 | |
3446 | void DomRect::setElementWidth(int a) |
3447 | { |
3448 | m_children |= Width; |
3449 | m_width = a; |
3450 | } |
3451 | |
3452 | void DomRect::setElementHeight(int a) |
3453 | { |
3454 | m_children |= Height; |
3455 | m_height = a; |
3456 | } |
3457 | |
3458 | void DomRect::clearElementX() |
3459 | { |
3460 | m_children &= ~X; |
3461 | } |
3462 | |
3463 | void DomRect::clearElementY() |
3464 | { |
3465 | m_children &= ~Y; |
3466 | } |
3467 | |
3468 | void DomRect::clearElementWidth() |
3469 | { |
3470 | m_children &= ~Width; |
3471 | } |
3472 | |
3473 | void DomRect::clearElementHeight() |
3474 | { |
3475 | m_children &= ~Height; |
3476 | } |
3477 | |
3478 | DomLocale::~DomLocale() = default; |
3479 | |
3480 | void DomLocale::read(QXmlStreamReader &reader) |
3481 | { |
3482 | const QXmlStreamAttributes &attributes = reader.attributes(); |
3483 | for (const QXmlStreamAttribute &attribute : attributes) { |
3484 | const auto name = attribute.name(); |
3485 | if (name == u"language"_s ) { |
3486 | setAttributeLanguage(attribute.value().toString()); |
3487 | continue; |
3488 | } |
3489 | if (name == u"country"_s ) { |
3490 | setAttributeCountry(attribute.value().toString()); |
3491 | continue; |
3492 | } |
3493 | reader.raiseError(message: "Unexpected attribute "_L1 + name); |
3494 | } |
3495 | |
3496 | while (!reader.hasError()) { |
3497 | switch (reader.readNext()) { |
3498 | case QXmlStreamReader::StartElement : { |
3499 | const auto tag = reader.name(); |
3500 | reader.raiseError(message: "Unexpected element "_L1 + tag); |
3501 | } |
3502 | break; |
3503 | case QXmlStreamReader::EndElement : |
3504 | return; |
3505 | default : |
3506 | break; |
3507 | } |
3508 | } |
3509 | } |
3510 | |
3511 | void DomLocale::write(QXmlStreamWriter &writer, const QString &tagName) const |
3512 | { |
3513 | writer.writeStartElement(qualifiedName: tagName.isEmpty() ? QStringLiteral("locale" ) : tagName.toLower()); |
3514 | |
3515 | if (hasAttributeLanguage()) |
3516 | writer.writeAttribute(qualifiedName: u"language"_s , value: attributeLanguage()); |
3517 | |
3518 | if (hasAttributeCountry()) |
3519 | writer.writeAttribute(qualifiedName: u"country"_s , value: attributeCountry()); |
3520 | |
3521 | writer.writeEndElement(); |
3522 | } |
3523 | |
3524 | DomSizePolicy::~DomSizePolicy() = default; |
3525 | |
3526 | void DomSizePolicy::read(QXmlStreamReader &reader) |
3527 | { |
3528 | const QXmlStreamAttributes &attributes = reader.attributes(); |
3529 | for (const QXmlStreamAttribute &attribute : attributes) { |
3530 | const auto name = attribute.name(); |
3531 | if (name == u"hsizetype"_s ) { |
3532 | setAttributeHSizeType(attribute.value().toString()); |
3533 | continue; |
3534 | } |
3535 | if (name == u"vsizetype"_s ) { |
3536 | setAttributeVSizeType(attribute.value().toString()); |
3537 | continue; |
3538 | } |
3539 | reader.raiseError(message: "Unexpected attribute "_L1 + name); |
3540 | } |
3541 | |
3542 | while (!reader.hasError()) { |
3543 | switch (reader.readNext()) { |
3544 | case QXmlStreamReader::StartElement : { |
3545 | const auto tag = reader.name(); |
3546 | if (!tag.compare(other: u"hsizetype"_s , cs: Qt::CaseInsensitive)) { |
3547 | setElementHSizeType(reader.readElementText().toInt()); |
3548 | continue; |
3549 | } |
3550 | if (!tag.compare(other: u"vsizetype"_s , cs: Qt::CaseInsensitive)) { |
3551 | setElementVSizeType(reader.readElementText().toInt()); |
3552 | continue; |
3553 | } |
3554 | if (!tag.compare(other: u"horstretch"_s , cs: Qt::CaseInsensitive)) { |
3555 | setElementHorStretch(reader.readElementText().toInt()); |
3556 | continue; |
3557 | } |
3558 | if (!tag.compare(other: u"verstretch"_s , cs: Qt::CaseInsensitive)) { |
3559 | setElementVerStretch(reader.readElementText().toInt()); |
3560 | continue; |
3561 | } |
3562 | reader.raiseError(message: "Unexpected element "_L1 + tag); |
3563 | } |
3564 | break; |
3565 | case QXmlStreamReader::EndElement : |
3566 | return; |
3567 | default : |
3568 | break; |
3569 | } |
3570 | } |
3571 | } |
3572 | |
3573 | void DomSizePolicy::write(QXmlStreamWriter &writer, const QString &tagName) const |
3574 | { |
3575 | writer.writeStartElement(qualifiedName: tagName.isEmpty() ? QStringLiteral("sizepolicy" ) : tagName.toLower()); |
3576 | |
3577 | if (hasAttributeHSizeType()) |
3578 | writer.writeAttribute(qualifiedName: u"hsizetype"_s , value: attributeHSizeType()); |
3579 | |
3580 | if (hasAttributeVSizeType()) |
3581 | writer.writeAttribute(qualifiedName: u"vsizetype"_s , value: attributeVSizeType()); |
3582 | |
3583 | if (m_children & HSizeType) |
3584 | writer.writeTextElement(qualifiedName: u"hsizetype"_s , text: QString::number(m_hSizeType)); |
3585 | |
3586 | if (m_children & VSizeType) |
3587 | writer.writeTextElement(qualifiedName: u"vsizetype"_s , text: QString::number(m_vSizeType)); |
3588 | |
3589 | if (m_children & HorStretch) |
3590 | writer.writeTextElement(qualifiedName: u"horstretch"_s , text: QString::number(m_horStretch)); |
3591 | |
3592 | if (m_children & VerStretch) |
3593 | writer.writeTextElement(qualifiedName: u"verstretch"_s , text: QString::number(m_verStretch)); |
3594 | |
3595 | writer.writeEndElement(); |
3596 | } |
3597 | |
3598 | void DomSizePolicy::setElementHSizeType(int a) |
3599 | { |
3600 | m_children |= HSizeType; |
3601 | m_hSizeType = a; |
3602 | } |
3603 | |
3604 | void DomSizePolicy::setElementVSizeType(int a) |
3605 | { |
3606 | m_children |= VSizeType; |
3607 | m_vSizeType = a; |
3608 | } |
3609 | |
3610 | void DomSizePolicy::setElementHorStretch(int a) |
3611 | { |
3612 | m_children |= HorStretch; |
3613 | m_horStretch = a; |
3614 | } |
3615 | |
3616 | void DomSizePolicy::setElementVerStretch(int a) |
3617 | { |
3618 | m_children |= VerStretch; |
3619 | m_verStretch = a; |
3620 | } |
3621 | |
3622 | void DomSizePolicy::clearElementHSizeType() |
3623 | { |
3624 | m_children &= ~HSizeType; |
3625 | } |
3626 | |
3627 | void DomSizePolicy::clearElementVSizeType() |
3628 | { |
3629 | m_children &= ~VSizeType; |
3630 | } |
3631 | |
3632 | void DomSizePolicy::clearElementHorStretch() |
3633 | { |
3634 | m_children &= ~HorStretch; |
3635 | } |
3636 | |
3637 | void DomSizePolicy::clearElementVerStretch() |
3638 | { |
3639 | m_children &= ~VerStretch; |
3640 | } |
3641 | |
3642 | DomSize::~DomSize() = default; |
3643 | |
3644 | void DomSize::read(QXmlStreamReader &reader) |
3645 | { |
3646 | while (!reader.hasError()) { |
3647 | switch (reader.readNext()) { |
3648 | case QXmlStreamReader::StartElement : { |
3649 | const auto tag = reader.name(); |
3650 | if (!tag.compare(other: u"width"_s , cs: Qt::CaseInsensitive)) { |
3651 | setElementWidth(reader.readElementText().toInt()); |
3652 | continue; |
3653 | } |
3654 | if (!tag.compare(other: u"height"_s , cs: Qt::CaseInsensitive)) { |
3655 | setElementHeight(reader.readElementText().toInt()); |
3656 | continue; |
3657 | } |
3658 | reader.raiseError(message: "Unexpected element "_L1 + tag); |
3659 | } |
3660 | break; |
3661 | case QXmlStreamReader::EndElement : |
3662 | return; |
3663 | default : |
3664 | break; |
3665 | } |
3666 | } |
3667 | } |
3668 | |
3669 | void DomSize::write(QXmlStreamWriter &writer, const QString &tagName) const |
3670 | { |
3671 | writer.writeStartElement(qualifiedName: tagName.isEmpty() ? QStringLiteral("size" ) : tagName.toLower()); |
3672 | |
3673 | if (m_children & Width) |
3674 | writer.writeTextElement(qualifiedName: u"width"_s , text: QString::number(m_width)); |
3675 | |
3676 | if (m_children & Height) |
3677 | writer.writeTextElement(qualifiedName: u"height"_s , text: QString::number(m_height)); |
3678 | |
3679 | writer.writeEndElement(); |
3680 | } |
3681 | |
3682 | void DomSize::setElementWidth(int a) |
3683 | { |
3684 | m_children |= Width; |
3685 | m_width = a; |
3686 | } |
3687 | |
3688 | void DomSize::setElementHeight(int a) |
3689 | { |
3690 | m_children |= Height; |
3691 | m_height = a; |
3692 | } |
3693 | |
3694 | void DomSize::clearElementWidth() |
3695 | { |
3696 | m_children &= ~Width; |
3697 | } |
3698 | |
3699 | void DomSize::clearElementHeight() |
3700 | { |
3701 | m_children &= ~Height; |
3702 | } |
3703 | |
3704 | DomDate::~DomDate() = default; |
3705 | |
3706 | void DomDate::read(QXmlStreamReader &reader) |
3707 | { |
3708 | while (!reader.hasError()) { |
3709 | switch (reader.readNext()) { |
3710 | case QXmlStreamReader::StartElement : { |
3711 | const auto tag = reader.name(); |
3712 | if (!tag.compare(other: u"year"_s , cs: Qt::CaseInsensitive)) { |
3713 | setElementYear(reader.readElementText().toInt()); |
3714 | continue; |
3715 | } |
3716 | if (!tag.compare(other: u"month"_s , cs: Qt::CaseInsensitive)) { |
3717 | setElementMonth(reader.readElementText().toInt()); |
3718 | continue; |
3719 | } |
3720 | if (!tag.compare(other: u"day"_s , cs: Qt::CaseInsensitive)) { |
3721 | setElementDay(reader.readElementText().toInt()); |
3722 | continue; |
3723 | } |
3724 | reader.raiseError(message: "Unexpected element "_L1 + tag); |
3725 | } |
3726 | break; |
3727 | case QXmlStreamReader::EndElement : |
3728 | return; |
3729 | default : |
3730 | break; |
3731 | } |
3732 | } |
3733 | } |
3734 | |
3735 | void DomDate::write(QXmlStreamWriter &writer, const QString &tagName) const |
3736 | { |
3737 | writer.writeStartElement(qualifiedName: tagName.isEmpty() ? QStringLiteral("date" ) : tagName.toLower()); |
3738 | |
3739 | if (m_children & Year) |
3740 | writer.writeTextElement(qualifiedName: u"year"_s , text: QString::number(m_year)); |
3741 | |
3742 | if (m_children & Month) |
3743 | writer.writeTextElement(qualifiedName: u"month"_s , text: QString::number(m_month)); |
3744 | |
3745 | if (m_children & Day) |
3746 | writer.writeTextElement(qualifiedName: u"day"_s , text: QString::number(m_day)); |
3747 | |
3748 | writer.writeEndElement(); |
3749 | } |
3750 | |
3751 | void DomDate::setElementYear(int a) |
3752 | { |
3753 | m_children |= Year; |
3754 | m_year = a; |
3755 | } |
3756 | |
3757 | void DomDate::setElementMonth(int a) |
3758 | { |
3759 | m_children |= Month; |
3760 | m_month = a; |
3761 | } |
3762 | |
3763 | void DomDate::setElementDay(int a) |
3764 | { |
3765 | m_children |= Day; |
3766 | m_day = a; |
3767 | } |
3768 | |
3769 | void DomDate::clearElementYear() |
3770 | { |
3771 | m_children &= ~Year; |
3772 | } |
3773 | |
3774 | void DomDate::clearElementMonth() |
3775 | { |
3776 | m_children &= ~Month; |
3777 | } |
3778 | |
3779 | void DomDate::clearElementDay() |
3780 | { |
3781 | m_children &= ~Day; |
3782 | } |
3783 | |
3784 | DomTime::~DomTime() = default; |
3785 | |
3786 | void DomTime::read(QXmlStreamReader &reader) |
3787 | { |
3788 | while (!reader.hasError()) { |
3789 | switch (reader.readNext()) { |
3790 | case QXmlStreamReader::StartElement : { |
3791 | const auto tag = reader.name(); |
3792 | if (!tag.compare(other: u"hour"_s , cs: Qt::CaseInsensitive)) { |
3793 | setElementHour(reader.readElementText().toInt()); |
3794 | continue; |
3795 | } |
3796 | if (!tag.compare(other: u"minute"_s , cs: Qt::CaseInsensitive)) { |
3797 | setElementMinute(reader.readElementText().toInt()); |
3798 | continue; |
3799 | } |
3800 | if (!tag.compare(other: u"second"_s , cs: Qt::CaseInsensitive)) { |
3801 | setElementSecond(reader.readElementText().toInt()); |
3802 | continue; |
3803 | } |
3804 | reader.raiseError(message: "Unexpected element "_L1 + tag); |
3805 | } |
3806 | break; |
3807 | case QXmlStreamReader::EndElement : |
3808 | return; |
3809 | default : |
3810 | break; |
3811 | } |
3812 | } |
3813 | } |
3814 | |
3815 | void DomTime::write(QXmlStreamWriter &writer, const QString &tagName) const |
3816 | { |
3817 | writer.writeStartElement(qualifiedName: tagName.isEmpty() ? QStringLiteral("time" ) : tagName.toLower()); |
3818 | |
3819 | if (m_children & Hour) |
3820 | writer.writeTextElement(qualifiedName: u"hour"_s , text: QString::number(m_hour)); |
3821 | |
3822 | if (m_children & Minute) |
3823 | writer.writeTextElement(qualifiedName: u"minute"_s , text: QString::number(m_minute)); |
3824 | |
3825 | if (m_children & Second) |
3826 | writer.writeTextElement(qualifiedName: u"second"_s , text: QString::number(m_second)); |
3827 | |
3828 | writer.writeEndElement(); |
3829 | } |
3830 | |
3831 | void DomTime::setElementHour(int a) |
3832 | { |
3833 | m_children |= Hour; |
3834 | m_hour = a; |
3835 | } |
3836 | |
3837 | void DomTime::setElementMinute(int a) |
3838 | { |
3839 | m_children |= Minute; |
3840 | m_minute = a; |
3841 | } |
3842 | |
3843 | void DomTime::setElementSecond(int a) |
3844 | { |
3845 | m_children |= Second; |
3846 | m_second = a; |
3847 | } |
3848 | |
3849 | void DomTime::clearElementHour() |
3850 | { |
3851 | m_children &= ~Hour; |
3852 | } |
3853 | |
3854 | void DomTime::clearElementMinute() |
3855 | { |
3856 | m_children &= ~Minute; |
3857 | } |
3858 | |
3859 | void DomTime::clearElementSecond() |
3860 | { |
3861 | m_children &= ~Second; |
3862 | } |
3863 | |
3864 | DomDateTime::~DomDateTime() = default; |
3865 | |
3866 | void DomDateTime::read(QXmlStreamReader &reader) |
3867 | { |
3868 | while (!reader.hasError()) { |
3869 | switch (reader.readNext()) { |
3870 | case QXmlStreamReader::StartElement : { |
3871 | const auto tag = reader.name(); |
3872 | if (!tag.compare(other: u"hour"_s , cs: Qt::CaseInsensitive)) { |
3873 | setElementHour(reader.readElementText().toInt()); |
3874 | continue; |
3875 | } |
3876 | if (!tag.compare(other: u"minute"_s , cs: Qt::CaseInsensitive)) { |
3877 | setElementMinute(reader.readElementText().toInt()); |
3878 | continue; |
3879 | } |
3880 | if (!tag.compare(other: u"second"_s , cs: Qt::CaseInsensitive)) { |
3881 | setElementSecond(reader.readElementText().toInt()); |
3882 | continue; |
3883 | } |
3884 | if (!tag.compare(other: u"year"_s , cs: Qt::CaseInsensitive)) { |
3885 | setElementYear(reader.readElementText().toInt()); |
3886 | continue; |
3887 | } |
3888 | if (!tag.compare(other: u"month"_s , cs: Qt::CaseInsensitive)) { |
3889 | setElementMonth(reader.readElementText().toInt()); |
3890 | continue; |
3891 | } |
3892 | if (!tag.compare(other: u"day"_s , cs: Qt::CaseInsensitive)) { |
3893 | setElementDay(reader.readElementText().toInt()); |
3894 | continue; |
3895 | } |
3896 | reader.raiseError(message: "Unexpected element "_L1 + tag); |
3897 | } |
3898 | break; |
3899 | case QXmlStreamReader::EndElement : |
3900 | return; |
3901 | default : |
3902 | break; |
3903 | } |
3904 | } |
3905 | } |
3906 | |
3907 | void DomDateTime::write(QXmlStreamWriter &writer, const QString &tagName) const |
3908 | { |
3909 | writer.writeStartElement(qualifiedName: tagName.isEmpty() ? QStringLiteral("datetime" ) : tagName.toLower()); |
3910 | |
3911 | if (m_children & Hour) |
3912 | writer.writeTextElement(qualifiedName: u"hour"_s , text: QString::number(m_hour)); |
3913 | |
3914 | if (m_children & Minute) |
3915 | writer.writeTextElement(qualifiedName: u"minute"_s , text: QString::number(m_minute)); |
3916 | |
3917 | if (m_children & Second) |
3918 | writer.writeTextElement(qualifiedName: u"second"_s , text: QString::number(m_second)); |
3919 | |
3920 | if (m_children & Year) |
3921 | writer.writeTextElement(qualifiedName: u"year"_s , text: QString::number(m_year)); |
3922 | |
3923 | if (m_children & Month) |
3924 | writer.writeTextElement(qualifiedName: u"month"_s , text: QString::number(m_month)); |
3925 | |
3926 | if (m_children & Day) |
3927 | writer.writeTextElement(qualifiedName: u"day"_s , text: QString::number(m_day)); |
3928 | |
3929 | writer.writeEndElement(); |
3930 | } |
3931 | |
3932 | void DomDateTime::setElementHour(int a) |
3933 | { |
3934 | m_children |= Hour; |
3935 | m_hour = a; |
3936 | } |
3937 | |
3938 | void DomDateTime::setElementMinute(int a) |
3939 | { |
3940 | m_children |= Minute; |
3941 | m_minute = a; |
3942 | } |
3943 | |
3944 | void DomDateTime::setElementSecond(int a) |
3945 | { |
3946 | m_children |= Second; |
3947 | m_second = a; |
3948 | } |
3949 | |
3950 | void DomDateTime::setElementYear(int a) |
3951 | { |
3952 | m_children |= Year; |
3953 | m_year = a; |
3954 | } |
3955 | |
3956 | void DomDateTime::setElementMonth(int a) |
3957 | { |
3958 | m_children |= Month; |
3959 | m_month = a; |
3960 | } |
3961 | |
3962 | void DomDateTime::setElementDay(int a) |
3963 | { |
3964 | m_children |= Day; |
3965 | m_day = a; |
3966 | } |
3967 | |
3968 | void DomDateTime::clearElementHour() |
3969 | { |
3970 | m_children &= ~Hour; |
3971 | } |
3972 | |
3973 | void DomDateTime::clearElementMinute() |
3974 | { |
3975 | m_children &= ~Minute; |
3976 | } |
3977 | |
3978 | void DomDateTime::clearElementSecond() |
3979 | { |
3980 | m_children &= ~Second; |
3981 | } |
3982 | |
3983 | void DomDateTime::clearElementYear() |
3984 | { |
3985 | m_children &= ~Year; |
3986 | } |
3987 | |
3988 | void DomDateTime::clearElementMonth() |
3989 | { |
3990 | m_children &= ~Month; |
3991 | } |
3992 | |
3993 | void DomDateTime::clearElementDay() |
3994 | { |
3995 | m_children &= ~Day; |
3996 | } |
3997 | |
3998 | DomStringList::~DomStringList() |
3999 | { |
4000 | m_string.clear(); |
4001 | } |
4002 | |
4003 | void DomStringList::read(QXmlStreamReader &reader) |
4004 | { |
4005 | const QXmlStreamAttributes &attributes = reader.attributes(); |
4006 | for (const QXmlStreamAttribute &attribute : attributes) { |
4007 | const auto name = attribute.name(); |
4008 | if (name == u"notr"_s ) { |
4009 | setAttributeNotr(attribute.value().toString()); |
4010 | continue; |
4011 | } |
4012 | if (name == u"comment"_s ) { |
4013 | setAttributeComment(attribute.value().toString()); |
4014 | continue; |
4015 | } |
4016 | if (name == u"extracomment"_s ) { |
4017 | setAttributeExtraComment(attribute.value().toString()); |
4018 | continue; |
4019 | } |
4020 | if (name == u"id"_s ) { |
4021 | setAttributeId(attribute.value().toString()); |
4022 | continue; |
4023 | } |
4024 | reader.raiseError(message: "Unexpected attribute "_L1 + name); |
4025 | } |
4026 | |
4027 | while (!reader.hasError()) { |
4028 | switch (reader.readNext()) { |
4029 | case QXmlStreamReader::StartElement : { |
4030 | const auto tag = reader.name(); |
4031 | if (!tag.compare(other: u"string"_s , cs: Qt::CaseInsensitive)) { |
4032 | m_string.append(t: reader.readElementText()); |
4033 | continue; |
4034 | } |
4035 | reader.raiseError(message: "Unexpected element "_L1 + tag); |
4036 | } |
4037 | break; |
4038 | case QXmlStreamReader::EndElement : |
4039 | return; |
4040 | default : |
4041 | break; |
4042 | } |
4043 | } |
4044 | } |
4045 | |
4046 | void DomStringList::write(QXmlStreamWriter &writer, const QString &tagName) const |
4047 | { |
4048 | writer.writeStartElement(qualifiedName: tagName.isEmpty() ? QStringLiteral("stringlist" ) : tagName.toLower()); |
4049 | |
4050 | if (hasAttributeNotr()) |
4051 | writer.writeAttribute(qualifiedName: u"notr"_s , value: attributeNotr()); |
4052 | |
4053 | if (hasAttributeComment()) |
4054 | writer.writeAttribute(qualifiedName: u"comment"_s , value: attributeComment()); |
4055 | |
4056 | if (hasAttributeExtraComment()) |
4057 | writer.writeAttribute(qualifiedName: u"extracomment"_s , value: attributeExtraComment()); |
4058 | |
4059 | if (hasAttributeId()) |
4060 | writer.writeAttribute(qualifiedName: u"id"_s , value: attributeId()); |
4061 | |
4062 | for (const QString &v : m_string) |
4063 | writer.writeTextElement(qualifiedName: u"string"_s , text: v); |
4064 | |
4065 | writer.writeEndElement(); |
4066 | } |
4067 | |
4068 | void DomStringList::setElementString(const QStringList &a) |
4069 | { |
4070 | m_children |= String; |
4071 | m_string = a; |
4072 | } |
4073 | |
4074 | DomResourcePixmap::~DomResourcePixmap() = default; |
4075 | |
4076 | void DomResourcePixmap::read(QXmlStreamReader &reader) |
4077 | { |
4078 | const QXmlStreamAttributes &attributes = reader.attributes(); |
4079 | for (const QXmlStreamAttribute &attribute : attributes) { |
4080 | const auto name = attribute.name(); |
4081 | if (name == u"resource"_s ) { |
4082 | setAttributeResource(attribute.value().toString()); |
4083 | continue; |
4084 | } |
4085 | if (name == u"alias"_s ) { |
4086 | setAttributeAlias(attribute.value().toString()); |
4087 | continue; |
4088 | } |
4089 | reader.raiseError(message: "Unexpected attribute "_L1 + name); |
4090 | } |
4091 | |
4092 | while (!reader.hasError()) { |
4093 | switch (reader.readNext()) { |
4094 | case QXmlStreamReader::StartElement : { |
4095 | const auto tag = reader.name(); |
4096 | reader.raiseError(message: "Unexpected element "_L1 + tag); |
4097 | } |
4098 | break; |
4099 | case QXmlStreamReader::EndElement : |
4100 | return; |
4101 | case QXmlStreamReader::Characters : |
4102 | if (!reader.isWhitespace()) |
4103 | m_text.append(s: reader.text().toString()); |
4104 | break; |
4105 | default : |
4106 | break; |
4107 | } |
4108 | } |
4109 | } |
4110 | |
4111 | void DomResourcePixmap::write(QXmlStreamWriter &writer, const QString &tagName) const |
4112 | { |
4113 | writer.writeStartElement(qualifiedName: tagName.isEmpty() ? QStringLiteral("resourcepixmap" ) : tagName.toLower()); |
4114 | |
4115 | if (hasAttributeResource()) |
4116 | writer.writeAttribute(qualifiedName: u"resource"_s , value: attributeResource()); |
4117 | |
4118 | if (hasAttributeAlias()) |
4119 | writer.writeAttribute(qualifiedName: u"alias"_s , value: attributeAlias()); |
4120 | |
4121 | if (!m_text.isEmpty()) |
4122 | writer.writeCharacters(text: m_text); |
4123 | |
4124 | writer.writeEndElement(); |
4125 | } |
4126 | |
4127 | DomResourceIcon::~DomResourceIcon() |
4128 | { |
4129 | delete m_normalOff; |
4130 | delete m_normalOn; |
4131 | delete m_disabledOff; |
4132 | delete m_disabledOn; |
4133 | delete m_activeOff; |
4134 | delete m_activeOn; |
4135 | delete m_selectedOff; |
4136 | delete m_selectedOn; |
4137 | } |
4138 | |
4139 | void DomResourceIcon::read(QXmlStreamReader &reader) |
4140 | { |
4141 | const QXmlStreamAttributes &attributes = reader.attributes(); |
4142 | for (const QXmlStreamAttribute &attribute : attributes) { |
4143 | const auto name = attribute.name(); |
4144 | if (name == u"theme"_s ) { |
4145 | setAttributeTheme(attribute.value().toString()); |
4146 | continue; |
4147 | } |
4148 | if (name == u"resource"_s ) { |
4149 | setAttributeResource(attribute.value().toString()); |
4150 | continue; |
4151 | } |
4152 | reader.raiseError(message: "Unexpected attribute "_L1 + name); |
4153 | } |
4154 | |
4155 | while (!reader.hasError()) { |
4156 | switch (reader.readNext()) { |
4157 | case QXmlStreamReader::StartElement : { |
4158 | const auto tag = reader.name(); |
4159 | if (!tag.compare(other: u"normaloff"_s , cs: Qt::CaseInsensitive)) { |
4160 | auto *v = new DomResourcePixmap(); |
4161 | v->read(reader); |
4162 | setElementNormalOff(v); |
4163 | continue; |
4164 | } |
4165 | if (!tag.compare(other: u"normalon"_s , cs: Qt::CaseInsensitive)) { |
4166 | auto *v = new DomResourcePixmap(); |
4167 | v->read(reader); |
4168 | setElementNormalOn(v); |
4169 | continue; |
4170 | } |
4171 | if (!tag.compare(other: u"disabledoff"_s , cs: Qt::CaseInsensitive)) { |
4172 | auto *v = new DomResourcePixmap(); |
4173 | v->read(reader); |
4174 | setElementDisabledOff(v); |
4175 | continue; |
4176 | } |
4177 | if (!tag.compare(other: u"disabledon"_s , cs: Qt::CaseInsensitive)) { |
4178 | auto *v = new DomResourcePixmap(); |
4179 | v->read(reader); |
4180 | setElementDisabledOn(v); |
4181 | continue; |
4182 | } |
4183 | if (!tag.compare(other: u"activeoff"_s , cs: Qt::CaseInsensitive)) { |
4184 | auto *v = new DomResourcePixmap(); |
4185 | v->read(reader); |
4186 | setElementActiveOff(v); |
4187 | continue; |
4188 | } |
4189 | if (!tag.compare(other: u"activeon"_s , cs: Qt::CaseInsensitive)) { |
4190 | auto *v = new DomResourcePixmap(); |
4191 | v->read(reader); |
4192 | setElementActiveOn(v); |
4193 | continue; |
4194 | } |
4195 | if (!tag.compare(other: u"selectedoff"_s , cs: Qt::CaseInsensitive)) { |
4196 | auto *v = new DomResourcePixmap(); |
4197 | v->read(reader); |
4198 | setElementSelectedOff(v); |
4199 | continue; |
4200 | } |
4201 | if (!tag.compare(other: u"selectedon"_s , cs: Qt::CaseInsensitive)) { |
4202 | auto *v = new DomResourcePixmap(); |
4203 | v->read(reader); |
4204 | setElementSelectedOn(v); |
4205 | continue; |
4206 | } |
4207 | reader.raiseError(message: "Unexpected element "_L1 + tag); |
4208 | } |
4209 | break; |
4210 | case QXmlStreamReader::EndElement : |
4211 | return; |
4212 | case QXmlStreamReader::Characters : |
4213 | if (!reader.isWhitespace()) |
4214 | m_text.append(s: reader.text().toString()); |
4215 | break; |
4216 | default : |
4217 | break; |
4218 | } |
4219 | } |
4220 | } |
4221 | |
4222 | void DomResourceIcon::write(QXmlStreamWriter &writer, const QString &tagName) const |
4223 | { |
4224 | writer.writeStartElement(qualifiedName: tagName.isEmpty() ? QStringLiteral("resourceicon" ) : tagName.toLower()); |
4225 | |
4226 | if (hasAttributeTheme()) |
4227 | writer.writeAttribute(qualifiedName: u"theme"_s , value: attributeTheme()); |
4228 | |
4229 | if (hasAttributeResource()) |
4230 | writer.writeAttribute(qualifiedName: u"resource"_s , value: attributeResource()); |
4231 | |
4232 | if (m_children & NormalOff) |
4233 | m_normalOff->write(writer, tagName: u"normaloff"_s ); |
4234 | |
4235 | if (m_children & NormalOn) |
4236 | m_normalOn->write(writer, tagName: u"normalon"_s ); |
4237 | |
4238 | if (m_children & DisabledOff) |
4239 | m_disabledOff->write(writer, tagName: u"disabledoff"_s ); |
4240 | |
4241 | if (m_children & DisabledOn) |
4242 | m_disabledOn->write(writer, tagName: u"disabledon"_s ); |
4243 | |
4244 | if (m_children & ActiveOff) |
4245 | m_activeOff->write(writer, tagName: u"activeoff"_s ); |
4246 | |
4247 | if (m_children & ActiveOn) |
4248 | m_activeOn->write(writer, tagName: u"activeon"_s ); |
4249 | |
4250 | if (m_children & SelectedOff) |
4251 | m_selectedOff->write(writer, tagName: u"selectedoff"_s ); |
4252 | |
4253 | if (m_children & SelectedOn) |
4254 | m_selectedOn->write(writer, tagName: u"selectedon"_s ); |
4255 | |
4256 | if (!m_text.isEmpty()) |
4257 | writer.writeCharacters(text: m_text); |
4258 | |
4259 | writer.writeEndElement(); |
4260 | } |
4261 | |
4262 | DomResourcePixmap *DomResourceIcon::takeElementNormalOff() |
4263 | { |
4264 | DomResourcePixmap *a = m_normalOff; |
4265 | m_normalOff = nullptr; |
4266 | m_children ^= NormalOff; |
4267 | return a; |
4268 | } |
4269 | |
4270 | void DomResourceIcon::setElementNormalOff(DomResourcePixmap *a) |
4271 | { |
4272 | delete m_normalOff; |
4273 | m_children |= NormalOff; |
4274 | m_normalOff = a; |
4275 | } |
4276 | |
4277 | DomResourcePixmap *DomResourceIcon::takeElementNormalOn() |
4278 | { |
4279 | DomResourcePixmap *a = m_normalOn; |
4280 | m_normalOn = nullptr; |
4281 | m_children ^= NormalOn; |
4282 | return a; |
4283 | } |
4284 | |
4285 | void DomResourceIcon::setElementNormalOn(DomResourcePixmap *a) |
4286 | { |
4287 | delete m_normalOn; |
4288 | m_children |= NormalOn; |
4289 | m_normalOn = a; |
4290 | } |
4291 | |
4292 | DomResourcePixmap *DomResourceIcon::takeElementDisabledOff() |
4293 | { |
4294 | DomResourcePixmap *a = m_disabledOff; |
4295 | m_disabledOff = nullptr; |
4296 | m_children ^= DisabledOff; |
4297 | return a; |
4298 | } |
4299 | |
4300 | void DomResourceIcon::setElementDisabledOff(DomResourcePixmap *a) |
4301 | { |
4302 | delete m_disabledOff; |
4303 | m_children |= DisabledOff; |
4304 | m_disabledOff = a; |
4305 | } |
4306 | |
4307 | DomResourcePixmap *DomResourceIcon::takeElementDisabledOn() |
4308 | { |
4309 | DomResourcePixmap *a = m_disabledOn; |
4310 | m_disabledOn = nullptr; |
4311 | m_children ^= DisabledOn; |
4312 | return a; |
4313 | } |
4314 | |
4315 | void DomResourceIcon::setElementDisabledOn(DomResourcePixmap *a) |
4316 | { |
4317 | delete m_disabledOn; |
4318 | m_children |= DisabledOn; |
4319 | m_disabledOn = a; |
4320 | } |
4321 | |
4322 | DomResourcePixmap *DomResourceIcon::takeElementActiveOff() |
4323 | { |
4324 | DomResourcePixmap *a = m_activeOff; |
4325 | m_activeOff = nullptr; |
4326 | m_children ^= ActiveOff; |
4327 | return a; |
4328 | } |
4329 | |
4330 | void DomResourceIcon::setElementActiveOff(DomResourcePixmap *a) |
4331 | { |
4332 | delete m_activeOff; |
4333 | m_children |= ActiveOff; |
4334 | m_activeOff = a; |
4335 | } |
4336 | |
4337 | DomResourcePixmap *DomResourceIcon::takeElementActiveOn() |
4338 | { |
4339 | DomResourcePixmap *a = m_activeOn; |
4340 | m_activeOn = nullptr; |
4341 | m_children ^= ActiveOn; |
4342 | return a; |
4343 | } |
4344 | |
4345 | void DomResourceIcon::setElementActiveOn(DomResourcePixmap *a) |
4346 | { |
4347 | delete m_activeOn; |
4348 | m_children |= ActiveOn; |
4349 | m_activeOn = a; |
4350 | } |
4351 | |
4352 | DomResourcePixmap *DomResourceIcon::takeElementSelectedOff() |
4353 | { |
4354 | DomResourcePixmap *a = m_selectedOff; |
4355 | m_selectedOff = nullptr; |
4356 | m_children ^= SelectedOff; |
4357 | return a; |
4358 | } |
4359 | |
4360 | void DomResourceIcon::setElementSelectedOff(DomResourcePixmap *a) |
4361 | { |
4362 | delete m_selectedOff; |
4363 | m_children |= SelectedOff; |
4364 | m_selectedOff = a; |
4365 | } |
4366 | |
4367 | DomResourcePixmap *DomResourceIcon::takeElementSelectedOn() |
4368 | { |
4369 | DomResourcePixmap *a = m_selectedOn; |
4370 | m_selectedOn = nullptr; |
4371 | m_children ^= SelectedOn; |
4372 | return a; |
4373 | } |
4374 | |
4375 | void DomResourceIcon::setElementSelectedOn(DomResourcePixmap *a) |
4376 | { |
4377 | delete m_selectedOn; |
4378 | m_children |= SelectedOn; |
4379 | m_selectedOn = a; |
4380 | } |
4381 | |
4382 | void DomResourceIcon::clearElementNormalOff() |
4383 | { |
4384 | delete m_normalOff; |
4385 | m_normalOff = nullptr; |
4386 | m_children &= ~NormalOff; |
4387 | } |
4388 | |
4389 | void DomResourceIcon::clearElementNormalOn() |
4390 | { |
4391 | delete m_normalOn; |
4392 | m_normalOn = nullptr; |
4393 | m_children &= ~NormalOn; |
4394 | } |
4395 | |
4396 | void DomResourceIcon::clearElementDisabledOff() |
4397 | { |
4398 | delete m_disabledOff; |
4399 | m_disabledOff = nullptr; |
4400 | m_children &= ~DisabledOff; |
4401 | } |
4402 | |
4403 | void DomResourceIcon::clearElementDisabledOn() |
4404 | { |
4405 | delete m_disabledOn; |
4406 | m_disabledOn = nullptr; |
4407 | m_children &= ~DisabledOn; |
4408 | } |
4409 | |
4410 | void DomResourceIcon::clearElementActiveOff() |
4411 | { |
4412 | delete m_activeOff; |
4413 | m_activeOff = nullptr; |
4414 | m_children &= ~ActiveOff; |
4415 | } |
4416 | |
4417 | void DomResourceIcon::clearElementActiveOn() |
4418 | { |
4419 | delete m_activeOn; |
4420 | m_activeOn = nullptr; |
4421 | m_children &= ~ActiveOn; |
4422 | } |
4423 | |
4424 | void DomResourceIcon::clearElementSelectedOff() |
4425 | { |
4426 | delete m_selectedOff; |
4427 | m_selectedOff = nullptr; |
4428 | m_children &= ~SelectedOff; |
4429 | } |
4430 | |
4431 | void DomResourceIcon::clearElementSelectedOn() |
4432 | { |
4433 | delete m_selectedOn; |
4434 | m_selectedOn = nullptr; |
4435 | m_children &= ~SelectedOn; |
4436 | } |
4437 | |
4438 | DomString::~DomString() = default; |
4439 | |
4440 | void DomString::read(QXmlStreamReader &reader) |
4441 | { |
4442 | const QXmlStreamAttributes &attributes = reader.attributes(); |
4443 | for (const QXmlStreamAttribute &attribute : attributes) { |
4444 | const auto name = attribute.name(); |
4445 | if (name == u"notr"_s ) { |
4446 | setAttributeNotr(attribute.value().toString()); |
4447 | continue; |
4448 | } |
4449 | if (name == u"comment"_s ) { |
4450 | setAttributeComment(attribute.value().toString()); |
4451 | continue; |
4452 | } |
4453 | if (name == u"extracomment"_s ) { |
4454 | setAttributeExtraComment(attribute.value().toString()); |
4455 | continue; |
4456 | } |
4457 | if (name == u"id"_s ) { |
4458 | setAttributeId(attribute.value().toString()); |
4459 | continue; |
4460 | } |
4461 | reader.raiseError(message: "Unexpected attribute "_L1 + name); |
4462 | } |
4463 | |
4464 | while (!reader.hasError()) { |
4465 | switch (reader.readNext()) { |
4466 | case QXmlStreamReader::StartElement : { |
4467 | const auto tag = reader.name(); |
4468 | reader.raiseError(message: "Unexpected element "_L1 + tag); |
4469 | } |
4470 | break; |
4471 | case QXmlStreamReader::EndElement : |
4472 | return; |
4473 | case QXmlStreamReader::Characters : |
4474 | if (!reader.isWhitespace()) |
4475 | m_text.append(s: reader.text().toString()); |
4476 | break; |
4477 | default : |
4478 | break; |
4479 | } |
4480 | } |
4481 | } |
4482 | |
4483 | void DomString::write(QXmlStreamWriter &writer, const QString &tagName) const |
4484 | { |
4485 | writer.writeStartElement(qualifiedName: tagName.isEmpty() ? QStringLiteral("string" ) : tagName.toLower()); |
4486 | |
4487 | if (hasAttributeNotr()) |
4488 | writer.writeAttribute(qualifiedName: u"notr"_s , value: attributeNotr()); |
4489 | |
4490 | if (hasAttributeComment()) |
4491 | writer.writeAttribute(qualifiedName: u"comment"_s , value: attributeComment()); |
4492 | |
4493 | if (hasAttributeExtraComment()) |
4494 | writer.writeAttribute(qualifiedName: u"extracomment"_s , value: attributeExtraComment()); |
4495 | |
4496 | if (hasAttributeId()) |
4497 | writer.writeAttribute(qualifiedName: u"id"_s , value: attributeId()); |
4498 | |
4499 | if (!m_text.isEmpty()) |
4500 | writer.writeCharacters(text: m_text); |
4501 | |
4502 | writer.writeEndElement(); |
4503 | } |
4504 | |
4505 | DomPointF::~DomPointF() = default; |
4506 | |
4507 | void DomPointF::read(QXmlStreamReader &reader) |
4508 | { |
4509 | while (!reader.hasError()) { |
4510 | switch (reader.readNext()) { |
4511 | case QXmlStreamReader::StartElement : { |
4512 | const auto tag = reader.name(); |
4513 | if (!tag.compare(other: u"x"_s , cs: Qt::CaseInsensitive)) { |
4514 | setElementX(reader.readElementText().toDouble()); |
4515 | continue; |
4516 | } |
4517 | if (!tag.compare(other: u"y"_s , cs: Qt::CaseInsensitive)) { |
4518 | setElementY(reader.readElementText().toDouble()); |
4519 | continue; |
4520 | } |
4521 | reader.raiseError(message: "Unexpected element "_L1 + tag); |
4522 | } |
4523 | break; |
4524 | case QXmlStreamReader::EndElement : |
4525 | return; |
4526 | default : |
4527 | break; |
4528 | } |
4529 | } |
4530 | } |
4531 | |
4532 | void DomPointF::write(QXmlStreamWriter &writer, const QString &tagName) const |
4533 | { |
4534 | writer.writeStartElement(qualifiedName: tagName.isEmpty() ? QStringLiteral("pointf" ) : tagName.toLower()); |
4535 | |
4536 | if (m_children & X) |
4537 | writer.writeTextElement(qualifiedName: u"x"_s , text: QString::number(m_x, format: 'f', precision: 15)); |
4538 | |
4539 | if (m_children & Y) |
4540 | writer.writeTextElement(qualifiedName: u"y"_s , text: QString::number(m_y, format: 'f', precision: 15)); |
4541 | |
4542 | writer.writeEndElement(); |
4543 | } |
4544 | |
4545 | void DomPointF::setElementX(double a) |
4546 | { |
4547 | m_children |= X; |
4548 | m_x = a; |
4549 | } |
4550 | |
4551 | void DomPointF::setElementY(double a) |
4552 | { |
4553 | m_children |= Y; |
4554 | m_y = a; |
4555 | } |
4556 | |
4557 | void DomPointF::clearElementX() |
4558 | { |
4559 | m_children &= ~X; |
4560 | } |
4561 | |
4562 | void DomPointF::clearElementY() |
4563 | { |
4564 | m_children &= ~Y; |
4565 | } |
4566 | |
4567 | DomRectF::~DomRectF() = default; |
4568 | |
4569 | void DomRectF::read(QXmlStreamReader &reader) |
4570 | { |
4571 | while (!reader.hasError()) { |
4572 | switch (reader.readNext()) { |
4573 | case QXmlStreamReader::StartElement : { |
4574 | const auto tag = reader.name(); |
4575 | if (!tag.compare(other: u"x"_s , cs: Qt::CaseInsensitive)) { |
4576 | setElementX(reader.readElementText().toDouble()); |
4577 | continue; |
4578 | } |
4579 | if (!tag.compare(other: u"y"_s , cs: Qt::CaseInsensitive)) { |
4580 | setElementY(reader.readElementText().toDouble()); |
4581 | continue; |
4582 | } |
4583 | if (!tag.compare(other: u"width"_s , cs: Qt::CaseInsensitive)) { |
4584 | setElementWidth(reader.readElementText().toDouble()); |
4585 | continue; |
4586 | } |
4587 | if (!tag.compare(other: u"height"_s , cs: Qt::CaseInsensitive)) { |
4588 | setElementHeight(reader.readElementText().toDouble()); |
4589 | continue; |
4590 | } |
4591 | reader.raiseError(message: "Unexpected element "_L1 + tag); |
4592 | } |
4593 | break; |
4594 | case QXmlStreamReader::EndElement : |
4595 | return; |
4596 | default : |
4597 | break; |
4598 | } |
4599 | } |
4600 | } |
4601 | |
4602 | void DomRectF::write(QXmlStreamWriter &writer, const QString &tagName) const |
4603 | { |
4604 | writer.writeStartElement(qualifiedName: tagName.isEmpty() ? QStringLiteral("rectf" ) : tagName.toLower()); |
4605 | |
4606 | if (m_children & X) |
4607 | writer.writeTextElement(qualifiedName: u"x"_s , text: QString::number(m_x, format: 'f', precision: 15)); |
4608 | |
4609 | if (m_children & Y) |
4610 | writer.writeTextElement(qualifiedName: u"y"_s , text: QString::number(m_y, format: 'f', precision: 15)); |
4611 | |
4612 | if (m_children & Width) |
4613 | writer.writeTextElement(qualifiedName: u"width"_s , text: QString::number(m_width, format: 'f', precision: 15)); |
4614 | |
4615 | if (m_children & Height) |
4616 | writer.writeTextElement(qualifiedName: u"height"_s , text: QString::number(m_height, format: 'f', precision: 15)); |
4617 | |
4618 | writer.writeEndElement(); |
4619 | } |
4620 | |
4621 | void DomRectF::setElementX(double a) |
4622 | { |
4623 | m_children |= X; |
4624 | m_x = a; |
4625 | } |
4626 | |
4627 | void DomRectF::setElementY(double a) |
4628 | { |
4629 | m_children |= Y; |
4630 | m_y = a; |
4631 | } |
4632 | |
4633 | void DomRectF::setElementWidth(double a) |
4634 | { |
4635 | m_children |= Width; |
4636 | m_width = a; |
4637 | } |
4638 | |
4639 | void DomRectF::setElementHeight(double a) |
4640 | { |
4641 | m_children |= Height; |
4642 | m_height = a; |
4643 | } |
4644 | |
4645 | void DomRectF::clearElementX() |
4646 | { |
4647 | m_children &= ~X; |
4648 | } |
4649 | |
4650 | void DomRectF::clearElementY() |
4651 | { |
4652 | m_children &= ~Y; |
4653 | } |
4654 | |
4655 | void DomRectF::clearElementWidth() |
4656 | { |
4657 | m_children &= ~Width; |
4658 | } |
4659 | |
4660 | void DomRectF::clearElementHeight() |
4661 | { |
4662 | m_children &= ~Height; |
4663 | } |
4664 | |
4665 | DomSizeF::~DomSizeF() = default; |
4666 | |
4667 | void DomSizeF::read(QXmlStreamReader &reader) |
4668 | { |
4669 | while (!reader.hasError()) { |
4670 | switch (reader.readNext()) { |
4671 | case QXmlStreamReader::StartElement : { |
4672 | const auto tag = reader.name(); |
4673 | if (!tag.compare(other: u"width"_s , cs: Qt::CaseInsensitive)) { |
4674 | setElementWidth(reader.readElementText().toDouble()); |
4675 | continue; |
4676 | } |
4677 | if (!tag.compare(other: u"height"_s , cs: Qt::CaseInsensitive)) { |
4678 | setElementHeight(reader.readElementText().toDouble()); |
4679 | continue; |
4680 | } |
4681 | reader.raiseError(message: "Unexpected element "_L1 + tag); |
4682 | } |
4683 | break; |
4684 | case QXmlStreamReader::EndElement : |
4685 | return; |
4686 | default : |
4687 | break; |
4688 | } |
4689 | } |
4690 | } |
4691 | |
4692 | void DomSizeF::write(QXmlStreamWriter &writer, const QString &tagName) const |
4693 | { |
4694 | writer.writeStartElement(qualifiedName: tagName.isEmpty() ? QStringLiteral("sizef" ) : tagName.toLower()); |
4695 | |
4696 | if (m_children & Width) |
4697 | writer.writeTextElement(qualifiedName: u"width"_s , text: QString::number(m_width, format: 'f', precision: 15)); |
4698 | |
4699 | if (m_children & Height) |
4700 | writer.writeTextElement(qualifiedName: u"height"_s , text: QString::number(m_height, format: 'f', precision: 15)); |
4701 | |
4702 | writer.writeEndElement(); |
4703 | } |
4704 | |
4705 | void DomSizeF::setElementWidth(double a) |
4706 | { |
4707 | m_children |= Width; |
4708 | m_width = a; |
4709 | } |
4710 | |
4711 | void DomSizeF::setElementHeight(double a) |
4712 | { |
4713 | m_children |= Height; |
4714 | m_height = a; |
4715 | } |
4716 | |
4717 | void DomSizeF::clearElementWidth() |
4718 | { |
4719 | m_children &= ~Width; |
4720 | } |
4721 | |
4722 | void DomSizeF::clearElementHeight() |
4723 | { |
4724 | m_children &= ~Height; |
4725 | } |
4726 | |
4727 | DomChar::~DomChar() = default; |
4728 | |
4729 | void DomChar::read(QXmlStreamReader &reader) |
4730 | { |
4731 | while (!reader.hasError()) { |
4732 | switch (reader.readNext()) { |
4733 | case QXmlStreamReader::StartElement : { |
4734 | const auto tag = reader.name(); |
4735 | if (!tag.compare(other: u"unicode"_s , cs: Qt::CaseInsensitive)) { |
4736 | setElementUnicode(reader.readElementText().toInt()); |
4737 | continue; |
4738 | } |
4739 | reader.raiseError(message: "Unexpected element "_L1 + tag); |
4740 | } |
4741 | break; |
4742 | case QXmlStreamReader::EndElement : |
4743 | return; |
4744 | default : |
4745 | break; |
4746 | } |
4747 | } |
4748 | } |
4749 | |
4750 | void DomChar::write(QXmlStreamWriter &writer, const QString &tagName) const |
4751 | { |
4752 | writer.writeStartElement(qualifiedName: tagName.isEmpty() ? QStringLiteral("char" ) : tagName.toLower()); |
4753 | |
4754 | if (m_children & Unicode) |
4755 | writer.writeTextElement(qualifiedName: u"unicode"_s , text: QString::number(m_unicode)); |
4756 | |
4757 | writer.writeEndElement(); |
4758 | } |
4759 | |
4760 | void DomChar::setElementUnicode(int a) |
4761 | { |
4762 | m_children |= Unicode; |
4763 | m_unicode = a; |
4764 | } |
4765 | |
4766 | void DomChar::clearElementUnicode() |
4767 | { |
4768 | m_children &= ~Unicode; |
4769 | } |
4770 | |
4771 | DomUrl::~DomUrl() |
4772 | { |
4773 | delete m_string; |
4774 | } |
4775 | |
4776 | void DomUrl::read(QXmlStreamReader &reader) |
4777 | { |
4778 | while (!reader.hasError()) { |
4779 | switch (reader.readNext()) { |
4780 | case QXmlStreamReader::StartElement : { |
4781 | const auto tag = reader.name(); |
4782 | if (!tag.compare(other: u"string"_s , cs: Qt::CaseInsensitive)) { |
4783 | auto *v = new DomString(); |
4784 | v->read(reader); |
4785 | setElementString(v); |
4786 | continue; |
4787 | } |
4788 | reader.raiseError(message: "Unexpected element "_L1 + tag); |
4789 | } |
4790 | break; |
4791 | case QXmlStreamReader::EndElement : |
4792 | return; |
4793 | default : |
4794 | break; |
4795 | } |
4796 | } |
4797 | } |
4798 | |
4799 | void DomUrl::write(QXmlStreamWriter &writer, const QString &tagName) const |
4800 | { |
4801 | writer.writeStartElement(qualifiedName: tagName.isEmpty() ? QStringLiteral("url" ) : tagName.toLower()); |
4802 | |
4803 | if (m_children & String) |
4804 | m_string->write(writer, tagName: u"string"_s ); |
4805 | |
4806 | writer.writeEndElement(); |
4807 | } |
4808 | |
4809 | DomString *DomUrl::takeElementString() |
4810 | { |
4811 | DomString *a = m_string; |
4812 | m_string = nullptr; |
4813 | m_children ^= String; |
4814 | return a; |
4815 | } |
4816 | |
4817 | void DomUrl::setElementString(DomString *a) |
4818 | { |
4819 | delete m_string; |
4820 | m_children |= String; |
4821 | m_string = a; |
4822 | } |
4823 | |
4824 | void DomUrl::clearElementString() |
4825 | { |
4826 | delete m_string; |
4827 | m_string = nullptr; |
4828 | m_children &= ~String; |
4829 | } |
4830 | |
4831 | DomProperty::~DomProperty() |
4832 | { |
4833 | delete m_color; |
4834 | delete m_font; |
4835 | delete m_iconSet; |
4836 | delete m_pixmap; |
4837 | delete m_palette; |
4838 | delete m_point; |
4839 | delete m_rect; |
4840 | delete m_locale; |
4841 | delete m_sizePolicy; |
4842 | delete m_size; |
4843 | delete m_string; |
4844 | delete m_stringList; |
4845 | delete m_date; |
4846 | delete m_time; |
4847 | delete m_dateTime; |
4848 | delete m_pointF; |
4849 | delete m_rectF; |
4850 | delete m_sizeF; |
4851 | delete m_char; |
4852 | delete m_url; |
4853 | delete m_brush; |
4854 | } |
4855 | |
4856 | void DomProperty::clear() |
4857 | { |
4858 | delete m_color; |
4859 | delete m_font; |
4860 | delete m_iconSet; |
4861 | delete m_pixmap; |
4862 | delete m_palette; |
4863 | delete m_point; |
4864 | delete m_rect; |
4865 | delete m_locale; |
4866 | delete m_sizePolicy; |
4867 | delete m_size; |
4868 | delete m_string; |
4869 | delete m_stringList; |
4870 | delete m_date; |
4871 | delete m_time; |
4872 | delete m_dateTime; |
4873 | delete m_pointF; |
4874 | delete m_rectF; |
4875 | delete m_sizeF; |
4876 | delete m_char; |
4877 | delete m_url; |
4878 | delete m_brush; |
4879 | |
4880 | m_kind = Unknown; |
4881 | |
4882 | m_color = nullptr; |
4883 | m_cursor = 0; |
4884 | m_font = nullptr; |
4885 | m_iconSet = nullptr; |
4886 | m_pixmap = nullptr; |
4887 | m_palette = nullptr; |
4888 | m_point = nullptr; |
4889 | m_rect = nullptr; |
4890 | m_locale = nullptr; |
4891 | m_sizePolicy = nullptr; |
4892 | m_size = nullptr; |
4893 | m_string = nullptr; |
4894 | m_stringList = nullptr; |
4895 | m_number = 0; |
4896 | m_float = 0.0; |
4897 | m_double = 0.0; |
4898 | m_date = nullptr; |
4899 | m_time = nullptr; |
4900 | m_dateTime = nullptr; |
4901 | m_pointF = nullptr; |
4902 | m_rectF = nullptr; |
4903 | m_sizeF = nullptr; |
4904 | m_longLong = 0; |
4905 | m_char = nullptr; |
4906 | m_url = nullptr; |
4907 | m_UInt = 0; |
4908 | m_uLongLong = 0; |
4909 | m_brush = nullptr; |
4910 | } |
4911 | |
4912 | void DomProperty::read(QXmlStreamReader &reader) |
4913 | { |
4914 | const QXmlStreamAttributes &attributes = reader.attributes(); |
4915 | for (const QXmlStreamAttribute &attribute : attributes) { |
4916 | const auto name = attribute.name(); |
4917 | if (name == u"name"_s ) { |
4918 | setAttributeName(attribute.value().toString()); |
4919 | continue; |
4920 | } |
4921 | if (name == u"stdset"_s ) { |
4922 | setAttributeStdset(attribute.value().toInt()); |
4923 | continue; |
4924 | } |
4925 | reader.raiseError(message: "Unexpected attribute "_L1 + name); |
4926 | } |
4927 | |
4928 | while (!reader.hasError()) { |
4929 | switch (reader.readNext()) { |
4930 | case QXmlStreamReader::StartElement : { |
4931 | const auto tag = reader.name(); |
4932 | if (!tag.compare(other: u"bool"_s , cs: Qt::CaseInsensitive)) { |
4933 | setElementBool(reader.readElementText()); |
4934 | continue; |
4935 | } |
4936 | if (!tag.compare(other: u"color"_s , cs: Qt::CaseInsensitive)) { |
4937 | auto *v = new DomColor(); |
4938 | v->read(reader); |
4939 | setElementColor(v); |
4940 | continue; |
4941 | } |
4942 | if (!tag.compare(other: u"cstring"_s , cs: Qt::CaseInsensitive)) { |
4943 | setElementCstring(reader.readElementText()); |
4944 | continue; |
4945 | } |
4946 | if (!tag.compare(other: u"cursor"_s , cs: Qt::CaseInsensitive)) { |
4947 | setElementCursor(reader.readElementText().toInt()); |
4948 | continue; |
4949 | } |
4950 | if (!tag.compare(other: u"cursorshape"_s , cs: Qt::CaseInsensitive)) { |
4951 | setElementCursorShape(reader.readElementText()); |
4952 | continue; |
4953 | } |
4954 | if (!tag.compare(other: u"enum"_s , cs: Qt::CaseInsensitive)) { |
4955 | setElementEnum(reader.readElementText()); |
4956 | continue; |
4957 | } |
4958 | if (!tag.compare(other: u"font"_s , cs: Qt::CaseInsensitive)) { |
4959 | auto *v = new DomFont(); |
4960 | v->read(reader); |
4961 | setElementFont(v); |
4962 | continue; |
4963 | } |
4964 | if (!tag.compare(other: u"iconset"_s , cs: Qt::CaseInsensitive)) { |
4965 | auto *v = new DomResourceIcon(); |
4966 | v->read(reader); |
4967 | setElementIconSet(v); |
4968 | continue; |
4969 | } |
4970 | if (!tag.compare(other: u"pixmap"_s , cs: Qt::CaseInsensitive)) { |
4971 | auto *v = new DomResourcePixmap(); |
4972 | v->read(reader); |
4973 | setElementPixmap(v); |
4974 | continue; |
4975 | } |
4976 | if (!tag.compare(other: u"palette"_s , cs: Qt::CaseInsensitive)) { |
4977 | auto *v = new DomPalette(); |
4978 | v->read(reader); |
4979 | setElementPalette(v); |
4980 | continue; |
4981 | } |
4982 | if (!tag.compare(other: u"point"_s , cs: Qt::CaseInsensitive)) { |
4983 | auto *v = new DomPoint(); |
4984 | v->read(reader); |
4985 | setElementPoint(v); |
4986 | continue; |
4987 | } |
4988 | if (!tag.compare(other: u"rect"_s , cs: Qt::CaseInsensitive)) { |
4989 | auto *v = new DomRect(); |
4990 | v->read(reader); |
4991 | setElementRect(v); |
4992 | continue; |
4993 | } |
4994 | if (!tag.compare(other: u"set"_s , cs: Qt::CaseInsensitive)) { |
4995 | setElementSet(reader.readElementText()); |
4996 | continue; |
4997 | } |
4998 | if (!tag.compare(other: u"locale"_s , cs: Qt::CaseInsensitive)) { |
4999 | auto *v = new DomLocale(); |
5000 | v->read(reader); |
5001 | setElementLocale(v); |
5002 | continue; |
5003 | } |
5004 | if (!tag.compare(other: u"sizepolicy"_s , cs: Qt::CaseInsensitive)) { |
5005 | auto *v = new DomSizePolicy(); |
5006 | v->read(reader); |
5007 | setElementSizePolicy(v); |
5008 | continue; |
5009 | } |
5010 | if (!tag.compare(other: u"size"_s , cs: Qt::CaseInsensitive)) { |
5011 | auto *v = new DomSize(); |
5012 | v->read(reader); |
5013 | setElementSize(v); |
5014 | continue; |
5015 | } |
5016 | if (!tag.compare(other: u"string"_s , cs: Qt::CaseInsensitive)) { |
5017 | auto *v = new DomString(); |
5018 | v->read(reader); |
5019 | setElementString(v); |
5020 | continue; |
5021 | } |
5022 | if (!tag.compare(other: u"stringlist"_s , cs: Qt::CaseInsensitive)) { |
5023 | auto *v = new DomStringList(); |
5024 | v->read(reader); |
5025 | setElementStringList(v); |
5026 | continue; |
5027 | } |
5028 | if (!tag.compare(other: u"number"_s , cs: Qt::CaseInsensitive)) { |
5029 | setElementNumber(reader.readElementText().toInt()); |
5030 | continue; |
5031 | } |
5032 | if (!tag.compare(other: u"float"_s , cs: Qt::CaseInsensitive)) { |
5033 | setElementFloat(reader.readElementText().toFloat()); |
5034 | continue; |
5035 | } |
5036 | if (!tag.compare(other: u"double"_s , cs: Qt::CaseInsensitive)) { |
5037 | setElementDouble(reader.readElementText().toDouble()); |
5038 | continue; |
5039 | } |
5040 | if (!tag.compare(other: u"date"_s , cs: Qt::CaseInsensitive)) { |
5041 | auto *v = new DomDate(); |
5042 | v->read(reader); |
5043 | setElementDate(v); |
5044 | continue; |
5045 | } |
5046 | if (!tag.compare(other: u"time"_s , cs: Qt::CaseInsensitive)) { |
5047 | auto *v = new DomTime(); |
5048 | v->read(reader); |
5049 | setElementTime(v); |
5050 | continue; |
5051 | } |
5052 | if (!tag.compare(other: u"datetime"_s , cs: Qt::CaseInsensitive)) { |
5053 | auto *v = new DomDateTime(); |
5054 | v->read(reader); |
5055 | setElementDateTime(v); |
5056 | continue; |
5057 | } |
5058 | if (!tag.compare(other: u"pointf"_s , cs: Qt::CaseInsensitive)) { |
5059 | auto *v = new DomPointF(); |
5060 | v->read(reader); |
5061 | setElementPointF(v); |
5062 | continue; |
5063 | } |
5064 | if (!tag.compare(other: u"rectf"_s , cs: Qt::CaseInsensitive)) { |
5065 | auto *v = new DomRectF(); |
5066 | v->read(reader); |
5067 | setElementRectF(v); |
5068 | continue; |
5069 | } |
5070 | if (!tag.compare(other: u"sizef"_s , cs: Qt::CaseInsensitive)) { |
5071 | auto *v = new DomSizeF(); |
5072 | v->read(reader); |
5073 | setElementSizeF(v); |
5074 | continue; |
5075 | } |
5076 | if (!tag.compare(other: u"longlong"_s , cs: Qt::CaseInsensitive)) { |
5077 | setElementLongLong(reader.readElementText().toLongLong()); |
5078 | continue; |
5079 | } |
5080 | if (!tag.compare(other: u"char"_s , cs: Qt::CaseInsensitive)) { |
5081 | auto *v = new DomChar(); |
5082 | v->read(reader); |
5083 | setElementChar(v); |
5084 | continue; |
5085 | } |
5086 | if (!tag.compare(other: u"url"_s , cs: Qt::CaseInsensitive)) { |
5087 | auto *v = new DomUrl(); |
5088 | v->read(reader); |
5089 | setElementUrl(v); |
5090 | continue; |
5091 | } |
5092 | if (!tag.compare(other: u"uint"_s , cs: Qt::CaseInsensitive)) { |
5093 | setElementUInt(reader.readElementText().toUInt()); |
5094 | continue; |
5095 | } |
5096 | if (!tag.compare(other: u"ulonglong"_s , cs: Qt::CaseInsensitive)) { |
5097 | setElementULongLong(reader.readElementText().toULongLong()); |
5098 | continue; |
5099 | } |
5100 | if (!tag.compare(other: u"brush"_s , cs: Qt::CaseInsensitive)) { |
5101 | auto *v = new DomBrush(); |
5102 | v->read(reader); |
5103 | setElementBrush(v); |
5104 | continue; |
5105 | } |
5106 | reader.raiseError(message: "Unexpected element "_L1 + tag); |
5107 | } |
5108 | break; |
5109 | case QXmlStreamReader::EndElement : |
5110 | return; |
5111 | default : |
5112 | break; |
5113 | } |
5114 | } |
5115 | } |
5116 | |
5117 | void DomProperty::write(QXmlStreamWriter &writer, const QString &tagName) const |
5118 | { |
5119 | writer.writeStartElement(qualifiedName: tagName.isEmpty() ? QStringLiteral("property" ) : tagName.toLower()); |
5120 | |
5121 | if (hasAttributeName()) |
5122 | writer.writeAttribute(qualifiedName: u"name"_s , value: attributeName()); |
5123 | |
5124 | if (hasAttributeStdset()) |
5125 | writer.writeAttribute(qualifiedName: u"stdset"_s , value: QString::number(attributeStdset())); |
5126 | |
5127 | switch (kind()) { |
5128 | case Bool: |
5129 | writer.writeTextElement(qualifiedName: u"bool"_s , text: elementBool()); |
5130 | break; |
5131 | |
5132 | case Color: |
5133 | if (m_color != nullptr) |
5134 | m_color->write(writer, tagName: u"color"_s ); |
5135 | break; |
5136 | |
5137 | case Cstring: |
5138 | writer.writeTextElement(qualifiedName: u"cstring"_s , text: elementCstring()); |
5139 | break; |
5140 | |
5141 | case Cursor: |
5142 | writer.writeTextElement(qualifiedName: u"cursor"_s , text: QString::number(elementCursor())); |
5143 | break; |
5144 | |
5145 | case CursorShape: |
5146 | writer.writeTextElement(qualifiedName: u"cursorShape"_s , text: elementCursorShape()); |
5147 | break; |
5148 | |
5149 | case Enum: |
5150 | writer.writeTextElement(qualifiedName: u"enum"_s , text: elementEnum()); |
5151 | break; |
5152 | |
5153 | case Font: |
5154 | if (m_font != nullptr) |
5155 | m_font->write(writer, tagName: u"font"_s ); |
5156 | break; |
5157 | |
5158 | case IconSet: |
5159 | if (m_iconSet != nullptr) |
5160 | m_iconSet->write(writer, tagName: u"iconset"_s ); |
5161 | break; |
5162 | |
5163 | case Pixmap: |
5164 | if (m_pixmap != nullptr) |
5165 | m_pixmap->write(writer, tagName: u"pixmap"_s ); |
5166 | break; |
5167 | |
5168 | case Palette: |
5169 | if (m_palette != nullptr) |
5170 | m_palette->write(writer, tagName: u"palette"_s ); |
5171 | break; |
5172 | |
5173 | case Point: |
5174 | if (m_point != nullptr) |
5175 | m_point->write(writer, tagName: u"point"_s ); |
5176 | break; |
5177 | |
5178 | case Rect: |
5179 | if (m_rect != nullptr) |
5180 | m_rect->write(writer, tagName: u"rect"_s ); |
5181 | break; |
5182 | |
5183 | case Set: |
5184 | writer.writeTextElement(qualifiedName: u"set"_s , text: elementSet()); |
5185 | break; |
5186 | |
5187 | case Locale: |
5188 | if (m_locale != nullptr) |
5189 | m_locale->write(writer, tagName: u"locale"_s ); |
5190 | break; |
5191 | |
5192 | case SizePolicy: |
5193 | if (m_sizePolicy != nullptr) |
5194 | m_sizePolicy->write(writer, tagName: u"sizepolicy"_s ); |
5195 | break; |
5196 | |
5197 | case Size: |
5198 | if (m_size != nullptr) |
5199 | m_size->write(writer, tagName: u"size"_s ); |
5200 | break; |
5201 | |
5202 | case String: |
5203 | if (m_string != nullptr) |
5204 | m_string->write(writer, tagName: u"string"_s ); |
5205 | break; |
5206 | |
5207 | case StringList: |
5208 | if (m_stringList != nullptr) |
5209 | m_stringList->write(writer, tagName: u"stringlist"_s ); |
5210 | break; |
5211 | |
5212 | case Number: |
5213 | writer.writeTextElement(qualifiedName: u"number"_s , text: QString::number(elementNumber())); |
5214 | break; |
5215 | |
5216 | case Float: |
5217 | writer.writeTextElement(qualifiedName: u"float"_s , text: QString::number(elementFloat(), format: 'f', precision: 8)); |
5218 | break; |
5219 | |
5220 | case Double: |
5221 | writer.writeTextElement(qualifiedName: u"double"_s , text: QString::number(elementDouble(), format: 'f', precision: 15)); |
5222 | break; |
5223 | |
5224 | case Date: |
5225 | if (m_date != nullptr) |
5226 | m_date->write(writer, tagName: u"date"_s ); |
5227 | break; |
5228 | |
5229 | case Time: |
5230 | if (m_time != nullptr) |
5231 | m_time->write(writer, tagName: u"time"_s ); |
5232 | break; |
5233 | |
5234 | case DateTime: |
5235 | if (m_dateTime != nullptr) |
5236 | m_dateTime->write(writer, tagName: u"datetime"_s ); |
5237 | break; |
5238 | |
5239 | case PointF: |
5240 | if (m_pointF != nullptr) |
5241 | m_pointF->write(writer, tagName: u"pointf"_s ); |
5242 | break; |
5243 | |
5244 | case RectF: |
5245 | if (m_rectF != nullptr) |
5246 | m_rectF->write(writer, tagName: u"rectf"_s ); |
5247 | break; |
5248 | |
5249 | case SizeF: |
5250 | if (m_sizeF != nullptr) |
5251 | m_sizeF->write(writer, tagName: u"sizef"_s ); |
5252 | break; |
5253 | |
5254 | case LongLong: |
5255 | writer.writeTextElement(qualifiedName: u"longLong"_s , text: QString::number(elementLongLong())); |
5256 | break; |
5257 | |
5258 | case Char: |
5259 | if (m_char != nullptr) |
5260 | m_char->write(writer, tagName: u"char"_s ); |
5261 | break; |
5262 | |
5263 | case Url: |
5264 | if (m_url != nullptr) |
5265 | m_url->write(writer, tagName: u"url"_s ); |
5266 | break; |
5267 | |
5268 | case UInt: |
5269 | writer.writeTextElement(qualifiedName: u"UInt"_s , text: QString::number(elementUInt())); |
5270 | break; |
5271 | |
5272 | case ULongLong: |
5273 | writer.writeTextElement(qualifiedName: u"uLongLong"_s , text: QString::number(elementULongLong())); |
5274 | break; |
5275 | |
5276 | case Brush: |
5277 | if (m_brush != nullptr) |
5278 | m_brush->write(writer, tagName: u"brush"_s ); |
5279 | break; |
5280 | |
5281 | default: |
5282 | break; |
5283 | } |
5284 | writer.writeEndElement(); |
5285 | } |
5286 | |
5287 | void DomProperty::setElementBool(const QString &a) |
5288 | { |
5289 | clear(); |
5290 | m_kind = Bool; |
5291 | m_bool = a; |
5292 | } |
5293 | |
5294 | DomColor *DomProperty::takeElementColor() |
5295 | { |
5296 | DomColor *a = m_color; |
5297 | m_color = nullptr; |
5298 | return a; |
5299 | } |
5300 | |
5301 | void DomProperty::setElementColor(DomColor *a) |
5302 | { |
5303 | clear(); |
5304 | m_kind = Color; |
5305 | m_color = a; |
5306 | } |
5307 | |
5308 | void DomProperty::setElementCstring(const QString &a) |
5309 | { |
5310 | clear(); |
5311 | m_kind = Cstring; |
5312 | m_cstring = a; |
5313 | } |
5314 | |
5315 | void DomProperty::setElementCursor(int a) |
5316 | { |
5317 | clear(); |
5318 | m_kind = Cursor; |
5319 | m_cursor = a; |
5320 | } |
5321 | |
5322 | void DomProperty::setElementCursorShape(const QString &a) |
5323 | { |
5324 | clear(); |
5325 | m_kind = CursorShape; |
5326 | m_cursorShape = a; |
5327 | } |
5328 | |
5329 | void DomProperty::setElementEnum(const QString &a) |
5330 | { |
5331 | clear(); |
5332 | m_kind = Enum; |
5333 | m_enum = a; |
5334 | } |
5335 | |
5336 | DomFont *DomProperty::takeElementFont() |
5337 | { |
5338 | DomFont *a = m_font; |
5339 | m_font = nullptr; |
5340 | return a; |
5341 | } |
5342 | |
5343 | void DomProperty::setElementFont(DomFont *a) |
5344 | { |
5345 | clear(); |
5346 | m_kind = Font; |
5347 | m_font = a; |
5348 | } |
5349 | |
5350 | DomResourceIcon *DomProperty::takeElementIconSet() |
5351 | { |
5352 | DomResourceIcon *a = m_iconSet; |
5353 | m_iconSet = nullptr; |
5354 | return a; |
5355 | } |
5356 | |
5357 | void DomProperty::setElementIconSet(DomResourceIcon *a) |
5358 | { |
5359 | clear(); |
5360 | m_kind = IconSet; |
5361 | m_iconSet = a; |
5362 | } |
5363 | |
5364 | DomResourcePixmap *DomProperty::takeElementPixmap() |
5365 | { |
5366 | DomResourcePixmap *a = m_pixmap; |
5367 | m_pixmap = nullptr; |
5368 | return a; |
5369 | } |
5370 | |
5371 | void DomProperty::setElementPixmap(DomResourcePixmap *a) |
5372 | { |
5373 | clear(); |
5374 | m_kind = Pixmap; |
5375 | m_pixmap = a; |
5376 | } |
5377 | |
5378 | DomPalette *DomProperty::takeElementPalette() |
5379 | { |
5380 | DomPalette *a = m_palette; |
5381 | m_palette = nullptr; |
5382 | return a; |
5383 | } |
5384 | |
5385 | void DomProperty::setElementPalette(DomPalette *a) |
5386 | { |
5387 | clear(); |
5388 | m_kind = Palette; |
5389 | m_palette = a; |
5390 | } |
5391 | |
5392 | DomPoint *DomProperty::takeElementPoint() |
5393 | { |
5394 | DomPoint *a = m_point; |
5395 | m_point = nullptr; |
5396 | return a; |
5397 | } |
5398 | |
5399 | void DomProperty::setElementPoint(DomPoint *a) |
5400 | { |
5401 | clear(); |
5402 | m_kind = Point; |
5403 | m_point = a; |
5404 | } |
5405 | |
5406 | DomRect *DomProperty::takeElementRect() |
5407 | { |
5408 | DomRect *a = m_rect; |
5409 | m_rect = nullptr; |
5410 | return a; |
5411 | } |
5412 | |
5413 | void DomProperty::setElementRect(DomRect *a) |
5414 | { |
5415 | clear(); |
5416 | m_kind = Rect; |
5417 | m_rect = a; |
5418 | } |
5419 | |
5420 | void DomProperty::setElementSet(const QString &a) |
5421 | { |
5422 | clear(); |
5423 | m_kind = Set; |
5424 | m_set = a; |
5425 | } |
5426 | |
5427 | DomLocale *DomProperty::takeElementLocale() |
5428 | { |
5429 | DomLocale *a = m_locale; |
5430 | m_locale = nullptr; |
5431 | return a; |
5432 | } |
5433 | |
5434 | void DomProperty::setElementLocale(DomLocale *a) |
5435 | { |
5436 | clear(); |
5437 | m_kind = Locale; |
5438 | m_locale = a; |
5439 | } |
5440 | |
5441 | DomSizePolicy *DomProperty::takeElementSizePolicy() |
5442 | { |
5443 | DomSizePolicy *a = m_sizePolicy; |
5444 | m_sizePolicy = nullptr; |
5445 | return a; |
5446 | } |
5447 | |
5448 | void DomProperty::setElementSizePolicy(DomSizePolicy *a) |
5449 | { |
5450 | clear(); |
5451 | m_kind = SizePolicy; |
5452 | m_sizePolicy = a; |
5453 | } |
5454 | |
5455 | DomSize *DomProperty::takeElementSize() |
5456 | { |
5457 | DomSize *a = m_size; |
5458 | m_size = nullptr; |
5459 | return a; |
5460 | } |
5461 | |
5462 | void DomProperty::setElementSize(DomSize *a) |
5463 | { |
5464 | clear(); |
5465 | m_kind = Size; |
5466 | m_size = a; |
5467 | } |
5468 | |
5469 | DomString *DomProperty::takeElementString() |
5470 | { |
5471 | DomString *a = m_string; |
5472 | m_string = nullptr; |
5473 | return a; |
5474 | } |
5475 | |
5476 | void DomProperty::setElementString(DomString *a) |
5477 | { |
5478 | clear(); |
5479 | m_kind = String; |
5480 | m_string = a; |
5481 | } |
5482 | |
5483 | DomStringList *DomProperty::takeElementStringList() |
5484 | { |
5485 | DomStringList *a = m_stringList; |
5486 | m_stringList = nullptr; |
5487 | return a; |
5488 | } |
5489 | |
5490 | void DomProperty::setElementStringList(DomStringList *a) |
5491 | { |
5492 | clear(); |
5493 | m_kind = StringList; |
5494 | m_stringList = a; |
5495 | } |
5496 | |
5497 | void DomProperty::setElementNumber(int a) |
5498 | { |
5499 | clear(); |
5500 | m_kind = Number; |
5501 | m_number = a; |
5502 | } |
5503 | |
5504 | void DomProperty::setElementFloat(float a) |
5505 | { |
5506 | clear(); |
5507 | m_kind = Float; |
5508 | m_float = a; |
5509 | } |
5510 | |
5511 | void DomProperty::setElementDouble(double a) |
5512 | { |
5513 | clear(); |
5514 | m_kind = Double; |
5515 | m_double = a; |
5516 | } |
5517 | |
5518 | DomDate *DomProperty::takeElementDate() |
5519 | { |
5520 | DomDate *a = m_date; |
5521 | m_date = nullptr; |
5522 | return a; |
5523 | } |
5524 | |
5525 | void DomProperty::setElementDate(DomDate *a) |
5526 | { |
5527 | clear(); |
5528 | m_kind = Date; |
5529 | m_date = a; |
5530 | } |
5531 | |
5532 | DomTime *DomProperty::takeElementTime() |
5533 | { |
5534 | DomTime *a = m_time; |
5535 | m_time = nullptr; |
5536 | return a; |
5537 | } |
5538 | |
5539 | void DomProperty::setElementTime(DomTime *a) |
5540 | { |
5541 | clear(); |
5542 | m_kind = Time; |
5543 | m_time = a; |
5544 | } |
5545 | |
5546 | DomDateTime *DomProperty::takeElementDateTime() |
5547 | { |
5548 | DomDateTime *a = m_dateTime; |
5549 | m_dateTime = nullptr; |
5550 | return a; |
5551 | } |
5552 | |
5553 | void DomProperty::setElementDateTime(DomDateTime *a) |
5554 | { |
5555 | clear(); |
5556 | m_kind = DateTime; |
5557 | m_dateTime = a; |
5558 | } |
5559 | |
5560 | DomPointF *DomProperty::takeElementPointF() |
5561 | { |
5562 | DomPointF *a = m_pointF; |
5563 | m_pointF = nullptr; |
5564 | return a; |
5565 | } |
5566 | |
5567 | void DomProperty::setElementPointF(DomPointF *a) |
5568 | { |
5569 | clear(); |
5570 | m_kind = PointF; |
5571 | m_pointF = a; |
5572 | } |
5573 | |
5574 | DomRectF *DomProperty::takeElementRectF() |
5575 | { |
5576 | DomRectF *a = m_rectF; |
5577 | m_rectF = nullptr; |
5578 | return a; |
5579 | } |
5580 | |
5581 | void DomProperty::setElementRectF(DomRectF *a) |
5582 | { |
5583 | clear(); |
5584 | m_kind = RectF; |
5585 | m_rectF = a; |
5586 | } |
5587 | |
5588 | DomSizeF *DomProperty::takeElementSizeF() |
5589 | { |
5590 | DomSizeF *a = m_sizeF; |
5591 | m_sizeF = nullptr; |
5592 | return a; |
5593 | } |
5594 | |
5595 | void DomProperty::setElementSizeF(DomSizeF *a) |
5596 | { |
5597 | clear(); |
5598 | m_kind = SizeF; |
5599 | m_sizeF = a; |
5600 | } |
5601 | |
5602 | void DomProperty::setElementLongLong(qlonglong a) |
5603 | { |
5604 | clear(); |
5605 | m_kind = LongLong; |
5606 | m_longLong = a; |
5607 | } |
5608 | |
5609 | DomChar *DomProperty::takeElementChar() |
5610 | { |
5611 | DomChar *a = m_char; |
5612 | m_char = nullptr; |
5613 | return a; |
5614 | } |
5615 | |
5616 | void DomProperty::setElementChar(DomChar *a) |
5617 | { |
5618 | clear(); |
5619 | m_kind = Char; |
5620 | m_char = a; |
5621 | } |
5622 | |
5623 | DomUrl *DomProperty::takeElementUrl() |
5624 | { |
5625 | DomUrl *a = m_url; |
5626 | m_url = nullptr; |
5627 | return a; |
5628 | } |
5629 | |
5630 | void DomProperty::setElementUrl(DomUrl *a) |
5631 | { |
5632 | clear(); |
5633 | m_kind = Url; |
5634 | m_url = a; |
5635 | } |
5636 | |
5637 | void DomProperty::setElementUInt(uint a) |
5638 | { |
5639 | clear(); |
5640 | m_kind = UInt; |
5641 | m_UInt = a; |
5642 | } |
5643 | |
5644 | void DomProperty::setElementULongLong(qulonglong a) |
5645 | { |
5646 | clear(); |
5647 | m_kind = ULongLong; |
5648 | m_uLongLong = a; |
5649 | } |
5650 | |
5651 | DomBrush *DomProperty::takeElementBrush() |
5652 | { |
5653 | DomBrush *a = m_brush; |
5654 | m_brush = nullptr; |
5655 | return a; |
5656 | } |
5657 | |
5658 | void DomProperty::setElementBrush(DomBrush *a) |
5659 | { |
5660 | clear(); |
5661 | m_kind = Brush; |
5662 | m_brush = a; |
5663 | } |
5664 | |
5665 | DomConnections::~DomConnections() |
5666 | { |
5667 | qDeleteAll(c: m_connection); |
5668 | m_connection.clear(); |
5669 | } |
5670 | |
5671 | void DomConnections::read(QXmlStreamReader &reader) |
5672 | { |
5673 | while (!reader.hasError()) { |
5674 | switch (reader.readNext()) { |
5675 | case QXmlStreamReader::StartElement : { |
5676 | const auto tag = reader.name(); |
5677 | if (!tag.compare(other: u"connection"_s , cs: Qt::CaseInsensitive)) { |
5678 | auto *v = new DomConnection(); |
5679 | v->read(reader); |
5680 | m_connection.append(t: v); |
5681 | continue; |
5682 | } |
5683 | reader.raiseError(message: "Unexpected element "_L1 + tag); |
5684 | } |
5685 | break; |
5686 | case QXmlStreamReader::EndElement : |
5687 | return; |
5688 | default : |
5689 | break; |
5690 | } |
5691 | } |
5692 | } |
5693 | |
5694 | void DomConnections::write(QXmlStreamWriter &writer, const QString &tagName) const |
5695 | { |
5696 | writer.writeStartElement(qualifiedName: tagName.isEmpty() ? QStringLiteral("connections" ) : tagName.toLower()); |
5697 | |
5698 | for (DomConnection *v : m_connection) |
5699 | v->write(writer, tagName: u"connection"_s ); |
5700 | |
5701 | writer.writeEndElement(); |
5702 | } |
5703 | |
5704 | void DomConnections::setElementConnection(const QList<DomConnection *> &a) |
5705 | { |
5706 | m_children |= Connection; |
5707 | m_connection = a; |
5708 | } |
5709 | |
5710 | DomConnection::~DomConnection() |
5711 | { |
5712 | delete m_hints; |
5713 | } |
5714 | |
5715 | void DomConnection::read(QXmlStreamReader &reader) |
5716 | { |
5717 | while (!reader.hasError()) { |
5718 | switch (reader.readNext()) { |
5719 | case QXmlStreamReader::StartElement : { |
5720 | const auto tag = reader.name(); |
5721 | if (!tag.compare(other: u"sender"_s , cs: Qt::CaseInsensitive)) { |
5722 | setElementSender(reader.readElementText()); |
5723 | continue; |
5724 | } |
5725 | if (!tag.compare(other: u"signal"_s , cs: Qt::CaseInsensitive)) { |
5726 | setElementSignal(reader.readElementText()); |
5727 | continue; |
5728 | } |
5729 | if (!tag.compare(other: u"receiver"_s , cs: Qt::CaseInsensitive)) { |
5730 | setElementReceiver(reader.readElementText()); |
5731 | continue; |
5732 | } |
5733 | if (!tag.compare(other: u"slot"_s , cs: Qt::CaseInsensitive)) { |
5734 | setElementSlot(reader.readElementText()); |
5735 | continue; |
5736 | } |
5737 | if (!tag.compare(other: u"hints"_s , cs: Qt::CaseInsensitive)) { |
5738 | auto *v = new DomConnectionHints(); |
5739 | v->read(reader); |
5740 | setElementHints(v); |
5741 | continue; |
5742 | } |
5743 | reader.raiseError(message: "Unexpected element "_L1 + tag); |
5744 | } |
5745 | break; |
5746 | case QXmlStreamReader::EndElement : |
5747 | return; |
5748 | default : |
5749 | break; |
5750 | } |
5751 | } |
5752 | } |
5753 | |
5754 | void DomConnection::write(QXmlStreamWriter &writer, const QString &tagName) const |
5755 | { |
5756 | writer.writeStartElement(qualifiedName: tagName.isEmpty() ? QStringLiteral("connection" ) : tagName.toLower()); |
5757 | |
5758 | if (m_children & Sender) |
5759 | writer.writeTextElement(qualifiedName: u"sender"_s , text: m_sender); |
5760 | |
5761 | if (m_children & Signal) |
5762 | writer.writeTextElement(qualifiedName: u"signal"_s , text: m_signal); |
5763 | |
5764 | if (m_children & Receiver) |
5765 | writer.writeTextElement(qualifiedName: u"receiver"_s , text: m_receiver); |
5766 | |
5767 | if (m_children & Slot) |
5768 | writer.writeTextElement(qualifiedName: u"slot"_s , text: m_slot); |
5769 | |
5770 | if (m_children & Hints) |
5771 | m_hints->write(writer, tagName: u"hints"_s ); |
5772 | |
5773 | writer.writeEndElement(); |
5774 | } |
5775 | |
5776 | void DomConnection::setElementSender(const QString &a) |
5777 | { |
5778 | m_children |= Sender; |
5779 | m_sender = a; |
5780 | } |
5781 | |
5782 | void DomConnection::setElementSignal(const QString &a) |
5783 | { |
5784 | m_children |= Signal; |
5785 | m_signal = a; |
5786 | } |
5787 | |
5788 | void DomConnection::setElementReceiver(const QString &a) |
5789 | { |
5790 | m_children |= Receiver; |
5791 | m_receiver = a; |
5792 | } |
5793 | |
5794 | void DomConnection::setElementSlot(const QString &a) |
5795 | { |
5796 | m_children |= Slot; |
5797 | m_slot = a; |
5798 | } |
5799 | |
5800 | DomConnectionHints *DomConnection::takeElementHints() |
5801 | { |
5802 | DomConnectionHints *a = m_hints; |
5803 | m_hints = nullptr; |
5804 | m_children ^= Hints; |
5805 | return a; |
5806 | } |
5807 | |
5808 | void DomConnection::setElementHints(DomConnectionHints *a) |
5809 | { |
5810 | delete m_hints; |
5811 | m_children |= Hints; |
5812 | m_hints = a; |
5813 | } |
5814 | |
5815 | void DomConnection::clearElementSender() |
5816 | { |
5817 | m_children &= ~Sender; |
5818 | } |
5819 | |
5820 | void DomConnection::clearElementSignal() |
5821 | { |
5822 | m_children &= ~Signal; |
5823 | } |
5824 | |
5825 | void DomConnection::clearElementReceiver() |
5826 | { |
5827 | m_children &= ~Receiver; |
5828 | } |
5829 | |
5830 | void DomConnection::clearElementSlot() |
5831 | { |
5832 | m_children &= ~Slot; |
5833 | } |
5834 | |
5835 | void DomConnection::clearElementHints() |
5836 | { |
5837 | delete m_hints; |
5838 | m_hints = nullptr; |
5839 | m_children &= ~Hints; |
5840 | } |
5841 | |
5842 | DomConnectionHints::~DomConnectionHints() |
5843 | { |
5844 | qDeleteAll(c: m_hint); |
5845 | m_hint.clear(); |
5846 | } |
5847 | |
5848 | void DomConnectionHints::read(QXmlStreamReader &reader) |
5849 | { |
5850 | while (!reader.hasError()) { |
5851 | switch (reader.readNext()) { |
5852 | case QXmlStreamReader::StartElement : { |
5853 | const auto tag = reader.name(); |
5854 | if (!tag.compare(other: u"hint"_s , cs: Qt::CaseInsensitive)) { |
5855 | auto *v = new DomConnectionHint(); |
5856 | v->read(reader); |
5857 | m_hint.append(t: v); |
5858 | continue; |
5859 | } |
5860 | reader.raiseError(message: "Unexpected element "_L1 + tag); |
5861 | } |
5862 | break; |
5863 | case QXmlStreamReader::EndElement : |
5864 | return; |
5865 | default : |
5866 | break; |
5867 | } |
5868 | } |
5869 | } |
5870 | |
5871 | void DomConnectionHints::write(QXmlStreamWriter &writer, const QString &tagName) const |
5872 | { |
5873 | writer.writeStartElement(qualifiedName: tagName.isEmpty() ? QStringLiteral("connectionhints" ) : tagName.toLower()); |
5874 | |
5875 | for (DomConnectionHint *v : m_hint) |
5876 | v->write(writer, tagName: u"hint"_s ); |
5877 | |
5878 | writer.writeEndElement(); |
5879 | } |
5880 | |
5881 | void DomConnectionHints::setElementHint(const QList<DomConnectionHint *> &a) |
5882 | { |
5883 | m_children |= Hint; |
5884 | m_hint = a; |
5885 | } |
5886 | |
5887 | DomConnectionHint::~DomConnectionHint() = default; |
5888 | |
5889 | void DomConnectionHint::read(QXmlStreamReader &reader) |
5890 | { |
5891 | const QXmlStreamAttributes &attributes = reader.attributes(); |
5892 | for (const QXmlStreamAttribute &attribute : attributes) { |
5893 | const auto name = attribute.name(); |
5894 | if (name == u"type"_s ) { |
5895 | setAttributeType(attribute.value().toString()); |
5896 | continue; |
5897 | } |
5898 | reader.raiseError(message: "Unexpected attribute "_L1 + name); |
5899 | } |
5900 | |
5901 | while (!reader.hasError()) { |
5902 | switch (reader.readNext()) { |
5903 | case QXmlStreamReader::StartElement : { |
5904 | const auto tag = reader.name(); |
5905 | if (!tag.compare(other: u"x"_s , cs: Qt::CaseInsensitive)) { |
5906 | setElementX(reader.readElementText().toInt()); |
5907 | continue; |
5908 | } |
5909 | if (!tag.compare(other: u"y"_s , cs: Qt::CaseInsensitive)) { |
5910 | setElementY(reader.readElementText().toInt()); |
5911 | continue; |
5912 | } |
5913 | reader.raiseError(message: "Unexpected element "_L1 + tag); |
5914 | } |
5915 | break; |
5916 | case QXmlStreamReader::EndElement : |
5917 | return; |
5918 | default : |
5919 | break; |
5920 | } |
5921 | } |
5922 | } |
5923 | |
5924 | void DomConnectionHint::write(QXmlStreamWriter &writer, const QString &tagName) const |
5925 | { |
5926 | writer.writeStartElement(qualifiedName: tagName.isEmpty() ? QStringLiteral("connectionhint" ) : tagName.toLower()); |
5927 | |
5928 | if (hasAttributeType()) |
5929 | writer.writeAttribute(qualifiedName: u"type"_s , value: attributeType()); |
5930 | |
5931 | if (m_children & X) |
5932 | writer.writeTextElement(qualifiedName: u"x"_s , text: QString::number(m_x)); |
5933 | |
5934 | if (m_children & Y) |
5935 | writer.writeTextElement(qualifiedName: u"y"_s , text: QString::number(m_y)); |
5936 | |
5937 | writer.writeEndElement(); |
5938 | } |
5939 | |
5940 | void DomConnectionHint::setElementX(int a) |
5941 | { |
5942 | m_children |= X; |
5943 | m_x = a; |
5944 | } |
5945 | |
5946 | void DomConnectionHint::setElementY(int a) |
5947 | { |
5948 | m_children |= Y; |
5949 | m_y = a; |
5950 | } |
5951 | |
5952 | void DomConnectionHint::clearElementX() |
5953 | { |
5954 | m_children &= ~X; |
5955 | } |
5956 | |
5957 | void DomConnectionHint::clearElementY() |
5958 | { |
5959 | m_children &= ~Y; |
5960 | } |
5961 | |
5962 | DomDesignerData::~DomDesignerData() |
5963 | { |
5964 | qDeleteAll(c: m_property); |
5965 | m_property.clear(); |
5966 | } |
5967 | |
5968 | void DomDesignerData::read(QXmlStreamReader &reader) |
5969 | { |
5970 | while (!reader.hasError()) { |
5971 | switch (reader.readNext()) { |
5972 | case QXmlStreamReader::StartElement : { |
5973 | const auto tag = reader.name(); |
5974 | if (!tag.compare(other: u"property"_s , cs: Qt::CaseInsensitive)) { |
5975 | auto *v = new DomProperty(); |
5976 | v->read(reader); |
5977 | m_property.append(t: v); |
5978 | continue; |
5979 | } |
5980 | reader.raiseError(message: "Unexpected element "_L1 + tag); |
5981 | } |
5982 | break; |
5983 | case QXmlStreamReader::EndElement : |
5984 | return; |
5985 | default : |
5986 | break; |
5987 | } |
5988 | } |
5989 | } |
5990 | |
5991 | void DomDesignerData::write(QXmlStreamWriter &writer, const QString &tagName) const |
5992 | { |
5993 | writer.writeStartElement(qualifiedName: tagName.isEmpty() ? QStringLiteral("designerdata" ) : tagName.toLower()); |
5994 | |
5995 | for (DomProperty *v : m_property) |
5996 | v->write(writer, tagName: u"property"_s ); |
5997 | |
5998 | writer.writeEndElement(); |
5999 | } |
6000 | |
6001 | void DomDesignerData::setElementProperty(const QList<DomProperty *> &a) |
6002 | { |
6003 | m_children |= Property; |
6004 | m_property = a; |
6005 | } |
6006 | |
6007 | DomSlots::~DomSlots() |
6008 | { |
6009 | m_signal.clear(); |
6010 | m_slot.clear(); |
6011 | } |
6012 | |
6013 | void DomSlots::read(QXmlStreamReader &reader) |
6014 | { |
6015 | while (!reader.hasError()) { |
6016 | switch (reader.readNext()) { |
6017 | case QXmlStreamReader::StartElement : { |
6018 | const auto tag = reader.name(); |
6019 | if (!tag.compare(other: u"signal"_s , cs: Qt::CaseInsensitive)) { |
6020 | m_signal.append(t: reader.readElementText()); |
6021 | continue; |
6022 | } |
6023 | if (!tag.compare(other: u"slot"_s , cs: Qt::CaseInsensitive)) { |
6024 | m_slot.append(t: reader.readElementText()); |
6025 | continue; |
6026 | } |
6027 | reader.raiseError(message: "Unexpected element "_L1 + tag); |
6028 | } |
6029 | break; |
6030 | case QXmlStreamReader::EndElement : |
6031 | return; |
6032 | default : |
6033 | break; |
6034 | } |
6035 | } |
6036 | } |
6037 | |
6038 | void DomSlots::write(QXmlStreamWriter &writer, const QString &tagName) const |
6039 | { |
6040 | writer.writeStartElement(qualifiedName: tagName.isEmpty() ? QStringLiteral("slots" ) : tagName.toLower()); |
6041 | |
6042 | for (const QString &v : m_signal) |
6043 | writer.writeTextElement(qualifiedName: u"signal"_s , text: v); |
6044 | |
6045 | for (const QString &v : m_slot) |
6046 | writer.writeTextElement(qualifiedName: u"slot"_s , text: v); |
6047 | |
6048 | writer.writeEndElement(); |
6049 | } |
6050 | |
6051 | void DomSlots::setElementSignal(const QStringList &a) |
6052 | { |
6053 | m_children |= Signal; |
6054 | m_signal = a; |
6055 | } |
6056 | |
6057 | void DomSlots::setElementSlot(const QStringList &a) |
6058 | { |
6059 | m_children |= Slot; |
6060 | m_slot = a; |
6061 | } |
6062 | |
6063 | DomPropertySpecifications::~DomPropertySpecifications() |
6064 | { |
6065 | qDeleteAll(c: m_tooltip); |
6066 | m_tooltip.clear(); |
6067 | qDeleteAll(c: m_stringpropertyspecification); |
6068 | m_stringpropertyspecification.clear(); |
6069 | } |
6070 | |
6071 | void DomPropertySpecifications::read(QXmlStreamReader &reader) |
6072 | { |
6073 | while (!reader.hasError()) { |
6074 | switch (reader.readNext()) { |
6075 | case QXmlStreamReader::StartElement : { |
6076 | const auto tag = reader.name(); |
6077 | if (!tag.compare(other: u"tooltip"_s , cs: Qt::CaseInsensitive)) { |
6078 | auto *v = new DomPropertyToolTip(); |
6079 | v->read(reader); |
6080 | m_tooltip.append(t: v); |
6081 | continue; |
6082 | } |
6083 | if (!tag.compare(other: u"stringpropertyspecification"_s , cs: Qt::CaseInsensitive)) { |
6084 | auto *v = new DomStringPropertySpecification(); |
6085 | v->read(reader); |
6086 | m_stringpropertyspecification.append(t: v); |
6087 | continue; |
6088 | } |
6089 | reader.raiseError(message: "Unexpected element "_L1 + tag); |
6090 | } |
6091 | break; |
6092 | case QXmlStreamReader::EndElement : |
6093 | return; |
6094 | default : |
6095 | break; |
6096 | } |
6097 | } |
6098 | } |
6099 | |
6100 | void DomPropertySpecifications::write(QXmlStreamWriter &writer, const QString &tagName) const |
6101 | { |
6102 | writer.writeStartElement(qualifiedName: tagName.isEmpty() ? QStringLiteral("propertyspecifications" ) : tagName.toLower()); |
6103 | |
6104 | for (DomPropertyToolTip *v : m_tooltip) |
6105 | v->write(writer, tagName: u"tooltip"_s ); |
6106 | |
6107 | for (DomStringPropertySpecification *v : m_stringpropertyspecification) |
6108 | v->write(writer, tagName: u"stringpropertyspecification"_s ); |
6109 | |
6110 | writer.writeEndElement(); |
6111 | } |
6112 | |
6113 | void DomPropertySpecifications::setElementTooltip(const QList<DomPropertyToolTip *> &a) |
6114 | { |
6115 | m_children |= Tooltip; |
6116 | m_tooltip = a; |
6117 | } |
6118 | |
6119 | void DomPropertySpecifications::setElementStringpropertyspecification(const QList<DomStringPropertySpecification *> &a) |
6120 | { |
6121 | m_children |= Stringpropertyspecification; |
6122 | m_stringpropertyspecification = a; |
6123 | } |
6124 | |
6125 | DomPropertyToolTip::~DomPropertyToolTip() = default; |
6126 | |
6127 | void DomPropertyToolTip::read(QXmlStreamReader &reader) |
6128 | { |
6129 | const QXmlStreamAttributes &attributes = reader.attributes(); |
6130 | for (const QXmlStreamAttribute &attribute : attributes) { |
6131 | const auto name = attribute.name(); |
6132 | if (name == u"name"_s ) { |
6133 | setAttributeName(attribute.value().toString()); |
6134 | continue; |
6135 | } |
6136 | reader.raiseError(message: "Unexpected attribute "_L1 + name); |
6137 | } |
6138 | |
6139 | while (!reader.hasError()) { |
6140 | switch (reader.readNext()) { |
6141 | case QXmlStreamReader::StartElement : { |
6142 | const auto tag = reader.name(); |
6143 | reader.raiseError(message: "Unexpected element "_L1 + tag); |
6144 | } |
6145 | break; |
6146 | case QXmlStreamReader::EndElement : |
6147 | return; |
6148 | default : |
6149 | break; |
6150 | } |
6151 | } |
6152 | } |
6153 | |
6154 | void DomPropertyToolTip::write(QXmlStreamWriter &writer, const QString &tagName) const |
6155 | { |
6156 | writer.writeStartElement(qualifiedName: tagName.isEmpty() ? QStringLiteral("propertytooltip" ) : tagName.toLower()); |
6157 | |
6158 | if (hasAttributeName()) |
6159 | writer.writeAttribute(qualifiedName: u"name"_s , value: attributeName()); |
6160 | |
6161 | writer.writeEndElement(); |
6162 | } |
6163 | |
6164 | DomStringPropertySpecification::~DomStringPropertySpecification() = default; |
6165 | |
6166 | void DomStringPropertySpecification::read(QXmlStreamReader &reader) |
6167 | { |
6168 | const QXmlStreamAttributes &attributes = reader.attributes(); |
6169 | for (const QXmlStreamAttribute &attribute : attributes) { |
6170 | const auto name = attribute.name(); |
6171 | if (name == u"name"_s ) { |
6172 | setAttributeName(attribute.value().toString()); |
6173 | continue; |
6174 | } |
6175 | if (name == u"type"_s ) { |
6176 | setAttributeType(attribute.value().toString()); |
6177 | continue; |
6178 | } |
6179 | if (name == u"notr"_s ) { |
6180 | setAttributeNotr(attribute.value().toString()); |
6181 | continue; |
6182 | } |
6183 | reader.raiseError(message: "Unexpected attribute "_L1 + name); |
6184 | } |
6185 | |
6186 | while (!reader.hasError()) { |
6187 | switch (reader.readNext()) { |
6188 | case QXmlStreamReader::StartElement : { |
6189 | const auto tag = reader.name(); |
6190 | reader.raiseError(message: "Unexpected element "_L1 + tag); |
6191 | } |
6192 | break; |
6193 | case QXmlStreamReader::EndElement : |
6194 | return; |
6195 | default : |
6196 | break; |
6197 | } |
6198 | } |
6199 | } |
6200 | |
6201 | void DomStringPropertySpecification::write(QXmlStreamWriter &writer, const QString &tagName) const |
6202 | { |
6203 | writer.writeStartElement(qualifiedName: tagName.isEmpty() ? QStringLiteral("stringpropertyspecification" ) : tagName.toLower()); |
6204 | |
6205 | if (hasAttributeName()) |
6206 | writer.writeAttribute(qualifiedName: u"name"_s , value: attributeName()); |
6207 | |
6208 | if (hasAttributeType()) |
6209 | writer.writeAttribute(qualifiedName: u"type"_s , value: attributeType()); |
6210 | |
6211 | if (hasAttributeNotr()) |
6212 | writer.writeAttribute(qualifiedName: u"notr"_s , value: attributeNotr()); |
6213 | |
6214 | writer.writeEndElement(); |
6215 | } |
6216 | |
6217 | QT_END_NAMESPACE |
6218 | |
6219 | |