Mercurial > projects > qtd
comparison tools/duic/ui4.cpp @ 1:e78566595089
initial import
author | mandel |
---|---|
date | Mon, 11 May 2009 16:01:50 +0000 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
0:36fb74dc547d | 1:e78566595089 |
---|---|
1 /**************************************************************************** | |
2 ** | |
3 ** Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies). | |
4 ** Contact: Qt Software Information (qt-info@nokia.com) | |
5 ** | |
6 ** This file is part of the tools applications of the Qt Toolkit. | |
7 ** | |
8 ** Commercial Usage | |
9 ** Licensees holding valid Qt Commercial licenses may use this file in | |
10 ** accordance with the Qt Commercial License Agreement provided with the | |
11 ** Software or, alternatively, in accordance with the terms contained in | |
12 ** a written agreement between you and Nokia. | |
13 ** | |
14 ** | |
15 ** GNU General Public License Usage | |
16 ** Alternatively, this file may be used under the terms of the GNU | |
17 ** General Public License versions 2.0 or 3.0 as published by the Free | |
18 ** Software Foundation and appearing in the file LICENSE.GPL included in | |
19 ** the packaging of this file. Please review the following information | |
20 ** to ensure GNU General Public Licensing requirements will be met: | |
21 ** http://www.fsf.org/licensing/licenses/info/GPLv2.html and | |
22 ** http://www.gnu.org/copyleft/gpl.html. In addition, as a special | |
23 ** exception, Nokia gives you certain additional rights. These rights | |
24 ** are described in the Nokia Qt GPL Exception version 1.3, included in | |
25 ** the file GPL_EXCEPTION.txt in this package. | |
26 ** | |
27 ** Qt for Windows(R) Licensees | |
28 ** As a special exception, Nokia, as the sole copyright holder for Qt | |
29 ** Designer, grants users of the Qt/Eclipse Integration plug-in the | |
30 ** right for the Qt/Eclipse Integration to link to functionality | |
31 ** provided by Qt Designer and its related libraries. | |
32 ** | |
33 ** If you are unsure which license is appropriate for your use, please | |
34 ** contact the sales department at qt-sales@nokia.com. | |
35 ** | |
36 ****************************************************************************/ | |
37 #include "ui4.h" | |
38 #include <QtXml/QDomDocument> | |
39 | |
40 QT_BEGIN_NAMESPACE | |
41 #ifdef QFORMINTERNAL_NAMESPACE | |
42 using namespace QFormInternal; | |
43 #endif | |
44 | |
45 /******************************************************************************* | |
46 ** Implementations | |
47 */ | |
48 | |
49 void DomUI::clear(bool clear_all) | |
50 { | |
51 delete m_widget; | |
52 delete m_layoutDefault; | |
53 delete m_layoutFunction; | |
54 delete m_customWidgets; | |
55 delete m_tabStops; | |
56 delete m_images; | |
57 delete m_includes; | |
58 delete m_resources; | |
59 delete m_connections; | |
60 delete m_designerdata; | |
61 delete m_slots; | |
62 | |
63 if (clear_all) { | |
64 m_text = QString(); | |
65 m_has_attr_version = false; | |
66 m_has_attr_language = false; | |
67 m_has_attr_stdSetDef = false; | |
68 m_attr_stdSetDef = 0; | |
69 } | |
70 | |
71 m_children = 0; | |
72 m_widget = 0; | |
73 m_layoutDefault = 0; | |
74 m_layoutFunction = 0; | |
75 m_customWidgets = 0; | |
76 m_tabStops = 0; | |
77 m_images = 0; | |
78 m_includes = 0; | |
79 m_resources = 0; | |
80 m_connections = 0; | |
81 m_designerdata = 0; | |
82 m_slots = 0; | |
83 } | |
84 | |
85 DomUI::DomUI() | |
86 { | |
87 m_children = 0; | |
88 m_has_attr_version = false; | |
89 m_has_attr_language = false; | |
90 m_has_attr_stdSetDef = false; | |
91 m_attr_stdSetDef = 0; | |
92 m_widget = 0; | |
93 m_layoutDefault = 0; | |
94 m_layoutFunction = 0; | |
95 m_customWidgets = 0; | |
96 m_tabStops = 0; | |
97 m_images = 0; | |
98 m_includes = 0; | |
99 m_resources = 0; | |
100 m_connections = 0; | |
101 m_designerdata = 0; | |
102 m_slots = 0; | |
103 } | |
104 | |
105 DomUI::~DomUI() | |
106 { | |
107 delete m_widget; | |
108 delete m_layoutDefault; | |
109 delete m_layoutFunction; | |
110 delete m_customWidgets; | |
111 delete m_tabStops; | |
112 delete m_images; | |
113 delete m_includes; | |
114 delete m_resources; | |
115 delete m_connections; | |
116 delete m_designerdata; | |
117 delete m_slots; | |
118 } | |
119 | |
120 void DomUI::read(const QDomElement &node) | |
121 { | |
122 if (node.hasAttribute(QLatin1String("version"))) | |
123 setAttributeVersion(node.attribute(QLatin1String("version"))); | |
124 if (node.hasAttribute(QLatin1String("language"))) | |
125 setAttributeLanguage(node.attribute(QLatin1String("language"))); | |
126 if (node.hasAttribute(QLatin1String("stdsetdef"))) | |
127 setAttributeStdSetDef(node.attribute(QLatin1String("stdsetdef")).toInt()); | |
128 | |
129 for (QDomNode n = node.firstChild(); !n.isNull(); n = n.nextSibling()) { | |
130 if (!n.isElement()) | |
131 continue; | |
132 QDomElement e = n.toElement(); | |
133 QString tag = e.tagName().toLower(); | |
134 if (tag == QLatin1String("author")) { | |
135 setElementAuthor(e.text()); | |
136 continue; | |
137 } | |
138 if (tag == QLatin1String("comment")) { | |
139 setElementComment(e.text()); | |
140 continue; | |
141 } | |
142 if (tag == QLatin1String("exportmacro")) { | |
143 setElementExportMacro(e.text()); | |
144 continue; | |
145 } | |
146 if (tag == QLatin1String("class")) { | |
147 setElementClass(e.text()); | |
148 continue; | |
149 } | |
150 if (tag == QLatin1String("widget")) { | |
151 DomWidget *v = new DomWidget(); | |
152 v->read(e); | |
153 setElementWidget(v); | |
154 continue; | |
155 } | |
156 if (tag == QLatin1String("layoutdefault")) { | |
157 DomLayoutDefault *v = new DomLayoutDefault(); | |
158 v->read(e); | |
159 setElementLayoutDefault(v); | |
160 continue; | |
161 } | |
162 if (tag == QLatin1String("layoutfunction")) { | |
163 DomLayoutFunction *v = new DomLayoutFunction(); | |
164 v->read(e); | |
165 setElementLayoutFunction(v); | |
166 continue; | |
167 } | |
168 if (tag == QLatin1String("pixmapfunction")) { | |
169 setElementPixmapFunction(e.text()); | |
170 continue; | |
171 } | |
172 if (tag == QLatin1String("customwidgets")) { | |
173 DomCustomWidgets *v = new DomCustomWidgets(); | |
174 v->read(e); | |
175 setElementCustomWidgets(v); | |
176 continue; | |
177 } | |
178 if (tag == QLatin1String("tabstops")) { | |
179 DomTabStops *v = new DomTabStops(); | |
180 v->read(e); | |
181 setElementTabStops(v); | |
182 continue; | |
183 } | |
184 if (tag == QLatin1String("images")) { | |
185 DomImages *v = new DomImages(); | |
186 v->read(e); | |
187 setElementImages(v); | |
188 continue; | |
189 } | |
190 if (tag == QLatin1String("includes")) { | |
191 DomIncludes *v = new DomIncludes(); | |
192 v->read(e); | |
193 setElementIncludes(v); | |
194 continue; | |
195 } | |
196 if (tag == QLatin1String("resources")) { | |
197 DomResources *v = new DomResources(); | |
198 v->read(e); | |
199 setElementResources(v); | |
200 continue; | |
201 } | |
202 if (tag == QLatin1String("connections")) { | |
203 DomConnections *v = new DomConnections(); | |
204 v->read(e); | |
205 setElementConnections(v); | |
206 continue; | |
207 } | |
208 if (tag == QLatin1String("designerdata")) { | |
209 DomDesignerData *v = new DomDesignerData(); | |
210 v->read(e); | |
211 setElementDesignerdata(v); | |
212 continue; | |
213 } | |
214 if (tag == QLatin1String("slots")) { | |
215 DomSlots *v = new DomSlots(); | |
216 v->read(e); | |
217 setElementSlots(v); | |
218 continue; | |
219 } | |
220 } | |
221 | |
222 m_text.clear(); | |
223 for (QDomNode child = node.firstChild(); !child.isNull(); child = child.nextSibling()) { | |
224 if (child.isText()) | |
225 m_text.append(child.nodeValue()); | |
226 } | |
227 } | |
228 | |
229 QDomElement DomUI::write(QDomDocument &doc, const QString &tagName) const | |
230 { | |
231 QDomElement e = doc.createElement(tagName.isEmpty() ? QString::fromUtf8("ui") : tagName.toLower()); | |
232 | |
233 QDomElement child; | |
234 | |
235 if (hasAttributeVersion()) | |
236 e.setAttribute(QLatin1String("version"), attributeVersion()); | |
237 | |
238 if (hasAttributeLanguage()) | |
239 e.setAttribute(QLatin1String("language"), attributeLanguage()); | |
240 | |
241 if (hasAttributeStdSetDef()) | |
242 e.setAttribute(QLatin1String("stdsetdef"), attributeStdSetDef()); | |
243 | |
244 if (m_children & Author) { | |
245 child = doc.createElement(QLatin1String("author")); | |
246 child.appendChild(doc.createTextNode(m_author)); | |
247 e.appendChild(child); | |
248 } | |
249 | |
250 if (m_children & Comment) { | |
251 child = doc.createElement(QLatin1String("comment")); | |
252 child.appendChild(doc.createTextNode(m_comment)); | |
253 e.appendChild(child); | |
254 } | |
255 | |
256 if (m_children & ExportMacro) { | |
257 child = doc.createElement(QLatin1String("exportmacro")); | |
258 child.appendChild(doc.createTextNode(m_exportMacro)); | |
259 e.appendChild(child); | |
260 } | |
261 | |
262 if (m_children & Class) { | |
263 child = doc.createElement(QLatin1String("class")); | |
264 child.appendChild(doc.createTextNode(m_class)); | |
265 e.appendChild(child); | |
266 } | |
267 | |
268 if (m_children & Widget) { | |
269 e.appendChild(m_widget->write(doc, QLatin1String("widget"))); | |
270 } | |
271 | |
272 if (m_children & LayoutDefault) { | |
273 e.appendChild(m_layoutDefault->write(doc, QLatin1String("layoutdefault"))); | |
274 } | |
275 | |
276 if (m_children & LayoutFunction) { | |
277 e.appendChild(m_layoutFunction->write(doc, QLatin1String("layoutfunction"))); | |
278 } | |
279 | |
280 if (m_children & PixmapFunction) { | |
281 child = doc.createElement(QLatin1String("pixmapfunction")); | |
282 child.appendChild(doc.createTextNode(m_pixmapFunction)); | |
283 e.appendChild(child); | |
284 } | |
285 | |
286 if (m_children & CustomWidgets) { | |
287 e.appendChild(m_customWidgets->write(doc, QLatin1String("customwidgets"))); | |
288 } | |
289 | |
290 if (m_children & TabStops) { | |
291 e.appendChild(m_tabStops->write(doc, QLatin1String("tabstops"))); | |
292 } | |
293 | |
294 if (m_children & Images) { | |
295 e.appendChild(m_images->write(doc, QLatin1String("images"))); | |
296 } | |
297 | |
298 if (m_children & Includes) { | |
299 e.appendChild(m_includes->write(doc, QLatin1String("includes"))); | |
300 } | |
301 | |
302 if (m_children & Resources) { | |
303 e.appendChild(m_resources->write(doc, QLatin1String("resources"))); | |
304 } | |
305 | |
306 if (m_children & Connections) { | |
307 e.appendChild(m_connections->write(doc, QLatin1String("connections"))); | |
308 } | |
309 | |
310 if (m_children & Designerdata) { | |
311 e.appendChild(m_designerdata->write(doc, QLatin1String("designerdata"))); | |
312 } | |
313 | |
314 if (m_children & Slots) { | |
315 e.appendChild(m_slots->write(doc, QLatin1String("slots"))); | |
316 } | |
317 | |
318 if (!m_text.isEmpty()) | |
319 e.appendChild(doc.createTextNode(m_text)); | |
320 | |
321 return e; | |
322 } | |
323 | |
324 void DomUI::setElementAuthor(const QString& a) | |
325 { | |
326 m_children |= Author; | |
327 m_author = a; | |
328 } | |
329 | |
330 void DomUI::setElementComment(const QString& a) | |
331 { | |
332 m_children |= Comment; | |
333 m_comment = a; | |
334 } | |
335 | |
336 void DomUI::setElementExportMacro(const QString& a) | |
337 { | |
338 m_children |= ExportMacro; | |
339 m_exportMacro = a; | |
340 } | |
341 | |
342 void DomUI::setElementClass(const QString& a) | |
343 { | |
344 m_children |= Class; | |
345 m_class = a; | |
346 } | |
347 | |
348 void DomUI::setElementWidget(DomWidget* a) | |
349 { | |
350 delete m_widget; | |
351 m_children |= Widget; | |
352 m_widget = a; | |
353 } | |
354 | |
355 void DomUI::setElementLayoutDefault(DomLayoutDefault* a) | |
356 { | |
357 delete m_layoutDefault; | |
358 m_children |= LayoutDefault; | |
359 m_layoutDefault = a; | |
360 } | |
361 | |
362 void DomUI::setElementLayoutFunction(DomLayoutFunction* a) | |
363 { | |
364 delete m_layoutFunction; | |
365 m_children |= LayoutFunction; | |
366 m_layoutFunction = a; | |
367 } | |
368 | |
369 void DomUI::setElementPixmapFunction(const QString& a) | |
370 { | |
371 m_children |= PixmapFunction; | |
372 m_pixmapFunction = a; | |
373 } | |
374 | |
375 void DomUI::setElementCustomWidgets(DomCustomWidgets* a) | |
376 { | |
377 delete m_customWidgets; | |
378 m_children |= CustomWidgets; | |
379 m_customWidgets = a; | |
380 } | |
381 | |
382 void DomUI::setElementTabStops(DomTabStops* a) | |
383 { | |
384 delete m_tabStops; | |
385 m_children |= TabStops; | |
386 m_tabStops = a; | |
387 } | |
388 | |
389 void DomUI::setElementImages(DomImages* a) | |
390 { | |
391 delete m_images; | |
392 m_children |= Images; | |
393 m_images = a; | |
394 } | |
395 | |
396 void DomUI::setElementIncludes(DomIncludes* a) | |
397 { | |
398 delete m_includes; | |
399 m_children |= Includes; | |
400 m_includes = a; | |
401 } | |
402 | |
403 void DomUI::setElementResources(DomResources* a) | |
404 { | |
405 delete m_resources; | |
406 m_children |= Resources; | |
407 m_resources = a; | |
408 } | |
409 | |
410 void DomUI::setElementConnections(DomConnections* a) | |
411 { | |
412 delete m_connections; | |
413 m_children |= Connections; | |
414 m_connections = a; | |
415 } | |
416 | |
417 void DomUI::setElementDesignerdata(DomDesignerData* a) | |
418 { | |
419 delete m_designerdata; | |
420 m_children |= Designerdata; | |
421 m_designerdata = a; | |
422 } | |
423 | |
424 void DomUI::setElementSlots(DomSlots* a) | |
425 { | |
426 delete m_slots; | |
427 m_children |= Slots; | |
428 m_slots = a; | |
429 } | |
430 | |
431 void DomUI::clearElementAuthor() | |
432 { | |
433 m_children &= ~Author; | |
434 } | |
435 | |
436 void DomUI::clearElementComment() | |
437 { | |
438 m_children &= ~Comment; | |
439 } | |
440 | |
441 void DomUI::clearElementExportMacro() | |
442 { | |
443 m_children &= ~ExportMacro; | |
444 } | |
445 | |
446 void DomUI::clearElementClass() | |
447 { | |
448 m_children &= ~Class; | |
449 } | |
450 | |
451 void DomUI::clearElementWidget() | |
452 { | |
453 delete m_widget; | |
454 m_widget = 0; | |
455 m_children &= ~Widget; | |
456 } | |
457 | |
458 void DomUI::clearElementLayoutDefault() | |
459 { | |
460 delete m_layoutDefault; | |
461 m_layoutDefault = 0; | |
462 m_children &= ~LayoutDefault; | |
463 } | |
464 | |
465 void DomUI::clearElementLayoutFunction() | |
466 { | |
467 delete m_layoutFunction; | |
468 m_layoutFunction = 0; | |
469 m_children &= ~LayoutFunction; | |
470 } | |
471 | |
472 void DomUI::clearElementPixmapFunction() | |
473 { | |
474 m_children &= ~PixmapFunction; | |
475 } | |
476 | |
477 void DomUI::clearElementCustomWidgets() | |
478 { | |
479 delete m_customWidgets; | |
480 m_customWidgets = 0; | |
481 m_children &= ~CustomWidgets; | |
482 } | |
483 | |
484 void DomUI::clearElementTabStops() | |
485 { | |
486 delete m_tabStops; | |
487 m_tabStops = 0; | |
488 m_children &= ~TabStops; | |
489 } | |
490 | |
491 void DomUI::clearElementImages() | |
492 { | |
493 delete m_images; | |
494 m_images = 0; | |
495 m_children &= ~Images; | |
496 } | |
497 | |
498 void DomUI::clearElementIncludes() | |
499 { | |
500 delete m_includes; | |
501 m_includes = 0; | |
502 m_children &= ~Includes; | |
503 } | |
504 | |
505 void DomUI::clearElementResources() | |
506 { | |
507 delete m_resources; | |
508 m_resources = 0; | |
509 m_children &= ~Resources; | |
510 } | |
511 | |
512 void DomUI::clearElementConnections() | |
513 { | |
514 delete m_connections; | |
515 m_connections = 0; | |
516 m_children &= ~Connections; | |
517 } | |
518 | |
519 void DomUI::clearElementDesignerdata() | |
520 { | |
521 delete m_designerdata; | |
522 m_designerdata = 0; | |
523 m_children &= ~Designerdata; | |
524 } | |
525 | |
526 void DomUI::clearElementSlots() | |
527 { | |
528 delete m_slots; | |
529 m_slots = 0; | |
530 m_children &= ~Slots; | |
531 } | |
532 | |
533 void DomIncludes::clear(bool clear_all) | |
534 { | |
535 for (int i = 0; i < m_include.size(); ++i) | |
536 delete m_include[i]; | |
537 m_include.clear(); | |
538 | |
539 if (clear_all) { | |
540 m_text = QString(); | |
541 } | |
542 | |
543 } | |
544 | |
545 DomIncludes::DomIncludes() | |
546 { | |
547 } | |
548 | |
549 DomIncludes::~DomIncludes() | |
550 { | |
551 for (int i = 0; i < m_include.size(); ++i) | |
552 delete m_include[i]; | |
553 m_include.clear(); | |
554 } | |
555 | |
556 void DomIncludes::read(const QDomElement &node) | |
557 { | |
558 | |
559 for (QDomNode n = node.firstChild(); !n.isNull(); n = n.nextSibling()) { | |
560 if (!n.isElement()) | |
561 continue; | |
562 QDomElement e = n.toElement(); | |
563 QString tag = e.tagName().toLower(); | |
564 if (tag == QLatin1String("include")) { | |
565 DomInclude *v = new DomInclude(); | |
566 v->read(e); | |
567 m_include.append(v); | |
568 continue; | |
569 } | |
570 } | |
571 | |
572 m_text.clear(); | |
573 for (QDomNode child = node.firstChild(); !child.isNull(); child = child.nextSibling()) { | |
574 if (child.isText()) | |
575 m_text.append(child.nodeValue()); | |
576 } | |
577 } | |
578 | |
579 QDomElement DomIncludes::write(QDomDocument &doc, const QString &tagName) const | |
580 { | |
581 QDomElement e = doc.createElement(tagName.isEmpty() ? QString::fromUtf8("includes") : tagName.toLower()); | |
582 | |
583 QDomElement child; | |
584 | |
585 for (int i = 0; i < m_include.size(); ++i) { | |
586 DomInclude* v = m_include[i]; | |
587 QDomNode child = v->write(doc, QLatin1String("include")); | |
588 e.appendChild(child); | |
589 } | |
590 if (!m_text.isEmpty()) | |
591 e.appendChild(doc.createTextNode(m_text)); | |
592 | |
593 return e; | |
594 } | |
595 | |
596 void DomIncludes::setElementInclude(const QList<DomInclude*>& a) | |
597 { | |
598 m_include = a; | |
599 } | |
600 | |
601 void DomInclude::clear(bool clear_all) | |
602 { | |
603 | |
604 if (clear_all) { | |
605 m_text = QString(); | |
606 m_has_attr_location = false; | |
607 m_has_attr_impldecl = false; | |
608 } | |
609 | |
610 } | |
611 | |
612 DomInclude::DomInclude() | |
613 { | |
614 m_has_attr_location = false; | |
615 m_has_attr_impldecl = false; | |
616 } | |
617 | |
618 DomInclude::~DomInclude() | |
619 { | |
620 } | |
621 | |
622 void DomInclude::read(const QDomElement &node) | |
623 { | |
624 if (node.hasAttribute(QLatin1String("location"))) | |
625 setAttributeLocation(node.attribute(QLatin1String("location"))); | |
626 if (node.hasAttribute(QLatin1String("impldecl"))) | |
627 setAttributeImpldecl(node.attribute(QLatin1String("impldecl"))); | |
628 | |
629 for (QDomNode n = node.firstChild(); !n.isNull(); n = n.nextSibling()) { | |
630 if (!n.isElement()) | |
631 continue; | |
632 QDomElement e = n.toElement(); | |
633 QString tag = e.tagName().toLower(); | |
634 } | |
635 | |
636 m_text.clear(); | |
637 for (QDomNode child = node.firstChild(); !child.isNull(); child = child.nextSibling()) { | |
638 if (child.isText()) | |
639 m_text.append(child.nodeValue()); | |
640 } | |
641 } | |
642 | |
643 QDomElement DomInclude::write(QDomDocument &doc, const QString &tagName) const | |
644 { | |
645 QDomElement e = doc.createElement(tagName.isEmpty() ? QString::fromUtf8("include") : tagName.toLower()); | |
646 | |
647 QDomElement child; | |
648 | |
649 if (hasAttributeLocation()) | |
650 e.setAttribute(QLatin1String("location"), attributeLocation()); | |
651 | |
652 if (hasAttributeImpldecl()) | |
653 e.setAttribute(QLatin1String("impldecl"), attributeImpldecl()); | |
654 | |
655 if (!m_text.isEmpty()) | |
656 e.appendChild(doc.createTextNode(m_text)); | |
657 | |
658 return e; | |
659 } | |
660 | |
661 void DomResources::clear(bool clear_all) | |
662 { | |
663 for (int i = 0; i < m_include.size(); ++i) | |
664 delete m_include[i]; | |
665 m_include.clear(); | |
666 | |
667 if (clear_all) { | |
668 m_text = QString(); | |
669 m_has_attr_name = false; | |
670 } | |
671 | |
672 } | |
673 | |
674 DomResources::DomResources() | |
675 { | |
676 m_has_attr_name = false; | |
677 } | |
678 | |
679 DomResources::~DomResources() | |
680 { | |
681 for (int i = 0; i < m_include.size(); ++i) | |
682 delete m_include[i]; | |
683 m_include.clear(); | |
684 } | |
685 | |
686 void DomResources::read(const QDomElement &node) | |
687 { | |
688 if (node.hasAttribute(QLatin1String("name"))) | |
689 setAttributeName(node.attribute(QLatin1String("name"))); | |
690 | |
691 for (QDomNode n = node.firstChild(); !n.isNull(); n = n.nextSibling()) { | |
692 if (!n.isElement()) | |
693 continue; | |
694 QDomElement e = n.toElement(); | |
695 QString tag = e.tagName().toLower(); | |
696 if (tag == QLatin1String("include")) { | |
697 DomResource *v = new DomResource(); | |
698 v->read(e); | |
699 m_include.append(v); | |
700 continue; | |
701 } | |
702 } | |
703 | |
704 m_text.clear(); | |
705 for (QDomNode child = node.firstChild(); !child.isNull(); child = child.nextSibling()) { | |
706 if (child.isText()) | |
707 m_text.append(child.nodeValue()); | |
708 } | |
709 } | |
710 | |
711 QDomElement DomResources::write(QDomDocument &doc, const QString &tagName) const | |
712 { | |
713 QDomElement e = doc.createElement(tagName.isEmpty() ? QString::fromUtf8("resources") : tagName.toLower()); | |
714 | |
715 QDomElement child; | |
716 | |
717 if (hasAttributeName()) | |
718 e.setAttribute(QLatin1String("name"), attributeName()); | |
719 | |
720 for (int i = 0; i < m_include.size(); ++i) { | |
721 DomResource* v = m_include[i]; | |
722 QDomNode child = v->write(doc, QLatin1String("include")); | |
723 e.appendChild(child); | |
724 } | |
725 if (!m_text.isEmpty()) | |
726 e.appendChild(doc.createTextNode(m_text)); | |
727 | |
728 return e; | |
729 } | |
730 | |
731 void DomResources::setElementInclude(const QList<DomResource*>& a) | |
732 { | |
733 m_include = a; | |
734 } | |
735 | |
736 void DomResource::clear(bool clear_all) | |
737 { | |
738 | |
739 if (clear_all) { | |
740 m_text = QString(); | |
741 m_has_attr_location = false; | |
742 } | |
743 | |
744 } | |
745 | |
746 DomResource::DomResource() | |
747 { | |
748 m_has_attr_location = false; | |
749 } | |
750 | |
751 DomResource::~DomResource() | |
752 { | |
753 } | |
754 | |
755 void DomResource::read(const QDomElement &node) | |
756 { | |
757 if (node.hasAttribute(QLatin1String("location"))) | |
758 setAttributeLocation(node.attribute(QLatin1String("location"))); | |
759 | |
760 for (QDomNode n = node.firstChild(); !n.isNull(); n = n.nextSibling()) { | |
761 if (!n.isElement()) | |
762 continue; | |
763 QDomElement e = n.toElement(); | |
764 QString tag = e.tagName().toLower(); | |
765 } | |
766 | |
767 m_text.clear(); | |
768 for (QDomNode child = node.firstChild(); !child.isNull(); child = child.nextSibling()) { | |
769 if (child.isText()) | |
770 m_text.append(child.nodeValue()); | |
771 } | |
772 } | |
773 | |
774 QDomElement DomResource::write(QDomDocument &doc, const QString &tagName) const | |
775 { | |
776 QDomElement e = doc.createElement(tagName.isEmpty() ? QString::fromUtf8("resource") : tagName.toLower()); | |
777 | |
778 QDomElement child; | |
779 | |
780 if (hasAttributeLocation()) | |
781 e.setAttribute(QLatin1String("location"), attributeLocation()); | |
782 | |
783 if (!m_text.isEmpty()) | |
784 e.appendChild(doc.createTextNode(m_text)); | |
785 | |
786 return e; | |
787 } | |
788 | |
789 void DomActionGroup::clear(bool clear_all) | |
790 { | |
791 for (int i = 0; i < m_action.size(); ++i) | |
792 delete m_action[i]; | |
793 m_action.clear(); | |
794 for (int i = 0; i < m_actionGroup.size(); ++i) | |
795 delete m_actionGroup[i]; | |
796 m_actionGroup.clear(); | |
797 for (int i = 0; i < m_property.size(); ++i) | |
798 delete m_property[i]; | |
799 m_property.clear(); | |
800 for (int i = 0; i < m_attribute.size(); ++i) | |
801 delete m_attribute[i]; | |
802 m_attribute.clear(); | |
803 | |
804 if (clear_all) { | |
805 m_text = QString(); | |
806 m_has_attr_name = false; | |
807 } | |
808 | |
809 } | |
810 | |
811 DomActionGroup::DomActionGroup() | |
812 { | |
813 m_has_attr_name = false; | |
814 } | |
815 | |
816 DomActionGroup::~DomActionGroup() | |
817 { | |
818 for (int i = 0; i < m_action.size(); ++i) | |
819 delete m_action[i]; | |
820 m_action.clear(); | |
821 for (int i = 0; i < m_actionGroup.size(); ++i) | |
822 delete m_actionGroup[i]; | |
823 m_actionGroup.clear(); | |
824 for (int i = 0; i < m_property.size(); ++i) | |
825 delete m_property[i]; | |
826 m_property.clear(); | |
827 for (int i = 0; i < m_attribute.size(); ++i) | |
828 delete m_attribute[i]; | |
829 m_attribute.clear(); | |
830 } | |
831 | |
832 void DomActionGroup::read(const QDomElement &node) | |
833 { | |
834 if (node.hasAttribute(QLatin1String("name"))) | |
835 setAttributeName(node.attribute(QLatin1String("name"))); | |
836 | |
837 for (QDomNode n = node.firstChild(); !n.isNull(); n = n.nextSibling()) { | |
838 if (!n.isElement()) | |
839 continue; | |
840 QDomElement e = n.toElement(); | |
841 QString tag = e.tagName().toLower(); | |
842 if (tag == QLatin1String("action")) { | |
843 DomAction *v = new DomAction(); | |
844 v->read(e); | |
845 m_action.append(v); | |
846 continue; | |
847 } | |
848 if (tag == QLatin1String("actiongroup")) { | |
849 DomActionGroup *v = new DomActionGroup(); | |
850 v->read(e); | |
851 m_actionGroup.append(v); | |
852 continue; | |
853 } | |
854 if (tag == QLatin1String("property")) { | |
855 DomProperty *v = new DomProperty(); | |
856 v->read(e); | |
857 m_property.append(v); | |
858 continue; | |
859 } | |
860 if (tag == QLatin1String("attribute")) { | |
861 DomProperty *v = new DomProperty(); | |
862 v->read(e); | |
863 m_attribute.append(v); | |
864 continue; | |
865 } | |
866 } | |
867 | |
868 m_text.clear(); | |
869 for (QDomNode child = node.firstChild(); !child.isNull(); child = child.nextSibling()) { | |
870 if (child.isText()) | |
871 m_text.append(child.nodeValue()); | |
872 } | |
873 } | |
874 | |
875 QDomElement DomActionGroup::write(QDomDocument &doc, const QString &tagName) const | |
876 { | |
877 QDomElement e = doc.createElement(tagName.isEmpty() ? QString::fromUtf8("actiongroup") : tagName.toLower()); | |
878 | |
879 QDomElement child; | |
880 | |
881 if (hasAttributeName()) | |
882 e.setAttribute(QLatin1String("name"), attributeName()); | |
883 | |
884 for (int i = 0; i < m_action.size(); ++i) { | |
885 DomAction* v = m_action[i]; | |
886 QDomNode child = v->write(doc, QLatin1String("action")); | |
887 e.appendChild(child); | |
888 } | |
889 for (int i = 0; i < m_actionGroup.size(); ++i) { | |
890 DomActionGroup* v = m_actionGroup[i]; | |
891 QDomNode child = v->write(doc, QLatin1String("actiongroup")); | |
892 e.appendChild(child); | |
893 } | |
894 for (int i = 0; i < m_property.size(); ++i) { | |
895 DomProperty* v = m_property[i]; | |
896 QDomNode child = v->write(doc, QLatin1String("property")); | |
897 e.appendChild(child); | |
898 } | |
899 for (int i = 0; i < m_attribute.size(); ++i) { | |
900 DomProperty* v = m_attribute[i]; | |
901 QDomNode child = v->write(doc, QLatin1String("attribute")); | |
902 e.appendChild(child); | |
903 } | |
904 if (!m_text.isEmpty()) | |
905 e.appendChild(doc.createTextNode(m_text)); | |
906 | |
907 return e; | |
908 } | |
909 | |
910 void DomActionGroup::setElementAction(const QList<DomAction*>& a) | |
911 { | |
912 m_action = a; | |
913 } | |
914 | |
915 void DomActionGroup::setElementActionGroup(const QList<DomActionGroup*>& a) | |
916 { | |
917 m_actionGroup = a; | |
918 } | |
919 | |
920 void DomActionGroup::setElementProperty(const QList<DomProperty*>& a) | |
921 { | |
922 m_property = a; | |
923 } | |
924 | |
925 void DomActionGroup::setElementAttribute(const QList<DomProperty*>& a) | |
926 { | |
927 m_attribute = a; | |
928 } | |
929 | |
930 void DomAction::clear(bool clear_all) | |
931 { | |
932 for (int i = 0; i < m_property.size(); ++i) | |
933 delete m_property[i]; | |
934 m_property.clear(); | |
935 for (int i = 0; i < m_attribute.size(); ++i) | |
936 delete m_attribute[i]; | |
937 m_attribute.clear(); | |
938 | |
939 if (clear_all) { | |
940 m_text = QString(); | |
941 m_has_attr_name = false; | |
942 m_has_attr_menu = false; | |
943 } | |
944 | |
945 } | |
946 | |
947 DomAction::DomAction() | |
948 { | |
949 m_has_attr_name = false; | |
950 m_has_attr_menu = false; | |
951 } | |
952 | |
953 DomAction::~DomAction() | |
954 { | |
955 for (int i = 0; i < m_property.size(); ++i) | |
956 delete m_property[i]; | |
957 m_property.clear(); | |
958 for (int i = 0; i < m_attribute.size(); ++i) | |
959 delete m_attribute[i]; | |
960 m_attribute.clear(); | |
961 } | |
962 | |
963 void DomAction::read(const QDomElement &node) | |
964 { | |
965 if (node.hasAttribute(QLatin1String("name"))) | |
966 setAttributeName(node.attribute(QLatin1String("name"))); | |
967 if (node.hasAttribute(QLatin1String("menu"))) | |
968 setAttributeMenu(node.attribute(QLatin1String("menu"))); | |
969 | |
970 for (QDomNode n = node.firstChild(); !n.isNull(); n = n.nextSibling()) { | |
971 if (!n.isElement()) | |
972 continue; | |
973 QDomElement e = n.toElement(); | |
974 QString tag = e.tagName().toLower(); | |
975 if (tag == QLatin1String("property")) { | |
976 DomProperty *v = new DomProperty(); | |
977 v->read(e); | |
978 m_property.append(v); | |
979 continue; | |
980 } | |
981 if (tag == QLatin1String("attribute")) { | |
982 DomProperty *v = new DomProperty(); | |
983 v->read(e); | |
984 m_attribute.append(v); | |
985 continue; | |
986 } | |
987 } | |
988 | |
989 m_text.clear(); | |
990 for (QDomNode child = node.firstChild(); !child.isNull(); child = child.nextSibling()) { | |
991 if (child.isText()) | |
992 m_text.append(child.nodeValue()); | |
993 } | |
994 } | |
995 | |
996 QDomElement DomAction::write(QDomDocument &doc, const QString &tagName) const | |
997 { | |
998 QDomElement e = doc.createElement(tagName.isEmpty() ? QString::fromUtf8("action") : tagName.toLower()); | |
999 | |
1000 QDomElement child; | |
1001 | |
1002 if (hasAttributeName()) | |
1003 e.setAttribute(QLatin1String("name"), attributeName()); | |
1004 | |
1005 if (hasAttributeMenu()) | |
1006 e.setAttribute(QLatin1String("menu"), attributeMenu()); | |
1007 | |
1008 for (int i = 0; i < m_property.size(); ++i) { | |
1009 DomProperty* v = m_property[i]; | |
1010 QDomNode child = v->write(doc, QLatin1String("property")); | |
1011 e.appendChild(child); | |
1012 } | |
1013 for (int i = 0; i < m_attribute.size(); ++i) { | |
1014 DomProperty* v = m_attribute[i]; | |
1015 QDomNode child = v->write(doc, QLatin1String("attribute")); | |
1016 e.appendChild(child); | |
1017 } | |
1018 if (!m_text.isEmpty()) | |
1019 e.appendChild(doc.createTextNode(m_text)); | |
1020 | |
1021 return e; | |
1022 } | |
1023 | |
1024 void DomAction::setElementProperty(const QList<DomProperty*>& a) | |
1025 { | |
1026 m_property = a; | |
1027 } | |
1028 | |
1029 void DomAction::setElementAttribute(const QList<DomProperty*>& a) | |
1030 { | |
1031 m_attribute = a; | |
1032 } | |
1033 | |
1034 void DomActionRef::clear(bool clear_all) | |
1035 { | |
1036 | |
1037 if (clear_all) { | |
1038 m_text = QString(); | |
1039 m_has_attr_name = false; | |
1040 } | |
1041 | |
1042 } | |
1043 | |
1044 DomActionRef::DomActionRef() | |
1045 { | |
1046 m_has_attr_name = false; | |
1047 } | |
1048 | |
1049 DomActionRef::~DomActionRef() | |
1050 { | |
1051 } | |
1052 | |
1053 void DomActionRef::read(const QDomElement &node) | |
1054 { | |
1055 if (node.hasAttribute(QLatin1String("name"))) | |
1056 setAttributeName(node.attribute(QLatin1String("name"))); | |
1057 | |
1058 for (QDomNode n = node.firstChild(); !n.isNull(); n = n.nextSibling()) { | |
1059 if (!n.isElement()) | |
1060 continue; | |
1061 QDomElement e = n.toElement(); | |
1062 QString tag = e.tagName().toLower(); | |
1063 } | |
1064 | |
1065 m_text.clear(); | |
1066 for (QDomNode child = node.firstChild(); !child.isNull(); child = child.nextSibling()) { | |
1067 if (child.isText()) | |
1068 m_text.append(child.nodeValue()); | |
1069 } | |
1070 } | |
1071 | |
1072 QDomElement DomActionRef::write(QDomDocument &doc, const QString &tagName) const | |
1073 { | |
1074 QDomElement e = doc.createElement(tagName.isEmpty() ? QString::fromUtf8("actionref") : tagName.toLower()); | |
1075 | |
1076 QDomElement child; | |
1077 | |
1078 if (hasAttributeName()) | |
1079 e.setAttribute(QLatin1String("name"), attributeName()); | |
1080 | |
1081 if (!m_text.isEmpty()) | |
1082 e.appendChild(doc.createTextNode(m_text)); | |
1083 | |
1084 return e; | |
1085 } | |
1086 | |
1087 void DomImages::clear(bool clear_all) | |
1088 { | |
1089 for (int i = 0; i < m_image.size(); ++i) | |
1090 delete m_image[i]; | |
1091 m_image.clear(); | |
1092 | |
1093 if (clear_all) { | |
1094 m_text = QString(); | |
1095 } | |
1096 | |
1097 } | |
1098 | |
1099 DomImages::DomImages() | |
1100 { | |
1101 } | |
1102 | |
1103 DomImages::~DomImages() | |
1104 { | |
1105 for (int i = 0; i < m_image.size(); ++i) | |
1106 delete m_image[i]; | |
1107 m_image.clear(); | |
1108 } | |
1109 | |
1110 void DomImages::read(const QDomElement &node) | |
1111 { | |
1112 | |
1113 for (QDomNode n = node.firstChild(); !n.isNull(); n = n.nextSibling()) { | |
1114 if (!n.isElement()) | |
1115 continue; | |
1116 QDomElement e = n.toElement(); | |
1117 QString tag = e.tagName().toLower(); | |
1118 if (tag == QLatin1String("image")) { | |
1119 DomImage *v = new DomImage(); | |
1120 v->read(e); | |
1121 m_image.append(v); | |
1122 continue; | |
1123 } | |
1124 } | |
1125 | |
1126 m_text.clear(); | |
1127 for (QDomNode child = node.firstChild(); !child.isNull(); child = child.nextSibling()) { | |
1128 if (child.isText()) | |
1129 m_text.append(child.nodeValue()); | |
1130 } | |
1131 } | |
1132 | |
1133 QDomElement DomImages::write(QDomDocument &doc, const QString &tagName) const | |
1134 { | |
1135 QDomElement e = doc.createElement(tagName.isEmpty() ? QString::fromUtf8("images") : tagName.toLower()); | |
1136 | |
1137 QDomElement child; | |
1138 | |
1139 for (int i = 0; i < m_image.size(); ++i) { | |
1140 DomImage* v = m_image[i]; | |
1141 QDomNode child = v->write(doc, QLatin1String("image")); | |
1142 e.appendChild(child); | |
1143 } | |
1144 if (!m_text.isEmpty()) | |
1145 e.appendChild(doc.createTextNode(m_text)); | |
1146 | |
1147 return e; | |
1148 } | |
1149 | |
1150 void DomImages::setElementImage(const QList<DomImage*>& a) | |
1151 { | |
1152 m_image = a; | |
1153 } | |
1154 | |
1155 void DomImage::clear(bool clear_all) | |
1156 { | |
1157 delete m_data; | |
1158 | |
1159 if (clear_all) { | |
1160 m_text = QString(); | |
1161 m_has_attr_name = false; | |
1162 } | |
1163 | |
1164 m_children = 0; | |
1165 m_data = 0; | |
1166 } | |
1167 | |
1168 DomImage::DomImage() | |
1169 { | |
1170 m_children = 0; | |
1171 m_has_attr_name = false; | |
1172 m_data = 0; | |
1173 } | |
1174 | |
1175 DomImage::~DomImage() | |
1176 { | |
1177 delete m_data; | |
1178 } | |
1179 | |
1180 void DomImage::read(const QDomElement &node) | |
1181 { | |
1182 if (node.hasAttribute(QLatin1String("name"))) | |
1183 setAttributeName(node.attribute(QLatin1String("name"))); | |
1184 | |
1185 for (QDomNode n = node.firstChild(); !n.isNull(); n = n.nextSibling()) { | |
1186 if (!n.isElement()) | |
1187 continue; | |
1188 QDomElement e = n.toElement(); | |
1189 QString tag = e.tagName().toLower(); | |
1190 if (tag == QLatin1String("data")) { | |
1191 DomImageData *v = new DomImageData(); | |
1192 v->read(e); | |
1193 setElementData(v); | |
1194 continue; | |
1195 } | |
1196 } | |
1197 | |
1198 m_text.clear(); | |
1199 for (QDomNode child = node.firstChild(); !child.isNull(); child = child.nextSibling()) { | |
1200 if (child.isText()) | |
1201 m_text.append(child.nodeValue()); | |
1202 } | |
1203 } | |
1204 | |
1205 QDomElement DomImage::write(QDomDocument &doc, const QString &tagName) const | |
1206 { | |
1207 QDomElement e = doc.createElement(tagName.isEmpty() ? QString::fromUtf8("image") : tagName.toLower()); | |
1208 | |
1209 QDomElement child; | |
1210 | |
1211 if (hasAttributeName()) | |
1212 e.setAttribute(QLatin1String("name"), attributeName()); | |
1213 | |
1214 if (m_children & Data) { | |
1215 e.appendChild(m_data->write(doc, QLatin1String("data"))); | |
1216 } | |
1217 | |
1218 if (!m_text.isEmpty()) | |
1219 e.appendChild(doc.createTextNode(m_text)); | |
1220 | |
1221 return e; | |
1222 } | |
1223 | |
1224 void DomImage::setElementData(DomImageData* a) | |
1225 { | |
1226 delete m_data; | |
1227 m_children |= Data; | |
1228 m_data = a; | |
1229 } | |
1230 | |
1231 void DomImage::clearElementData() | |
1232 { | |
1233 delete m_data; | |
1234 m_data = 0; | |
1235 m_children &= ~Data; | |
1236 } | |
1237 | |
1238 void DomImageData::clear(bool clear_all) | |
1239 { | |
1240 | |
1241 if (clear_all) { | |
1242 m_text = QString(); | |
1243 m_has_attr_format = false; | |
1244 m_has_attr_length = false; | |
1245 m_attr_length = 0; | |
1246 } | |
1247 | |
1248 } | |
1249 | |
1250 DomImageData::DomImageData() | |
1251 { | |
1252 m_has_attr_format = false; | |
1253 m_has_attr_length = false; | |
1254 m_attr_length = 0; | |
1255 } | |
1256 | |
1257 DomImageData::~DomImageData() | |
1258 { | |
1259 } | |
1260 | |
1261 void DomImageData::read(const QDomElement &node) | |
1262 { | |
1263 if (node.hasAttribute(QLatin1String("format"))) | |
1264 setAttributeFormat(node.attribute(QLatin1String("format"))); | |
1265 if (node.hasAttribute(QLatin1String("length"))) | |
1266 setAttributeLength(node.attribute(QLatin1String("length")).toInt()); | |
1267 | |
1268 for (QDomNode n = node.firstChild(); !n.isNull(); n = n.nextSibling()) { | |
1269 if (!n.isElement()) | |
1270 continue; | |
1271 QDomElement e = n.toElement(); | |
1272 QString tag = e.tagName().toLower(); | |
1273 } | |
1274 | |
1275 m_text.clear(); | |
1276 for (QDomNode child = node.firstChild(); !child.isNull(); child = child.nextSibling()) { | |
1277 if (child.isText()) | |
1278 m_text.append(child.nodeValue()); | |
1279 } | |
1280 } | |
1281 | |
1282 QDomElement DomImageData::write(QDomDocument &doc, const QString &tagName) const | |
1283 { | |
1284 QDomElement e = doc.createElement(tagName.isEmpty() ? QString::fromUtf8("imagedata") : tagName.toLower()); | |
1285 | |
1286 QDomElement child; | |
1287 | |
1288 if (hasAttributeFormat()) | |
1289 e.setAttribute(QLatin1String("format"), attributeFormat()); | |
1290 | |
1291 if (hasAttributeLength()) | |
1292 e.setAttribute(QLatin1String("length"), attributeLength()); | |
1293 | |
1294 if (!m_text.isEmpty()) | |
1295 e.appendChild(doc.createTextNode(m_text)); | |
1296 | |
1297 return e; | |
1298 } | |
1299 | |
1300 void DomCustomWidgets::clear(bool clear_all) | |
1301 { | |
1302 for (int i = 0; i < m_customWidget.size(); ++i) | |
1303 delete m_customWidget[i]; | |
1304 m_customWidget.clear(); | |
1305 | |
1306 if (clear_all) { | |
1307 m_text = QString(); | |
1308 } | |
1309 | |
1310 } | |
1311 | |
1312 DomCustomWidgets::DomCustomWidgets() | |
1313 { | |
1314 } | |
1315 | |
1316 DomCustomWidgets::~DomCustomWidgets() | |
1317 { | |
1318 for (int i = 0; i < m_customWidget.size(); ++i) | |
1319 delete m_customWidget[i]; | |
1320 m_customWidget.clear(); | |
1321 } | |
1322 | |
1323 void DomCustomWidgets::read(const QDomElement &node) | |
1324 { | |
1325 | |
1326 for (QDomNode n = node.firstChild(); !n.isNull(); n = n.nextSibling()) { | |
1327 if (!n.isElement()) | |
1328 continue; | |
1329 QDomElement e = n.toElement(); | |
1330 QString tag = e.tagName().toLower(); | |
1331 if (tag == QLatin1String("customwidget")) { | |
1332 DomCustomWidget *v = new DomCustomWidget(); | |
1333 v->read(e); | |
1334 m_customWidget.append(v); | |
1335 continue; | |
1336 } | |
1337 } | |
1338 | |
1339 m_text.clear(); | |
1340 for (QDomNode child = node.firstChild(); !child.isNull(); child = child.nextSibling()) { | |
1341 if (child.isText()) | |
1342 m_text.append(child.nodeValue()); | |
1343 } | |
1344 } | |
1345 | |
1346 QDomElement DomCustomWidgets::write(QDomDocument &doc, const QString &tagName) const | |
1347 { | |
1348 QDomElement e = doc.createElement(tagName.isEmpty() ? QString::fromUtf8("customwidgets") : tagName.toLower()); | |
1349 | |
1350 QDomElement child; | |
1351 | |
1352 for (int i = 0; i < m_customWidget.size(); ++i) { | |
1353 DomCustomWidget* v = m_customWidget[i]; | |
1354 QDomNode child = v->write(doc, QLatin1String("customwidget")); | |
1355 e.appendChild(child); | |
1356 } | |
1357 if (!m_text.isEmpty()) | |
1358 e.appendChild(doc.createTextNode(m_text)); | |
1359 | |
1360 return e; | |
1361 } | |
1362 | |
1363 void DomCustomWidgets::setElementCustomWidget(const QList<DomCustomWidget*>& a) | |
1364 { | |
1365 m_customWidget = a; | |
1366 } | |
1367 | |
1368 void DomHeader::clear(bool clear_all) | |
1369 { | |
1370 | |
1371 if (clear_all) { | |
1372 m_text = QString(); | |
1373 m_has_attr_location = false; | |
1374 } | |
1375 | |
1376 } | |
1377 | |
1378 DomHeader::DomHeader() | |
1379 { | |
1380 m_has_attr_location = false; | |
1381 } | |
1382 | |
1383 DomHeader::~DomHeader() | |
1384 { | |
1385 } | |
1386 | |
1387 void DomHeader::read(const QDomElement &node) | |
1388 { | |
1389 if (node.hasAttribute(QLatin1String("location"))) | |
1390 setAttributeLocation(node.attribute(QLatin1String("location"))); | |
1391 | |
1392 m_text.clear(); | |
1393 for (QDomNode child = node.firstChild(); !child.isNull(); child = child.nextSibling()) { | |
1394 if (child.isText()) | |
1395 m_text.append(child.nodeValue()); | |
1396 } | |
1397 } | |
1398 | |
1399 QDomElement DomHeader::write(QDomDocument &doc, const QString &tagName) const | |
1400 { | |
1401 QDomElement e = doc.createElement(tagName.isEmpty() ? QString::fromUtf8("header") : tagName.toLower()); | |
1402 | |
1403 QDomElement child; | |
1404 | |
1405 if (hasAttributeLocation()) | |
1406 e.setAttribute(QLatin1String("location"), attributeLocation()); | |
1407 | |
1408 if (!m_text.isEmpty()) | |
1409 e.appendChild(doc.createTextNode(m_text)); | |
1410 | |
1411 return e; | |
1412 } | |
1413 | |
1414 void DomCustomWidget::clear(bool clear_all) | |
1415 { | |
1416 delete m_header; | |
1417 delete m_sizeHint; | |
1418 delete m_sizePolicy; | |
1419 delete m_script; | |
1420 delete m_properties; | |
1421 delete m_slots; | |
1422 | |
1423 if (clear_all) { | |
1424 m_text = QString(); | |
1425 } | |
1426 | |
1427 m_children = 0; | |
1428 m_header = 0; | |
1429 m_sizeHint = 0; | |
1430 m_container = 0; | |
1431 m_sizePolicy = 0; | |
1432 m_script = 0; | |
1433 m_properties = 0; | |
1434 m_slots = 0; | |
1435 } | |
1436 | |
1437 DomCustomWidget::DomCustomWidget() | |
1438 { | |
1439 m_children = 0; | |
1440 m_header = 0; | |
1441 m_sizeHint = 0; | |
1442 m_container = 0; | |
1443 m_sizePolicy = 0; | |
1444 m_script = 0; | |
1445 m_properties = 0; | |
1446 m_slots = 0; | |
1447 } | |
1448 | |
1449 DomCustomWidget::~DomCustomWidget() | |
1450 { | |
1451 delete m_header; | |
1452 delete m_sizeHint; | |
1453 delete m_sizePolicy; | |
1454 delete m_script; | |
1455 delete m_properties; | |
1456 delete m_slots; | |
1457 } | |
1458 | |
1459 void DomCustomWidget::read(const QDomElement &node) | |
1460 { | |
1461 | |
1462 for (QDomNode n = node.firstChild(); !n.isNull(); n = n.nextSibling()) { | |
1463 if (!n.isElement()) | |
1464 continue; | |
1465 QDomElement e = n.toElement(); | |
1466 QString tag = e.tagName().toLower(); | |
1467 if (tag == QLatin1String("class")) { | |
1468 setElementClass(e.text()); | |
1469 continue; | |
1470 } | |
1471 if (tag == QLatin1String("extends")) { | |
1472 setElementExtends(e.text()); | |
1473 continue; | |
1474 } | |
1475 if (tag == QLatin1String("header")) { | |
1476 DomHeader *v = new DomHeader(); | |
1477 v->read(e); | |
1478 setElementHeader(v); | |
1479 continue; | |
1480 } | |
1481 if (tag == QLatin1String("sizehint")) { | |
1482 DomSize *v = new DomSize(); | |
1483 v->read(e); | |
1484 setElementSizeHint(v); | |
1485 continue; | |
1486 } | |
1487 if (tag == QLatin1String("addpagemethod")) { | |
1488 setElementAddPageMethod(e.text()); | |
1489 continue; | |
1490 } | |
1491 if (tag == QLatin1String("container")) { | |
1492 setElementContainer(e.text().toInt()); | |
1493 continue; | |
1494 } | |
1495 if (tag == QLatin1String("sizepolicy")) { | |
1496 DomSizePolicyData *v = new DomSizePolicyData(); | |
1497 v->read(e); | |
1498 setElementSizePolicy(v); | |
1499 continue; | |
1500 } | |
1501 if (tag == QLatin1String("pixmap")) { | |
1502 setElementPixmap(e.text()); | |
1503 continue; | |
1504 } | |
1505 if (tag == QLatin1String("script")) { | |
1506 DomScript *v = new DomScript(); | |
1507 v->read(e); | |
1508 setElementScript(v); | |
1509 continue; | |
1510 } | |
1511 if (tag == QLatin1String("properties")) { | |
1512 DomProperties *v = new DomProperties(); | |
1513 v->read(e); | |
1514 setElementProperties(v); | |
1515 continue; | |
1516 } | |
1517 if (tag == QLatin1String("slots")) { | |
1518 DomSlots *v = new DomSlots(); | |
1519 v->read(e); | |
1520 setElementSlots(v); | |
1521 continue; | |
1522 } | |
1523 } | |
1524 | |
1525 m_text.clear(); | |
1526 for (QDomNode child = node.firstChild(); !child.isNull(); child = child.nextSibling()) { | |
1527 if (child.isText()) | |
1528 m_text.append(child.nodeValue()); | |
1529 } | |
1530 } | |
1531 | |
1532 QDomElement DomCustomWidget::write(QDomDocument &doc, const QString &tagName) const | |
1533 { | |
1534 QDomElement e = doc.createElement(tagName.isEmpty() ? QString::fromUtf8("customwidget") : tagName.toLower()); | |
1535 | |
1536 QDomElement child; | |
1537 | |
1538 if (m_children & Class) { | |
1539 child = doc.createElement(QLatin1String("class")); | |
1540 child.appendChild(doc.createTextNode(m_class)); | |
1541 e.appendChild(child); | |
1542 } | |
1543 | |
1544 if (m_children & Extends) { | |
1545 child = doc.createElement(QLatin1String("extends")); | |
1546 child.appendChild(doc.createTextNode(m_extends)); | |
1547 e.appendChild(child); | |
1548 } | |
1549 | |
1550 if (m_children & Header) { | |
1551 e.appendChild(m_header->write(doc, QLatin1String("header"))); | |
1552 } | |
1553 | |
1554 if (m_children & SizeHint) { | |
1555 e.appendChild(m_sizeHint->write(doc, QLatin1String("sizehint"))); | |
1556 } | |
1557 | |
1558 if (m_children & AddPageMethod) { | |
1559 child = doc.createElement(QLatin1String("addpagemethod")); | |
1560 child.appendChild(doc.createTextNode(m_addPageMethod)); | |
1561 e.appendChild(child); | |
1562 } | |
1563 | |
1564 if (m_children & Container) { | |
1565 child = doc.createElement(QLatin1String("container")); | |
1566 child.appendChild(doc.createTextNode(QString::number(m_container))); | |
1567 e.appendChild(child); | |
1568 } | |
1569 | |
1570 if (m_children & SizePolicy) { | |
1571 e.appendChild(m_sizePolicy->write(doc, QLatin1String("sizepolicy"))); | |
1572 } | |
1573 | |
1574 if (m_children & Pixmap) { | |
1575 child = doc.createElement(QLatin1String("pixmap")); | |
1576 child.appendChild(doc.createTextNode(m_pixmap)); | |
1577 e.appendChild(child); | |
1578 } | |
1579 | |
1580 if (m_children & Script) { | |
1581 e.appendChild(m_script->write(doc, QLatin1String("script"))); | |
1582 } | |
1583 | |
1584 if (m_children & Properties) { | |
1585 e.appendChild(m_properties->write(doc, QLatin1String("properties"))); | |
1586 } | |
1587 | |
1588 if (m_children & Slots) { | |
1589 e.appendChild(m_slots->write(doc, QLatin1String("slots"))); | |
1590 } | |
1591 | |
1592 if (!m_text.isEmpty()) | |
1593 e.appendChild(doc.createTextNode(m_text)); | |
1594 | |
1595 return e; | |
1596 } | |
1597 | |
1598 void DomCustomWidget::setElementClass(const QString& a) | |
1599 { | |
1600 m_children |= Class; | |
1601 m_class = a; | |
1602 } | |
1603 | |
1604 void DomCustomWidget::setElementExtends(const QString& a) | |
1605 { | |
1606 m_children |= Extends; | |
1607 m_extends = a; | |
1608 } | |
1609 | |
1610 void DomCustomWidget::setElementHeader(DomHeader* a) | |
1611 { | |
1612 delete m_header; | |
1613 m_children |= Header; | |
1614 m_header = a; | |
1615 } | |
1616 | |
1617 void DomCustomWidget::setElementSizeHint(DomSize* a) | |
1618 { | |
1619 delete m_sizeHint; | |
1620 m_children |= SizeHint; | |
1621 m_sizeHint = a; | |
1622 } | |
1623 | |
1624 void DomCustomWidget::setElementAddPageMethod(const QString& a) | |
1625 { | |
1626 m_children |= AddPageMethod; | |
1627 m_addPageMethod = a; | |
1628 } | |
1629 | |
1630 void DomCustomWidget::setElementContainer(int a) | |
1631 { | |
1632 m_children |= Container; | |
1633 m_container = a; | |
1634 } | |
1635 | |
1636 void DomCustomWidget::setElementSizePolicy(DomSizePolicyData* a) | |
1637 { | |
1638 delete m_sizePolicy; | |
1639 m_children |= SizePolicy; | |
1640 m_sizePolicy = a; | |
1641 } | |
1642 | |
1643 void DomCustomWidget::setElementPixmap(const QString& a) | |
1644 { | |
1645 m_children |= Pixmap; | |
1646 m_pixmap = a; | |
1647 } | |
1648 | |
1649 void DomCustomWidget::setElementScript(DomScript* a) | |
1650 { | |
1651 delete m_script; | |
1652 m_children |= Script; | |
1653 m_script = a; | |
1654 } | |
1655 | |
1656 void DomCustomWidget::setElementProperties(DomProperties* a) | |
1657 { | |
1658 delete m_properties; | |
1659 m_children |= Properties; | |
1660 m_properties = a; | |
1661 } | |
1662 | |
1663 void DomCustomWidget::setElementSlots(DomSlots* a) | |
1664 { | |
1665 delete m_slots; | |
1666 m_children |= Slots; | |
1667 m_slots = a; | |
1668 } | |
1669 | |
1670 void DomCustomWidget::clearElementClass() | |
1671 { | |
1672 m_children &= ~Class; | |
1673 } | |
1674 | |
1675 void DomCustomWidget::clearElementExtends() | |
1676 { | |
1677 m_children &= ~Extends; | |
1678 } | |
1679 | |
1680 void DomCustomWidget::clearElementHeader() | |
1681 { | |
1682 delete m_header; | |
1683 m_header = 0; | |
1684 m_children &= ~Header; | |
1685 } | |
1686 | |
1687 void DomCustomWidget::clearElementSizeHint() | |
1688 { | |
1689 delete m_sizeHint; | |
1690 m_sizeHint = 0; | |
1691 m_children &= ~SizeHint; | |
1692 } | |
1693 | |
1694 void DomCustomWidget::clearElementAddPageMethod() | |
1695 { | |
1696 m_children &= ~AddPageMethod; | |
1697 } | |
1698 | |
1699 void DomCustomWidget::clearElementContainer() | |
1700 { | |
1701 m_children &= ~Container; | |
1702 } | |
1703 | |
1704 void DomCustomWidget::clearElementSizePolicy() | |
1705 { | |
1706 delete m_sizePolicy; | |
1707 m_sizePolicy = 0; | |
1708 m_children &= ~SizePolicy; | |
1709 } | |
1710 | |
1711 void DomCustomWidget::clearElementPixmap() | |
1712 { | |
1713 m_children &= ~Pixmap; | |
1714 } | |
1715 | |
1716 void DomCustomWidget::clearElementScript() | |
1717 { | |
1718 delete m_script; | |
1719 m_script = 0; | |
1720 m_children &= ~Script; | |
1721 } | |
1722 | |
1723 void DomCustomWidget::clearElementProperties() | |
1724 { | |
1725 delete m_properties; | |
1726 m_properties = 0; | |
1727 m_children &= ~Properties; | |
1728 } | |
1729 | |
1730 void DomCustomWidget::clearElementSlots() | |
1731 { | |
1732 delete m_slots; | |
1733 m_slots = 0; | |
1734 m_children &= ~Slots; | |
1735 } | |
1736 | |
1737 void DomProperties::clear(bool clear_all) | |
1738 { | |
1739 for (int i = 0; i < m_property.size(); ++i) | |
1740 delete m_property[i]; | |
1741 m_property.clear(); | |
1742 | |
1743 if (clear_all) { | |
1744 m_text = QString(); | |
1745 } | |
1746 | |
1747 } | |
1748 | |
1749 DomProperties::DomProperties() | |
1750 { | |
1751 } | |
1752 | |
1753 DomProperties::~DomProperties() | |
1754 { | |
1755 for (int i = 0; i < m_property.size(); ++i) | |
1756 delete m_property[i]; | |
1757 m_property.clear(); | |
1758 } | |
1759 | |
1760 void DomProperties::read(const QDomElement &node) | |
1761 { | |
1762 | |
1763 for (QDomNode n = node.firstChild(); !n.isNull(); n = n.nextSibling()) { | |
1764 if (!n.isElement()) | |
1765 continue; | |
1766 QDomElement e = n.toElement(); | |
1767 QString tag = e.tagName().toLower(); | |
1768 if (tag == QLatin1String("property")) { | |
1769 DomPropertyData *v = new DomPropertyData(); | |
1770 v->read(e); | |
1771 m_property.append(v); | |
1772 continue; | |
1773 } | |
1774 } | |
1775 | |
1776 m_text.clear(); | |
1777 for (QDomNode child = node.firstChild(); !child.isNull(); child = child.nextSibling()) { | |
1778 if (child.isText()) | |
1779 m_text.append(child.nodeValue()); | |
1780 } | |
1781 } | |
1782 | |
1783 QDomElement DomProperties::write(QDomDocument &doc, const QString &tagName) const | |
1784 { | |
1785 QDomElement e = doc.createElement(tagName.isEmpty() ? QString::fromUtf8("properties") : tagName.toLower()); | |
1786 | |
1787 QDomElement child; | |
1788 | |
1789 for (int i = 0; i < m_property.size(); ++i) { | |
1790 DomPropertyData* v = m_property[i]; | |
1791 QDomNode child = v->write(doc, QLatin1String("property")); | |
1792 e.appendChild(child); | |
1793 } | |
1794 if (!m_text.isEmpty()) | |
1795 e.appendChild(doc.createTextNode(m_text)); | |
1796 | |
1797 return e; | |
1798 } | |
1799 | |
1800 void DomProperties::setElementProperty(const QList<DomPropertyData*>& a) | |
1801 { | |
1802 m_property = a; | |
1803 } | |
1804 | |
1805 void DomPropertyData::clear(bool clear_all) | |
1806 { | |
1807 | |
1808 if (clear_all) { | |
1809 m_text = QString(); | |
1810 m_has_attr_type = false; | |
1811 } | |
1812 | |
1813 } | |
1814 | |
1815 DomPropertyData::DomPropertyData() | |
1816 { | |
1817 m_has_attr_type = false; | |
1818 } | |
1819 | |
1820 DomPropertyData::~DomPropertyData() | |
1821 { | |
1822 } | |
1823 | |
1824 void DomPropertyData::read(const QDomElement &node) | |
1825 { | |
1826 if (node.hasAttribute(QLatin1String("type"))) | |
1827 setAttributeType(node.attribute(QLatin1String("type"))); | |
1828 | |
1829 for (QDomNode n = node.firstChild(); !n.isNull(); n = n.nextSibling()) { | |
1830 if (!n.isElement()) | |
1831 continue; | |
1832 QDomElement e = n.toElement(); | |
1833 QString tag = e.tagName().toLower(); | |
1834 } | |
1835 | |
1836 m_text.clear(); | |
1837 for (QDomNode child = node.firstChild(); !child.isNull(); child = child.nextSibling()) { | |
1838 if (child.isText()) | |
1839 m_text.append(child.nodeValue()); | |
1840 } | |
1841 } | |
1842 | |
1843 QDomElement DomPropertyData::write(QDomDocument &doc, const QString &tagName) const | |
1844 { | |
1845 QDomElement e = doc.createElement(tagName.isEmpty() ? QString::fromUtf8("propertydata") : tagName.toLower()); | |
1846 | |
1847 QDomElement child; | |
1848 | |
1849 if (hasAttributeType()) | |
1850 e.setAttribute(QLatin1String("type"), attributeType()); | |
1851 | |
1852 if (!m_text.isEmpty()) | |
1853 e.appendChild(doc.createTextNode(m_text)); | |
1854 | |
1855 return e; | |
1856 } | |
1857 | |
1858 void DomSizePolicyData::clear(bool clear_all) | |
1859 { | |
1860 | |
1861 if (clear_all) { | |
1862 m_text = QString(); | |
1863 } | |
1864 | |
1865 m_children = 0; | |
1866 m_horData = 0; | |
1867 m_verData = 0; | |
1868 } | |
1869 | |
1870 DomSizePolicyData::DomSizePolicyData() | |
1871 { | |
1872 m_children = 0; | |
1873 m_horData = 0; | |
1874 m_verData = 0; | |
1875 } | |
1876 | |
1877 DomSizePolicyData::~DomSizePolicyData() | |
1878 { | |
1879 } | |
1880 | |
1881 void DomSizePolicyData::read(const QDomElement &node) | |
1882 { | |
1883 | |
1884 for (QDomNode n = node.firstChild(); !n.isNull(); n = n.nextSibling()) { | |
1885 if (!n.isElement()) | |
1886 continue; | |
1887 QDomElement e = n.toElement(); | |
1888 QString tag = e.tagName().toLower(); | |
1889 if (tag == QLatin1String("hordata")) { | |
1890 setElementHorData(e.text().toInt()); | |
1891 continue; | |
1892 } | |
1893 if (tag == QLatin1String("verdata")) { | |
1894 setElementVerData(e.text().toInt()); | |
1895 continue; | |
1896 } | |
1897 } | |
1898 | |
1899 m_text.clear(); | |
1900 for (QDomNode child = node.firstChild(); !child.isNull(); child = child.nextSibling()) { | |
1901 if (child.isText()) | |
1902 m_text.append(child.nodeValue()); | |
1903 } | |
1904 } | |
1905 | |
1906 QDomElement DomSizePolicyData::write(QDomDocument &doc, const QString &tagName) const | |
1907 { | |
1908 QDomElement e = doc.createElement(tagName.isEmpty() ? QString::fromUtf8("sizepolicydata") : tagName.toLower()); | |
1909 | |
1910 QDomElement child; | |
1911 | |
1912 if (m_children & HorData) { | |
1913 child = doc.createElement(QLatin1String("hordata")); | |
1914 child.appendChild(doc.createTextNode(QString::number(m_horData))); | |
1915 e.appendChild(child); | |
1916 } | |
1917 | |
1918 if (m_children & VerData) { | |
1919 child = doc.createElement(QLatin1String("verdata")); | |
1920 child.appendChild(doc.createTextNode(QString::number(m_verData))); | |
1921 e.appendChild(child); | |
1922 } | |
1923 | |
1924 if (!m_text.isEmpty()) | |
1925 e.appendChild(doc.createTextNode(m_text)); | |
1926 | |
1927 return e; | |
1928 } | |
1929 | |
1930 void DomSizePolicyData::setElementHorData(int a) | |
1931 { | |
1932 m_children |= HorData; | |
1933 m_horData = a; | |
1934 } | |
1935 | |
1936 void DomSizePolicyData::setElementVerData(int a) | |
1937 { | |
1938 m_children |= VerData; | |
1939 m_verData = a; | |
1940 } | |
1941 | |
1942 void DomSizePolicyData::clearElementHorData() | |
1943 { | |
1944 m_children &= ~HorData; | |
1945 } | |
1946 | |
1947 void DomSizePolicyData::clearElementVerData() | |
1948 { | |
1949 m_children &= ~VerData; | |
1950 } | |
1951 | |
1952 void DomLayoutDefault::clear(bool clear_all) | |
1953 { | |
1954 | |
1955 if (clear_all) { | |
1956 m_text = QString(); | |
1957 m_has_attr_spacing = false; | |
1958 m_attr_spacing = 0; | |
1959 m_has_attr_margin = false; | |
1960 m_attr_margin = 0; | |
1961 } | |
1962 | |
1963 } | |
1964 | |
1965 DomLayoutDefault::DomLayoutDefault() | |
1966 { | |
1967 m_has_attr_spacing = false; | |
1968 m_attr_spacing = 0; | |
1969 m_has_attr_margin = false; | |
1970 m_attr_margin = 0; | |
1971 } | |
1972 | |
1973 DomLayoutDefault::~DomLayoutDefault() | |
1974 { | |
1975 } | |
1976 | |
1977 void DomLayoutDefault::read(const QDomElement &node) | |
1978 { | |
1979 if (node.hasAttribute(QLatin1String("spacing"))) | |
1980 setAttributeSpacing(node.attribute(QLatin1String("spacing")).toInt()); | |
1981 if (node.hasAttribute(QLatin1String("margin"))) | |
1982 setAttributeMargin(node.attribute(QLatin1String("margin")).toInt()); | |
1983 | |
1984 for (QDomNode n = node.firstChild(); !n.isNull(); n = n.nextSibling()) { | |
1985 if (!n.isElement()) | |
1986 continue; | |
1987 QDomElement e = n.toElement(); | |
1988 QString tag = e.tagName().toLower(); | |
1989 } | |
1990 | |
1991 m_text.clear(); | |
1992 for (QDomNode child = node.firstChild(); !child.isNull(); child = child.nextSibling()) { | |
1993 if (child.isText()) | |
1994 m_text.append(child.nodeValue()); | |
1995 } | |
1996 } | |
1997 | |
1998 QDomElement DomLayoutDefault::write(QDomDocument &doc, const QString &tagName) const | |
1999 { | |
2000 QDomElement e = doc.createElement(tagName.isEmpty() ? QString::fromUtf8("layoutdefault") : tagName.toLower()); | |
2001 | |
2002 QDomElement child; | |
2003 | |
2004 if (hasAttributeSpacing()) | |
2005 e.setAttribute(QLatin1String("spacing"), attributeSpacing()); | |
2006 | |
2007 if (hasAttributeMargin()) | |
2008 e.setAttribute(QLatin1String("margin"), attributeMargin()); | |
2009 | |
2010 if (!m_text.isEmpty()) | |
2011 e.appendChild(doc.createTextNode(m_text)); | |
2012 | |
2013 return e; | |
2014 } | |
2015 | |
2016 void DomLayoutFunction::clear(bool clear_all) | |
2017 { | |
2018 | |
2019 if (clear_all) { | |
2020 m_text = QString(); | |
2021 m_has_attr_spacing = false; | |
2022 m_has_attr_margin = false; | |
2023 } | |
2024 | |
2025 } | |
2026 | |
2027 DomLayoutFunction::DomLayoutFunction() | |
2028 { | |
2029 m_has_attr_spacing = false; | |
2030 m_has_attr_margin = false; | |
2031 } | |
2032 | |
2033 DomLayoutFunction::~DomLayoutFunction() | |
2034 { | |
2035 } | |
2036 | |
2037 void DomLayoutFunction::read(const QDomElement &node) | |
2038 { | |
2039 if (node.hasAttribute(QLatin1String("spacing"))) | |
2040 setAttributeSpacing(node.attribute(QLatin1String("spacing"))); | |
2041 if (node.hasAttribute(QLatin1String("margin"))) | |
2042 setAttributeMargin(node.attribute(QLatin1String("margin"))); | |
2043 | |
2044 for (QDomNode n = node.firstChild(); !n.isNull(); n = n.nextSibling()) { | |
2045 if (!n.isElement()) | |
2046 continue; | |
2047 QDomElement e = n.toElement(); | |
2048 QString tag = e.tagName().toLower(); | |
2049 } | |
2050 | |
2051 m_text.clear(); | |
2052 for (QDomNode child = node.firstChild(); !child.isNull(); child = child.nextSibling()) { | |
2053 if (child.isText()) | |
2054 m_text.append(child.nodeValue()); | |
2055 } | |
2056 } | |
2057 | |
2058 QDomElement DomLayoutFunction::write(QDomDocument &doc, const QString &tagName) const | |
2059 { | |
2060 QDomElement e = doc.createElement(tagName.isEmpty() ? QString::fromUtf8("layoutfunction") : tagName.toLower()); | |
2061 | |
2062 QDomElement child; | |
2063 | |
2064 if (hasAttributeSpacing()) | |
2065 e.setAttribute(QLatin1String("spacing"), attributeSpacing()); | |
2066 | |
2067 if (hasAttributeMargin()) | |
2068 e.setAttribute(QLatin1String("margin"), attributeMargin()); | |
2069 | |
2070 if (!m_text.isEmpty()) | |
2071 e.appendChild(doc.createTextNode(m_text)); | |
2072 | |
2073 return e; | |
2074 } | |
2075 | |
2076 void DomTabStops::clear(bool clear_all) | |
2077 { | |
2078 m_tabStop.clear(); | |
2079 | |
2080 if (clear_all) { | |
2081 m_text = QString(); | |
2082 } | |
2083 | |
2084 } | |
2085 | |
2086 DomTabStops::DomTabStops() | |
2087 { | |
2088 } | |
2089 | |
2090 DomTabStops::~DomTabStops() | |
2091 { | |
2092 m_tabStop.clear(); | |
2093 } | |
2094 | |
2095 void DomTabStops::read(const QDomElement &node) | |
2096 { | |
2097 | |
2098 for (QDomNode n = node.firstChild(); !n.isNull(); n = n.nextSibling()) { | |
2099 if (!n.isElement()) | |
2100 continue; | |
2101 QDomElement e = n.toElement(); | |
2102 QString tag = e.tagName().toLower(); | |
2103 if (tag == QLatin1String("tabstop")) { | |
2104 m_tabStop.append(e.text()); | |
2105 continue; | |
2106 } | |
2107 } | |
2108 | |
2109 m_text.clear(); | |
2110 for (QDomNode child = node.firstChild(); !child.isNull(); child = child.nextSibling()) { | |
2111 if (child.isText()) | |
2112 m_text.append(child.nodeValue()); | |
2113 } | |
2114 } | |
2115 | |
2116 QDomElement DomTabStops::write(QDomDocument &doc, const QString &tagName) const | |
2117 { | |
2118 QDomElement e = doc.createElement(tagName.isEmpty() ? QString::fromUtf8("tabstops") : tagName.toLower()); | |
2119 | |
2120 QDomElement child; | |
2121 | |
2122 for (int i = 0; i < m_tabStop.size(); ++i) { | |
2123 QString v = m_tabStop[i]; | |
2124 QDomNode child = doc.createElement(QLatin1String("tabstop")); | |
2125 child.appendChild(doc.createTextNode(v)); | |
2126 e.appendChild(child); | |
2127 } | |
2128 if (!m_text.isEmpty()) | |
2129 e.appendChild(doc.createTextNode(m_text)); | |
2130 | |
2131 return e; | |
2132 } | |
2133 | |
2134 void DomTabStops::setElementTabStop(const QStringList& a) | |
2135 { | |
2136 m_tabStop = a; | |
2137 } | |
2138 | |
2139 void DomLayout::clear(bool clear_all) | |
2140 { | |
2141 for (int i = 0; i < m_property.size(); ++i) | |
2142 delete m_property[i]; | |
2143 m_property.clear(); | |
2144 for (int i = 0; i < m_attribute.size(); ++i) | |
2145 delete m_attribute[i]; | |
2146 m_attribute.clear(); | |
2147 for (int i = 0; i < m_item.size(); ++i) | |
2148 delete m_item[i]; | |
2149 m_item.clear(); | |
2150 | |
2151 if (clear_all) { | |
2152 m_text = QString(); | |
2153 m_has_attr_class = false; | |
2154 m_has_attr_name = false; | |
2155 } | |
2156 | |
2157 } | |
2158 | |
2159 DomLayout::DomLayout() | |
2160 { | |
2161 m_has_attr_class = false; | |
2162 m_has_attr_name = false; | |
2163 } | |
2164 | |
2165 DomLayout::~DomLayout() | |
2166 { | |
2167 for (int i = 0; i < m_property.size(); ++i) | |
2168 delete m_property[i]; | |
2169 m_property.clear(); | |
2170 for (int i = 0; i < m_attribute.size(); ++i) | |
2171 delete m_attribute[i]; | |
2172 m_attribute.clear(); | |
2173 for (int i = 0; i < m_item.size(); ++i) | |
2174 delete m_item[i]; | |
2175 m_item.clear(); | |
2176 } | |
2177 | |
2178 void DomLayout::read(const QDomElement &node) | |
2179 { | |
2180 if (node.hasAttribute(QLatin1String("class"))) | |
2181 setAttributeClass(node.attribute(QLatin1String("class"))); | |
2182 if (node.hasAttribute(QLatin1String("name"))) | |
2183 setAttributeName(node.attribute(QLatin1String("name"))); | |
2184 | |
2185 for (QDomNode n = node.firstChild(); !n.isNull(); n = n.nextSibling()) { | |
2186 if (!n.isElement()) | |
2187 continue; | |
2188 QDomElement e = n.toElement(); | |
2189 QString tag = e.tagName().toLower(); | |
2190 if (tag == QLatin1String("property")) { | |
2191 DomProperty *v = new DomProperty(); | |
2192 v->read(e); | |
2193 m_property.append(v); | |
2194 continue; | |
2195 } | |
2196 if (tag == QLatin1String("attribute")) { | |
2197 DomProperty *v = new DomProperty(); | |
2198 v->read(e); | |
2199 m_attribute.append(v); | |
2200 continue; | |
2201 } | |
2202 if (tag == QLatin1String("item")) { | |
2203 DomLayoutItem *v = new DomLayoutItem(); | |
2204 v->read(e); | |
2205 m_item.append(v); | |
2206 continue; | |
2207 } | |
2208 } | |
2209 | |
2210 m_text.clear(); | |
2211 for (QDomNode child = node.firstChild(); !child.isNull(); child = child.nextSibling()) { | |
2212 if (child.isText()) | |
2213 m_text.append(child.nodeValue()); | |
2214 } | |
2215 } | |
2216 | |
2217 QDomElement DomLayout::write(QDomDocument &doc, const QString &tagName) const | |
2218 { | |
2219 QDomElement e = doc.createElement(tagName.isEmpty() ? QString::fromUtf8("layout") : tagName.toLower()); | |
2220 | |
2221 QDomElement child; | |
2222 | |
2223 if (hasAttributeClass()) | |
2224 e.setAttribute(QLatin1String("class"), attributeClass()); | |
2225 | |
2226 if (hasAttributeName()) | |
2227 e.setAttribute(QLatin1String("name"), attributeName()); | |
2228 | |
2229 for (int i = 0; i < m_property.size(); ++i) { | |
2230 DomProperty* v = m_property[i]; | |
2231 QDomNode child = v->write(doc, QLatin1String("property")); | |
2232 e.appendChild(child); | |
2233 } | |
2234 for (int i = 0; i < m_attribute.size(); ++i) { | |
2235 DomProperty* v = m_attribute[i]; | |
2236 QDomNode child = v->write(doc, QLatin1String("attribute")); | |
2237 e.appendChild(child); | |
2238 } | |
2239 for (int i = 0; i < m_item.size(); ++i) { | |
2240 DomLayoutItem* v = m_item[i]; | |
2241 QDomNode child = v->write(doc, QLatin1String("item")); | |
2242 e.appendChild(child); | |
2243 } | |
2244 if (!m_text.isEmpty()) | |
2245 e.appendChild(doc.createTextNode(m_text)); | |
2246 | |
2247 return e; | |
2248 } | |
2249 | |
2250 void DomLayout::setElementProperty(const QList<DomProperty*>& a) | |
2251 { | |
2252 m_property = a; | |
2253 } | |
2254 | |
2255 void DomLayout::setElementAttribute(const QList<DomProperty*>& a) | |
2256 { | |
2257 m_attribute = a; | |
2258 } | |
2259 | |
2260 void DomLayout::setElementItem(const QList<DomLayoutItem*>& a) | |
2261 { | |
2262 m_item = a; | |
2263 } | |
2264 | |
2265 void DomLayoutItem::clear(bool clear_all) | |
2266 { | |
2267 delete m_widget; | |
2268 delete m_layout; | |
2269 delete m_spacer; | |
2270 | |
2271 if (clear_all) { | |
2272 m_text = QString(); | |
2273 m_has_attr_row = false; | |
2274 m_attr_row = 0; | |
2275 m_has_attr_column = false; | |
2276 m_attr_column = 0; | |
2277 m_has_attr_rowSpan = false; | |
2278 m_attr_rowSpan = 0; | |
2279 m_has_attr_colSpan = false; | |
2280 m_attr_colSpan = 0; | |
2281 } | |
2282 | |
2283 m_kind = Unknown; | |
2284 | |
2285 m_widget = 0; | |
2286 m_layout = 0; | |
2287 m_spacer = 0; | |
2288 } | |
2289 | |
2290 DomLayoutItem::DomLayoutItem() | |
2291 { | |
2292 m_kind = Unknown; | |
2293 | |
2294 m_has_attr_row = false; | |
2295 m_attr_row = 0; | |
2296 m_has_attr_column = false; | |
2297 m_attr_column = 0; | |
2298 m_has_attr_rowSpan = false; | |
2299 m_attr_rowSpan = 0; | |
2300 m_has_attr_colSpan = false; | |
2301 m_attr_colSpan = 0; | |
2302 m_widget = 0; | |
2303 m_layout = 0; | |
2304 m_spacer = 0; | |
2305 } | |
2306 | |
2307 DomLayoutItem::~DomLayoutItem() | |
2308 { | |
2309 delete m_widget; | |
2310 delete m_layout; | |
2311 delete m_spacer; | |
2312 } | |
2313 | |
2314 void DomLayoutItem::read(const QDomElement &node) | |
2315 { | |
2316 if (node.hasAttribute(QLatin1String("row"))) | |
2317 setAttributeRow(node.attribute(QLatin1String("row")).toInt()); | |
2318 if (node.hasAttribute(QLatin1String("column"))) | |
2319 setAttributeColumn(node.attribute(QLatin1String("column")).toInt()); | |
2320 if (node.hasAttribute(QLatin1String("rowspan"))) | |
2321 setAttributeRowSpan(node.attribute(QLatin1String("rowspan")).toInt()); | |
2322 if (node.hasAttribute(QLatin1String("colspan"))) | |
2323 setAttributeColSpan(node.attribute(QLatin1String("colspan")).toInt()); | |
2324 | |
2325 for (QDomNode n = node.firstChild(); !n.isNull(); n = n.nextSibling()) { | |
2326 if (!n.isElement()) | |
2327 continue; | |
2328 QDomElement e = n.toElement(); | |
2329 QString tag = e.tagName().toLower(); | |
2330 if (tag == QLatin1String("widget")) { | |
2331 DomWidget *v = new DomWidget(); | |
2332 v->read(e); | |
2333 setElementWidget(v); | |
2334 continue; | |
2335 } | |
2336 if (tag == QLatin1String("layout")) { | |
2337 DomLayout *v = new DomLayout(); | |
2338 v->read(e); | |
2339 setElementLayout(v); | |
2340 continue; | |
2341 } | |
2342 if (tag == QLatin1String("spacer")) { | |
2343 DomSpacer *v = new DomSpacer(); | |
2344 v->read(e); | |
2345 setElementSpacer(v); | |
2346 continue; | |
2347 } | |
2348 } | |
2349 | |
2350 m_text.clear(); | |
2351 for (QDomNode child = node.firstChild(); !child.isNull(); child = child.nextSibling()) { | |
2352 if (child.isText()) | |
2353 m_text.append(child.nodeValue()); | |
2354 } | |
2355 } | |
2356 | |
2357 QDomElement DomLayoutItem::write(QDomDocument &doc, const QString &tagName) const | |
2358 { | |
2359 QDomElement e = doc.createElement(tagName.isEmpty() ? QString::fromUtf8("layoutitem") : tagName.toLower()); | |
2360 | |
2361 QDomElement child; | |
2362 | |
2363 if (hasAttributeRow()) | |
2364 e.setAttribute(QLatin1String("row"), attributeRow()); | |
2365 | |
2366 if (hasAttributeColumn()) | |
2367 e.setAttribute(QLatin1String("column"), attributeColumn()); | |
2368 | |
2369 if (hasAttributeRowSpan()) | |
2370 e.setAttribute(QLatin1String("rowspan"), attributeRowSpan()); | |
2371 | |
2372 if (hasAttributeColSpan()) | |
2373 e.setAttribute(QLatin1String("colspan"), attributeColSpan()); | |
2374 | |
2375 switch(kind()) { | |
2376 case Widget: { | |
2377 DomWidget* v = elementWidget(); | |
2378 if (v != 0) { | |
2379 QDomElement child = v->write(doc, QLatin1String("widget")); | |
2380 e.appendChild(child); | |
2381 } | |
2382 break; | |
2383 } | |
2384 case Layout: { | |
2385 DomLayout* v = elementLayout(); | |
2386 if (v != 0) { | |
2387 QDomElement child = v->write(doc, QLatin1String("layout")); | |
2388 e.appendChild(child); | |
2389 } | |
2390 break; | |
2391 } | |
2392 case Spacer: { | |
2393 DomSpacer* v = elementSpacer(); | |
2394 if (v != 0) { | |
2395 QDomElement child = v->write(doc, QLatin1String("spacer")); | |
2396 e.appendChild(child); | |
2397 } | |
2398 break; | |
2399 } | |
2400 default: | |
2401 break; | |
2402 } | |
2403 if (!m_text.isEmpty()) | |
2404 e.appendChild(doc.createTextNode(m_text)); | |
2405 | |
2406 return e; | |
2407 } | |
2408 | |
2409 void DomLayoutItem::setElementWidget(DomWidget* a) | |
2410 { | |
2411 clear(false); | |
2412 m_kind = Widget; | |
2413 m_widget = a; | |
2414 } | |
2415 | |
2416 void DomLayoutItem::setElementLayout(DomLayout* a) | |
2417 { | |
2418 clear(false); | |
2419 m_kind = Layout; | |
2420 m_layout = a; | |
2421 } | |
2422 | |
2423 void DomLayoutItem::setElementSpacer(DomSpacer* a) | |
2424 { | |
2425 clear(false); | |
2426 m_kind = Spacer; | |
2427 m_spacer = a; | |
2428 } | |
2429 | |
2430 void DomRow::clear(bool clear_all) | |
2431 { | |
2432 for (int i = 0; i < m_property.size(); ++i) | |
2433 delete m_property[i]; | |
2434 m_property.clear(); | |
2435 | |
2436 if (clear_all) { | |
2437 m_text = QString(); | |
2438 } | |
2439 | |
2440 } | |
2441 | |
2442 DomRow::DomRow() | |
2443 { | |
2444 } | |
2445 | |
2446 DomRow::~DomRow() | |
2447 { | |
2448 for (int i = 0; i < m_property.size(); ++i) | |
2449 delete m_property[i]; | |
2450 m_property.clear(); | |
2451 } | |
2452 | |
2453 void DomRow::read(const QDomElement &node) | |
2454 { | |
2455 | |
2456 for (QDomNode n = node.firstChild(); !n.isNull(); n = n.nextSibling()) { | |
2457 if (!n.isElement()) | |
2458 continue; | |
2459 QDomElement e = n.toElement(); | |
2460 QString tag = e.tagName().toLower(); | |
2461 if (tag == QLatin1String("property")) { | |
2462 DomProperty *v = new DomProperty(); | |
2463 v->read(e); | |
2464 m_property.append(v); | |
2465 continue; | |
2466 } | |
2467 } | |
2468 | |
2469 m_text.clear(); | |
2470 for (QDomNode child = node.firstChild(); !child.isNull(); child = child.nextSibling()) { | |
2471 if (child.isText()) | |
2472 m_text.append(child.nodeValue()); | |
2473 } | |
2474 } | |
2475 | |
2476 QDomElement DomRow::write(QDomDocument &doc, const QString &tagName) const | |
2477 { | |
2478 QDomElement e = doc.createElement(tagName.isEmpty() ? QString::fromUtf8("row") : tagName.toLower()); | |
2479 | |
2480 QDomElement child; | |
2481 | |
2482 for (int i = 0; i < m_property.size(); ++i) { | |
2483 DomProperty* v = m_property[i]; | |
2484 QDomNode child = v->write(doc, QLatin1String("property")); | |
2485 e.appendChild(child); | |
2486 } | |
2487 if (!m_text.isEmpty()) | |
2488 e.appendChild(doc.createTextNode(m_text)); | |
2489 | |
2490 return e; | |
2491 } | |
2492 | |
2493 void DomRow::setElementProperty(const QList<DomProperty*>& a) | |
2494 { | |
2495 m_property = a; | |
2496 } | |
2497 | |
2498 void DomColumn::clear(bool clear_all) | |
2499 { | |
2500 for (int i = 0; i < m_property.size(); ++i) | |
2501 delete m_property[i]; | |
2502 m_property.clear(); | |
2503 | |
2504 if (clear_all) { | |
2505 m_text = QString(); | |
2506 } | |
2507 | |
2508 } | |
2509 | |
2510 DomColumn::DomColumn() | |
2511 { | |
2512 } | |
2513 | |
2514 DomColumn::~DomColumn() | |
2515 { | |
2516 for (int i = 0; i < m_property.size(); ++i) | |
2517 delete m_property[i]; | |
2518 m_property.clear(); | |
2519 } | |
2520 | |
2521 void DomColumn::read(const QDomElement &node) | |
2522 { | |
2523 | |
2524 for (QDomNode n = node.firstChild(); !n.isNull(); n = n.nextSibling()) { | |
2525 if (!n.isElement()) | |
2526 continue; | |
2527 QDomElement e = n.toElement(); | |
2528 QString tag = e.tagName().toLower(); | |
2529 if (tag == QLatin1String("property")) { | |
2530 DomProperty *v = new DomProperty(); | |
2531 v->read(e); | |
2532 m_property.append(v); | |
2533 continue; | |
2534 } | |
2535 } | |
2536 | |
2537 m_text.clear(); | |
2538 for (QDomNode child = node.firstChild(); !child.isNull(); child = child.nextSibling()) { | |
2539 if (child.isText()) | |
2540 m_text.append(child.nodeValue()); | |
2541 } | |
2542 } | |
2543 | |
2544 QDomElement DomColumn::write(QDomDocument &doc, const QString &tagName) const | |
2545 { | |
2546 QDomElement e = doc.createElement(tagName.isEmpty() ? QString::fromUtf8("column") : tagName.toLower()); | |
2547 | |
2548 QDomElement child; | |
2549 | |
2550 for (int i = 0; i < m_property.size(); ++i) { | |
2551 DomProperty* v = m_property[i]; | |
2552 QDomNode child = v->write(doc, QLatin1String("property")); | |
2553 e.appendChild(child); | |
2554 } | |
2555 if (!m_text.isEmpty()) | |
2556 e.appendChild(doc.createTextNode(m_text)); | |
2557 | |
2558 return e; | |
2559 } | |
2560 | |
2561 void DomColumn::setElementProperty(const QList<DomProperty*>& a) | |
2562 { | |
2563 m_property = a; | |
2564 } | |
2565 | |
2566 void DomItem::clear(bool clear_all) | |
2567 { | |
2568 for (int i = 0; i < m_property.size(); ++i) | |
2569 delete m_property[i]; | |
2570 m_property.clear(); | |
2571 for (int i = 0; i < m_item.size(); ++i) | |
2572 delete m_item[i]; | |
2573 m_item.clear(); | |
2574 | |
2575 if (clear_all) { | |
2576 m_text = QString(); | |
2577 m_has_attr_row = false; | |
2578 m_attr_row = 0; | |
2579 m_has_attr_column = false; | |
2580 m_attr_column = 0; | |
2581 } | |
2582 | |
2583 } | |
2584 | |
2585 DomItem::DomItem() | |
2586 { | |
2587 m_has_attr_row = false; | |
2588 m_attr_row = 0; | |
2589 m_has_attr_column = false; | |
2590 m_attr_column = 0; | |
2591 } | |
2592 | |
2593 DomItem::~DomItem() | |
2594 { | |
2595 for (int i = 0; i < m_property.size(); ++i) | |
2596 delete m_property[i]; | |
2597 m_property.clear(); | |
2598 for (int i = 0; i < m_item.size(); ++i) | |
2599 delete m_item[i]; | |
2600 m_item.clear(); | |
2601 } | |
2602 | |
2603 void DomItem::read(const QDomElement &node) | |
2604 { | |
2605 if (node.hasAttribute(QLatin1String("row"))) | |
2606 setAttributeRow(node.attribute(QLatin1String("row")).toInt()); | |
2607 if (node.hasAttribute(QLatin1String("column"))) | |
2608 setAttributeColumn(node.attribute(QLatin1String("column")).toInt()); | |
2609 | |
2610 for (QDomNode n = node.firstChild(); !n.isNull(); n = n.nextSibling()) { | |
2611 if (!n.isElement()) | |
2612 continue; | |
2613 QDomElement e = n.toElement(); | |
2614 QString tag = e.tagName().toLower(); | |
2615 if (tag == QLatin1String("property")) { | |
2616 DomProperty *v = new DomProperty(); | |
2617 v->read(e); | |
2618 m_property.append(v); | |
2619 continue; | |
2620 } | |
2621 if (tag == QLatin1String("item")) { | |
2622 DomItem *v = new DomItem(); | |
2623 v->read(e); | |
2624 m_item.append(v); | |
2625 continue; | |
2626 } | |
2627 } | |
2628 | |
2629 m_text.clear(); | |
2630 for (QDomNode child = node.firstChild(); !child.isNull(); child = child.nextSibling()) { | |
2631 if (child.isText()) | |
2632 m_text.append(child.nodeValue()); | |
2633 } | |
2634 } | |
2635 | |
2636 QDomElement DomItem::write(QDomDocument &doc, const QString &tagName) const | |
2637 { | |
2638 QDomElement e = doc.createElement(tagName.isEmpty() ? QString::fromUtf8("item") : tagName.toLower()); | |
2639 | |
2640 QDomElement child; | |
2641 | |
2642 if (hasAttributeRow()) | |
2643 e.setAttribute(QLatin1String("row"), attributeRow()); | |
2644 | |
2645 if (hasAttributeColumn()) | |
2646 e.setAttribute(QLatin1String("column"), attributeColumn()); | |
2647 | |
2648 for (int i = 0; i < m_property.size(); ++i) { | |
2649 DomProperty* v = m_property[i]; | |
2650 QDomNode child = v->write(doc, QLatin1String("property")); | |
2651 e.appendChild(child); | |
2652 } | |
2653 for (int i = 0; i < m_item.size(); ++i) { | |
2654 DomItem* v = m_item[i]; | |
2655 QDomNode child = v->write(doc, QLatin1String("item")); | |
2656 e.appendChild(child); | |
2657 } | |
2658 if (!m_text.isEmpty()) | |
2659 e.appendChild(doc.createTextNode(m_text)); | |
2660 | |
2661 return e; | |
2662 } | |
2663 | |
2664 void DomItem::setElementProperty(const QList<DomProperty*>& a) | |
2665 { | |
2666 m_property = a; | |
2667 } | |
2668 | |
2669 void DomItem::setElementItem(const QList<DomItem*>& a) | |
2670 { | |
2671 m_item = a; | |
2672 } | |
2673 | |
2674 void DomWidget::clear(bool clear_all) | |
2675 { | |
2676 m_class.clear(); | |
2677 for (int i = 0; i < m_property.size(); ++i) | |
2678 delete m_property[i]; | |
2679 m_property.clear(); | |
2680 for (int i = 0; i < m_script.size(); ++i) | |
2681 delete m_script[i]; | |
2682 m_script.clear(); | |
2683 for (int i = 0; i < m_widgetData.size(); ++i) | |
2684 delete m_widgetData[i]; | |
2685 m_widgetData.clear(); | |
2686 for (int i = 0; i < m_attribute.size(); ++i) | |
2687 delete m_attribute[i]; | |
2688 m_attribute.clear(); | |
2689 for (int i = 0; i < m_row.size(); ++i) | |
2690 delete m_row[i]; | |
2691 m_row.clear(); | |
2692 for (int i = 0; i < m_column.size(); ++i) | |
2693 delete m_column[i]; | |
2694 m_column.clear(); | |
2695 for (int i = 0; i < m_item.size(); ++i) | |
2696 delete m_item[i]; | |
2697 m_item.clear(); | |
2698 for (int i = 0; i < m_layout.size(); ++i) | |
2699 delete m_layout[i]; | |
2700 m_layout.clear(); | |
2701 for (int i = 0; i < m_widget.size(); ++i) | |
2702 delete m_widget[i]; | |
2703 m_widget.clear(); | |
2704 for (int i = 0; i < m_action.size(); ++i) | |
2705 delete m_action[i]; | |
2706 m_action.clear(); | |
2707 for (int i = 0; i < m_actionGroup.size(); ++i) | |
2708 delete m_actionGroup[i]; | |
2709 m_actionGroup.clear(); | |
2710 for (int i = 0; i < m_addAction.size(); ++i) | |
2711 delete m_addAction[i]; | |
2712 m_addAction.clear(); | |
2713 m_zOrder.clear(); | |
2714 | |
2715 if (clear_all) { | |
2716 m_text = QString(); | |
2717 m_has_attr_class = false; | |
2718 m_has_attr_name = false; | |
2719 m_has_attr_native = false; | |
2720 m_attr_native = false; | |
2721 } | |
2722 | |
2723 } | |
2724 | |
2725 DomWidget::DomWidget() | |
2726 { | |
2727 m_has_attr_class = false; | |
2728 m_has_attr_name = false; | |
2729 m_has_attr_native = false; | |
2730 m_attr_native = false; | |
2731 } | |
2732 | |
2733 DomWidget::~DomWidget() | |
2734 { | |
2735 m_class.clear(); | |
2736 for (int i = 0; i < m_property.size(); ++i) | |
2737 delete m_property[i]; | |
2738 m_property.clear(); | |
2739 for (int i = 0; i < m_script.size(); ++i) | |
2740 delete m_script[i]; | |
2741 m_script.clear(); | |
2742 for (int i = 0; i < m_widgetData.size(); ++i) | |
2743 delete m_widgetData[i]; | |
2744 m_widgetData.clear(); | |
2745 for (int i = 0; i < m_attribute.size(); ++i) | |
2746 delete m_attribute[i]; | |
2747 m_attribute.clear(); | |
2748 for (int i = 0; i < m_row.size(); ++i) | |
2749 delete m_row[i]; | |
2750 m_row.clear(); | |
2751 for (int i = 0; i < m_column.size(); ++i) | |
2752 delete m_column[i]; | |
2753 m_column.clear(); | |
2754 for (int i = 0; i < m_item.size(); ++i) | |
2755 delete m_item[i]; | |
2756 m_item.clear(); | |
2757 for (int i = 0; i < m_layout.size(); ++i) | |
2758 delete m_layout[i]; | |
2759 m_layout.clear(); | |
2760 for (int i = 0; i < m_widget.size(); ++i) | |
2761 delete m_widget[i]; | |
2762 m_widget.clear(); | |
2763 for (int i = 0; i < m_action.size(); ++i) | |
2764 delete m_action[i]; | |
2765 m_action.clear(); | |
2766 for (int i = 0; i < m_actionGroup.size(); ++i) | |
2767 delete m_actionGroup[i]; | |
2768 m_actionGroup.clear(); | |
2769 for (int i = 0; i < m_addAction.size(); ++i) | |
2770 delete m_addAction[i]; | |
2771 m_addAction.clear(); | |
2772 m_zOrder.clear(); | |
2773 } | |
2774 | |
2775 void DomWidget::read(const QDomElement &node) | |
2776 { | |
2777 if (node.hasAttribute(QLatin1String("class"))) | |
2778 setAttributeClass(node.attribute(QLatin1String("class"))); | |
2779 if (node.hasAttribute(QLatin1String("name"))) | |
2780 setAttributeName(node.attribute(QLatin1String("name"))); | |
2781 if (node.hasAttribute(QLatin1String("native"))) | |
2782 setAttributeNative((node.attribute(QLatin1String("native")) == QLatin1String("true") ? true : false)); | |
2783 | |
2784 for (QDomNode n = node.firstChild(); !n.isNull(); n = n.nextSibling()) { | |
2785 if (!n.isElement()) | |
2786 continue; | |
2787 QDomElement e = n.toElement(); | |
2788 QString tag = e.tagName().toLower(); | |
2789 if (tag == QLatin1String("class")) { | |
2790 m_class.append(e.text()); | |
2791 continue; | |
2792 } | |
2793 if (tag == QLatin1String("property")) { | |
2794 DomProperty *v = new DomProperty(); | |
2795 v->read(e); | |
2796 m_property.append(v); | |
2797 continue; | |
2798 } | |
2799 if (tag == QLatin1String("script")) { | |
2800 DomScript *v = new DomScript(); | |
2801 v->read(e); | |
2802 m_script.append(v); | |
2803 continue; | |
2804 } | |
2805 if (tag == QLatin1String("widgetdata")) { | |
2806 DomWidgetData *v = new DomWidgetData(); | |
2807 v->read(e); | |
2808 m_widgetData.append(v); | |
2809 continue; | |
2810 } | |
2811 if (tag == QLatin1String("attribute")) { | |
2812 DomProperty *v = new DomProperty(); | |
2813 v->read(e); | |
2814 m_attribute.append(v); | |
2815 continue; | |
2816 } | |
2817 if (tag == QLatin1String("row")) { | |
2818 DomRow *v = new DomRow(); | |
2819 v->read(e); | |
2820 m_row.append(v); | |
2821 continue; | |
2822 } | |
2823 if (tag == QLatin1String("column")) { | |
2824 DomColumn *v = new DomColumn(); | |
2825 v->read(e); | |
2826 m_column.append(v); | |
2827 continue; | |
2828 } | |
2829 if (tag == QLatin1String("item")) { | |
2830 DomItem *v = new DomItem(); | |
2831 v->read(e); | |
2832 m_item.append(v); | |
2833 continue; | |
2834 } | |
2835 if (tag == QLatin1String("layout")) { | |
2836 DomLayout *v = new DomLayout(); | |
2837 v->read(e); | |
2838 m_layout.append(v); | |
2839 continue; | |
2840 } | |
2841 if (tag == QLatin1String("widget")) { | |
2842 DomWidget *v = new DomWidget(); | |
2843 v->read(e); | |
2844 m_widget.append(v); | |
2845 continue; | |
2846 } | |
2847 if (tag == QLatin1String("action")) { | |
2848 DomAction *v = new DomAction(); | |
2849 v->read(e); | |
2850 m_action.append(v); | |
2851 continue; | |
2852 } | |
2853 if (tag == QLatin1String("actiongroup")) { | |
2854 DomActionGroup *v = new DomActionGroup(); | |
2855 v->read(e); | |
2856 m_actionGroup.append(v); | |
2857 continue; | |
2858 } | |
2859 if (tag == QLatin1String("addaction")) { | |
2860 DomActionRef *v = new DomActionRef(); | |
2861 v->read(e); | |
2862 m_addAction.append(v); | |
2863 continue; | |
2864 } | |
2865 if (tag == QLatin1String("zorder")) { | |
2866 m_zOrder.append(e.text()); | |
2867 continue; | |
2868 } | |
2869 } | |
2870 | |
2871 m_text.clear(); | |
2872 for (QDomNode child = node.firstChild(); !child.isNull(); child = child.nextSibling()) { | |
2873 if (child.isText()) | |
2874 m_text.append(child.nodeValue()); | |
2875 } | |
2876 } | |
2877 | |
2878 QDomElement DomWidget::write(QDomDocument &doc, const QString &tagName) const | |
2879 { | |
2880 QDomElement e = doc.createElement(tagName.isEmpty() ? QString::fromUtf8("widget") : tagName.toLower()); | |
2881 | |
2882 QDomElement child; | |
2883 | |
2884 if (hasAttributeClass()) | |
2885 e.setAttribute(QLatin1String("class"), attributeClass()); | |
2886 | |
2887 if (hasAttributeName()) | |
2888 e.setAttribute(QLatin1String("name"), attributeName()); | |
2889 | |
2890 if (hasAttributeNative()) | |
2891 e.setAttribute(QLatin1String("native"), attributeNative()); | |
2892 | |
2893 for (int i = 0; i < m_class.size(); ++i) { | |
2894 QString v = m_class[i]; | |
2895 QDomNode child = doc.createElement(QLatin1String("class")); | |
2896 child.appendChild(doc.createTextNode(v)); | |
2897 e.appendChild(child); | |
2898 } | |
2899 for (int i = 0; i < m_property.size(); ++i) { | |
2900 DomProperty* v = m_property[i]; | |
2901 QDomNode child = v->write(doc, QLatin1String("property")); | |
2902 e.appendChild(child); | |
2903 } | |
2904 for (int i = 0; i < m_script.size(); ++i) { | |
2905 DomScript* v = m_script[i]; | |
2906 QDomNode child = v->write(doc, QLatin1String("script")); | |
2907 e.appendChild(child); | |
2908 } | |
2909 for (int i = 0; i < m_widgetData.size(); ++i) { | |
2910 DomWidgetData* v = m_widgetData[i]; | |
2911 QDomNode child = v->write(doc, QLatin1String("widgetdata")); | |
2912 e.appendChild(child); | |
2913 } | |
2914 for (int i = 0; i < m_attribute.size(); ++i) { | |
2915 DomProperty* v = m_attribute[i]; | |
2916 QDomNode child = v->write(doc, QLatin1String("attribute")); | |
2917 e.appendChild(child); | |
2918 } | |
2919 for (int i = 0; i < m_row.size(); ++i) { | |
2920 DomRow* v = m_row[i]; | |
2921 QDomNode child = v->write(doc, QLatin1String("row")); | |
2922 e.appendChild(child); | |
2923 } | |
2924 for (int i = 0; i < m_column.size(); ++i) { | |
2925 DomColumn* v = m_column[i]; | |
2926 QDomNode child = v->write(doc, QLatin1String("column")); | |
2927 e.appendChild(child); | |
2928 } | |
2929 for (int i = 0; i < m_item.size(); ++i) { | |
2930 DomItem* v = m_item[i]; | |
2931 QDomNode child = v->write(doc, QLatin1String("item")); | |
2932 e.appendChild(child); | |
2933 } | |
2934 for (int i = 0; i < m_layout.size(); ++i) { | |
2935 DomLayout* v = m_layout[i]; | |
2936 QDomNode child = v->write(doc, QLatin1String("layout")); | |
2937 e.appendChild(child); | |
2938 } | |
2939 for (int i = 0; i < m_widget.size(); ++i) { | |
2940 DomWidget* v = m_widget[i]; | |
2941 QDomNode child = v->write(doc, QLatin1String("widget")); | |
2942 e.appendChild(child); | |
2943 } | |
2944 for (int i = 0; i < m_action.size(); ++i) { | |
2945 DomAction* v = m_action[i]; | |
2946 QDomNode child = v->write(doc, QLatin1String("action")); | |
2947 e.appendChild(child); | |
2948 } | |
2949 for (int i = 0; i < m_actionGroup.size(); ++i) { | |
2950 DomActionGroup* v = m_actionGroup[i]; | |
2951 QDomNode child = v->write(doc, QLatin1String("actiongroup")); | |
2952 e.appendChild(child); | |
2953 } | |
2954 for (int i = 0; i < m_addAction.size(); ++i) { | |
2955 DomActionRef* v = m_addAction[i]; | |
2956 QDomNode child = v->write(doc, QLatin1String("addaction")); | |
2957 e.appendChild(child); | |
2958 } | |
2959 for (int i = 0; i < m_zOrder.size(); ++i) { | |
2960 QString v = m_zOrder[i]; | |
2961 QDomNode child = doc.createElement(QLatin1String("zorder")); | |
2962 child.appendChild(doc.createTextNode(v)); | |
2963 e.appendChild(child); | |
2964 } | |
2965 if (!m_text.isEmpty()) | |
2966 e.appendChild(doc.createTextNode(m_text)); | |
2967 | |
2968 return e; | |
2969 } | |
2970 | |
2971 void DomWidget::setElementClass(const QStringList& a) | |
2972 { | |
2973 m_class = a; | |
2974 } | |
2975 | |
2976 void DomWidget::setElementProperty(const QList<DomProperty*>& a) | |
2977 { | |
2978 m_property = a; | |
2979 } | |
2980 | |
2981 void DomWidget::setElementScript(const QList<DomScript*>& a) | |
2982 { | |
2983 m_script = a; | |
2984 } | |
2985 | |
2986 void DomWidget::setElementWidgetData(const QList<DomWidgetData*>& a) | |
2987 { | |
2988 m_widgetData = a; | |
2989 } | |
2990 | |
2991 void DomWidget::setElementAttribute(const QList<DomProperty*>& a) | |
2992 { | |
2993 m_attribute = a; | |
2994 } | |
2995 | |
2996 void DomWidget::setElementRow(const QList<DomRow*>& a) | |
2997 { | |
2998 m_row = a; | |
2999 } | |
3000 | |
3001 void DomWidget::setElementColumn(const QList<DomColumn*>& a) | |
3002 { | |
3003 m_column = a; | |
3004 } | |
3005 | |
3006 void DomWidget::setElementItem(const QList<DomItem*>& a) | |
3007 { | |
3008 m_item = a; | |
3009 } | |
3010 | |
3011 void DomWidget::setElementLayout(const QList<DomLayout*>& a) | |
3012 { | |
3013 m_layout = a; | |
3014 } | |
3015 | |
3016 void DomWidget::setElementWidget(const QList<DomWidget*>& a) | |
3017 { | |
3018 m_widget = a; | |
3019 } | |
3020 | |
3021 void DomWidget::setElementAction(const QList<DomAction*>& a) | |
3022 { | |
3023 m_action = a; | |
3024 } | |
3025 | |
3026 void DomWidget::setElementActionGroup(const QList<DomActionGroup*>& a) | |
3027 { | |
3028 m_actionGroup = a; | |
3029 } | |
3030 | |
3031 void DomWidget::setElementAddAction(const QList<DomActionRef*>& a) | |
3032 { | |
3033 m_addAction = a; | |
3034 } | |
3035 | |
3036 void DomWidget::setElementZOrder(const QStringList& a) | |
3037 { | |
3038 m_zOrder = a; | |
3039 } | |
3040 | |
3041 void DomSpacer::clear(bool clear_all) | |
3042 { | |
3043 for (int i = 0; i < m_property.size(); ++i) | |
3044 delete m_property[i]; | |
3045 m_property.clear(); | |
3046 | |
3047 if (clear_all) { | |
3048 m_text = QString(); | |
3049 m_has_attr_name = false; | |
3050 } | |
3051 | |
3052 } | |
3053 | |
3054 DomSpacer::DomSpacer() | |
3055 { | |
3056 m_has_attr_name = false; | |
3057 } | |
3058 | |
3059 DomSpacer::~DomSpacer() | |
3060 { | |
3061 for (int i = 0; i < m_property.size(); ++i) | |
3062 delete m_property[i]; | |
3063 m_property.clear(); | |
3064 } | |
3065 | |
3066 void DomSpacer::read(const QDomElement &node) | |
3067 { | |
3068 if (node.hasAttribute(QLatin1String("name"))) | |
3069 setAttributeName(node.attribute(QLatin1String("name"))); | |
3070 | |
3071 for (QDomNode n = node.firstChild(); !n.isNull(); n = n.nextSibling()) { | |
3072 if (!n.isElement()) | |
3073 continue; | |
3074 QDomElement e = n.toElement(); | |
3075 QString tag = e.tagName().toLower(); | |
3076 if (tag == QLatin1String("property")) { | |
3077 DomProperty *v = new DomProperty(); | |
3078 v->read(e); | |
3079 m_property.append(v); | |
3080 continue; | |
3081 } | |
3082 } | |
3083 | |
3084 m_text.clear(); | |
3085 for (QDomNode child = node.firstChild(); !child.isNull(); child = child.nextSibling()) { | |
3086 if (child.isText()) | |
3087 m_text.append(child.nodeValue()); | |
3088 } | |
3089 } | |
3090 | |
3091 QDomElement DomSpacer::write(QDomDocument &doc, const QString &tagName) const | |
3092 { | |
3093 QDomElement e = doc.createElement(tagName.isEmpty() ? QString::fromUtf8("spacer") : tagName.toLower()); | |
3094 | |
3095 QDomElement child; | |
3096 | |
3097 if (hasAttributeName()) | |
3098 e.setAttribute(QLatin1String("name"), attributeName()); | |
3099 | |
3100 for (int i = 0; i < m_property.size(); ++i) { | |
3101 DomProperty* v = m_property[i]; | |
3102 QDomNode child = v->write(doc, QLatin1String("property")); | |
3103 e.appendChild(child); | |
3104 } | |
3105 if (!m_text.isEmpty()) | |
3106 e.appendChild(doc.createTextNode(m_text)); | |
3107 | |
3108 return e; | |
3109 } | |
3110 | |
3111 void DomSpacer::setElementProperty(const QList<DomProperty*>& a) | |
3112 { | |
3113 m_property = a; | |
3114 } | |
3115 | |
3116 void DomColor::clear(bool clear_all) | |
3117 { | |
3118 | |
3119 if (clear_all) { | |
3120 m_text = QString(); | |
3121 m_has_attr_alpha = false; | |
3122 m_attr_alpha = 0; | |
3123 } | |
3124 | |
3125 m_children = 0; | |
3126 m_red = 0; | |
3127 m_green = 0; | |
3128 m_blue = 0; | |
3129 } | |
3130 | |
3131 DomColor::DomColor() | |
3132 { | |
3133 m_children = 0; | |
3134 m_has_attr_alpha = false; | |
3135 m_attr_alpha = 0; | |
3136 m_red = 0; | |
3137 m_green = 0; | |
3138 m_blue = 0; | |
3139 } | |
3140 | |
3141 DomColor::~DomColor() | |
3142 { | |
3143 } | |
3144 | |
3145 void DomColor::read(const QDomElement &node) | |
3146 { | |
3147 if (node.hasAttribute(QLatin1String("alpha"))) | |
3148 setAttributeAlpha(node.attribute(QLatin1String("alpha")).toInt()); | |
3149 | |
3150 for (QDomNode n = node.firstChild(); !n.isNull(); n = n.nextSibling()) { | |
3151 if (!n.isElement()) | |
3152 continue; | |
3153 QDomElement e = n.toElement(); | |
3154 QString tag = e.tagName().toLower(); | |
3155 if (tag == QLatin1String("red")) { | |
3156 setElementRed(e.text().toInt()); | |
3157 continue; | |
3158 } | |
3159 if (tag == QLatin1String("green")) { | |
3160 setElementGreen(e.text().toInt()); | |
3161 continue; | |
3162 } | |
3163 if (tag == QLatin1String("blue")) { | |
3164 setElementBlue(e.text().toInt()); | |
3165 continue; | |
3166 } | |
3167 } | |
3168 | |
3169 m_text.clear(); | |
3170 for (QDomNode child = node.firstChild(); !child.isNull(); child = child.nextSibling()) { | |
3171 if (child.isText()) | |
3172 m_text.append(child.nodeValue()); | |
3173 } | |
3174 } | |
3175 | |
3176 QDomElement DomColor::write(QDomDocument &doc, const QString &tagName) const | |
3177 { | |
3178 QDomElement e = doc.createElement(tagName.isEmpty() ? QString::fromUtf8("color") : tagName.toLower()); | |
3179 | |
3180 QDomElement child; | |
3181 | |
3182 if (hasAttributeAlpha()) | |
3183 e.setAttribute(QLatin1String("alpha"), attributeAlpha()); | |
3184 | |
3185 if (m_children & Red) { | |
3186 child = doc.createElement(QLatin1String("red")); | |
3187 child.appendChild(doc.createTextNode(QString::number(m_red))); | |
3188 e.appendChild(child); | |
3189 } | |
3190 | |
3191 if (m_children & Green) { | |
3192 child = doc.createElement(QLatin1String("green")); | |
3193 child.appendChild(doc.createTextNode(QString::number(m_green))); | |
3194 e.appendChild(child); | |
3195 } | |
3196 | |
3197 if (m_children & Blue) { | |
3198 child = doc.createElement(QLatin1String("blue")); | |
3199 child.appendChild(doc.createTextNode(QString::number(m_blue))); | |
3200 e.appendChild(child); | |
3201 } | |
3202 | |
3203 if (!m_text.isEmpty()) | |
3204 e.appendChild(doc.createTextNode(m_text)); | |
3205 | |
3206 return e; | |
3207 } | |
3208 | |
3209 void DomColor::setElementRed(int a) | |
3210 { | |
3211 m_children |= Red; | |
3212 m_red = a; | |
3213 } | |
3214 | |
3215 void DomColor::setElementGreen(int a) | |
3216 { | |
3217 m_children |= Green; | |
3218 m_green = a; | |
3219 } | |
3220 | |
3221 void DomColor::setElementBlue(int a) | |
3222 { | |
3223 m_children |= Blue; | |
3224 m_blue = a; | |
3225 } | |
3226 | |
3227 void DomColor::clearElementRed() | |
3228 { | |
3229 m_children &= ~Red; | |
3230 } | |
3231 | |
3232 void DomColor::clearElementGreen() | |
3233 { | |
3234 m_children &= ~Green; | |
3235 } | |
3236 | |
3237 void DomColor::clearElementBlue() | |
3238 { | |
3239 m_children &= ~Blue; | |
3240 } | |
3241 | |
3242 void DomGradientStop::clear(bool clear_all) | |
3243 { | |
3244 delete m_color; | |
3245 | |
3246 if (clear_all) { | |
3247 m_text = QString(); | |
3248 m_has_attr_position = false; | |
3249 m_attr_position = 0.0; | |
3250 } | |
3251 | |
3252 m_children = 0; | |
3253 m_color = 0; | |
3254 } | |
3255 | |
3256 DomGradientStop::DomGradientStop() | |
3257 { | |
3258 m_children = 0; | |
3259 m_has_attr_position = false; | |
3260 m_attr_position = 0.0; | |
3261 m_color = 0; | |
3262 } | |
3263 | |
3264 DomGradientStop::~DomGradientStop() | |
3265 { | |
3266 delete m_color; | |
3267 } | |
3268 | |
3269 void DomGradientStop::read(const QDomElement &node) | |
3270 { | |
3271 if (node.hasAttribute(QLatin1String("position"))) | |
3272 setAttributePosition(node.attribute(QLatin1String("position")).toDouble()); | |
3273 | |
3274 for (QDomNode n = node.firstChild(); !n.isNull(); n = n.nextSibling()) { | |
3275 if (!n.isElement()) | |
3276 continue; | |
3277 QDomElement e = n.toElement(); | |
3278 QString tag = e.tagName().toLower(); | |
3279 if (tag == QLatin1String("color")) { | |
3280 DomColor *v = new DomColor(); | |
3281 v->read(e); | |
3282 setElementColor(v); | |
3283 continue; | |
3284 } | |
3285 } | |
3286 | |
3287 m_text.clear(); | |
3288 for (QDomNode child = node.firstChild(); !child.isNull(); child = child.nextSibling()) { | |
3289 if (child.isText()) | |
3290 m_text.append(child.nodeValue()); | |
3291 } | |
3292 } | |
3293 | |
3294 QDomElement DomGradientStop::write(QDomDocument &doc, const QString &tagName) const | |
3295 { | |
3296 QDomElement e = doc.createElement(tagName.isEmpty() ? QString::fromUtf8("gradientstop") : tagName.toLower()); | |
3297 | |
3298 QDomElement child; | |
3299 | |
3300 if (hasAttributePosition()) | |
3301 e.setAttribute(QLatin1String("position"), attributePosition()); | |
3302 | |
3303 if (m_children & Color) { | |
3304 e.appendChild(m_color->write(doc, QLatin1String("color"))); | |
3305 } | |
3306 | |
3307 if (!m_text.isEmpty()) | |
3308 e.appendChild(doc.createTextNode(m_text)); | |
3309 | |
3310 return e; | |
3311 } | |
3312 | |
3313 void DomGradientStop::setElementColor(DomColor* a) | |
3314 { | |
3315 delete m_color; | |
3316 m_children |= Color; | |
3317 m_color = a; | |
3318 } | |
3319 | |
3320 void DomGradientStop::clearElementColor() | |
3321 { | |
3322 delete m_color; | |
3323 m_color = 0; | |
3324 m_children &= ~Color; | |
3325 } | |
3326 | |
3327 void DomGradient::clear(bool clear_all) | |
3328 { | |
3329 for (int i = 0; i < m_gradientStop.size(); ++i) | |
3330 delete m_gradientStop[i]; | |
3331 m_gradientStop.clear(); | |
3332 | |
3333 if (clear_all) { | |
3334 m_text = QString(); | |
3335 m_has_attr_startX = false; | |
3336 m_attr_startX = 0.0; | |
3337 m_has_attr_startY = false; | |
3338 m_attr_startY = 0.0; | |
3339 m_has_attr_endX = false; | |
3340 m_attr_endX = 0.0; | |
3341 m_has_attr_endY = false; | |
3342 m_attr_endY = 0.0; | |
3343 m_has_attr_centralX = false; | |
3344 m_attr_centralX = 0.0; | |
3345 m_has_attr_centralY = false; | |
3346 m_attr_centralY = 0.0; | |
3347 m_has_attr_focalX = false; | |
3348 m_attr_focalX = 0.0; | |
3349 m_has_attr_focalY = false; | |
3350 m_attr_focalY = 0.0; | |
3351 m_has_attr_radius = false; | |
3352 m_attr_radius = 0.0; | |
3353 m_has_attr_angle = false; | |
3354 m_attr_angle = 0.0; | |
3355 m_has_attr_type = false; | |
3356 m_has_attr_spread = false; | |
3357 m_has_attr_coordinateMode = false; | |
3358 } | |
3359 | |
3360 } | |
3361 | |
3362 DomGradient::DomGradient() | |
3363 { | |
3364 m_has_attr_startX = false; | |
3365 m_attr_startX = 0.0; | |
3366 m_has_attr_startY = false; | |
3367 m_attr_startY = 0.0; | |
3368 m_has_attr_endX = false; | |
3369 m_attr_endX = 0.0; | |
3370 m_has_attr_endY = false; | |
3371 m_attr_endY = 0.0; | |
3372 m_has_attr_centralX = false; | |
3373 m_attr_centralX = 0.0; | |
3374 m_has_attr_centralY = false; | |
3375 m_attr_centralY = 0.0; | |
3376 m_has_attr_focalX = false; | |
3377 m_attr_focalX = 0.0; | |
3378 m_has_attr_focalY = false; | |
3379 m_attr_focalY = 0.0; | |
3380 m_has_attr_radius = false; | |
3381 m_attr_radius = 0.0; | |
3382 m_has_attr_angle = false; | |
3383 m_attr_angle = 0.0; | |
3384 m_has_attr_type = false; | |
3385 m_has_attr_spread = false; | |
3386 m_has_attr_coordinateMode = false; | |
3387 } | |
3388 | |
3389 DomGradient::~DomGradient() | |
3390 { | |
3391 for (int i = 0; i < m_gradientStop.size(); ++i) | |
3392 delete m_gradientStop[i]; | |
3393 m_gradientStop.clear(); | |
3394 } | |
3395 | |
3396 void DomGradient::read(const QDomElement &node) | |
3397 { | |
3398 if (node.hasAttribute(QLatin1String("startx"))) | |
3399 setAttributeStartX(node.attribute(QLatin1String("startx")).toDouble()); | |
3400 if (node.hasAttribute(QLatin1String("starty"))) | |
3401 setAttributeStartY(node.attribute(QLatin1String("starty")).toDouble()); | |
3402 if (node.hasAttribute(QLatin1String("endx"))) | |
3403 setAttributeEndX(node.attribute(QLatin1String("endx")).toDouble()); | |
3404 if (node.hasAttribute(QLatin1String("endy"))) | |
3405 setAttributeEndY(node.attribute(QLatin1String("endy")).toDouble()); | |
3406 if (node.hasAttribute(QLatin1String("centralx"))) | |
3407 setAttributeCentralX(node.attribute(QLatin1String("centralx")).toDouble()); | |
3408 if (node.hasAttribute(QLatin1String("centraly"))) | |
3409 setAttributeCentralY(node.attribute(QLatin1String("centraly")).toDouble()); | |
3410 if (node.hasAttribute(QLatin1String("focalx"))) | |
3411 setAttributeFocalX(node.attribute(QLatin1String("focalx")).toDouble()); | |
3412 if (node.hasAttribute(QLatin1String("focaly"))) | |
3413 setAttributeFocalY(node.attribute(QLatin1String("focaly")).toDouble()); | |
3414 if (node.hasAttribute(QLatin1String("radius"))) | |
3415 setAttributeRadius(node.attribute(QLatin1String("radius")).toDouble()); | |
3416 if (node.hasAttribute(QLatin1String("angle"))) | |
3417 setAttributeAngle(node.attribute(QLatin1String("angle")).toDouble()); | |
3418 if (node.hasAttribute(QLatin1String("type"))) | |
3419 setAttributeType(node.attribute(QLatin1String("type"))); | |
3420 if (node.hasAttribute(QLatin1String("spread"))) | |
3421 setAttributeSpread(node.attribute(QLatin1String("spread"))); | |
3422 if (node.hasAttribute(QLatin1String("coordinatemode"))) | |
3423 setAttributeCoordinateMode(node.attribute(QLatin1String("coordinatemode"))); | |
3424 | |
3425 for (QDomNode n = node.firstChild(); !n.isNull(); n = n.nextSibling()) { | |
3426 if (!n.isElement()) | |
3427 continue; | |
3428 QDomElement e = n.toElement(); | |
3429 QString tag = e.tagName().toLower(); | |
3430 if (tag == QLatin1String("gradientstop")) { | |
3431 DomGradientStop *v = new DomGradientStop(); | |
3432 v->read(e); | |
3433 m_gradientStop.append(v); | |
3434 continue; | |
3435 } | |
3436 } | |
3437 | |
3438 m_text.clear(); | |
3439 for (QDomNode child = node.firstChild(); !child.isNull(); child = child.nextSibling()) { | |
3440 if (child.isText()) | |
3441 m_text.append(child.nodeValue()); | |
3442 } | |
3443 } | |
3444 | |
3445 QDomElement DomGradient::write(QDomDocument &doc, const QString &tagName) const | |
3446 { | |
3447 QDomElement e = doc.createElement(tagName.isEmpty() ? QString::fromUtf8("gradient") : tagName.toLower()); | |
3448 | |
3449 QDomElement child; | |
3450 | |
3451 if (hasAttributeStartX()) | |
3452 e.setAttribute(QLatin1String("startx"), attributeStartX()); | |
3453 | |
3454 if (hasAttributeStartY()) | |
3455 e.setAttribute(QLatin1String("starty"), attributeStartY()); | |
3456 | |
3457 if (hasAttributeEndX()) | |
3458 e.setAttribute(QLatin1String("endx"), attributeEndX()); | |
3459 | |
3460 if (hasAttributeEndY()) | |
3461 e.setAttribute(QLatin1String("endy"), attributeEndY()); | |
3462 | |
3463 if (hasAttributeCentralX()) | |
3464 e.setAttribute(QLatin1String("centralx"), attributeCentralX()); | |
3465 | |
3466 if (hasAttributeCentralY()) | |
3467 e.setAttribute(QLatin1String("centraly"), attributeCentralY()); | |
3468 | |
3469 if (hasAttributeFocalX()) | |
3470 e.setAttribute(QLatin1String("focalx"), attributeFocalX()); | |
3471 | |
3472 if (hasAttributeFocalY()) | |
3473 e.setAttribute(QLatin1String("focaly"), attributeFocalY()); | |
3474 | |
3475 if (hasAttributeRadius()) | |
3476 e.setAttribute(QLatin1String("radius"), attributeRadius()); | |
3477 | |
3478 if (hasAttributeAngle()) | |
3479 e.setAttribute(QLatin1String("angle"), attributeAngle()); | |
3480 | |
3481 if (hasAttributeType()) | |
3482 e.setAttribute(QLatin1String("type"), attributeType()); | |
3483 | |
3484 if (hasAttributeSpread()) | |
3485 e.setAttribute(QLatin1String("spread"), attributeSpread()); | |
3486 | |
3487 if (hasAttributeCoordinateMode()) | |
3488 e.setAttribute(QLatin1String("coordinatemode"), attributeCoordinateMode()); | |
3489 | |
3490 for (int i = 0; i < m_gradientStop.size(); ++i) { | |
3491 DomGradientStop* v = m_gradientStop[i]; | |
3492 QDomNode child = v->write(doc, QLatin1String("gradientstop")); | |
3493 e.appendChild(child); | |
3494 } | |
3495 if (!m_text.isEmpty()) | |
3496 e.appendChild(doc.createTextNode(m_text)); | |
3497 | |
3498 return e; | |
3499 } | |
3500 | |
3501 void DomGradient::setElementGradientStop(const QList<DomGradientStop*>& a) | |
3502 { | |
3503 m_gradientStop = a; | |
3504 } | |
3505 | |
3506 void DomBrush::clear(bool clear_all) | |
3507 { | |
3508 delete m_color; | |
3509 delete m_texture; | |
3510 delete m_gradient; | |
3511 | |
3512 if (clear_all) { | |
3513 m_text = QString(); | |
3514 m_has_attr_brushStyle = false; | |
3515 } | |
3516 | |
3517 m_kind = Unknown; | |
3518 | |
3519 m_color = 0; | |
3520 m_texture = 0; | |
3521 m_gradient = 0; | |
3522 } | |
3523 | |
3524 DomBrush::DomBrush() | |
3525 { | |
3526 m_kind = Unknown; | |
3527 | |
3528 m_has_attr_brushStyle = false; | |
3529 m_color = 0; | |
3530 m_texture = 0; | |
3531 m_gradient = 0; | |
3532 } | |
3533 | |
3534 DomBrush::~DomBrush() | |
3535 { | |
3536 delete m_color; | |
3537 delete m_texture; | |
3538 delete m_gradient; | |
3539 } | |
3540 | |
3541 void DomBrush::read(const QDomElement &node) | |
3542 { | |
3543 if (node.hasAttribute(QLatin1String("brushstyle"))) | |
3544 setAttributeBrushStyle(node.attribute(QLatin1String("brushstyle"))); | |
3545 | |
3546 for (QDomNode n = node.firstChild(); !n.isNull(); n = n.nextSibling()) { | |
3547 if (!n.isElement()) | |
3548 continue; | |
3549 QDomElement e = n.toElement(); | |
3550 QString tag = e.tagName().toLower(); | |
3551 if (tag == QLatin1String("color")) { | |
3552 DomColor *v = new DomColor(); | |
3553 v->read(e); | |
3554 setElementColor(v); | |
3555 continue; | |
3556 } | |
3557 if (tag == QLatin1String("texture")) { | |
3558 DomProperty *v = new DomProperty(); | |
3559 v->read(e); | |
3560 setElementTexture(v); | |
3561 continue; | |
3562 } | |
3563 if (tag == QLatin1String("gradient")) { | |
3564 DomGradient *v = new DomGradient(); | |
3565 v->read(e); | |
3566 setElementGradient(v); | |
3567 continue; | |
3568 } | |
3569 } | |
3570 | |
3571 m_text.clear(); | |
3572 for (QDomNode child = node.firstChild(); !child.isNull(); child = child.nextSibling()) { | |
3573 if (child.isText()) | |
3574 m_text.append(child.nodeValue()); | |
3575 } | |
3576 } | |
3577 | |
3578 QDomElement DomBrush::write(QDomDocument &doc, const QString &tagName) const | |
3579 { | |
3580 QDomElement e = doc.createElement(tagName.isEmpty() ? QString::fromUtf8("brush") : tagName.toLower()); | |
3581 | |
3582 QDomElement child; | |
3583 | |
3584 if (hasAttributeBrushStyle()) | |
3585 e.setAttribute(QLatin1String("brushstyle"), attributeBrushStyle()); | |
3586 | |
3587 switch(kind()) { | |
3588 case Color: { | |
3589 DomColor* v = elementColor(); | |
3590 if (v != 0) { | |
3591 QDomElement child = v->write(doc, QLatin1String("color")); | |
3592 e.appendChild(child); | |
3593 } | |
3594 break; | |
3595 } | |
3596 case Texture: { | |
3597 DomProperty* v = elementTexture(); | |
3598 if (v != 0) { | |
3599 QDomElement child = v->write(doc, QLatin1String("texture")); | |
3600 e.appendChild(child); | |
3601 } | |
3602 break; | |
3603 } | |
3604 case Gradient: { | |
3605 DomGradient* v = elementGradient(); | |
3606 if (v != 0) { | |
3607 QDomElement child = v->write(doc, QLatin1String("gradient")); | |
3608 e.appendChild(child); | |
3609 } | |
3610 break; | |
3611 } | |
3612 default: | |
3613 break; | |
3614 } | |
3615 if (!m_text.isEmpty()) | |
3616 e.appendChild(doc.createTextNode(m_text)); | |
3617 | |
3618 return e; | |
3619 } | |
3620 | |
3621 void DomBrush::setElementColor(DomColor* a) | |
3622 { | |
3623 clear(false); | |
3624 m_kind = Color; | |
3625 m_color = a; | |
3626 } | |
3627 | |
3628 void DomBrush::setElementTexture(DomProperty* a) | |
3629 { | |
3630 clear(false); | |
3631 m_kind = Texture; | |
3632 m_texture = a; | |
3633 } | |
3634 | |
3635 void DomBrush::setElementGradient(DomGradient* a) | |
3636 { | |
3637 clear(false); | |
3638 m_kind = Gradient; | |
3639 m_gradient = a; | |
3640 } | |
3641 | |
3642 void DomColorRole::clear(bool clear_all) | |
3643 { | |
3644 delete m_brush; | |
3645 | |
3646 if (clear_all) { | |
3647 m_text = QString(); | |
3648 m_has_attr_role = false; | |
3649 } | |
3650 | |
3651 m_children = 0; | |
3652 m_brush = 0; | |
3653 } | |
3654 | |
3655 DomColorRole::DomColorRole() | |
3656 { | |
3657 m_children = 0; | |
3658 m_has_attr_role = false; | |
3659 m_brush = 0; | |
3660 } | |
3661 | |
3662 DomColorRole::~DomColorRole() | |
3663 { | |
3664 delete m_brush; | |
3665 } | |
3666 | |
3667 void DomColorRole::read(const QDomElement &node) | |
3668 { | |
3669 if (node.hasAttribute(QLatin1String("role"))) | |
3670 setAttributeRole(node.attribute(QLatin1String("role"))); | |
3671 | |
3672 for (QDomNode n = node.firstChild(); !n.isNull(); n = n.nextSibling()) { | |
3673 if (!n.isElement()) | |
3674 continue; | |
3675 QDomElement e = n.toElement(); | |
3676 QString tag = e.tagName().toLower(); | |
3677 if (tag == QLatin1String("brush")) { | |
3678 DomBrush *v = new DomBrush(); | |
3679 v->read(e); | |
3680 setElementBrush(v); | |
3681 continue; | |
3682 } | |
3683 } | |
3684 | |
3685 m_text.clear(); | |
3686 for (QDomNode child = node.firstChild(); !child.isNull(); child = child.nextSibling()) { | |
3687 if (child.isText()) | |
3688 m_text.append(child.nodeValue()); | |
3689 } | |
3690 } | |
3691 | |
3692 QDomElement DomColorRole::write(QDomDocument &doc, const QString &tagName) const | |
3693 { | |
3694 QDomElement e = doc.createElement(tagName.isEmpty() ? QString::fromUtf8("colorrole") : tagName.toLower()); | |
3695 | |
3696 QDomElement child; | |
3697 | |
3698 if (hasAttributeRole()) | |
3699 e.setAttribute(QLatin1String("role"), attributeRole()); | |
3700 | |
3701 if (m_children & Brush) { | |
3702 e.appendChild(m_brush->write(doc, QLatin1String("brush"))); | |
3703 } | |
3704 | |
3705 if (!m_text.isEmpty()) | |
3706 e.appendChild(doc.createTextNode(m_text)); | |
3707 | |
3708 return e; | |
3709 } | |
3710 | |
3711 void DomColorRole::setElementBrush(DomBrush* a) | |
3712 { | |
3713 delete m_brush; | |
3714 m_children |= Brush; | |
3715 m_brush = a; | |
3716 } | |
3717 | |
3718 void DomColorRole::clearElementBrush() | |
3719 { | |
3720 delete m_brush; | |
3721 m_brush = 0; | |
3722 m_children &= ~Brush; | |
3723 } | |
3724 | |
3725 void DomColorGroup::clear(bool clear_all) | |
3726 { | |
3727 for (int i = 0; i < m_colorRole.size(); ++i) | |
3728 delete m_colorRole[i]; | |
3729 m_colorRole.clear(); | |
3730 for (int i = 0; i < m_color.size(); ++i) | |
3731 delete m_color[i]; | |
3732 m_color.clear(); | |
3733 | |
3734 if (clear_all) { | |
3735 m_text = QString(); | |
3736 } | |
3737 | |
3738 } | |
3739 | |
3740 DomColorGroup::DomColorGroup() | |
3741 { | |
3742 } | |
3743 | |
3744 DomColorGroup::~DomColorGroup() | |
3745 { | |
3746 for (int i = 0; i < m_colorRole.size(); ++i) | |
3747 delete m_colorRole[i]; | |
3748 m_colorRole.clear(); | |
3749 for (int i = 0; i < m_color.size(); ++i) | |
3750 delete m_color[i]; | |
3751 m_color.clear(); | |
3752 } | |
3753 | |
3754 void DomColorGroup::read(const QDomElement &node) | |
3755 { | |
3756 | |
3757 for (QDomNode n = node.firstChild(); !n.isNull(); n = n.nextSibling()) { | |
3758 if (!n.isElement()) | |
3759 continue; | |
3760 QDomElement e = n.toElement(); | |
3761 QString tag = e.tagName().toLower(); | |
3762 if (tag == QLatin1String("colorrole")) { | |
3763 DomColorRole *v = new DomColorRole(); | |
3764 v->read(e); | |
3765 m_colorRole.append(v); | |
3766 continue; | |
3767 } | |
3768 if (tag == QLatin1String("color")) { | |
3769 DomColor *v = new DomColor(); | |
3770 v->read(e); | |
3771 m_color.append(v); | |
3772 continue; | |
3773 } | |
3774 } | |
3775 | |
3776 m_text.clear(); | |
3777 for (QDomNode child = node.firstChild(); !child.isNull(); child = child.nextSibling()) { | |
3778 if (child.isText()) | |
3779 m_text.append(child.nodeValue()); | |
3780 } | |
3781 } | |
3782 | |
3783 QDomElement DomColorGroup::write(QDomDocument &doc, const QString &tagName) const | |
3784 { | |
3785 QDomElement e = doc.createElement(tagName.isEmpty() ? QString::fromUtf8("colorgroup") : tagName.toLower()); | |
3786 | |
3787 QDomElement child; | |
3788 | |
3789 for (int i = 0; i < m_colorRole.size(); ++i) { | |
3790 DomColorRole* v = m_colorRole[i]; | |
3791 QDomNode child = v->write(doc, QLatin1String("colorrole")); | |
3792 e.appendChild(child); | |
3793 } | |
3794 for (int i = 0; i < m_color.size(); ++i) { | |
3795 DomColor* v = m_color[i]; | |
3796 QDomNode child = v->write(doc, QLatin1String("color")); | |
3797 e.appendChild(child); | |
3798 } | |
3799 if (!m_text.isEmpty()) | |
3800 e.appendChild(doc.createTextNode(m_text)); | |
3801 | |
3802 return e; | |
3803 } | |
3804 | |
3805 void DomColorGroup::setElementColorRole(const QList<DomColorRole*>& a) | |
3806 { | |
3807 m_colorRole = a; | |
3808 } | |
3809 | |
3810 void DomColorGroup::setElementColor(const QList<DomColor*>& a) | |
3811 { | |
3812 m_color = a; | |
3813 } | |
3814 | |
3815 void DomPalette::clear(bool clear_all) | |
3816 { | |
3817 delete m_active; | |
3818 delete m_inactive; | |
3819 delete m_disabled; | |
3820 | |
3821 if (clear_all) { | |
3822 m_text = QString(); | |
3823 } | |
3824 | |
3825 m_children = 0; | |
3826 m_active = 0; | |
3827 m_inactive = 0; | |
3828 m_disabled = 0; | |
3829 } | |
3830 | |
3831 DomPalette::DomPalette() | |
3832 { | |
3833 m_children = 0; | |
3834 m_active = 0; | |
3835 m_inactive = 0; | |
3836 m_disabled = 0; | |
3837 } | |
3838 | |
3839 DomPalette::~DomPalette() | |
3840 { | |
3841 delete m_active; | |
3842 delete m_inactive; | |
3843 delete m_disabled; | |
3844 } | |
3845 | |
3846 void DomPalette::read(const QDomElement &node) | |
3847 { | |
3848 | |
3849 for (QDomNode n = node.firstChild(); !n.isNull(); n = n.nextSibling()) { | |
3850 if (!n.isElement()) | |
3851 continue; | |
3852 QDomElement e = n.toElement(); | |
3853 QString tag = e.tagName().toLower(); | |
3854 if (tag == QLatin1String("active")) { | |
3855 DomColorGroup *v = new DomColorGroup(); | |
3856 v->read(e); | |
3857 setElementActive(v); | |
3858 continue; | |
3859 } | |
3860 if (tag == QLatin1String("inactive")) { | |
3861 DomColorGroup *v = new DomColorGroup(); | |
3862 v->read(e); | |
3863 setElementInactive(v); | |
3864 continue; | |
3865 } | |
3866 if (tag == QLatin1String("disabled")) { | |
3867 DomColorGroup *v = new DomColorGroup(); | |
3868 v->read(e); | |
3869 setElementDisabled(v); | |
3870 continue; | |
3871 } | |
3872 } | |
3873 | |
3874 m_text.clear(); | |
3875 for (QDomNode child = node.firstChild(); !child.isNull(); child = child.nextSibling()) { | |
3876 if (child.isText()) | |
3877 m_text.append(child.nodeValue()); | |
3878 } | |
3879 } | |
3880 | |
3881 QDomElement DomPalette::write(QDomDocument &doc, const QString &tagName) const | |
3882 { | |
3883 QDomElement e = doc.createElement(tagName.isEmpty() ? QString::fromUtf8("palette") : tagName.toLower()); | |
3884 | |
3885 QDomElement child; | |
3886 | |
3887 if (m_children & Active) { | |
3888 e.appendChild(m_active->write(doc, QLatin1String("active"))); | |
3889 } | |
3890 | |
3891 if (m_children & Inactive) { | |
3892 e.appendChild(m_inactive->write(doc, QLatin1String("inactive"))); | |
3893 } | |
3894 | |
3895 if (m_children & Disabled) { | |
3896 e.appendChild(m_disabled->write(doc, QLatin1String("disabled"))); | |
3897 } | |
3898 | |
3899 if (!m_text.isEmpty()) | |
3900 e.appendChild(doc.createTextNode(m_text)); | |
3901 | |
3902 return e; | |
3903 } | |
3904 | |
3905 void DomPalette::setElementActive(DomColorGroup* a) | |
3906 { | |
3907 delete m_active; | |
3908 m_children |= Active; | |
3909 m_active = a; | |
3910 } | |
3911 | |
3912 void DomPalette::setElementInactive(DomColorGroup* a) | |
3913 { | |
3914 delete m_inactive; | |
3915 m_children |= Inactive; | |
3916 m_inactive = a; | |
3917 } | |
3918 | |
3919 void DomPalette::setElementDisabled(DomColorGroup* a) | |
3920 { | |
3921 delete m_disabled; | |
3922 m_children |= Disabled; | |
3923 m_disabled = a; | |
3924 } | |
3925 | |
3926 void DomPalette::clearElementActive() | |
3927 { | |
3928 delete m_active; | |
3929 m_active = 0; | |
3930 m_children &= ~Active; | |
3931 } | |
3932 | |
3933 void DomPalette::clearElementInactive() | |
3934 { | |
3935 delete m_inactive; | |
3936 m_inactive = 0; | |
3937 m_children &= ~Inactive; | |
3938 } | |
3939 | |
3940 void DomPalette::clearElementDisabled() | |
3941 { | |
3942 delete m_disabled; | |
3943 m_disabled = 0; | |
3944 m_children &= ~Disabled; | |
3945 } | |
3946 | |
3947 void DomFont::clear(bool clear_all) | |
3948 { | |
3949 | |
3950 if (clear_all) { | |
3951 m_text = QString(); | |
3952 } | |
3953 | |
3954 m_children = 0; | |
3955 m_pointSize = 0; | |
3956 m_weight = 0; | |
3957 m_italic = false; | |
3958 m_bold = false; | |
3959 m_underline = false; | |
3960 m_strikeOut = false; | |
3961 m_antialiasing = false; | |
3962 m_kerning = false; | |
3963 } | |
3964 | |
3965 DomFont::DomFont() | |
3966 { | |
3967 m_children = 0; | |
3968 m_pointSize = 0; | |
3969 m_weight = 0; | |
3970 m_italic = false; | |
3971 m_bold = false; | |
3972 m_underline = false; | |
3973 m_strikeOut = false; | |
3974 m_antialiasing = false; | |
3975 m_kerning = false; | |
3976 } | |
3977 | |
3978 DomFont::~DomFont() | |
3979 { | |
3980 } | |
3981 | |
3982 void DomFont::read(const QDomElement &node) | |
3983 { | |
3984 | |
3985 for (QDomNode n = node.firstChild(); !n.isNull(); n = n.nextSibling()) { | |
3986 if (!n.isElement()) | |
3987 continue; | |
3988 QDomElement e = n.toElement(); | |
3989 QString tag = e.tagName().toLower(); | |
3990 if (tag == QLatin1String("family")) { | |
3991 setElementFamily(e.text()); | |
3992 continue; | |
3993 } | |
3994 if (tag == QLatin1String("pointsize")) { | |
3995 setElementPointSize(e.text().toInt()); | |
3996 continue; | |
3997 } | |
3998 if (tag == QLatin1String("weight")) { | |
3999 setElementWeight(e.text().toInt()); | |
4000 continue; | |
4001 } | |
4002 if (tag == QLatin1String("italic")) { | |
4003 setElementItalic((e.text() == QLatin1String("true") ? true : false)); | |
4004 continue; | |
4005 } | |
4006 if (tag == QLatin1String("bold")) { | |
4007 setElementBold((e.text() == QLatin1String("true") ? true : false)); | |
4008 continue; | |
4009 } | |
4010 if (tag == QLatin1String("underline")) { | |
4011 setElementUnderline((e.text() == QLatin1String("true") ? true : false)); | |
4012 continue; | |
4013 } | |
4014 if (tag == QLatin1String("strikeout")) { | |
4015 setElementStrikeOut((e.text() == QLatin1String("true") ? true : false)); | |
4016 continue; | |
4017 } | |
4018 if (tag == QLatin1String("antialiasing")) { | |
4019 setElementAntialiasing((e.text() == QLatin1String("true") ? true : false)); | |
4020 continue; | |
4021 } | |
4022 if (tag == QLatin1String("stylestrategy")) { | |
4023 setElementStyleStrategy(e.text()); | |
4024 continue; | |
4025 } | |
4026 if (tag == QLatin1String("kerning")) { | |
4027 setElementKerning((e.text() == QLatin1String("true") ? true : false)); | |
4028 continue; | |
4029 } | |
4030 } | |
4031 | |
4032 m_text.clear(); | |
4033 for (QDomNode child = node.firstChild(); !child.isNull(); child = child.nextSibling()) { | |
4034 if (child.isText()) | |
4035 m_text.append(child.nodeValue()); | |
4036 } | |
4037 } | |
4038 | |
4039 QDomElement DomFont::write(QDomDocument &doc, const QString &tagName) const | |
4040 { | |
4041 QDomElement e = doc.createElement(tagName.isEmpty() ? QString::fromUtf8("font") : tagName.toLower()); | |
4042 | |
4043 QDomElement child; | |
4044 | |
4045 if (m_children & Family) { | |
4046 child = doc.createElement(QLatin1String("family")); | |
4047 child.appendChild(doc.createTextNode(m_family)); | |
4048 e.appendChild(child); | |
4049 } | |
4050 | |
4051 if (m_children & PointSize) { | |
4052 child = doc.createElement(QLatin1String("pointsize")); | |
4053 child.appendChild(doc.createTextNode(QString::number(m_pointSize))); | |
4054 e.appendChild(child); | |
4055 } | |
4056 | |
4057 if (m_children & Weight) { | |
4058 child = doc.createElement(QLatin1String("weight")); | |
4059 child.appendChild(doc.createTextNode(QString::number(m_weight))); | |
4060 e.appendChild(child); | |
4061 } | |
4062 | |
4063 if (m_children & Italic) { | |
4064 child = doc.createElement(QLatin1String("italic")); | |
4065 child.appendChild(doc.createTextNode((m_italic ? QLatin1String("true") : QLatin1String("false")))); | |
4066 e.appendChild(child); | |
4067 } | |
4068 | |
4069 if (m_children & Bold) { | |
4070 child = doc.createElement(QLatin1String("bold")); | |
4071 child.appendChild(doc.createTextNode((m_bold ? QLatin1String("true") : QLatin1String("false")))); | |
4072 e.appendChild(child); | |
4073 } | |
4074 | |
4075 if (m_children & Underline) { | |
4076 child = doc.createElement(QLatin1String("underline")); | |
4077 child.appendChild(doc.createTextNode((m_underline ? QLatin1String("true") : QLatin1String("false")))); | |
4078 e.appendChild(child); | |
4079 } | |
4080 | |
4081 if (m_children & StrikeOut) { | |
4082 child = doc.createElement(QLatin1String("strikeout")); | |
4083 child.appendChild(doc.createTextNode((m_strikeOut ? QLatin1String("true") : QLatin1String("false")))); | |
4084 e.appendChild(child); | |
4085 } | |
4086 | |
4087 if (m_children & Antialiasing) { | |
4088 child = doc.createElement(QLatin1String("antialiasing")); | |
4089 child.appendChild(doc.createTextNode((m_antialiasing ? QLatin1String("true") : QLatin1String("false")))); | |
4090 e.appendChild(child); | |
4091 } | |
4092 | |
4093 if (m_children & StyleStrategy) { | |
4094 child = doc.createElement(QLatin1String("stylestrategy")); | |
4095 child.appendChild(doc.createTextNode(m_styleStrategy)); | |
4096 e.appendChild(child); | |
4097 } | |
4098 | |
4099 if (m_children & Kerning) { | |
4100 child = doc.createElement(QLatin1String("kerning")); | |
4101 child.appendChild(doc.createTextNode((m_kerning ? QLatin1String("true") : QLatin1String("false")))); | |
4102 e.appendChild(child); | |
4103 } | |
4104 | |
4105 if (!m_text.isEmpty()) | |
4106 e.appendChild(doc.createTextNode(m_text)); | |
4107 | |
4108 return e; | |
4109 } | |
4110 | |
4111 void DomFont::setElementFamily(const QString& a) | |
4112 { | |
4113 m_children |= Family; | |
4114 m_family = a; | |
4115 } | |
4116 | |
4117 void DomFont::setElementPointSize(int a) | |
4118 { | |
4119 m_children |= PointSize; | |
4120 m_pointSize = a; | |
4121 } | |
4122 | |
4123 void DomFont::setElementWeight(int a) | |
4124 { | |
4125 m_children |= Weight; | |
4126 m_weight = a; | |
4127 } | |
4128 | |
4129 void DomFont::setElementItalic(bool a) | |
4130 { | |
4131 m_children |= Italic; | |
4132 m_italic = a; | |
4133 } | |
4134 | |
4135 void DomFont::setElementBold(bool a) | |
4136 { | |
4137 m_children |= Bold; | |
4138 m_bold = a; | |
4139 } | |
4140 | |
4141 void DomFont::setElementUnderline(bool a) | |
4142 { | |
4143 m_children |= Underline; | |
4144 m_underline = a; | |
4145 } | |
4146 | |
4147 void DomFont::setElementStrikeOut(bool a) | |
4148 { | |
4149 m_children |= StrikeOut; | |
4150 m_strikeOut = a; | |
4151 } | |
4152 | |
4153 void DomFont::setElementAntialiasing(bool a) | |
4154 { | |
4155 m_children |= Antialiasing; | |
4156 m_antialiasing = a; | |
4157 } | |
4158 | |
4159 void DomFont::setElementStyleStrategy(const QString& a) | |
4160 { | |
4161 m_children |= StyleStrategy; | |
4162 m_styleStrategy = a; | |
4163 } | |
4164 | |
4165 void DomFont::setElementKerning(bool a) | |
4166 { | |
4167 m_children |= Kerning; | |
4168 m_kerning = a; | |
4169 } | |
4170 | |
4171 void DomFont::clearElementFamily() | |
4172 { | |
4173 m_children &= ~Family; | |
4174 } | |
4175 | |
4176 void DomFont::clearElementPointSize() | |
4177 { | |
4178 m_children &= ~PointSize; | |
4179 } | |
4180 | |
4181 void DomFont::clearElementWeight() | |
4182 { | |
4183 m_children &= ~Weight; | |
4184 } | |
4185 | |
4186 void DomFont::clearElementItalic() | |
4187 { | |
4188 m_children &= ~Italic; | |
4189 } | |
4190 | |
4191 void DomFont::clearElementBold() | |
4192 { | |
4193 m_children &= ~Bold; | |
4194 } | |
4195 | |
4196 void DomFont::clearElementUnderline() | |
4197 { | |
4198 m_children &= ~Underline; | |
4199 } | |
4200 | |
4201 void DomFont::clearElementStrikeOut() | |
4202 { | |
4203 m_children &= ~StrikeOut; | |
4204 } | |
4205 | |
4206 void DomFont::clearElementAntialiasing() | |
4207 { | |
4208 m_children &= ~Antialiasing; | |
4209 } | |
4210 | |
4211 void DomFont::clearElementStyleStrategy() | |
4212 { | |
4213 m_children &= ~StyleStrategy; | |
4214 } | |
4215 | |
4216 void DomFont::clearElementKerning() | |
4217 { | |
4218 m_children &= ~Kerning; | |
4219 } | |
4220 | |
4221 void DomPoint::clear(bool clear_all) | |
4222 { | |
4223 | |
4224 if (clear_all) { | |
4225 m_text = QString(); | |
4226 } | |
4227 | |
4228 m_children = 0; | |
4229 m_x = 0; | |
4230 m_y = 0; | |
4231 } | |
4232 | |
4233 DomPoint::DomPoint() | |
4234 { | |
4235 m_children = 0; | |
4236 m_x = 0; | |
4237 m_y = 0; | |
4238 } | |
4239 | |
4240 DomPoint::~DomPoint() | |
4241 { | |
4242 } | |
4243 | |
4244 void DomPoint::read(const QDomElement &node) | |
4245 { | |
4246 | |
4247 for (QDomNode n = node.firstChild(); !n.isNull(); n = n.nextSibling()) { | |
4248 if (!n.isElement()) | |
4249 continue; | |
4250 QDomElement e = n.toElement(); | |
4251 QString tag = e.tagName().toLower(); | |
4252 if (tag == QString(QLatin1Char('x'))) { | |
4253 setElementX(e.text().toInt()); | |
4254 continue; | |
4255 } | |
4256 if (tag == QString(QLatin1Char('y'))) { | |
4257 setElementY(e.text().toInt()); | |
4258 continue; | |
4259 } | |
4260 } | |
4261 | |
4262 m_text.clear(); | |
4263 for (QDomNode child = node.firstChild(); !child.isNull(); child = child.nextSibling()) { | |
4264 if (child.isText()) | |
4265 m_text.append(child.nodeValue()); | |
4266 } | |
4267 } | |
4268 | |
4269 QDomElement DomPoint::write(QDomDocument &doc, const QString &tagName) const | |
4270 { | |
4271 QDomElement e = doc.createElement(tagName.isEmpty() ? QString::fromUtf8("point") : tagName.toLower()); | |
4272 | |
4273 QDomElement child; | |
4274 | |
4275 if (m_children & X) { | |
4276 child = doc.createElement(QString(QLatin1Char('x'))); | |
4277 child.appendChild(doc.createTextNode(QString::number(m_x))); | |
4278 e.appendChild(child); | |
4279 } | |
4280 | |
4281 if (m_children & Y) { | |
4282 child = doc.createElement(QString(QLatin1Char('y'))); | |
4283 child.appendChild(doc.createTextNode(QString::number(m_y))); | |
4284 e.appendChild(child); | |
4285 } | |
4286 | |
4287 if (!m_text.isEmpty()) | |
4288 e.appendChild(doc.createTextNode(m_text)); | |
4289 | |
4290 return e; | |
4291 } | |
4292 | |
4293 void DomPoint::setElementX(int a) | |
4294 { | |
4295 m_children |= X; | |
4296 m_x = a; | |
4297 } | |
4298 | |
4299 void DomPoint::setElementY(int a) | |
4300 { | |
4301 m_children |= Y; | |
4302 m_y = a; | |
4303 } | |
4304 | |
4305 void DomPoint::clearElementX() | |
4306 { | |
4307 m_children &= ~X; | |
4308 } | |
4309 | |
4310 void DomPoint::clearElementY() | |
4311 { | |
4312 m_children &= ~Y; | |
4313 } | |
4314 | |
4315 void DomRect::clear(bool clear_all) | |
4316 { | |
4317 | |
4318 if (clear_all) { | |
4319 m_text = QString(); | |
4320 } | |
4321 | |
4322 m_children = 0; | |
4323 m_x = 0; | |
4324 m_y = 0; | |
4325 m_width = 0; | |
4326 m_height = 0; | |
4327 } | |
4328 | |
4329 DomRect::DomRect() | |
4330 { | |
4331 m_children = 0; | |
4332 m_x = 0; | |
4333 m_y = 0; | |
4334 m_width = 0; | |
4335 m_height = 0; | |
4336 } | |
4337 | |
4338 DomRect::~DomRect() | |
4339 { | |
4340 } | |
4341 | |
4342 void DomRect::read(const QDomElement &node) | |
4343 { | |
4344 | |
4345 for (QDomNode n = node.firstChild(); !n.isNull(); n = n.nextSibling()) { | |
4346 if (!n.isElement()) | |
4347 continue; | |
4348 QDomElement e = n.toElement(); | |
4349 QString tag = e.tagName().toLower(); | |
4350 if (tag == QString(QLatin1Char('x'))) { | |
4351 setElementX(e.text().toInt()); | |
4352 continue; | |
4353 } | |
4354 if (tag == QString(QLatin1Char('y'))) { | |
4355 setElementY(e.text().toInt()); | |
4356 continue; | |
4357 } | |
4358 if (tag == QLatin1String("width")) { | |
4359 setElementWidth(e.text().toInt()); | |
4360 continue; | |
4361 } | |
4362 if (tag == QLatin1String("height")) { | |
4363 setElementHeight(e.text().toInt()); | |
4364 continue; | |
4365 } | |
4366 } | |
4367 | |
4368 m_text.clear(); | |
4369 for (QDomNode child = node.firstChild(); !child.isNull(); child = child.nextSibling()) { | |
4370 if (child.isText()) | |
4371 m_text.append(child.nodeValue()); | |
4372 } | |
4373 } | |
4374 | |
4375 QDomElement DomRect::write(QDomDocument &doc, const QString &tagName) const | |
4376 { | |
4377 QDomElement e = doc.createElement(tagName.isEmpty() ? QString::fromUtf8("rect") : tagName.toLower()); | |
4378 | |
4379 QDomElement child; | |
4380 | |
4381 if (m_children & X) { | |
4382 child = doc.createElement(QString(QLatin1Char('x'))); | |
4383 child.appendChild(doc.createTextNode(QString::number(m_x))); | |
4384 e.appendChild(child); | |
4385 } | |
4386 | |
4387 if (m_children & Y) { | |
4388 child = doc.createElement(QString(QLatin1Char('y'))); | |
4389 child.appendChild(doc.createTextNode(QString::number(m_y))); | |
4390 e.appendChild(child); | |
4391 } | |
4392 | |
4393 if (m_children & Width) { | |
4394 child = doc.createElement(QLatin1String("width")); | |
4395 child.appendChild(doc.createTextNode(QString::number(m_width))); | |
4396 e.appendChild(child); | |
4397 } | |
4398 | |
4399 if (m_children & Height) { | |
4400 child = doc.createElement(QLatin1String("height")); | |
4401 child.appendChild(doc.createTextNode(QString::number(m_height))); | |
4402 e.appendChild(child); | |
4403 } | |
4404 | |
4405 if (!m_text.isEmpty()) | |
4406 e.appendChild(doc.createTextNode(m_text)); | |
4407 | |
4408 return e; | |
4409 } | |
4410 | |
4411 void DomRect::setElementX(int a) | |
4412 { | |
4413 m_children |= X; | |
4414 m_x = a; | |
4415 } | |
4416 | |
4417 void DomRect::setElementY(int a) | |
4418 { | |
4419 m_children |= Y; | |
4420 m_y = a; | |
4421 } | |
4422 | |
4423 void DomRect::setElementWidth(int a) | |
4424 { | |
4425 m_children |= Width; | |
4426 m_width = a; | |
4427 } | |
4428 | |
4429 void DomRect::setElementHeight(int a) | |
4430 { | |
4431 m_children |= Height; | |
4432 m_height = a; | |
4433 } | |
4434 | |
4435 void DomRect::clearElementX() | |
4436 { | |
4437 m_children &= ~X; | |
4438 } | |
4439 | |
4440 void DomRect::clearElementY() | |
4441 { | |
4442 m_children &= ~Y; | |
4443 } | |
4444 | |
4445 void DomRect::clearElementWidth() | |
4446 { | |
4447 m_children &= ~Width; | |
4448 } | |
4449 | |
4450 void DomRect::clearElementHeight() | |
4451 { | |
4452 m_children &= ~Height; | |
4453 } | |
4454 | |
4455 void DomLocale::clear(bool clear_all) | |
4456 { | |
4457 | |
4458 if (clear_all) { | |
4459 m_text = QString(); | |
4460 m_has_attr_language = false; | |
4461 m_has_attr_country = false; | |
4462 } | |
4463 | |
4464 } | |
4465 | |
4466 DomLocale::DomLocale() | |
4467 { | |
4468 m_has_attr_language = false; | |
4469 m_has_attr_country = false; | |
4470 } | |
4471 | |
4472 DomLocale::~DomLocale() | |
4473 { | |
4474 } | |
4475 | |
4476 void DomLocale::read(const QDomElement &node) | |
4477 { | |
4478 if (node.hasAttribute(QLatin1String("language"))) | |
4479 setAttributeLanguage(node.attribute(QLatin1String("language"))); | |
4480 if (node.hasAttribute(QLatin1String("country"))) | |
4481 setAttributeCountry(node.attribute(QLatin1String("country"))); | |
4482 | |
4483 m_text.clear(); | |
4484 for (QDomNode child = node.firstChild(); !child.isNull(); child = child.nextSibling()) { | |
4485 if (child.isText()) | |
4486 m_text.append(child.nodeValue()); | |
4487 } | |
4488 } | |
4489 | |
4490 QDomElement DomLocale::write(QDomDocument &doc, const QString &tagName) const | |
4491 { | |
4492 QDomElement e = doc.createElement(tagName.isEmpty() ? QString::fromUtf8("locale") : tagName.toLower()); | |
4493 | |
4494 QDomElement child; | |
4495 | |
4496 if (hasAttributeLanguage()) | |
4497 e.setAttribute(QLatin1String("language"), attributeLanguage()); | |
4498 | |
4499 if (hasAttributeCountry()) | |
4500 e.setAttribute(QLatin1String("country"), attributeCountry()); | |
4501 | |
4502 if (!m_text.isEmpty()) | |
4503 e.appendChild(doc.createTextNode(m_text)); | |
4504 | |
4505 return e; | |
4506 } | |
4507 | |
4508 void DomSizePolicy::clear(bool clear_all) | |
4509 { | |
4510 | |
4511 if (clear_all) { | |
4512 m_text = QString(); | |
4513 m_has_attr_hSizeType = false; | |
4514 m_has_attr_vSizeType = false; | |
4515 } | |
4516 | |
4517 m_children = 0; | |
4518 m_hSizeType = 0; | |
4519 m_vSizeType = 0; | |
4520 m_horStretch = 0; | |
4521 m_verStretch = 0; | |
4522 } | |
4523 | |
4524 DomSizePolicy::DomSizePolicy() | |
4525 { | |
4526 m_children = 0; | |
4527 m_has_attr_hSizeType = false; | |
4528 m_has_attr_vSizeType = false; | |
4529 m_hSizeType = 0; | |
4530 m_vSizeType = 0; | |
4531 m_horStretch = 0; | |
4532 m_verStretch = 0; | |
4533 } | |
4534 | |
4535 DomSizePolicy::~DomSizePolicy() | |
4536 { | |
4537 } | |
4538 | |
4539 void DomSizePolicy::read(const QDomElement &node) | |
4540 { | |
4541 if (node.hasAttribute(QLatin1String("hsizetype"))) | |
4542 setAttributeHSizeType(node.attribute(QLatin1String("hsizetype"))); | |
4543 if (node.hasAttribute(QLatin1String("vsizetype"))) | |
4544 setAttributeVSizeType(node.attribute(QLatin1String("vsizetype"))); | |
4545 | |
4546 for (QDomNode n = node.firstChild(); !n.isNull(); n = n.nextSibling()) { | |
4547 if (!n.isElement()) | |
4548 continue; | |
4549 QDomElement e = n.toElement(); | |
4550 QString tag = e.tagName().toLower(); | |
4551 if (tag == QLatin1String("hsizetype")) { | |
4552 setElementHSizeType(e.text().toInt()); | |
4553 continue; | |
4554 } | |
4555 if (tag == QLatin1String("vsizetype")) { | |
4556 setElementVSizeType(e.text().toInt()); | |
4557 continue; | |
4558 } | |
4559 if (tag == QLatin1String("horstretch")) { | |
4560 setElementHorStretch(e.text().toInt()); | |
4561 continue; | |
4562 } | |
4563 if (tag == QLatin1String("verstretch")) { | |
4564 setElementVerStretch(e.text().toInt()); | |
4565 continue; | |
4566 } | |
4567 } | |
4568 | |
4569 m_text.clear(); | |
4570 for (QDomNode child = node.firstChild(); !child.isNull(); child = child.nextSibling()) { | |
4571 if (child.isText()) | |
4572 m_text.append(child.nodeValue()); | |
4573 } | |
4574 } | |
4575 | |
4576 QDomElement DomSizePolicy::write(QDomDocument &doc, const QString &tagName) const | |
4577 { | |
4578 QDomElement e = doc.createElement(tagName.isEmpty() ? QString::fromUtf8("sizepolicy") : tagName.toLower()); | |
4579 | |
4580 QDomElement child; | |
4581 | |
4582 if (hasAttributeHSizeType()) | |
4583 e.setAttribute(QLatin1String("hsizetype"), attributeHSizeType()); | |
4584 | |
4585 if (hasAttributeVSizeType()) | |
4586 e.setAttribute(QLatin1String("vsizetype"), attributeVSizeType()); | |
4587 | |
4588 if (m_children & HSizeType) { | |
4589 child = doc.createElement(QLatin1String("hsizetype")); | |
4590 child.appendChild(doc.createTextNode(QString::number(m_hSizeType))); | |
4591 e.appendChild(child); | |
4592 } | |
4593 | |
4594 if (m_children & VSizeType) { | |
4595 child = doc.createElement(QLatin1String("vsizetype")); | |
4596 child.appendChild(doc.createTextNode(QString::number(m_vSizeType))); | |
4597 e.appendChild(child); | |
4598 } | |
4599 | |
4600 if (m_children & HorStretch) { | |
4601 child = doc.createElement(QLatin1String("horstretch")); | |
4602 child.appendChild(doc.createTextNode(QString::number(m_horStretch))); | |
4603 e.appendChild(child); | |
4604 } | |
4605 | |
4606 if (m_children & VerStretch) { | |
4607 child = doc.createElement(QLatin1String("verstretch")); | |
4608 child.appendChild(doc.createTextNode(QString::number(m_verStretch))); | |
4609 e.appendChild(child); | |
4610 } | |
4611 | |
4612 if (!m_text.isEmpty()) | |
4613 e.appendChild(doc.createTextNode(m_text)); | |
4614 | |
4615 return e; | |
4616 } | |
4617 | |
4618 void DomSizePolicy::setElementHSizeType(int a) | |
4619 { | |
4620 m_children |= HSizeType; | |
4621 m_hSizeType = a; | |
4622 } | |
4623 | |
4624 void DomSizePolicy::setElementVSizeType(int a) | |
4625 { | |
4626 m_children |= VSizeType; | |
4627 m_vSizeType = a; | |
4628 } | |
4629 | |
4630 void DomSizePolicy::setElementHorStretch(int a) | |
4631 { | |
4632 m_children |= HorStretch; | |
4633 m_horStretch = a; | |
4634 } | |
4635 | |
4636 void DomSizePolicy::setElementVerStretch(int a) | |
4637 { | |
4638 m_children |= VerStretch; | |
4639 m_verStretch = a; | |
4640 } | |
4641 | |
4642 void DomSizePolicy::clearElementHSizeType() | |
4643 { | |
4644 m_children &= ~HSizeType; | |
4645 } | |
4646 | |
4647 void DomSizePolicy::clearElementVSizeType() | |
4648 { | |
4649 m_children &= ~VSizeType; | |
4650 } | |
4651 | |
4652 void DomSizePolicy::clearElementHorStretch() | |
4653 { | |
4654 m_children &= ~HorStretch; | |
4655 } | |
4656 | |
4657 void DomSizePolicy::clearElementVerStretch() | |
4658 { | |
4659 m_children &= ~VerStretch; | |
4660 } | |
4661 | |
4662 void DomSize::clear(bool clear_all) | |
4663 { | |
4664 | |
4665 if (clear_all) { | |
4666 m_text = QString(); | |
4667 } | |
4668 | |
4669 m_children = 0; | |
4670 m_width = 0; | |
4671 m_height = 0; | |
4672 } | |
4673 | |
4674 DomSize::DomSize() | |
4675 { | |
4676 m_children = 0; | |
4677 m_width = 0; | |
4678 m_height = 0; | |
4679 } | |
4680 | |
4681 DomSize::~DomSize() | |
4682 { | |
4683 } | |
4684 | |
4685 void DomSize::read(const QDomElement &node) | |
4686 { | |
4687 | |
4688 for (QDomNode n = node.firstChild(); !n.isNull(); n = n.nextSibling()) { | |
4689 if (!n.isElement()) | |
4690 continue; | |
4691 QDomElement e = n.toElement(); | |
4692 QString tag = e.tagName().toLower(); | |
4693 if (tag == QLatin1String("width")) { | |
4694 setElementWidth(e.text().toInt()); | |
4695 continue; | |
4696 } | |
4697 if (tag == QLatin1String("height")) { | |
4698 setElementHeight(e.text().toInt()); | |
4699 continue; | |
4700 } | |
4701 } | |
4702 | |
4703 m_text.clear(); | |
4704 for (QDomNode child = node.firstChild(); !child.isNull(); child = child.nextSibling()) { | |
4705 if (child.isText()) | |
4706 m_text.append(child.nodeValue()); | |
4707 } | |
4708 } | |
4709 | |
4710 QDomElement DomSize::write(QDomDocument &doc, const QString &tagName) const | |
4711 { | |
4712 QDomElement e = doc.createElement(tagName.isEmpty() ? QString::fromUtf8("size") : tagName.toLower()); | |
4713 | |
4714 QDomElement child; | |
4715 | |
4716 if (m_children & Width) { | |
4717 child = doc.createElement(QLatin1String("width")); | |
4718 child.appendChild(doc.createTextNode(QString::number(m_width))); | |
4719 e.appendChild(child); | |
4720 } | |
4721 | |
4722 if (m_children & Height) { | |
4723 child = doc.createElement(QLatin1String("height")); | |
4724 child.appendChild(doc.createTextNode(QString::number(m_height))); | |
4725 e.appendChild(child); | |
4726 } | |
4727 | |
4728 if (!m_text.isEmpty()) | |
4729 e.appendChild(doc.createTextNode(m_text)); | |
4730 | |
4731 return e; | |
4732 } | |
4733 | |
4734 void DomSize::setElementWidth(int a) | |
4735 { | |
4736 m_children |= Width; | |
4737 m_width = a; | |
4738 } | |
4739 | |
4740 void DomSize::setElementHeight(int a) | |
4741 { | |
4742 m_children |= Height; | |
4743 m_height = a; | |
4744 } | |
4745 | |
4746 void DomSize::clearElementWidth() | |
4747 { | |
4748 m_children &= ~Width; | |
4749 } | |
4750 | |
4751 void DomSize::clearElementHeight() | |
4752 { | |
4753 m_children &= ~Height; | |
4754 } | |
4755 | |
4756 void DomDate::clear(bool clear_all) | |
4757 { | |
4758 | |
4759 if (clear_all) { | |
4760 m_text = QString(); | |
4761 } | |
4762 | |
4763 m_children = 0; | |
4764 m_year = 0; | |
4765 m_month = 0; | |
4766 m_day = 0; | |
4767 } | |
4768 | |
4769 DomDate::DomDate() | |
4770 { | |
4771 m_children = 0; | |
4772 m_year = 0; | |
4773 m_month = 0; | |
4774 m_day = 0; | |
4775 } | |
4776 | |
4777 DomDate::~DomDate() | |
4778 { | |
4779 } | |
4780 | |
4781 void DomDate::read(const QDomElement &node) | |
4782 { | |
4783 | |
4784 for (QDomNode n = node.firstChild(); !n.isNull(); n = n.nextSibling()) { | |
4785 if (!n.isElement()) | |
4786 continue; | |
4787 QDomElement e = n.toElement(); | |
4788 QString tag = e.tagName().toLower(); | |
4789 if (tag == QLatin1String("year")) { | |
4790 setElementYear(e.text().toInt()); | |
4791 continue; | |
4792 } | |
4793 if (tag == QLatin1String("month")) { | |
4794 setElementMonth(e.text().toInt()); | |
4795 continue; | |
4796 } | |
4797 if (tag == QLatin1String("day")) { | |
4798 setElementDay(e.text().toInt()); | |
4799 continue; | |
4800 } | |
4801 } | |
4802 | |
4803 m_text.clear(); | |
4804 for (QDomNode child = node.firstChild(); !child.isNull(); child = child.nextSibling()) { | |
4805 if (child.isText()) | |
4806 m_text.append(child.nodeValue()); | |
4807 } | |
4808 } | |
4809 | |
4810 QDomElement DomDate::write(QDomDocument &doc, const QString &tagName) const | |
4811 { | |
4812 QDomElement e = doc.createElement(tagName.isEmpty() ? QString::fromUtf8("date") : tagName.toLower()); | |
4813 | |
4814 QDomElement child; | |
4815 | |
4816 if (m_children & Year) { | |
4817 child = doc.createElement(QLatin1String("year")); | |
4818 child.appendChild(doc.createTextNode(QString::number(m_year))); | |
4819 e.appendChild(child); | |
4820 } | |
4821 | |
4822 if (m_children & Month) { | |
4823 child = doc.createElement(QLatin1String("month")); | |
4824 child.appendChild(doc.createTextNode(QString::number(m_month))); | |
4825 e.appendChild(child); | |
4826 } | |
4827 | |
4828 if (m_children & Day) { | |
4829 child = doc.createElement(QLatin1String("day")); | |
4830 child.appendChild(doc.createTextNode(QString::number(m_day))); | |
4831 e.appendChild(child); | |
4832 } | |
4833 | |
4834 if (!m_text.isEmpty()) | |
4835 e.appendChild(doc.createTextNode(m_text)); | |
4836 | |
4837 return e; | |
4838 } | |
4839 | |
4840 void DomDate::setElementYear(int a) | |
4841 { | |
4842 m_children |= Year; | |
4843 m_year = a; | |
4844 } | |
4845 | |
4846 void DomDate::setElementMonth(int a) | |
4847 { | |
4848 m_children |= Month; | |
4849 m_month = a; | |
4850 } | |
4851 | |
4852 void DomDate::setElementDay(int a) | |
4853 { | |
4854 m_children |= Day; | |
4855 m_day = a; | |
4856 } | |
4857 | |
4858 void DomDate::clearElementYear() | |
4859 { | |
4860 m_children &= ~Year; | |
4861 } | |
4862 | |
4863 void DomDate::clearElementMonth() | |
4864 { | |
4865 m_children &= ~Month; | |
4866 } | |
4867 | |
4868 void DomDate::clearElementDay() | |
4869 { | |
4870 m_children &= ~Day; | |
4871 } | |
4872 | |
4873 void DomTime::clear(bool clear_all) | |
4874 { | |
4875 | |
4876 if (clear_all) { | |
4877 m_text = QString(); | |
4878 } | |
4879 | |
4880 m_children = 0; | |
4881 m_hour = 0; | |
4882 m_minute = 0; | |
4883 m_second = 0; | |
4884 } | |
4885 | |
4886 DomTime::DomTime() | |
4887 { | |
4888 m_children = 0; | |
4889 m_hour = 0; | |
4890 m_minute = 0; | |
4891 m_second = 0; | |
4892 } | |
4893 | |
4894 DomTime::~DomTime() | |
4895 { | |
4896 } | |
4897 | |
4898 void DomTime::read(const QDomElement &node) | |
4899 { | |
4900 | |
4901 for (QDomNode n = node.firstChild(); !n.isNull(); n = n.nextSibling()) { | |
4902 if (!n.isElement()) | |
4903 continue; | |
4904 QDomElement e = n.toElement(); | |
4905 QString tag = e.tagName().toLower(); | |
4906 if (tag == QLatin1String("hour")) { | |
4907 setElementHour(e.text().toInt()); | |
4908 continue; | |
4909 } | |
4910 if (tag == QLatin1String("minute")) { | |
4911 setElementMinute(e.text().toInt()); | |
4912 continue; | |
4913 } | |
4914 if (tag == QLatin1String("second")) { | |
4915 setElementSecond(e.text().toInt()); | |
4916 continue; | |
4917 } | |
4918 } | |
4919 | |
4920 m_text.clear(); | |
4921 for (QDomNode child = node.firstChild(); !child.isNull(); child = child.nextSibling()) { | |
4922 if (child.isText()) | |
4923 m_text.append(child.nodeValue()); | |
4924 } | |
4925 } | |
4926 | |
4927 QDomElement DomTime::write(QDomDocument &doc, const QString &tagName) const | |
4928 { | |
4929 QDomElement e = doc.createElement(tagName.isEmpty() ? QString::fromUtf8("time") : tagName.toLower()); | |
4930 | |
4931 QDomElement child; | |
4932 | |
4933 if (m_children & Hour) { | |
4934 child = doc.createElement(QLatin1String("hour")); | |
4935 child.appendChild(doc.createTextNode(QString::number(m_hour))); | |
4936 e.appendChild(child); | |
4937 } | |
4938 | |
4939 if (m_children & Minute) { | |
4940 child = doc.createElement(QLatin1String("minute")); | |
4941 child.appendChild(doc.createTextNode(QString::number(m_minute))); | |
4942 e.appendChild(child); | |
4943 } | |
4944 | |
4945 if (m_children & Second) { | |
4946 child = doc.createElement(QLatin1String("second")); | |
4947 child.appendChild(doc.createTextNode(QString::number(m_second))); | |
4948 e.appendChild(child); | |
4949 } | |
4950 | |
4951 if (!m_text.isEmpty()) | |
4952 e.appendChild(doc.createTextNode(m_text)); | |
4953 | |
4954 return e; | |
4955 } | |
4956 | |
4957 void DomTime::setElementHour(int a) | |
4958 { | |
4959 m_children |= Hour; | |
4960 m_hour = a; | |
4961 } | |
4962 | |
4963 void DomTime::setElementMinute(int a) | |
4964 { | |
4965 m_children |= Minute; | |
4966 m_minute = a; | |
4967 } | |
4968 | |
4969 void DomTime::setElementSecond(int a) | |
4970 { | |
4971 m_children |= Second; | |
4972 m_second = a; | |
4973 } | |
4974 | |
4975 void DomTime::clearElementHour() | |
4976 { | |
4977 m_children &= ~Hour; | |
4978 } | |
4979 | |
4980 void DomTime::clearElementMinute() | |
4981 { | |
4982 m_children &= ~Minute; | |
4983 } | |
4984 | |
4985 void DomTime::clearElementSecond() | |
4986 { | |
4987 m_children &= ~Second; | |
4988 } | |
4989 | |
4990 void DomDateTime::clear(bool clear_all) | |
4991 { | |
4992 | |
4993 if (clear_all) { | |
4994 m_text = QString(); | |
4995 } | |
4996 | |
4997 m_children = 0; | |
4998 m_hour = 0; | |
4999 m_minute = 0; | |
5000 m_second = 0; | |
5001 m_year = 0; | |
5002 m_month = 0; | |
5003 m_day = 0; | |
5004 } | |
5005 | |
5006 DomDateTime::DomDateTime() | |
5007 { | |
5008 m_children = 0; | |
5009 m_hour = 0; | |
5010 m_minute = 0; | |
5011 m_second = 0; | |
5012 m_year = 0; | |
5013 m_month = 0; | |
5014 m_day = 0; | |
5015 } | |
5016 | |
5017 DomDateTime::~DomDateTime() | |
5018 { | |
5019 } | |
5020 | |
5021 void DomDateTime::read(const QDomElement &node) | |
5022 { | |
5023 | |
5024 for (QDomNode n = node.firstChild(); !n.isNull(); n = n.nextSibling()) { | |
5025 if (!n.isElement()) | |
5026 continue; | |
5027 QDomElement e = n.toElement(); | |
5028 QString tag = e.tagName().toLower(); | |
5029 if (tag == QLatin1String("hour")) { | |
5030 setElementHour(e.text().toInt()); | |
5031 continue; | |
5032 } | |
5033 if (tag == QLatin1String("minute")) { | |
5034 setElementMinute(e.text().toInt()); | |
5035 continue; | |
5036 } | |
5037 if (tag == QLatin1String("second")) { | |
5038 setElementSecond(e.text().toInt()); | |
5039 continue; | |
5040 } | |
5041 if (tag == QLatin1String("year")) { | |
5042 setElementYear(e.text().toInt()); | |
5043 continue; | |
5044 } | |
5045 if (tag == QLatin1String("month")) { | |
5046 setElementMonth(e.text().toInt()); | |
5047 continue; | |
5048 } | |
5049 if (tag == QLatin1String("day")) { | |
5050 setElementDay(e.text().toInt()); | |
5051 continue; | |
5052 } | |
5053 } | |
5054 | |
5055 m_text.clear(); | |
5056 for (QDomNode child = node.firstChild(); !child.isNull(); child = child.nextSibling()) { | |
5057 if (child.isText()) | |
5058 m_text.append(child.nodeValue()); | |
5059 } | |
5060 } | |
5061 | |
5062 QDomElement DomDateTime::write(QDomDocument &doc, const QString &tagName) const | |
5063 { | |
5064 QDomElement e = doc.createElement(tagName.isEmpty() ? QString::fromUtf8("datetime") : tagName.toLower()); | |
5065 | |
5066 QDomElement child; | |
5067 | |
5068 if (m_children & Hour) { | |
5069 child = doc.createElement(QLatin1String("hour")); | |
5070 child.appendChild(doc.createTextNode(QString::number(m_hour))); | |
5071 e.appendChild(child); | |
5072 } | |
5073 | |
5074 if (m_children & Minute) { | |
5075 child = doc.createElement(QLatin1String("minute")); | |
5076 child.appendChild(doc.createTextNode(QString::number(m_minute))); | |
5077 e.appendChild(child); | |
5078 } | |
5079 | |
5080 if (m_children & Second) { | |
5081 child = doc.createElement(QLatin1String("second")); | |
5082 child.appendChild(doc.createTextNode(QString::number(m_second))); | |
5083 e.appendChild(child); | |
5084 } | |
5085 | |
5086 if (m_children & Year) { | |
5087 child = doc.createElement(QLatin1String("year")); | |
5088 child.appendChild(doc.createTextNode(QString::number(m_year))); | |
5089 e.appendChild(child); | |
5090 } | |
5091 | |
5092 if (m_children & Month) { | |
5093 child = doc.createElement(QLatin1String("month")); | |
5094 child.appendChild(doc.createTextNode(QString::number(m_month))); | |
5095 e.appendChild(child); | |
5096 } | |
5097 | |
5098 if (m_children & Day) { | |
5099 child = doc.createElement(QLatin1String("day")); | |
5100 child.appendChild(doc.createTextNode(QString::number(m_day))); | |
5101 e.appendChild(child); | |
5102 } | |
5103 | |
5104 if (!m_text.isEmpty()) | |
5105 e.appendChild(doc.createTextNode(m_text)); | |
5106 | |
5107 return e; | |
5108 } | |
5109 | |
5110 void DomDateTime::setElementHour(int a) | |
5111 { | |
5112 m_children |= Hour; | |
5113 m_hour = a; | |
5114 } | |
5115 | |
5116 void DomDateTime::setElementMinute(int a) | |
5117 { | |
5118 m_children |= Minute; | |
5119 m_minute = a; | |
5120 } | |
5121 | |
5122 void DomDateTime::setElementSecond(int a) | |
5123 { | |
5124 m_children |= Second; | |
5125 m_second = a; | |
5126 } | |
5127 | |
5128 void DomDateTime::setElementYear(int a) | |
5129 { | |
5130 m_children |= Year; | |
5131 m_year = a; | |
5132 } | |
5133 | |
5134 void DomDateTime::setElementMonth(int a) | |
5135 { | |
5136 m_children |= Month; | |
5137 m_month = a; | |
5138 } | |
5139 | |
5140 void DomDateTime::setElementDay(int a) | |
5141 { | |
5142 m_children |= Day; | |
5143 m_day = a; | |
5144 } | |
5145 | |
5146 void DomDateTime::clearElementHour() | |
5147 { | |
5148 m_children &= ~Hour; | |
5149 } | |
5150 | |
5151 void DomDateTime::clearElementMinute() | |
5152 { | |
5153 m_children &= ~Minute; | |
5154 } | |
5155 | |
5156 void DomDateTime::clearElementSecond() | |
5157 { | |
5158 m_children &= ~Second; | |
5159 } | |
5160 | |
5161 void DomDateTime::clearElementYear() | |
5162 { | |
5163 m_children &= ~Year; | |
5164 } | |
5165 | |
5166 void DomDateTime::clearElementMonth() | |
5167 { | |
5168 m_children &= ~Month; | |
5169 } | |
5170 | |
5171 void DomDateTime::clearElementDay() | |
5172 { | |
5173 m_children &= ~Day; | |
5174 } | |
5175 | |
5176 void DomStringList::clear(bool clear_all) | |
5177 { | |
5178 m_string.clear(); | |
5179 | |
5180 if (clear_all) { | |
5181 m_text = QString(); | |
5182 } | |
5183 | |
5184 } | |
5185 | |
5186 DomStringList::DomStringList() | |
5187 { | |
5188 } | |
5189 | |
5190 DomStringList::~DomStringList() | |
5191 { | |
5192 m_string.clear(); | |
5193 } | |
5194 | |
5195 void DomStringList::read(const QDomElement &node) | |
5196 { | |
5197 | |
5198 for (QDomNode n = node.firstChild(); !n.isNull(); n = n.nextSibling()) { | |
5199 if (!n.isElement()) | |
5200 continue; | |
5201 QDomElement e = n.toElement(); | |
5202 QString tag = e.tagName().toLower(); | |
5203 if (tag == QLatin1String("string")) { | |
5204 m_string.append(e.text()); | |
5205 continue; | |
5206 } | |
5207 } | |
5208 | |
5209 m_text.clear(); | |
5210 for (QDomNode child = node.firstChild(); !child.isNull(); child = child.nextSibling()) { | |
5211 if (child.isText()) | |
5212 m_text.append(child.nodeValue()); | |
5213 } | |
5214 } | |
5215 | |
5216 QDomElement DomStringList::write(QDomDocument &doc, const QString &tagName) const | |
5217 { | |
5218 QDomElement e = doc.createElement(tagName.isEmpty() ? QString::fromUtf8("stringlist") : tagName.toLower()); | |
5219 | |
5220 QDomElement child; | |
5221 | |
5222 for (int i = 0; i < m_string.size(); ++i) { | |
5223 QString v = m_string[i]; | |
5224 QDomNode child = doc.createElement(QLatin1String("string")); | |
5225 child.appendChild(doc.createTextNode(v)); | |
5226 e.appendChild(child); | |
5227 } | |
5228 if (!m_text.isEmpty()) | |
5229 e.appendChild(doc.createTextNode(m_text)); | |
5230 | |
5231 return e; | |
5232 } | |
5233 | |
5234 void DomStringList::setElementString(const QStringList& a) | |
5235 { | |
5236 m_string = a; | |
5237 } | |
5238 | |
5239 void DomResourcePixmap::clear(bool clear_all) | |
5240 { | |
5241 | |
5242 if (clear_all) { | |
5243 m_text = QString(); | |
5244 m_has_attr_resource = false; | |
5245 m_has_attr_alias = false; | |
5246 } | |
5247 | |
5248 } | |
5249 | |
5250 DomResourcePixmap::DomResourcePixmap() | |
5251 { | |
5252 m_has_attr_resource = false; | |
5253 m_has_attr_alias = false; | |
5254 } | |
5255 | |
5256 DomResourcePixmap::~DomResourcePixmap() | |
5257 { | |
5258 } | |
5259 | |
5260 void DomResourcePixmap::read(const QDomElement &node) | |
5261 { | |
5262 if (node.hasAttribute(QLatin1String("resource"))) | |
5263 setAttributeResource(node.attribute(QLatin1String("resource"))); | |
5264 if (node.hasAttribute(QLatin1String("alias"))) | |
5265 setAttributeAlias(node.attribute(QLatin1String("alias"))); | |
5266 | |
5267 for (QDomNode n = node.firstChild(); !n.isNull(); n = n.nextSibling()) { | |
5268 if (!n.isElement()) | |
5269 continue; | |
5270 QDomElement e = n.toElement(); | |
5271 QString tag = e.tagName().toLower(); | |
5272 } | |
5273 | |
5274 m_text.clear(); | |
5275 for (QDomNode child = node.firstChild(); !child.isNull(); child = child.nextSibling()) { | |
5276 if (child.isText()) | |
5277 m_text.append(child.nodeValue()); | |
5278 } | |
5279 } | |
5280 | |
5281 QDomElement DomResourcePixmap::write(QDomDocument &doc, const QString &tagName) const | |
5282 { | |
5283 QDomElement e = doc.createElement(tagName.isEmpty() ? QString::fromUtf8("resourcepixmap") : tagName.toLower()); | |
5284 | |
5285 QDomElement child; | |
5286 | |
5287 if (hasAttributeResource()) | |
5288 e.setAttribute(QLatin1String("resource"), attributeResource()); | |
5289 | |
5290 if (hasAttributeAlias()) | |
5291 e.setAttribute(QLatin1String("alias"), attributeAlias()); | |
5292 | |
5293 if (!m_text.isEmpty()) | |
5294 e.appendChild(doc.createTextNode(m_text)); | |
5295 | |
5296 return e; | |
5297 } | |
5298 | |
5299 void DomResourceIcon::clear(bool clear_all) | |
5300 { | |
5301 delete m_normalOff; | |
5302 delete m_normalOn; | |
5303 delete m_disabledOff; | |
5304 delete m_disabledOn; | |
5305 delete m_activeOff; | |
5306 delete m_activeOn; | |
5307 delete m_selectedOff; | |
5308 delete m_selectedOn; | |
5309 | |
5310 if (clear_all) { | |
5311 m_text = QString(); | |
5312 m_has_attr_resource = false; | |
5313 } | |
5314 | |
5315 m_children = 0; | |
5316 m_normalOff = 0; | |
5317 m_normalOn = 0; | |
5318 m_disabledOff = 0; | |
5319 m_disabledOn = 0; | |
5320 m_activeOff = 0; | |
5321 m_activeOn = 0; | |
5322 m_selectedOff = 0; | |
5323 m_selectedOn = 0; | |
5324 } | |
5325 | |
5326 DomResourceIcon::DomResourceIcon() | |
5327 { | |
5328 m_children = 0; | |
5329 m_has_attr_resource = false; | |
5330 m_normalOff = 0; | |
5331 m_normalOn = 0; | |
5332 m_disabledOff = 0; | |
5333 m_disabledOn = 0; | |
5334 m_activeOff = 0; | |
5335 m_activeOn = 0; | |
5336 m_selectedOff = 0; | |
5337 m_selectedOn = 0; | |
5338 } | |
5339 | |
5340 DomResourceIcon::~DomResourceIcon() | |
5341 { | |
5342 delete m_normalOff; | |
5343 delete m_normalOn; | |
5344 delete m_disabledOff; | |
5345 delete m_disabledOn; | |
5346 delete m_activeOff; | |
5347 delete m_activeOn; | |
5348 delete m_selectedOff; | |
5349 delete m_selectedOn; | |
5350 } | |
5351 | |
5352 void DomResourceIcon::read(const QDomElement &node) | |
5353 { | |
5354 if (node.hasAttribute(QLatin1String("resource"))) | |
5355 setAttributeResource(node.attribute(QLatin1String("resource"))); | |
5356 | |
5357 for (QDomNode n = node.firstChild(); !n.isNull(); n = n.nextSibling()) { | |
5358 if (!n.isElement()) | |
5359 continue; | |
5360 QDomElement e = n.toElement(); | |
5361 QString tag = e.tagName().toLower(); | |
5362 if (tag == QLatin1String("normaloff")) { | |
5363 DomResourcePixmap *v = new DomResourcePixmap(); | |
5364 v->read(e); | |
5365 setElementNormalOff(v); | |
5366 continue; | |
5367 } | |
5368 if (tag == QLatin1String("normalon")) { | |
5369 DomResourcePixmap *v = new DomResourcePixmap(); | |
5370 v->read(e); | |
5371 setElementNormalOn(v); | |
5372 continue; | |
5373 } | |
5374 if (tag == QLatin1String("disabledoff")) { | |
5375 DomResourcePixmap *v = new DomResourcePixmap(); | |
5376 v->read(e); | |
5377 setElementDisabledOff(v); | |
5378 continue; | |
5379 } | |
5380 if (tag == QLatin1String("disabledon")) { | |
5381 DomResourcePixmap *v = new DomResourcePixmap(); | |
5382 v->read(e); | |
5383 setElementDisabledOn(v); | |
5384 continue; | |
5385 } | |
5386 if (tag == QLatin1String("activeoff")) { | |
5387 DomResourcePixmap *v = new DomResourcePixmap(); | |
5388 v->read(e); | |
5389 setElementActiveOff(v); | |
5390 continue; | |
5391 } | |
5392 if (tag == QLatin1String("activeon")) { | |
5393 DomResourcePixmap *v = new DomResourcePixmap(); | |
5394 v->read(e); | |
5395 setElementActiveOn(v); | |
5396 continue; | |
5397 } | |
5398 if (tag == QLatin1String("selectedoff")) { | |
5399 DomResourcePixmap *v = new DomResourcePixmap(); | |
5400 v->read(e); | |
5401 setElementSelectedOff(v); | |
5402 continue; | |
5403 } | |
5404 if (tag == QLatin1String("selectedon")) { | |
5405 DomResourcePixmap *v = new DomResourcePixmap(); | |
5406 v->read(e); | |
5407 setElementSelectedOn(v); | |
5408 continue; | |
5409 } | |
5410 } | |
5411 | |
5412 m_text.clear(); | |
5413 for (QDomNode child = node.firstChild(); !child.isNull(); child = child.nextSibling()) { | |
5414 if (child.isText()) | |
5415 m_text.append(child.nodeValue()); | |
5416 } | |
5417 } | |
5418 | |
5419 QDomElement DomResourceIcon::write(QDomDocument &doc, const QString &tagName) const | |
5420 { | |
5421 QDomElement e = doc.createElement(tagName.isEmpty() ? QString::fromUtf8("resourceicon") : tagName.toLower()); | |
5422 | |
5423 QDomElement child; | |
5424 | |
5425 if (hasAttributeResource()) | |
5426 e.setAttribute(QLatin1String("resource"), attributeResource()); | |
5427 | |
5428 if (m_children & NormalOff) { | |
5429 e.appendChild(m_normalOff->write(doc, QLatin1String("normaloff"))); | |
5430 } | |
5431 | |
5432 if (m_children & NormalOn) { | |
5433 e.appendChild(m_normalOn->write(doc, QLatin1String("normalon"))); | |
5434 } | |
5435 | |
5436 if (m_children & DisabledOff) { | |
5437 e.appendChild(m_disabledOff->write(doc, QLatin1String("disabledoff"))); | |
5438 } | |
5439 | |
5440 if (m_children & DisabledOn) { | |
5441 e.appendChild(m_disabledOn->write(doc, QLatin1String("disabledon"))); | |
5442 } | |
5443 | |
5444 if (m_children & ActiveOff) { | |
5445 e.appendChild(m_activeOff->write(doc, QLatin1String("activeoff"))); | |
5446 } | |
5447 | |
5448 if (m_children & ActiveOn) { | |
5449 e.appendChild(m_activeOn->write(doc, QLatin1String("activeon"))); | |
5450 } | |
5451 | |
5452 if (m_children & SelectedOff) { | |
5453 e.appendChild(m_selectedOff->write(doc, QLatin1String("selectedoff"))); | |
5454 } | |
5455 | |
5456 if (m_children & SelectedOn) { | |
5457 e.appendChild(m_selectedOn->write(doc, QLatin1String("selectedon"))); | |
5458 } | |
5459 | |
5460 if (!m_text.isEmpty()) | |
5461 e.appendChild(doc.createTextNode(m_text)); | |
5462 | |
5463 return e; | |
5464 } | |
5465 | |
5466 void DomResourceIcon::setElementNormalOff(DomResourcePixmap* a) | |
5467 { | |
5468 delete m_normalOff; | |
5469 m_children |= NormalOff; | |
5470 m_normalOff = a; | |
5471 } | |
5472 | |
5473 void DomResourceIcon::setElementNormalOn(DomResourcePixmap* a) | |
5474 { | |
5475 delete m_normalOn; | |
5476 m_children |= NormalOn; | |
5477 m_normalOn = a; | |
5478 } | |
5479 | |
5480 void DomResourceIcon::setElementDisabledOff(DomResourcePixmap* a) | |
5481 { | |
5482 delete m_disabledOff; | |
5483 m_children |= DisabledOff; | |
5484 m_disabledOff = a; | |
5485 } | |
5486 | |
5487 void DomResourceIcon::setElementDisabledOn(DomResourcePixmap* a) | |
5488 { | |
5489 delete m_disabledOn; | |
5490 m_children |= DisabledOn; | |
5491 m_disabledOn = a; | |
5492 } | |
5493 | |
5494 void DomResourceIcon::setElementActiveOff(DomResourcePixmap* a) | |
5495 { | |
5496 delete m_activeOff; | |
5497 m_children |= ActiveOff; | |
5498 m_activeOff = a; | |
5499 } | |
5500 | |
5501 void DomResourceIcon::setElementActiveOn(DomResourcePixmap* a) | |
5502 { | |
5503 delete m_activeOn; | |
5504 m_children |= ActiveOn; | |
5505 m_activeOn = a; | |
5506 } | |
5507 | |
5508 void DomResourceIcon::setElementSelectedOff(DomResourcePixmap* a) | |
5509 { | |
5510 delete m_selectedOff; | |
5511 m_children |= SelectedOff; | |
5512 m_selectedOff = a; | |
5513 } | |
5514 | |
5515 void DomResourceIcon::setElementSelectedOn(DomResourcePixmap* a) | |
5516 { | |
5517 delete m_selectedOn; | |
5518 m_children |= SelectedOn; | |
5519 m_selectedOn = a; | |
5520 } | |
5521 | |
5522 void DomResourceIcon::clearElementNormalOff() | |
5523 { | |
5524 delete m_normalOff; | |
5525 m_normalOff = 0; | |
5526 m_children &= ~NormalOff; | |
5527 } | |
5528 | |
5529 void DomResourceIcon::clearElementNormalOn() | |
5530 { | |
5531 delete m_normalOn; | |
5532 m_normalOn = 0; | |
5533 m_children &= ~NormalOn; | |
5534 } | |
5535 | |
5536 void DomResourceIcon::clearElementDisabledOff() | |
5537 { | |
5538 delete m_disabledOff; | |
5539 m_disabledOff = 0; | |
5540 m_children &= ~DisabledOff; | |
5541 } | |
5542 | |
5543 void DomResourceIcon::clearElementDisabledOn() | |
5544 { | |
5545 delete m_disabledOn; | |
5546 m_disabledOn = 0; | |
5547 m_children &= ~DisabledOn; | |
5548 } | |
5549 | |
5550 void DomResourceIcon::clearElementActiveOff() | |
5551 { | |
5552 delete m_activeOff; | |
5553 m_activeOff = 0; | |
5554 m_children &= ~ActiveOff; | |
5555 } | |
5556 | |
5557 void DomResourceIcon::clearElementActiveOn() | |
5558 { | |
5559 delete m_activeOn; | |
5560 m_activeOn = 0; | |
5561 m_children &= ~ActiveOn; | |
5562 } | |
5563 | |
5564 void DomResourceIcon::clearElementSelectedOff() | |
5565 { | |
5566 delete m_selectedOff; | |
5567 m_selectedOff = 0; | |
5568 m_children &= ~SelectedOff; | |
5569 } | |
5570 | |
5571 void DomResourceIcon::clearElementSelectedOn() | |
5572 { | |
5573 delete m_selectedOn; | |
5574 m_selectedOn = 0; | |
5575 m_children &= ~SelectedOn; | |
5576 } | |
5577 | |
5578 void DomString::clear(bool clear_all) | |
5579 { | |
5580 | |
5581 if (clear_all) { | |
5582 m_text = QString(); | |
5583 m_has_attr_notr = false; | |
5584 m_has_attr_comment = false; | |
5585 } | |
5586 | |
5587 } | |
5588 | |
5589 DomString::DomString() | |
5590 { | |
5591 m_has_attr_notr = false; | |
5592 m_has_attr_comment = false; | |
5593 } | |
5594 | |
5595 DomString::~DomString() | |
5596 { | |
5597 } | |
5598 | |
5599 void DomString::read(const QDomElement &node) | |
5600 { | |
5601 if (node.hasAttribute(QLatin1String("notr"))) | |
5602 setAttributeNotr(node.attribute(QLatin1String("notr"))); | |
5603 if (node.hasAttribute(QLatin1String("comment"))) | |
5604 setAttributeComment(node.attribute(QLatin1String("comment"))); | |
5605 | |
5606 for (QDomNode n = node.firstChild(); !n.isNull(); n = n.nextSibling()) { | |
5607 if (!n.isElement()) | |
5608 continue; | |
5609 QDomElement e = n.toElement(); | |
5610 QString tag = e.tagName().toLower(); | |
5611 } | |
5612 | |
5613 m_text.clear(); | |
5614 for (QDomNode child = node.firstChild(); !child.isNull(); child = child.nextSibling()) { | |
5615 if (child.isText()) | |
5616 m_text.append(child.nodeValue()); | |
5617 } | |
5618 } | |
5619 | |
5620 QDomElement DomString::write(QDomDocument &doc, const QString &tagName) const | |
5621 { | |
5622 QDomElement e = doc.createElement(tagName.isEmpty() ? QString::fromUtf8("string") : tagName.toLower()); | |
5623 | |
5624 QDomElement child; | |
5625 | |
5626 if (hasAttributeNotr()) | |
5627 e.setAttribute(QLatin1String("notr"), attributeNotr()); | |
5628 | |
5629 if (hasAttributeComment()) | |
5630 e.setAttribute(QLatin1String("comment"), attributeComment()); | |
5631 | |
5632 if (!m_text.isEmpty()) | |
5633 e.appendChild(doc.createTextNode(m_text)); | |
5634 | |
5635 return e; | |
5636 } | |
5637 | |
5638 void DomPointF::clear(bool clear_all) | |
5639 { | |
5640 | |
5641 if (clear_all) { | |
5642 m_text = QString(); | |
5643 } | |
5644 | |
5645 m_children = 0; | |
5646 m_x = 0; | |
5647 m_y = 0; | |
5648 } | |
5649 | |
5650 DomPointF::DomPointF() | |
5651 { | |
5652 m_children = 0; | |
5653 m_x = 0; | |
5654 m_y = 0; | |
5655 } | |
5656 | |
5657 DomPointF::~DomPointF() | |
5658 { | |
5659 } | |
5660 | |
5661 void DomPointF::read(const QDomElement &node) | |
5662 { | |
5663 | |
5664 for (QDomNode n = node.firstChild(); !n.isNull(); n = n.nextSibling()) { | |
5665 if (!n.isElement()) | |
5666 continue; | |
5667 QDomElement e = n.toElement(); | |
5668 QString tag = e.tagName().toLower(); | |
5669 if (tag == QString(QLatin1Char('x'))) { | |
5670 setElementX(e.text().toDouble()); | |
5671 continue; | |
5672 } | |
5673 if (tag == QString(QLatin1Char('y'))) { | |
5674 setElementY(e.text().toDouble()); | |
5675 continue; | |
5676 } | |
5677 } | |
5678 | |
5679 m_text.clear(); | |
5680 for (QDomNode child = node.firstChild(); !child.isNull(); child = child.nextSibling()) { | |
5681 if (child.isText()) | |
5682 m_text.append(child.nodeValue()); | |
5683 } | |
5684 } | |
5685 | |
5686 QDomElement DomPointF::write(QDomDocument &doc, const QString &tagName) const | |
5687 { | |
5688 QDomElement e = doc.createElement(tagName.isEmpty() ? QString::fromUtf8("pointf") : tagName.toLower()); | |
5689 | |
5690 QDomElement child; | |
5691 | |
5692 if (m_children & X) { | |
5693 child = doc.createElement(QString(QLatin1Char('x'))); | |
5694 child.appendChild(doc.createTextNode(QString::number(m_x, 'f', 15))); | |
5695 e.appendChild(child); | |
5696 } | |
5697 | |
5698 if (m_children & Y) { | |
5699 child = doc.createElement(QString(QLatin1Char('y'))); | |
5700 child.appendChild(doc.createTextNode(QString::number(m_y, 'f', 15))); | |
5701 e.appendChild(child); | |
5702 } | |
5703 | |
5704 if (!m_text.isEmpty()) | |
5705 e.appendChild(doc.createTextNode(m_text)); | |
5706 | |
5707 return e; | |
5708 } | |
5709 | |
5710 void DomPointF::setElementX(double a) | |
5711 { | |
5712 m_children |= X; | |
5713 m_x = a; | |
5714 } | |
5715 | |
5716 void DomPointF::setElementY(double a) | |
5717 { | |
5718 m_children |= Y; | |
5719 m_y = a; | |
5720 } | |
5721 | |
5722 void DomPointF::clearElementX() | |
5723 { | |
5724 m_children &= ~X; | |
5725 } | |
5726 | |
5727 void DomPointF::clearElementY() | |
5728 { | |
5729 m_children &= ~Y; | |
5730 } | |
5731 | |
5732 void DomRectF::clear(bool clear_all) | |
5733 { | |
5734 | |
5735 if (clear_all) { | |
5736 m_text = QString(); | |
5737 } | |
5738 | |
5739 m_children = 0; | |
5740 m_x = 0; | |
5741 m_y = 0; | |
5742 m_width = 0; | |
5743 m_height = 0; | |
5744 } | |
5745 | |
5746 DomRectF::DomRectF() | |
5747 { | |
5748 m_children = 0; | |
5749 m_x = 0; | |
5750 m_y = 0; | |
5751 m_width = 0; | |
5752 m_height = 0; | |
5753 } | |
5754 | |
5755 DomRectF::~DomRectF() | |
5756 { | |
5757 } | |
5758 | |
5759 void DomRectF::read(const QDomElement &node) | |
5760 { | |
5761 | |
5762 for (QDomNode n = node.firstChild(); !n.isNull(); n = n.nextSibling()) { | |
5763 if (!n.isElement()) | |
5764 continue; | |
5765 QDomElement e = n.toElement(); | |
5766 QString tag = e.tagName().toLower(); | |
5767 if (tag == QString(QLatin1Char('x'))) { | |
5768 setElementX(e.text().toDouble()); | |
5769 continue; | |
5770 } | |
5771 if (tag == QString(QLatin1Char('y'))) { | |
5772 setElementY(e.text().toDouble()); | |
5773 continue; | |
5774 } | |
5775 if (tag == QLatin1String("width")) { | |
5776 setElementWidth(e.text().toDouble()); | |
5777 continue; | |
5778 } | |
5779 if (tag == QLatin1String("height")) { | |
5780 setElementHeight(e.text().toDouble()); | |
5781 continue; | |
5782 } | |
5783 } | |
5784 | |
5785 m_text.clear(); | |
5786 for (QDomNode child = node.firstChild(); !child.isNull(); child = child.nextSibling()) { | |
5787 if (child.isText()) | |
5788 m_text.append(child.nodeValue()); | |
5789 } | |
5790 } | |
5791 | |
5792 QDomElement DomRectF::write(QDomDocument &doc, const QString &tagName) const | |
5793 { | |
5794 QDomElement e = doc.createElement(tagName.isEmpty() ? QString::fromUtf8("rectf") : tagName.toLower()); | |
5795 | |
5796 QDomElement child; | |
5797 | |
5798 if (m_children & X) { | |
5799 child = doc.createElement(QString(QLatin1Char('x'))); | |
5800 child.appendChild(doc.createTextNode(QString::number(m_x, 'f', 15))); | |
5801 e.appendChild(child); | |
5802 } | |
5803 | |
5804 if (m_children & Y) { | |
5805 child = doc.createElement(QString(QLatin1Char('y'))); | |
5806 child.appendChild(doc.createTextNode(QString::number(m_y, 'f', 15))); | |
5807 e.appendChild(child); | |
5808 } | |
5809 | |
5810 if (m_children & Width) { | |
5811 child = doc.createElement(QLatin1String("width")); | |
5812 child.appendChild(doc.createTextNode(QString::number(m_width, 'f', 15))); | |
5813 e.appendChild(child); | |
5814 } | |
5815 | |
5816 if (m_children & Height) { | |
5817 child = doc.createElement(QLatin1String("height")); | |
5818 child.appendChild(doc.createTextNode(QString::number(m_height, 'f', 15))); | |
5819 e.appendChild(child); | |
5820 } | |
5821 | |
5822 if (!m_text.isEmpty()) | |
5823 e.appendChild(doc.createTextNode(m_text)); | |
5824 | |
5825 return e; | |
5826 } | |
5827 | |
5828 void DomRectF::setElementX(double a) | |
5829 { | |
5830 m_children |= X; | |
5831 m_x = a; | |
5832 } | |
5833 | |
5834 void DomRectF::setElementY(double a) | |
5835 { | |
5836 m_children |= Y; | |
5837 m_y = a; | |
5838 } | |
5839 | |
5840 void DomRectF::setElementWidth(double a) | |
5841 { | |
5842 m_children |= Width; | |
5843 m_width = a; | |
5844 } | |
5845 | |
5846 void DomRectF::setElementHeight(double a) | |
5847 { | |
5848 m_children |= Height; | |
5849 m_height = a; | |
5850 } | |
5851 | |
5852 void DomRectF::clearElementX() | |
5853 { | |
5854 m_children &= ~X; | |
5855 } | |
5856 | |
5857 void DomRectF::clearElementY() | |
5858 { | |
5859 m_children &= ~Y; | |
5860 } | |
5861 | |
5862 void DomRectF::clearElementWidth() | |
5863 { | |
5864 m_children &= ~Width; | |
5865 } | |
5866 | |
5867 void DomRectF::clearElementHeight() | |
5868 { | |
5869 m_children &= ~Height; | |
5870 } | |
5871 | |
5872 void DomSizeF::clear(bool clear_all) | |
5873 { | |
5874 | |
5875 if (clear_all) { | |
5876 m_text = QString(); | |
5877 } | |
5878 | |
5879 m_children = 0; | |
5880 m_width = 0; | |
5881 m_height = 0; | |
5882 } | |
5883 | |
5884 DomSizeF::DomSizeF() | |
5885 { | |
5886 m_children = 0; | |
5887 m_width = 0; | |
5888 m_height = 0; | |
5889 } | |
5890 | |
5891 DomSizeF::~DomSizeF() | |
5892 { | |
5893 } | |
5894 | |
5895 void DomSizeF::read(const QDomElement &node) | |
5896 { | |
5897 | |
5898 for (QDomNode n = node.firstChild(); !n.isNull(); n = n.nextSibling()) { | |
5899 if (!n.isElement()) | |
5900 continue; | |
5901 QDomElement e = n.toElement(); | |
5902 QString tag = e.tagName().toLower(); | |
5903 if (tag == QLatin1String("width")) { | |
5904 setElementWidth(e.text().toDouble()); | |
5905 continue; | |
5906 } | |
5907 if (tag == QLatin1String("height")) { | |
5908 setElementHeight(e.text().toDouble()); | |
5909 continue; | |
5910 } | |
5911 } | |
5912 | |
5913 m_text.clear(); | |
5914 for (QDomNode child = node.firstChild(); !child.isNull(); child = child.nextSibling()) { | |
5915 if (child.isText()) | |
5916 m_text.append(child.nodeValue()); | |
5917 } | |
5918 } | |
5919 | |
5920 QDomElement DomSizeF::write(QDomDocument &doc, const QString &tagName) const | |
5921 { | |
5922 QDomElement e = doc.createElement(tagName.isEmpty() ? QString::fromUtf8("sizef") : tagName.toLower()); | |
5923 | |
5924 QDomElement child; | |
5925 | |
5926 if (m_children & Width) { | |
5927 child = doc.createElement(QLatin1String("width")); | |
5928 child.appendChild(doc.createTextNode(QString::number(m_width, 'f', 15))); | |
5929 e.appendChild(child); | |
5930 } | |
5931 | |
5932 if (m_children & Height) { | |
5933 child = doc.createElement(QLatin1String("height")); | |
5934 child.appendChild(doc.createTextNode(QString::number(m_height, 'f', 15))); | |
5935 e.appendChild(child); | |
5936 } | |
5937 | |
5938 if (!m_text.isEmpty()) | |
5939 e.appendChild(doc.createTextNode(m_text)); | |
5940 | |
5941 return e; | |
5942 } | |
5943 | |
5944 void DomSizeF::setElementWidth(double a) | |
5945 { | |
5946 m_children |= Width; | |
5947 m_width = a; | |
5948 } | |
5949 | |
5950 void DomSizeF::setElementHeight(double a) | |
5951 { | |
5952 m_children |= Height; | |
5953 m_height = a; | |
5954 } | |
5955 | |
5956 void DomSizeF::clearElementWidth() | |
5957 { | |
5958 m_children &= ~Width; | |
5959 } | |
5960 | |
5961 void DomSizeF::clearElementHeight() | |
5962 { | |
5963 m_children &= ~Height; | |
5964 } | |
5965 | |
5966 void DomChar::clear(bool clear_all) | |
5967 { | |
5968 | |
5969 if (clear_all) { | |
5970 m_text = QString(); | |
5971 } | |
5972 | |
5973 m_children = 0; | |
5974 m_unicode = 0; | |
5975 } | |
5976 | |
5977 DomChar::DomChar() | |
5978 { | |
5979 m_children = 0; | |
5980 m_unicode = 0; | |
5981 } | |
5982 | |
5983 DomChar::~DomChar() | |
5984 { | |
5985 } | |
5986 | |
5987 void DomChar::read(const QDomElement &node) | |
5988 { | |
5989 | |
5990 for (QDomNode n = node.firstChild(); !n.isNull(); n = n.nextSibling()) { | |
5991 if (!n.isElement()) | |
5992 continue; | |
5993 QDomElement e = n.toElement(); | |
5994 QString tag = e.tagName().toLower(); | |
5995 if (tag == QLatin1String("unicode")) { | |
5996 setElementUnicode(e.text().toInt()); | |
5997 continue; | |
5998 } | |
5999 } | |
6000 | |
6001 m_text.clear(); | |
6002 for (QDomNode child = node.firstChild(); !child.isNull(); child = child.nextSibling()) { | |
6003 if (child.isText()) | |
6004 m_text.append(child.nodeValue()); | |
6005 } | |
6006 } | |
6007 | |
6008 QDomElement DomChar::write(QDomDocument &doc, const QString &tagName) const | |
6009 { | |
6010 QDomElement e = doc.createElement(tagName.isEmpty() ? QString::fromUtf8("char") : tagName.toLower()); | |
6011 | |
6012 QDomElement child; | |
6013 | |
6014 if (m_children & Unicode) { | |
6015 child = doc.createElement(QLatin1String("unicode")); | |
6016 child.appendChild(doc.createTextNode(QString::number(m_unicode))); | |
6017 e.appendChild(child); | |
6018 } | |
6019 | |
6020 if (!m_text.isEmpty()) | |
6021 e.appendChild(doc.createTextNode(m_text)); | |
6022 | |
6023 return e; | |
6024 } | |
6025 | |
6026 void DomChar::setElementUnicode(int a) | |
6027 { | |
6028 m_children |= Unicode; | |
6029 m_unicode = a; | |
6030 } | |
6031 | |
6032 void DomChar::clearElementUnicode() | |
6033 { | |
6034 m_children &= ~Unicode; | |
6035 } | |
6036 | |
6037 void DomUrl::clear(bool clear_all) | |
6038 { | |
6039 delete m_string; | |
6040 | |
6041 if (clear_all) { | |
6042 m_text = QString(); | |
6043 } | |
6044 | |
6045 m_children = 0; | |
6046 m_string = 0; | |
6047 } | |
6048 | |
6049 DomUrl::DomUrl() | |
6050 { | |
6051 m_children = 0; | |
6052 m_string = 0; | |
6053 } | |
6054 | |
6055 DomUrl::~DomUrl() | |
6056 { | |
6057 delete m_string; | |
6058 } | |
6059 | |
6060 void DomUrl::read(const QDomElement &node) | |
6061 { | |
6062 | |
6063 for (QDomNode n = node.firstChild(); !n.isNull(); n = n.nextSibling()) { | |
6064 if (!n.isElement()) | |
6065 continue; | |
6066 QDomElement e = n.toElement(); | |
6067 QString tag = e.tagName().toLower(); | |
6068 if (tag == QLatin1String("string")) { | |
6069 DomString *v = new DomString(); | |
6070 v->read(e); | |
6071 setElementString(v); | |
6072 continue; | |
6073 } | |
6074 } | |
6075 | |
6076 m_text.clear(); | |
6077 for (QDomNode child = node.firstChild(); !child.isNull(); child = child.nextSibling()) { | |
6078 if (child.isText()) | |
6079 m_text.append(child.nodeValue()); | |
6080 } | |
6081 } | |
6082 | |
6083 QDomElement DomUrl::write(QDomDocument &doc, const QString &tagName) const | |
6084 { | |
6085 QDomElement e = doc.createElement(tagName.isEmpty() ? QString::fromUtf8("url") : tagName.toLower()); | |
6086 | |
6087 QDomElement child; | |
6088 | |
6089 if (m_children & String) { | |
6090 e.appendChild(m_string->write(doc, QLatin1String("string"))); | |
6091 } | |
6092 | |
6093 if (!m_text.isEmpty()) | |
6094 e.appendChild(doc.createTextNode(m_text)); | |
6095 | |
6096 return e; | |
6097 } | |
6098 | |
6099 void DomUrl::setElementString(DomString* a) | |
6100 { | |
6101 delete m_string; | |
6102 m_children |= String; | |
6103 m_string = a; | |
6104 } | |
6105 | |
6106 void DomUrl::clearElementString() | |
6107 { | |
6108 delete m_string; | |
6109 m_string = 0; | |
6110 m_children &= ~String; | |
6111 } | |
6112 | |
6113 void DomProperty::clear(bool clear_all) | |
6114 { | |
6115 delete m_color; | |
6116 delete m_font; | |
6117 delete m_iconSet; | |
6118 delete m_pixmap; | |
6119 delete m_palette; | |
6120 delete m_point; | |
6121 delete m_rect; | |
6122 delete m_locale; | |
6123 delete m_sizePolicy; | |
6124 delete m_size; | |
6125 delete m_string; | |
6126 delete m_stringList; | |
6127 delete m_date; | |
6128 delete m_time; | |
6129 delete m_dateTime; | |
6130 delete m_pointF; | |
6131 delete m_rectF; | |
6132 delete m_sizeF; | |
6133 delete m_char; | |
6134 delete m_url; | |
6135 delete m_brush; | |
6136 | |
6137 if (clear_all) { | |
6138 m_text = QString(); | |
6139 m_has_attr_name = false; | |
6140 m_has_attr_stdset = false; | |
6141 m_attr_stdset = 0; | |
6142 } | |
6143 | |
6144 m_kind = Unknown; | |
6145 | |
6146 m_color = 0; | |
6147 m_cursor = 0; | |
6148 m_font = 0; | |
6149 m_iconSet = 0; | |
6150 m_pixmap = 0; | |
6151 m_palette = 0; | |
6152 m_point = 0; | |
6153 m_rect = 0; | |
6154 m_locale = 0; | |
6155 m_sizePolicy = 0; | |
6156 m_size = 0; | |
6157 m_string = 0; | |
6158 m_stringList = 0; | |
6159 m_number = 0; | |
6160 m_float = 0.0; | |
6161 m_double = 0; | |
6162 m_date = 0; | |
6163 m_time = 0; | |
6164 m_dateTime = 0; | |
6165 m_pointF = 0; | |
6166 m_rectF = 0; | |
6167 m_sizeF = 0; | |
6168 m_longLong = 0; | |
6169 m_char = 0; | |
6170 m_url = 0; | |
6171 m_uInt = 0; | |
6172 m_uLongLong = 0; | |
6173 m_brush = 0; | |
6174 } | |
6175 | |
6176 DomProperty::DomProperty() | |
6177 { | |
6178 m_kind = Unknown; | |
6179 | |
6180 m_has_attr_name = false; | |
6181 m_has_attr_stdset = false; | |
6182 m_attr_stdset = 0; | |
6183 m_color = 0; | |
6184 m_cursor = 0; | |
6185 m_font = 0; | |
6186 m_iconSet = 0; | |
6187 m_pixmap = 0; | |
6188 m_palette = 0; | |
6189 m_point = 0; | |
6190 m_rect = 0; | |
6191 m_locale = 0; | |
6192 m_sizePolicy = 0; | |
6193 m_size = 0; | |
6194 m_string = 0; | |
6195 m_stringList = 0; | |
6196 m_number = 0; | |
6197 m_float = 0.0; | |
6198 m_double = 0; | |
6199 m_date = 0; | |
6200 m_time = 0; | |
6201 m_dateTime = 0; | |
6202 m_pointF = 0; | |
6203 m_rectF = 0; | |
6204 m_sizeF = 0; | |
6205 m_longLong = 0; | |
6206 m_char = 0; | |
6207 m_url = 0; | |
6208 m_uInt = 0; | |
6209 m_uLongLong = 0; | |
6210 m_brush = 0; | |
6211 } | |
6212 | |
6213 DomProperty::~DomProperty() | |
6214 { | |
6215 delete m_color; | |
6216 delete m_font; | |
6217 delete m_iconSet; | |
6218 delete m_pixmap; | |
6219 delete m_palette; | |
6220 delete m_point; | |
6221 delete m_rect; | |
6222 delete m_locale; | |
6223 delete m_sizePolicy; | |
6224 delete m_size; | |
6225 delete m_string; | |
6226 delete m_stringList; | |
6227 delete m_date; | |
6228 delete m_time; | |
6229 delete m_dateTime; | |
6230 delete m_pointF; | |
6231 delete m_rectF; | |
6232 delete m_sizeF; | |
6233 delete m_char; | |
6234 delete m_url; | |
6235 delete m_brush; | |
6236 } | |
6237 | |
6238 void DomProperty::read(const QDomElement &node) | |
6239 { | |
6240 if (node.hasAttribute(QLatin1String("name"))) | |
6241 setAttributeName(node.attribute(QLatin1String("name"))); | |
6242 if (node.hasAttribute(QLatin1String("stdset"))) | |
6243 setAttributeStdset(node.attribute(QLatin1String("stdset")).toInt()); | |
6244 | |
6245 for (QDomNode n = node.firstChild(); !n.isNull(); n = n.nextSibling()) { | |
6246 if (!n.isElement()) | |
6247 continue; | |
6248 QDomElement e = n.toElement(); | |
6249 QString tag = e.tagName().toLower(); | |
6250 if (tag == QLatin1String("bool")) { | |
6251 setElementBool(e.text()); | |
6252 continue; | |
6253 } | |
6254 if (tag == QLatin1String("color")) { | |
6255 DomColor *v = new DomColor(); | |
6256 v->read(e); | |
6257 setElementColor(v); | |
6258 continue; | |
6259 } | |
6260 if (tag == QLatin1String("cstring")) { | |
6261 setElementCstring(e.text()); | |
6262 continue; | |
6263 } | |
6264 if (tag == QLatin1String("cursor")) { | |
6265 setElementCursor(e.text().toInt()); | |
6266 continue; | |
6267 } | |
6268 if (tag == QLatin1String("cursorshape")) { | |
6269 setElementCursorShape(e.text()); | |
6270 continue; | |
6271 } | |
6272 if (tag == QLatin1String("enum")) { | |
6273 setElementEnum(e.text()); | |
6274 continue; | |
6275 } | |
6276 if (tag == QLatin1String("font")) { | |
6277 DomFont *v = new DomFont(); | |
6278 v->read(e); | |
6279 setElementFont(v); | |
6280 continue; | |
6281 } | |
6282 if (tag == QLatin1String("iconset")) { | |
6283 DomResourceIcon *v = new DomResourceIcon(); | |
6284 v->read(e); | |
6285 setElementIconSet(v); | |
6286 continue; | |
6287 } | |
6288 if (tag == QLatin1String("pixmap")) { | |
6289 DomResourcePixmap *v = new DomResourcePixmap(); | |
6290 v->read(e); | |
6291 setElementPixmap(v); | |
6292 continue; | |
6293 } | |
6294 if (tag == QLatin1String("palette")) { | |
6295 DomPalette *v = new DomPalette(); | |
6296 v->read(e); | |
6297 setElementPalette(v); | |
6298 continue; | |
6299 } | |
6300 if (tag == QLatin1String("point")) { | |
6301 DomPoint *v = new DomPoint(); | |
6302 v->read(e); | |
6303 setElementPoint(v); | |
6304 continue; | |
6305 } | |
6306 if (tag == QLatin1String("rect")) { | |
6307 DomRect *v = new DomRect(); | |
6308 v->read(e); | |
6309 setElementRect(v); | |
6310 continue; | |
6311 } | |
6312 if (tag == QLatin1String("set")) { | |
6313 setElementSet(e.text()); | |
6314 continue; | |
6315 } | |
6316 if (tag == QLatin1String("locale")) { | |
6317 DomLocale *v = new DomLocale(); | |
6318 v->read(e); | |
6319 setElementLocale(v); | |
6320 continue; | |
6321 } | |
6322 if (tag == QLatin1String("sizepolicy")) { | |
6323 DomSizePolicy *v = new DomSizePolicy(); | |
6324 v->read(e); | |
6325 setElementSizePolicy(v); | |
6326 continue; | |
6327 } | |
6328 if (tag == QLatin1String("size")) { | |
6329 DomSize *v = new DomSize(); | |
6330 v->read(e); | |
6331 setElementSize(v); | |
6332 continue; | |
6333 } | |
6334 if (tag == QLatin1String("string")) { | |
6335 DomString *v = new DomString(); | |
6336 v->read(e); | |
6337 setElementString(v); | |
6338 continue; | |
6339 } | |
6340 if (tag == QLatin1String("stringlist")) { | |
6341 DomStringList *v = new DomStringList(); | |
6342 v->read(e); | |
6343 setElementStringList(v); | |
6344 continue; | |
6345 } | |
6346 if (tag == QLatin1String("number")) { | |
6347 setElementNumber(e.text().toInt()); | |
6348 continue; | |
6349 } | |
6350 if (tag == QLatin1String("float")) { | |
6351 setElementFloat(e.text().toFloat()); | |
6352 continue; | |
6353 } | |
6354 if (tag == QLatin1String("double")) { | |
6355 setElementDouble(e.text().toDouble()); | |
6356 continue; | |
6357 } | |
6358 if (tag == QLatin1String("date")) { | |
6359 DomDate *v = new DomDate(); | |
6360 v->read(e); | |
6361 setElementDate(v); | |
6362 continue; | |
6363 } | |
6364 if (tag == QLatin1String("time")) { | |
6365 DomTime *v = new DomTime(); | |
6366 v->read(e); | |
6367 setElementTime(v); | |
6368 continue; | |
6369 } | |
6370 if (tag == QLatin1String("datetime")) { | |
6371 DomDateTime *v = new DomDateTime(); | |
6372 v->read(e); | |
6373 setElementDateTime(v); | |
6374 continue; | |
6375 } | |
6376 if (tag == QLatin1String("pointf")) { | |
6377 DomPointF *v = new DomPointF(); | |
6378 v->read(e); | |
6379 setElementPointF(v); | |
6380 continue; | |
6381 } | |
6382 if (tag == QLatin1String("rectf")) { | |
6383 DomRectF *v = new DomRectF(); | |
6384 v->read(e); | |
6385 setElementRectF(v); | |
6386 continue; | |
6387 } | |
6388 if (tag == QLatin1String("sizef")) { | |
6389 DomSizeF *v = new DomSizeF(); | |
6390 v->read(e); | |
6391 setElementSizeF(v); | |
6392 continue; | |
6393 } | |
6394 if (tag == QLatin1String("longlong")) { | |
6395 setElementLongLong(e.text().toLongLong()); | |
6396 continue; | |
6397 } | |
6398 if (tag == QLatin1String("char")) { | |
6399 DomChar *v = new DomChar(); | |
6400 v->read(e); | |
6401 setElementChar(v); | |
6402 continue; | |
6403 } | |
6404 if (tag == QLatin1String("url")) { | |
6405 DomUrl *v = new DomUrl(); | |
6406 v->read(e); | |
6407 setElementUrl(v); | |
6408 continue; | |
6409 } | |
6410 if (tag == QLatin1String("uint")) { | |
6411 setElementUInt(e.text().toUInt()); | |
6412 continue; | |
6413 } | |
6414 if (tag == QLatin1String("ulonglong")) { | |
6415 setElementULongLong(e.text().toULongLong()); | |
6416 continue; | |
6417 } | |
6418 if (tag == QLatin1String("brush")) { | |
6419 DomBrush *v = new DomBrush(); | |
6420 v->read(e); | |
6421 setElementBrush(v); | |
6422 continue; | |
6423 } | |
6424 } | |
6425 | |
6426 m_text.clear(); | |
6427 for (QDomNode child = node.firstChild(); !child.isNull(); child = child.nextSibling()) { | |
6428 if (child.isText()) | |
6429 m_text.append(child.nodeValue()); | |
6430 } | |
6431 } | |
6432 | |
6433 QDomElement DomProperty::write(QDomDocument &doc, const QString &tagName) const | |
6434 { | |
6435 QDomElement e = doc.createElement(tagName.isEmpty() ? QString::fromUtf8("property") : tagName.toLower()); | |
6436 | |
6437 QDomElement child; | |
6438 | |
6439 if (hasAttributeName()) | |
6440 e.setAttribute(QLatin1String("name"), attributeName()); | |
6441 | |
6442 if (hasAttributeStdset()) | |
6443 e.setAttribute(QLatin1String("stdset"), attributeStdset()); | |
6444 | |
6445 switch(kind()) { | |
6446 case Bool: { | |
6447 QDomElement child = doc.createElement(QLatin1String("bool")); | |
6448 QDomText text = doc.createTextNode(elementBool()); | |
6449 child.appendChild(text); | |
6450 e.appendChild(child); | |
6451 break; | |
6452 } | |
6453 case Color: { | |
6454 DomColor* v = elementColor(); | |
6455 if (v != 0) { | |
6456 QDomElement child = v->write(doc, QLatin1String("color")); | |
6457 e.appendChild(child); | |
6458 } | |
6459 break; | |
6460 } | |
6461 case Cstring: { | |
6462 QDomElement child = doc.createElement(QLatin1String("cstring")); | |
6463 QDomText text = doc.createTextNode(elementCstring()); | |
6464 child.appendChild(text); | |
6465 e.appendChild(child); | |
6466 break; | |
6467 } | |
6468 case Cursor: { | |
6469 QDomElement child = doc.createElement(QLatin1String("cursor")); | |
6470 QDomText text = doc.createTextNode(QString::number(elementCursor())); | |
6471 child.appendChild(text); | |
6472 e.appendChild(child); | |
6473 break; | |
6474 } | |
6475 case CursorShape: { | |
6476 QDomElement child = doc.createElement(QLatin1String("cursorShape")); | |
6477 QDomText text = doc.createTextNode(elementCursorShape()); | |
6478 child.appendChild(text); | |
6479 e.appendChild(child); | |
6480 break; | |
6481 } | |
6482 case Enum: { | |
6483 QDomElement child = doc.createElement(QLatin1String("enum")); | |
6484 QDomText text = doc.createTextNode(elementEnum()); | |
6485 child.appendChild(text); | |
6486 e.appendChild(child); | |
6487 break; | |
6488 } | |
6489 case Font: { | |
6490 DomFont* v = elementFont(); | |
6491 if (v != 0) { | |
6492 QDomElement child = v->write(doc, QLatin1String("font")); | |
6493 e.appendChild(child); | |
6494 } | |
6495 break; | |
6496 } | |
6497 case IconSet: { | |
6498 DomResourceIcon* v = elementIconSet(); | |
6499 if (v != 0) { | |
6500 QDomElement child = v->write(doc, QLatin1String("iconset")); | |
6501 e.appendChild(child); | |
6502 } | |
6503 break; | |
6504 } | |
6505 case Pixmap: { | |
6506 DomResourcePixmap* v = elementPixmap(); | |
6507 if (v != 0) { | |
6508 QDomElement child = v->write(doc, QLatin1String("pixmap")); | |
6509 e.appendChild(child); | |
6510 } | |
6511 break; | |
6512 } | |
6513 case Palette: { | |
6514 DomPalette* v = elementPalette(); | |
6515 if (v != 0) { | |
6516 QDomElement child = v->write(doc, QLatin1String("palette")); | |
6517 e.appendChild(child); | |
6518 } | |
6519 break; | |
6520 } | |
6521 case Point: { | |
6522 DomPoint* v = elementPoint(); | |
6523 if (v != 0) { | |
6524 QDomElement child = v->write(doc, QLatin1String("point")); | |
6525 e.appendChild(child); | |
6526 } | |
6527 break; | |
6528 } | |
6529 case Rect: { | |
6530 DomRect* v = elementRect(); | |
6531 if (v != 0) { | |
6532 QDomElement child = v->write(doc, QLatin1String("rect")); | |
6533 e.appendChild(child); | |
6534 } | |
6535 break; | |
6536 } | |
6537 case Set: { | |
6538 QDomElement child = doc.createElement(QLatin1String("set")); | |
6539 QDomText text = doc.createTextNode(elementSet()); | |
6540 child.appendChild(text); | |
6541 e.appendChild(child); | |
6542 break; | |
6543 } | |
6544 case Locale: { | |
6545 DomLocale* v = elementLocale(); | |
6546 if (v != 0) { | |
6547 QDomElement child = v->write(doc, QLatin1String("locale")); | |
6548 e.appendChild(child); | |
6549 } | |
6550 break; | |
6551 } | |
6552 case SizePolicy: { | |
6553 DomSizePolicy* v = elementSizePolicy(); | |
6554 if (v != 0) { | |
6555 QDomElement child = v->write(doc, QLatin1String("sizepolicy")); | |
6556 e.appendChild(child); | |
6557 } | |
6558 break; | |
6559 } | |
6560 case Size: { | |
6561 DomSize* v = elementSize(); | |
6562 if (v != 0) { | |
6563 QDomElement child = v->write(doc, QLatin1String("size")); | |
6564 e.appendChild(child); | |
6565 } | |
6566 break; | |
6567 } | |
6568 case String: { | |
6569 DomString* v = elementString(); | |
6570 if (v != 0) { | |
6571 QDomElement child = v->write(doc, QLatin1String("string")); | |
6572 e.appendChild(child); | |
6573 } | |
6574 break; | |
6575 } | |
6576 case StringList: { | |
6577 DomStringList* v = elementStringList(); | |
6578 if (v != 0) { | |
6579 QDomElement child = v->write(doc, QLatin1String("stringlist")); | |
6580 e.appendChild(child); | |
6581 } | |
6582 break; | |
6583 } | |
6584 case Number: { | |
6585 QDomElement child = doc.createElement(QLatin1String("number")); | |
6586 QDomText text = doc.createTextNode(QString::number(elementNumber())); | |
6587 child.appendChild(text); | |
6588 e.appendChild(child); | |
6589 break; | |
6590 } | |
6591 case Float: { | |
6592 QDomElement child = doc.createElement(QLatin1String("float")); | |
6593 QDomText text = doc.createTextNode(QString::number(elementFloat(), 'f', 8)); | |
6594 child.appendChild(text); | |
6595 e.appendChild(child); | |
6596 break; | |
6597 } | |
6598 case Double: { | |
6599 QDomElement child = doc.createElement(QLatin1String("double")); | |
6600 QDomText text = doc.createTextNode(QString::number(elementDouble(), 'f', 15)); | |
6601 child.appendChild(text); | |
6602 e.appendChild(child); | |
6603 break; | |
6604 } | |
6605 case Date: { | |
6606 DomDate* v = elementDate(); | |
6607 if (v != 0) { | |
6608 QDomElement child = v->write(doc, QLatin1String("date")); | |
6609 e.appendChild(child); | |
6610 } | |
6611 break; | |
6612 } | |
6613 case Time: { | |
6614 DomTime* v = elementTime(); | |
6615 if (v != 0) { | |
6616 QDomElement child = v->write(doc, QLatin1String("time")); | |
6617 e.appendChild(child); | |
6618 } | |
6619 break; | |
6620 } | |
6621 case DateTime: { | |
6622 DomDateTime* v = elementDateTime(); | |
6623 if (v != 0) { | |
6624 QDomElement child = v->write(doc, QLatin1String("datetime")); | |
6625 e.appendChild(child); | |
6626 } | |
6627 break; | |
6628 } | |
6629 case PointF: { | |
6630 DomPointF* v = elementPointF(); | |
6631 if (v != 0) { | |
6632 QDomElement child = v->write(doc, QLatin1String("pointf")); | |
6633 e.appendChild(child); | |
6634 } | |
6635 break; | |
6636 } | |
6637 case RectF: { | |
6638 DomRectF* v = elementRectF(); | |
6639 if (v != 0) { | |
6640 QDomElement child = v->write(doc, QLatin1String("rectf")); | |
6641 e.appendChild(child); | |
6642 } | |
6643 break; | |
6644 } | |
6645 case SizeF: { | |
6646 DomSizeF* v = elementSizeF(); | |
6647 if (v != 0) { | |
6648 QDomElement child = v->write(doc, QLatin1String("sizef")); | |
6649 e.appendChild(child); | |
6650 } | |
6651 break; | |
6652 } | |
6653 case LongLong: { | |
6654 QDomElement child = doc.createElement(QLatin1String("longLong")); | |
6655 QDomText text = doc.createTextNode(QString::number(elementLongLong())); | |
6656 child.appendChild(text); | |
6657 e.appendChild(child); | |
6658 break; | |
6659 } | |
6660 case Char: { | |
6661 DomChar* v = elementChar(); | |
6662 if (v != 0) { | |
6663 QDomElement child = v->write(doc, QLatin1String("char")); | |
6664 e.appendChild(child); | |
6665 } | |
6666 break; | |
6667 } | |
6668 case Url: { | |
6669 DomUrl* v = elementUrl(); | |
6670 if (v != 0) { | |
6671 QDomElement child = v->write(doc, QLatin1String("url")); | |
6672 e.appendChild(child); | |
6673 } | |
6674 break; | |
6675 } | |
6676 case UInt: { | |
6677 QDomElement child = doc.createElement(QLatin1String("uInt")); | |
6678 QDomText text = doc.createTextNode(QString::number(elementUInt())); | |
6679 child.appendChild(text); | |
6680 e.appendChild(child); | |
6681 break; | |
6682 } | |
6683 case ULongLong: { | |
6684 QDomElement child = doc.createElement(QLatin1String("uLongLong")); | |
6685 QDomText text = doc.createTextNode(QString::number(elementULongLong())); | |
6686 child.appendChild(text); | |
6687 e.appendChild(child); | |
6688 break; | |
6689 } | |
6690 case Brush: { | |
6691 DomBrush* v = elementBrush(); | |
6692 if (v != 0) { | |
6693 QDomElement child = v->write(doc, QLatin1String("brush")); | |
6694 e.appendChild(child); | |
6695 } | |
6696 break; | |
6697 } | |
6698 default: | |
6699 break; | |
6700 } | |
6701 if (!m_text.isEmpty()) | |
6702 e.appendChild(doc.createTextNode(m_text)); | |
6703 | |
6704 return e; | |
6705 } | |
6706 | |
6707 void DomProperty::setElementBool(const QString& a) | |
6708 { | |
6709 clear(false); | |
6710 m_kind = Bool; | |
6711 m_bool = a; | |
6712 } | |
6713 | |
6714 void DomProperty::setElementColor(DomColor* a) | |
6715 { | |
6716 clear(false); | |
6717 m_kind = Color; | |
6718 m_color = a; | |
6719 } | |
6720 | |
6721 void DomProperty::setElementCstring(const QString& a) | |
6722 { | |
6723 clear(false); | |
6724 m_kind = Cstring; | |
6725 m_cstring = a; | |
6726 } | |
6727 | |
6728 void DomProperty::setElementCursor(int a) | |
6729 { | |
6730 clear(false); | |
6731 m_kind = Cursor; | |
6732 m_cursor = a; | |
6733 } | |
6734 | |
6735 void DomProperty::setElementCursorShape(const QString& a) | |
6736 { | |
6737 clear(false); | |
6738 m_kind = CursorShape; | |
6739 m_cursorShape = a; | |
6740 } | |
6741 | |
6742 void DomProperty::setElementEnum(const QString& a) | |
6743 { | |
6744 clear(false); | |
6745 m_kind = Enum; | |
6746 m_enum = a; | |
6747 } | |
6748 | |
6749 void DomProperty::setElementFont(DomFont* a) | |
6750 { | |
6751 clear(false); | |
6752 m_kind = Font; | |
6753 m_font = a; | |
6754 } | |
6755 | |
6756 void DomProperty::setElementIconSet(DomResourceIcon* a) | |
6757 { | |
6758 clear(false); | |
6759 m_kind = IconSet; | |
6760 m_iconSet = a; | |
6761 } | |
6762 | |
6763 void DomProperty::setElementPixmap(DomResourcePixmap* a) | |
6764 { | |
6765 clear(false); | |
6766 m_kind = Pixmap; | |
6767 m_pixmap = a; | |
6768 } | |
6769 | |
6770 void DomProperty::setElementPalette(DomPalette* a) | |
6771 { | |
6772 clear(false); | |
6773 m_kind = Palette; | |
6774 m_palette = a; | |
6775 } | |
6776 | |
6777 void DomProperty::setElementPoint(DomPoint* a) | |
6778 { | |
6779 clear(false); | |
6780 m_kind = Point; | |
6781 m_point = a; | |
6782 } | |
6783 | |
6784 void DomProperty::setElementRect(DomRect* a) | |
6785 { | |
6786 clear(false); | |
6787 m_kind = Rect; | |
6788 m_rect = a; | |
6789 } | |
6790 | |
6791 void DomProperty::setElementSet(const QString& a) | |
6792 { | |
6793 clear(false); | |
6794 m_kind = Set; | |
6795 m_set = a; | |
6796 } | |
6797 | |
6798 void DomProperty::setElementLocale(DomLocale* a) | |
6799 { | |
6800 clear(false); | |
6801 m_kind = Locale; | |
6802 m_locale = a; | |
6803 } | |
6804 | |
6805 void DomProperty::setElementSizePolicy(DomSizePolicy* a) | |
6806 { | |
6807 clear(false); | |
6808 m_kind = SizePolicy; | |
6809 m_sizePolicy = a; | |
6810 } | |
6811 | |
6812 void DomProperty::setElementSize(DomSize* a) | |
6813 { | |
6814 clear(false); | |
6815 m_kind = Size; | |
6816 m_size = a; | |
6817 } | |
6818 | |
6819 void DomProperty::setElementString(DomString* a) | |
6820 { | |
6821 clear(false); | |
6822 m_kind = String; | |
6823 m_string = a; | |
6824 } | |
6825 | |
6826 void DomProperty::setElementStringList(DomStringList* a) | |
6827 { | |
6828 clear(false); | |
6829 m_kind = StringList; | |
6830 m_stringList = a; | |
6831 } | |
6832 | |
6833 void DomProperty::setElementNumber(int a) | |
6834 { | |
6835 clear(false); | |
6836 m_kind = Number; | |
6837 m_number = a; | |
6838 } | |
6839 | |
6840 void DomProperty::setElementFloat(float a) | |
6841 { | |
6842 clear(false); | |
6843 m_kind = Float; | |
6844 m_float = a; | |
6845 } | |
6846 | |
6847 void DomProperty::setElementDouble(double a) | |
6848 { | |
6849 clear(false); | |
6850 m_kind = Double; | |
6851 m_double = a; | |
6852 } | |
6853 | |
6854 void DomProperty::setElementDate(DomDate* a) | |
6855 { | |
6856 clear(false); | |
6857 m_kind = Date; | |
6858 m_date = a; | |
6859 } | |
6860 | |
6861 void DomProperty::setElementTime(DomTime* a) | |
6862 { | |
6863 clear(false); | |
6864 m_kind = Time; | |
6865 m_time = a; | |
6866 } | |
6867 | |
6868 void DomProperty::setElementDateTime(DomDateTime* a) | |
6869 { | |
6870 clear(false); | |
6871 m_kind = DateTime; | |
6872 m_dateTime = a; | |
6873 } | |
6874 | |
6875 void DomProperty::setElementPointF(DomPointF* a) | |
6876 { | |
6877 clear(false); | |
6878 m_kind = PointF; | |
6879 m_pointF = a; | |
6880 } | |
6881 | |
6882 void DomProperty::setElementRectF(DomRectF* a) | |
6883 { | |
6884 clear(false); | |
6885 m_kind = RectF; | |
6886 m_rectF = a; | |
6887 } | |
6888 | |
6889 void DomProperty::setElementSizeF(DomSizeF* a) | |
6890 { | |
6891 clear(false); | |
6892 m_kind = SizeF; | |
6893 m_sizeF = a; | |
6894 } | |
6895 | |
6896 void DomProperty::setElementLongLong(qlonglong a) | |
6897 { | |
6898 clear(false); | |
6899 m_kind = LongLong; | |
6900 m_longLong = a; | |
6901 } | |
6902 | |
6903 void DomProperty::setElementChar(DomChar* a) | |
6904 { | |
6905 clear(false); | |
6906 m_kind = Char; | |
6907 m_char = a; | |
6908 } | |
6909 | |
6910 void DomProperty::setElementUrl(DomUrl* a) | |
6911 { | |
6912 clear(false); | |
6913 m_kind = Url; | |
6914 m_url = a; | |
6915 } | |
6916 | |
6917 void DomProperty::setElementUInt(uint a) | |
6918 { | |
6919 clear(false); | |
6920 m_kind = UInt; | |
6921 m_uInt = a; | |
6922 } | |
6923 | |
6924 void DomProperty::setElementULongLong(qulonglong a) | |
6925 { | |
6926 clear(false); | |
6927 m_kind = ULongLong; | |
6928 m_uLongLong = a; | |
6929 } | |
6930 | |
6931 void DomProperty::setElementBrush(DomBrush* a) | |
6932 { | |
6933 clear(false); | |
6934 m_kind = Brush; | |
6935 m_brush = a; | |
6936 } | |
6937 | |
6938 void DomConnections::clear(bool clear_all) | |
6939 { | |
6940 for (int i = 0; i < m_connection.size(); ++i) | |
6941 delete m_connection[i]; | |
6942 m_connection.clear(); | |
6943 | |
6944 if (clear_all) { | |
6945 m_text = QString(); | |
6946 } | |
6947 | |
6948 } | |
6949 | |
6950 DomConnections::DomConnections() | |
6951 { | |
6952 } | |
6953 | |
6954 DomConnections::~DomConnections() | |
6955 { | |
6956 for (int i = 0; i < m_connection.size(); ++i) | |
6957 delete m_connection[i]; | |
6958 m_connection.clear(); | |
6959 } | |
6960 | |
6961 void DomConnections::read(const QDomElement &node) | |
6962 { | |
6963 | |
6964 for (QDomNode n = node.firstChild(); !n.isNull(); n = n.nextSibling()) { | |
6965 if (!n.isElement()) | |
6966 continue; | |
6967 QDomElement e = n.toElement(); | |
6968 QString tag = e.tagName().toLower(); | |
6969 if (tag == QLatin1String("connection")) { | |
6970 DomConnection *v = new DomConnection(); | |
6971 v->read(e); | |
6972 m_connection.append(v); | |
6973 continue; | |
6974 } | |
6975 } | |
6976 | |
6977 m_text.clear(); | |
6978 for (QDomNode child = node.firstChild(); !child.isNull(); child = child.nextSibling()) { | |
6979 if (child.isText()) | |
6980 m_text.append(child.nodeValue()); | |
6981 } | |
6982 } | |
6983 | |
6984 QDomElement DomConnections::write(QDomDocument &doc, const QString &tagName) const | |
6985 { | |
6986 QDomElement e = doc.createElement(tagName.isEmpty() ? QString::fromUtf8("connections") : tagName.toLower()); | |
6987 | |
6988 QDomElement child; | |
6989 | |
6990 for (int i = 0; i < m_connection.size(); ++i) { | |
6991 DomConnection* v = m_connection[i]; | |
6992 QDomNode child = v->write(doc, QLatin1String("connection")); | |
6993 e.appendChild(child); | |
6994 } | |
6995 if (!m_text.isEmpty()) | |
6996 e.appendChild(doc.createTextNode(m_text)); | |
6997 | |
6998 return e; | |
6999 } | |
7000 | |
7001 void DomConnections::setElementConnection(const QList<DomConnection*>& a) | |
7002 { | |
7003 m_connection = a; | |
7004 } | |
7005 | |
7006 void DomConnection::clear(bool clear_all) | |
7007 { | |
7008 delete m_hints; | |
7009 | |
7010 if (clear_all) { | |
7011 m_text = QString(); | |
7012 } | |
7013 | |
7014 m_children = 0; | |
7015 m_hints = 0; | |
7016 } | |
7017 | |
7018 DomConnection::DomConnection() | |
7019 { | |
7020 m_children = 0; | |
7021 m_hints = 0; | |
7022 } | |
7023 | |
7024 DomConnection::~DomConnection() | |
7025 { | |
7026 delete m_hints; | |
7027 } | |
7028 | |
7029 void DomConnection::read(const QDomElement &node) | |
7030 { | |
7031 | |
7032 for (QDomNode n = node.firstChild(); !n.isNull(); n = n.nextSibling()) { | |
7033 if (!n.isElement()) | |
7034 continue; | |
7035 QDomElement e = n.toElement(); | |
7036 QString tag = e.tagName().toLower(); | |
7037 if (tag == QLatin1String("sender")) { | |
7038 setElementSender(e.text()); | |
7039 continue; | |
7040 } | |
7041 if (tag == QLatin1String("signal")) { | |
7042 setElementSignal(e.text()); | |
7043 continue; | |
7044 } | |
7045 if (tag == QLatin1String("receiver")) { | |
7046 setElementReceiver(e.text()); | |
7047 continue; | |
7048 } | |
7049 if (tag == QLatin1String("slot")) { | |
7050 setElementSlot(e.text()); | |
7051 continue; | |
7052 } | |
7053 if (tag == QLatin1String("hints")) { | |
7054 DomConnectionHints *v = new DomConnectionHints(); | |
7055 v->read(e); | |
7056 setElementHints(v); | |
7057 continue; | |
7058 } | |
7059 } | |
7060 | |
7061 m_text.clear(); | |
7062 for (QDomNode child = node.firstChild(); !child.isNull(); child = child.nextSibling()) { | |
7063 if (child.isText()) | |
7064 m_text.append(child.nodeValue()); | |
7065 } | |
7066 } | |
7067 | |
7068 QDomElement DomConnection::write(QDomDocument &doc, const QString &tagName) const | |
7069 { | |
7070 QDomElement e = doc.createElement(tagName.isEmpty() ? QString::fromUtf8("connection") : tagName.toLower()); | |
7071 | |
7072 QDomElement child; | |
7073 | |
7074 if (m_children & Sender) { | |
7075 child = doc.createElement(QLatin1String("sender")); | |
7076 child.appendChild(doc.createTextNode(m_sender)); | |
7077 e.appendChild(child); | |
7078 } | |
7079 | |
7080 if (m_children & Signal) { | |
7081 child = doc.createElement(QLatin1String("signal")); | |
7082 child.appendChild(doc.createTextNode(m_signal)); | |
7083 e.appendChild(child); | |
7084 } | |
7085 | |
7086 if (m_children & Receiver) { | |
7087 child = doc.createElement(QLatin1String("receiver")); | |
7088 child.appendChild(doc.createTextNode(m_receiver)); | |
7089 e.appendChild(child); | |
7090 } | |
7091 | |
7092 if (m_children & Slot) { | |
7093 child = doc.createElement(QLatin1String("slot")); | |
7094 child.appendChild(doc.createTextNode(m_slot)); | |
7095 e.appendChild(child); | |
7096 } | |
7097 | |
7098 if (m_children & Hints) { | |
7099 e.appendChild(m_hints->write(doc, QLatin1String("hints"))); | |
7100 } | |
7101 | |
7102 if (!m_text.isEmpty()) | |
7103 e.appendChild(doc.createTextNode(m_text)); | |
7104 | |
7105 return e; | |
7106 } | |
7107 | |
7108 void DomConnection::setElementSender(const QString& a) | |
7109 { | |
7110 m_children |= Sender; | |
7111 m_sender = a; | |
7112 } | |
7113 | |
7114 void DomConnection::setElementSignal(const QString& a) | |
7115 { | |
7116 m_children |= Signal; | |
7117 m_signal = a; | |
7118 } | |
7119 | |
7120 void DomConnection::setElementReceiver(const QString& a) | |
7121 { | |
7122 m_children |= Receiver; | |
7123 m_receiver = a; | |
7124 } | |
7125 | |
7126 void DomConnection::setElementSlot(const QString& a) | |
7127 { | |
7128 m_children |= Slot; | |
7129 m_slot = a; | |
7130 } | |
7131 | |
7132 void DomConnection::setElementHints(DomConnectionHints* a) | |
7133 { | |
7134 delete m_hints; | |
7135 m_children |= Hints; | |
7136 m_hints = a; | |
7137 } | |
7138 | |
7139 void DomConnection::clearElementSender() | |
7140 { | |
7141 m_children &= ~Sender; | |
7142 } | |
7143 | |
7144 void DomConnection::clearElementSignal() | |
7145 { | |
7146 m_children &= ~Signal; | |
7147 } | |
7148 | |
7149 void DomConnection::clearElementReceiver() | |
7150 { | |
7151 m_children &= ~Receiver; | |
7152 } | |
7153 | |
7154 void DomConnection::clearElementSlot() | |
7155 { | |
7156 m_children &= ~Slot; | |
7157 } | |
7158 | |
7159 void DomConnection::clearElementHints() | |
7160 { | |
7161 delete m_hints; | |
7162 m_hints = 0; | |
7163 m_children &= ~Hints; | |
7164 } | |
7165 | |
7166 void DomConnectionHints::clear(bool clear_all) | |
7167 { | |
7168 for (int i = 0; i < m_hint.size(); ++i) | |
7169 delete m_hint[i]; | |
7170 m_hint.clear(); | |
7171 | |
7172 if (clear_all) { | |
7173 m_text = QString(); | |
7174 } | |
7175 | |
7176 } | |
7177 | |
7178 DomConnectionHints::DomConnectionHints() | |
7179 { | |
7180 } | |
7181 | |
7182 DomConnectionHints::~DomConnectionHints() | |
7183 { | |
7184 for (int i = 0; i < m_hint.size(); ++i) | |
7185 delete m_hint[i]; | |
7186 m_hint.clear(); | |
7187 } | |
7188 | |
7189 void DomConnectionHints::read(const QDomElement &node) | |
7190 { | |
7191 | |
7192 for (QDomNode n = node.firstChild(); !n.isNull(); n = n.nextSibling()) { | |
7193 if (!n.isElement()) | |
7194 continue; | |
7195 QDomElement e = n.toElement(); | |
7196 QString tag = e.tagName().toLower(); | |
7197 if (tag == QLatin1String("hint")) { | |
7198 DomConnectionHint *v = new DomConnectionHint(); | |
7199 v->read(e); | |
7200 m_hint.append(v); | |
7201 continue; | |
7202 } | |
7203 } | |
7204 | |
7205 m_text.clear(); | |
7206 for (QDomNode child = node.firstChild(); !child.isNull(); child = child.nextSibling()) { | |
7207 if (child.isText()) | |
7208 m_text.append(child.nodeValue()); | |
7209 } | |
7210 } | |
7211 | |
7212 QDomElement DomConnectionHints::write(QDomDocument &doc, const QString &tagName) const | |
7213 { | |
7214 QDomElement e = doc.createElement(tagName.isEmpty() ? QString::fromUtf8("connectionhints") : tagName.toLower()); | |
7215 | |
7216 QDomElement child; | |
7217 | |
7218 for (int i = 0; i < m_hint.size(); ++i) { | |
7219 DomConnectionHint* v = m_hint[i]; | |
7220 QDomNode child = v->write(doc, QLatin1String("hint")); | |
7221 e.appendChild(child); | |
7222 } | |
7223 if (!m_text.isEmpty()) | |
7224 e.appendChild(doc.createTextNode(m_text)); | |
7225 | |
7226 return e; | |
7227 } | |
7228 | |
7229 void DomConnectionHints::setElementHint(const QList<DomConnectionHint*>& a) | |
7230 { | |
7231 m_hint = a; | |
7232 } | |
7233 | |
7234 void DomConnectionHint::clear(bool clear_all) | |
7235 { | |
7236 | |
7237 if (clear_all) { | |
7238 m_text = QString(); | |
7239 m_has_attr_type = false; | |
7240 } | |
7241 | |
7242 m_children = 0; | |
7243 m_x = 0; | |
7244 m_y = 0; | |
7245 } | |
7246 | |
7247 DomConnectionHint::DomConnectionHint() | |
7248 { | |
7249 m_children = 0; | |
7250 m_has_attr_type = false; | |
7251 m_x = 0; | |
7252 m_y = 0; | |
7253 } | |
7254 | |
7255 DomConnectionHint::~DomConnectionHint() | |
7256 { | |
7257 } | |
7258 | |
7259 void DomConnectionHint::read(const QDomElement &node) | |
7260 { | |
7261 if (node.hasAttribute(QLatin1String("type"))) | |
7262 setAttributeType(node.attribute(QLatin1String("type"))); | |
7263 | |
7264 for (QDomNode n = node.firstChild(); !n.isNull(); n = n.nextSibling()) { | |
7265 if (!n.isElement()) | |
7266 continue; | |
7267 QDomElement e = n.toElement(); | |
7268 QString tag = e.tagName().toLower(); | |
7269 if (tag == QString(QLatin1Char('x'))) { | |
7270 setElementX(e.text().toInt()); | |
7271 continue; | |
7272 } | |
7273 if (tag == QString(QLatin1Char('y'))) { | |
7274 setElementY(e.text().toInt()); | |
7275 continue; | |
7276 } | |
7277 } | |
7278 | |
7279 m_text.clear(); | |
7280 for (QDomNode child = node.firstChild(); !child.isNull(); child = child.nextSibling()) { | |
7281 if (child.isText()) | |
7282 m_text.append(child.nodeValue()); | |
7283 } | |
7284 } | |
7285 | |
7286 QDomElement DomConnectionHint::write(QDomDocument &doc, const QString &tagName) const | |
7287 { | |
7288 QDomElement e = doc.createElement(tagName.isEmpty() ? QString::fromUtf8("connectionhint") : tagName.toLower()); | |
7289 | |
7290 QDomElement child; | |
7291 | |
7292 if (hasAttributeType()) | |
7293 e.setAttribute(QLatin1String("type"), attributeType()); | |
7294 | |
7295 if (m_children & X) { | |
7296 child = doc.createElement(QString(QLatin1Char('x'))); | |
7297 child.appendChild(doc.createTextNode(QString::number(m_x))); | |
7298 e.appendChild(child); | |
7299 } | |
7300 | |
7301 if (m_children & Y) { | |
7302 child = doc.createElement(QString(QLatin1Char('y'))); | |
7303 child.appendChild(doc.createTextNode(QString::number(m_y))); | |
7304 e.appendChild(child); | |
7305 } | |
7306 | |
7307 if (!m_text.isEmpty()) | |
7308 e.appendChild(doc.createTextNode(m_text)); | |
7309 | |
7310 return e; | |
7311 } | |
7312 | |
7313 void DomConnectionHint::setElementX(int a) | |
7314 { | |
7315 m_children |= X; | |
7316 m_x = a; | |
7317 } | |
7318 | |
7319 void DomConnectionHint::setElementY(int a) | |
7320 { | |
7321 m_children |= Y; | |
7322 m_y = a; | |
7323 } | |
7324 | |
7325 void DomConnectionHint::clearElementX() | |
7326 { | |
7327 m_children &= ~X; | |
7328 } | |
7329 | |
7330 void DomConnectionHint::clearElementY() | |
7331 { | |
7332 m_children &= ~Y; | |
7333 } | |
7334 | |
7335 void DomScript::clear(bool clear_all) | |
7336 { | |
7337 | |
7338 if (clear_all) { | |
7339 m_text = QString(); | |
7340 m_has_attr_source = false; | |
7341 m_has_attr_language = false; | |
7342 } | |
7343 | |
7344 } | |
7345 | |
7346 DomScript::DomScript() | |
7347 { | |
7348 m_has_attr_source = false; | |
7349 m_has_attr_language = false; | |
7350 } | |
7351 | |
7352 DomScript::~DomScript() | |
7353 { | |
7354 } | |
7355 | |
7356 void DomScript::read(const QDomElement &node) | |
7357 { | |
7358 if (node.hasAttribute(QLatin1String("source"))) | |
7359 setAttributeSource(node.attribute(QLatin1String("source"))); | |
7360 if (node.hasAttribute(QLatin1String("language"))) | |
7361 setAttributeLanguage(node.attribute(QLatin1String("language"))); | |
7362 | |
7363 for (QDomNode n = node.firstChild(); !n.isNull(); n = n.nextSibling()) { | |
7364 if (!n.isElement()) | |
7365 continue; | |
7366 QDomElement e = n.toElement(); | |
7367 QString tag = e.tagName().toLower(); | |
7368 } | |
7369 | |
7370 m_text.clear(); | |
7371 for (QDomNode child = node.firstChild(); !child.isNull(); child = child.nextSibling()) { | |
7372 if (child.isText()) | |
7373 m_text.append(child.nodeValue()); | |
7374 } | |
7375 } | |
7376 | |
7377 QDomElement DomScript::write(QDomDocument &doc, const QString &tagName) const | |
7378 { | |
7379 QDomElement e = doc.createElement(tagName.isEmpty() ? QString::fromUtf8("script") : tagName.toLower()); | |
7380 | |
7381 QDomElement child; | |
7382 | |
7383 if (hasAttributeSource()) | |
7384 e.setAttribute(QLatin1String("source"), attributeSource()); | |
7385 | |
7386 if (hasAttributeLanguage()) | |
7387 e.setAttribute(QLatin1String("language"), attributeLanguage()); | |
7388 | |
7389 if (!m_text.isEmpty()) | |
7390 e.appendChild(doc.createTextNode(m_text)); | |
7391 | |
7392 return e; | |
7393 } | |
7394 | |
7395 void DomWidgetData::clear(bool clear_all) | |
7396 { | |
7397 for (int i = 0; i < m_property.size(); ++i) | |
7398 delete m_property[i]; | |
7399 m_property.clear(); | |
7400 | |
7401 if (clear_all) { | |
7402 m_text = QString(); | |
7403 } | |
7404 | |
7405 } | |
7406 | |
7407 DomWidgetData::DomWidgetData() | |
7408 { | |
7409 } | |
7410 | |
7411 DomWidgetData::~DomWidgetData() | |
7412 { | |
7413 for (int i = 0; i < m_property.size(); ++i) | |
7414 delete m_property[i]; | |
7415 m_property.clear(); | |
7416 } | |
7417 | |
7418 void DomWidgetData::read(const QDomElement &node) | |
7419 { | |
7420 | |
7421 for (QDomNode n = node.firstChild(); !n.isNull(); n = n.nextSibling()) { | |
7422 if (!n.isElement()) | |
7423 continue; | |
7424 QDomElement e = n.toElement(); | |
7425 QString tag = e.tagName().toLower(); | |
7426 if (tag == QLatin1String("property")) { | |
7427 DomProperty *v = new DomProperty(); | |
7428 v->read(e); | |
7429 m_property.append(v); | |
7430 continue; | |
7431 } | |
7432 } | |
7433 | |
7434 m_text.clear(); | |
7435 for (QDomNode child = node.firstChild(); !child.isNull(); child = child.nextSibling()) { | |
7436 if (child.isText()) | |
7437 m_text.append(child.nodeValue()); | |
7438 } | |
7439 } | |
7440 | |
7441 QDomElement DomWidgetData::write(QDomDocument &doc, const QString &tagName) const | |
7442 { | |
7443 QDomElement e = doc.createElement(tagName.isEmpty() ? QString::fromUtf8("widgetdata") : tagName.toLower()); | |
7444 | |
7445 QDomElement child; | |
7446 | |
7447 for (int i = 0; i < m_property.size(); ++i) { | |
7448 DomProperty* v = m_property[i]; | |
7449 QDomNode child = v->write(doc, QLatin1String("property")); | |
7450 e.appendChild(child); | |
7451 } | |
7452 if (!m_text.isEmpty()) | |
7453 e.appendChild(doc.createTextNode(m_text)); | |
7454 | |
7455 return e; | |
7456 } | |
7457 | |
7458 void DomWidgetData::setElementProperty(const QList<DomProperty*>& a) | |
7459 { | |
7460 m_property = a; | |
7461 } | |
7462 | |
7463 void DomDesignerData::clear(bool clear_all) | |
7464 { | |
7465 for (int i = 0; i < m_property.size(); ++i) | |
7466 delete m_property[i]; | |
7467 m_property.clear(); | |
7468 | |
7469 if (clear_all) { | |
7470 m_text = QString(); | |
7471 } | |
7472 | |
7473 } | |
7474 | |
7475 DomDesignerData::DomDesignerData() | |
7476 { | |
7477 } | |
7478 | |
7479 DomDesignerData::~DomDesignerData() | |
7480 { | |
7481 for (int i = 0; i < m_property.size(); ++i) | |
7482 delete m_property[i]; | |
7483 m_property.clear(); | |
7484 } | |
7485 | |
7486 void DomDesignerData::read(const QDomElement &node) | |
7487 { | |
7488 | |
7489 for (QDomNode n = node.firstChild(); !n.isNull(); n = n.nextSibling()) { | |
7490 if (!n.isElement()) | |
7491 continue; | |
7492 QDomElement e = n.toElement(); | |
7493 QString tag = e.tagName().toLower(); | |
7494 if (tag == QLatin1String("property")) { | |
7495 DomProperty *v = new DomProperty(); | |
7496 v->read(e); | |
7497 m_property.append(v); | |
7498 continue; | |
7499 } | |
7500 } | |
7501 | |
7502 m_text.clear(); | |
7503 for (QDomNode child = node.firstChild(); !child.isNull(); child = child.nextSibling()) { | |
7504 if (child.isText()) | |
7505 m_text.append(child.nodeValue()); | |
7506 } | |
7507 } | |
7508 | |
7509 QDomElement DomDesignerData::write(QDomDocument &doc, const QString &tagName) const | |
7510 { | |
7511 QDomElement e = doc.createElement(tagName.isEmpty() ? QString::fromUtf8("designerdata") : tagName.toLower()); | |
7512 | |
7513 QDomElement child; | |
7514 | |
7515 for (int i = 0; i < m_property.size(); ++i) { | |
7516 DomProperty* v = m_property[i]; | |
7517 QDomNode child = v->write(doc, QLatin1String("property")); | |
7518 e.appendChild(child); | |
7519 } | |
7520 if (!m_text.isEmpty()) | |
7521 e.appendChild(doc.createTextNode(m_text)); | |
7522 | |
7523 return e; | |
7524 } | |
7525 | |
7526 void DomDesignerData::setElementProperty(const QList<DomProperty*>& a) | |
7527 { | |
7528 m_property = a; | |
7529 } | |
7530 | |
7531 void DomSlots::clear(bool clear_all) | |
7532 { | |
7533 m_slot.clear(); | |
7534 m_signal.clear(); | |
7535 | |
7536 if (clear_all) { | |
7537 m_text = QString(); | |
7538 } | |
7539 | |
7540 } | |
7541 | |
7542 DomSlots::DomSlots() | |
7543 { | |
7544 } | |
7545 | |
7546 DomSlots::~DomSlots() | |
7547 { | |
7548 m_slot.clear(); | |
7549 m_signal.clear(); | |
7550 } | |
7551 | |
7552 void DomSlots::read(const QDomElement &node) | |
7553 { | |
7554 | |
7555 for (QDomNode n = node.firstChild(); !n.isNull(); n = n.nextSibling()) { | |
7556 if (!n.isElement()) | |
7557 continue; | |
7558 QDomElement e = n.toElement(); | |
7559 QString tag = e.tagName().toLower(); | |
7560 if (tag == QLatin1String("slot")) { | |
7561 m_slot.append(e.text()); | |
7562 continue; | |
7563 } | |
7564 if (tag == QLatin1String("signal")) { | |
7565 m_signal.append(e.text()); | |
7566 continue; | |
7567 } | |
7568 } | |
7569 | |
7570 m_text.clear(); | |
7571 for (QDomNode child = node.firstChild(); !child.isNull(); child = child.nextSibling()) { | |
7572 if (child.isText()) | |
7573 m_text.append(child.nodeValue()); | |
7574 } | |
7575 } | |
7576 | |
7577 QDomElement DomSlots::write(QDomDocument &doc, const QString &tagName) const | |
7578 { | |
7579 QDomElement e = doc.createElement(tagName.isEmpty() ? QString::fromUtf8("slots") : tagName.toLower()); | |
7580 | |
7581 QDomElement child; | |
7582 | |
7583 for (int i = 0; i < m_slot.size(); ++i) { | |
7584 QString v = m_slot[i]; | |
7585 QDomNode child = doc.createElement(QLatin1String("slot")); | |
7586 child.appendChild(doc.createTextNode(v)); | |
7587 e.appendChild(child); | |
7588 } | |
7589 for (int i = 0; i < m_signal.size(); ++i) { | |
7590 QString v = m_signal[i]; | |
7591 QDomNode child = doc.createElement(QLatin1String("signal")); | |
7592 child.appendChild(doc.createTextNode(v)); | |
7593 e.appendChild(child); | |
7594 } | |
7595 if (!m_text.isEmpty()) | |
7596 e.appendChild(doc.createTextNode(m_text)); | |
7597 | |
7598 return e; | |
7599 } | |
7600 | |
7601 void DomSlots::setElementSlot(const QStringList& a) | |
7602 { | |
7603 m_slot = a; | |
7604 } | |
7605 | |
7606 void DomSlots::setElementSignal(const QStringList& a) | |
7607 { | |
7608 m_signal = a; | |
7609 } | |
7610 | |
7611 QT_END_NAMESPACE | |
7612 |