1 | /**************************************************************************** |
2 | ** |
3 | ** Copyright (C) 2020 The Qt Company Ltd. |
4 | ** Contact: https://www.qt.io/licensing/ |
5 | ** |
6 | ** This file is part of the tools applications of the Qt Toolkit. |
7 | ** |
8 | ** $QT_BEGIN_LICENSE:GPL-EXCEPT$ |
9 | ** Commercial License Usage |
10 | ** Licensees holding valid commercial Qt licenses may use this file in |
11 | ** accordance with the commercial license agreement provided with the |
12 | ** Software or, alternatively, in accordance with the terms contained in |
13 | ** a written agreement between you and The Qt Company. For licensing terms |
14 | ** and conditions see https://www.qt.io/terms-conditions. For further |
15 | ** information use the contact form at https://www.qt.io/contact-us. |
16 | ** |
17 | ** GNU General Public License Usage |
18 | ** Alternatively, this file may be used under the terms of the GNU |
19 | ** General Public License version 3 as published by the Free Software |
20 | ** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT |
21 | ** included in the packaging of this file. Please review the following |
22 | ** information to ensure the GNU General Public License requirements will |
23 | ** be met: https://www.gnu.org/licenses/gpl-3.0.html. |
24 | ** |
25 | ** $QT_END_LICENSE$ |
26 | ** |
27 | ****************************************************************************/ |
28 | |
29 | // THIS FILE IS AUTOMATICALLY GENERATED. DO NOT EDIT! |
30 | |
31 | #include "ui4.h" |
32 | |
33 | |
34 | QT_BEGIN_NAMESPACE |
35 | #ifdef QFORMINTERNAL_NAMESPACE |
36 | using namespace QFormInternal; |
37 | #endif |
38 | |
39 | /******************************************************************************* |
40 | ** Implementations |
41 | */ |
42 | |
43 | DomUI::~DomUI() |
44 | { |
45 | delete m_widget; |
46 | delete m_layoutDefault; |
47 | delete m_layoutFunction; |
48 | delete m_customWidgets; |
49 | delete m_tabStops; |
50 | delete m_includes; |
51 | delete m_resources; |
52 | delete m_connections; |
53 | delete m_designerdata; |
54 | delete m_slots; |
55 | delete m_buttonGroups; |
56 | } |
57 | |
58 | void DomUI::read(QXmlStreamReader &reader) |
59 | { |
60 | const QXmlStreamAttributes &attributes = reader.attributes(); |
61 | for (const QXmlStreamAttribute &attribute : attributes) { |
62 | const auto name = attribute.name(); |
63 | if (name == QLatin1String("version" )) { |
64 | setAttributeVersion(attribute.value().toString()); |
65 | continue; |
66 | } |
67 | if (name == QLatin1String("language" )) { |
68 | setAttributeLanguage(attribute.value().toString()); |
69 | continue; |
70 | } |
71 | if (name == QLatin1String("displayname" )) { |
72 | setAttributeDisplayname(attribute.value().toString()); |
73 | continue; |
74 | } |
75 | if (name == QLatin1String("idbasedtr" )) { |
76 | setAttributeIdbasedtr(attribute.value() == QLatin1String("true" )); |
77 | continue; |
78 | } |
79 | if (name == QLatin1String("connectslotsbyname" )) { |
80 | setAttributeConnectslotsbyname(attribute.value() == QLatin1String("true" )); |
81 | continue; |
82 | } |
83 | if (name == QLatin1String("stdsetdef" )) { |
84 | setAttributeStdsetdef(attribute.value().toInt()); |
85 | continue; |
86 | } |
87 | if (name == QLatin1String("stdSetDef" )) { |
88 | setAttributeStdSetDef(attribute.value().toInt()); |
89 | continue; |
90 | } |
91 | reader.raiseError(QLatin1String("Unexpected attribute " ) + name); |
92 | } |
93 | |
94 | while (!reader.hasError()) { |
95 | switch (reader.readNext()) { |
96 | case QXmlStreamReader::StartElement : { |
97 | const auto tag = reader.name(); |
98 | if (!tag.compare(QLatin1String("author" ), Qt::CaseInsensitive)) { |
99 | setElementAuthor(reader.readElementText()); |
100 | continue; |
101 | } |
102 | if (!tag.compare(QLatin1String("comment" ), Qt::CaseInsensitive)) { |
103 | setElementComment(reader.readElementText()); |
104 | continue; |
105 | } |
106 | if (!tag.compare(QLatin1String("exportmacro" ), Qt::CaseInsensitive)) { |
107 | setElementExportMacro(reader.readElementText()); |
108 | continue; |
109 | } |
110 | if (!tag.compare(QLatin1String("class" ), Qt::CaseInsensitive)) { |
111 | setElementClass(reader.readElementText()); |
112 | continue; |
113 | } |
114 | if (!tag.compare(QLatin1String("widget" ), Qt::CaseInsensitive)) { |
115 | auto *v = new DomWidget(); |
116 | v->read(reader); |
117 | setElementWidget(v); |
118 | continue; |
119 | } |
120 | if (!tag.compare(QLatin1String("layoutdefault" ), Qt::CaseInsensitive)) { |
121 | auto *v = new DomLayoutDefault(); |
122 | v->read(reader); |
123 | setElementLayoutDefault(v); |
124 | continue; |
125 | } |
126 | if (!tag.compare(QLatin1String("layoutfunction" ), Qt::CaseInsensitive)) { |
127 | auto *v = new DomLayoutFunction(); |
128 | v->read(reader); |
129 | setElementLayoutFunction(v); |
130 | continue; |
131 | } |
132 | if (!tag.compare(QLatin1String("pixmapfunction" ), Qt::CaseInsensitive)) { |
133 | setElementPixmapFunction(reader.readElementText()); |
134 | continue; |
135 | } |
136 | if (!tag.compare(QLatin1String("customwidgets" ), Qt::CaseInsensitive)) { |
137 | auto *v = new DomCustomWidgets(); |
138 | v->read(reader); |
139 | setElementCustomWidgets(v); |
140 | continue; |
141 | } |
142 | if (!tag.compare(QLatin1String("tabstops" ), Qt::CaseInsensitive)) { |
143 | auto *v = new DomTabStops(); |
144 | v->read(reader); |
145 | setElementTabStops(v); |
146 | continue; |
147 | } |
148 | if (!tag.compare(QLatin1String("images" ), Qt::CaseInsensitive)) { |
149 | qWarning("Omitting deprecated element <images>." ); |
150 | reader.skipCurrentElement(); |
151 | continue; |
152 | } |
153 | if (!tag.compare(QLatin1String("includes" ), Qt::CaseInsensitive)) { |
154 | auto *v = new DomIncludes(); |
155 | v->read(reader); |
156 | setElementIncludes(v); |
157 | continue; |
158 | } |
159 | if (!tag.compare(QLatin1String("resources" ), Qt::CaseInsensitive)) { |
160 | auto *v = new DomResources(); |
161 | v->read(reader); |
162 | setElementResources(v); |
163 | continue; |
164 | } |
165 | if (!tag.compare(QLatin1String("connections" ), Qt::CaseInsensitive)) { |
166 | auto *v = new DomConnections(); |
167 | v->read(reader); |
168 | setElementConnections(v); |
169 | continue; |
170 | } |
171 | if (!tag.compare(QLatin1String("designerdata" ), Qt::CaseInsensitive)) { |
172 | auto *v = new DomDesignerData(); |
173 | v->read(reader); |
174 | setElementDesignerdata(v); |
175 | continue; |
176 | } |
177 | if (!tag.compare(QLatin1String("slots" ), Qt::CaseInsensitive)) { |
178 | auto *v = new DomSlots(); |
179 | v->read(reader); |
180 | setElementSlots(v); |
181 | continue; |
182 | } |
183 | if (!tag.compare(QLatin1String("buttongroups" ), Qt::CaseInsensitive)) { |
184 | auto *v = new DomButtonGroups(); |
185 | v->read(reader); |
186 | setElementButtonGroups(v); |
187 | continue; |
188 | } |
189 | reader.raiseError(QLatin1String("Unexpected element " ) + tag); |
190 | } |
191 | break; |
192 | case QXmlStreamReader::EndElement : |
193 | return; |
194 | default : |
195 | break; |
196 | } |
197 | } |
198 | } |
199 | |
200 | void DomUI::write(QXmlStreamWriter &writer, const QString &tagName) const |
201 | { |
202 | writer.writeStartElement(tagName.isEmpty() ? QStringLiteral("ui" ) : tagName.toLower()); |
203 | |
204 | if (hasAttributeVersion()) |
205 | writer.writeAttribute(QStringLiteral("version" ), attributeVersion()); |
206 | |
207 | if (hasAttributeLanguage()) |
208 | writer.writeAttribute(QStringLiteral("language" ), attributeLanguage()); |
209 | |
210 | if (hasAttributeDisplayname()) |
211 | writer.writeAttribute(QStringLiteral("displayname" ), attributeDisplayname()); |
212 | |
213 | if (hasAttributeIdbasedtr()) |
214 | writer.writeAttribute(QStringLiteral("idbasedtr" ), (attributeIdbasedtr() ? QLatin1String("true" ) : QLatin1String("false" ))); |
215 | |
216 | if (hasAttributeConnectslotsbyname()) |
217 | writer.writeAttribute(QStringLiteral("connectslotsbyname" ), (attributeConnectslotsbyname() ? QLatin1String("true" ) : QLatin1String("false" ))); |
218 | |
219 | if (hasAttributeStdsetdef()) |
220 | writer.writeAttribute(QStringLiteral("stdsetdef" ), QString::number(attributeStdsetdef())); |
221 | |
222 | if (hasAttributeStdSetDef()) |
223 | writer.writeAttribute(QStringLiteral("stdsetdef" ), QString::number(attributeStdSetDef())); |
224 | |
225 | if (m_children & Author) |
226 | writer.writeTextElement(QStringLiteral("author" ), m_author); |
227 | |
228 | if (m_children & Comment) |
229 | writer.writeTextElement(QStringLiteral("comment" ), m_comment); |
230 | |
231 | if (m_children & ExportMacro) |
232 | writer.writeTextElement(QStringLiteral("exportmacro" ), m_exportMacro); |
233 | |
234 | if (m_children & Class) |
235 | writer.writeTextElement(QStringLiteral("class" ), m_class); |
236 | |
237 | if (m_children & Widget) |
238 | m_widget->write(writer, QStringLiteral("widget" )); |
239 | |
240 | if (m_children & LayoutDefault) |
241 | m_layoutDefault->write(writer, QStringLiteral("layoutdefault" )); |
242 | |
243 | if (m_children & LayoutFunction) |
244 | m_layoutFunction->write(writer, QStringLiteral("layoutfunction" )); |
245 | |
246 | if (m_children & PixmapFunction) |
247 | writer.writeTextElement(QStringLiteral("pixmapfunction" ), m_pixmapFunction); |
248 | |
249 | if (m_children & CustomWidgets) |
250 | m_customWidgets->write(writer, QStringLiteral("customwidgets" )); |
251 | |
252 | if (m_children & TabStops) |
253 | m_tabStops->write(writer, QStringLiteral("tabstops" )); |
254 | |
255 | if (m_children & Includes) |
256 | m_includes->write(writer, QStringLiteral("includes" )); |
257 | |
258 | if (m_children & Resources) |
259 | m_resources->write(writer, QStringLiteral("resources" )); |
260 | |
261 | if (m_children & Connections) |
262 | m_connections->write(writer, QStringLiteral("connections" )); |
263 | |
264 | if (m_children & Designerdata) |
265 | m_designerdata->write(writer, QStringLiteral("designerdata" )); |
266 | |
267 | if (m_children & Slots) |
268 | m_slots->write(writer, QStringLiteral("slots" )); |
269 | |
270 | if (m_children & ButtonGroups) |
271 | m_buttonGroups->write(writer, QStringLiteral("buttongroups" )); |
272 | |
273 | writer.writeEndElement(); |
274 | } |
275 | |
276 | void DomUI::setElementAuthor(const QString &a) |
277 | { |
278 | m_children |= Author; |
279 | m_author = a; |
280 | } |
281 | |
282 | void DomUI::(const QString &a) |
283 | { |
284 | m_children |= Comment; |
285 | m_comment = a; |
286 | } |
287 | |
288 | void DomUI::setElementExportMacro(const QString &a) |
289 | { |
290 | m_children |= ExportMacro; |
291 | m_exportMacro = a; |
292 | } |
293 | |
294 | void DomUI::setElementClass(const QString &a) |
295 | { |
296 | m_children |= Class; |
297 | m_class = a; |
298 | } |
299 | |
300 | DomWidget *DomUI::takeElementWidget() |
301 | { |
302 | DomWidget *a = m_widget; |
303 | m_widget = nullptr; |
304 | m_children ^= Widget; |
305 | return a; |
306 | } |
307 | |
308 | void DomUI::setElementWidget(DomWidget *a) |
309 | { |
310 | delete m_widget; |
311 | m_children |= Widget; |
312 | m_widget = a; |
313 | } |
314 | |
315 | DomLayoutDefault *DomUI::takeElementLayoutDefault() |
316 | { |
317 | DomLayoutDefault *a = m_layoutDefault; |
318 | m_layoutDefault = nullptr; |
319 | m_children ^= LayoutDefault; |
320 | return a; |
321 | } |
322 | |
323 | void DomUI::setElementLayoutDefault(DomLayoutDefault *a) |
324 | { |
325 | delete m_layoutDefault; |
326 | m_children |= LayoutDefault; |
327 | m_layoutDefault = a; |
328 | } |
329 | |
330 | DomLayoutFunction *DomUI::takeElementLayoutFunction() |
331 | { |
332 | DomLayoutFunction *a = m_layoutFunction; |
333 | m_layoutFunction = nullptr; |
334 | m_children ^= LayoutFunction; |
335 | return a; |
336 | } |
337 | |
338 | void DomUI::setElementLayoutFunction(DomLayoutFunction *a) |
339 | { |
340 | delete m_layoutFunction; |
341 | m_children |= LayoutFunction; |
342 | m_layoutFunction = a; |
343 | } |
344 | |
345 | void DomUI::setElementPixmapFunction(const QString &a) |
346 | { |
347 | m_children |= PixmapFunction; |
348 | m_pixmapFunction = a; |
349 | } |
350 | |
351 | DomCustomWidgets *DomUI::takeElementCustomWidgets() |
352 | { |
353 | DomCustomWidgets *a = m_customWidgets; |
354 | m_customWidgets = nullptr; |
355 | m_children ^= CustomWidgets; |
356 | return a; |
357 | } |
358 | |
359 | void DomUI::setElementCustomWidgets(DomCustomWidgets *a) |
360 | { |
361 | delete m_customWidgets; |
362 | m_children |= CustomWidgets; |
363 | m_customWidgets = a; |
364 | } |
365 | |
366 | DomTabStops *DomUI::takeElementTabStops() |
367 | { |
368 | DomTabStops *a = m_tabStops; |
369 | m_tabStops = nullptr; |
370 | m_children ^= TabStops; |
371 | return a; |
372 | } |
373 | |
374 | void DomUI::setElementTabStops(DomTabStops *a) |
375 | { |
376 | delete m_tabStops; |
377 | m_children |= TabStops; |
378 | m_tabStops = a; |
379 | } |
380 | |
381 | DomIncludes *DomUI::takeElementIncludes() |
382 | { |
383 | DomIncludes *a = m_includes; |
384 | m_includes = nullptr; |
385 | m_children ^= Includes; |
386 | return a; |
387 | } |
388 | |
389 | void DomUI::setElementIncludes(DomIncludes *a) |
390 | { |
391 | delete m_includes; |
392 | m_children |= Includes; |
393 | m_includes = a; |
394 | } |
395 | |
396 | DomResources *DomUI::takeElementResources() |
397 | { |
398 | DomResources *a = m_resources; |
399 | m_resources = nullptr; |
400 | m_children ^= Resources; |
401 | return a; |
402 | } |
403 | |
404 | void DomUI::setElementResources(DomResources *a) |
405 | { |
406 | delete m_resources; |
407 | m_children |= Resources; |
408 | m_resources = a; |
409 | } |
410 | |
411 | DomConnections *DomUI::takeElementConnections() |
412 | { |
413 | DomConnections *a = m_connections; |
414 | m_connections = nullptr; |
415 | m_children ^= Connections; |
416 | return a; |
417 | } |
418 | |
419 | void DomUI::setElementConnections(DomConnections *a) |
420 | { |
421 | delete m_connections; |
422 | m_children |= Connections; |
423 | m_connections = a; |
424 | } |
425 | |
426 | DomDesignerData *DomUI::takeElementDesignerdata() |
427 | { |
428 | DomDesignerData *a = m_designerdata; |
429 | m_designerdata = nullptr; |
430 | m_children ^= Designerdata; |
431 | return a; |
432 | } |
433 | |
434 | void DomUI::setElementDesignerdata(DomDesignerData *a) |
435 | { |
436 | delete m_designerdata; |
437 | m_children |= Designerdata; |
438 | m_designerdata = a; |
439 | } |
440 | |
441 | DomSlots *DomUI::takeElementSlots() |
442 | { |
443 | DomSlots *a = m_slots; |
444 | m_slots = nullptr; |
445 | m_children ^= Slots; |
446 | return a; |
447 | } |
448 | |
449 | void DomUI::setElementSlots(DomSlots *a) |
450 | { |
451 | delete m_slots; |
452 | m_children |= Slots; |
453 | m_slots = a; |
454 | } |
455 | |
456 | DomButtonGroups *DomUI::takeElementButtonGroups() |
457 | { |
458 | DomButtonGroups *a = m_buttonGroups; |
459 | m_buttonGroups = nullptr; |
460 | m_children ^= ButtonGroups; |
461 | return a; |
462 | } |
463 | |
464 | void DomUI::setElementButtonGroups(DomButtonGroups *a) |
465 | { |
466 | delete m_buttonGroups; |
467 | m_children |= ButtonGroups; |
468 | m_buttonGroups = a; |
469 | } |
470 | |
471 | void DomUI::clearElementAuthor() |
472 | { |
473 | m_children &= ~Author; |
474 | } |
475 | |
476 | void DomUI::() |
477 | { |
478 | m_children &= ~Comment; |
479 | } |
480 | |
481 | void DomUI::clearElementExportMacro() |
482 | { |
483 | m_children &= ~ExportMacro; |
484 | } |
485 | |
486 | void DomUI::clearElementClass() |
487 | { |
488 | m_children &= ~Class; |
489 | } |
490 | |
491 | void DomUI::clearElementWidget() |
492 | { |
493 | delete m_widget; |
494 | m_widget = nullptr; |
495 | m_children &= ~Widget; |
496 | } |
497 | |
498 | void DomUI::clearElementLayoutDefault() |
499 | { |
500 | delete m_layoutDefault; |
501 | m_layoutDefault = nullptr; |
502 | m_children &= ~LayoutDefault; |
503 | } |
504 | |
505 | void DomUI::clearElementLayoutFunction() |
506 | { |
507 | delete m_layoutFunction; |
508 | m_layoutFunction = nullptr; |
509 | m_children &= ~LayoutFunction; |
510 | } |
511 | |
512 | void DomUI::clearElementPixmapFunction() |
513 | { |
514 | m_children &= ~PixmapFunction; |
515 | } |
516 | |
517 | void DomUI::clearElementCustomWidgets() |
518 | { |
519 | delete m_customWidgets; |
520 | m_customWidgets = nullptr; |
521 | m_children &= ~CustomWidgets; |
522 | } |
523 | |
524 | void DomUI::clearElementTabStops() |
525 | { |
526 | delete m_tabStops; |
527 | m_tabStops = nullptr; |
528 | m_children &= ~TabStops; |
529 | } |
530 | |
531 | void DomUI::clearElementIncludes() |
532 | { |
533 | delete m_includes; |
534 | m_includes = nullptr; |
535 | m_children &= ~Includes; |
536 | } |
537 | |
538 | void DomUI::clearElementResources() |
539 | { |
540 | delete m_resources; |
541 | m_resources = nullptr; |
542 | m_children &= ~Resources; |
543 | } |
544 | |
545 | void DomUI::clearElementConnections() |
546 | { |
547 | delete m_connections; |
548 | m_connections = nullptr; |
549 | m_children &= ~Connections; |
550 | } |
551 | |
552 | void DomUI::clearElementDesignerdata() |
553 | { |
554 | delete m_designerdata; |
555 | m_designerdata = nullptr; |
556 | m_children &= ~Designerdata; |
557 | } |
558 | |
559 | void DomUI::clearElementSlots() |
560 | { |
561 | delete m_slots; |
562 | m_slots = nullptr; |
563 | m_children &= ~Slots; |
564 | } |
565 | |
566 | void DomUI::clearElementButtonGroups() |
567 | { |
568 | delete m_buttonGroups; |
569 | m_buttonGroups = nullptr; |
570 | m_children &= ~ButtonGroups; |
571 | } |
572 | |
573 | DomIncludes::~DomIncludes() |
574 | { |
575 | qDeleteAll(m_include); |
576 | m_include.clear(); |
577 | } |
578 | |
579 | void DomIncludes::read(QXmlStreamReader &reader) |
580 | { |
581 | while (!reader.hasError()) { |
582 | switch (reader.readNext()) { |
583 | case QXmlStreamReader::StartElement : { |
584 | const auto tag = reader.name(); |
585 | if (!tag.compare(QLatin1String("include" ), Qt::CaseInsensitive)) { |
586 | auto *v = new DomInclude(); |
587 | v->read(reader); |
588 | m_include.append(v); |
589 | continue; |
590 | } |
591 | reader.raiseError(QLatin1String("Unexpected element " ) + tag); |
592 | } |
593 | break; |
594 | case QXmlStreamReader::EndElement : |
595 | return; |
596 | default : |
597 | break; |
598 | } |
599 | } |
600 | } |
601 | |
602 | void DomIncludes::write(QXmlStreamWriter &writer, const QString &tagName) const |
603 | { |
604 | writer.writeStartElement(tagName.isEmpty() ? QStringLiteral("includes" ) : tagName.toLower()); |
605 | |
606 | for (DomInclude *v : m_include) |
607 | v->write(writer, QStringLiteral("include" )); |
608 | |
609 | writer.writeEndElement(); |
610 | } |
611 | |
612 | void DomIncludes::setElementInclude(const QList<DomInclude *> &a) |
613 | { |
614 | m_children |= Include; |
615 | m_include = a; |
616 | } |
617 | |
618 | DomInclude::~DomInclude() = default; |
619 | |
620 | void DomInclude::read(QXmlStreamReader &reader) |
621 | { |
622 | const QXmlStreamAttributes &attributes = reader.attributes(); |
623 | for (const QXmlStreamAttribute &attribute : attributes) { |
624 | const auto name = attribute.name(); |
625 | if (name == QLatin1String("location" )) { |
626 | setAttributeLocation(attribute.value().toString()); |
627 | continue; |
628 | } |
629 | if (name == QLatin1String("impldecl" )) { |
630 | setAttributeImpldecl(attribute.value().toString()); |
631 | continue; |
632 | } |
633 | reader.raiseError(QLatin1String("Unexpected attribute " ) + name); |
634 | } |
635 | |
636 | while (!reader.hasError()) { |
637 | switch (reader.readNext()) { |
638 | case QXmlStreamReader::StartElement : { |
639 | const auto tag = reader.name(); |
640 | reader.raiseError(QLatin1String("Unexpected element " ) + tag); |
641 | } |
642 | break; |
643 | case QXmlStreamReader::EndElement : |
644 | return; |
645 | case QXmlStreamReader::Characters : |
646 | if (!reader.isWhitespace()) |
647 | m_text.append(reader.text().toString()); |
648 | break; |
649 | default : |
650 | break; |
651 | } |
652 | } |
653 | } |
654 | |
655 | void DomInclude::write(QXmlStreamWriter &writer, const QString &tagName) const |
656 | { |
657 | writer.writeStartElement(tagName.isEmpty() ? QStringLiteral("include" ) : tagName.toLower()); |
658 | |
659 | if (hasAttributeLocation()) |
660 | writer.writeAttribute(QStringLiteral("location" ), attributeLocation()); |
661 | |
662 | if (hasAttributeImpldecl()) |
663 | writer.writeAttribute(QStringLiteral("impldecl" ), attributeImpldecl()); |
664 | |
665 | if (!m_text.isEmpty()) |
666 | writer.writeCharacters(m_text); |
667 | |
668 | writer.writeEndElement(); |
669 | } |
670 | |
671 | DomResources::~DomResources() |
672 | { |
673 | qDeleteAll(m_include); |
674 | m_include.clear(); |
675 | } |
676 | |
677 | void DomResources::read(QXmlStreamReader &reader) |
678 | { |
679 | const QXmlStreamAttributes &attributes = reader.attributes(); |
680 | for (const QXmlStreamAttribute &attribute : attributes) { |
681 | const auto name = attribute.name(); |
682 | if (name == QLatin1String("name" )) { |
683 | setAttributeName(attribute.value().toString()); |
684 | continue; |
685 | } |
686 | reader.raiseError(QLatin1String("Unexpected attribute " ) + name); |
687 | } |
688 | |
689 | while (!reader.hasError()) { |
690 | switch (reader.readNext()) { |
691 | case QXmlStreamReader::StartElement : { |
692 | const auto tag = reader.name(); |
693 | if (!tag.compare(QLatin1String("include" ), Qt::CaseInsensitive)) { |
694 | auto *v = new DomResource(); |
695 | v->read(reader); |
696 | m_include.append(v); |
697 | continue; |
698 | } |
699 | reader.raiseError(QLatin1String("Unexpected element " ) + tag); |
700 | } |
701 | break; |
702 | case QXmlStreamReader::EndElement : |
703 | return; |
704 | default : |
705 | break; |
706 | } |
707 | } |
708 | } |
709 | |
710 | void DomResources::write(QXmlStreamWriter &writer, const QString &tagName) const |
711 | { |
712 | writer.writeStartElement(tagName.isEmpty() ? QStringLiteral("resources" ) : tagName.toLower()); |
713 | |
714 | if (hasAttributeName()) |
715 | writer.writeAttribute(QStringLiteral("name" ), attributeName()); |
716 | |
717 | for (DomResource *v : m_include) |
718 | v->write(writer, QStringLiteral("include" )); |
719 | |
720 | writer.writeEndElement(); |
721 | } |
722 | |
723 | void DomResources::setElementInclude(const QList<DomResource *> &a) |
724 | { |
725 | m_children |= Include; |
726 | m_include = a; |
727 | } |
728 | |
729 | DomResource::~DomResource() = default; |
730 | |
731 | void DomResource::read(QXmlStreamReader &reader) |
732 | { |
733 | const QXmlStreamAttributes &attributes = reader.attributes(); |
734 | for (const QXmlStreamAttribute &attribute : attributes) { |
735 | const auto name = attribute.name(); |
736 | if (name == QLatin1String("location" )) { |
737 | setAttributeLocation(attribute.value().toString()); |
738 | continue; |
739 | } |
740 | reader.raiseError(QLatin1String("Unexpected attribute " ) + name); |
741 | } |
742 | |
743 | while (!reader.hasError()) { |
744 | switch (reader.readNext()) { |
745 | case QXmlStreamReader::StartElement : { |
746 | const auto tag = reader.name(); |
747 | reader.raiseError(QLatin1String("Unexpected element " ) + tag); |
748 | } |
749 | break; |
750 | case QXmlStreamReader::EndElement : |
751 | return; |
752 | default : |
753 | break; |
754 | } |
755 | } |
756 | } |
757 | |
758 | void DomResource::write(QXmlStreamWriter &writer, const QString &tagName) const |
759 | { |
760 | writer.writeStartElement(tagName.isEmpty() ? QStringLiteral("resource" ) : tagName.toLower()); |
761 | |
762 | if (hasAttributeLocation()) |
763 | writer.writeAttribute(QStringLiteral("location" ), attributeLocation()); |
764 | |
765 | writer.writeEndElement(); |
766 | } |
767 | |
768 | DomActionGroup::~DomActionGroup() |
769 | { |
770 | qDeleteAll(m_action); |
771 | m_action.clear(); |
772 | qDeleteAll(m_actionGroup); |
773 | m_actionGroup.clear(); |
774 | qDeleteAll(m_property); |
775 | m_property.clear(); |
776 | qDeleteAll(m_attribute); |
777 | m_attribute.clear(); |
778 | } |
779 | |
780 | void DomActionGroup::read(QXmlStreamReader &reader) |
781 | { |
782 | const QXmlStreamAttributes &attributes = reader.attributes(); |
783 | for (const QXmlStreamAttribute &attribute : attributes) { |
784 | const auto name = attribute.name(); |
785 | if (name == QLatin1String("name" )) { |
786 | setAttributeName(attribute.value().toString()); |
787 | continue; |
788 | } |
789 | reader.raiseError(QLatin1String("Unexpected attribute " ) + name); |
790 | } |
791 | |
792 | while (!reader.hasError()) { |
793 | switch (reader.readNext()) { |
794 | case QXmlStreamReader::StartElement : { |
795 | const auto tag = reader.name(); |
796 | if (!tag.compare(QLatin1String("action" ), Qt::CaseInsensitive)) { |
797 | auto *v = new DomAction(); |
798 | v->read(reader); |
799 | m_action.append(v); |
800 | continue; |
801 | } |
802 | if (!tag.compare(QLatin1String("actiongroup" ), Qt::CaseInsensitive)) { |
803 | auto *v = new DomActionGroup(); |
804 | v->read(reader); |
805 | m_actionGroup.append(v); |
806 | continue; |
807 | } |
808 | if (!tag.compare(QLatin1String("property" ), Qt::CaseInsensitive)) { |
809 | auto *v = new DomProperty(); |
810 | v->read(reader); |
811 | m_property.append(v); |
812 | continue; |
813 | } |
814 | if (!tag.compare(QLatin1String("attribute" ), Qt::CaseInsensitive)) { |
815 | auto *v = new DomProperty(); |
816 | v->read(reader); |
817 | m_attribute.append(v); |
818 | continue; |
819 | } |
820 | reader.raiseError(QLatin1String("Unexpected element " ) + tag); |
821 | } |
822 | break; |
823 | case QXmlStreamReader::EndElement : |
824 | return; |
825 | default : |
826 | break; |
827 | } |
828 | } |
829 | } |
830 | |
831 | void DomActionGroup::write(QXmlStreamWriter &writer, const QString &tagName) const |
832 | { |
833 | writer.writeStartElement(tagName.isEmpty() ? QStringLiteral("actiongroup" ) : tagName.toLower()); |
834 | |
835 | if (hasAttributeName()) |
836 | writer.writeAttribute(QStringLiteral("name" ), attributeName()); |
837 | |
838 | for (DomAction *v : m_action) |
839 | v->write(writer, QStringLiteral("action" )); |
840 | |
841 | for (DomActionGroup *v : m_actionGroup) |
842 | v->write(writer, QStringLiteral("actiongroup" )); |
843 | |
844 | for (DomProperty *v : m_property) |
845 | v->write(writer, QStringLiteral("property" )); |
846 | |
847 | for (DomProperty *v : m_attribute) |
848 | v->write(writer, QStringLiteral("attribute" )); |
849 | |
850 | writer.writeEndElement(); |
851 | } |
852 | |
853 | void DomActionGroup::setElementAction(const QList<DomAction *> &a) |
854 | { |
855 | m_children |= Action; |
856 | m_action = a; |
857 | } |
858 | |
859 | void DomActionGroup::setElementActionGroup(const QList<DomActionGroup *> &a) |
860 | { |
861 | m_children |= ActionGroup; |
862 | m_actionGroup = a; |
863 | } |
864 | |
865 | void DomActionGroup::setElementProperty(const QList<DomProperty *> &a) |
866 | { |
867 | m_children |= Property; |
868 | m_property = a; |
869 | } |
870 | |
871 | void DomActionGroup::setElementAttribute(const QList<DomProperty *> &a) |
872 | { |
873 | m_children |= Attribute; |
874 | m_attribute = a; |
875 | } |
876 | |
877 | DomAction::~DomAction() |
878 | { |
879 | qDeleteAll(m_property); |
880 | m_property.clear(); |
881 | qDeleteAll(m_attribute); |
882 | m_attribute.clear(); |
883 | } |
884 | |
885 | void DomAction::read(QXmlStreamReader &reader) |
886 | { |
887 | const QXmlStreamAttributes &attributes = reader.attributes(); |
888 | for (const QXmlStreamAttribute &attribute : attributes) { |
889 | const auto name = attribute.name(); |
890 | if (name == QLatin1String("name" )) { |
891 | setAttributeName(attribute.value().toString()); |
892 | continue; |
893 | } |
894 | if (name == QLatin1String("menu" )) { |
895 | setAttributeMenu(attribute.value().toString()); |
896 | continue; |
897 | } |
898 | reader.raiseError(QLatin1String("Unexpected attribute " ) + name); |
899 | } |
900 | |
901 | while (!reader.hasError()) { |
902 | switch (reader.readNext()) { |
903 | case QXmlStreamReader::StartElement : { |
904 | const auto tag = reader.name(); |
905 | if (!tag.compare(QLatin1String("property" ), Qt::CaseInsensitive)) { |
906 | auto *v = new DomProperty(); |
907 | v->read(reader); |
908 | m_property.append(v); |
909 | continue; |
910 | } |
911 | if (!tag.compare(QLatin1String("attribute" ), Qt::CaseInsensitive)) { |
912 | auto *v = new DomProperty(); |
913 | v->read(reader); |
914 | m_attribute.append(v); |
915 | continue; |
916 | } |
917 | reader.raiseError(QLatin1String("Unexpected element " ) + tag); |
918 | } |
919 | break; |
920 | case QXmlStreamReader::EndElement : |
921 | return; |
922 | default : |
923 | break; |
924 | } |
925 | } |
926 | } |
927 | |
928 | void DomAction::write(QXmlStreamWriter &writer, const QString &tagName) const |
929 | { |
930 | writer.writeStartElement(tagName.isEmpty() ? QStringLiteral("action" ) : tagName.toLower()); |
931 | |
932 | if (hasAttributeName()) |
933 | writer.writeAttribute(QStringLiteral("name" ), attributeName()); |
934 | |
935 | if (hasAttributeMenu()) |
936 | writer.writeAttribute(QStringLiteral("menu" ), attributeMenu()); |
937 | |
938 | for (DomProperty *v : m_property) |
939 | v->write(writer, QStringLiteral("property" )); |
940 | |
941 | for (DomProperty *v : m_attribute) |
942 | v->write(writer, QStringLiteral("attribute" )); |
943 | |
944 | writer.writeEndElement(); |
945 | } |
946 | |
947 | void DomAction::setElementProperty(const QList<DomProperty *> &a) |
948 | { |
949 | m_children |= Property; |
950 | m_property = a; |
951 | } |
952 | |
953 | void DomAction::setElementAttribute(const QList<DomProperty *> &a) |
954 | { |
955 | m_children |= Attribute; |
956 | m_attribute = a; |
957 | } |
958 | |
959 | DomActionRef::~DomActionRef() = default; |
960 | |
961 | void DomActionRef::read(QXmlStreamReader &reader) |
962 | { |
963 | const QXmlStreamAttributes &attributes = reader.attributes(); |
964 | for (const QXmlStreamAttribute &attribute : attributes) { |
965 | const auto name = attribute.name(); |
966 | if (name == QLatin1String("name" )) { |
967 | setAttributeName(attribute.value().toString()); |
968 | continue; |
969 | } |
970 | reader.raiseError(QLatin1String("Unexpected attribute " ) + name); |
971 | } |
972 | |
973 | while (!reader.hasError()) { |
974 | switch (reader.readNext()) { |
975 | case QXmlStreamReader::StartElement : { |
976 | const auto tag = reader.name(); |
977 | reader.raiseError(QLatin1String("Unexpected element " ) + tag); |
978 | } |
979 | break; |
980 | case QXmlStreamReader::EndElement : |
981 | return; |
982 | default : |
983 | break; |
984 | } |
985 | } |
986 | } |
987 | |
988 | void DomActionRef::write(QXmlStreamWriter &writer, const QString &tagName) const |
989 | { |
990 | writer.writeStartElement(tagName.isEmpty() ? QStringLiteral("actionref" ) : tagName.toLower()); |
991 | |
992 | if (hasAttributeName()) |
993 | writer.writeAttribute(QStringLiteral("name" ), attributeName()); |
994 | |
995 | writer.writeEndElement(); |
996 | } |
997 | |
998 | DomButtonGroup::~DomButtonGroup() |
999 | { |
1000 | qDeleteAll(m_property); |
1001 | m_property.clear(); |
1002 | qDeleteAll(m_attribute); |
1003 | m_attribute.clear(); |
1004 | } |
1005 | |
1006 | void DomButtonGroup::read(QXmlStreamReader &reader) |
1007 | { |
1008 | const QXmlStreamAttributes &attributes = reader.attributes(); |
1009 | for (const QXmlStreamAttribute &attribute : attributes) { |
1010 | const auto name = attribute.name(); |
1011 | if (name == QLatin1String("name" )) { |
1012 | setAttributeName(attribute.value().toString()); |
1013 | continue; |
1014 | } |
1015 | reader.raiseError(QLatin1String("Unexpected attribute " ) + name); |
1016 | } |
1017 | |
1018 | while (!reader.hasError()) { |
1019 | switch (reader.readNext()) { |
1020 | case QXmlStreamReader::StartElement : { |
1021 | const auto tag = reader.name(); |
1022 | if (!tag.compare(QLatin1String("property" ), Qt::CaseInsensitive)) { |
1023 | auto *v = new DomProperty(); |
1024 | v->read(reader); |
1025 | m_property.append(v); |
1026 | continue; |
1027 | } |
1028 | if (!tag.compare(QLatin1String("attribute" ), Qt::CaseInsensitive)) { |
1029 | auto *v = new DomProperty(); |
1030 | v->read(reader); |
1031 | m_attribute.append(v); |
1032 | continue; |
1033 | } |
1034 | reader.raiseError(QLatin1String("Unexpected element " ) + tag); |
1035 | } |
1036 | break; |
1037 | case QXmlStreamReader::EndElement : |
1038 | return; |
1039 | default : |
1040 | break; |
1041 | } |
1042 | } |
1043 | } |
1044 | |
1045 | void DomButtonGroup::write(QXmlStreamWriter &writer, const QString &tagName) const |
1046 | { |
1047 | writer.writeStartElement(tagName.isEmpty() ? QStringLiteral("buttongroup" ) : tagName.toLower()); |
1048 | |
1049 | if (hasAttributeName()) |
1050 | writer.writeAttribute(QStringLiteral("name" ), attributeName()); |
1051 | |
1052 | for (DomProperty *v : m_property) |
1053 | v->write(writer, QStringLiteral("property" )); |
1054 | |
1055 | for (DomProperty *v : m_attribute) |
1056 | v->write(writer, QStringLiteral("attribute" )); |
1057 | |
1058 | writer.writeEndElement(); |
1059 | } |
1060 | |
1061 | void DomButtonGroup::setElementProperty(const QList<DomProperty *> &a) |
1062 | { |
1063 | m_children |= Property; |
1064 | m_property = a; |
1065 | } |
1066 | |
1067 | void DomButtonGroup::setElementAttribute(const QList<DomProperty *> &a) |
1068 | { |
1069 | m_children |= Attribute; |
1070 | m_attribute = a; |
1071 | } |
1072 | |
1073 | DomButtonGroups::~DomButtonGroups() |
1074 | { |
1075 | qDeleteAll(m_buttonGroup); |
1076 | m_buttonGroup.clear(); |
1077 | } |
1078 | |
1079 | void DomButtonGroups::read(QXmlStreamReader &reader) |
1080 | { |
1081 | while (!reader.hasError()) { |
1082 | switch (reader.readNext()) { |
1083 | case QXmlStreamReader::StartElement : { |
1084 | const auto tag = reader.name(); |
1085 | if (!tag.compare(QLatin1String("buttongroup" ), Qt::CaseInsensitive)) { |
1086 | auto *v = new DomButtonGroup(); |
1087 | v->read(reader); |
1088 | m_buttonGroup.append(v); |
1089 | continue; |
1090 | } |
1091 | reader.raiseError(QLatin1String("Unexpected element " ) + tag); |
1092 | } |
1093 | break; |
1094 | case QXmlStreamReader::EndElement : |
1095 | return; |
1096 | default : |
1097 | break; |
1098 | } |
1099 | } |
1100 | } |
1101 | |
1102 | void DomButtonGroups::write(QXmlStreamWriter &writer, const QString &tagName) const |
1103 | { |
1104 | writer.writeStartElement(tagName.isEmpty() ? QStringLiteral("buttongroups" ) : tagName.toLower()); |
1105 | |
1106 | for (DomButtonGroup *v : m_buttonGroup) |
1107 | v->write(writer, QStringLiteral("buttongroup" )); |
1108 | |
1109 | writer.writeEndElement(); |
1110 | } |
1111 | |
1112 | void DomButtonGroups::setElementButtonGroup(const QList<DomButtonGroup *> &a) |
1113 | { |
1114 | m_children |= ButtonGroup; |
1115 | m_buttonGroup = a; |
1116 | } |
1117 | |
1118 | DomCustomWidgets::~DomCustomWidgets() |
1119 | { |
1120 | qDeleteAll(m_customWidget); |
1121 | m_customWidget.clear(); |
1122 | } |
1123 | |
1124 | void DomCustomWidgets::read(QXmlStreamReader &reader) |
1125 | { |
1126 | while (!reader.hasError()) { |
1127 | switch (reader.readNext()) { |
1128 | case QXmlStreamReader::StartElement : { |
1129 | const auto tag = reader.name(); |
1130 | if (!tag.compare(QLatin1String("customwidget" ), Qt::CaseInsensitive)) { |
1131 | auto *v = new DomCustomWidget(); |
1132 | v->read(reader); |
1133 | m_customWidget.append(v); |
1134 | continue; |
1135 | } |
1136 | reader.raiseError(QLatin1String("Unexpected element " ) + tag); |
1137 | } |
1138 | break; |
1139 | case QXmlStreamReader::EndElement : |
1140 | return; |
1141 | default : |
1142 | break; |
1143 | } |
1144 | } |
1145 | } |
1146 | |
1147 | void DomCustomWidgets::write(QXmlStreamWriter &writer, const QString &tagName) const |
1148 | { |
1149 | writer.writeStartElement(tagName.isEmpty() ? QStringLiteral("customwidgets" ) : tagName.toLower()); |
1150 | |
1151 | for (DomCustomWidget *v : m_customWidget) |
1152 | v->write(writer, QStringLiteral("customwidget" )); |
1153 | |
1154 | writer.writeEndElement(); |
1155 | } |
1156 | |
1157 | void DomCustomWidgets::setElementCustomWidget(const QList<DomCustomWidget *> &a) |
1158 | { |
1159 | m_children |= CustomWidget; |
1160 | m_customWidget = a; |
1161 | } |
1162 | |
1163 | DomHeader::() = default; |
1164 | |
1165 | void DomHeader::(QXmlStreamReader &reader) |
1166 | { |
1167 | const QXmlStreamAttributes &attributes = reader.attributes(); |
1168 | for (const QXmlStreamAttribute &attribute : attributes) { |
1169 | const auto name = attribute.name(); |
1170 | if (name == QLatin1String("location" )) { |
1171 | setAttributeLocation(attribute.value().toString()); |
1172 | continue; |
1173 | } |
1174 | reader.raiseError(QLatin1String("Unexpected attribute " ) + name); |
1175 | } |
1176 | |
1177 | while (!reader.hasError()) { |
1178 | switch (reader.readNext()) { |
1179 | case QXmlStreamReader::StartElement : { |
1180 | const auto tag = reader.name(); |
1181 | reader.raiseError(QLatin1String("Unexpected element " ) + tag); |
1182 | } |
1183 | break; |
1184 | case QXmlStreamReader::EndElement : |
1185 | return; |
1186 | case QXmlStreamReader::Characters : |
1187 | if (!reader.isWhitespace()) |
1188 | m_text.append(reader.text().toString()); |
1189 | break; |
1190 | default : |
1191 | break; |
1192 | } |
1193 | } |
1194 | } |
1195 | |
1196 | void DomHeader::(QXmlStreamWriter &writer, const QString &tagName) const |
1197 | { |
1198 | writer.writeStartElement(tagName.isEmpty() ? QStringLiteral("header" ) : tagName.toLower()); |
1199 | |
1200 | if (hasAttributeLocation()) |
1201 | writer.writeAttribute(QStringLiteral("location" ), attributeLocation()); |
1202 | |
1203 | if (!m_text.isEmpty()) |
1204 | writer.writeCharacters(m_text); |
1205 | |
1206 | writer.writeEndElement(); |
1207 | } |
1208 | |
1209 | DomCustomWidget::~DomCustomWidget() |
1210 | { |
1211 | delete m_header; |
1212 | delete m_sizeHint; |
1213 | delete m_slots; |
1214 | delete m_propertyspecifications; |
1215 | } |
1216 | |
1217 | void DomCustomWidget::read(QXmlStreamReader &reader) |
1218 | { |
1219 | while (!reader.hasError()) { |
1220 | switch (reader.readNext()) { |
1221 | case QXmlStreamReader::StartElement : { |
1222 | const auto tag = reader.name(); |
1223 | if (!tag.compare(QLatin1String("class" ), Qt::CaseInsensitive)) { |
1224 | setElementClass(reader.readElementText()); |
1225 | continue; |
1226 | } |
1227 | if (!tag.compare(QLatin1String("extends" ), Qt::CaseInsensitive)) { |
1228 | setElementExtends(reader.readElementText()); |
1229 | continue; |
1230 | } |
1231 | if (!tag.compare(QLatin1String("header" ), Qt::CaseInsensitive)) { |
1232 | auto *v = new DomHeader(); |
1233 | v->read(reader); |
1234 | setElementHeader(v); |
1235 | continue; |
1236 | } |
1237 | if (!tag.compare(QLatin1String("sizehint" ), Qt::CaseInsensitive)) { |
1238 | auto *v = new DomSize(); |
1239 | v->read(reader); |
1240 | setElementSizeHint(v); |
1241 | continue; |
1242 | } |
1243 | if (!tag.compare(QLatin1String("addpagemethod" ), Qt::CaseInsensitive)) { |
1244 | setElementAddPageMethod(reader.readElementText()); |
1245 | continue; |
1246 | } |
1247 | if (!tag.compare(QLatin1String("container" ), Qt::CaseInsensitive)) { |
1248 | setElementContainer(reader.readElementText().toInt()); |
1249 | continue; |
1250 | } |
1251 | if (!tag.compare(QLatin1String("sizepolicy" ), Qt::CaseInsensitive)) { |
1252 | qWarning("Omitting deprecated element <sizepolicy>." ); |
1253 | reader.skipCurrentElement(); |
1254 | continue; |
1255 | } |
1256 | if (!tag.compare(QLatin1String("pixmap" ), Qt::CaseInsensitive)) { |
1257 | setElementPixmap(reader.readElementText()); |
1258 | continue; |
1259 | } |
1260 | if (!tag.compare(QLatin1String("script" ), Qt::CaseInsensitive)) { |
1261 | qWarning("Omitting deprecated element <script>." ); |
1262 | reader.skipCurrentElement(); |
1263 | continue; |
1264 | } |
1265 | if (!tag.compare(QLatin1String("properties" ), Qt::CaseInsensitive)) { |
1266 | qWarning("Omitting deprecated element <properties>." ); |
1267 | reader.skipCurrentElement(); |
1268 | continue; |
1269 | } |
1270 | if (!tag.compare(QLatin1String("slots" ), Qt::CaseInsensitive)) { |
1271 | auto *v = new DomSlots(); |
1272 | v->read(reader); |
1273 | setElementSlots(v); |
1274 | continue; |
1275 | } |
1276 | if (!tag.compare(QLatin1String("propertyspecifications" ), Qt::CaseInsensitive)) { |
1277 | auto *v = new DomPropertySpecifications(); |
1278 | v->read(reader); |
1279 | setElementPropertyspecifications(v); |
1280 | continue; |
1281 | } |
1282 | reader.raiseError(QLatin1String("Unexpected element " ) + tag); |
1283 | } |
1284 | break; |
1285 | case QXmlStreamReader::EndElement : |
1286 | return; |
1287 | default : |
1288 | break; |
1289 | } |
1290 | } |
1291 | } |
1292 | |
1293 | void DomCustomWidget::write(QXmlStreamWriter &writer, const QString &tagName) const |
1294 | { |
1295 | writer.writeStartElement(tagName.isEmpty() ? QStringLiteral("customwidget" ) : tagName.toLower()); |
1296 | |
1297 | if (m_children & Class) |
1298 | writer.writeTextElement(QStringLiteral("class" ), m_class); |
1299 | |
1300 | if (m_children & Extends) |
1301 | writer.writeTextElement(QStringLiteral("extends" ), m_extends); |
1302 | |
1303 | if (m_children & Header) |
1304 | m_header->write(writer, QStringLiteral("header" )); |
1305 | |
1306 | if (m_children & SizeHint) |
1307 | m_sizeHint->write(writer, QStringLiteral("sizehint" )); |
1308 | |
1309 | if (m_children & AddPageMethod) |
1310 | writer.writeTextElement(QStringLiteral("addpagemethod" ), m_addPageMethod); |
1311 | |
1312 | if (m_children & Container) |
1313 | writer.writeTextElement(QStringLiteral("container" ), QString::number(m_container)); |
1314 | |
1315 | if (m_children & Pixmap) |
1316 | writer.writeTextElement(QStringLiteral("pixmap" ), m_pixmap); |
1317 | |
1318 | if (m_children & Slots) |
1319 | m_slots->write(writer, QStringLiteral("slots" )); |
1320 | |
1321 | if (m_children & Propertyspecifications) |
1322 | m_propertyspecifications->write(writer, QStringLiteral("propertyspecifications" )); |
1323 | |
1324 | writer.writeEndElement(); |
1325 | } |
1326 | |
1327 | void DomCustomWidget::setElementClass(const QString &a) |
1328 | { |
1329 | m_children |= Class; |
1330 | m_class = a; |
1331 | } |
1332 | |
1333 | void DomCustomWidget::setElementExtends(const QString &a) |
1334 | { |
1335 | m_children |= Extends; |
1336 | m_extends = a; |
1337 | } |
1338 | |
1339 | DomHeader *DomCustomWidget::() |
1340 | { |
1341 | DomHeader *a = m_header; |
1342 | m_header = nullptr; |
1343 | m_children ^= Header; |
1344 | return a; |
1345 | } |
1346 | |
1347 | void DomCustomWidget::(DomHeader *a) |
1348 | { |
1349 | delete m_header; |
1350 | m_children |= Header; |
1351 | m_header = a; |
1352 | } |
1353 | |
1354 | DomSize *DomCustomWidget::takeElementSizeHint() |
1355 | { |
1356 | DomSize *a = m_sizeHint; |
1357 | m_sizeHint = nullptr; |
1358 | m_children ^= SizeHint; |
1359 | return a; |
1360 | } |
1361 | |
1362 | void DomCustomWidget::setElementSizeHint(DomSize *a) |
1363 | { |
1364 | delete m_sizeHint; |
1365 | m_children |= SizeHint; |
1366 | m_sizeHint = a; |
1367 | } |
1368 | |
1369 | void DomCustomWidget::setElementAddPageMethod(const QString &a) |
1370 | { |
1371 | m_children |= AddPageMethod; |
1372 | m_addPageMethod = a; |
1373 | } |
1374 | |
1375 | void DomCustomWidget::setElementContainer(int a) |
1376 | { |
1377 | m_children |= Container; |
1378 | m_container = a; |
1379 | } |
1380 | |
1381 | void DomCustomWidget::setElementPixmap(const QString &a) |
1382 | { |
1383 | m_children |= Pixmap; |
1384 | m_pixmap = a; |
1385 | } |
1386 | |
1387 | DomSlots *DomCustomWidget::takeElementSlots() |
1388 | { |
1389 | DomSlots *a = m_slots; |
1390 | m_slots = nullptr; |
1391 | m_children ^= Slots; |
1392 | return a; |
1393 | } |
1394 | |
1395 | void DomCustomWidget::setElementSlots(DomSlots *a) |
1396 | { |
1397 | delete m_slots; |
1398 | m_children |= Slots; |
1399 | m_slots = a; |
1400 | } |
1401 | |
1402 | DomPropertySpecifications *DomCustomWidget::takeElementPropertyspecifications() |
1403 | { |
1404 | DomPropertySpecifications *a = m_propertyspecifications; |
1405 | m_propertyspecifications = nullptr; |
1406 | m_children ^= Propertyspecifications; |
1407 | return a; |
1408 | } |
1409 | |
1410 | void DomCustomWidget::setElementPropertyspecifications(DomPropertySpecifications *a) |
1411 | { |
1412 | delete m_propertyspecifications; |
1413 | m_children |= Propertyspecifications; |
1414 | m_propertyspecifications = a; |
1415 | } |
1416 | |
1417 | void DomCustomWidget::clearElementClass() |
1418 | { |
1419 | m_children &= ~Class; |
1420 | } |
1421 | |
1422 | void DomCustomWidget::clearElementExtends() |
1423 | { |
1424 | m_children &= ~Extends; |
1425 | } |
1426 | |
1427 | void DomCustomWidget::() |
1428 | { |
1429 | delete m_header; |
1430 | m_header = nullptr; |
1431 | m_children &= ~Header; |
1432 | } |
1433 | |
1434 | void DomCustomWidget::clearElementSizeHint() |
1435 | { |
1436 | delete m_sizeHint; |
1437 | m_sizeHint = nullptr; |
1438 | m_children &= ~SizeHint; |
1439 | } |
1440 | |
1441 | void DomCustomWidget::clearElementAddPageMethod() |
1442 | { |
1443 | m_children &= ~AddPageMethod; |
1444 | } |
1445 | |
1446 | void DomCustomWidget::clearElementContainer() |
1447 | { |
1448 | m_children &= ~Container; |
1449 | } |
1450 | |
1451 | void DomCustomWidget::clearElementPixmap() |
1452 | { |
1453 | m_children &= ~Pixmap; |
1454 | } |
1455 | |
1456 | void DomCustomWidget::clearElementSlots() |
1457 | { |
1458 | delete m_slots; |
1459 | m_slots = nullptr; |
1460 | m_children &= ~Slots; |
1461 | } |
1462 | |
1463 | void DomCustomWidget::clearElementPropertyspecifications() |
1464 | { |
1465 | delete m_propertyspecifications; |
1466 | m_propertyspecifications = nullptr; |
1467 | m_children &= ~Propertyspecifications; |
1468 | } |
1469 | |
1470 | DomLayoutDefault::~DomLayoutDefault() = default; |
1471 | |
1472 | void DomLayoutDefault::read(QXmlStreamReader &reader) |
1473 | { |
1474 | const QXmlStreamAttributes &attributes = reader.attributes(); |
1475 | for (const QXmlStreamAttribute &attribute : attributes) { |
1476 | const auto name = attribute.name(); |
1477 | if (name == QLatin1String("spacing" )) { |
1478 | setAttributeSpacing(attribute.value().toInt()); |
1479 | continue; |
1480 | } |
1481 | if (name == QLatin1String("margin" )) { |
1482 | setAttributeMargin(attribute.value().toInt()); |
1483 | continue; |
1484 | } |
1485 | reader.raiseError(QLatin1String("Unexpected attribute " ) + name); |
1486 | } |
1487 | |
1488 | while (!reader.hasError()) { |
1489 | switch (reader.readNext()) { |
1490 | case QXmlStreamReader::StartElement : { |
1491 | const auto tag = reader.name(); |
1492 | reader.raiseError(QLatin1String("Unexpected element " ) + tag); |
1493 | } |
1494 | break; |
1495 | case QXmlStreamReader::EndElement : |
1496 | return; |
1497 | default : |
1498 | break; |
1499 | } |
1500 | } |
1501 | } |
1502 | |
1503 | void DomLayoutDefault::write(QXmlStreamWriter &writer, const QString &tagName) const |
1504 | { |
1505 | writer.writeStartElement(tagName.isEmpty() ? QStringLiteral("layoutdefault" ) : tagName.toLower()); |
1506 | |
1507 | if (hasAttributeSpacing()) |
1508 | writer.writeAttribute(QStringLiteral("spacing" ), QString::number(attributeSpacing())); |
1509 | |
1510 | if (hasAttributeMargin()) |
1511 | writer.writeAttribute(QStringLiteral("margin" ), QString::number(attributeMargin())); |
1512 | |
1513 | writer.writeEndElement(); |
1514 | } |
1515 | |
1516 | DomLayoutFunction::~DomLayoutFunction() = default; |
1517 | |
1518 | void DomLayoutFunction::read(QXmlStreamReader &reader) |
1519 | { |
1520 | const QXmlStreamAttributes &attributes = reader.attributes(); |
1521 | for (const QXmlStreamAttribute &attribute : attributes) { |
1522 | const auto name = attribute.name(); |
1523 | if (name == QLatin1String("spacing" )) { |
1524 | setAttributeSpacing(attribute.value().toString()); |
1525 | continue; |
1526 | } |
1527 | if (name == QLatin1String("margin" )) { |
1528 | setAttributeMargin(attribute.value().toString()); |
1529 | continue; |
1530 | } |
1531 | reader.raiseError(QLatin1String("Unexpected attribute " ) + name); |
1532 | } |
1533 | |
1534 | while (!reader.hasError()) { |
1535 | switch (reader.readNext()) { |
1536 | case QXmlStreamReader::StartElement : { |
1537 | const auto tag = reader.name(); |
1538 | reader.raiseError(QLatin1String("Unexpected element " ) + tag); |
1539 | } |
1540 | break; |
1541 | case QXmlStreamReader::EndElement : |
1542 | return; |
1543 | default : |
1544 | break; |
1545 | } |
1546 | } |
1547 | } |
1548 | |
1549 | void DomLayoutFunction::write(QXmlStreamWriter &writer, const QString &tagName) const |
1550 | { |
1551 | writer.writeStartElement(tagName.isEmpty() ? QStringLiteral("layoutfunction" ) : tagName.toLower()); |
1552 | |
1553 | if (hasAttributeSpacing()) |
1554 | writer.writeAttribute(QStringLiteral("spacing" ), attributeSpacing()); |
1555 | |
1556 | if (hasAttributeMargin()) |
1557 | writer.writeAttribute(QStringLiteral("margin" ), attributeMargin()); |
1558 | |
1559 | writer.writeEndElement(); |
1560 | } |
1561 | |
1562 | DomTabStops::~DomTabStops() |
1563 | { |
1564 | m_tabStop.clear(); |
1565 | } |
1566 | |
1567 | void DomTabStops::read(QXmlStreamReader &reader) |
1568 | { |
1569 | while (!reader.hasError()) { |
1570 | switch (reader.readNext()) { |
1571 | case QXmlStreamReader::StartElement : { |
1572 | const auto tag = reader.name(); |
1573 | if (!tag.compare(QLatin1String("tabstop" ), Qt::CaseInsensitive)) { |
1574 | m_tabStop.append(reader.readElementText()); |
1575 | continue; |
1576 | } |
1577 | reader.raiseError(QLatin1String("Unexpected element " ) + tag); |
1578 | } |
1579 | break; |
1580 | case QXmlStreamReader::EndElement : |
1581 | return; |
1582 | default : |
1583 | break; |
1584 | } |
1585 | } |
1586 | } |
1587 | |
1588 | void DomTabStops::write(QXmlStreamWriter &writer, const QString &tagName) const |
1589 | { |
1590 | writer.writeStartElement(tagName.isEmpty() ? QStringLiteral("tabstops" ) : tagName.toLower()); |
1591 | |
1592 | for (const QString &v : m_tabStop) |
1593 | writer.writeTextElement(QStringLiteral("tabstop" ), v); |
1594 | |
1595 | writer.writeEndElement(); |
1596 | } |
1597 | |
1598 | void DomTabStops::setElementTabStop(const QStringList &a) |
1599 | { |
1600 | m_children |= TabStop; |
1601 | m_tabStop = a; |
1602 | } |
1603 | |
1604 | DomLayout::~DomLayout() |
1605 | { |
1606 | qDeleteAll(m_property); |
1607 | m_property.clear(); |
1608 | qDeleteAll(m_attribute); |
1609 | m_attribute.clear(); |
1610 | qDeleteAll(m_item); |
1611 | m_item.clear(); |
1612 | } |
1613 | |
1614 | void DomLayout::read(QXmlStreamReader &reader) |
1615 | { |
1616 | const QXmlStreamAttributes &attributes = reader.attributes(); |
1617 | for (const QXmlStreamAttribute &attribute : attributes) { |
1618 | const auto name = attribute.name(); |
1619 | if (name == QLatin1String("class" )) { |
1620 | setAttributeClass(attribute.value().toString()); |
1621 | continue; |
1622 | } |
1623 | if (name == QLatin1String("name" )) { |
1624 | setAttributeName(attribute.value().toString()); |
1625 | continue; |
1626 | } |
1627 | if (name == QLatin1String("stretch" )) { |
1628 | setAttributeStretch(attribute.value().toString()); |
1629 | continue; |
1630 | } |
1631 | if (name == QLatin1String("rowstretch" )) { |
1632 | setAttributeRowStretch(attribute.value().toString()); |
1633 | continue; |
1634 | } |
1635 | if (name == QLatin1String("columnstretch" )) { |
1636 | setAttributeColumnStretch(attribute.value().toString()); |
1637 | continue; |
1638 | } |
1639 | if (name == QLatin1String("rowminimumheight" )) { |
1640 | setAttributeRowMinimumHeight(attribute.value().toString()); |
1641 | continue; |
1642 | } |
1643 | if (name == QLatin1String("columnminimumwidth" )) { |
1644 | setAttributeColumnMinimumWidth(attribute.value().toString()); |
1645 | continue; |
1646 | } |
1647 | reader.raiseError(QLatin1String("Unexpected attribute " ) + name); |
1648 | } |
1649 | |
1650 | while (!reader.hasError()) { |
1651 | switch (reader.readNext()) { |
1652 | case QXmlStreamReader::StartElement : { |
1653 | const auto tag = reader.name(); |
1654 | if (!tag.compare(QLatin1String("property" ), Qt::CaseInsensitive)) { |
1655 | auto *v = new DomProperty(); |
1656 | v->read(reader); |
1657 | m_property.append(v); |
1658 | continue; |
1659 | } |
1660 | if (!tag.compare(QLatin1String("attribute" ), Qt::CaseInsensitive)) { |
1661 | auto *v = new DomProperty(); |
1662 | v->read(reader); |
1663 | m_attribute.append(v); |
1664 | continue; |
1665 | } |
1666 | if (!tag.compare(QLatin1String("item" ), Qt::CaseInsensitive)) { |
1667 | auto *v = new DomLayoutItem(); |
1668 | v->read(reader); |
1669 | m_item.append(v); |
1670 | continue; |
1671 | } |
1672 | reader.raiseError(QLatin1String("Unexpected element " ) + tag); |
1673 | } |
1674 | break; |
1675 | case QXmlStreamReader::EndElement : |
1676 | return; |
1677 | default : |
1678 | break; |
1679 | } |
1680 | } |
1681 | } |
1682 | |
1683 | void DomLayout::write(QXmlStreamWriter &writer, const QString &tagName) const |
1684 | { |
1685 | writer.writeStartElement(tagName.isEmpty() ? QStringLiteral("layout" ) : tagName.toLower()); |
1686 | |
1687 | if (hasAttributeClass()) |
1688 | writer.writeAttribute(QStringLiteral("class" ), attributeClass()); |
1689 | |
1690 | if (hasAttributeName()) |
1691 | writer.writeAttribute(QStringLiteral("name" ), attributeName()); |
1692 | |
1693 | if (hasAttributeStretch()) |
1694 | writer.writeAttribute(QStringLiteral("stretch" ), attributeStretch()); |
1695 | |
1696 | if (hasAttributeRowStretch()) |
1697 | writer.writeAttribute(QStringLiteral("rowstretch" ), attributeRowStretch()); |
1698 | |
1699 | if (hasAttributeColumnStretch()) |
1700 | writer.writeAttribute(QStringLiteral("columnstretch" ), attributeColumnStretch()); |
1701 | |
1702 | if (hasAttributeRowMinimumHeight()) |
1703 | writer.writeAttribute(QStringLiteral("rowminimumheight" ), attributeRowMinimumHeight()); |
1704 | |
1705 | if (hasAttributeColumnMinimumWidth()) |
1706 | writer.writeAttribute(QStringLiteral("columnminimumwidth" ), attributeColumnMinimumWidth()); |
1707 | |
1708 | for (DomProperty *v : m_property) |
1709 | v->write(writer, QStringLiteral("property" )); |
1710 | |
1711 | for (DomProperty *v : m_attribute) |
1712 | v->write(writer, QStringLiteral("attribute" )); |
1713 | |
1714 | for (DomLayoutItem *v : m_item) |
1715 | v->write(writer, QStringLiteral("item" )); |
1716 | |
1717 | writer.writeEndElement(); |
1718 | } |
1719 | |
1720 | void DomLayout::setElementProperty(const QList<DomProperty *> &a) |
1721 | { |
1722 | m_children |= Property; |
1723 | m_property = a; |
1724 | } |
1725 | |
1726 | void DomLayout::setElementAttribute(const QList<DomProperty *> &a) |
1727 | { |
1728 | m_children |= Attribute; |
1729 | m_attribute = a; |
1730 | } |
1731 | |
1732 | void DomLayout::setElementItem(const QList<DomLayoutItem *> &a) |
1733 | { |
1734 | m_children |= Item; |
1735 | m_item = a; |
1736 | } |
1737 | |
1738 | DomLayoutItem::~DomLayoutItem() |
1739 | { |
1740 | delete m_widget; |
1741 | delete m_layout; |
1742 | delete m_spacer; |
1743 | } |
1744 | |
1745 | void DomLayoutItem::clear() |
1746 | { |
1747 | delete m_widget; |
1748 | delete m_layout; |
1749 | delete m_spacer; |
1750 | |
1751 | m_kind = Unknown; |
1752 | |
1753 | m_widget = nullptr; |
1754 | m_layout = nullptr; |
1755 | m_spacer = nullptr; |
1756 | } |
1757 | |
1758 | void DomLayoutItem::read(QXmlStreamReader &reader) |
1759 | { |
1760 | const QXmlStreamAttributes &attributes = reader.attributes(); |
1761 | for (const QXmlStreamAttribute &attribute : attributes) { |
1762 | const auto name = attribute.name(); |
1763 | if (name == QLatin1String("row" )) { |
1764 | setAttributeRow(attribute.value().toInt()); |
1765 | continue; |
1766 | } |
1767 | if (name == QLatin1String("column" )) { |
1768 | setAttributeColumn(attribute.value().toInt()); |
1769 | continue; |
1770 | } |
1771 | if (name == QLatin1String("rowspan" )) { |
1772 | setAttributeRowSpan(attribute.value().toInt()); |
1773 | continue; |
1774 | } |
1775 | if (name == QLatin1String("colspan" )) { |
1776 | setAttributeColSpan(attribute.value().toInt()); |
1777 | continue; |
1778 | } |
1779 | if (name == QLatin1String("alignment" )) { |
1780 | setAttributeAlignment(attribute.value().toString()); |
1781 | continue; |
1782 | } |
1783 | reader.raiseError(QLatin1String("Unexpected attribute " ) + name); |
1784 | } |
1785 | |
1786 | while (!reader.hasError()) { |
1787 | switch (reader.readNext()) { |
1788 | case QXmlStreamReader::StartElement : { |
1789 | const auto tag = reader.name(); |
1790 | if (!tag.compare(QLatin1String("widget" ), Qt::CaseInsensitive)) { |
1791 | auto *v = new DomWidget(); |
1792 | v->read(reader); |
1793 | setElementWidget(v); |
1794 | continue; |
1795 | } |
1796 | if (!tag.compare(QLatin1String("layout" ), Qt::CaseInsensitive)) { |
1797 | auto *v = new DomLayout(); |
1798 | v->read(reader); |
1799 | setElementLayout(v); |
1800 | continue; |
1801 | } |
1802 | if (!tag.compare(QLatin1String("spacer" ), Qt::CaseInsensitive)) { |
1803 | auto *v = new DomSpacer(); |
1804 | v->read(reader); |
1805 | setElementSpacer(v); |
1806 | continue; |
1807 | } |
1808 | reader.raiseError(QLatin1String("Unexpected element " ) + tag); |
1809 | } |
1810 | break; |
1811 | case QXmlStreamReader::EndElement : |
1812 | return; |
1813 | default : |
1814 | break; |
1815 | } |
1816 | } |
1817 | } |
1818 | |
1819 | void DomLayoutItem::write(QXmlStreamWriter &writer, const QString &tagName) const |
1820 | { |
1821 | writer.writeStartElement(tagName.isEmpty() ? QStringLiteral("layoutitem" ) : tagName.toLower()); |
1822 | |
1823 | if (hasAttributeRow()) |
1824 | writer.writeAttribute(QStringLiteral("row" ), QString::number(attributeRow())); |
1825 | |
1826 | if (hasAttributeColumn()) |
1827 | writer.writeAttribute(QStringLiteral("column" ), QString::number(attributeColumn())); |
1828 | |
1829 | if (hasAttributeRowSpan()) |
1830 | writer.writeAttribute(QStringLiteral("rowspan" ), QString::number(attributeRowSpan())); |
1831 | |
1832 | if (hasAttributeColSpan()) |
1833 | writer.writeAttribute(QStringLiteral("colspan" ), QString::number(attributeColSpan())); |
1834 | |
1835 | if (hasAttributeAlignment()) |
1836 | writer.writeAttribute(QStringLiteral("alignment" ), attributeAlignment()); |
1837 | |
1838 | switch (kind()) { |
1839 | case Widget: |
1840 | if (m_widget != nullptr) |
1841 | m_widget->write(writer, QStringLiteral("widget" )); |
1842 | break; |
1843 | |
1844 | case Layout: |
1845 | if (m_layout != nullptr) |
1846 | m_layout->write(writer, QStringLiteral("layout" )); |
1847 | break; |
1848 | |
1849 | case Spacer: |
1850 | if (m_spacer != nullptr) |
1851 | m_spacer->write(writer, QStringLiteral("spacer" )); |
1852 | break; |
1853 | |
1854 | default: |
1855 | break; |
1856 | } |
1857 | writer.writeEndElement(); |
1858 | } |
1859 | |
1860 | DomWidget *DomLayoutItem::takeElementWidget() |
1861 | { |
1862 | DomWidget *a = m_widget; |
1863 | m_widget = nullptr; |
1864 | return a; |
1865 | } |
1866 | |
1867 | void DomLayoutItem::setElementWidget(DomWidget *a) |
1868 | { |
1869 | clear(); |
1870 | m_kind = Widget; |
1871 | m_widget = a; |
1872 | } |
1873 | |
1874 | DomLayout *DomLayoutItem::takeElementLayout() |
1875 | { |
1876 | DomLayout *a = m_layout; |
1877 | m_layout = nullptr; |
1878 | return a; |
1879 | } |
1880 | |
1881 | void DomLayoutItem::setElementLayout(DomLayout *a) |
1882 | { |
1883 | clear(); |
1884 | m_kind = Layout; |
1885 | m_layout = a; |
1886 | } |
1887 | |
1888 | DomSpacer *DomLayoutItem::takeElementSpacer() |
1889 | { |
1890 | DomSpacer *a = m_spacer; |
1891 | m_spacer = nullptr; |
1892 | return a; |
1893 | } |
1894 | |
1895 | void DomLayoutItem::setElementSpacer(DomSpacer *a) |
1896 | { |
1897 | clear(); |
1898 | m_kind = Spacer; |
1899 | m_spacer = a; |
1900 | } |
1901 | |
1902 | DomRow::~DomRow() |
1903 | { |
1904 | qDeleteAll(m_property); |
1905 | m_property.clear(); |
1906 | } |
1907 | |
1908 | void DomRow::read(QXmlStreamReader &reader) |
1909 | { |
1910 | while (!reader.hasError()) { |
1911 | switch (reader.readNext()) { |
1912 | case QXmlStreamReader::StartElement : { |
1913 | const auto tag = reader.name(); |
1914 | if (!tag.compare(QLatin1String("property" ), Qt::CaseInsensitive)) { |
1915 | auto *v = new DomProperty(); |
1916 | v->read(reader); |
1917 | m_property.append(v); |
1918 | continue; |
1919 | } |
1920 | reader.raiseError(QLatin1String("Unexpected element " ) + tag); |
1921 | } |
1922 | break; |
1923 | case QXmlStreamReader::EndElement : |
1924 | return; |
1925 | default : |
1926 | break; |
1927 | } |
1928 | } |
1929 | } |
1930 | |
1931 | void DomRow::write(QXmlStreamWriter &writer, const QString &tagName) const |
1932 | { |
1933 | writer.writeStartElement(tagName.isEmpty() ? QStringLiteral("row" ) : tagName.toLower()); |
1934 | |
1935 | for (DomProperty *v : m_property) |
1936 | v->write(writer, QStringLiteral("property" )); |
1937 | |
1938 | writer.writeEndElement(); |
1939 | } |
1940 | |
1941 | void DomRow::setElementProperty(const QList<DomProperty *> &a) |
1942 | { |
1943 | m_children |= Property; |
1944 | m_property = a; |
1945 | } |
1946 | |
1947 | DomColumn::~DomColumn() |
1948 | { |
1949 | qDeleteAll(m_property); |
1950 | m_property.clear(); |
1951 | } |
1952 | |
1953 | void DomColumn::read(QXmlStreamReader &reader) |
1954 | { |
1955 | while (!reader.hasError()) { |
1956 | switch (reader.readNext()) { |
1957 | case QXmlStreamReader::StartElement : { |
1958 | const auto tag = reader.name(); |
1959 | if (!tag.compare(QLatin1String("property" ), Qt::CaseInsensitive)) { |
1960 | auto *v = new DomProperty(); |
1961 | v->read(reader); |
1962 | m_property.append(v); |
1963 | continue; |
1964 | } |
1965 | reader.raiseError(QLatin1String("Unexpected element " ) + tag); |
1966 | } |
1967 | break; |
1968 | case QXmlStreamReader::EndElement : |
1969 | return; |
1970 | default : |
1971 | break; |
1972 | } |
1973 | } |
1974 | } |
1975 | |
1976 | void DomColumn::write(QXmlStreamWriter &writer, const QString &tagName) const |
1977 | { |
1978 | writer.writeStartElement(tagName.isEmpty() ? QStringLiteral("column" ) : tagName.toLower()); |
1979 | |
1980 | for (DomProperty *v : m_property) |
1981 | v->write(writer, QStringLiteral("property" )); |
1982 | |
1983 | writer.writeEndElement(); |
1984 | } |
1985 | |
1986 | void DomColumn::setElementProperty(const QList<DomProperty *> &a) |
1987 | { |
1988 | m_children |= Property; |
1989 | m_property = a; |
1990 | } |
1991 | |
1992 | DomItem::~DomItem() |
1993 | { |
1994 | qDeleteAll(m_property); |
1995 | m_property.clear(); |
1996 | qDeleteAll(m_item); |
1997 | m_item.clear(); |
1998 | } |
1999 | |
2000 | void DomItem::read(QXmlStreamReader &reader) |
2001 | { |
2002 | const QXmlStreamAttributes &attributes = reader.attributes(); |
2003 | for (const QXmlStreamAttribute &attribute : attributes) { |
2004 | const auto name = attribute.name(); |
2005 | if (name == QLatin1String("row" )) { |
2006 | setAttributeRow(attribute.value().toInt()); |
2007 | continue; |
2008 | } |
2009 | if (name == QLatin1String("column" )) { |
2010 | setAttributeColumn(attribute.value().toInt()); |
2011 | continue; |
2012 | } |
2013 | reader.raiseError(QLatin1String("Unexpected attribute " ) + name); |
2014 | } |
2015 | |
2016 | while (!reader.hasError()) { |
2017 | switch (reader.readNext()) { |
2018 | case QXmlStreamReader::StartElement : { |
2019 | const auto tag = reader.name(); |
2020 | if (!tag.compare(QLatin1String("property" ), Qt::CaseInsensitive)) { |
2021 | auto *v = new DomProperty(); |
2022 | v->read(reader); |
2023 | m_property.append(v); |
2024 | continue; |
2025 | } |
2026 | if (!tag.compare(QLatin1String("item" ), Qt::CaseInsensitive)) { |
2027 | auto *v = new DomItem(); |
2028 | v->read(reader); |
2029 | m_item.append(v); |
2030 | continue; |
2031 | } |
2032 | reader.raiseError(QLatin1String("Unexpected element " ) + tag); |
2033 | } |
2034 | break; |
2035 | case QXmlStreamReader::EndElement : |
2036 | return; |
2037 | default : |
2038 | break; |
2039 | } |
2040 | } |
2041 | } |
2042 | |
2043 | void DomItem::write(QXmlStreamWriter &writer, const QString &tagName) const |
2044 | { |
2045 | writer.writeStartElement(tagName.isEmpty() ? QStringLiteral("item" ) : tagName.toLower()); |
2046 | |
2047 | if (hasAttributeRow()) |
2048 | writer.writeAttribute(QStringLiteral("row" ), QString::number(attributeRow())); |
2049 | |
2050 | if (hasAttributeColumn()) |
2051 | writer.writeAttribute(QStringLiteral("column" ), QString::number(attributeColumn())); |
2052 | |
2053 | for (DomProperty *v : m_property) |
2054 | v->write(writer, QStringLiteral("property" )); |
2055 | |
2056 | for (DomItem *v : m_item) |
2057 | v->write(writer, QStringLiteral("item" )); |
2058 | |
2059 | writer.writeEndElement(); |
2060 | } |
2061 | |
2062 | void DomItem::setElementProperty(const QList<DomProperty *> &a) |
2063 | { |
2064 | m_children |= Property; |
2065 | m_property = a; |
2066 | } |
2067 | |
2068 | void DomItem::setElementItem(const QList<DomItem *> &a) |
2069 | { |
2070 | m_children |= Item; |
2071 | m_item = a; |
2072 | } |
2073 | |
2074 | DomWidget::~DomWidget() |
2075 | { |
2076 | m_class.clear(); |
2077 | qDeleteAll(m_property); |
2078 | m_property.clear(); |
2079 | qDeleteAll(m_attribute); |
2080 | m_attribute.clear(); |
2081 | qDeleteAll(m_row); |
2082 | m_row.clear(); |
2083 | qDeleteAll(m_column); |
2084 | m_column.clear(); |
2085 | qDeleteAll(m_item); |
2086 | m_item.clear(); |
2087 | qDeleteAll(m_layout); |
2088 | m_layout.clear(); |
2089 | qDeleteAll(m_widget); |
2090 | m_widget.clear(); |
2091 | qDeleteAll(m_action); |
2092 | m_action.clear(); |
2093 | qDeleteAll(m_actionGroup); |
2094 | m_actionGroup.clear(); |
2095 | qDeleteAll(m_addAction); |
2096 | m_addAction.clear(); |
2097 | m_zOrder.clear(); |
2098 | } |
2099 | |
2100 | void DomWidget::read(QXmlStreamReader &reader) |
2101 | { |
2102 | const QXmlStreamAttributes &attributes = reader.attributes(); |
2103 | for (const QXmlStreamAttribute &attribute : attributes) { |
2104 | const auto name = attribute.name(); |
2105 | if (name == QLatin1String("class" )) { |
2106 | setAttributeClass(attribute.value().toString()); |
2107 | continue; |
2108 | } |
2109 | if (name == QLatin1String("name" )) { |
2110 | setAttributeName(attribute.value().toString()); |
2111 | continue; |
2112 | } |
2113 | if (name == QLatin1String("native" )) { |
2114 | setAttributeNative(attribute.value() == QLatin1String("true" )); |
2115 | continue; |
2116 | } |
2117 | reader.raiseError(QLatin1String("Unexpected attribute " ) + name); |
2118 | } |
2119 | |
2120 | while (!reader.hasError()) { |
2121 | switch (reader.readNext()) { |
2122 | case QXmlStreamReader::StartElement : { |
2123 | const auto tag = reader.name(); |
2124 | if (!tag.compare(QLatin1String("class" ), Qt::CaseInsensitive)) { |
2125 | m_class.append(reader.readElementText()); |
2126 | continue; |
2127 | } |
2128 | if (!tag.compare(QLatin1String("property" ), Qt::CaseInsensitive)) { |
2129 | auto *v = new DomProperty(); |
2130 | v->read(reader); |
2131 | m_property.append(v); |
2132 | continue; |
2133 | } |
2134 | if (!tag.compare(QLatin1String("script" ), Qt::CaseInsensitive)) { |
2135 | qWarning("Omitting deprecated element <script>." ); |
2136 | reader.skipCurrentElement(); |
2137 | continue; |
2138 | } |
2139 | if (!tag.compare(QLatin1String("widgetdata" ), Qt::CaseInsensitive)) { |
2140 | qWarning("Omitting deprecated element <widgetdata>." ); |
2141 | reader.skipCurrentElement(); |
2142 | continue; |
2143 | } |
2144 | if (!tag.compare(QLatin1String("attribute" ), Qt::CaseInsensitive)) { |
2145 | auto *v = new DomProperty(); |
2146 | v->read(reader); |
2147 | m_attribute.append(v); |
2148 | continue; |
2149 | } |
2150 | if (!tag.compare(QLatin1String("row" ), Qt::CaseInsensitive)) { |
2151 | auto *v = new DomRow(); |
2152 | v->read(reader); |
2153 | m_row.append(v); |
2154 | continue; |
2155 | } |
2156 | if (!tag.compare(QLatin1String("column" ), Qt::CaseInsensitive)) { |
2157 | auto *v = new DomColumn(); |
2158 | v->read(reader); |
2159 | m_column.append(v); |
2160 | continue; |
2161 | } |
2162 | if (!tag.compare(QLatin1String("item" ), Qt::CaseInsensitive)) { |
2163 | auto *v = new DomItem(); |
2164 | v->read(reader); |
2165 | m_item.append(v); |
2166 | continue; |
2167 | } |
2168 | if (!tag.compare(QLatin1String("layout" ), Qt::CaseInsensitive)) { |
2169 | auto *v = new DomLayout(); |
2170 | v->read(reader); |
2171 | m_layout.append(v); |
2172 | continue; |
2173 | } |
2174 | if (!tag.compare(QLatin1String("widget" ), Qt::CaseInsensitive)) { |
2175 | auto *v = new DomWidget(); |
2176 | v->read(reader); |
2177 | m_widget.append(v); |
2178 | continue; |
2179 | } |
2180 | if (!tag.compare(QLatin1String("action" ), Qt::CaseInsensitive)) { |
2181 | auto *v = new DomAction(); |
2182 | v->read(reader); |
2183 | m_action.append(v); |
2184 | continue; |
2185 | } |
2186 | if (!tag.compare(QLatin1String("actiongroup" ), Qt::CaseInsensitive)) { |
2187 | auto *v = new DomActionGroup(); |
2188 | v->read(reader); |
2189 | m_actionGroup.append(v); |
2190 | continue; |
2191 | } |
2192 | if (!tag.compare(QLatin1String("addaction" ), Qt::CaseInsensitive)) { |
2193 | auto *v = new DomActionRef(); |
2194 | v->read(reader); |
2195 | m_addAction.append(v); |
2196 | continue; |
2197 | } |
2198 | if (!tag.compare(QLatin1String("zorder" ), Qt::CaseInsensitive)) { |
2199 | m_zOrder.append(reader.readElementText()); |
2200 | continue; |
2201 | } |
2202 | reader.raiseError(QLatin1String("Unexpected element " ) + tag); |
2203 | } |
2204 | break; |
2205 | case QXmlStreamReader::EndElement : |
2206 | return; |
2207 | default : |
2208 | break; |
2209 | } |
2210 | } |
2211 | } |
2212 | |
2213 | void DomWidget::write(QXmlStreamWriter &writer, const QString &tagName) const |
2214 | { |
2215 | writer.writeStartElement(tagName.isEmpty() ? QStringLiteral("widget" ) : tagName.toLower()); |
2216 | |
2217 | if (hasAttributeClass()) |
2218 | writer.writeAttribute(QStringLiteral("class" ), attributeClass()); |
2219 | |
2220 | if (hasAttributeName()) |
2221 | writer.writeAttribute(QStringLiteral("name" ), attributeName()); |
2222 | |
2223 | if (hasAttributeNative()) |
2224 | writer.writeAttribute(QStringLiteral("native" ), (attributeNative() ? QLatin1String("true" ) : QLatin1String("false" ))); |
2225 | |
2226 | for (const QString &v : m_class) |
2227 | writer.writeTextElement(QStringLiteral("class" ), v); |
2228 | |
2229 | for (DomProperty *v : m_property) |
2230 | v->write(writer, QStringLiteral("property" )); |
2231 | |
2232 | for (DomProperty *v : m_attribute) |
2233 | v->write(writer, QStringLiteral("attribute" )); |
2234 | |
2235 | for (DomRow *v : m_row) |
2236 | v->write(writer, QStringLiteral("row" )); |
2237 | |
2238 | for (DomColumn *v : m_column) |
2239 | v->write(writer, QStringLiteral("column" )); |
2240 | |
2241 | for (DomItem *v : m_item) |
2242 | v->write(writer, QStringLiteral("item" )); |
2243 | |
2244 | for (DomLayout *v : m_layout) |
2245 | v->write(writer, QStringLiteral("layout" )); |
2246 | |
2247 | for (DomWidget *v : m_widget) |
2248 | v->write(writer, QStringLiteral("widget" )); |
2249 | |
2250 | for (DomAction *v : m_action) |
2251 | v->write(writer, QStringLiteral("action" )); |
2252 | |
2253 | for (DomActionGroup *v : m_actionGroup) |
2254 | v->write(writer, QStringLiteral("actiongroup" )); |
2255 | |
2256 | for (DomActionRef *v : m_addAction) |
2257 | v->write(writer, QStringLiteral("addaction" )); |
2258 | |
2259 | for (const QString &v : m_zOrder) |
2260 | writer.writeTextElement(QStringLiteral("zorder" ), v); |
2261 | |
2262 | writer.writeEndElement(); |
2263 | } |
2264 | |
2265 | void DomWidget::setElementClass(const QStringList &a) |
2266 | { |
2267 | m_children |= Class; |
2268 | m_class = a; |
2269 | } |
2270 | |
2271 | void DomWidget::setElementProperty(const QList<DomProperty *> &a) |
2272 | { |
2273 | m_children |= Property; |
2274 | m_property = a; |
2275 | } |
2276 | |
2277 | void DomWidget::setElementAttribute(const QList<DomProperty *> &a) |
2278 | { |
2279 | m_children |= Attribute; |
2280 | m_attribute = a; |
2281 | } |
2282 | |
2283 | void DomWidget::setElementRow(const QList<DomRow *> &a) |
2284 | { |
2285 | m_children |= Row; |
2286 | m_row = a; |
2287 | } |
2288 | |
2289 | void DomWidget::setElementColumn(const QList<DomColumn *> &a) |
2290 | { |
2291 | m_children |= Column; |
2292 | m_column = a; |
2293 | } |
2294 | |
2295 | void DomWidget::setElementItem(const QList<DomItem *> &a) |
2296 | { |
2297 | m_children |= Item; |
2298 | m_item = a; |
2299 | } |
2300 | |
2301 | void DomWidget::setElementLayout(const QList<DomLayout *> &a) |
2302 | { |
2303 | m_children |= Layout; |
2304 | m_layout = a; |
2305 | } |
2306 | |
2307 | void DomWidget::setElementWidget(const QList<DomWidget *> &a) |
2308 | { |
2309 | m_children |= Widget; |
2310 | m_widget = a; |
2311 | } |
2312 | |
2313 | void DomWidget::setElementAction(const QList<DomAction *> &a) |
2314 | { |
2315 | m_children |= Action; |
2316 | m_action = a; |
2317 | } |
2318 | |
2319 | void DomWidget::setElementActionGroup(const QList<DomActionGroup *> &a) |
2320 | { |
2321 | m_children |= ActionGroup; |
2322 | m_actionGroup = a; |
2323 | } |
2324 | |
2325 | void DomWidget::setElementAddAction(const QList<DomActionRef *> &a) |
2326 | { |
2327 | m_children |= AddAction; |
2328 | m_addAction = a; |
2329 | } |
2330 | |
2331 | void DomWidget::setElementZOrder(const QStringList &a) |
2332 | { |
2333 | m_children |= ZOrder; |
2334 | m_zOrder = a; |
2335 | } |
2336 | |
2337 | DomSpacer::~DomSpacer() |
2338 | { |
2339 | qDeleteAll(m_property); |
2340 | m_property.clear(); |
2341 | } |
2342 | |
2343 | void DomSpacer::read(QXmlStreamReader &reader) |
2344 | { |
2345 | const QXmlStreamAttributes &attributes = reader.attributes(); |
2346 | for (const QXmlStreamAttribute &attribute : attributes) { |
2347 | const auto name = attribute.name(); |
2348 | if (name == QLatin1String("name" )) { |
2349 | setAttributeName(attribute.value().toString()); |
2350 | continue; |
2351 | } |
2352 | reader.raiseError(QLatin1String("Unexpected attribute " ) + name); |
2353 | } |
2354 | |
2355 | while (!reader.hasError()) { |
2356 | switch (reader.readNext()) { |
2357 | case QXmlStreamReader::StartElement : { |
2358 | const auto tag = reader.name(); |
2359 | if (!tag.compare(QLatin1String("property" ), Qt::CaseInsensitive)) { |
2360 | auto *v = new DomProperty(); |
2361 | v->read(reader); |
2362 | m_property.append(v); |
2363 | continue; |
2364 | } |
2365 | reader.raiseError(QLatin1String("Unexpected element " ) + tag); |
2366 | } |
2367 | break; |
2368 | case QXmlStreamReader::EndElement : |
2369 | return; |
2370 | default : |
2371 | break; |
2372 | } |
2373 | } |
2374 | } |
2375 | |
2376 | void DomSpacer::write(QXmlStreamWriter &writer, const QString &tagName) const |
2377 | { |
2378 | writer.writeStartElement(tagName.isEmpty() ? QStringLiteral("spacer" ) : tagName.toLower()); |
2379 | |
2380 | if (hasAttributeName()) |
2381 | writer.writeAttribute(QStringLiteral("name" ), attributeName()); |
2382 | |
2383 | for (DomProperty *v : m_property) |
2384 | v->write(writer, QStringLiteral("property" )); |
2385 | |
2386 | writer.writeEndElement(); |
2387 | } |
2388 | |
2389 | void DomSpacer::setElementProperty(const QList<DomProperty *> &a) |
2390 | { |
2391 | m_children |= Property; |
2392 | m_property = a; |
2393 | } |
2394 | |
2395 | DomColor::~DomColor() = default; |
2396 | |
2397 | void DomColor::read(QXmlStreamReader &reader) |
2398 | { |
2399 | const QXmlStreamAttributes &attributes = reader.attributes(); |
2400 | for (const QXmlStreamAttribute &attribute : attributes) { |
2401 | const auto name = attribute.name(); |
2402 | if (name == QLatin1String("alpha" )) { |
2403 | setAttributeAlpha(attribute.value().toInt()); |
2404 | continue; |
2405 | } |
2406 | reader.raiseError(QLatin1String("Unexpected attribute " ) + name); |
2407 | } |
2408 | |
2409 | while (!reader.hasError()) { |
2410 | switch (reader.readNext()) { |
2411 | case QXmlStreamReader::StartElement : { |
2412 | const auto tag = reader.name(); |
2413 | if (!tag.compare(QLatin1String("red" ), Qt::CaseInsensitive)) { |
2414 | setElementRed(reader.readElementText().toInt()); |
2415 | continue; |
2416 | } |
2417 | if (!tag.compare(QLatin1String("green" ), Qt::CaseInsensitive)) { |
2418 | setElementGreen(reader.readElementText().toInt()); |
2419 | continue; |
2420 | } |
2421 | if (!tag.compare(QLatin1String("blue" ), Qt::CaseInsensitive)) { |
2422 | setElementBlue(reader.readElementText().toInt()); |
2423 | continue; |
2424 | } |
2425 | reader.raiseError(QLatin1String("Unexpected element " ) + tag); |
2426 | } |
2427 | break; |
2428 | case QXmlStreamReader::EndElement : |
2429 | return; |
2430 | default : |
2431 | break; |
2432 | } |
2433 | } |
2434 | } |
2435 | |
2436 | void DomColor::write(QXmlStreamWriter &writer, const QString &tagName) const |
2437 | { |
2438 | writer.writeStartElement(tagName.isEmpty() ? QStringLiteral("color" ) : tagName.toLower()); |
2439 | |
2440 | if (hasAttributeAlpha()) |
2441 | writer.writeAttribute(QStringLiteral("alpha" ), QString::number(attributeAlpha())); |
2442 | |
2443 | if (m_children & Red) |
2444 | writer.writeTextElement(QStringLiteral("red" ), QString::number(m_red)); |
2445 | |
2446 | if (m_children & Green) |
2447 | writer.writeTextElement(QStringLiteral("green" ), QString::number(m_green)); |
2448 | |
2449 | if (m_children & Blue) |
2450 | writer.writeTextElement(QStringLiteral("blue" ), QString::number(m_blue)); |
2451 | |
2452 | writer.writeEndElement(); |
2453 | } |
2454 | |
2455 | void DomColor::setElementRed(int a) |
2456 | { |
2457 | m_children |= Red; |
2458 | m_red = a; |
2459 | } |
2460 | |
2461 | void DomColor::setElementGreen(int a) |
2462 | { |
2463 | m_children |= Green; |
2464 | m_green = a; |
2465 | } |
2466 | |
2467 | void DomColor::setElementBlue(int a) |
2468 | { |
2469 | m_children |= Blue; |
2470 | m_blue = a; |
2471 | } |
2472 | |
2473 | void DomColor::clearElementRed() |
2474 | { |
2475 | m_children &= ~Red; |
2476 | } |
2477 | |
2478 | void DomColor::clearElementGreen() |
2479 | { |
2480 | m_children &= ~Green; |
2481 | } |
2482 | |
2483 | void DomColor::clearElementBlue() |
2484 | { |
2485 | m_children &= ~Blue; |
2486 | } |
2487 | |
2488 | DomGradientStop::~DomGradientStop() |
2489 | { |
2490 | delete m_color; |
2491 | } |
2492 | |
2493 | void DomGradientStop::read(QXmlStreamReader &reader) |
2494 | { |
2495 | const QXmlStreamAttributes &attributes = reader.attributes(); |
2496 | for (const QXmlStreamAttribute &attribute : attributes) { |
2497 | const auto name = attribute.name(); |
2498 | if (name == QLatin1String("position" )) { |
2499 | setAttributePosition(attribute.value().toDouble()); |
2500 | continue; |
2501 | } |
2502 | reader.raiseError(QLatin1String("Unexpected attribute " ) + name); |
2503 | } |
2504 | |
2505 | while (!reader.hasError()) { |
2506 | switch (reader.readNext()) { |
2507 | case QXmlStreamReader::StartElement : { |
2508 | const auto tag = reader.name(); |
2509 | if (!tag.compare(QLatin1String("color" ), Qt::CaseInsensitive)) { |
2510 | auto *v = new DomColor(); |
2511 | v->read(reader); |
2512 | setElementColor(v); |
2513 | continue; |
2514 | } |
2515 | reader.raiseError(QLatin1String("Unexpected element " ) + tag); |
2516 | } |
2517 | break; |
2518 | case QXmlStreamReader::EndElement : |
2519 | return; |
2520 | default : |
2521 | break; |
2522 | } |
2523 | } |
2524 | } |
2525 | |
2526 | void DomGradientStop::write(QXmlStreamWriter &writer, const QString &tagName) const |
2527 | { |
2528 | writer.writeStartElement(tagName.isEmpty() ? QStringLiteral("gradientstop" ) : tagName.toLower()); |
2529 | |
2530 | if (hasAttributePosition()) |
2531 | writer.writeAttribute(QStringLiteral("position" ), QString::number(attributePosition(), 'f', 15)); |
2532 | |
2533 | if (m_children & Color) |
2534 | m_color->write(writer, QStringLiteral("color" )); |
2535 | |
2536 | writer.writeEndElement(); |
2537 | } |
2538 | |
2539 | DomColor *DomGradientStop::takeElementColor() |
2540 | { |
2541 | DomColor *a = m_color; |
2542 | m_color = nullptr; |
2543 | m_children ^= Color; |
2544 | return a; |
2545 | } |
2546 | |
2547 | void DomGradientStop::setElementColor(DomColor *a) |
2548 | { |
2549 | delete m_color; |
2550 | m_children |= Color; |
2551 | m_color = a; |
2552 | } |
2553 | |
2554 | void DomGradientStop::clearElementColor() |
2555 | { |
2556 | delete m_color; |
2557 | m_color = nullptr; |
2558 | m_children &= ~Color; |
2559 | } |
2560 | |
2561 | DomGradient::~DomGradient() |
2562 | { |
2563 | qDeleteAll(m_gradientStop); |
2564 | m_gradientStop.clear(); |
2565 | } |
2566 | |
2567 | void DomGradient::read(QXmlStreamReader &reader) |
2568 | { |
2569 | const QXmlStreamAttributes &attributes = reader.attributes(); |
2570 | for (const QXmlStreamAttribute &attribute : attributes) { |
2571 | const auto name = attribute.name(); |
2572 | if (name == QLatin1String("startx" )) { |
2573 | setAttributeStartX(attribute.value().toDouble()); |
2574 | continue; |
2575 | } |
2576 | if (name == QLatin1String("starty" )) { |
2577 | setAttributeStartY(attribute.value().toDouble()); |
2578 | continue; |
2579 | } |
2580 | if (name == QLatin1String("endx" )) { |
2581 | setAttributeEndX(attribute.value().toDouble()); |
2582 | continue; |
2583 | } |
2584 | if (name == QLatin1String("endy" )) { |
2585 | setAttributeEndY(attribute.value().toDouble()); |
2586 | continue; |
2587 | } |
2588 | if (name == QLatin1String("centralx" )) { |
2589 | setAttributeCentralX(attribute.value().toDouble()); |
2590 | continue; |
2591 | } |
2592 | if (name == QLatin1String("centraly" )) { |
2593 | setAttributeCentralY(attribute.value().toDouble()); |
2594 | continue; |
2595 | } |
2596 | if (name == QLatin1String("focalx" )) { |
2597 | setAttributeFocalX(attribute.value().toDouble()); |
2598 | continue; |
2599 | } |
2600 | if (name == QLatin1String("focaly" )) { |
2601 | setAttributeFocalY(attribute.value().toDouble()); |
2602 | continue; |
2603 | } |
2604 | if (name == QLatin1String("radius" )) { |
2605 | setAttributeRadius(attribute.value().toDouble()); |
2606 | continue; |
2607 | } |
2608 | if (name == QLatin1String("angle" )) { |
2609 | setAttributeAngle(attribute.value().toDouble()); |
2610 | continue; |
2611 | } |
2612 | if (name == QLatin1String("type" )) { |
2613 | setAttributeType(attribute.value().toString()); |
2614 | continue; |
2615 | } |
2616 | if (name == QLatin1String("spread" )) { |
2617 | setAttributeSpread(attribute.value().toString()); |
2618 | continue; |
2619 | } |
2620 | if (name == QLatin1String("coordinatemode" )) { |
2621 | setAttributeCoordinateMode(attribute.value().toString()); |
2622 | continue; |
2623 | } |
2624 | reader.raiseError(QLatin1String("Unexpected attribute " ) + name); |
2625 | } |
2626 | |
2627 | while (!reader.hasError()) { |
2628 | switch (reader.readNext()) { |
2629 | case QXmlStreamReader::StartElement : { |
2630 | const auto tag = reader.name(); |
2631 | if (!tag.compare(QLatin1String("gradientstop" ), Qt::CaseInsensitive)) { |
2632 | auto *v = new DomGradientStop(); |
2633 | v->read(reader); |
2634 | m_gradientStop.append(v); |
2635 | continue; |
2636 | } |
2637 | reader.raiseError(QLatin1String("Unexpected element " ) + tag); |
2638 | } |
2639 | break; |
2640 | case QXmlStreamReader::EndElement : |
2641 | return; |
2642 | default : |
2643 | break; |
2644 | } |
2645 | } |
2646 | } |
2647 | |
2648 | void DomGradient::write(QXmlStreamWriter &writer, const QString &tagName) const |
2649 | { |
2650 | writer.writeStartElement(tagName.isEmpty() ? QStringLiteral("gradient" ) : tagName.toLower()); |
2651 | |
2652 | if (hasAttributeStartX()) |
2653 | writer.writeAttribute(QStringLiteral("startx" ), QString::number(attributeStartX(), 'f', 15)); |
2654 | |
2655 | if (hasAttributeStartY()) |
2656 | writer.writeAttribute(QStringLiteral("starty" ), QString::number(attributeStartY(), 'f', 15)); |
2657 | |
2658 | if (hasAttributeEndX()) |
2659 | writer.writeAttribute(QStringLiteral("endx" ), QString::number(attributeEndX(), 'f', 15)); |
2660 | |
2661 | if (hasAttributeEndY()) |
2662 | writer.writeAttribute(QStringLiteral("endy" ), QString::number(attributeEndY(), 'f', 15)); |
2663 | |
2664 | if (hasAttributeCentralX()) |
2665 | writer.writeAttribute(QStringLiteral("centralx" ), QString::number(attributeCentralX(), 'f', 15)); |
2666 | |
2667 | if (hasAttributeCentralY()) |
2668 | writer.writeAttribute(QStringLiteral("centraly" ), QString::number(attributeCentralY(), 'f', 15)); |
2669 | |
2670 | if (hasAttributeFocalX()) |
2671 | writer.writeAttribute(QStringLiteral("focalx" ), QString::number(attributeFocalX(), 'f', 15)); |
2672 | |
2673 | if (hasAttributeFocalY()) |
2674 | writer.writeAttribute(QStringLiteral("focaly" ), QString::number(attributeFocalY(), 'f', 15)); |
2675 | |
2676 | if (hasAttributeRadius()) |
2677 | writer.writeAttribute(QStringLiteral("radius" ), QString::number(attributeRadius(), 'f', 15)); |
2678 | |
2679 | if (hasAttributeAngle()) |
2680 | writer.writeAttribute(QStringLiteral("angle" ), QString::number(attributeAngle(), 'f', 15)); |
2681 | |
2682 | if (hasAttributeType()) |
2683 | writer.writeAttribute(QStringLiteral("type" ), attributeType()); |
2684 | |
2685 | if (hasAttributeSpread()) |
2686 | writer.writeAttribute(QStringLiteral("spread" ), attributeSpread()); |
2687 | |
2688 | if (hasAttributeCoordinateMode()) |
2689 | writer.writeAttribute(QStringLiteral("coordinatemode" ), attributeCoordinateMode()); |
2690 | |
2691 | for (DomGradientStop *v : m_gradientStop) |
2692 | v->write(writer, QStringLiteral("gradientstop" )); |
2693 | |
2694 | writer.writeEndElement(); |
2695 | } |
2696 | |
2697 | void DomGradient::setElementGradientStop(const QList<DomGradientStop *> &a) |
2698 | { |
2699 | m_children |= GradientStop; |
2700 | m_gradientStop = a; |
2701 | } |
2702 | |
2703 | DomBrush::~DomBrush() |
2704 | { |
2705 | delete m_color; |
2706 | delete m_texture; |
2707 | delete m_gradient; |
2708 | } |
2709 | |
2710 | void DomBrush::clear() |
2711 | { |
2712 | delete m_color; |
2713 | delete m_texture; |
2714 | delete m_gradient; |
2715 | |
2716 | m_kind = Unknown; |
2717 | |
2718 | m_color = nullptr; |
2719 | m_texture = nullptr; |
2720 | m_gradient = nullptr; |
2721 | } |
2722 | |
2723 | void DomBrush::read(QXmlStreamReader &reader) |
2724 | { |
2725 | const QXmlStreamAttributes &attributes = reader.attributes(); |
2726 | for (const QXmlStreamAttribute &attribute : attributes) { |
2727 | const auto name = attribute.name(); |
2728 | if (name == QLatin1String("brushstyle" )) { |
2729 | setAttributeBrushStyle(attribute.value().toString()); |
2730 | continue; |
2731 | } |
2732 | reader.raiseError(QLatin1String("Unexpected attribute " ) + name); |
2733 | } |
2734 | |
2735 | while (!reader.hasError()) { |
2736 | switch (reader.readNext()) { |
2737 | case QXmlStreamReader::StartElement : { |
2738 | const auto tag = reader.name(); |
2739 | if (!tag.compare(QLatin1String("color" ), Qt::CaseInsensitive)) { |
2740 | auto *v = new DomColor(); |
2741 | v->read(reader); |
2742 | setElementColor(v); |
2743 | continue; |
2744 | } |
2745 | if (!tag.compare(QLatin1String("texture" ), Qt::CaseInsensitive)) { |
2746 | auto *v = new DomProperty(); |
2747 | v->read(reader); |
2748 | setElementTexture(v); |
2749 | continue; |
2750 | } |
2751 | if (!tag.compare(QLatin1String("gradient" ), Qt::CaseInsensitive)) { |
2752 | auto *v = new DomGradient |
---|