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