author | Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> |
Fri, 19 Feb 2010 23:40:16 +0200 | |
branch | RCL_3 |
changeset 4 | 3b1da2848fc7 |
parent 0 | 1918ee327afb |
permissions | -rw-r--r-- |
0 | 1 |
/**************************************************************************** |
2 |
** |
|
4
3b1da2848fc7
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
3 |
** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). |
0 | 4 |
** All rights reserved. |
5 |
** Contact: Nokia Corporation (qt-info@nokia.com) |
|
6 |
** |
|
7 |
** This file is part of the tools applications of the Qt Toolkit. |
|
8 |
** |
|
9 |
** $QT_BEGIN_LICENSE:LGPL$ |
|
10 |
** No Commercial Usage |
|
11 |
** This file contains pre-release code and may not be distributed. |
|
12 |
** You may use this file in accordance with the terms and conditions |
|
13 |
** contained in the Technology Preview License Agreement accompanying |
|
14 |
** this package. |
|
15 |
** |
|
16 |
** GNU Lesser General Public License Usage |
|
17 |
** Alternatively, this file may be used under the terms of the GNU Lesser |
|
18 |
** General Public License version 2.1 as published by the Free Software |
|
19 |
** Foundation and appearing in the file LICENSE.LGPL included in the |
|
20 |
** packaging of this file. Please review the following information to |
|
21 |
** ensure the GNU Lesser General Public License version 2.1 requirements |
|
22 |
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. |
|
23 |
** |
|
24 |
** In addition, as a special exception, Nokia gives you certain additional |
|
25 |
** rights. These rights are described in the Nokia Qt LGPL Exception |
|
26 |
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. |
|
27 |
** |
|
28 |
** If you have questions regarding the use of this file, please contact |
|
29 |
** Nokia at qt-info@nokia.com. |
|
30 |
** |
|
31 |
** |
|
32 |
** |
|
33 |
** |
|
34 |
** |
|
35 |
** |
|
36 |
** |
|
37 |
** |
|
38 |
** $QT_END_LICENSE$ |
|
39 |
** |
|
40 |
****************************************************************************/ |
|
41 |
#include "ui4.h" |
|
42 |
||
43 |
#ifdef QUILOADER_QDOM_READ |
|
44 |
#include <QtXml/QDomElement> |
|
45 |
#endif |
|
46 |
||
47 |
QT_BEGIN_NAMESPACE |
|
48 |
#ifdef QFORMINTERNAL_NAMESPACE |
|
49 |
using namespace QFormInternal; |
|
50 |
#endif |
|
51 |
||
52 |
/******************************************************************************* |
|
53 |
** Implementations |
|
54 |
*/ |
|
55 |
||
56 |
void DomUI::clear(bool clear_all) |
|
57 |
{ |
|
58 |
delete m_widget; |
|
59 |
delete m_layoutDefault; |
|
60 |
delete m_layoutFunction; |
|
61 |
delete m_customWidgets; |
|
62 |
delete m_tabStops; |
|
63 |
delete m_images; |
|
64 |
delete m_includes; |
|
65 |
delete m_resources; |
|
66 |
delete m_connections; |
|
67 |
delete m_designerdata; |
|
68 |
delete m_slots; |
|
69 |
delete m_buttonGroups; |
|
70 |
||
71 |
if (clear_all) { |
|
72 |
m_text.clear(); |
|
73 |
m_has_attr_version = false; |
|
74 |
m_has_attr_language = false; |
|
75 |
m_has_attr_displayname = false; |
|
76 |
m_has_attr_stdsetdef = false; |
|
77 |
m_attr_stdsetdef = 0; |
|
78 |
m_has_attr_stdSetDef = false; |
|
79 |
m_attr_stdSetDef = 0; |
|
80 |
} |
|
81 |
||
82 |
m_children = 0; |
|
83 |
m_widget = 0; |
|
84 |
m_layoutDefault = 0; |
|
85 |
m_layoutFunction = 0; |
|
86 |
m_customWidgets = 0; |
|
87 |
m_tabStops = 0; |
|
88 |
m_images = 0; |
|
89 |
m_includes = 0; |
|
90 |
m_resources = 0; |
|
91 |
m_connections = 0; |
|
92 |
m_designerdata = 0; |
|
93 |
m_slots = 0; |
|
94 |
m_buttonGroups = 0; |
|
95 |
} |
|
96 |
||
97 |
DomUI::DomUI() |
|
98 |
{ |
|
99 |
m_children = 0; |
|
100 |
m_has_attr_version = false; |
|
101 |
m_has_attr_language = false; |
|
102 |
m_has_attr_displayname = false; |
|
103 |
m_has_attr_stdsetdef = false; |
|
104 |
m_attr_stdsetdef = 0; |
|
105 |
m_has_attr_stdSetDef = false; |
|
106 |
m_attr_stdSetDef = 0; |
|
107 |
m_widget = 0; |
|
108 |
m_layoutDefault = 0; |
|
109 |
m_layoutFunction = 0; |
|
110 |
m_customWidgets = 0; |
|
111 |
m_tabStops = 0; |
|
112 |
m_images = 0; |
|
113 |
m_includes = 0; |
|
114 |
m_resources = 0; |
|
115 |
m_connections = 0; |
|
116 |
m_designerdata = 0; |
|
117 |
m_slots = 0; |
|
118 |
m_buttonGroups = 0; |
|
119 |
} |
|
120 |
||
121 |
DomUI::~DomUI() |
|
122 |
{ |
|
123 |
delete m_widget; |
|
124 |
delete m_layoutDefault; |
|
125 |
delete m_layoutFunction; |
|
126 |
delete m_customWidgets; |
|
127 |
delete m_tabStops; |
|
128 |
delete m_images; |
|
129 |
delete m_includes; |
|
130 |
delete m_resources; |
|
131 |
delete m_connections; |
|
132 |
delete m_designerdata; |
|
133 |
delete m_slots; |
|
134 |
delete m_buttonGroups; |
|
135 |
} |
|
136 |
||
137 |
void DomUI::read(QXmlStreamReader &reader) |
|
138 |
{ |
|
139 |
||
140 |
foreach (const QXmlStreamAttribute &attribute, reader.attributes()) { |
|
141 |
QStringRef name = attribute.name(); |
|
142 |
if (name == QLatin1String("version")) { |
|
143 |
setAttributeVersion(attribute.value().toString()); |
|
144 |
continue; |
|
145 |
} |
|
146 |
if (name == QLatin1String("language")) { |
|
147 |
setAttributeLanguage(attribute.value().toString()); |
|
148 |
continue; |
|
149 |
} |
|
150 |
if (name == QLatin1String("displayname")) { |
|
151 |
setAttributeDisplayname(attribute.value().toString()); |
|
152 |
continue; |
|
153 |
} |
|
154 |
if (name == QLatin1String("stdsetdef")) { |
|
155 |
setAttributeStdsetdef(attribute.value().toString().toInt()); |
|
156 |
continue; |
|
157 |
} |
|
158 |
if (name == QLatin1String("stdSetDef")) { |
|
159 |
setAttributeStdSetDef(attribute.value().toString().toInt()); |
|
160 |
continue; |
|
161 |
} |
|
162 |
reader.raiseError(QLatin1String("Unexpected attribute ") + name.toString()); |
|
163 |
} |
|
164 |
||
165 |
for (bool finished = false; !finished && !reader.hasError();) { |
|
166 |
switch (reader.readNext()) { |
|
167 |
case QXmlStreamReader::StartElement : { |
|
168 |
const QString tag = reader.name().toString().toLower(); |
|
169 |
if (tag == QLatin1String("author")) { |
|
170 |
setElementAuthor(reader.readElementText()); |
|
171 |
continue; |
|
172 |
} |
|
173 |
if (tag == QLatin1String("comment")) { |
|
174 |
setElementComment(reader.readElementText()); |
|
175 |
continue; |
|
176 |
} |
|
177 |
if (tag == QLatin1String("exportmacro")) { |
|
178 |
setElementExportMacro(reader.readElementText()); |
|
179 |
continue; |
|
180 |
} |
|
181 |
if (tag == QLatin1String("class")) { |
|
182 |
setElementClass(reader.readElementText()); |
|
183 |
continue; |
|
184 |
} |
|
185 |
if (tag == QLatin1String("widget")) { |
|
186 |
DomWidget *v = new DomWidget(); |
|
187 |
v->read(reader); |
|
188 |
setElementWidget(v); |
|
189 |
continue; |
|
190 |
} |
|
191 |
if (tag == QLatin1String("layoutdefault")) { |
|
192 |
DomLayoutDefault *v = new DomLayoutDefault(); |
|
193 |
v->read(reader); |
|
194 |
setElementLayoutDefault(v); |
|
195 |
continue; |
|
196 |
} |
|
197 |
if (tag == QLatin1String("layoutfunction")) { |
|
198 |
DomLayoutFunction *v = new DomLayoutFunction(); |
|
199 |
v->read(reader); |
|
200 |
setElementLayoutFunction(v); |
|
201 |
continue; |
|
202 |
} |
|
203 |
if (tag == QLatin1String("pixmapfunction")) { |
|
204 |
setElementPixmapFunction(reader.readElementText()); |
|
205 |
continue; |
|
206 |
} |
|
207 |
if (tag == QLatin1String("customwidgets")) { |
|
208 |
DomCustomWidgets *v = new DomCustomWidgets(); |
|
209 |
v->read(reader); |
|
210 |
setElementCustomWidgets(v); |
|
211 |
continue; |
|
212 |
} |
|
213 |
if (tag == QLatin1String("tabstops")) { |
|
214 |
DomTabStops *v = new DomTabStops(); |
|
215 |
v->read(reader); |
|
216 |
setElementTabStops(v); |
|
217 |
continue; |
|
218 |
} |
|
219 |
if (tag == QLatin1String("images")) { |
|
220 |
DomImages *v = new DomImages(); |
|
221 |
v->read(reader); |
|
222 |
setElementImages(v); |
|
223 |
continue; |
|
224 |
} |
|
225 |
if (tag == QLatin1String("includes")) { |
|
226 |
DomIncludes *v = new DomIncludes(); |
|
227 |
v->read(reader); |
|
228 |
setElementIncludes(v); |
|
229 |
continue; |
|
230 |
} |
|
231 |
if (tag == QLatin1String("resources")) { |
|
232 |
DomResources *v = new DomResources(); |
|
233 |
v->read(reader); |
|
234 |
setElementResources(v); |
|
235 |
continue; |
|
236 |
} |
|
237 |
if (tag == QLatin1String("connections")) { |
|
238 |
DomConnections *v = new DomConnections(); |
|
239 |
v->read(reader); |
|
240 |
setElementConnections(v); |
|
241 |
continue; |
|
242 |
} |
|
243 |
if (tag == QLatin1String("designerdata")) { |
|
244 |
DomDesignerData *v = new DomDesignerData(); |
|
245 |
v->read(reader); |
|
246 |
setElementDesignerdata(v); |
|
247 |
continue; |
|
248 |
} |
|
249 |
if (tag == QLatin1String("slots")) { |
|
250 |
DomSlots *v = new DomSlots(); |
|
251 |
v->read(reader); |
|
252 |
setElementSlots(v); |
|
253 |
continue; |
|
254 |
} |
|
255 |
if (tag == QLatin1String("buttongroups")) { |
|
256 |
DomButtonGroups *v = new DomButtonGroups(); |
|
257 |
v->read(reader); |
|
258 |
setElementButtonGroups(v); |
|
259 |
continue; |
|
260 |
} |
|
261 |
reader.raiseError(QLatin1String("Unexpected element ") + tag); |
|
262 |
} |
|
263 |
break; |
|
264 |
case QXmlStreamReader::EndElement : |
|
265 |
finished = true; |
|
266 |
break; |
|
267 |
case QXmlStreamReader::Characters : |
|
268 |
if (!reader.isWhitespace()) |
|
269 |
m_text.append(reader.text().toString()); |
|
270 |
break; |
|
271 |
default : |
|
272 |
break; |
|
273 |
} |
|
274 |
} |
|
275 |
} |
|
276 |
||
277 |
#ifdef QUILOADER_QDOM_READ |
|
278 |
void DomUI::read(const QDomElement &node) |
|
279 |
{ |
|
280 |
if (node.hasAttribute(QLatin1String("version"))) |
|
281 |
setAttributeVersion(node.attribute(QLatin1String("version"))); |
|
282 |
if (node.hasAttribute(QLatin1String("language"))) |
|
283 |
setAttributeLanguage(node.attribute(QLatin1String("language"))); |
|
284 |
if (node.hasAttribute(QLatin1String("displayname"))) |
|
285 |
setAttributeDisplayname(node.attribute(QLatin1String("displayname"))); |
|
286 |
if (node.hasAttribute(QLatin1String("stdsetdef"))) |
|
287 |
setAttributeStdsetdef(node.attribute(QLatin1String("stdsetdef")).toInt()); |
|
288 |
if (node.hasAttribute(QLatin1String("stdSetDef"))) |
|
289 |
setAttributeStdSetDef(node.attribute(QLatin1String("stdSetDef")).toInt()); |
|
290 |
||
291 |
for (QDomNode n = node.firstChild(); !n.isNull(); n = n.nextSibling()) { |
|
292 |
if (!n.isElement()) |
|
293 |
continue; |
|
294 |
QDomElement e = n.toElement(); |
|
295 |
QString tag = e.tagName().toLower(); |
|
296 |
if (tag == QLatin1String("author")) { |
|
297 |
setElementAuthor(e.text()); |
|
298 |
continue; |
|
299 |
} |
|
300 |
if (tag == QLatin1String("comment")) { |
|
301 |
setElementComment(e.text()); |
|
302 |
continue; |
|
303 |
} |
|
304 |
if (tag == QLatin1String("exportmacro")) { |
|
305 |
setElementExportMacro(e.text()); |
|
306 |
continue; |
|
307 |
} |
|
308 |
if (tag == QLatin1String("class")) { |
|
309 |
setElementClass(e.text()); |
|
310 |
continue; |
|
311 |
} |
|
312 |
if (tag == QLatin1String("widget")) { |
|
313 |
DomWidget *v = new DomWidget(); |
|
314 |
v->read(e); |
|
315 |
setElementWidget(v); |
|
316 |
continue; |
|
317 |
} |
|
318 |
if (tag == QLatin1String("layoutdefault")) { |
|
319 |
DomLayoutDefault *v = new DomLayoutDefault(); |
|
320 |
v->read(e); |
|
321 |
setElementLayoutDefault(v); |
|
322 |
continue; |
|
323 |
} |
|
324 |
if (tag == QLatin1String("layoutfunction")) { |
|
325 |
DomLayoutFunction *v = new DomLayoutFunction(); |
|
326 |
v->read(e); |
|
327 |
setElementLayoutFunction(v); |
|
328 |
continue; |
|
329 |
} |
|
330 |
if (tag == QLatin1String("pixmapfunction")) { |
|
331 |
setElementPixmapFunction(e.text()); |
|
332 |
continue; |
|
333 |
} |
|
334 |
if (tag == QLatin1String("customwidgets")) { |
|
335 |
DomCustomWidgets *v = new DomCustomWidgets(); |
|
336 |
v->read(e); |
|
337 |
setElementCustomWidgets(v); |
|
338 |
continue; |
|
339 |
} |
|
340 |
if (tag == QLatin1String("tabstops")) { |
|
341 |
DomTabStops *v = new DomTabStops(); |
|
342 |
v->read(e); |
|
343 |
setElementTabStops(v); |
|
344 |
continue; |
|
345 |
} |
|
346 |
if (tag == QLatin1String("images")) { |
|
347 |
DomImages *v = new DomImages(); |
|
348 |
v->read(e); |
|
349 |
setElementImages(v); |
|
350 |
continue; |
|
351 |
} |
|
352 |
if (tag == QLatin1String("includes")) { |
|
353 |
DomIncludes *v = new DomIncludes(); |
|
354 |
v->read(e); |
|
355 |
setElementIncludes(v); |
|
356 |
continue; |
|
357 |
} |
|
358 |
if (tag == QLatin1String("resources")) { |
|
359 |
DomResources *v = new DomResources(); |
|
360 |
v->read(e); |
|
361 |
setElementResources(v); |
|
362 |
continue; |
|
363 |
} |
|
364 |
if (tag == QLatin1String("connections")) { |
|
365 |
DomConnections *v = new DomConnections(); |
|
366 |
v->read(e); |
|
367 |
setElementConnections(v); |
|
368 |
continue; |
|
369 |
} |
|
370 |
if (tag == QLatin1String("designerdata")) { |
|
371 |
DomDesignerData *v = new DomDesignerData(); |
|
372 |
v->read(e); |
|
373 |
setElementDesignerdata(v); |
|
374 |
continue; |
|
375 |
} |
|
376 |
if (tag == QLatin1String("slots")) { |
|
377 |
DomSlots *v = new DomSlots(); |
|
378 |
v->read(e); |
|
379 |
setElementSlots(v); |
|
380 |
continue; |
|
381 |
} |
|
382 |
if (tag == QLatin1String("buttongroups")) { |
|
383 |
DomButtonGroups *v = new DomButtonGroups(); |
|
384 |
v->read(e); |
|
385 |
setElementButtonGroups(v); |
|
386 |
continue; |
|
387 |
} |
|
388 |
} |
|
389 |
m_text.clear(); |
|
390 |
for (QDomNode child = node.firstChild(); !child.isNull(); child = child.nextSibling()) { |
|
391 |
if (child.isText()) |
|
392 |
m_text.append(child.nodeValue()); |
|
393 |
} |
|
394 |
} |
|
395 |
#endif |
|
396 |
||
397 |
void DomUI::write(QXmlStreamWriter &writer, const QString &tagName) const |
|
398 |
{ |
|
399 |
writer.writeStartElement(tagName.isEmpty() ? QString::fromUtf8("ui") : tagName.toLower()); |
|
400 |
||
401 |
if (hasAttributeVersion()) |
|
402 |
writer.writeAttribute(QLatin1String("version"), attributeVersion()); |
|
403 |
||
404 |
if (hasAttributeLanguage()) |
|
405 |
writer.writeAttribute(QLatin1String("language"), attributeLanguage()); |
|
406 |
||
407 |
if (hasAttributeDisplayname()) |
|
408 |
writer.writeAttribute(QLatin1String("displayname"), attributeDisplayname()); |
|
409 |
||
410 |
if (hasAttributeStdsetdef()) |
|
411 |
writer.writeAttribute(QLatin1String("stdsetdef"), QString::number(attributeStdsetdef())); |
|
412 |
||
413 |
if (hasAttributeStdSetDef()) |
|
414 |
writer.writeAttribute(QLatin1String("stdsetdef"), QString::number(attributeStdSetDef())); |
|
415 |
||
416 |
if (m_children & Author) { |
|
417 |
writer.writeTextElement(QLatin1String("author"), m_author); |
|
418 |
} |
|
419 |
||
420 |
if (m_children & Comment) { |
|
421 |
writer.writeTextElement(QLatin1String("comment"), m_comment); |
|
422 |
} |
|
423 |
||
424 |
if (m_children & ExportMacro) { |
|
425 |
writer.writeTextElement(QLatin1String("exportmacro"), m_exportMacro); |
|
426 |
} |
|
427 |
||
428 |
if (m_children & Class) { |
|
429 |
writer.writeTextElement(QLatin1String("class"), m_class); |
|
430 |
} |
|
431 |
||
432 |
if (m_children & Widget) { |
|
433 |
m_widget->write(writer, QLatin1String("widget")); |
|
434 |
} |
|
435 |
||
436 |
if (m_children & LayoutDefault) { |
|
437 |
m_layoutDefault->write(writer, QLatin1String("layoutdefault")); |
|
438 |
} |
|
439 |
||
440 |
if (m_children & LayoutFunction) { |
|
441 |
m_layoutFunction->write(writer, QLatin1String("layoutfunction")); |
|
442 |
} |
|
443 |
||
444 |
if (m_children & PixmapFunction) { |
|
445 |
writer.writeTextElement(QLatin1String("pixmapfunction"), m_pixmapFunction); |
|
446 |
} |
|
447 |
||
448 |
if (m_children & CustomWidgets) { |
|
449 |
m_customWidgets->write(writer, QLatin1String("customwidgets")); |
|
450 |
} |
|
451 |
||
452 |
if (m_children & TabStops) { |
|
453 |
m_tabStops->write(writer, QLatin1String("tabstops")); |
|
454 |
} |
|
455 |
||
456 |
if (m_children & Images) { |
|
457 |
m_images->write(writer, QLatin1String("images")); |
|
458 |
} |
|
459 |
||
460 |
if (m_children & Includes) { |
|
461 |
m_includes->write(writer, QLatin1String("includes")); |
|
462 |
} |
|
463 |
||
464 |
if (m_children & Resources) { |
|
465 |
m_resources->write(writer, QLatin1String("resources")); |
|
466 |
} |
|
467 |
||
468 |
if (m_children & Connections) { |
|
469 |
m_connections->write(writer, QLatin1String("connections")); |
|
470 |
} |
|
471 |
||
472 |
if (m_children & Designerdata) { |
|
473 |
m_designerdata->write(writer, QLatin1String("designerdata")); |
|
474 |
} |
|
475 |
||
476 |
if (m_children & Slots) { |
|
477 |
m_slots->write(writer, QLatin1String("slots")); |
|
478 |
} |
|
479 |
||
480 |
if (m_children & ButtonGroups) { |
|
481 |
m_buttonGroups->write(writer, QLatin1String("buttongroups")); |
|
482 |
} |
|
483 |
||
484 |
if (!m_text.isEmpty()) |
|
485 |
writer.writeCharacters(m_text); |
|
486 |
||
487 |
writer.writeEndElement(); |
|
488 |
} |
|
489 |
||
490 |
void DomUI::setElementAuthor(const QString& a) |
|
491 |
{ |
|
492 |
m_children |= Author; |
|
493 |
m_author = a; |
|
494 |
} |
|
495 |
||
496 |
void DomUI::setElementComment(const QString& a) |
|
497 |
{ |
|
498 |
m_children |= Comment; |
|
499 |
m_comment = a; |
|
500 |
} |
|
501 |
||
502 |
void DomUI::setElementExportMacro(const QString& a) |
|
503 |
{ |
|
504 |
m_children |= ExportMacro; |
|
505 |
m_exportMacro = a; |
|
506 |
} |
|
507 |
||
508 |
void DomUI::setElementClass(const QString& a) |
|
509 |
{ |
|
510 |
m_children |= Class; |
|
511 |
m_class = a; |
|
512 |
} |
|
513 |
||
514 |
DomWidget* DomUI::takeElementWidget() |
|
515 |
{ |
|
516 |
DomWidget* a = m_widget; |
|
517 |
m_widget = 0; |
|
518 |
m_children ^= Widget; |
|
519 |
return a; |
|
520 |
} |
|
521 |
||
522 |
void DomUI::setElementWidget(DomWidget* a) |
|
523 |
{ |
|
524 |
delete m_widget; |
|
525 |
m_children |= Widget; |
|
526 |
m_widget = a; |
|
527 |
} |
|
528 |
||
529 |
DomLayoutDefault* DomUI::takeElementLayoutDefault() |
|
530 |
{ |
|
531 |
DomLayoutDefault* a = m_layoutDefault; |
|
532 |
m_layoutDefault = 0; |
|
533 |
m_children ^= LayoutDefault; |
|
534 |
return a; |
|
535 |
} |
|
536 |
||
537 |
void DomUI::setElementLayoutDefault(DomLayoutDefault* a) |
|
538 |
{ |
|
539 |
delete m_layoutDefault; |
|
540 |
m_children |= LayoutDefault; |
|
541 |
m_layoutDefault = a; |
|
542 |
} |
|
543 |
||
544 |
DomLayoutFunction* DomUI::takeElementLayoutFunction() |
|
545 |
{ |
|
546 |
DomLayoutFunction* a = m_layoutFunction; |
|
547 |
m_layoutFunction = 0; |
|
548 |
m_children ^= LayoutFunction; |
|
549 |
return a; |
|
550 |
} |
|
551 |
||
552 |
void DomUI::setElementLayoutFunction(DomLayoutFunction* a) |
|
553 |
{ |
|
554 |
delete m_layoutFunction; |
|
555 |
m_children |= LayoutFunction; |
|
556 |
m_layoutFunction = a; |
|
557 |
} |
|
558 |
||
559 |
void DomUI::setElementPixmapFunction(const QString& a) |
|
560 |
{ |
|
561 |
m_children |= PixmapFunction; |
|
562 |
m_pixmapFunction = a; |
|
563 |
} |
|
564 |
||
565 |
DomCustomWidgets* DomUI::takeElementCustomWidgets() |
|
566 |
{ |
|
567 |
DomCustomWidgets* a = m_customWidgets; |
|
568 |
m_customWidgets = 0; |
|
569 |
m_children ^= CustomWidgets; |
|
570 |
return a; |
|
571 |
} |
|
572 |
||
573 |
void DomUI::setElementCustomWidgets(DomCustomWidgets* a) |
|
574 |
{ |
|
575 |
delete m_customWidgets; |
|
576 |
m_children |= CustomWidgets; |
|
577 |
m_customWidgets = a; |
|
578 |
} |
|
579 |
||
580 |
DomTabStops* DomUI::takeElementTabStops() |
|
581 |
{ |
|
582 |
DomTabStops* a = m_tabStops; |
|
583 |
m_tabStops = 0; |
|
584 |
m_children ^= TabStops; |
|
585 |
return a; |
|
586 |
} |
|
587 |
||
588 |
void DomUI::setElementTabStops(DomTabStops* a) |
|
589 |
{ |
|
590 |
delete m_tabStops; |
|
591 |
m_children |= TabStops; |
|
592 |
m_tabStops = a; |
|
593 |
} |
|
594 |
||
595 |
DomImages* DomUI::takeElementImages() |
|
596 |
{ |
|
597 |
DomImages* a = m_images; |
|
598 |
m_images = 0; |
|
599 |
m_children ^= Images; |
|
600 |
return a; |
|
601 |
} |
|
602 |
||
603 |
void DomUI::setElementImages(DomImages* a) |
|
604 |
{ |
|
605 |
delete m_images; |
|
606 |
m_children |= Images; |
|
607 |
m_images = a; |
|
608 |
} |
|
609 |
||
610 |
DomIncludes* DomUI::takeElementIncludes() |
|
611 |
{ |
|
612 |
DomIncludes* a = m_includes; |
|
613 |
m_includes = 0; |
|
614 |
m_children ^= Includes; |
|
615 |
return a; |
|
616 |
} |
|
617 |
||
618 |
void DomUI::setElementIncludes(DomIncludes* a) |
|
619 |
{ |
|
620 |
delete m_includes; |
|
621 |
m_children |= Includes; |
|
622 |
m_includes = a; |
|
623 |
} |
|
624 |
||
625 |
DomResources* DomUI::takeElementResources() |
|
626 |
{ |
|
627 |
DomResources* a = m_resources; |
|
628 |
m_resources = 0; |
|
629 |
m_children ^= Resources; |
|
630 |
return a; |
|
631 |
} |
|
632 |
||
633 |
void DomUI::setElementResources(DomResources* a) |
|
634 |
{ |
|
635 |
delete m_resources; |
|
636 |
m_children |= Resources; |
|
637 |
m_resources = a; |
|
638 |
} |
|
639 |
||
640 |
DomConnections* DomUI::takeElementConnections() |
|
641 |
{ |
|
642 |
DomConnections* a = m_connections; |
|
643 |
m_connections = 0; |
|
644 |
m_children ^= Connections; |
|
645 |
return a; |
|
646 |
} |
|
647 |
||
648 |
void DomUI::setElementConnections(DomConnections* a) |
|
649 |
{ |
|
650 |
delete m_connections; |
|
651 |
m_children |= Connections; |
|
652 |
m_connections = a; |
|
653 |
} |
|
654 |
||
655 |
DomDesignerData* DomUI::takeElementDesignerdata() |
|
656 |
{ |
|
657 |
DomDesignerData* a = m_designerdata; |
|
658 |
m_designerdata = 0; |
|
659 |
m_children ^= Designerdata; |
|
660 |
return a; |
|
661 |
} |
|
662 |
||
663 |
void DomUI::setElementDesignerdata(DomDesignerData* a) |
|
664 |
{ |
|
665 |
delete m_designerdata; |
|
666 |
m_children |= Designerdata; |
|
667 |
m_designerdata = a; |
|
668 |
} |
|
669 |
||
670 |
DomSlots* DomUI::takeElementSlots() |
|
671 |
{ |
|
672 |
DomSlots* a = m_slots; |
|
673 |
m_slots = 0; |
|
674 |
m_children ^= Slots; |
|
675 |
return a; |
|
676 |
} |
|
677 |
||
678 |
void DomUI::setElementSlots(DomSlots* a) |
|
679 |
{ |
|
680 |
delete m_slots; |
|
681 |
m_children |= Slots; |
|
682 |
m_slots = a; |
|
683 |
} |
|
684 |
||
685 |
DomButtonGroups* DomUI::takeElementButtonGroups() |
|
686 |
{ |
|
687 |
DomButtonGroups* a = m_buttonGroups; |
|
688 |
m_buttonGroups = 0; |
|
689 |
m_children ^= ButtonGroups; |
|
690 |
return a; |
|
691 |
} |
|
692 |
||
693 |
void DomUI::setElementButtonGroups(DomButtonGroups* a) |
|
694 |
{ |
|
695 |
delete m_buttonGroups; |
|
696 |
m_children |= ButtonGroups; |
|
697 |
m_buttonGroups = a; |
|
698 |
} |
|
699 |
||
700 |
void DomUI::clearElementAuthor() |
|
701 |
{ |
|
702 |
m_children &= ~Author; |
|
703 |
} |
|
704 |
||
705 |
void DomUI::clearElementComment() |
|
706 |
{ |
|
707 |
m_children &= ~Comment; |
|
708 |
} |
|
709 |
||
710 |
void DomUI::clearElementExportMacro() |
|
711 |
{ |
|
712 |
m_children &= ~ExportMacro; |
|
713 |
} |
|
714 |
||
715 |
void DomUI::clearElementClass() |
|
716 |
{ |
|
717 |
m_children &= ~Class; |
|
718 |
} |
|
719 |
||
720 |
void DomUI::clearElementWidget() |
|
721 |
{ |
|
722 |
delete m_widget; |
|
723 |
m_widget = 0; |
|
724 |
m_children &= ~Widget; |
|
725 |
} |
|
726 |
||
727 |
void DomUI::clearElementLayoutDefault() |
|
728 |
{ |
|
729 |
delete m_layoutDefault; |
|
730 |
m_layoutDefault = 0; |
|
731 |
m_children &= ~LayoutDefault; |
|
732 |
} |
|
733 |
||
734 |
void DomUI::clearElementLayoutFunction() |
|
735 |
{ |
|
736 |
delete m_layoutFunction; |
|
737 |
m_layoutFunction = 0; |
|
738 |
m_children &= ~LayoutFunction; |
|
739 |
} |
|
740 |
||
741 |
void DomUI::clearElementPixmapFunction() |
|
742 |
{ |
|
743 |
m_children &= ~PixmapFunction; |
|
744 |
} |
|
745 |
||
746 |
void DomUI::clearElementCustomWidgets() |
|
747 |
{ |
|
748 |
delete m_customWidgets; |
|
749 |
m_customWidgets = 0; |
|
750 |
m_children &= ~CustomWidgets; |
|
751 |
} |
|
752 |
||
753 |
void DomUI::clearElementTabStops() |
|
754 |
{ |
|
755 |
delete m_tabStops; |
|
756 |
m_tabStops = 0; |
|
757 |
m_children &= ~TabStops; |
|
758 |
} |
|
759 |
||
760 |
void DomUI::clearElementImages() |
|
761 |
{ |
|
762 |
delete m_images; |
|
763 |
m_images = 0; |
|
764 |
m_children &= ~Images; |
|
765 |
} |
|
766 |
||
767 |
void DomUI::clearElementIncludes() |
|
768 |
{ |
|
769 |
delete m_includes; |
|
770 |
m_includes = 0; |
|
771 |
m_children &= ~Includes; |
|
772 |
} |
|
773 |
||
774 |
void DomUI::clearElementResources() |
|
775 |
{ |
|
776 |
delete m_resources; |
|
777 |
m_resources = 0; |
|
778 |
m_children &= ~Resources; |
|
779 |
} |
|
780 |
||
781 |
void DomUI::clearElementConnections() |
|
782 |
{ |
|
783 |
delete m_connections; |
|
784 |
m_connections = 0; |
|
785 |
m_children &= ~Connections; |
|
786 |
} |
|
787 |
||
788 |
void DomUI::clearElementDesignerdata() |
|
789 |
{ |
|
790 |
delete m_designerdata; |
|
791 |
m_designerdata = 0; |
|
792 |
m_children &= ~Designerdata; |
|
793 |
} |
|
794 |
||
795 |
void DomUI::clearElementSlots() |
|
796 |
{ |
|
797 |
delete m_slots; |
|
798 |
m_slots = 0; |
|
799 |
m_children &= ~Slots; |
|
800 |
} |
|
801 |
||
802 |
void DomUI::clearElementButtonGroups() |
|
803 |
{ |
|
804 |
delete m_buttonGroups; |
|
805 |
m_buttonGroups = 0; |
|
806 |
m_children &= ~ButtonGroups; |
|
807 |
} |
|
808 |
||
809 |
void DomIncludes::clear(bool clear_all) |
|
810 |
{ |
|
811 |
qDeleteAll(m_include); |
|
812 |
m_include.clear(); |
|
813 |
||
814 |
if (clear_all) { |
|
815 |
m_text.clear(); |
|
816 |
} |
|
817 |
||
818 |
m_children = 0; |
|
819 |
} |
|
820 |
||
821 |
DomIncludes::DomIncludes() |
|
822 |
{ |
|
823 |
m_children = 0; |
|
824 |
} |
|
825 |
||
826 |
DomIncludes::~DomIncludes() |
|
827 |
{ |
|
828 |
qDeleteAll(m_include); |
|
829 |
m_include.clear(); |
|
830 |
} |
|
831 |
||
832 |
void DomIncludes::read(QXmlStreamReader &reader) |
|
833 |
{ |
|
834 |
||
835 |
for (bool finished = false; !finished && !reader.hasError();) { |
|
836 |
switch (reader.readNext()) { |
|
837 |
case QXmlStreamReader::StartElement : { |
|
838 |
const QString tag = reader.name().toString().toLower(); |
|
839 |
if (tag == QLatin1String("include")) { |
|
840 |
DomInclude *v = new DomInclude(); |
|
841 |
v->read(reader); |
|
842 |
m_include.append(v); |
|
843 |
continue; |
|
844 |
} |
|
845 |
reader.raiseError(QLatin1String("Unexpected element ") + tag); |
|
846 |
} |
|
847 |
break; |
|
848 |
case QXmlStreamReader::EndElement : |
|
849 |
finished = true; |
|
850 |
break; |
|
851 |
case QXmlStreamReader::Characters : |
|
852 |
if (!reader.isWhitespace()) |
|
853 |
m_text.append(reader.text().toString()); |
|
854 |
break; |
|
855 |
default : |
|
856 |
break; |
|
857 |
} |
|
858 |
} |
|
859 |
} |
|
860 |
||
861 |
#ifdef QUILOADER_QDOM_READ |
|
862 |
void DomIncludes::read(const QDomElement &node) |
|
863 |
{ |
|
864 |
for (QDomNode n = node.firstChild(); !n.isNull(); n = n.nextSibling()) { |
|
865 |
if (!n.isElement()) |
|
866 |
continue; |
|
867 |
QDomElement e = n.toElement(); |
|
868 |
QString tag = e.tagName().toLower(); |
|
869 |
if (tag == QLatin1String("include")) { |
|
870 |
DomInclude *v = new DomInclude(); |
|
871 |
v->read(e); |
|
872 |
m_include.append(v); |
|
873 |
continue; |
|
874 |
} |
|
875 |
} |
|
876 |
m_text.clear(); |
|
877 |
for (QDomNode child = node.firstChild(); !child.isNull(); child = child.nextSibling()) { |
|
878 |
if (child.isText()) |
|
879 |
m_text.append(child.nodeValue()); |
|
880 |
} |
|
881 |
} |
|
882 |
#endif |
|
883 |
||
884 |
void DomIncludes::write(QXmlStreamWriter &writer, const QString &tagName) const |
|
885 |
{ |
|
886 |
writer.writeStartElement(tagName.isEmpty() ? QString::fromUtf8("includes") : tagName.toLower()); |
|
887 |
||
888 |
for (int i = 0; i < m_include.size(); ++i) { |
|
889 |
DomInclude* v = m_include[i]; |
|
890 |
v->write(writer, QLatin1String("include")); |
|
891 |
} |
|
892 |
if (!m_text.isEmpty()) |
|
893 |
writer.writeCharacters(m_text); |
|
894 |
||
895 |
writer.writeEndElement(); |
|
896 |
} |
|
897 |
||
898 |
void DomIncludes::setElementInclude(const QList<DomInclude*>& a) |
|
899 |
{ |
|
900 |
m_children |= Include; |
|
901 |
m_include = a; |
|
902 |
} |
|
903 |
||
904 |
void DomInclude::clear(bool clear_all) |
|
905 |
{ |
|
906 |
||
907 |
if (clear_all) { |
|
908 |
m_text = QLatin1String(""); |
|
909 |
m_has_attr_location = false; |
|
910 |
m_has_attr_impldecl = false; |
|
911 |
} |
|
912 |
||
913 |
m_children = 0; |
|
914 |
} |
|
915 |
||
916 |
DomInclude::DomInclude() |
|
917 |
{ |
|
918 |
m_children = 0; |
|
919 |
m_has_attr_location = false; |
|
920 |
m_has_attr_impldecl = false; |
|
921 |
m_text = QLatin1String(""); |
|
922 |
} |
|
923 |
||
924 |
DomInclude::~DomInclude() |
|
925 |
{ |
|
926 |
} |
|
927 |
||
928 |
void DomInclude::read(QXmlStreamReader &reader) |
|
929 |
{ |
|
930 |
||
931 |
foreach (const QXmlStreamAttribute &attribute, reader.attributes()) { |
|
932 |
QStringRef name = attribute.name(); |
|
933 |
if (name == QLatin1String("location")) { |
|
934 |
setAttributeLocation(attribute.value().toString()); |
|
935 |
continue; |
|
936 |
} |
|
937 |
if (name == QLatin1String("impldecl")) { |
|
938 |
setAttributeImpldecl(attribute.value().toString()); |
|
939 |
continue; |
|
940 |
} |
|
941 |
reader.raiseError(QLatin1String("Unexpected attribute ") + name.toString()); |
|
942 |
} |
|
943 |
||
944 |
for (bool finished = false; !finished && !reader.hasError();) { |
|
945 |
switch (reader.readNext()) { |
|
946 |
case QXmlStreamReader::StartElement : { |
|
947 |
const QString tag = reader.name().toString().toLower(); |
|
948 |
reader.raiseError(QLatin1String("Unexpected element ") + tag); |
|
949 |
} |
|
950 |
break; |
|
951 |
case QXmlStreamReader::EndElement : |
|
952 |
finished = true; |
|
953 |
break; |
|
954 |
case QXmlStreamReader::Characters : |
|
955 |
if (!reader.isWhitespace()) |
|
956 |
m_text.append(reader.text().toString()); |
|
957 |
break; |
|
958 |
default : |
|
959 |
break; |
|
960 |
} |
|
961 |
} |
|
962 |
} |
|
963 |
||
964 |
#ifdef QUILOADER_QDOM_READ |
|
965 |
void DomInclude::read(const QDomElement &node) |
|
966 |
{ |
|
967 |
if (node.hasAttribute(QLatin1String("location"))) |
|
968 |
setAttributeLocation(node.attribute(QLatin1String("location"))); |
|
969 |
if (node.hasAttribute(QLatin1String("impldecl"))) |
|
970 |
setAttributeImpldecl(node.attribute(QLatin1String("impldecl"))); |
|
971 |
||
972 |
for (QDomNode n = node.firstChild(); !n.isNull(); n = n.nextSibling()) { |
|
973 |
if (!n.isElement()) |
|
974 |
continue; |
|
975 |
QDomElement e = n.toElement(); |
|
976 |
QString tag = e.tagName().toLower(); |
|
977 |
} |
|
978 |
m_text = QLatin1String(""); |
|
979 |
for (QDomNode child = node.firstChild(); !child.isNull(); child = child.nextSibling()) { |
|
980 |
if (child.isText()) |
|
981 |
m_text.append(child.nodeValue()); |
|
982 |
} |
|
983 |
} |
|
984 |
#endif |
|
985 |
||
986 |
void DomInclude::write(QXmlStreamWriter &writer, const QString &tagName) const |
|
987 |
{ |
|
988 |
writer.writeStartElement(tagName.isEmpty() ? QString::fromUtf8("include") : tagName.toLower()); |
|
989 |
||
990 |
if (hasAttributeLocation()) |
|
991 |
writer.writeAttribute(QLatin1String("location"), attributeLocation()); |
|
992 |
||
993 |
if (hasAttributeImpldecl()) |
|
994 |
writer.writeAttribute(QLatin1String("impldecl"), attributeImpldecl()); |
|
995 |
||
996 |
if (!m_text.isEmpty()) |
|
997 |
writer.writeCharacters(m_text); |
|
998 |
||
999 |
writer.writeEndElement(); |
|
1000 |
} |
|
1001 |
||
1002 |
void DomResources::clear(bool clear_all) |
|
1003 |
{ |
|
1004 |
qDeleteAll(m_include); |
|
1005 |
m_include.clear(); |
|
1006 |
||
1007 |
if (clear_all) { |
|
1008 |
m_text.clear(); |
|
1009 |
m_has_attr_name = false; |
|
1010 |
} |
|
1011 |
||
1012 |
m_children = 0; |
|
1013 |
} |
|
1014 |
||
1015 |
DomResources::DomResources() |
|
1016 |
{ |
|
1017 |
m_children = 0; |
|
1018 |
m_has_attr_name = false; |
|
1019 |
} |
|
1020 |
||
1021 |
DomResources::~DomResources() |
|
1022 |
{ |
|
1023 |
qDeleteAll(m_include); |
|
1024 |
m_include.clear(); |
|
1025 |
} |
|
1026 |
||
1027 |
void DomResources::read(QXmlStreamReader &reader) |
|
1028 |
{ |
|
1029 |
||
1030 |
foreach (const QXmlStreamAttribute &attribute, reader.attributes()) { |
|
1031 |
QStringRef name = attribute.name(); |
|
1032 |
if (name == QLatin1String("name")) { |
|
1033 |
setAttributeName(attribute.value().toString()); |
|
1034 |
continue; |
|
1035 |
} |
|
1036 |
reader.raiseError(QLatin1String("Unexpected attribute ") + name.toString()); |
|
1037 |
} |
|
1038 |
||
1039 |
for (bool finished = false; !finished && !reader.hasError();) { |
|
1040 |
switch (reader.readNext()) { |
|
1041 |
case QXmlStreamReader::StartElement : { |
|
1042 |
const QString tag = reader.name().toString().toLower(); |
|
1043 |
if (tag == QLatin1String("include")) { |
|
1044 |
DomResource *v = new DomResource(); |
|
1045 |
v->read(reader); |
|
1046 |
m_include.append(v); |
|
1047 |
continue; |
|
1048 |
} |
|
1049 |
reader.raiseError(QLatin1String("Unexpected element ") + tag); |
|
1050 |
} |
|
1051 |
break; |
|
1052 |
case QXmlStreamReader::EndElement : |
|
1053 |
finished = true; |
|
1054 |
break; |
|
1055 |
case QXmlStreamReader::Characters : |
|
1056 |
if (!reader.isWhitespace()) |
|
1057 |
m_text.append(reader.text().toString()); |
|
1058 |
break; |
|
1059 |
default : |
|
1060 |
break; |
|
1061 |
} |
|
1062 |
} |
|
1063 |
} |
|
1064 |
||
1065 |
#ifdef QUILOADER_QDOM_READ |
|
1066 |
void DomResources::read(const QDomElement &node) |
|
1067 |
{ |
|
1068 |
if (node.hasAttribute(QLatin1String("name"))) |
|
1069 |
setAttributeName(node.attribute(QLatin1String("name"))); |
|
1070 |
||
1071 |
for (QDomNode n = node.firstChild(); !n.isNull(); n = n.nextSibling()) { |
|
1072 |
if (!n.isElement()) |
|
1073 |
continue; |
|
1074 |
QDomElement e = n.toElement(); |
|
1075 |
QString tag = e.tagName().toLower(); |
|
1076 |
if (tag == QLatin1String("include")) { |
|
1077 |
DomResource *v = new DomResource(); |
|
1078 |
v->read(e); |
|
1079 |
m_include.append(v); |
|
1080 |
continue; |
|
1081 |
} |
|
1082 |
} |
|
1083 |
m_text.clear(); |
|
1084 |
for (QDomNode child = node.firstChild(); !child.isNull(); child = child.nextSibling()) { |
|
1085 |
if (child.isText()) |
|
1086 |
m_text.append(child.nodeValue()); |
|
1087 |
} |
|
1088 |
} |
|
1089 |
#endif |
|
1090 |
||
1091 |
void DomResources::write(QXmlStreamWriter &writer, const QString &tagName) const |
|
1092 |
{ |
|
1093 |
writer.writeStartElement(tagName.isEmpty() ? QString::fromUtf8("resources") : tagName.toLower()); |
|
1094 |
||
1095 |
if (hasAttributeName()) |
|
1096 |
writer.writeAttribute(QLatin1String("name"), attributeName()); |
|
1097 |
||
1098 |
for (int i = 0; i < m_include.size(); ++i) { |
|
1099 |
DomResource* v = m_include[i]; |
|
1100 |
v->write(writer, QLatin1String("include")); |
|
1101 |
} |
|
1102 |
if (!m_text.isEmpty()) |
|
1103 |
writer.writeCharacters(m_text); |
|
1104 |
||
1105 |
writer.writeEndElement(); |
|
1106 |
} |
|
1107 |
||
1108 |
void DomResources::setElementInclude(const QList<DomResource*>& a) |
|
1109 |
{ |
|
1110 |
m_children |= Include; |
|
1111 |
m_include = a; |
|
1112 |
} |
|
1113 |
||
1114 |
void DomResource::clear(bool clear_all) |
|
1115 |
{ |
|
1116 |
||
1117 |
if (clear_all) { |
|
1118 |
m_text.clear(); |
|
1119 |
m_has_attr_location = false; |
|
1120 |
} |
|
1121 |
||
1122 |
m_children = 0; |
|
1123 |
} |
|
1124 |
||
1125 |
DomResource::DomResource() |
|
1126 |
{ |
|
1127 |
m_children = 0; |
|
1128 |
m_has_attr_location = false; |
|
1129 |
} |
|
1130 |
||
1131 |
DomResource::~DomResource() |
|
1132 |
{ |
|
1133 |
} |
|
1134 |
||
1135 |
void DomResource::read(QXmlStreamReader &reader) |
|
1136 |
{ |
|
1137 |
||
1138 |
foreach (const QXmlStreamAttribute &attribute, reader.attributes()) { |
|
1139 |
QStringRef name = attribute.name(); |
|
1140 |
if (name == QLatin1String("location")) { |
|
1141 |
setAttributeLocation(attribute.value().toString()); |
|
1142 |
continue; |
|
1143 |
} |
|
1144 |
reader.raiseError(QLatin1String("Unexpected attribute ") + name.toString()); |
|
1145 |
} |
|
1146 |
||
1147 |
for (bool finished = false; !finished && !reader.hasError();) { |
|
1148 |
switch (reader.readNext()) { |
|
1149 |
case QXmlStreamReader::StartElement : { |
|
1150 |
const QString tag = reader.name().toString().toLower(); |
|
1151 |
reader.raiseError(QLatin1String("Unexpected element ") + tag); |
|
1152 |
} |
|
1153 |
break; |
|
1154 |
case QXmlStreamReader::EndElement : |
|
1155 |
finished = true; |
|
1156 |
break; |
|
1157 |
case QXmlStreamReader::Characters : |
|
1158 |
if (!reader.isWhitespace()) |
|
1159 |
m_text.append(reader.text().toString()); |
|
1160 |
break; |
|
1161 |
default : |
|
1162 |
break; |
|
1163 |
} |
|
1164 |
} |
|
1165 |
} |
|
1166 |
||
1167 |
#ifdef QUILOADER_QDOM_READ |
|
1168 |
void DomResource::read(const QDomElement &node) |
|
1169 |
{ |
|
1170 |
if (node.hasAttribute(QLatin1String("location"))) |
|
1171 |
setAttributeLocation(node.attribute(QLatin1String("location"))); |
|
1172 |
||
1173 |
for (QDomNode n = node.firstChild(); !n.isNull(); n = n.nextSibling()) { |
|
1174 |
if (!n.isElement()) |
|
1175 |
continue; |
|
1176 |
QDomElement e = n.toElement(); |
|
1177 |
QString tag = e.tagName().toLower(); |
|
1178 |
} |
|
1179 |
m_text.clear(); |
|
1180 |
for (QDomNode child = node.firstChild(); !child.isNull(); child = child.nextSibling()) { |
|
1181 |
if (child.isText()) |
|
1182 |
m_text.append(child.nodeValue()); |
|
1183 |
} |
|
1184 |
} |
|
1185 |
#endif |
|
1186 |
||
1187 |
void DomResource::write(QXmlStreamWriter &writer, const QString &tagName) const |
|
1188 |
{ |
|
1189 |
writer.writeStartElement(tagName.isEmpty() ? QString::fromUtf8("resource") : tagName.toLower()); |
|
1190 |
||
1191 |
if (hasAttributeLocation()) |
|
1192 |
writer.writeAttribute(QLatin1String("location"), attributeLocation()); |
|
1193 |
||
1194 |
if (!m_text.isEmpty()) |
|
1195 |
writer.writeCharacters(m_text); |
|
1196 |
||
1197 |
writer.writeEndElement(); |
|
1198 |
} |
|
1199 |
||
1200 |
void DomActionGroup::clear(bool clear_all) |
|
1201 |
{ |
|
1202 |
qDeleteAll(m_action); |
|
1203 |
m_action.clear(); |
|
1204 |
qDeleteAll(m_actionGroup); |
|
1205 |
m_actionGroup.clear(); |
|
1206 |
qDeleteAll(m_property); |
|
1207 |
m_property.clear(); |
|
1208 |
qDeleteAll(m_attribute); |
|
1209 |
m_attribute.clear(); |
|
1210 |
||
1211 |
if (clear_all) { |
|
1212 |
m_text.clear(); |
|
1213 |
m_has_attr_name = false; |
|
1214 |
} |
|
1215 |
||
1216 |
m_children = 0; |
|
1217 |
} |
|
1218 |
||
1219 |
DomActionGroup::DomActionGroup() |
|
1220 |
{ |
|
1221 |
m_children = 0; |
|
1222 |
m_has_attr_name = false; |
|
1223 |
} |
|
1224 |
||
1225 |
DomActionGroup::~DomActionGroup() |
|
1226 |
{ |
|
1227 |
qDeleteAll(m_action); |
|
1228 |
m_action.clear(); |
|
1229 |
qDeleteAll(m_actionGroup); |
|
1230 |
m_actionGroup.clear(); |
|
1231 |
qDeleteAll(m_property); |
|
1232 |
m_property.clear(); |
|
1233 |
qDeleteAll(m_attribute); |
|
1234 |
m_attribute.clear(); |
|
1235 |
} |
|
1236 |
||
1237 |
void DomActionGroup::read(QXmlStreamReader &reader) |
|
1238 |
{ |
|
1239 |
||
1240 |
foreach (const QXmlStreamAttribute &attribute, reader.attributes()) { |
|
1241 |
QStringRef name = attribute.name(); |
|
1242 |
if (name == QLatin1String("name")) { |
|
1243 |
setAttributeName(attribute.value().toString()); |
|
1244 |
continue; |
|
1245 |
} |
|
1246 |
reader.raiseError(QLatin1String("Unexpected attribute ") + name.toString()); |
|
1247 |
} |
|
1248 |
||
1249 |
for (bool finished = false; !finished && !reader.hasError();) { |
|
1250 |
switch (reader.readNext()) { |
|
1251 |
case QXmlStreamReader::StartElement : { |
|
1252 |
const QString tag = reader.name().toString().toLower(); |
|
1253 |
if (tag == QLatin1String("action")) { |
|
1254 |
DomAction *v = new DomAction(); |
|
1255 |
v->read(reader); |
|
1256 |
m_action.append(v); |
|
1257 |
continue; |
|
1258 |
} |
|
1259 |
if (tag == QLatin1String("actiongroup")) { |
|
1260 |
DomActionGroup *v = new DomActionGroup(); |
|
1261 |
v->read(reader); |
|
1262 |
m_actionGroup.append(v); |
|
1263 |
continue; |
|
1264 |
} |
|
1265 |
if (tag == QLatin1String("property")) { |
|
1266 |
DomProperty *v = new DomProperty(); |
|
1267 |
v->read(reader); |
|
1268 |
m_property.append(v); |
|
1269 |
continue; |
|
1270 |
} |
|
1271 |
if (tag == QLatin1String("attribute")) { |
|
1272 |
DomProperty *v = new DomProperty(); |
|
1273 |
v->read(reader); |
|
1274 |
m_attribute.append(v); |
|
1275 |
continue; |
|
1276 |
} |
|
1277 |
reader.raiseError(QLatin1String("Unexpected element ") + tag); |
|
1278 |
} |
|
1279 |
break; |
|
1280 |
case QXmlStreamReader::EndElement : |
|
1281 |
finished = true; |
|
1282 |
break; |
|
1283 |
case QXmlStreamReader::Characters : |
|
1284 |
if (!reader.isWhitespace()) |
|
1285 |
m_text.append(reader.text().toString()); |
|
1286 |
break; |
|
1287 |
default : |
|
1288 |
break; |
|
1289 |
} |
|
1290 |
} |
|
1291 |
} |
|
1292 |
||
1293 |
#ifdef QUILOADER_QDOM_READ |
|
1294 |
void DomActionGroup::read(const QDomElement &node) |
|
1295 |
{ |
|
1296 |
if (node.hasAttribute(QLatin1String("name"))) |
|
1297 |
setAttributeName(node.attribute(QLatin1String("name"))); |
|
1298 |
||
1299 |
for (QDomNode n = node.firstChild(); !n.isNull(); n = n.nextSibling()) { |
|
1300 |
if (!n.isElement()) |
|
1301 |
continue; |
|
1302 |
QDomElement e = n.toElement(); |
|
1303 |
QString tag = e.tagName().toLower(); |
|
1304 |
if (tag == QLatin1String("action")) { |
|
1305 |
DomAction *v = new DomAction(); |
|
1306 |
v->read(e); |
|
1307 |
m_action.append(v); |
|
1308 |
continue; |
|
1309 |
} |
|
1310 |
if (tag == QLatin1String("actiongroup")) { |
|
1311 |
DomActionGroup *v = new DomActionGroup(); |
|
1312 |
v->read(e); |
|
1313 |
m_actionGroup.append(v); |
|
1314 |
continue; |
|
1315 |
} |
|
1316 |
if (tag == QLatin1String("property")) { |
|
1317 |
DomProperty *v = new DomProperty(); |
|
1318 |
v->read(e); |
|
1319 |
m_property.append(v); |
|
1320 |
continue; |
|
1321 |
} |
|
1322 |
if (tag == QLatin1String("attribute")) { |
|
1323 |
DomProperty *v = new DomProperty(); |
|
1324 |
v->read(e); |
|
1325 |
m_attribute.append(v); |
|
1326 |
continue; |
|
1327 |
} |
|
1328 |
} |
|
1329 |
m_text.clear(); |
|
1330 |
for (QDomNode child = node.firstChild(); !child.isNull(); child = child.nextSibling()) { |
|
1331 |
if (child.isText()) |
|
1332 |
m_text.append(child.nodeValue()); |
|
1333 |
} |
|
1334 |
} |
|
1335 |
#endif |
|
1336 |
||
1337 |
void DomActionGroup::write(QXmlStreamWriter &writer, const QString &tagName) const |
|
1338 |
{ |
|
1339 |
writer.writeStartElement(tagName.isEmpty() ? QString::fromUtf8("actiongroup") : tagName.toLower()); |
|
1340 |
||
1341 |
if (hasAttributeName()) |
|
1342 |
writer.writeAttribute(QLatin1String("name"), attributeName()); |
|
1343 |
||
1344 |
for (int i = 0; i < m_action.size(); ++i) { |
|
1345 |
DomAction* v = m_action[i]; |
|
1346 |
v->write(writer, QLatin1String("action")); |
|
1347 |
} |
|
1348 |
for (int i = 0; i < m_actionGroup.size(); ++i) { |
|
1349 |
DomActionGroup* v = m_actionGroup[i]; |
|
1350 |
v->write(writer, QLatin1String("actiongroup")); |
|
1351 |
} |
|
1352 |
for (int i = 0; i < m_property.size(); ++i) { |
|
1353 |
DomProperty* v = m_property[i]; |
|
1354 |
v->write(writer, QLatin1String("property")); |
|
1355 |
} |
|
1356 |
for (int i = 0; i < m_attribute.size(); ++i) { |
|
1357 |
DomProperty* v = m_attribute[i]; |
|
1358 |
v->write(writer, QLatin1String("attribute")); |
|
1359 |
} |
|
1360 |
if (!m_text.isEmpty()) |
|
1361 |
writer.writeCharacters(m_text); |
|
1362 |
||
1363 |
writer.writeEndElement(); |
|
1364 |
} |
|
1365 |
||
1366 |
void DomActionGroup::setElementAction(const QList<DomAction*>& a) |
|
1367 |
{ |
|
1368 |
m_children |= Action; |
|
1369 |
m_action = a; |
|
1370 |
} |
|
1371 |
||
1372 |
void DomActionGroup::setElementActionGroup(const QList<DomActionGroup*>& a) |
|
1373 |
{ |
|
1374 |
m_children |= ActionGroup; |
|
1375 |
m_actionGroup = a; |
|
1376 |
} |
|
1377 |
||
1378 |
void DomActionGroup::setElementProperty(const QList<DomProperty*>& a) |
|
1379 |
{ |
|
1380 |
m_children |= Property; |
|
1381 |
m_property = a; |
|
1382 |
} |
|
1383 |
||
1384 |
void DomActionGroup::setElementAttribute(const QList<DomProperty*>& a) |
|
1385 |
{ |
|
1386 |
m_children |= Attribute; |
|
1387 |
m_attribute = a; |
|
1388 |
} |
|
1389 |
||
1390 |
void DomAction::clear(bool clear_all) |
|
1391 |
{ |
|
1392 |
qDeleteAll(m_property); |
|
1393 |
m_property.clear(); |
|
1394 |
qDeleteAll(m_attribute); |
|
1395 |
m_attribute.clear(); |
|
1396 |
||
1397 |
if (clear_all) { |
|
1398 |
m_text.clear(); |
|
1399 |
m_has_attr_name = false; |
|
1400 |
m_has_attr_menu = false; |
|
1401 |
} |
|
1402 |
||
1403 |
m_children = 0; |
|
1404 |
} |
|
1405 |
||
1406 |
DomAction::DomAction() |
|
1407 |
{ |
|
1408 |
m_children = 0; |
|
1409 |
m_has_attr_name = false; |
|
1410 |
m_has_attr_menu = false; |
|
1411 |
} |
|
1412 |
||
1413 |
DomAction::~DomAction() |
|
1414 |
{ |
|
1415 |
qDeleteAll(m_property); |
|
1416 |
m_property.clear(); |
|
1417 |
qDeleteAll(m_attribute); |
|
1418 |
m_attribute.clear(); |
|
1419 |
} |
|
1420 |
||
1421 |
void DomAction::read(QXmlStreamReader &reader) |
|
1422 |
{ |
|
1423 |
||
1424 |
foreach (const QXmlStreamAttribute &attribute, reader.attributes()) { |
|
1425 |
QStringRef name = attribute.name(); |
|
1426 |
if (name == QLatin1String("name")) { |
|
1427 |
setAttributeName(attribute.value().toString()); |
|
1428 |
continue; |
|
1429 |
} |
|
1430 |
if (name == QLatin1String("menu")) { |
|
1431 |
setAttributeMenu(attribute.value().toString()); |
|
1432 |
continue; |
|
1433 |
} |
|
1434 |
reader.raiseError(QLatin1String("Unexpected attribute ") + name.toString()); |
|
1435 |
} |
|
1436 |
||
1437 |
for (bool finished = false; !finished && !reader.hasError();) { |
|
1438 |
switch (reader.readNext()) { |
|
1439 |
case QXmlStreamReader::StartElement : { |
|
1440 |
const QString tag = reader.name().toString().toLower(); |
|
1441 |
if (tag == QLatin1String("property")) { |
|
1442 |
DomProperty *v = new DomProperty(); |
|
1443 |
v->read(reader); |
|
1444 |
m_property.append(v); |
|
1445 |
continue; |
|
1446 |
} |
|
1447 |
if (tag == QLatin1String("attribute")) { |
|
1448 |
DomProperty *v = new DomProperty(); |
|
1449 |
v->read(reader); |
|
1450 |
m_attribute.append(v); |
|
1451 |
continue; |
|
1452 |
} |
|
1453 |
reader.raiseError(QLatin1String("Unexpected element ") + tag); |
|
1454 |
} |
|
1455 |
break; |
|
1456 |
case QXmlStreamReader::EndElement : |
|
1457 |
finished = true; |
|
1458 |
break; |
|
1459 |
case QXmlStreamReader::Characters : |
|
1460 |
if (!reader.isWhitespace()) |
|
1461 |
m_text.append(reader.text().toString()); |
|
1462 |
break; |
|
1463 |
default : |
|
1464 |
break; |
|
1465 |
} |
|
1466 |
} |
|
1467 |
} |
|
1468 |
||
1469 |
#ifdef QUILOADER_QDOM_READ |
|
1470 |
void DomAction::read(const QDomElement &node) |
|
1471 |
{ |
|
1472 |
if (node.hasAttribute(QLatin1String("name"))) |
|
1473 |
setAttributeName(node.attribute(QLatin1String("name"))); |
|
1474 |
if (node.hasAttribute(QLatin1String("menu"))) |
|
1475 |
setAttributeMenu(node.attribute(QLatin1String("menu"))); |
|
1476 |
||
1477 |
for (QDomNode n = node.firstChild(); !n.isNull(); n = n.nextSibling()) { |
|
1478 |
if (!n.isElement()) |
|
1479 |
continue; |
|
1480 |
QDomElement e = n.toElement(); |
|
1481 |
QString tag = e.tagName().toLower(); |
|
1482 |
if (tag == QLatin1String("property")) { |
|
1483 |
DomProperty *v = new DomProperty(); |
|
1484 |
v->read(e); |
|
1485 |
m_property.append(v); |
|
1486 |
continue; |
|
1487 |
} |
|
1488 |
if (tag == QLatin1String("attribute")) { |
|
1489 |
DomProperty *v = new DomProperty(); |
|
1490 |
v->read(e); |
|
1491 |
m_attribute.append(v); |
|
1492 |
continue; |
|
1493 |
} |
|
1494 |
} |
|
1495 |
m_text.clear(); |
|
1496 |
for (QDomNode child = node.firstChild(); !child.isNull(); child = child.nextSibling()) { |
|
1497 |
if (child.isText()) |
|
1498 |
m_text.append(child.nodeValue()); |
|
1499 |
} |
|
1500 |
} |
|
1501 |
#endif |
|
1502 |
||
1503 |
void DomAction::write(QXmlStreamWriter &writer, const QString &tagName) const |
|
1504 |
{ |
|
1505 |
writer.writeStartElement(tagName.isEmpty() ? QString::fromUtf8("action") : tagName.toLower()); |
|
1506 |
||
1507 |
if (hasAttributeName()) |
|
1508 |
writer.writeAttribute(QLatin1String("name"), attributeName()); |
|
1509 |
||
1510 |
if (hasAttributeMenu()) |
|
1511 |
writer.writeAttribute(QLatin1String("menu"), attributeMenu()); |
|
1512 |
||
1513 |
for (int i = 0; i < m_property.size(); ++i) { |
|
1514 |
DomProperty* v = m_property[i]; |
|
1515 |
v->write(writer, QLatin1String("property")); |
|
1516 |
} |
|
1517 |
for (int i = 0; i < m_attribute.size(); ++i) { |
|
1518 |
DomProperty* v = m_attribute[i]; |
|
1519 |
v->write(writer, QLatin1String("attribute")); |
|
1520 |
} |
|
1521 |
if (!m_text.isEmpty()) |
|
1522 |
writer.writeCharacters(m_text); |
|
1523 |
||
1524 |
writer.writeEndElement(); |
|
1525 |
} |
|
1526 |
||
1527 |
void DomAction::setElementProperty(const QList<DomProperty*>& a) |
|
1528 |
{ |
|
1529 |
m_children |= Property; |
|
1530 |
m_property = a; |
|
1531 |
} |
|
1532 |
||
1533 |
void DomAction::setElementAttribute(const QList<DomProperty*>& a) |
|
1534 |
{ |
|
1535 |
m_children |= Attribute; |
|
1536 |
m_attribute = a; |
|
1537 |
} |
|
1538 |
||
1539 |
void DomActionRef::clear(bool clear_all) |
|
1540 |
{ |
|
1541 |
||
1542 |
if (clear_all) { |
|
1543 |
m_text.clear(); |
|
1544 |
m_has_attr_name = false; |
|
1545 |
} |
|
1546 |
||
1547 |
m_children = 0; |
|
1548 |
} |
|
1549 |
||
1550 |
DomActionRef::DomActionRef() |
|
1551 |
{ |
|
1552 |
m_children = 0; |
|
1553 |
m_has_attr_name = false; |
|
1554 |
} |
|
1555 |
||
1556 |
DomActionRef::~DomActionRef() |
|
1557 |
{ |
|
1558 |
} |
|
1559 |
||
1560 |
void DomActionRef::read(QXmlStreamReader &reader) |
|
1561 |
{ |
|
1562 |
||
1563 |
foreach (const QXmlStreamAttribute &attribute, reader.attributes()) { |
|
1564 |
QStringRef name = attribute.name(); |
|
1565 |
if (name == QLatin1String("name")) { |
|
1566 |
setAttributeName(attribute.value().toString()); |
|
1567 |
continue; |
|
1568 |
} |
|
1569 |
reader.raiseError(QLatin1String("Unexpected attribute ") + name.toString()); |
|
1570 |
} |
|
1571 |
||
1572 |
for (bool finished = false; !finished && !reader.hasError();) { |
|
1573 |
switch (reader.readNext()) { |
|
1574 |
case QXmlStreamReader::StartElement : { |
|
1575 |
const QString tag = reader.name().toString().toLower(); |
|
1576 |
reader.raiseError(QLatin1String("Unexpected element ") + tag); |
|
1577 |
} |
|
1578 |
break; |
|
1579 |
case QXmlStreamReader::EndElement : |
|
1580 |
finished = true; |
|
1581 |
break; |
|
1582 |
case QXmlStreamReader::Characters : |
|
1583 |
if (!reader.isWhitespace()) |
|
1584 |
m_text.append(reader.text().toString()); |
|
1585 |
break; |
|
1586 |
default : |
|
1587 |
break; |
|
1588 |
} |
|
1589 |
} |
|
1590 |
} |
|
1591 |
||
1592 |
#ifdef QUILOADER_QDOM_READ |
|
1593 |
void DomActionRef::read(const QDomElement &node) |
|
1594 |
{ |
|
1595 |
if (node.hasAttribute(QLatin1String("name"))) |
|
1596 |
setAttributeName(node.attribute(QLatin1String("name"))); |
|
1597 |
||
1598 |
for (QDomNode n = node.firstChild(); !n.isNull(); n = n.nextSibling()) { |
|
1599 |
if (!n.isElement()) |
|
1600 |
continue; |
|
1601 |
QDomElement e = n.toElement(); |
|
1602 |
QString tag = e.tagName().toLower(); |
|
1603 |
} |
|
1604 |
m_text.clear(); |
|
1605 |
for (QDomNode child = node.firstChild(); !child.isNull(); child = child.nextSibling()) { |
|
1606 |
if (child.isText()) |
|
1607 |
m_text.append(child.nodeValue()); |
|
1608 |
} |
|
1609 |
} |
|
1610 |
#endif |
|
1611 |
||
1612 |
void DomActionRef::write(QXmlStreamWriter &writer, const QString &tagName) const |
|
1613 |
{ |
|
1614 |
writer.writeStartElement(tagName.isEmpty() ? QString::fromUtf8("actionref") : tagName.toLower()); |
|
1615 |
||
1616 |
if (hasAttributeName()) |
|
1617 |
writer.writeAttribute(QLatin1String("name"), attributeName()); |
|
1618 |
||
1619 |
if (!m_text.isEmpty()) |
|
1620 |
writer.writeCharacters(m_text); |
|
1621 |
||
1622 |
writer.writeEndElement(); |
|
1623 |
} |
|
1624 |
||
1625 |
void DomButtonGroup::clear(bool clear_all) |
|
1626 |
{ |
|
1627 |
qDeleteAll(m_property); |
|
1628 |
m_property.clear(); |
|
1629 |
qDeleteAll(m_attribute); |
|
1630 |
m_attribute.clear(); |
|
1631 |
||
1632 |
if (clear_all) { |
|
1633 |
m_text.clear(); |
|
1634 |
m_has_attr_name = false; |
|
1635 |
} |
|
1636 |
||
1637 |
m_children = 0; |
|
1638 |
} |
|
1639 |
||
1640 |
DomButtonGroup::DomButtonGroup() |
|
1641 |
{ |
|
1642 |
m_children = 0; |
|
1643 |
m_has_attr_name = false; |
|
1644 |
} |
|
1645 |
||
1646 |
DomButtonGroup::~DomButtonGroup() |
|
1647 |
{ |
|
1648 |
qDeleteAll(m_property); |
|
1649 |
m_property.clear(); |
|
1650 |
qDeleteAll(m_attribute); |
|
1651 |
m_attribute.clear(); |
|
1652 |
} |
|
1653 |
||
1654 |
void DomButtonGroup::read(QXmlStreamReader &reader) |
|
1655 |
{ |
|
1656 |
||
1657 |
foreach (const QXmlStreamAttribute &attribute, reader.attributes()) { |
|
1658 |
QStringRef name = attribute.name(); |
|
1659 |
if (name == QLatin1String("name")) { |
|
1660 |
setAttributeName(attribute.value().toString()); |
|
1661 |
continue; |
|
1662 |
} |
|
1663 |
reader.raiseError(QLatin1String("Unexpected attribute ") + name.toString()); |
|
1664 |
} |
|
1665 |
||
1666 |
for (bool finished = false; !finished && !reader.hasError();) { |
|
1667 |
switch (reader.readNext()) { |
|
1668 |
case QXmlStreamReader::StartElement : { |
|
1669 |
const QString tag = reader.name().toString().toLower(); |
|
1670 |
if (tag == QLatin1String("property")) { |
|
1671 |
DomProperty *v = new DomProperty(); |
|
1672 |
v->read(reader); |
|
1673 |
m_property.append(v); |
|
1674 |
continue; |
|
1675 |
} |
|
1676 |
if (tag == QLatin1String("attribute")) { |
|
1677 |
DomProperty *v = new DomProperty(); |
|
1678 |
v->read(reader); |
|
1679 |
m_attribute.append(v); |
|
1680 |
continue; |
|
1681 |
} |
|
1682 |
reader.raiseError(QLatin1String("Unexpected element ") + tag); |
|
1683 |
} |
|
1684 |
break; |
|
1685 |
case QXmlStreamReader::EndElement : |
|
1686 |
finished = true; |
|
1687 |
break; |
|
1688 |
case QXmlStreamReader::Characters : |
|
1689 |
if (!reader.isWhitespace()) |
|
1690 |
m_text.append(reader.text().toString()); |
|
1691 |
break; |
|
1692 |
default : |
|
1693 |
break; |
|
1694 |
} |
|
1695 |
} |
|
1696 |
} |
|
1697 |
||
1698 |
#ifdef QUILOADER_QDOM_READ |
|
1699 |
void DomButtonGroup::read(const QDomElement &node) |
|
1700 |
{ |
|
1701 |
if (node.hasAttribute(QLatin1String("name"))) |
|
1702 |
setAttributeName(node.attribute(QLatin1String("name"))); |
|
1703 |
||
1704 |
for (QDomNode n = node.firstChild(); !n.isNull(); n = n.nextSibling()) { |
|
1705 |
if (!n.isElement()) |
|
1706 |
continue; |
|
1707 |
QDomElement e = n.toElement(); |
|
1708 |
QString tag = e.tagName().toLower(); |
|
1709 |
if (tag == QLatin1String("property")) { |
|
1710 |
DomProperty *v = new DomProperty(); |
|
1711 |
v->read(e); |
|
1712 |
m_property.append(v); |
|
1713 |
continue; |
|
1714 |
} |
|
1715 |
if (tag == QLatin1String("attribute")) { |
|
1716 |
DomProperty *v = new DomProperty(); |
|
1717 |
v->read(e); |
|
1718 |
m_attribute.append(v); |
|
1719 |
continue; |
|
1720 |
} |
|
1721 |
} |
|
1722 |
m_text.clear(); |
|
1723 |
for (QDomNode child = node.firstChild(); !child.isNull(); child = child.nextSibling()) { |
|
1724 |
if (child.isText()) |
|
1725 |
m_text.append(child.nodeValue()); |
|
1726 |
} |
|
1727 |
} |
|
1728 |
#endif |
|
1729 |
||
1730 |
void DomButtonGroup::write(QXmlStreamWriter &writer, const QString &tagName) const |
|
1731 |
{ |
|
1732 |
writer.writeStartElement(tagName.isEmpty() ? QString::fromUtf8("buttongroup") : tagName.toLower()); |
|
1733 |
||
1734 |
if (hasAttributeName()) |
|
1735 |
writer.writeAttribute(QLatin1String("name"), attributeName()); |
|
1736 |
||
1737 |
for (int i = 0; i < m_property.size(); ++i) { |
|
1738 |
DomProperty* v = m_property[i]; |
|
1739 |
v->write(writer, QLatin1String("property")); |
|
1740 |
} |
|
1741 |
for (int i = 0; i < m_attribute.size(); ++i) { |
|
1742 |
DomProperty* v = m_attribute[i]; |
|
1743 |
v->write(writer, QLatin1String("attribute")); |
|
1744 |
} |
|
1745 |
if (!m_text.isEmpty()) |
|
1746 |
writer.writeCharacters(m_text); |
|
1747 |
||
1748 |
writer.writeEndElement(); |
|
1749 |
} |
|
1750 |
||
1751 |
void DomButtonGroup::setElementProperty(const QList<DomProperty*>& a) |
|
1752 |
{ |
|
1753 |
m_children |= Property; |
|
1754 |
m_property = a; |
|
1755 |
} |
|
1756 |
||
1757 |
void DomButtonGroup::setElementAttribute(const QList<DomProperty*>& a) |
|
1758 |
{ |
|
1759 |
m_children |= Attribute; |
|
1760 |
m_attribute = a; |
|
1761 |
} |
|
1762 |
||
1763 |
void DomButtonGroups::clear(bool clear_all) |
|
1764 |
{ |
|
1765 |
qDeleteAll(m_buttonGroup); |
|
1766 |
m_buttonGroup.clear(); |
|
1767 |
||
1768 |
if (clear_all) { |
|
1769 |
m_text.clear(); |
|
1770 |
} |
|
1771 |
||
1772 |
m_children = 0; |
|
1773 |
} |
|
1774 |
||
1775 |
DomButtonGroups::DomButtonGroups() |
|
1776 |
{ |
|
1777 |
m_children = 0; |
|
1778 |
} |
|
1779 |
||
1780 |
DomButtonGroups::~DomButtonGroups() |
|
1781 |
{ |
|
1782 |
qDeleteAll(m_buttonGroup); |
|
1783 |
m_buttonGroup.clear(); |
|
1784 |
} |
|
1785 |
||
1786 |
void DomButtonGroups::read(QXmlStreamReader &reader) |
|
1787 |
{ |
|
1788 |
||
1789 |
for (bool finished = false; !finished && !reader.hasError();) { |
|
1790 |
switch (reader.readNext()) { |
|
1791 |
case QXmlStreamReader::StartElement : { |
|
1792 |
const QString tag = reader.name().toString().toLower(); |
|
1793 |
if (tag == QLatin1String("buttongroup")) { |
|
1794 |
DomButtonGroup *v = new DomButtonGroup(); |
|
1795 |
v->read(reader); |
|
1796 |
m_buttonGroup.append(v); |
|
1797 |
continue; |
|
1798 |
} |
|
1799 |
reader.raiseError(QLatin1String("Unexpected element ") + tag); |
|
1800 |
} |
|
1801 |
break; |
|
1802 |
case QXmlStreamReader::EndElement : |
|
1803 |
finished = true; |
|
1804 |
break; |
|
1805 |
case QXmlStreamReader::Characters : |
|
1806 |
if (!reader.isWhitespace()) |
|
1807 |
m_text.append(reader.text().toString()); |
|
1808 |
break; |
|
1809 |
default : |
|
1810 |
break; |
|
1811 |
} |
|
1812 |
} |
|
1813 |
} |
|
1814 |
||
1815 |
#ifdef QUILOADER_QDOM_READ |
|
1816 |
void DomButtonGroups::read(const QDomElement &node) |
|
1817 |
{ |
|
1818 |
for (QDomNode n = node.firstChild(); !n.isNull(); n = n.nextSibling()) { |
|
1819 |
if (!n.isElement()) |
|
1820 |
continue; |
|
1821 |
QDomElement e = n.toElement(); |
|
1822 |
QString tag = e.tagName().toLower(); |
|
1823 |
if (tag == QLatin1String("buttongroup")) { |
|
1824 |
DomButtonGroup *v = new DomButtonGroup(); |
|
1825 |
v->read(e); |
|
1826 |
m_buttonGroup.append(v); |
|
1827 |
continue; |
|
1828 |
} |
|
1829 |
} |
|
1830 |
m_text.clear(); |
|
1831 |
for (QDomNode child = node.firstChild(); !child.isNull(); child = child.nextSibling()) { |
|
1832 |
if (child.isText()) |
|
1833 |
m_text.append(child.nodeValue()); |
|
1834 |
} |
|
1835 |
} |
|
1836 |
#endif |
|
1837 |
||
1838 |
void DomButtonGroups::write(QXmlStreamWriter &writer, const QString &tagName) const |
|
1839 |
{ |
|
1840 |
writer.writeStartElement(tagName.isEmpty() ? QString::fromUtf8("buttongroups") : tagName.toLower()); |
|
1841 |
||
1842 |
for (int i = 0; i < m_buttonGroup.size(); ++i) { |
|
1843 |
DomButtonGroup* v = m_buttonGroup[i]; |
|
1844 |
v->write(writer, QLatin1String("buttongroup")); |
|
1845 |
} |
|
1846 |
if (!m_text.isEmpty()) |
|
1847 |
writer.writeCharacters(m_text); |
|
1848 |
||
1849 |
writer.writeEndElement(); |
|
1850 |
} |
|
1851 |
||
1852 |
void DomButtonGroups::setElementButtonGroup(const QList<DomButtonGroup*>& a) |
|
1853 |
{ |
|
1854 |
m_children |= ButtonGroup; |
|
1855 |
m_buttonGroup = a; |
|
1856 |
} |
|
1857 |
||
1858 |
void DomImages::clear(bool clear_all) |
|
1859 |
{ |
|
1860 |
qDeleteAll(m_image); |
|
1861 |
m_image.clear(); |
|
1862 |
||
1863 |
if (clear_all) { |
|
1864 |
m_text.clear(); |
|
1865 |
} |
|
1866 |
||
1867 |
m_children = 0; |
|
1868 |
} |
|
1869 |
||
1870 |
DomImages::DomImages() |
|
1871 |
{ |
|
1872 |
m_children = 0; |
|
1873 |
} |
|
1874 |
||
1875 |
DomImages::~DomImages() |
|
1876 |
{ |
|
1877 |
qDeleteAll(m_image); |
|
1878 |
m_image.clear(); |
|
1879 |
} |
|
1880 |
||
1881 |
void DomImages::read(QXmlStreamReader &reader) |
|
1882 |
{ |
|
1883 |
||
1884 |
for (bool finished = false; !finished && !reader.hasError();) { |
|
1885 |
switch (reader.readNext()) { |
|
1886 |
case QXmlStreamReader::StartElement : { |
|
1887 |
const QString tag = reader.name().toString().toLower(); |
|
1888 |
if (tag == QLatin1String("image")) { |
|
1889 |
DomImage *v = new DomImage(); |
|
1890 |
v->read(reader); |
|
1891 |
m_image.append(v); |
|
1892 |
continue; |
|
1893 |
} |
|
1894 |
reader.raiseError(QLatin1String("Unexpected element ") + tag); |
|
1895 |
} |
|
1896 |
break; |
|
1897 |
case QXmlStreamReader::EndElement : |
|
1898 |
finished = true; |
|
1899 |
break; |
|
1900 |
case QXmlStreamReader::Characters : |
|
1901 |
if (!reader.isWhitespace()) |
|
1902 |
m_text.append(reader.text().toString()); |
|
1903 |
break; |
|
1904 |
default : |
|
1905 |
break; |
|
1906 |
} |
|
1907 |
} |
|
1908 |
} |
|
1909 |
||
1910 |
#ifdef QUILOADER_QDOM_READ |
|
1911 |
void DomImages::read(const QDomElement &node) |
|
1912 |
{ |
|
1913 |
for (QDomNode n = node.firstChild(); !n.isNull(); n = n.nextSibling()) { |
|
1914 |
if (!n.isElement()) |
|
1915 |
continue; |
|
1916 |
QDomElement e = n.toElement(); |
|
1917 |
QString tag = e.tagName().toLower(); |
|
1918 |
if (tag == QLatin1String("image")) { |
|
1919 |
DomImage *v = new DomImage(); |
|
1920 |
v->read(e); |
|
1921 |
m_image.append(v); |
|
1922 |
continue; |
|
1923 |
} |
|
1924 |
} |
|
1925 |
m_text.clear(); |
|
1926 |
for (QDomNode child = node.firstChild(); !child.isNull(); child = child.nextSibling()) { |
|
1927 |
if (child.isText()) |
|
1928 |
m_text.append(child.nodeValue()); |
|
1929 |
} |
|
1930 |
} |
|
1931 |
#endif |
|
1932 |
||
1933 |
void DomImages::write(QXmlStreamWriter &writer, const QString &tagName) const |
|
1934 |
{ |
|
1935 |
writer.writeStartElement(tagName.isEmpty() ? QString::fromUtf8("images") : tagName.toLower()); |
|
1936 |
||
1937 |
for (int i = 0; i < m_image.size(); ++i) { |
|
1938 |
DomImage* v = m_image[i]; |
|
1939 |
v->write(writer, QLatin1String("image")); |
|
1940 |
} |
|
1941 |
if (!m_text.isEmpty()) |
|
1942 |
writer.writeCharacters(m_text); |
|
1943 |
||
1944 |
writer.writeEndElement(); |
|
1945 |
} |
|
1946 |
||
1947 |
void DomImages::setElementImage(const QList<DomImage*>& a) |
|
1948 |
{ |
|
1949 |
m_children |= Image; |
|
1950 |
m_image = a; |
|
1951 |
} |
|
1952 |
||
1953 |
void DomImage::clear(bool clear_all) |
|
1954 |
{ |
|
1955 |
delete m_data; |
|
1956 |
||
1957 |
if (clear_all) { |
|
1958 |
m_text.clear(); |
|
1959 |
m_has_attr_name = false; |
|
1960 |
} |
|
1961 |
||
1962 |
m_children = 0; |
|
1963 |
m_data = 0; |
|
1964 |
} |
|
1965 |
||
1966 |
DomImage::DomImage() |
|
1967 |
{ |
|
1968 |
m_children = 0; |
|
1969 |
m_has_attr_name = false; |
|
1970 |
m_data = 0; |
|
1971 |
} |
|
1972 |
||
1973 |
DomImage::~DomImage() |
|
1974 |
{ |
|
1975 |
delete m_data; |
|
1976 |
} |
|
1977 |
||
1978 |
void DomImage::read(QXmlStreamReader &reader) |
|
1979 |
{ |
|
1980 |
||
1981 |
foreach (const QXmlStreamAttribute &attribute, reader.attributes()) { |
|
1982 |
QStringRef name = attribute.name(); |
|
1983 |
if (name == QLatin1String("name")) { |
|
1984 |
setAttributeName(attribute.value().toString()); |
|
1985 |
continue; |
|
1986 |
} |
|
1987 |
reader.raiseError(QLatin1String("Unexpected attribute ") + name.toString()); |
|
1988 |
} |
|
1989 |
||
1990 |
for (bool finished = false; !finished && !reader.hasError();) { |
|
1991 |
switch (reader.readNext()) { |
|
1992 |
case QXmlStreamReader::StartElement : { |
|
1993 |
const QString tag = reader.name().toString().toLower(); |
|
1994 |
if (tag == QLatin1String("data")) { |
|
1995 |
DomImageData *v = new DomImageData(); |
|
1996 |
v->read(reader); |
|
1997 |
setElementData(v); |
|
1998 |
continue; |
|
1999 |
} |
|
2000 |
reader.raiseError(QLatin1String("Unexpected element ") + tag); |
|
2001 |
} |
|
2002 |
break; |
|
2003 |
case QXmlStreamReader::EndElement : |
|
2004 |
finished = true; |
|
2005 |
break; |
|
2006 |
case QXmlStreamReader::Characters : |
|
2007 |
if (!reader.isWhitespace()) |
|
2008 |
m_text.append(reader.text().toString()); |
|
2009 |
break; |
|
2010 |
default : |
|
2011 |
break; |
|
2012 |
} |
|
2013 |
} |
|
2014 |
} |
|
2015 |
||
2016 |
#ifdef QUILOADER_QDOM_READ |
|
2017 |
void DomImage::read(const QDomElement &node) |
|
2018 |
{ |
|
2019 |
if (node.hasAttribute(QLatin1String("name"))) |
|
2020 |
setAttributeName(node.attribute(QLatin1String("name"))); |
|
2021 |
||
2022 |
for (QDomNode n = node.firstChild(); !n.isNull(); n = n.nextSibling()) { |
|
2023 |
if (!n.isElement()) |
|
2024 |
continue; |
|
2025 |
QDomElement e = n.toElement(); |
|
2026 |
QString tag = e.tagName().toLower(); |
|
2027 |
if (tag == QLatin1String("data")) { |
|
2028 |
DomImageData *v = new DomImageData(); |
|
2029 |
v->read(e); |
|
2030 |
setElementData(v); |
|
2031 |
continue; |
|
2032 |
} |
|
2033 |
} |
|
2034 |
m_text.clear(); |
|
2035 |
for (QDomNode child = node.firstChild(); !child.isNull(); child = child.nextSibling()) { |
|
2036 |
if (child.isText()) |
|
2037 |
m_text.append(child.nodeValue()); |
|
2038 |
} |
|
2039 |
} |
|
2040 |
#endif |
|
2041 |
||
2042 |
void DomImage::write(QXmlStreamWriter &writer, const QString &tagName) const |
|
2043 |
{ |
|
2044 |
writer.writeStartElement(tagName.isEmpty() ? QString::fromUtf8("image") : tagName.toLower()); |
|
2045 |
||
2046 |
if (hasAttributeName()) |
|
2047 |
writer.writeAttribute(QLatin1String("name"), attributeName()); |
|
2048 |
||
2049 |
if (m_children & Data) { |
|
2050 |
m_data->write(writer, QLatin1String("data")); |
|
2051 |
} |
|
2052 |
||
2053 |
if (!m_text.isEmpty()) |
|
2054 |
writer.writeCharacters(m_text); |
|
2055 |
||
2056 |
writer.writeEndElement(); |
|
2057 |
} |
|
2058 |
||
2059 |
DomImageData* DomImage::takeElementData() |
|
2060 |
{ |
|
2061 |
DomImageData* a = m_data; |
|
2062 |
m_data = 0; |
|
2063 |
m_children ^= Data; |
|
2064 |
return a; |
|
2065 |
} |
|
2066 |
||
2067 |
void DomImage::setElementData(DomImageData* a) |
|
2068 |
{ |
|
2069 |
delete m_data; |
|
2070 |
m_children |= Data; |
|
2071 |
m_data = a; |
|
2072 |
} |
|
2073 |
||
2074 |
void DomImage::clearElementData() |
|
2075 |
{ |
|
2076 |
delete m_data; |
|
2077 |
m_data = 0; |
|
2078 |
m_children &= ~Data; |
|
2079 |
} |
|
2080 |
||
2081 |
void DomImageData::clear(bool clear_all) |
|
2082 |
{ |
|
2083 |
||
2084 |
if (clear_all) { |
|
2085 |
m_text = QLatin1String(""); |
|
2086 |
m_has_attr_format = false; |
|
2087 |
m_has_attr_length = false; |
|
2088 |
m_attr_length = 0; |
|
2089 |
} |
|
2090 |
||
2091 |
m_children = 0; |
|
2092 |
} |
|
2093 |
||
2094 |
DomImageData::DomImageData() |
|
2095 |
{ |
|
2096 |
m_children = 0; |
|
2097 |
m_has_attr_format = false; |
|
2098 |
m_has_attr_length = false; |
|
2099 |
m_attr_length = 0; |
|
2100 |
m_text = QLatin1String(""); |
|
2101 |
} |
|
2102 |
||
2103 |
DomImageData::~DomImageData() |
|
2104 |
{ |
|
2105 |
} |
|
2106 |
||
2107 |
void DomImageData::read(QXmlStreamReader &reader) |
|
2108 |
{ |
|
2109 |
||
2110 |
foreach (const QXmlStreamAttribute &attribute, reader.attributes()) { |
|
2111 |
QStringRef name = attribute.name(); |
|
2112 |
if (name == QLatin1String("format")) { |
|
2113 |
setAttributeFormat(attribute.value().toString()); |
|
2114 |
continue; |
|
2115 |
} |
|
2116 |
if (name == QLatin1String("length")) { |
|
2117 |
setAttributeLength(attribute.value().toString().toInt()); |
|
2118 |
continue; |
|
2119 |
} |
|
2120 |
reader.raiseError(QLatin1String("Unexpected attribute ") + name.toString()); |
|
2121 |
} |
|
2122 |
||
2123 |
for (bool finished = false; !finished && !reader.hasError();) { |
|
2124 |
switch (reader.readNext()) { |
|
2125 |
case QXmlStreamReader::StartElement : { |
|
2126 |
const QString tag = reader.name().toString().toLower(); |
|
2127 |
reader.raiseError(QLatin1String("Unexpected element ") + tag); |
|
2128 |
} |
|
2129 |
break; |
|
2130 |
case QXmlStreamReader::EndElement : |
|
2131 |
finished = true; |
|
2132 |
break; |
|
2133 |
case QXmlStreamReader::Characters : |
|
2134 |
if (!reader.isWhitespace()) |
|
2135 |
m_text.append(reader.text().toString()); |
|
2136 |
break; |
|
2137 |
default : |
|
2138 |
break; |
|
2139 |
} |
|
2140 |
} |
|
2141 |
} |
|
2142 |
||
2143 |
#ifdef QUILOADER_QDOM_READ |
|
2144 |
void DomImageData::read(const QDomElement &node) |
|
2145 |
{ |
|
2146 |
if (node.hasAttribute(QLatin1String("format"))) |
|
2147 |
setAttributeFormat(node.attribute(QLatin1String("format"))); |
|
2148 |
if (node.hasAttribute(QLatin1String("length"))) |
|
2149 |
setAttributeLength(node.attribute(QLatin1String("length")).toInt()); |
|
2150 |
||
2151 |
for (QDomNode n = node.firstChild(); !n.isNull(); n = n.nextSibling()) { |
|
2152 |
if (!n.isElement()) |
|
2153 |
continue; |
|
2154 |
QDomElement e = n.toElement(); |
|
2155 |
QString tag = e.tagName().toLower(); |
|
2156 |
} |
|
2157 |
m_text = QLatin1String(""); |
|
2158 |
for (QDomNode child = node.firstChild(); !child.isNull(); child = child.nextSibling()) { |
|
2159 |
if (child.isText()) |
|
2160 |
m_text.append(child.nodeValue()); |
|
2161 |
} |
|
2162 |
} |
|
2163 |
#endif |
|
2164 |
||
2165 |
void DomImageData::write(QXmlStreamWriter &writer, const QString &tagName) const |
|
2166 |
{ |
|
2167 |
writer.writeStartElement(tagName.isEmpty() ? QString::fromUtf8("imagedata") : tagName.toLower()); |
|
2168 |
||
2169 |
if (hasAttributeFormat()) |
|
2170 |
writer.writeAttribute(QLatin1String("format"), attributeFormat()); |
|
2171 |
||
2172 |
if (hasAttributeLength()) |
|
2173 |
writer.writeAttribute(QLatin1String("length"), QString::number(attributeLength())); |
|
2174 |
||
2175 |
if (!m_text.isEmpty()) |
|
2176 |
writer.writeCharacters(m_text); |
|
2177 |
||
2178 |
writer.writeEndElement(); |
|
2179 |
} |
|
2180 |
||
2181 |
void DomCustomWidgets::clear(bool clear_all) |
|
2182 |
{ |
|
2183 |
qDeleteAll(m_customWidget); |
|
2184 |
m_customWidget.clear(); |
|
2185 |
||
2186 |
if (clear_all) { |
|
2187 |
m_text.clear(); |
|
2188 |
} |
|
2189 |
||
2190 |
m_children = 0; |
|
2191 |
} |
|
2192 |
||
2193 |
DomCustomWidgets::DomCustomWidgets() |
|
2194 |
{ |
|
2195 |
m_children = 0; |
|
2196 |
} |
|
2197 |
||
2198 |
DomCustomWidgets::~DomCustomWidgets() |
|
2199 |
{ |
|
2200 |
qDeleteAll(m_customWidget); |
|
2201 |
m_customWidget.clear(); |
|
2202 |
} |
|
2203 |
||
2204 |
void DomCustomWidgets::read(QXmlStreamReader &reader) |
|
2205 |
{ |
|
2206 |
||
2207 |
for (bool finished = false; !finished && !reader.hasError();) { |
|
2208 |
switch (reader.readNext()) { |
|
2209 |
case QXmlStreamReader::StartElement : { |
|
2210 |
const QString tag = reader.name().toString().toLower(); |
|
2211 |
if (tag == QLatin1String("customwidget")) { |
|
2212 |
DomCustomWidget *v = new DomCustomWidget(); |
|
2213 |
v->read(reader); |
|
2214 |
m_customWidget.append(v); |
|
2215 |
continue; |
|
2216 |
} |
|
2217 |
reader.raiseError(QLatin1String("Unexpected element ") + tag); |
|
2218 |
} |
|
2219 |
break; |
|
2220 |
case QXmlStreamReader::EndElement : |
|
2221 |
finished = true; |
|
2222 |
break; |
|
2223 |
case QXmlStreamReader::Characters : |
|
2224 |
if (!reader.isWhitespace()) |
|
2225 |
m_text.append(reader.text().toString()); |
|
2226 |
break; |
|
2227 |
default : |
|
2228 |
break; |
|
2229 |
} |
|
2230 |
} |
|
2231 |
} |
|
2232 |
||
2233 |
#ifdef QUILOADER_QDOM_READ |
|
2234 |
void DomCustomWidgets::read(const QDomElement &node) |
|
2235 |
{ |
|
2236 |
for (QDomNode n = node.firstChild(); !n.isNull(); n = n.nextSibling()) { |
|
2237 |
if (!n.isElement()) |
|
2238 |
continue; |
|
2239 |
QDomElement e = n.toElement(); |
|
2240 |
QString tag = e.tagName().toLower(); |
|
2241 |
if (tag == QLatin1String("customwidget")) { |
|
2242 |
DomCustomWidget *v = new DomCustomWidget(); |
|
2243 |
v->read(e); |
|
2244 |
m_customWidget.append(v); |
|
2245 |
continue; |
|
2246 |
} |
|
2247 |
} |
|
2248 |
m_text.clear(); |
|
2249 |
for (QDomNode child = node.firstChild(); !child.isNull(); child = child.nextSibling()) { |
|
2250 |
if (child.isText()) |
|
2251 |
m_text.append(child.nodeValue()); |
|
2252 |
} |
|
2253 |
} |
|
2254 |
#endif |
|
2255 |
||
2256 |
void DomCustomWidgets::write(QXmlStreamWriter &writer, const QString &tagName) const |
|
2257 |
{ |
|
2258 |
writer.writeStartElement(tagName.isEmpty() ? QString::fromUtf8("customwidgets") : tagName.toLower()); |
|
2259 |
||
2260 |
for (int i = 0; i < m_customWidget.size(); ++i) { |
|
2261 |
DomCustomWidget* v = m_customWidget[i]; |
|
2262 |
v->write(writer, QLatin1String("customwidget")); |
|
2263 |
} |
|
2264 |
if (!m_text.isEmpty()) |
|
2265 |
writer.writeCharacters(m_text); |
|
2266 |
||
2267 |
writer.writeEndElement(); |
|
2268 |
} |
|
2269 |
||
2270 |
void DomCustomWidgets::setElementCustomWidget(const QList<DomCustomWidget*>& a) |
|
2271 |
{ |
|
2272 |
m_children |= CustomWidget; |
|
2273 |
m_customWidget = a; |
|
2274 |
} |
|
2275 |
||
2276 |
void DomHeader::clear(bool clear_all) |
|
2277 |
{ |
|
2278 |
||
2279 |
if (clear_all) { |
|
2280 |
m_text = QLatin1String(""); |
|
2281 |
m_has_attr_location = false; |
|
2282 |
} |
|
2283 |
||
2284 |
m_children = 0; |
|
2285 |
} |
|
2286 |
||
2287 |
DomHeader::DomHeader() |
|
2288 |
{ |
|
2289 |
m_children = 0; |
|
2290 |
m_has_attr_location = false; |
|
2291 |
m_text = QLatin1String(""); |
|
2292 |
} |
|
2293 |
||
2294 |
DomHeader::~DomHeader() |
|
2295 |
{ |
|
2296 |
} |
|
2297 |
||
2298 |
void DomHeader::read(QXmlStreamReader &reader) |
|
2299 |
{ |
|
2300 |
||
2301 |
foreach (const QXmlStreamAttribute &attribute, reader.attributes()) { |
|
2302 |
QStringRef name = attribute.name(); |
|
2303 |
if (name == QLatin1String("location")) { |
|
2304 |
setAttributeLocation(attribute.value().toString()); |
|
2305 |
continue; |
|
2306 |
} |
|
2307 |
reader.raiseError(QLatin1String("Unexpected attribute ") + name.toString()); |
|
2308 |
} |
|
2309 |
||
2310 |
for (bool finished = false; !finished && !reader.hasError();) { |
|
2311 |
switch (reader.readNext()) { |
|
2312 |
case QXmlStreamReader::StartElement : { |
|
2313 |
const QString tag = reader.name().toString().toLower(); |
|
2314 |
reader.raiseError(QLatin1String("Unexpected element ") + tag); |
|
2315 |
} |
|
2316 |
break; |
|
2317 |
case QXmlStreamReader::EndElement : |
|
2318 |
finished = true; |
|
2319 |
break; |
|
2320 |
case QXmlStreamReader::Characters : |
|
2321 |
if (!reader.isWhitespace()) |
|
2322 |
m_text.append(reader.text().toString()); |
|
2323 |
break; |
|
2324 |
default : |
|
2325 |
break; |
|
2326 |
} |
|
2327 |
} |
|
2328 |
} |
|
2329 |
||
2330 |
#ifdef QUILOADER_QDOM_READ |
|
2331 |
void DomHeader::read(const QDomElement &node) |
|
2332 |
{ |
|
2333 |
if (node.hasAttribute(QLatin1String("location"))) |
|
2334 |
setAttributeLocation(node.attribute(QLatin1String("location"))); |
|
2335 |
||
2336 |
for (QDomNode n = node.firstChild(); !n.isNull(); n = n.nextSibling()) { |
|
2337 |
if (!n.isElement()) |
|
2338 |
continue; |
|
2339 |
QDomElement e = n.toElement(); |
|
2340 |
QString tag = e.tagName().toLower(); |
|
2341 |
} |
|
2342 |
m_text = QLatin1String(""); |
|
2343 |
for (QDomNode child = node.firstChild(); !child.isNull(); child = child.nextSibling()) { |
|
2344 |
if (child.isText()) |
|
2345 |
m_text.append(child.nodeValue()); |
|
2346 |
} |
|
2347 |
} |
|
2348 |
#endif |
|
2349 |
||
2350 |
void DomHeader::write(QXmlStreamWriter &writer, const QString &tagName) const |
|
2351 |
{ |
|
2352 |
writer.writeStartElement(tagName.isEmpty() ? QString::fromUtf8("header") : tagName.toLower()); |
|
2353 |
||
2354 |
if (hasAttributeLocation()) |
|
2355 |
writer.writeAttribute(QLatin1String("location"), attributeLocation()); |
|
2356 |
||
2357 |
if (!m_text.isEmpty()) |
|
2358 |
writer.writeCharacters(m_text); |
|
2359 |
||
2360 |
writer.writeEndElement(); |
|
2361 |
} |
|
2362 |
||
2363 |
void DomCustomWidget::clear(bool clear_all) |
|
2364 |
{ |
|
2365 |
delete m_header; |
|
2366 |
delete m_sizeHint; |
|
2367 |
delete m_sizePolicy; |
|
2368 |
delete m_script; |
|
2369 |
delete m_properties; |
|
2370 |
delete m_slots; |
|
2371 |
delete m_propertyspecifications; |
|
2372 |
||
2373 |
if (clear_all) { |
|
2374 |
m_text.clear(); |
|
2375 |
} |
|
2376 |
||
2377 |
m_children = 0; |
|
2378 |
m_header = 0; |
|
2379 |
m_sizeHint = 0; |
|
2380 |
m_container = 0; |
|
2381 |
m_sizePolicy = 0; |
|
2382 |
m_script = 0; |
|
2383 |
m_properties = 0; |
|
2384 |
m_slots = 0; |
|
2385 |
m_propertyspecifications = 0; |
|
2386 |
} |
|
2387 |
||
2388 |
DomCustomWidget::DomCustomWidget() |
|
2389 |
{ |
|
2390 |
m_children = 0; |
|
2391 |
m_header = 0; |
|
2392 |
m_sizeHint = 0; |
|
2393 |
m_container = 0; |
|
2394 |
m_sizePolicy = 0; |
|
2395 |
m_script = 0; |
|
2396 |
m_properties = 0; |
|
2397 |
m_slots = 0; |
|
2398 |
m_propertyspecifications = 0; |
|
2399 |
} |
|
2400 |
||
2401 |
DomCustomWidget::~DomCustomWidget() |
|
2402 |
{ |
|
2403 |
delete m_header; |
|
2404 |
delete m_sizeHint; |
|
2405 |
delete m_sizePolicy; |
|
2406 |
delete m_script; |
|
2407 |
delete m_properties; |
|
2408 |
delete m_slots; |
|
2409 |
delete m_propertyspecifications; |
|
2410 |
} |
|
2411 |
||
2412 |
void DomCustomWidget::read(QXmlStreamReader &reader) |
|
2413 |
{ |
|
2414 |
||
2415 |
for (bool finished = false; !finished && !reader.hasError();) { |
|
2416 |
switch (reader.readNext()) { |
|
2417 |
case QXmlStreamReader::StartElement : { |
|
2418 |
const QString tag = reader.name().toString().toLower(); |
|
2419 |
if (tag == QLatin1String("class")) { |
|
2420 |
setElementClass(reader.readElementText()); |
|
2421 |
continue; |
|
2422 |
} |
|
2423 |
if (tag == QLatin1String("extends")) { |
|
2424 |
setElementExtends(reader.readElementText()); |
|
2425 |
continue; |
|
2426 |
} |
|
2427 |
if (tag == QLatin1String("header")) { |
|
2428 |
DomHeader *v = new DomHeader(); |
|
2429 |
v->read(reader); |
|
2430 |
setElementHeader(v); |
|
2431 |
continue; |
|
2432 |
} |
|
2433 |
if (tag == QLatin1String("sizehint")) { |
|
2434 |
DomSize *v = new DomSize(); |
|
2435 |
v->read(reader); |
|
2436 |
setElementSizeHint(v); |
|
2437 |
continue; |
|
2438 |
} |
|
2439 |
if (tag == QLatin1String("addpagemethod")) { |
|
2440 |
setElementAddPageMethod(reader.readElementText()); |
|
2441 |
continue; |
|
2442 |
} |
|
2443 |
if (tag == QLatin1String("container")) { |
|
2444 |
setElementContainer(reader.readElementText().toInt()); |
|
2445 |
continue; |
|
2446 |
} |
|
2447 |
if (tag == QLatin1String("sizepolicy")) { |
|
2448 |
DomSizePolicyData *v = new DomSizePolicyData(); |
|
2449 |
v->read(reader); |
|
2450 |
setElementSizePolicy(v); |
|
2451 |
continue; |
|
2452 |
} |
|
2453 |
if (tag == QLatin1String("pixmap")) { |
|
2454 |
setElementPixmap(reader.readElementText()); |
|
2455 |
continue; |
|
2456 |
} |
|
2457 |
if (tag == QLatin1String("script")) { |
|
2458 |
DomScript *v = new DomScript(); |
|
2459 |
v->read(reader); |
|
2460 |
setElementScript(v); |
|
2461 |
continue; |
|
2462 |
} |
|
2463 |
if (tag == QLatin1String("properties")) { |
|
2464 |
DomProperties *v = new DomProperties(); |
|
2465 |
v->read(reader); |
|
2466 |
setElementProperties(v); |
|
2467 |
continue; |
|
2468 |
} |
|
2469 |
if (tag == QLatin1String("slots")) { |
|
2470 |
DomSlots *v = new DomSlots(); |
|
2471 |
v->read(reader); |
|
2472 |
setElementSlots(v); |
|
2473 |
continue; |
|
2474 |
} |
|
2475 |
if (tag == QLatin1String("propertyspecifications")) { |
|
2476 |
DomPropertySpecifications *v = new DomPropertySpecifications(); |
|
2477 |
v->read(reader); |
|
2478 |
setElementPropertyspecifications(v); |
|
2479 |
continue; |
|
2480 |
} |
|
2481 |
reader.raiseError(QLatin1String("Unexpected element ") + tag); |
|
2482 |
} |
|
2483 |
break; |
|
2484 |
case QXmlStreamReader::EndElement : |
|
2485 |
finished = true; |
|
2486 |
break; |
|
2487 |
case QXmlStreamReader::Characters : |
|
2488 |
if (!reader.isWhitespace()) |
|
2489 |
m_text.append(reader.text().toString()); |
|
2490 |
break; |
|
2491 |
default : |
|
2492 |
break; |
|
2493 |
} |
|
2494 |
} |
|
2495 |
} |
|
2496 |
||
2497 |
#ifdef QUILOADER_QDOM_READ |
|
2498 |
void DomCustomWidget::read(const QDomElement &node) |
|
2499 |
{ |
|
2500 |
for (QDomNode n = node.firstChild(); !n.isNull(); n = n.nextSibling()) { |
|
2501 |
if (!n.isElement()) |
|
2502 |
continue; |
|
2503 |
QDomElement e = n.toElement(); |
|
2504 |
QString tag = e.tagName().toLower(); |
|
2505 |
if (tag == QLatin1String("class")) { |
|
2506 |
setElementClass(e.text()); |
|
2507 |
continue; |
|
2508 |
} |
|
2509 |
if (tag == QLatin1String("extends")) { |
|
2510 |
setElementExtends(e.text()); |
|
2511 |
continue; |
|
2512 |
} |
|
2513 |
if (tag == QLatin1String("header")) { |
|
2514 |
DomHeader *v = new DomHeader(); |
|
2515 |
v->read(e); |
|
2516 |
setElementHeader(v); |
|
2517 |
continue; |
|
2518 |
} |
|
2519 |
if (tag == QLatin1String("sizehint")) { |
|
2520 |
DomSize *v = new DomSize(); |
|
2521 |
v->read(e); |
|
2522 |
setElementSizeHint(v); |
|
2523 |
continue; |
|
2524 |
} |
|
2525 |
if (tag == QLatin1String("addpagemethod")) { |
|
2526 |
setElementAddPageMethod(e.text()); |
|
2527 |
continue; |
|
2528 |
} |
|
2529 |
if (tag == QLatin1String("container")) { |
|
2530 |
setElementContainer(e.text().toInt()); |
|
2531 |
continue; |
|
2532 |
} |
|
2533 |
if (tag == QLatin1String("sizepolicy")) { |
|
2534 |
DomSizePolicyData *v = new DomSizePolicyData(); |
|
2535 |
v->read(e); |
|
2536 |
setElementSizePolicy(v); |
|
2537 |
continue; |
|
2538 |
} |
|
2539 |
if (tag == QLatin1String("pixmap")) { |
|
2540 |
setElementPixmap(e.text()); |
|
2541 |
continue; |
|
2542 |
} |
|
2543 |
if (tag == QLatin1String("script")) { |
|
2544 |
DomScript *v = new DomScript(); |
|
2545 |
v->read(e); |
|
2546 |
setElementScript(v); |
|
2547 |
continue; |
|
2548 |
} |
|
2549 |
if (tag == QLatin1String("properties")) { |
|
2550 |
DomProperties *v = new DomProperties(); |
|
2551 |
v->read(e); |
|
2552 |
setElementProperties(v); |
|
2553 |
continue; |
|
2554 |
} |
|
2555 |
if (tag == QLatin1String("slots")) { |
|
2556 |
DomSlots *v = new DomSlots(); |
|
2557 |
v->read(e); |
|
2558 |
setElementSlots(v); |
|
2559 |
continue; |
|
2560 |
} |
|
2561 |
if (tag == QLatin1String("propertyspecifications")) { |
|
2562 |
DomPropertySpecifications *v = new DomPropertySpecifications(); |
|
2563 |
v->read(e); |
|
2564 |
setElementPropertyspecifications(v); |
|
2565 |
continue; |
|
2566 |
} |
|
2567 |
} |
|
2568 |
m_text.clear(); |
|
2569 |
for (QDomNode child = node.firstChild(); !child.isNull(); child = child.nextSibling()) { |
|
2570 |
if (child.isText()) |
|
2571 |
m_text.append(child.nodeValue()); |
|
2572 |
} |
|
2573 |
} |
|
2574 |
#endif |
|
2575 |
||
2576 |
void DomCustomWidget::write(QXmlStreamWriter &writer, const QString &tagName) const |
|
2577 |
{ |
|
2578 |
writer.writeStartElement(tagName.isEmpty() ? QString::fromUtf8("customwidget") : tagName.toLower()); |
|
2579 |
||
2580 |
if (m_children & Class) { |
|
2581 |
writer.writeTextElement(QLatin1String("class"), m_class); |
|
2582 |
} |
|
2583 |
||
2584 |
if (m_children & Extends) { |
|
2585 |
writer.writeTextElement(QLatin1String("extends"), m_extends); |
|
2586 |
} |
|
2587 |
||
2588 |
if (m_children & Header) { |
|
2589 |
m_header->write(writer, QLatin1String("header")); |
|
2590 |
} |
|
2591 |
||
2592 |
if (m_children & SizeHint) { |
|
2593 |
m_sizeHint->write(writer, QLatin1String("sizehint")); |
|
2594 |
} |
|
2595 |
||
2596 |
if (m_children & AddPageMethod) { |
|
2597 |
writer.writeTextElement(QLatin1String("addpagemethod"), m_addPageMethod); |
|
2598 |
} |
|
2599 |
||
2600 |
if (m_children & Container) { |
|
2601 |
writer.writeTextElement(QLatin1String("container"), QString::number(m_container)); |
|
2602 |
} |
|
2603 |
||
2604 |
if (m_children & SizePolicy) { |
|
2605 |
m_sizePolicy->write(writer, QLatin1String("sizepolicy")); |
|
2606 |
} |
|
2607 |
||
2608 |
if (m_children & Pixmap) { |
|
2609 |
writer.writeTextElement(QLatin1String("pixmap"), m_pixmap); |
|
2610 |
} |
|
2611 |
||
2612 |
if (m_children & Script) { |
|
2613 |
m_script->write(writer, QLatin1String("script")); |
|
2614 |
} |
|
2615 |
||
2616 |
if (m_children & Properties) { |
|
2617 |
m_properties->write(writer, QLatin1String("properties")); |
|
2618 |
} |
|
2619 |
||
2620 |
if (m_children & Slots) { |
|
2621 |
m_slots->write(writer, QLatin1String("slots")); |
|
2622 |
} |
|
2623 |
||
2624 |
if (m_children & Propertyspecifications) { |
|
2625 |
m_propertyspecifications->write(writer, QLatin1String("propertyspecifications")); |
|
2626 |
} |
|
2627 |
||
2628 |
if (!m_text.isEmpty()) |
|
2629 |
writer.writeCharacters(m_text); |
|
2630 |
||
2631 |
writer.writeEndElement(); |
|
2632 |
} |
|
2633 |
||
2634 |
void DomCustomWidget::setElementClass(const QString& a) |
|
2635 |
{ |
|
2636 |
m_children |= Class; |
|
2637 |
m_class = a; |
|
2638 |
} |
|
2639 |
||
2640 |
void DomCustomWidget::setElementExtends(const QString& a) |
|
2641 |
{ |
|
2642 |
m_children |= Extends; |
|
2643 |
m_extends = a; |
|
2644 |
} |
|
2645 |
||
2646 |
DomHeader* DomCustomWidget::takeElementHeader() |
|
2647 |
{ |
|
2648 |
DomHeader* a = m_header; |
|
2649 |
m_header = 0; |
|
2650 |
m_children ^= Header; |
|
2651 |
return a; |
|
2652 |
} |
|
2653 |
||
2654 |
void DomCustomWidget::setElementHeader(DomHeader* a) |
|
2655 |
{ |
|
2656 |
delete m_header; |
|
2657 |
m_children |= Header; |
|
2658 |
m_header = a; |
|
2659 |
} |
|
2660 |
||
2661 |
DomSize* DomCustomWidget::takeElementSizeHint() |
|
2662 |
{ |
|
2663 |
DomSize* a = m_sizeHint; |
|
2664 |
m_sizeHint = 0; |
|
2665 |
m_children ^= SizeHint; |
|
2666 |
return a; |
|
2667 |
} |
|
2668 |
||
2669 |
void DomCustomWidget::setElementSizeHint(DomSize* a) |
|
2670 |
{ |
|
2671 |
delete m_sizeHint; |
|
2672 |
m_children |= SizeHint; |
|
2673 |
m_sizeHint = a; |
|
2674 |
} |
|
2675 |
||
2676 |
void DomCustomWidget::setElementAddPageMethod(const QString& a) |
|
2677 |
{ |
|
2678 |
m_children |= AddPageMethod; |
|
2679 |
m_addPageMethod = a; |
|
2680 |
} |
|
2681 |
||
2682 |
void DomCustomWidget::setElementContainer(int a) |
|
2683 |
{ |
|
2684 |
m_children |= Container; |
|
2685 |
m_container = a; |
|
2686 |
} |
|
2687 |
||
2688 |
DomSizePolicyData* DomCustomWidget::takeElementSizePolicy() |
|
2689 |
{ |
|
2690 |
DomSizePolicyData* a = m_sizePolicy; |
|
2691 |
m_sizePolicy = 0; |
|
2692 |
m_children ^= SizePolicy; |
|
2693 |
return a; |
|
2694 |
} |
|
2695 |
||
2696 |
void DomCustomWidget::setElementSizePolicy(DomSizePolicyData* a) |
|
2697 |
{ |
|
2698 |
delete m_sizePolicy; |
|
2699 |
m_children |= SizePolicy; |
|
2700 |
m_sizePolicy = a; |
|
2701 |
} |
|
2702 |
||
2703 |
void DomCustomWidget::setElementPixmap(const QString& a) |
|
2704 |
{ |
|
2705 |
m_children |= Pixmap; |
|
2706 |
m_pixmap = a; |
|
2707 |
} |
|
2708 |
||
2709 |
DomScript* DomCustomWidget::takeElementScript() |
|
2710 |
{ |
|
2711 |
DomScript* a = m_script; |
|
2712 |
m_script = 0; |
|
2713 |
m_children ^= Script; |
|
2714 |
return a; |
|
2715 |
} |
|
2716 |
||
2717 |
void DomCustomWidget::setElementScript(DomScript* a) |
|
2718 |
{ |
|
2719 |
delete m_script; |
|
2720 |
m_children |= Script; |
|
2721 |
m_script = a; |
|
2722 |
} |
|
2723 |
||
2724 |
DomProperties* DomCustomWidget::takeElementProperties() |
|
2725 |
{ |
|
2726 |
DomProperties* a = m_properties; |
|
2727 |
m_properties = 0; |
|
2728 |
m_children ^= Properties; |
|
2729 |
return a; |
|
2730 |
} |
|
2731 |
||
2732 |
void DomCustomWidget::setElementProperties(DomProperties* a) |
|
2733 |
{ |
|
2734 |
delete m_properties; |
|
2735 |
m_children |= Properties; |
|
2736 |
m_properties = a; |
|
2737 |
} |
|
2738 |
||
2739 |
DomSlots* DomCustomWidget::takeElementSlots() |
|
2740 |
{ |
|
2741 |
DomSlots* a = m_slots; |
|
2742 |
m_slots = 0; |
|
2743 |
m_children ^= Slots; |
|
2744 |
return a; |
|
2745 |
} |
|
2746 |
||
2747 |
void DomCustomWidget::setElementSlots(DomSlots* a) |
|
2748 |
{ |
|
2749 |
delete m_slots; |
|
2750 |
m_children |= Slots; |
|
2751 |
m_slots = a; |
|
2752 |
} |
|
2753 |
||
2754 |
DomPropertySpecifications* DomCustomWidget::takeElementPropertyspecifications() |
|
2755 |
{ |
|
2756 |
DomPropertySpecifications* a = m_propertyspecifications; |
|
2757 |
m_propertyspecifications = 0; |
|
2758 |
m_children ^= Propertyspecifications; |
|
2759 |
return a; |
|
2760 |
} |
|
2761 |
||
2762 |
void DomCustomWidget::setElementPropertyspecifications(DomPropertySpecifications* a) |
|
2763 |
{ |
|
2764 |
delete m_propertyspecifications; |
|
2765 |
m_children |= Propertyspecifications; |
|
2766 |
m_propertyspecifications = a; |
|
2767 |
} |
|
2768 |
||
2769 |
void DomCustomWidget::clearElementClass() |
|
2770 |
{ |
|
2771 |
m_children &= ~Class; |
|
2772 |
} |
|
2773 |
||
2774 |
void DomCustomWidget::clearElementExtends() |
|
2775 |
{ |
|
2776 |
m_children &= ~Extends; |
|
2777 |
} |
|
2778 |
||
2779 |
void DomCustomWidget::clearElementHeader() |
|
2780 |
{ |
|
2781 |
delete m_header; |
|
2782 |
m_header = 0; |
|
2783 |
m_children &= ~Header; |
|
2784 |
} |
|
2785 |
||
2786 |
void DomCustomWidget::clearElementSizeHint() |
|
2787 |
{ |
|
2788 |
delete m_sizeHint; |
|
2789 |
m_sizeHint = 0; |
|
2790 |
m_children &= ~SizeHint; |
|
2791 |
} |
|
2792 |
||
2793 |
void DomCustomWidget::clearElementAddPageMethod() |
|
2794 |
{ |
|
2795 |
m_children &= ~AddPageMethod; |
|
2796 |
} |
|
2797 |
||
2798 |
void DomCustomWidget::clearElementContainer() |
|
2799 |
{ |
|
2800 |
m_children &= ~Container; |
|
2801 |
} |
|
2802 |
||
2803 |
void DomCustomWidget::clearElementSizePolicy() |
|
2804 |
{ |
|
2805 |
delete m_sizePolicy; |
|
2806 |
m_sizePolicy = 0; |
|
2807 |
m_children &= ~SizePolicy; |
|
2808 |
} |
|
2809 |
||
2810 |
void DomCustomWidget::clearElementPixmap() |
|
2811 |
{ |
|
2812 |
m_children &= ~Pixmap; |
|
2813 |
} |
|
2814 |
||
2815 |
void DomCustomWidget::clearElementScript() |
|
2816 |
{ |
|
2817 |
delete m_script; |
|
2818 |
m_script = 0; |
|
2819 |
m_children &= ~Script; |
|
2820 |
} |
|
2821 |
||
2822 |
void DomCustomWidget::clearElementProperties() |
|
2823 |
{ |
|
2824 |
delete m_properties; |
|
2825 |
m_properties = 0; |
|
2826 |
m_children &= ~Properties; |
|
2827 |
} |
|
2828 |
||
2829 |
void DomCustomWidget::clearElementSlots() |
|
2830 |
{ |
|
2831 |
delete m_slots; |
|
2832 |
m_slots = 0; |
|
2833 |
m_children &= ~Slots; |
|
2834 |
} |
|
2835 |
||
2836 |
void DomCustomWidget::clearElementPropertyspecifications() |
|
2837 |
{ |
|
2838 |
delete m_propertyspecifications; |
|
2839 |
m_propertyspecifications = 0; |
|
2840 |
m_children &= ~Propertyspecifications; |
|
2841 |
} |
|
2842 |
||
2843 |
void DomProperties::clear(bool clear_all) |
|
2844 |
{ |
|
2845 |
qDeleteAll(m_property); |
|
2846 |
m_property.clear(); |
|
2847 |
||
2848 |
if (clear_all) { |
|
2849 |
m_text.clear(); |
|
2850 |
} |
|
2851 |
||
2852 |
m_children = 0; |
|
2853 |
} |
|
2854 |
||
2855 |
DomProperties::DomProperties() |
|
2856 |
{ |
|
2857 |
m_children = 0; |
|
2858 |
} |
|
2859 |
||
2860 |
DomProperties::~DomProperties() |
|
2861 |
{ |
|
2862 |
qDeleteAll(m_property); |
|
2863 |
m_property.clear(); |
|
2864 |
} |
|
2865 |
||
2866 |
void DomProperties::read(QXmlStreamReader &reader) |
|
2867 |
{ |
|
2868 |
||
2869 |
for (bool finished = false; !finished && !reader.hasError();) { |
|
2870 |
switch (reader.readNext()) { |
|
2871 |
case QXmlStreamReader::StartElement : { |
|
2872 |
const QString tag = reader.name().toString().toLower(); |
|
2873 |
if (tag == QLatin1String("property")) { |
|
2874 |
DomPropertyData *v = new DomPropertyData(); |
|
2875 |
v->read(reader); |
|
2876 |
m_property.append(v); |
|
2877 |
continue; |
|
2878 |
} |
|
2879 |
reader.raiseError(QLatin1String("Unexpected element ") + tag); |
|
2880 |
} |
|
2881 |
break; |
|
2882 |
case QXmlStreamReader::EndElement : |
|
2883 |
finished = true; |
|
2884 |
break; |
|
2885 |
case QXmlStreamReader::Characters : |
|
2886 |
if (!reader.isWhitespace()) |
|
2887 |
m_text.append(reader.text().toString()); |
|
2888 |
break; |
|
2889 |
default : |
|
2890 |
break; |
|
2891 |
} |
|
2892 |
} |
|
2893 |
} |
|
2894 |
||
2895 |
#ifdef QUILOADER_QDOM_READ |
|
2896 |
void DomProperties::read(const QDomElement &node) |
|
2897 |
{ |
|
2898 |
for (QDomNode n = node.firstChild(); !n.isNull(); n = n.nextSibling()) { |
|
2899 |
if (!n.isElement()) |
|
2900 |
continue; |
|
2901 |
QDomElement e = n.toElement(); |
|
2902 |
QString tag = e.tagName().toLower(); |
|
2903 |
if (tag == QLatin1String("property")) { |
|
2904 |
DomPropertyData *v = new DomPropertyData(); |
|
2905 |
v->read(e); |
|
2906 |
m_property.append(v); |
|
2907 |
continue; |
|
2908 |
} |
|
2909 |
} |
|
2910 |
m_text.clear(); |
|
2911 |
for (QDomNode child = node.firstChild(); !child.isNull(); child = child.nextSibling()) { |
|
2912 |
if (child.isText()) |
|
2913 |
m_text.append(child.nodeValue()); |
|
2914 |
} |
|
2915 |
} |
|
2916 |
#endif |
|
2917 |
||
2918 |
void DomProperties::write(QXmlStreamWriter &writer, const QString &tagName) const |
|
2919 |
{ |
|
2920 |
writer.writeStartElement(tagName.isEmpty() ? QString::fromUtf8("properties") : tagName.toLower()); |
|
2921 |
||
2922 |
for (int i = 0; i < m_property.size(); ++i) { |
|
2923 |
DomPropertyData* v = m_property[i]; |
|
2924 |
v->write(writer, QLatin1String("property")); |
|
2925 |
} |
|
2926 |
if (!m_text.isEmpty()) |
|
2927 |
writer.writeCharacters(m_text); |
|
2928 |
||
2929 |
writer.writeEndElement(); |
|
2930 |
} |
|
2931 |
||
2932 |
void DomProperties::setElementProperty(const QList<DomPropertyData*>& a) |
|
2933 |
{ |
|
2934 |
m_children |= Property; |
|
2935 |
m_property = a; |
|
2936 |
} |
|
2937 |
||
2938 |
void DomPropertyData::clear(bool clear_all) |
|
2939 |
{ |
|
2940 |
||
2941 |
if (clear_all) { |
|
2942 |
m_text.clear(); |
|
2943 |
m_has_attr_type = false; |
|
2944 |
} |
|
2945 |
||
2946 |
m_children = 0; |
|
2947 |
} |
|
2948 |
||
2949 |
DomPropertyData::DomPropertyData() |
|
2950 |
{ |
|
2951 |
m_children = 0; |
|
2952 |
m_has_attr_type = false; |
|
2953 |
} |
|
2954 |
||
2955 |
DomPropertyData::~DomPropertyData() |
|
2956 |
{ |
|
2957 |
} |
|
2958 |
||
2959 |
void DomPropertyData::read(QXmlStreamReader &reader) |
|
2960 |
{ |
|
2961 |
||
2962 |
foreach (const QXmlStreamAttribute &attribute, reader.attributes()) { |
|
2963 |
QStringRef name = attribute.name(); |
|
2964 |
if (name == QLatin1String("type")) { |
|
2965 |
setAttributeType(attribute.value().toString()); |
|
2966 |
continue; |
|
2967 |
} |
|
2968 |
reader.raiseError(QLatin1String("Unexpected attribute ") + name.toString()); |
|
2969 |
} |
|
2970 |
||
2971 |
for (bool finished = false; !finished && !reader.hasError();) { |
|
2972 |
switch (reader.readNext()) { |
|
2973 |
case QXmlStreamReader::StartElement : { |
|
2974 |
const QString tag = reader.name().toString().toLower(); |
|
2975 |
reader.raiseError(QLatin1String("Unexpected element ") + tag); |
|
2976 |
} |
|
2977 |
break; |
|
2978 |
case QXmlStreamReader::EndElement : |
|
2979 |
finished = true; |
|
2980 |
break; |
|
2981 |
case QXmlStreamReader::Characters : |
|
2982 |
if (!reader.isWhitespace()) |
|
2983 |
m_text.append(reader.text().toString()); |
|
2984 |
break; |
|
2985 |
default : |
|
2986 |
break; |
|
2987 |
} |
|
2988 |
} |
|
2989 |
} |
|
2990 |
||
2991 |
#ifdef QUILOADER_QDOM_READ |
|
2992 |
void DomPropertyData::read(const QDomElement &node) |
|
2993 |
{ |
|
2994 |
if (node.hasAttribute(QLatin1String("type"))) |
|
2995 |
setAttributeType(node.attribute(QLatin1String("type"))); |
|
2996 |
||
2997 |
for (QDomNode n = node.firstChild(); !n.isNull(); n = n.nextSibling()) { |
|
2998 |
if (!n.isElement()) |
|
2999 |
continue; |
|
3000 |
QDomElement e = n.toElement(); |
|
3001 |
QString tag = e.tagName().toLower(); |
|
3002 |
} |
|
3003 |
m_text.clear(); |
|
3004 |
for (QDomNode child = node.firstChild(); !child.isNull(); child = child.nextSibling()) { |
|
3005 |
if (child.isText()) |
|
3006 |
m_text.append(child.nodeValue()); |
|
3007 |
} |
|
3008 |
} |
|
3009 |
#endif |
|
3010 |
||
3011 |
void DomPropertyData::write(QXmlStreamWriter &writer, const QString &tagName) const |
|
3012 |
{ |
|
3013 |
writer.writeStartElement(tagName.isEmpty() ? QString::fromUtf8("propertydata") : tagName.toLower()); |
|
3014 |
||
3015 |
if (hasAttributeType()) |
|
3016 |
writer.writeAttribute(QLatin1String("type"), attributeType()); |
|
3017 |
||
3018 |
if (!m_text.isEmpty()) |
|
3019 |
writer.writeCharacters(m_text); |
|
3020 |
||
3021 |
writer.writeEndElement(); |
|
3022 |
} |
|
3023 |
||
3024 |
void DomSizePolicyData::clear(bool clear_all) |
|
3025 |
{ |
|
3026 |
||
3027 |
if (clear_all) { |
|
3028 |
m_text.clear(); |
|
3029 |
} |
|
3030 |
||
3031 |
m_children = 0; |
|
3032 |
m_horData = 0; |
|
3033 |
m_verData = 0; |
|
3034 |
} |
|
3035 |
||
3036 |
DomSizePolicyData::DomSizePolicyData() |
|
3037 |
{ |
|
3038 |
m_children = 0; |
|
3039 |
m_horData = 0; |
|
3040 |
m_verData = 0; |
|
3041 |
} |
|
3042 |
||
3043 |
DomSizePolicyData::~DomSizePolicyData() |
|
3044 |
{ |
|
3045 |
} |
|
3046 |
||
3047 |
void DomSizePolicyData::read(QXmlStreamReader &reader) |
|
3048 |
{ |
|
3049 |
||
3050 |
for (bool finished = false; !finished && !reader.hasError();) { |
|
3051 |
switch (reader.readNext()) { |
|
3052 |
case QXmlStreamReader::StartElement : { |
|
3053 |
const QString tag = reader.name().toString().toLower(); |
|
3054 |
if (tag == QLatin1String("hordata")) { |
|
3055 |
setElementHorData(reader.readElementText().toInt()); |
|
3056 |
continue; |
|
3057 |
} |
|
3058 |
if (tag == QLatin1String("verdata")) { |
|
3059 |
setElementVerData(reader.readElementText().toInt()); |
|
3060 |
continue; |
|
3061 |
} |
|
3062 |
reader.raiseError(QLatin1String("Unexpected element ") + tag); |
|
3063 |
} |
|
3064 |
break; |
|
3065 |
case QXmlStreamReader::EndElement : |
|
3066 |
finished = true; |
|
3067 |
break; |
|
3068 |
case QXmlStreamReader::Characters : |
|
3069 |
if (!reader.isWhitespace()) |
|
3070 |
m_text.append(reader.text().toString()); |
|
3071 |
break; |
|
3072 |
default : |
|
3073 |
break; |
|
3074 |
} |
|
3075 |
} |
|
3076 |
} |
|
3077 |
||
3078 |
#ifdef QUILOADER_QDOM_READ |
|
3079 |
void DomSizePolicyData::read(const QDomElement &node) |
|
3080 |
{ |
|
3081 |
for (QDomNode n = node.firstChild(); !n.isNull(); n = n.nextSibling()) { |
|
3082 |
if (!n.isElement()) |
|
3083 |
continue; |
|
3084 |
QDomElement e = n.toElement(); |
|
3085 |
QString tag = e.tagName().toLower(); |
|
3086 |
if (tag == QLatin1String("hordata")) { |
|
3087 |
setElementHorData(e.text().toInt()); |
|
3088 |
continue; |
|
3089 |
} |
|
3090 |
if (tag == QLatin1String("verdata")) { |
|
3091 |
setElementVerData(e.text().toInt()); |
|
3092 |
continue; |
|
3093 |
} |
|
3094 |
} |
|
3095 |
m_text.clear(); |
|
3096 |
for (QDomNode child = node.firstChild(); !child.isNull(); child = child.nextSibling()) { |
|
3097 |
if (child.isText()) |
|
3098 |
m_text.append(child.nodeValue()); |
|
3099 |
} |
|
3100 |
} |
|
3101 |
#endif |
|
3102 |
||
3103 |
void DomSizePolicyData::write(QXmlStreamWriter &writer, const QString &tagName) const |
|
3104 |
{ |
|
3105 |
writer.writeStartElement(tagName.isEmpty() ? QString::fromUtf8("sizepolicydata") : tagName.toLower()); |
|
3106 |
||
3107 |
if (m_children & HorData) { |
|
3108 |
writer.writeTextElement(QLatin1String("hordata"), QString::number(m_horData)); |
|
3109 |
} |
|
3110 |
||
3111 |
if (m_children & VerData) { |
|
3112 |
writer.writeTextElement(QLatin1String("verdata"), QString::number(m_verData)); |
|
3113 |
} |
|
3114 |
||
3115 |
if (!m_text.isEmpty()) |
|
3116 |
writer.writeCharacters(m_text); |
|
3117 |
||
3118 |
writer.writeEndElement(); |
|
3119 |
} |
|
3120 |
||
3121 |
void DomSizePolicyData::setElementHorData(int a) |
|
3122 |
{ |
|
3123 |
m_children |= HorData; |
|
3124 |
m_horData = a; |
|
3125 |
} |
|
3126 |
||
3127 |
void DomSizePolicyData::setElementVerData(int a) |
|
3128 |
{ |
|
3129 |
m_children |= VerData; |
|
3130 |
m_verData = a; |
|
3131 |
} |
|
3132 |
||
3133 |
void DomSizePolicyData::clearElementHorData() |
|
3134 |
{ |
|
3135 |
m_children &= ~HorData; |
|
3136 |
} |
|
3137 |
||
3138 |
void DomSizePolicyData::clearElementVerData() |
|
3139 |
{ |
|
3140 |
m_children &= ~VerData; |
|
3141 |
} |
|
3142 |
||
3143 |
void DomLayoutDefault::clear(bool clear_all) |
|
3144 |
{ |
|
3145 |
||
3146 |
if (clear_all) { |
|
3147 |
m_text.clear(); |
|
3148 |
m_has_attr_spacing = false; |
|
3149 |
m_attr_spacing = 0; |
|
3150 |
m_has_attr_margin = false; |
|
3151 |
m_attr_margin = 0; |
|
3152 |
} |
|
3153 |
||
3154 |
m_children = 0; |
|
3155 |
} |
|
3156 |
||
3157 |
DomLayoutDefault::DomLayoutDefault() |
|
3158 |
{ |
|
3159 |
m_children = 0; |
|
3160 |
m_has_attr_spacing = false; |
|
3161 |
m_attr_spacing = 0; |
|
3162 |
m_has_attr_margin = false; |
|
3163 |
m_attr_margin = 0; |
|
3164 |
} |
|
3165 |
||
3166 |
DomLayoutDefault::~DomLayoutDefault() |
|
3167 |
{ |
|
3168 |
} |
|
3169 |
||
3170 |
void DomLayoutDefault::read(QXmlStreamReader &reader) |
|
3171 |
{ |
|
3172 |
||
3173 |
foreach (const QXmlStreamAttribute &attribute, reader.attributes()) { |
|
3174 |
QStringRef name = attribute.name(); |
|
3175 |
if (name == QLatin1String("spacing")) { |
|
3176 |
setAttributeSpacing(attribute.value().toString().toInt()); |
|
3177 |
continue; |
|
3178 |
} |
|
3179 |
if (name == QLatin1String("margin")) { |
|
3180 |
setAttributeMargin(attribute.value().toString().toInt()); |
|
3181 |
continue; |
|
3182 |
} |
|
3183 |
reader.raiseError(QLatin1String("Unexpected attribute ") + name.toString()); |
|
3184 |
} |
|
3185 |
||
3186 |
for (bool finished = false; !finished && !reader.hasError();) { |
|
3187 |
switch (reader.readNext()) { |
|
3188 |
case QXmlStreamReader::StartElement : { |
|
3189 |
const QString tag = reader.name().toString().toLower(); |
|
3190 |
reader.raiseError(QLatin1String("Unexpected element ") + tag); |
|
3191 |
} |
|
3192 |
break; |
|
3193 |
case QXmlStreamReader::EndElement : |
|
3194 |
finished = true; |
|
3195 |
break; |
|
3196 |
case QXmlStreamReader::Characters : |
|
3197 |
if (!reader.isWhitespace()) |
|
3198 |
m_text.append(reader.text().toString()); |
|
3199 |
break; |
|
3200 |
default : |
|
3201 |
break; |
|
3202 |
} |
|
3203 |
} |
|
3204 |
} |
|
3205 |
||
3206 |
#ifdef QUILOADER_QDOM_READ |
|
3207 |
void DomLayoutDefault::read(const QDomElement &node) |
|
3208 |
{ |
|
3209 |
if (node.hasAttribute(QLatin1String("spacing"))) |
|
3210 |
setAttributeSpacing(node.attribute(QLatin1String("spacing")).toInt()); |
|
3211 |
if (node.hasAttribute(QLatin1String("margin"))) |
|
3212 |
setAttributeMargin(node.attribute(QLatin1String("margin")).toInt()); |
|
3213 |
||
3214 |
for (QDomNode n = node.firstChild(); !n.isNull(); n = n.nextSibling()) { |
|
3215 |
if (!n.isElement()) |
|
3216 |
continue; |
|
3217 |
QDomElement e = n.toElement(); |
|
3218 |
QString tag = e.tagName().toLower(); |
|
3219 |
} |
|
3220 |
m_text.clear(); |
|
3221 |
for (QDomNode child = node.firstChild(); !child.isNull(); child = child.nextSibling()) { |
|
3222 |
if (child.isText()) |
|
3223 |
m_text.append(child.nodeValue()); |
|
3224 |
} |
|
3225 |
} |
|
3226 |
#endif |
|
3227 |
||
3228 |
void DomLayoutDefault::write(QXmlStreamWriter &writer, const QString &tagName) const |
|
3229 |
{ |
|
3230 |
writer.writeStartElement(tagName.isEmpty() ? QString::fromUtf8("layoutdefault") : tagName.toLower()); |
|
3231 |
||
3232 |
if (hasAttributeSpacing()) |
|
3233 |
writer.writeAttribute(QLatin1String("spacing"), QString::number(attributeSpacing())); |
|
3234 |
||
3235 |
if (hasAttributeMargin()) |
|
3236 |
writer.writeAttribute(QLatin1String("margin"), QString::number(attributeMargin())); |
|
3237 |
||
3238 |
if (!m_text.isEmpty()) |
|
3239 |
writer.writeCharacters(m_text); |
|
3240 |
||
3241 |
writer.writeEndElement(); |
|
3242 |
} |
|
3243 |
||
3244 |
void DomLayoutFunction::clear(bool clear_all) |
|
3245 |
{ |
|
3246 |
||
3247 |
if (clear_all) { |
|
3248 |
m_text.clear(); |
|
3249 |
m_has_attr_spacing = false; |
|
3250 |
m_has_attr_margin = false; |
|
3251 |
} |
|
3252 |
||
3253 |
m_children = 0; |
|
3254 |
} |
|
3255 |
||
3256 |
DomLayoutFunction::DomLayoutFunction() |
|
3257 |
{ |
|
3258 |
m_children = 0; |
|
3259 |
m_has_attr_spacing = false; |
|
3260 |
m_has_attr_margin = false; |
|
3261 |
} |
|
3262 |
||
3263 |
DomLayoutFunction::~DomLayoutFunction() |
|
3264 |
{ |
|
3265 |
} |
|
3266 |
||
3267 |
void DomLayoutFunction::read(QXmlStreamReader &reader) |
|
3268 |
{ |
|
3269 |
||
3270 |
foreach (const QXmlStreamAttribute &attribute, reader.attributes()) { |
|
3271 |
QStringRef name = attribute.name(); |
|
3272 |
if (name == QLatin1String("spacing")) { |
|
3273 |
setAttributeSpacing(attribute.value().toString()); |
|
3274 |
continue; |
|
3275 |
} |
|
3276 |
if (name == QLatin1String("margin")) { |
|
3277 |
setAttributeMargin(attribute.value().toString()); |
|
3278 |
continue; |
|
3279 |
} |
|
3280 |
reader.raiseError(QLatin1String("Unexpected attribute ") + name.toString()); |
|
3281 |
} |
|
3282 |
||
3283 |
for (bool finished = false; !finished && !reader.hasError();) { |
|
3284 |
switch (reader.readNext()) { |
|
3285 |
case QXmlStreamReader::StartElement : { |
|
3286 |
const QString tag = reader.name().toString().toLower(); |
|
3287 |
reader.raiseError(QLatin1String("Unexpected element ") + tag); |
|
3288 |
} |
|
3289 |
break; |
|
3290 |
case QXmlStreamReader::EndElement : |
|
3291 |
finished = true; |
|
3292 |
break; |
|
3293 |
case QXmlStreamReader::Characters : |
|
3294 |
if (!reader.isWhitespace()) |
|
3295 |
m_text.append(reader.text().toString()); |
|
3296 |
break; |
|
3297 |
default : |
|
3298 |
break; |
|
3299 |
} |
|
3300 |
} |
|
3301 |
} |
|
3302 |
||
3303 |
#ifdef QUILOADER_QDOM_READ |
|
3304 |
void DomLayoutFunction::read(const QDomElement &node) |
|
3305 |
{ |
|
3306 |
if (node.hasAttribute(QLatin1String("spacing"))) |
|
3307 |
setAttributeSpacing(node.attribute(QLatin1String("spacing"))); |
|
3308 |
if (node.hasAttribute(QLatin1String("margin"))) |
|
3309 |
setAttributeMargin(node.attribute(QLatin1String("margin"))); |
|
3310 |
||
3311 |
for (QDomNode n = node.firstChild(); !n.isNull(); n = n.nextSibling()) { |
|
3312 |
if (!n.isElement()) |
|
3313 |
continue; |
|
3314 |
QDomElement e = n.toElement(); |
|
3315 |
QString tag = e.tagName().toLower(); |
|
3316 |
} |
|
3317 |
m_text.clear(); |
|
3318 |
for (QDomNode child = node.firstChild(); !child.isNull(); child = child.nextSibling()) { |
|
3319 |
if (child.isText()) |
|
3320 |
m_text.append(child.nodeValue()); |
|
3321 |
} |
|
3322 |
} |
|
3323 |
#endif |
|
3324 |
||
3325 |
void DomLayoutFunction::write(QXmlStreamWriter &writer, const QString &tagName) const |
|
3326 |
{ |
|
3327 |
writer.writeStartElement(tagName.isEmpty() ? QString::fromUtf8("layoutfunction") : tagName.toLower()); |
|
3328 |
||
3329 |
if (hasAttributeSpacing()) |
|
3330 |
writer.writeAttribute(QLatin1String("spacing"), attributeSpacing()); |
|
3331 |
||
3332 |
if (hasAttributeMargin()) |
|
3333 |
writer.writeAttribute(QLatin1String("margin"), attributeMargin()); |
|
3334 |
||
3335 |
if (!m_text.isEmpty()) |
|
3336 |
writer.writeCharacters(m_text); |
|
3337 |
||
3338 |
writer.writeEndElement(); |
|
3339 |
} |
|
3340 |
||
3341 |
void DomTabStops::clear(bool clear_all) |
|
3342 |
{ |
|
3343 |
m_tabStop.clear(); |
|
3344 |
||
3345 |
if (clear_all) { |
|
3346 |
m_text.clear(); |
|
3347 |
} |
|
3348 |
||
3349 |
m_children = 0; |
|
3350 |
} |
|
3351 |
||
3352 |
DomTabStops::DomTabStops() |
|
3353 |
{ |
|
3354 |
m_children = 0; |
|
3355 |
} |
|
3356 |
||
3357 |
DomTabStops::~DomTabStops() |
|
3358 |
{ |
|
3359 |
m_tabStop.clear(); |
|
3360 |
} |
|
3361 |
||
3362 |
void DomTabStops::read(QXmlStreamReader &reader) |
|
3363 |
{ |
|
3364 |
||
3365 |
for (bool finished = false; !finished && !reader.hasError();) { |
|
3366 |
switch (reader.readNext()) { |
|
3367 |
case QXmlStreamReader::StartElement : { |
|
3368 |
const QString tag = reader.name().toString().toLower(); |
|
3369 |
if (tag == QLatin1String("tabstop")) { |
|
3370 |
m_tabStop.append(reader.readElementText()); |
|
3371 |
continue; |
|
3372 |
} |
|
3373 |
reader.raiseError(QLatin1String("Unexpected element ") + tag); |
|
3374 |
} |
|
3375 |
break; |
|
3376 |
case QXmlStreamReader::EndElement : |
|
3377 |
finished = true; |
|
3378 |
break; |
|
3379 |
case QXmlStreamReader::Characters : |
|
3380 |
if (!reader.isWhitespace()) |
|
3381 |
m_text.append(reader.text().toString()); |
|
3382 |
break; |
|
3383 |
default : |
|
3384 |
break; |
|
3385 |
} |
|
3386 |
} |
|
3387 |
} |
|
3388 |
||
3389 |
#ifdef QUILOADER_QDOM_READ |
|
3390 |
void DomTabStops::read(const QDomElement &node) |
|
3391 |
{ |
|
3392 |
for (QDomNode n = node.firstChild(); !n.isNull(); n = n.nextSibling()) { |
|
3393 |
if (!n.isElement()) |
|
3394 |
continue; |
|
3395 |
QDomElement e = n.toElement(); |
|
3396 |
QString tag = e.tagName().toLower(); |
|
3397 |
if (tag == QLatin1String("tabstop")) { |
|
3398 |
m_tabStop.append(e.text()); |
|
3399 |
continue; |
|
3400 |
} |
|
3401 |
} |
|
3402 |
m_text.clear(); |
|
3403 |
for (QDomNode child = node.firstChild(); !child.isNull(); child = child.nextSibling()) { |
|
3404 |
if (child.isText()) |
|
3405 |
m_text.append(child.nodeValue()); |
|
3406 |
} |
|
3407 |
} |
|
3408 |
#endif |
|
3409 |
||
3410 |
void DomTabStops::write(QXmlStreamWriter &writer, const QString &tagName) const |
|
3411 |
{ |
|
3412 |
writer.writeStartElement(tagName.isEmpty() ? QString::fromUtf8("tabstops") : tagName.toLower()); |
|
3413 |
||
3414 |
for (int i = 0; i < m_tabStop.size(); ++i) { |
|
3415 |
QString v = m_tabStop[i]; |
|
3416 |
writer.writeTextElement(QLatin1String("tabstop"), v); |
|
3417 |
} |
|
3418 |
if (!m_text.isEmpty()) |
|
3419 |
writer.writeCharacters(m_text); |
|
3420 |
||
3421 |
writer.writeEndElement(); |
|
3422 |
} |
|
3423 |
||
3424 |
void DomTabStops::setElementTabStop(const QStringList& a) |
|
3425 |
{ |
|
3426 |
m_children |= TabStop; |
|
3427 |
m_tabStop = a; |
|
3428 |
} |
|
3429 |
||
3430 |
void DomLayout::clear(bool clear_all) |
|
3431 |
{ |
|
3432 |
qDeleteAll(m_property); |
|
3433 |
m_property.clear(); |
|
3434 |
qDeleteAll(m_attribute); |
|
3435 |
m_attribute.clear(); |
|
3436 |
qDeleteAll(m_item); |
|
3437 |
m_item.clear(); |
|
3438 |
||
3439 |
if (clear_all) { |
|
3440 |
m_text.clear(); |
|
3441 |
m_has_attr_class = false; |
|
3442 |
m_has_attr_name = false; |
|
3443 |
m_has_attr_stretch = false; |
|
3444 |
m_has_attr_rowStretch = false; |
|
3445 |
m_has_attr_columnStretch = false; |
|
3446 |
m_has_attr_rowMinimumHeight = false; |
|
3447 |
m_has_attr_columnMinimumWidth = false; |
|
3448 |
} |
|
3449 |
||
3450 |
m_children = 0; |
|
3451 |
} |
|
3452 |
||
3453 |
DomLayout::DomLayout() |
|
3454 |
{ |
|
3455 |
m_children = 0; |
|
3456 |
m_has_attr_class = false; |
|
3457 |
m_has_attr_name = false; |
|
3458 |
m_has_attr_stretch = false; |
|
3459 |
m_has_attr_rowStretch = false; |
|
3460 |
m_has_attr_columnStretch = false; |
|
3461 |
m_has_attr_rowMinimumHeight = false; |
|
3462 |
m_has_attr_columnMinimumWidth = false; |
|
3463 |
} |
|
3464 |
||
3465 |
DomLayout::~DomLayout() |
|
3466 |
{ |
|
3467 |
qDeleteAll(m_property); |
|
3468 |
m_property.clear(); |
|
3469 |
qDeleteAll(m_attribute); |
|
3470 |
m_attribute.clear(); |
|
3471 |
qDeleteAll(m_item); |
|
3472 |
m_item.clear(); |
|
3473 |
} |
|
3474 |
||
3475 |
void DomLayout::read(QXmlStreamReader &reader) |
|
3476 |
{ |
|
3477 |
||
3478 |
foreach (const QXmlStreamAttribute &attribute, reader.attributes()) { |
|
3479 |
QStringRef name = attribute.name(); |
|
3480 |
if (name == QLatin1String("class")) { |
|
3481 |
setAttributeClass(attribute.value().toString()); |
|
3482 |
continue; |
|
3483 |
} |
|
3484 |
if (name == QLatin1String("name")) { |
|
3485 |
setAttributeName(attribute.value().toString()); |
|
3486 |
continue; |
|
3487 |
} |
|
3488 |
if (name == QLatin1String("stretch")) { |
|
3489 |
setAttributeStretch(attribute.value().toString()); |
|
3490 |
continue; |
|
3491 |
} |
|
3492 |
if (name == QLatin1String("rowstretch")) { |
|
3493 |
setAttributeRowStretch(attribute.value().toString()); |
|
3494 |
continue; |
|
3495 |
} |
|
3496 |
if (name == QLatin1String("columnstretch")) { |
|
3497 |
setAttributeColumnStretch(attribute.value().toString()); |
|
3498 |
continue; |
|
3499 |
} |
|
3500 |
if (name == QLatin1String("rowminimumheight")) { |
|
3501 |
setAttributeRowMinimumHeight(attribute.value().toString()); |
|
3502 |
continue; |
|
3503 |
} |
|
3504 |
if (name == QLatin1String("columnminimumwidth")) { |
|
3505 |
setAttributeColumnMinimumWidth(attribute.value().toString()); |
|
3506 |
continue; |
|
3507 |
} |
|
3508 |
reader.raiseError(QLatin1String("Unexpected attribute ") + name.toString()); |
|
3509 |
} |
|
3510 |
||
3511 |
for (bool finished = false; !finished && !reader.hasError();) { |
|
3512 |
switch (reader.readNext()) { |
|
3513 |
case QXmlStreamReader::StartElement : { |
|
3514 |
const QString tag = reader.name().toString().toLower(); |
|
3515 |
if (tag == QLatin1String("property")) { |
|
3516 |
DomProperty *v = new DomProperty(); |
|
3517 |
v->read(reader); |
|
3518 |
m_property.append(v); |
|
3519 |
continue; |
|
3520 |
} |
|
3521 |
if (tag == QLatin1String("attribute")) { |
|
3522 |
DomProperty *v = new DomProperty(); |
|
3523 |
v->read(reader); |
|
3524 |
m_attribute.append(v); |
|
3525 |
continue; |
|
3526 |
} |
|
3527 |
if (tag == QLatin1String("item")) { |
|
3528 |
DomLayoutItem *v = new DomLayoutItem(); |
|
3529 |
v->read(reader); |
|
3530 |
m_item.append(v); |
|
3531 |
continue; |
|
3532 |
} |
|
3533 |
reader.raiseError(QLatin1String("Unexpected element ") + tag); |
|
3534 |
} |
|
3535 |
break; |
|
3536 |
case QXmlStreamReader::EndElement : |
|
3537 |
finished = true; |
|
3538 |
break; |
|
3539 |
case QXmlStreamReader::Characters : |
|
3540 |
if (!reader.isWhitespace()) |
|
3541 |
m_text.append(reader.text().toString()); |
|
3542 |
break; |
|
3543 |
default : |
|
3544 |
break; |
|
3545 |
} |
|
3546 |
} |
|
3547 |
} |
|
3548 |
||
3549 |
#ifdef QUILOADER_QDOM_READ |
|
3550 |
void DomLayout::read(const QDomElement &node) |
|
3551 |
{ |
|
3552 |
if (node.hasAttribute(QLatin1String("class"))) |
|
3553 |
setAttributeClass(node.attribute(QLatin1String("class"))); |
|
3554 |
if (node.hasAttribute(QLatin1String("name"))) |
|
3555 |
setAttributeName(node.attribute(QLatin1String("name"))); |
|
3556 |
if (node.hasAttribute(QLatin1String("stretch"))) |
|
3557 |
setAttributeStretch(node.attribute(QLatin1String("stretch"))); |
|
3558 |
if (node.hasAttribute(QLatin1String("rowstretch"))) |
|
3559 |
setAttributeRowStretch(node.attribute(QLatin1String("rowstretch"))); |
|
3560 |
if (node.hasAttribute(QLatin1String("columnstretch"))) |
|
3561 |
setAttributeColumnStretch(node.attribute(QLatin1String("columnstretch"))); |
|
3562 |
if (node.hasAttribute(QLatin1String("rowminimumheight"))) |
|
3563 |
setAttributeRowMinimumHeight(node.attribute(QLatin1String("rowminimumheight"))); |
|
3564 |
if (node.hasAttribute(QLatin1String("columnminimumwidth"))) |
|
3565 |
setAttributeColumnMinimumWidth(node.attribute(QLatin1String("columnminimumwidth"))); |
|
3566 |
||
3567 |
for (QDomNode n = node.firstChild(); !n.isNull(); n = n.nextSibling()) { |
|
3568 |
if (!n.isElement()) |
|
3569 |
continue; |
|
3570 |
QDomElement e = n.toElement(); |
|
3571 |
QString tag = e.tagName().toLower(); |
|
3572 |
if (tag == QLatin1String("property")) { |
|
3573 |
DomProperty *v = new DomProperty(); |
|
3574 |
v->read(e); |
|
3575 |
m_property.append(v); |
|
3576 |
continue; |
|
3577 |
} |
|
3578 |
if (tag == QLatin1String("attribute")) { |
|
3579 |
DomProperty *v = new DomProperty(); |
|
3580 |
v->read(e); |
|
3581 |
m_attribute.append(v); |
|
3582 |
continue; |
|
3583 |
} |
|
3584 |
if (tag == QLatin1String("item")) { |
|
3585 |
DomLayoutItem *v = new DomLayoutItem(); |
|
3586 |
v->read(e); |
|
3587 |
m_item.append(v); |
|
3588 |
continue; |
|
3589 |
} |
|
3590 |
} |
|
3591 |
m_text.clear(); |
|
3592 |
for (QDomNode child = node.firstChild(); !child.isNull(); child = child.nextSibling()) { |
|
3593 |
if (child.isText()) |
|
3594 |
m_text.append(child.nodeValue()); |
|
3595 |
} |
|
3596 |
} |
|
3597 |
#endif |
|
3598 |
||
3599 |
void DomLayout::write(QXmlStreamWriter &writer, const QString &tagName) const |
|
3600 |
{ |
|
3601 |
writer.writeStartElement(tagName.isEmpty() ? QString::fromUtf8("layout") : tagName.toLower()); |
|
3602 |
||
3603 |
if (hasAttributeClass()) |
|
3604 |
writer.writeAttribute(QLatin1String("class"), attributeClass()); |
|
3605 |
||
3606 |
if (hasAttributeName()) |
|
3607 |
writer.writeAttribute(QLatin1String("name"), attributeName()); |
|
3608 |
||
3609 |
if (hasAttributeStretch()) |
|
3610 |
writer.writeAttribute(QLatin1String("stretch"), attributeStretch()); |
|
3611 |
||
3612 |
if (hasAttributeRowStretch()) |
|
3613 |
writer.writeAttribute(QLatin1String("rowstretch"), attributeRowStretch()); |
|
3614 |
||
3615 |
if (hasAttributeColumnStretch()) |
|
3616 |
writer.writeAttribute(QLatin1String("columnstretch"), attributeColumnStretch()); |
|
3617 |
||
3618 |
if (hasAttributeRowMinimumHeight()) |
|
3619 |
writer.writeAttribute(QLatin1String("rowminimumheight"), attributeRowMinimumHeight()); |
|
3620 |
||
3621 |
if (hasAttributeColumnMinimumWidth()) |
|
3622 |
writer.writeAttribute(QLatin1String("columnminimumwidth"), attributeColumnMinimumWidth()); |
|
3623 |
||
3624 |
for (int i = 0; i < m_property.size(); ++i) { |
|
3625 |
DomProperty* v = m_property[i]; |
|
3626 |
v->write(writer, QLatin1String("property")); |
|
3627 |
} |
|
3628 |
for (int i = 0; i < m_attribute.size(); ++i) { |
|
3629 |
DomProperty* v = m_attribute[i]; |
|
3630 |
v->write(writer, QLatin1String("attribute")); |
|
3631 |
} |
|
3632 |
for (int i = 0; i < m_item.size(); ++i) { |
|
3633 |
DomLayoutItem* v = m_item[i]; |
|
3634 |
v->write(writer, QLatin1String("item")); |
|
3635 |
} |
|
3636 |
if (!m_text.isEmpty()) |
|
3637 |
writer.writeCharacters(m_text); |
|
3638 |
||
3639 |
writer.writeEndElement(); |
|
3640 |
} |
|
3641 |
||
3642 |
void DomLayout::setElementProperty(const QList<DomProperty*>& a) |
|
3643 |
{ |
|
3644 |
m_children |= Property; |
|
3645 |
m_property = a; |
|
3646 |
} |
|
3647 |
||
3648 |
void DomLayout::setElementAttribute(const QList<DomProperty*>& a) |
|
3649 |
{ |
|
3650 |
m_children |= Attribute; |
|
3651 |
m_attribute = a; |
|
3652 |
} |
|
3653 |
||
3654 |
void DomLayout::setElementItem(const QList<DomLayoutItem*>& a) |
|
3655 |
{ |
|
3656 |
m_children |= Item; |
|
3657 |
m_item = a; |
|
3658 |
} |
|
3659 |
||
3660 |
void DomLayoutItem::clear(bool clear_all) |
|
3661 |
{ |
|
3662 |
delete m_widget; |
|
3663 |
delete m_layout; |
|
3664 |
delete m_spacer; |
|
3665 |
||
3666 |
if (clear_all) { |
|
3667 |
m_text.clear(); |
|
3668 |
m_has_attr_row = false; |
|
3669 |
m_attr_row = 0; |
|
3670 |
m_has_attr_column = false; |
|
3671 |
m_attr_column = 0; |
|
3672 |
m_has_attr_rowSpan = false; |
|
3673 |
m_attr_rowSpan = 0; |
|
3674 |
m_has_attr_colSpan = false; |
|
3675 |
m_attr_colSpan = 0; |
|
3676 |
} |
|
3677 |
||
3678 |
m_kind = Unknown; |
|
3679 |
||
3680 |
m_widget = 0; |
|
3681 |
m_layout = 0; |
|
3682 |
m_spacer = 0; |
|
3683 |
} |
|
3684 |
||
3685 |
DomLayoutItem::DomLayoutItem() |
|
3686 |
{ |
|
3687 |
m_kind = Unknown; |
|
3688 |
||
3689 |
m_has_attr_row = false; |
|
3690 |
m_attr_row = 0; |
|
3691 |
m_has_attr_column = false; |
|
3692 |
m_attr_column = 0; |
|
3693 |
m_has_attr_rowSpan = false; |
|
3694 |
m_attr_rowSpan = 0; |
|
3695 |
m_has_attr_colSpan = false; |
|
3696 |
m_attr_colSpan = 0; |
|
3697 |
m_widget = 0; |
|
3698 |
m_layout = 0; |
|
3699 |
m_spacer = 0; |
|
3700 |
} |
|
3701 |
||
3702 |
DomLayoutItem::~DomLayoutItem() |
|
3703 |
{ |
|
3704 |
delete m_widget; |
|
3705 |
delete m_layout; |
|
3706 |
delete m_spacer; |
|
3707 |
} |
|
3708 |
||
3709 |
void DomLayoutItem::read(QXmlStreamReader &reader) |
|
3710 |
{ |
|
3711 |
||
3712 |
foreach (const QXmlStreamAttribute &attribute, reader.attributes()) { |
|
3713 |
QStringRef name = attribute.name(); |
|
3714 |
if (name == QLatin1String("row")) { |
|
3715 |
setAttributeRow(attribute.value().toString().toInt()); |
|
3716 |
continue; |
|
3717 |
} |
|
3718 |
if (name == QLatin1String("column")) { |
|
3719 |
setAttributeColumn(attribute.value().toString().toInt()); |
|
3720 |
continue; |
|
3721 |
} |
|
3722 |
if (name == QLatin1String("rowspan")) { |
|
3723 |
setAttributeRowSpan(attribute.value().toString().toInt()); |
|
3724 |
continue; |
|
3725 |
} |
|
3726 |
if (name == QLatin1String("colspan")) { |
|
3727 |
setAttributeColSpan(attribute.value().toString().toInt()); |
|
3728 |
continue; |
|
3729 |
} |
|
3730 |
reader.raiseError(QLatin1String("Unexpected attribute ") + name.toString()); |
|
3731 |
} |
|
3732 |
||
3733 |
for (bool finished = false; !finished && !reader.hasError();) { |
|
3734 |
switch (reader.readNext()) { |
|
3735 |
case QXmlStreamReader::StartElement : { |
|
3736 |
const QString tag = reader.name().toString().toLower(); |
|
3737 |
if (tag == QLatin1String("widget")) { |
|
3738 |
DomWidget *v = new DomWidget(); |
|
3739 |
v->read(reader); |
|
3740 |
setElementWidget(v); |
|
3741 |
continue; |
|
3742 |
} |
|
3743 |
if (tag == QLatin1String("layout")) { |
|
3744 |
DomLayout *v = new DomLayout(); |
|
3745 |
v->read(reader); |
|
3746 |
setElementLayout(v); |
|
3747 |
continue; |
|
3748 |
} |
|
3749 |
if (tag == QLatin1String("spacer")) { |
|
3750 |
DomSpacer *v = new DomSpacer(); |
|
3751 |
v->read(reader); |
|
3752 |
setElementSpacer(v); |
|
3753 |
continue; |
|
3754 |
} |
|
3755 |
reader.raiseError(QLatin1String("Unexpected element ") + tag); |
|
3756 |
} |
|
3757 |
break; |
|
3758 |
case QXmlStreamReader::EndElement : |
|
3759 |
finished = true; |
|
3760 |
break; |
|
3761 |
case QXmlStreamReader::Characters : |
|
3762 |
if (!reader.isWhitespace()) |
|
3763 |
m_text.append(reader.text().toString()); |
|
3764 |
break; |
|
3765 |
default : |
|
3766 |
break; |
|
3767 |
} |
|
3768 |
} |
|
3769 |
} |
|
3770 |
||
3771 |
#ifdef QUILOADER_QDOM_READ |
|
3772 |
void DomLayoutItem::read(const QDomElement &node) |
|
3773 |
{ |
|
3774 |
if (node.hasAttribute(QLatin1String("row"))) |
|
3775 |
setAttributeRow(node.attribute(QLatin1String("row")).toInt()); |
|
3776 |
if (node.hasAttribute(QLatin1String("column"))) |
|
3777 |
setAttributeColumn(node.attribute(QLatin1String("column")).toInt()); |
|
3778 |
if (node.hasAttribute(QLatin1String("rowspan"))) |
|
3779 |
setAttributeRowSpan(node.attribute(QLatin1String("rowspan")).toInt()); |
|
3780 |
if (node.hasAttribute(QLatin1String("colspan"))) |
|
3781 |
setAttributeColSpan(node.attribute(QLatin1String("colspan")).toInt()); |
|
3782 |
||
3783 |
for (QDomNode n = node.firstChild(); !n.isNull(); n = n.nextSibling()) { |
|
3784 |
if (!n.isElement()) |
|
3785 |
continue; |
|
3786 |
QDomElement e = n.toElement(); |
|
3787 |
QString tag = e.tagName().toLower(); |
|
3788 |
if (tag == QLatin1String("widget")) { |
|
3789 |
DomWidget *v = new DomWidget(); |
|
3790 |
v->read(e); |
|
3791 |
setElementWidget(v); |
|
3792 |
continue; |
|
3793 |
} |
|
3794 |
if (tag == QLatin1String("layout")) { |
|
3795 |
DomLayout *v = new DomLayout(); |
|
3796 |
v->read(e); |
|
3797 |
setElementLayout(v); |
|
3798 |
continue; |
|
3799 |
} |
|
3800 |
if (tag == QLatin1String("spacer")) { |
|
3801 |
DomSpacer *v = new DomSpacer(); |
|
3802 |
v->read(e); |
|
3803 |
setElementSpacer(v); |
|
3804 |
continue; |
|
3805 |
} |
|
3806 |
} |
|
3807 |
m_text.clear(); |
|
3808 |
for (QDomNode child = node.firstChild(); !child.isNull(); child = child.nextSibling()) { |
|
3809 |
if (child.isText()) |
|
3810 |
m_text.append(child.nodeValue()); |
|
3811 |
} |
|
3812 |
} |
|
3813 |
#endif |
|
3814 |
||
3815 |
void DomLayoutItem::write(QXmlStreamWriter &writer, const QString &tagName) const |
|
3816 |
{ |
|
3817 |
writer.writeStartElement(tagName.isEmpty() ? QString::fromUtf8("layoutitem") : tagName.toLower()); |
|
3818 |
||
3819 |
if (hasAttributeRow()) |
|
3820 |
writer.writeAttribute(QLatin1String("row"), QString::number(attributeRow())); |
|
3821 |
||
3822 |
if (hasAttributeColumn()) |
|
3823 |
writer.writeAttribute(QLatin1String("column"), QString::number(attributeColumn())); |
|
3824 |
||
3825 |
if (hasAttributeRowSpan()) |
|
3826 |
writer.writeAttribute(QLatin1String("rowspan"), QString::number(attributeRowSpan())); |
|
3827 |
||
3828 |
if (hasAttributeColSpan()) |
|
3829 |
writer.writeAttribute(QLatin1String("colspan"), QString::number(attributeColSpan())); |
|
3830 |
||
3831 |
switch (kind()) { |
|
3832 |
case Widget: { |
|
3833 |
DomWidget* v = elementWidget(); |
|
3834 |
if (v != 0) { |
|
3835 |
v->write(writer, QLatin1String("widget")); |
|
3836 |
} |
|
3837 |
break; |
|
3838 |
} |
|
3839 |
case Layout: { |
|
3840 |
DomLayout* v = elementLayout(); |
|
3841 |
if (v != 0) { |
|
3842 |
v->write(writer, QLatin1String("layout")); |
|
3843 |
} |
|
3844 |
break; |
|
3845 |
} |
|
3846 |
case Spacer: { |
|
3847 |
DomSpacer* v = elementSpacer(); |
|
3848 |
if (v != 0) { |
|
3849 |
v->write(writer, QLatin1String("spacer")); |
|
3850 |
} |
|
3851 |
break; |
|
3852 |
} |
|
3853 |
default: |
|
3854 |
break; |
|
3855 |
} |
|
3856 |
if (!m_text.isEmpty()) |
|
3857 |
writer.writeCharacters(m_text); |
|
3858 |
||
3859 |
writer.writeEndElement(); |
|
3860 |
} |
|
3861 |
||
3862 |
DomWidget* DomLayoutItem::takeElementWidget() |
|
3863 |
{ |
|
3864 |
DomWidget* a = m_widget; |
|
3865 |
m_widget = 0; |
|
3866 |
return a; |
|
3867 |
} |
|
3868 |
||
3869 |
void DomLayoutItem::setElementWidget(DomWidget* a) |
|
3870 |
{ |
|
3871 |
clear(false); |
|
3872 |
m_kind = Widget; |
|
3873 |
m_widget = a; |
|
3874 |
} |
|
3875 |
||
3876 |
DomLayout* DomLayoutItem::takeElementLayout() |
|
3877 |
{ |
|
3878 |
DomLayout* a = m_layout; |
|
3879 |
m_layout = 0; |
|
3880 |
return a; |
|
3881 |
} |
|
3882 |
||
3883 |
void DomLayoutItem::setElementLayout(DomLayout* a) |
|
3884 |
{ |
|
3885 |
clear(false); |
|
3886 |
m_kind = Layout; |
|
3887 |
m_layout = a; |
|
3888 |
} |
|
3889 |
||
3890 |
DomSpacer* DomLayoutItem::takeElementSpacer() |
|
3891 |
{ |
|
3892 |
DomSpacer* a = m_spacer; |
|
3893 |
m_spacer = 0; |
|
3894 |
return a; |
|
3895 |
} |
|
3896 |
||
3897 |
void DomLayoutItem::setElementSpacer(DomSpacer* a) |
|
3898 |
{ |
|
3899 |
clear(false); |
|
3900 |
m_kind = Spacer; |
|
3901 |
m_spacer = a; |
|
3902 |
} |
|
3903 |
||
3904 |
void DomRow::clear(bool clear_all) |
|
3905 |
{ |
|
3906 |
qDeleteAll(m_property); |
|
3907 |
m_property.clear(); |
|
3908 |
||
3909 |
if (clear_all) { |
|
3910 |
m_text.clear(); |
|
3911 |
} |
|
3912 |
||
3913 |
m_children = 0; |
|
3914 |
} |
|
3915 |
||
3916 |
DomRow::DomRow() |
|
3917 |
{ |
|
3918 |
m_children = 0; |
|
3919 |
} |
|
3920 |
||
3921 |
DomRow::~DomRow() |
|
3922 |
{ |
|
3923 |
qDeleteAll(m_property); |
|
3924 |
m_property.clear(); |
|
3925 |
} |
|
3926 |
||
3927 |
void DomRow::read(QXmlStreamReader &reader) |
|
3928 |
{ |
|
3929 |
||
3930 |
for (bool finished = false; !finished && !reader.hasError();) { |
|
3931 |
switch (reader.readNext()) { |
|
3932 |
case QXmlStreamReader::StartElement : { |
|
3933 |
const QString tag = reader.name().toString().toLower(); |
|
3934 |
if (tag == QLatin1String("property")) { |
|
3935 |
DomProperty *v = new DomProperty(); |
|
3936 |
v->read(reader); |
|
3937 |
m_property.append(v); |
|
3938 |
continue; |
|
3939 |
} |
|
3940 |
reader.raiseError(QLatin1String("Unexpected element ") + tag); |
|
3941 |
} |
|
3942 |
break; |
|
3943 |
case QXmlStreamReader::EndElement : |
|
3944 |
finished = true; |
|
3945 |
break; |
|
3946 |
case QXmlStreamReader::Characters : |
|
3947 |
if (!reader.isWhitespace()) |
|
3948 |
m_text.append(reader.text().toString()); |
|
3949 |
break; |
|
3950 |
default : |
|
3951 |
break; |
|
3952 |
} |
|
3953 |
} |
|
3954 |
} |
|
3955 |
||
3956 |
#ifdef QUILOADER_QDOM_READ |
|
3957 |
void DomRow::read(const QDomElement &node) |
|
3958 |
{ |
|
3959 |
for (QDomNode n = node.firstChild(); !n.isNull(); n = n.nextSibling()) { |
|
3960 |
if (!n.isElement()) |
|
3961 |
continue; |
|
3962 |
QDomElement e = n.toElement(); |
|
3963 |
QString tag = e.tagName().toLower(); |
|
3964 |
if (tag == QLatin1String("property")) { |
|
3965 |
DomProperty *v = new DomProperty(); |
|
3966 |
v->read(e); |
|
3967 |
m_property.append(v); |
|
3968 |
continue; |
|
3969 |
} |
|
3970 |
} |
|
3971 |
m_text.clear(); |
|
3972 |
for (QDomNode child = node.firstChild(); !child.isNull(); child = child.nextSibling()) { |
|
3973 |
if (child.isText()) |
|
3974 |
m_text.append(child.nodeValue()); |
|
3975 |
} |
|
3976 |
} |
|
3977 |
#endif |
|
3978 |
||
3979 |
void DomRow::write(QXmlStreamWriter &writer, const QString &tagName) const |
|
3980 |
{ |
|
3981 |
writer.writeStartElement(tagName.isEmpty() ? QString::fromUtf8("row") : tagName.toLower()); |
|
3982 |
||
3983 |
for (int i = 0; i < m_property.size(); ++i) { |
|
3984 |
DomProperty* v = m_property[i]; |
|
3985 |
v->write(writer, QLatin1String("property")); |
|
3986 |
} |
|
3987 |
if (!m_text.isEmpty()) |
|
3988 |
writer.writeCharacters(m_text); |
|
3989 |
||
3990 |
writer.writeEndElement(); |
|
3991 |
} |
|
3992 |
||
3993 |
void DomRow::setElementProperty(const QList<DomProperty*>& a) |
|
3994 |
{ |
|
3995 |
m_children |= Property; |
|
3996 |
m_property = a; |
|
3997 |
} |
|
3998 |
||
3999 |
void DomColumn::clear(bool clear_all) |
|
4000 |
{ |
|
4001 |
qDeleteAll(m_property); |
|
4002 |
m_property.clear(); |
|
4003 |
||
4004 |
if (clear_all) { |
|
4005 |
m_text.clear(); |
|
4006 |
} |
|
4007 |
||
4008 |
m_children = 0; |
|
4009 |
} |
|
4010 |
||
4011 |
DomColumn::DomColumn() |
|
4012 |
{ |
|
4013 |
m_children = 0; |
|
4014 |
} |
|
4015 |
||
4016 |
DomColumn::~DomColumn() |
|
4017 |
{ |
|
4018 |
qDeleteAll(m_property); |
|
4019 |
m_property.clear(); |
|
4020 |
} |
|
4021 |
||
4022 |
void DomColumn::read(QXmlStreamReader &reader) |
|
4023 |
{ |
|
4024 |
||
4025 |
for (bool finished = false; !finished && !reader.hasError();) { |
|
4026 |
switch (reader.readNext()) { |
|
4027 |
case QXmlStreamReader::StartElement : { |
|
4028 |
const QString tag = reader.name().toString().toLower(); |
|
4029 |
if (tag == QLatin1String("property")) { |
|
4030 |
DomProperty *v = new DomProperty(); |
|
4031 |
v->read(reader); |
|
4032 |
m_property.append(v); |
|
4033 |
continue; |
|
4034 |
} |
|
4035 |
reader.raiseError(QLatin1String("Unexpected element ") + tag); |
|
4036 |
} |
|
4037 |
break; |
|
4038 |
case QXmlStreamReader::EndElement : |
|
4039 |
finished = true; |
|
4040 |
break; |
|
4041 |
case QXmlStreamReader::Characters : |
|
4042 |
if (!reader.isWhitespace()) |
|
4043 |
m_text.append(reader.text().toString()); |
|
4044 |
break; |
|
4045 |
default : |
|
4046 |
break; |
|
4047 |
} |
|
4048 |
} |
|
4049 |
} |
|
4050 |
||
4051 |
#ifdef QUILOADER_QDOM_READ |
|
4052 |
void DomColumn::read(const QDomElement &node) |
|
4053 |
{ |
|
4054 |
for (QDomNode n = node.firstChild(); !n.isNull(); n = n.nextSibling()) { |
|
4055 |
if (!n.isElement()) |
|
4056 |
continue; |
|
4057 |
QDomElement e = n.toElement(); |
|
4058 |
QString tag = e.tagName().toLower(); |
|
4059 |
if (tag == QLatin1String("property")) { |
|
4060 |
DomProperty *v = new DomProperty(); |
|
4061 |
v->read(e); |
|
4062 |
m_property.append(v); |
|
4063 |
continue; |
|
4064 |
} |
|
4065 |
} |
|
4066 |
m_text.clear(); |
|
4067 |
for (QDomNode child = node.firstChild(); !child.isNull(); child = child.nextSibling()) { |
|
4068 |
if (child.isText()) |
|
4069 |
m_text.append(child.nodeValue()); |
|
4070 |
} |
|
4071 |
} |
|
4072 |
#endif |
|
4073 |
||
4074 |
void DomColumn::write(QXmlStreamWriter &writer, const QString &tagName) const |
|
4075 |
{ |
|
4076 |
writer.writeStartElement(tagName.isEmpty() ? QString::fromUtf8("column") : tagName.toLower()); |
|
4077 |
||
4078 |
for (int i = 0; i < m_property.size(); ++i) { |
|
4079 |
DomProperty* v = m_property[i]; |
|
4080 |
v->write(writer, QLatin1String("property")); |
|
4081 |
} |
|
4082 |
if (!m_text.isEmpty()) |
|
4083 |
writer.writeCharacters(m_text); |
|
4084 |
||
4085 |
writer.writeEndElement(); |
|
4086 |
} |
|
4087 |
||
4088 |
void DomColumn::setElementProperty(const QList<DomProperty*>& a) |
|
4089 |
{ |
|
4090 |
m_children |= Property; |
|
4091 |
m_property = a; |
|
4092 |
} |
|
4093 |
||
4094 |
void DomItem::clear(bool clear_all) |
|
4095 |
{ |
|
4096 |
qDeleteAll(m_property); |
|
4097 |
m_property.clear(); |
|
4098 |
qDeleteAll(m_item); |
|
4099 |
m_item.clear(); |
|
4100 |
||
4101 |
if (clear_all) { |
|
4102 |
m_text.clear(); |
|
4103 |
m_has_attr_row = false; |
|
4104 |
m_attr_row = 0; |
|
4105 |
m_has_attr_column = false; |
|
4106 |
m_attr_column = 0; |
|
4107 |
} |
|
4108 |
||
4109 |
m_children = 0; |
|
4110 |
} |
|
4111 |
||
4112 |
DomItem::DomItem() |
|
4113 |
{ |
|
4114 |
m_children = 0; |
|
4115 |
m_has_attr_row = false; |
|
4116 |
m_attr_row = 0; |
|
4117 |
m_has_attr_column = false; |
|
4118 |
m_attr_column = 0; |
|
4119 |
} |
|
4120 |
||
4121 |
DomItem::~DomItem() |
|
4122 |
{ |
|
4123 |
qDeleteAll(m_property); |
|
4124 |
m_property.clear(); |
|
4125 |
qDeleteAll(m_item); |
|
4126 |
m_item.clear(); |
|
4127 |
} |
|
4128 |
||
4129 |
void DomItem::read(QXmlStreamReader &reader) |
|
4130 |
{ |
|
4131 |
||
4132 |
foreach (const QXmlStreamAttribute &attribute, reader.attributes()) { |
|
4133 |
QStringRef name = attribute.name(); |
|
4134 |
if (name == QLatin1String("row")) { |
|
4135 |
setAttributeRow(attribute.value().toString().toInt()); |
|
4136 |
continue; |
|
4137 |
} |
|
4138 |
if (name == QLatin1String("column")) { |
|
4139 |
setAttributeColumn(attribute.value().toString().toInt()); |
|
4140 |
continue; |
|
4141 |
} |
|
4142 |
reader.raiseError(QLatin1String("Unexpected attribute ") + name.toString()); |
|
4143 |
} |
|
4144 |
||
4145 |
for (bool finished = false; !finished && !reader.hasError();) { |
|
4146 |
switch (reader.readNext()) { |
|
4147 |
case QXmlStreamReader::StartElement : { |
|
4148 |
const QString tag = reader.name().toString().toLower(); |
|
4149 |
if (tag == QLatin1String("property")) { |
|
4150 |
DomProperty *v = new DomProperty(); |
|
4151 |
v->read(reader); |
|
4152 |
m_property.append(v); |
|
4153 |
continue; |
|
4154 |
} |
|
4155 |
if (tag == QLatin1String("item")) { |
|
4156 |
DomItem *v = new DomItem(); |
|
4157 |
v->read(reader); |
|
4158 |
m_item.append(v); |
|
4159 |
continue; |
|
4160 |
} |
|
4161 |
reader.raiseError(QLatin1String("Unexpected element ") + tag); |
|
4162 |
} |
|
4163 |
break; |
|
4164 |
case QXmlStreamReader::EndElement : |
|
4165 |
finished = true; |
|
4166 |
break; |
|
4167 |
case QXmlStreamReader::Characters : |
|
4168 |
if (!reader.isWhitespace()) |
|
4169 |
m_text.append(reader.text().toString()); |
|
4170 |
break; |
|
4171 |
default : |
|
4172 |
break; |
|
4173 |
} |
|
4174 |
} |
|
4175 |
} |
|
4176 |
||
4177 |
#ifdef QUILOADER_QDOM_READ |
|
4178 |
void DomItem::read(const QDomElement &node) |
|
4179 |
{ |
|
4180 |
if (node.hasAttribute(QLatin1String("row"))) |
|
4181 |
setAttributeRow(node.attribute(QLatin1String("row")).toInt()); |
|
4182 |
if (node.hasAttribute(QLatin1String("column"))) |
|
4183 |
setAttributeColumn(node.attribute(QLatin1String("column")).toInt()); |
|
4184 |
||
4185 |
for (QDomNode n = node.firstChild(); !n.isNull(); n = n.nextSibling()) { |
|
4186 |
if (!n.isElement()) |
|
4187 |
continue; |
|
4188 |
QDomElement e = n.toElement(); |
|
4189 |
QString tag = e.tagName().toLower(); |
|
4190 |
if (tag == QLatin1String("property")) { |
|
4191 |
DomProperty *v = new DomProperty(); |
|
4192 |
v->read(e); |
|
4193 |
m_property.append(v); |
|
4194 |
continue; |
|
4195 |
} |
|
4196 |
if (tag == QLatin1String("item")) { |
|
4197 |
DomItem *v = new DomItem(); |
|
4198 |
v->read(e); |
|
4199 |
m_item.append(v); |
|
4200 |
continue; |
|
4201 |
} |
|
4202 |
} |
|
4203 |
m_text.clear(); |
|
4204 |
for (QDomNode child = node.firstChild(); !child.isNull(); child = child.nextSibling()) { |
|
4205 |
if (child.isText()) |
|
4206 |
m_text.append(child.nodeValue()); |
|
4207 |
} |
|
4208 |
} |
|
4209 |
#endif |
|
4210 |
||
4211 |
void DomItem::write(QXmlStreamWriter &writer, const QString &tagName) const |
|
4212 |
{ |
|
4213 |
writer.writeStartElement(tagName.isEmpty() ? QString::fromUtf8("item") : tagName.toLower()); |
|
4214 |
||
4215 |
if (hasAttributeRow()) |
|
4216 |
writer.writeAttribute(QLatin1String("row"), QString::number(attributeRow())); |
|
4217 |
||
4218 |
if (hasAttributeColumn()) |
|
4219 |
writer.writeAttribute(QLatin1String("column"), QString::number(attributeColumn())); |
|
4220 |
||
4221 |
for (int i = 0; i < m_property.size(); ++i) { |
|
4222 |
DomProperty* v = m_property[i]; |
|
4223 |
v->write(writer, QLatin1String("property")); |
|
4224 |
} |
|
4225 |
for (int i = 0; i < m_item.size(); ++i) { |
|
4226 |
DomItem* v = m_item[i]; |
|
4227 |
v->write(writer, QLatin1String("item")); |
|
4228 |
} |
|
4229 |
if (!m_text.isEmpty()) |
|
4230 |
writer.writeCharacters(m_text); |
|
4231 |
||
4232 |
writer.writeEndElement(); |
|
4233 |
} |
|
4234 |
||
4235 |
void DomItem::setElementProperty(const QList<DomProperty*>& a) |
|
4236 |
{ |
|
4237 |
m_children |= Property; |
|
4238 |
m_property = a; |
|
4239 |
} |
|
4240 |
||
4241 |
void DomItem::setElementItem(const QList<DomItem*>& a) |
|
4242 |
{ |
|
4243 |
m_children |= Item; |
|
4244 |
m_item = a; |
|
4245 |
} |
|
4246 |
||
4247 |
void DomWidget::clear(bool clear_all) |
|
4248 |
{ |
|
4249 |
m_class.clear(); |
|
4250 |
qDeleteAll(m_property); |
|
4251 |
m_property.clear(); |
|
4252 |
qDeleteAll(m_script); |
|
4253 |
m_script.clear(); |
|
4254 |
qDeleteAll(m_widgetData); |
|
4255 |
m_widgetData.clear(); |
|
4256 |
qDeleteAll(m_attribute); |
|
4257 |
m_attribute.clear(); |
|
4258 |
qDeleteAll(m_row); |
|
4259 |
m_row.clear(); |
|
4260 |
qDeleteAll(m_column); |
|
4261 |
m_column.clear(); |
|
4262 |
qDeleteAll(m_item); |
|
4263 |
m_item.clear(); |
|
4264 |
qDeleteAll(m_layout); |
|
4265 |
m_layout.clear(); |
|
4266 |
qDeleteAll(m_widget); |
|
4267 |
m_widget.clear(); |
|
4268 |
qDeleteAll(m_action); |
|
4269 |
m_action.clear(); |
|
4270 |
qDeleteAll(m_actionGroup); |
|
4271 |
m_actionGroup.clear(); |
|
4272 |
qDeleteAll(m_addAction); |
|
4273 |
m_addAction.clear(); |
|
4274 |
m_zOrder.clear(); |
|
4275 |
||
4276 |
if (clear_all) { |
|
4277 |
m_text.clear(); |
|
4278 |
m_has_attr_class = false; |
|
4279 |
m_has_attr_name = false; |
|
4280 |
m_has_attr_native = false; |
|
4281 |
m_attr_native = false; |
|
4282 |
} |
|
4283 |
||
4284 |
m_children = 0; |
|
4285 |
} |
|
4286 |
||
4287 |
DomWidget::DomWidget() |
|
4288 |
{ |
|
4289 |
m_children = 0; |
|
4290 |
m_has_attr_class = false; |
|
4291 |
m_has_attr_name = false; |
|
4292 |
m_has_attr_native = false; |
|
4293 |
m_attr_native = false; |
|
4294 |
} |
|
4295 |
||
4296 |
DomWidget::~DomWidget() |
|
4297 |
{ |
|
4298 |
m_class.clear(); |
|
4299 |
qDeleteAll(m_property); |
|
4300 |
m_property.clear(); |
|
4301 |
qDeleteAll(m_script); |
|
4302 |
m_script.clear(); |
|
4303 |
qDeleteAll(m_widgetData); |
|
4304 |
m_widgetData.clear(); |
|
4305 |
qDeleteAll(m_attribute); |
|
4306 |
m_attribute.clear(); |
|
4307 |
qDeleteAll(m_row); |
|
4308 |
m_row.clear(); |
|
4309 |
qDeleteAll(m_column); |
|
4310 |
m_column.clear(); |
|
4311 |
qDeleteAll(m_item); |
|
4312 |
m_item.clear(); |
|
4313 |
qDeleteAll(m_layout); |
|
4314 |
m_layout.clear(); |
|
4315 |
qDeleteAll(m_widget); |
|
4316 |
m_widget.clear(); |
|
4317 |
qDeleteAll(m_action); |
|
4318 |
m_action.clear(); |
|
4319 |
qDeleteAll(m_actionGroup); |
|
4320 |
m_actionGroup.clear(); |
|
4321 |
qDeleteAll(m_addAction); |
|
4322 |
m_addAction.clear(); |
|
4323 |
m_zOrder.clear(); |
|
4324 |
} |
|
4325 |
||
4326 |
void DomWidget::read(QXmlStreamReader &reader) |
|
4327 |
{ |
|
4328 |
||
4329 |
foreach (const QXmlStreamAttribute &attribute, reader.attributes()) { |
|
4330 |
QStringRef name = attribute.name(); |
|
4331 |
if (name == QLatin1String("class")) { |
|
4332 |
setAttributeClass(attribute.value().toString()); |
|
4333 |
continue; |
|
4334 |
} |
|
4335 |
if (name == QLatin1String("name")) { |
|
4336 |
setAttributeName(attribute.value().toString()); |
|
4337 |
continue; |
|
4338 |
} |
|
4339 |
if (name == QLatin1String("native")) { |
|
4340 |
setAttributeNative((attribute.value().toString() == QLatin1String("true") ? true : false)); |
|
4341 |
continue; |
|
4342 |
} |
|
4343 |
reader.raiseError(QLatin1String("Unexpected attribute ") + name.toString()); |
|
4344 |
} |
|
4345 |
||
4346 |
for (bool finished = false; !finished && !reader.hasError();) { |
|
4347 |
switch (reader.readNext()) { |
|
4348 |
case QXmlStreamReader::StartElement : { |
|
4349 |
const QString tag = reader.name().toString().toLower(); |
|
4350 |
if (tag == QLatin1String("class")) { |
|
4351 |
m_class.append(reader.readElementText()); |
|
4352 |
continue; |
|
4353 |
} |
|
4354 |
if (tag == QLatin1String("property")) { |
|
4355 |
DomProperty *v = new DomProperty(); |
|
4356 |
v->read(reader); |
|
4357 |
m_property.append(v); |
|
4358 |
continue; |
|
4359 |
} |
|
4360 |
if (tag == QLatin1String("script")) { |
|
4361 |
DomScript *v = new DomScript(); |
|
4362 |
v->read(reader); |
|
4363 |
m_script.append(v); |
|
4364 |
continue; |
|
4365 |
} |
|
4366 |
if (tag == QLatin1String("widgetdata")) { |
|
4367 |
DomWidgetData *v = new DomWidgetData(); |
|
4368 |
v->read(reader); |
|
4369 |
m_widgetData.append(v); |
|
4370 |
continue; |
|
4371 |
} |
|
4372 |
if (tag == QLatin1String("attribute")) { |
|
4373 |
DomProperty *v = new DomProperty(); |
|
4374 |
v->read(reader); |
|
4375 |
m_attribute.append(v); |
|
4376 |
continue; |
|
4377 |
} |
|
4378 |
if (tag == QLatin1String("row")) { |
|
4379 |
DomRow *v = new DomRow(); |
|
4380 |
v->read(reader); |
|
4381 |
m_row.append(v); |
|
4382 |
continue; |
|
4383 |
} |
|
4384 |
if (tag == QLatin1String("column")) { |
|
4385 |
DomColumn *v = new DomColumn(); |
|
4386 |
v->read(reader); |
|
4387 |
m_column.append(v); |
|
4388 |
continue; |
|
4389 |
} |
|
4390 |
if (tag == QLatin1String("item")) { |
|
4391 |
DomItem *v = new DomItem(); |
|
4392 |
v->read(reader); |
|
4393 |
m_item.append(v); |
|
4394 |
continue; |
|
4395 |
} |
|
4396 |
if (tag == QLatin1String("layout")) { |
|
4397 |
DomLayout *v = new DomLayout(); |
|
4398 |
v->read(reader); |
|
4399 |
m_layout.append(v); |
|
4400 |
continue; |
|
4401 |
} |
|
4402 |
if (tag == QLatin1String("widget")) { |
|
4403 |
DomWidget *v = new DomWidget(); |
|
4404 |
v->read(reader); |
|
4405 |
m_widget.append(v); |
|
4406 |
continue; |
|
4407 |
} |
|
4408 |
if (tag == QLatin1String("action")) { |
|
4409 |
DomAction *v = new DomAction(); |
|
4410 |
v->read(reader); |
|
4411 |
m_action.append(v); |
|
4412 |
continue; |
|
4413 |
} |
|
4414 |
if (tag == QLatin1String("actiongroup")) { |
|
4415 |
DomActionGroup *v = new DomActionGroup(); |
|
4416 |
v->read(reader); |
|
4417 |
m_actionGroup.append(v); |
|
4418 |
continue; |
|
4419 |
} |
|
4420 |
if (tag == QLatin1String("addaction")) { |
|
4421 |
DomActionRef *v = new DomActionRef(); |
|
4422 |
v->read(reader); |
|
4423 |
m_addAction.append(v); |
|
4424 |
continue; |
|
4425 |
} |
|
4426 |
if (tag == QLatin1String("zorder")) { |
|
4427 |
m_zOrder.append(reader.readElementText()); |
|
4428 |
continue; |
|
4429 |
} |
|
4430 |
reader.raiseError(QLatin1String("Unexpected element ") + tag); |
|
4431 |
} |
|
4432 |
break; |
|
4433 |
case QXmlStreamReader::EndElement : |
|
4434 |
finished = true; |
|
4435 |
break; |
|
4436 |
case QXmlStreamReader::Characters : |
|
4437 |
if (!reader.isWhitespace()) |
|
4438 |
m_text.append(reader.text().toString()); |
|
4439 |
break; |
|
4440 |
default : |
|
4441 |
break; |
|
4442 |
} |
|
4443 |
} |
|
4444 |
} |
|
4445 |
||
4446 |
#ifdef QUILOADER_QDOM_READ |
|
4447 |
void DomWidget::read(const QDomElement &node) |
|
4448 |
{ |
|
4449 |
if (node.hasAttribute(QLatin1String("class"))) |
|
4450 |
setAttributeClass(node.attribute(QLatin1String("class"))); |
|
4451 |
if (node.hasAttribute(QLatin1String("name"))) |
|
4452 |
setAttributeName(node.attribute(QLatin1String("name"))); |
|
4453 |
if (node.hasAttribute(QLatin1String("native"))) |
|
4454 |
setAttributeNative((node.attribute(QLatin1String("native")) == QLatin1String("true") ? true : false)); |
|
4455 |
||
4456 |
for (QDomNode n = node.firstChild(); !n.isNull(); n = n.nextSibling()) { |
|
4457 |
if (!n.isElement()) |
|
4458 |
continue; |
|
4459 |
QDomElement e = n.toElement(); |
|
4460 |
QString tag = e.tagName().toLower(); |
|
4461 |
if (tag == QLatin1String("class")) { |
|
4462 |
m_class.append(e.text()); |
|
4463 |
continue; |
|
4464 |
} |
|
4465 |
if (tag == QLatin1String("property")) { |
|
4466 |
DomProperty *v = new DomProperty(); |
|
4467 |
v->read(e); |
|
4468 |
m_property.append(v); |
|
4469 |
continue; |
|
4470 |
} |
|
4471 |
if (tag == QLatin1String("script")) { |
|
4472 |
DomScript *v = new DomScript(); |
|
4473 |
v->read(e); |
|
4474 |
m_script.append(v); |
|
4475 |
continue; |
|
4476 |
} |
|
4477 |
if (tag == QLatin1String("widgetdata")) { |
|
4478 |
DomWidgetData *v = new DomWidgetData(); |
|
4479 |
v->read(e); |
|
4480 |
m_widgetData.append(v); |
|
4481 |
continue; |
|
4482 |
} |
|
4483 |
if (tag == QLatin1String("attribute")) { |
|
4484 |
DomProperty *v = new DomProperty(); |
|
4485 |
v->read(e); |
|
4486 |
m_attribute.append(v); |
|
4487 |
continue; |
|
4488 |
} |
|
4489 |
if (tag == QLatin1String("row")) { |
|
4490 |
DomRow *v = new DomRow(); |
|
4491 |
v->read(e); |
|
4492 |
m_row.append(v); |
|
4493 |
continue; |
|
4494 |
} |
|
4495 |
if (tag == QLatin1String("column")) { |
|
4496 |
DomColumn *v = new DomColumn(); |
|
4497 |
v->read(e); |
|
4498 |
m_column.append(v); |
|
4499 |
continue; |
|
4500 |
} |
|
4501 |
if (tag == QLatin1String("item")) { |
|
4502 |
DomItem *v = new DomItem(); |
|
4503 |
v->read(e); |
|
4504 |
m_item.append(v); |
|
4505 |
continue; |
|
4506 |
} |
|
4507 |
if (tag == QLatin1String("layout")) { |
|
4508 |
DomLayout *v = new DomLayout(); |
|
4509 |
v->read(e); |
|
4510 |
m_layout.append(v); |
|
4511 |
continue; |
|
4512 |
} |
|
4513 |
if (tag == QLatin1String("widget")) { |
|
4514 |
DomWidget *v = new DomWidget(); |
|
4515 |
v->read(e); |
|
4516 |
m_widget.append(v); |
|
4517 |
continue; |
|
4518 |
} |
|
4519 |
if (tag == QLatin1String("action")) { |
|
4520 |
DomAction *v = new DomAction(); |
|
4521 |
v->read(e); |
|
4522 |
m_action.append(v); |
|
4523 |
continue; |
|
4524 |
} |
|
4525 |
if (tag == QLatin1String("actiongroup")) { |
|
4526 |
DomActionGroup *v = new DomActionGroup(); |
|
4527 |
v->read(e); |
|
4528 |
m_actionGroup.append(v); |
|
4529 |
continue; |
|
4530 |
} |
|
4531 |
if (tag == QLatin1String("addaction")) { |
|
4532 |
DomActionRef *v = new DomActionRef(); |
|
4533 |
v->read(e); |
|
4534 |
m_addAction.append(v); |
|
4535 |
continue; |
|
4536 |
} |
|
4537 |
if (tag == QLatin1String("zorder")) { |
|
4538 |
m_zOrder.append(e.text()); |
|
4539 |
continue; |
|
4540 |
} |
|
4541 |
} |
|
4542 |
m_text.clear(); |
|
4543 |
for (QDomNode child = node.firstChild(); !child.isNull(); child = child.nextSibling()) { |
|
4544 |
if (child.isText()) |
|
4545 |
m_text.append(child.nodeValue()); |
|
4546 |
} |
|
4547 |
} |
|
4548 |
#endif |
|
4549 |
||
4550 |
void DomWidget::write(QXmlStreamWriter &writer, const QString &tagName) const |
|
4551 |
{ |
|
4552 |
writer.writeStartElement(tagName.isEmpty() ? QString::fromUtf8("widget") : tagName.toLower()); |
|
4553 |
||
4554 |
if (hasAttributeClass()) |
|
4555 |
writer.writeAttribute(QLatin1String("class"), attributeClass()); |
|
4556 |
||
4557 |
if (hasAttributeName()) |
|
4558 |
writer.writeAttribute(QLatin1String("name"), attributeName()); |
|
4559 |
||
4560 |
if (hasAttributeNative()) |
|
4561 |
writer.writeAttribute(QLatin1String("native"), (attributeNative() ? QLatin1String("true") : QLatin1String("false"))); |
|
4562 |
||
4563 |
for (int i = 0; i < m_class.size(); ++i) { |
|
4564 |
QString v = m_class[i]; |
|
4565 |
writer.writeTextElement(QLatin1String("class"), v); |
|
4566 |
} |
|
4567 |
for (int i = 0; i < m_property.size(); ++i) { |
|
4568 |
DomProperty* v = m_property[i]; |
|
4569 |
v->write(writer, QLatin1String("property")); |
|
4570 |
} |
|
4571 |
for (int i = 0; i < m_script.size(); ++i) { |
|
4572 |
DomScript* v = m_script[i]; |
|
4573 |
v->write(writer, QLatin1String("script")); |
|
4574 |
} |
|
4575 |
for (int i = 0; i < m_widgetData.size(); ++i) { |
|
4576 |
DomWidgetData* v = m_widgetData[i]; |
|
4577 |
v->write(writer, QLatin1String("widgetdata")); |
|
4578 |
} |
|
4579 |
for (int i = 0; i < m_attribute.size(); ++i) { |
|
4580 |
DomProperty* v = m_attribute[i]; |
|
4581 |
v->write(writer, QLatin1String("attribute")); |
|
4582 |
} |
|
4583 |
for (int i = 0; i < m_row.size(); ++i) { |
|
4584 |
DomRow* v = m_row[i]; |
|
4585 |
v->write(writer, QLatin1String("row")); |
|
4586 |
} |
|
4587 |
for (int i = 0; i < m_column.size(); ++i) { |
|
4588 |
DomColumn* v = m_column[i]; |
|
4589 |
v->write(writer, QLatin1String("column")); |
|
4590 |
} |
|
4591 |
for (int i = 0; i < m_item.size(); ++i) { |
|
4592 |
DomItem* v = m_item[i]; |
|
4593 |
v->write(writer, QLatin1String("item")); |
|
4594 |
} |
|
4595 |
for (int i = 0; i < m_layout.size(); ++i) { |
|
4596 |
DomLayout* v = m_layout[i]; |
|
4597 |
v->write(writer, QLatin1String("layout")); |
|
4598 |
} |
|
4599 |
for (int i = 0; i < m_widget.size(); ++i) { |
|
4600 |
DomWidget* v = m_widget[i]; |
|
4601 |
v->write(writer, QLatin1String("widget")); |
|
4602 |
} |
|
4603 |
for (int i = 0; i < m_action.size(); ++i) { |
|
4604 |
DomAction* v = m_action[i]; |
|
4605 |
v->write(writer, QLatin1String("action")); |
|
4606 |
} |
|
4607 |
for (int i = 0; i < m_actionGroup.size(); ++i) { |
|
4608 |
DomActionGroup* v = m_actionGroup[i]; |
|
4609 |
v->write(writer, QLatin1String("actiongroup")); |
|
4610 |
} |
|
4611 |
for (int i = 0; i < m_addAction.size(); ++i) { |
|
4612 |
DomActionRef* v = m_addAction[i]; |
|
4613 |
v->write(writer, QLatin1String("addaction")); |
|
4614 |
} |
|
4615 |
for (int i = 0; i < m_zOrder.size(); ++i) { |
|
4616 |
QString v = m_zOrder[i]; |
|
4617 |
writer.writeTextElement(QLatin1String("zorder"), v); |
|
4618 |
} |
|
4619 |
if (!m_text.isEmpty()) |
|
4620 |
writer.writeCharacters(m_text); |
|
4621 |
||
4622 |
writer.writeEndElement(); |
|
4623 |
} |
|
4624 |
||
4625 |
void DomWidget::setElementClass(const QStringList& a) |
|
4626 |
{ |
|
4627 |
m_children |= Class; |
|
4628 |
m_class = a; |
|
4629 |
} |
|
4630 |
||
4631 |
void DomWidget::setElementProperty(const QList<DomProperty*>& a) |
|
4632 |
{ |
|
4633 |
m_children |= Property; |
|
4634 |
m_property = a; |
|
4635 |
} |
|
4636 |
||
4637 |
void DomWidget::setElementScript(const QList<DomScript*>& a) |
|
4638 |
{ |
|
4639 |
m_children |= Script; |
|
4640 |
m_script = a; |
|
4641 |
} |
|
4642 |
||
4643 |
void DomWidget::setElementWidgetData(const QList<DomWidgetData*>& a) |
|
4644 |
{ |
|
4645 |
m_children |= WidgetData; |
|
4646 |
m_widgetData = a; |
|
4647 |
} |
|
4648 |
||
4649 |
void DomWidget::setElementAttribute(const QList<DomProperty*>& a) |
|
4650 |
{ |
|
4651 |
m_children |= Attribute; |
|
4652 |
m_attribute = a; |
|
4653 |
} |
|
4654 |
||
4655 |
void DomWidget::setElementRow(const QList<DomRow*>& a) |
|
4656 |
{ |
|
4657 |
m_children |= Row; |
|
4658 |
m_row = a; |
|
4659 |
} |
|
4660 |
||
4661 |
void DomWidget::setElementColumn(const QList<DomColumn*>& a) |
|
4662 |
{ |
|
4663 |
m_children |= Column; |
|
4664 |
m_column = a; |
|
4665 |
} |
|
4666 |
||
4667 |
void DomWidget::setElementItem(const QList<DomItem*>& a) |
|
4668 |
{ |
|
4669 |
m_children |= Item; |
|
4670 |
m_item = a; |
|
4671 |
} |
|
4672 |
||
4673 |
void DomWidget::setElementLayout(const QList<DomLayout*>& a) |
|
4674 |
{ |
|
4675 |
m_children |= Layout; |
|
4676 |
m_layout = a; |
|
4677 |
} |
|
4678 |
||
4679 |
void DomWidget::setElementWidget(const QList<DomWidget*>& a) |
|
4680 |
{ |
|
4681 |
m_children |= Widget; |
|
4682 |
m_widget = a; |
|
4683 |
} |
|
4684 |
||
4685 |
void DomWidget::setElementAction(const QList<DomAction*>& a) |
|
4686 |
{ |
|
4687 |
m_children |= Action; |
|
4688 |
m_action = a; |
|
4689 |
} |
|
4690 |
||
4691 |
void DomWidget::setElementActionGroup(const QList<DomActionGroup*>& a) |
|
4692 |
{ |
|
4693 |
m_children |= ActionGroup; |
|
4694 |
m_actionGroup = a; |
|
4695 |
} |
|
4696 |
||
4697 |
void DomWidget::setElementAddAction(const QList<DomActionRef*>& a) |
|
4698 |
{ |
|
4699 |
m_children |= AddAction; |
|
4700 |
m_addAction = a; |
|
4701 |
} |
|
4702 |
||
4703 |
void DomWidget::setElementZOrder(const QStringList& a) |
|
4704 |
{ |
|
4705 |
m_children |= ZOrder; |
|
4706 |
m_zOrder = a; |
|
4707 |
} |
|
4708 |
||
4709 |
void DomSpacer::clear(bool clear_all) |
|
4710 |
{ |
|
4711 |
qDeleteAll(m_property); |
|
4712 |
m_property.clear(); |
|
4713 |
||
4714 |
if (clear_all) { |
|
4715 |
m_text.clear(); |
|
4716 |
m_has_attr_name = false; |
|
4717 |
} |
|
4718 |
||
4719 |
m_children = 0; |
|
4720 |
} |
|
4721 |
||
4722 |
DomSpacer::DomSpacer() |
|
4723 |
{ |
|
4724 |
m_children = 0; |
|
4725 |
m_has_attr_name = false; |
|
4726 |
} |
|
4727 |
||
4728 |
DomSpacer::~DomSpacer() |
|
4729 |
{ |
|
4730 |
qDeleteAll(m_property); |
|
4731 |
m_property.clear(); |
|
4732 |
} |
|
4733 |
||
4734 |
void DomSpacer::read(QXmlStreamReader &reader) |
|
4735 |
{ |
|
4736 |
||
4737 |
foreach (const QXmlStreamAttribute &attribute, reader.attributes()) { |
|
4738 |
QStringRef name = attribute.name(); |
|
4739 |
if (name == QLatin1String("name")) { |
|
4740 |
setAttributeName(attribute.value().toString()); |
|
4741 |
continue; |
|
4742 |
} |
|
4743 |
reader.raiseError(QLatin1String("Unexpected attribute ") + name.toString()); |
|
4744 |
} |
|
4745 |
||
4746 |
for (bool finished = false; !finished && !reader.hasError();) { |
|
4747 |
switch (reader.readNext()) { |
|
4748 |
case QXmlStreamReader::StartElement : { |
|
4749 |
const QString tag = reader.name().toString().toLower(); |
|
4750 |
if (tag == QLatin1String("property")) { |
|
4751 |
DomProperty *v = new DomProperty(); |
|
4752 |
v->read(reader); |
|
4753 |
m_property.append(v); |
|
4754 |
continue; |
|
4755 |
} |
|
4756 |
reader.raiseError(QLatin1String("Unexpected element ") + tag); |
|
4757 |
} |
|
4758 |
break; |
|
4759 |
case QXmlStreamReader::EndElement : |
|
4760 |
finished = true; |
|
4761 |
break; |
|
4762 |
case QXmlStreamReader::Characters : |
|
4763 |
if (!reader.isWhitespace()) |
|
4764 |
m_text.append(reader.text().toString()); |
|
4765 |
break; |
|
4766 |
default : |
|
4767 |
break; |
|
4768 |
} |
|
4769 |
} |
|
4770 |
} |
|
4771 |
||
4772 |
#ifdef QUILOADER_QDOM_READ |
|
4773 |
void DomSpacer::read(const QDomElement &node) |
|
4774 |
{ |
|
4775 |
if (node.hasAttribute(QLatin1String("name"))) |
|
4776 |
setAttributeName(node.attribute(QLatin1String("name"))); |
|
4777 |
||
4778 |
for (QDomNode n = node.firstChild(); !n.isNull(); n = n.nextSibling()) { |
|
4779 |
if (!n.isElement()) |
|
4780 |
continue; |
|
4781 |
QDomElement e = n.toElement(); |
|
4782 |
QString tag = e.tagName().toLower(); |
|
4783 |
if (tag == QLatin1String("property")) { |
|
4784 |
DomProperty *v = new DomProperty(); |
|
4785 |
v->read(e); |
|
4786 |
m_property.append(v); |
|
4787 |
continue; |
|
4788 |
} |
|
4789 |
} |
|
4790 |
m_text.clear(); |
|
4791 |
for (QDomNode child = node.firstChild(); !child.isNull(); child = child.nextSibling()) { |
|
4792 |
if (child.isText()) |
|
4793 |
m_text.append(child.nodeValue()); |
|
4794 |
} |
|
4795 |
} |
|
4796 |
#endif |
|
4797 |
||
4798 |
void DomSpacer::write(QXmlStreamWriter &writer, const QString &tagName) const |
|
4799 |
{ |
|
4800 |
writer.writeStartElement(tagName.isEmpty() ? QString::fromUtf8("spacer") : tagName.toLower()); |
|
4801 |
||
4802 |
if (hasAttributeName()) |
|
4803 |
writer.writeAttribute(QLatin1String("name"), attributeName()); |
|
4804 |
||
4805 |
for (int i = 0; i < m_property.size(); ++i) { |
|
4806 |
DomProperty* v = m_property[i]; |
|
4807 |
v->write(writer, QLatin1String("property")); |
|
4808 |
} |
|
4809 |
if (!m_text.isEmpty()) |
|
4810 |
writer.writeCharacters(m_text); |
|
4811 |
||
4812 |
writer.writeEndElement(); |
|
4813 |
} |
|
4814 |
||
4815 |
void DomSpacer::setElementProperty(const QList<DomProperty*>& a) |
|
4816 |
{ |
|
4817 |
m_children |= Property; |
|
4818 |
m_property = a; |
|
4819 |
} |
|
4820 |
||
4821 |
void DomColor::clear(bool clear_all) |
|
4822 |
{ |
|
4823 |
||
4824 |
if (clear_all) { |
|
4825 |
m_text.clear(); |
|
4826 |
m_has_attr_alpha = false; |
|
4827 |
m_attr_alpha = 0; |
|
4828 |
} |
|
4829 |
||
4830 |
m_children = 0; |
|
4831 |
m_red = 0; |
|
4832 |
m_green = 0; |
|
4833 |
m_blue = 0; |
|
4834 |
} |
|
4835 |
||
4836 |
DomColor::DomColor() |
|
4837 |
{ |
|
4838 |
m_children = 0; |
|
4839 |
m_has_attr_alpha = false; |
|
4840 |
m_attr_alpha = 0; |
|
4841 |
m_red = 0; |
|
4842 |
m_green = 0; |
|
4843 |
m_blue = 0; |
|
4844 |
} |
|
4845 |
||
4846 |
DomColor::~DomColor() |
|
4847 |
{ |
|
4848 |
} |
|
4849 |
||
4850 |
void DomColor::read(QXmlStreamReader &reader) |
|
4851 |
{ |
|
4852 |
||
4853 |
foreach (const QXmlStreamAttribute &attribute, reader.attributes()) { |
|
4854 |
QStringRef name = attribute.name(); |
|
4855 |
if (name == QLatin1String("alpha")) { |
|
4856 |
setAttributeAlpha(attribute.value().toString().toInt()); |
|
4857 |
continue; |
|
4858 |
} |
|
4859 |
reader.raiseError(QLatin1String("Unexpected attribute ") + name.toString()); |
|
4860 |
} |
|
4861 |
||
4862 |
for (bool finished = false; !finished && !reader.hasError();) { |
|
4863 |
switch (reader.readNext()) { |
|
4864 |
case QXmlStreamReader::StartElement : { |
|
4865 |
const QString tag = reader.name().toString().toLower(); |
|
4866 |
if (tag == QLatin1String("red")) { |
|
4867 |
setElementRed(reader.readElementText().toInt()); |
|
4868 |
continue; |
|
4869 |
} |
|
4870 |
if (tag == QLatin1String("green")) { |
|
4871 |
setElementGreen(reader.readElementText().toInt()); |
|
4872 |
continue; |
|
4873 |
} |
|
4874 |
if (tag == QLatin1String("blue")) { |
|
4875 |
setElementBlue(reader.readElementText().toInt()); |
|
4876 |
continue; |
|
4877 |
} |
|
4878 |
reader.raiseError(QLatin1String("Unexpected element ") + tag); |
|
4879 |
} |
|
4880 |
break; |
|
4881 |
case QXmlStreamReader::EndElement : |
|
4882 |
finished = true; |
|
4883 |
break; |
|
4884 |
case QXmlStreamReader::Characters : |
|
4885 |
if (!reader.isWhitespace()) |
|
4886 |
m_text.append(reader.text().toString()); |
|
4887 |
break; |
|
4888 |
default : |
|
4889 |
break; |
|
4890 |
} |
|
4891 |
} |
|
4892 |
} |
|
4893 |
||
4894 |
#ifdef QUILOADER_QDOM_READ |
|
4895 |
void DomColor::read(const QDomElement &node) |
|
4896 |
{ |
|
4897 |
if (node.hasAttribute(QLatin1String("alpha"))) |
|
4898 |
setAttributeAlpha(node.attribute(QLatin1String("alpha")).toInt()); |
|
4899 |
||
4900 |
for (QDomNode n = node.firstChild(); !n.isNull(); n = n.nextSibling()) { |
|
4901 |
if (!n.isElement()) |
|
4902 |
continue; |
|
4903 |
QDomElement e = n.toElement(); |
|
4904 |
QString tag = e.tagName().toLower(); |
|
4905 |
if (tag == QLatin1String("red")) { |
|
4906 |
setElementRed(e.text().toInt()); |
|
4907 |
continue; |
|
4908 |
} |
|
4909 |
if (tag == QLatin1String("green")) { |
|
4910 |
setElementGreen(e.text().toInt()); |
|
4911 |
continue; |
|
4912 |
} |
|
4913 |
if (tag == QLatin1String("blue")) { |
|
4914 |
setElementBlue(e.text().toInt()); |
|
4915 |
continue; |
|
4916 |
} |
|
4917 |
} |
|
4918 |
m_text.clear(); |
|
4919 |
for (QDomNode child = node.firstChild(); !child.isNull(); child = child.nextSibling()) { |
|
4920 |
if (child.isText()) |
|
4921 |
m_text.append(child.nodeValue()); |
|
4922 |
} |
|
4923 |
} |
|
4924 |
#endif |
|
4925 |
||
4926 |
void DomColor::write(QXmlStreamWriter &writer, const QString &tagName) const |
|
4927 |
{ |
|
4928 |
writer.writeStartElement(tagName.isEmpty() ? QString::fromUtf8("color") : tagName.toLower()); |
|
4929 |
||
4930 |
if (hasAttributeAlpha()) |
|
4931 |
writer.writeAttribute(QLatin1String("alpha"), QString::number(attributeAlpha())); |
|
4932 |
||
4933 |
if (m_children & Red) { |
|
4934 |
writer.writeTextElement(QLatin1String("red"), QString::number(m_red)); |
|
4935 |
} |
|
4936 |
||
4937 |
if (m_children & Green) { |
|
4938 |
writer.writeTextElement(QLatin1String("green"), QString::number(m_green)); |
|
4939 |
} |
|
4940 |
||
4941 |
if (m_children & Blue) { |
|
4942 |
writer.writeTextElement(QLatin1String("blue"), QString::number(m_blue)); |
|
4943 |
} |
|
4944 |
||
4945 |
if (!m_text.isEmpty()) |
|
4946 |
writer.writeCharacters(m_text); |
|
4947 |
||
4948 |
writer.writeEndElement(); |
|
4949 |
} |
|
4950 |
||
4951 |
void DomColor::setElementRed(int a) |
|
4952 |
{ |
|
4953 |
m_children |= Red; |
|
4954 |
m_red = a; |
|
4955 |
} |
|
4956 |
||
4957 |
void DomColor::setElementGreen(int a) |
|
4958 |
{ |
|
4959 |
m_children |= Green; |
|
4960 |
m_green = a; |
|
4961 |
} |
|
4962 |
||
4963 |
void DomColor::setElementBlue(int a) |
|
4964 |
{ |
|
4965 |
m_children |= Blue; |
|
4966 |
m_blue = a; |
|
4967 |
} |
|
4968 |
||
4969 |
void DomColor::clearElementRed() |
|
4970 |
{ |
|
4971 |
m_children &= ~Red; |
|
4972 |
} |
|
4973 |
||
4974 |
void DomColor::clearElementGreen() |
|
4975 |
{ |
|
4976 |
m_children &= ~Green; |
|
4977 |
} |
|
4978 |
||
4979 |
void DomColor::clearElementBlue() |
|
4980 |
{ |
|
4981 |
m_children &= ~Blue; |
|
4982 |
} |
|
4983 |
||
4984 |
void DomGradientStop::clear(bool clear_all) |
|
4985 |
{ |
|
4986 |
delete m_color; |
|
4987 |
||
4988 |
if (clear_all) { |
|
4989 |
m_text.clear(); |
|
4990 |
m_has_attr_position = false; |
|
4991 |
m_attr_position = 0.0; |
|
4992 |
} |
|
4993 |
||
4994 |
m_children = 0; |
|
4995 |
m_color = 0; |
|
4996 |
} |
|
4997 |
||
4998 |
DomGradientStop::DomGradientStop() |
|
4999 |
{ |
|
5000 |
m_children = 0; |
|
5001 |
m_has_attr_position = false; |
|
5002 |
m_attr_position = 0.0; |
|
5003 |
m_color = 0; |
|
5004 |
} |
|
5005 |
||
5006 |
DomGradientStop::~DomGradientStop() |
|
5007 |
{ |
|
5008 |
delete m_color; |
|
5009 |
} |
|
5010 |
||
5011 |
void DomGradientStop::read(QXmlStreamReader &reader) |
|
5012 |
{ |
|
5013 |
||
5014 |
foreach (const QXmlStreamAttribute &attribute, reader.attributes()) { |
|
5015 |
QStringRef name = attribute.name(); |
|
5016 |
if (name == QLatin1String("position")) { |
|
5017 |
setAttributePosition(attribute.value().toString().toDouble()); |
|
5018 |
continue; |
|
5019 |
} |
|
5020 |
reader.raiseError(QLatin1String("Unexpected attribute ") + name.toString()); |
|
5021 |
} |
|
5022 |
||
5023 |
for (bool finished = false; !finished && !reader.hasError();) { |
|
5024 |
switch (reader.readNext()) { |
|
5025 |
case QXmlStreamReader::StartElement : { |
|
5026 |
const QString tag = reader.name().toString().toLower(); |
|
5027 |
if (tag == QLatin1String("color")) { |
|
5028 |
DomColor *v = new DomColor(); |
|
5029 |
v->read(reader); |
|
5030 |
setElementColor(v); |
|
5031 |
continue; |
|
5032 |
} |
|
5033 |
reader.raiseError(QLatin1String("Unexpected element ") + tag); |
|
5034 |
} |
|
5035 |
break; |
|
5036 |
case QXmlStreamReader::EndElement : |
|
5037 |
finished = true; |
|
5038 |
break; |
|
5039 |
case QXmlStreamReader::Characters : |
|
5040 |
if (!reader.isWhitespace()) |
|
5041 |
m_text.append(reader.text().toString()); |
|
5042 |
break; |
|
5043 |
default : |
|
5044 |
break; |
|
5045 |
} |
|
5046 |
} |
|
5047 |
} |
|
5048 |
||
5049 |
#ifdef QUILOADER_QDOM_READ |
|
5050 |
void DomGradientStop::read(const QDomElement &node) |
|
5051 |
{ |
|
5052 |
if (node.hasAttribute(QLatin1String("position"))) |
|
5053 |
setAttributePosition(node.attribute(QLatin1String("position")).toDouble()); |
|
5054 |
||
5055 |
for (QDomNode n = node.firstChild(); !n.isNull(); n = n.nextSibling()) { |
|
5056 |
if (!n.isElement()) |
|
5057 |
continue; |
|
5058 |
QDomElement e = n.toElement(); |
|
5059 |
QString tag = e.tagName().toLower(); |
|
5060 |
if (tag == QLatin1String("color")) { |
|
5061 |
DomColor *v = new DomColor(); |
|
5062 |
v->read(e); |
|
5063 |
setElementColor(v); |
|
5064 |
continue; |
|
5065 |
} |
|
5066 |
} |
|
5067 |
m_text.clear(); |
|
5068 |
for (QDomNode child = node.firstChild(); !child.isNull(); child = child.nextSibling()) { |
|
5069 |
if (child.isText()) |
|
5070 |
m_text.append(child.nodeValue()); |
|
5071 |
} |
|
5072 |
} |
|
5073 |
#endif |
|
5074 |
||
5075 |
void DomGradientStop::write(QXmlStreamWriter &writer, const QString &tagName) const |
|
5076 |
{ |
|
5077 |
writer.writeStartElement(tagName.isEmpty() ? QString::fromUtf8("gradientstop") : tagName.toLower()); |
|
5078 |
||
5079 |
if (hasAttributePosition()) |
|
5080 |
writer.writeAttribute(QLatin1String("position"), QString::number(attributePosition(), 'f', 15)); |
|
5081 |
||
5082 |
if (m_children & Color) { |
|
5083 |
m_color->write(writer, QLatin1String("color")); |
|
5084 |
} |
|
5085 |
||
5086 |
if (!m_text.isEmpty()) |
|
5087 |
writer.writeCharacters(m_text); |
|
5088 |
||
5089 |
writer.writeEndElement(); |
|
5090 |
} |
|
5091 |
||
5092 |
DomColor* DomGradientStop::takeElementColor() |
|
5093 |
{ |
|
5094 |
DomColor* a = m_color; |
|
5095 |
m_color = 0; |
|
5096 |
m_children ^= Color; |
|
5097 |
return a; |
|
5098 |
} |
|
5099 |
||
5100 |
void DomGradientStop::setElementColor(DomColor* a) |
|
5101 |
{ |
|
5102 |
delete m_color; |
|
5103 |
m_children |= Color; |
|
5104 |
m_color = a; |
|
5105 |
} |
|
5106 |
||
5107 |
void DomGradientStop::clearElementColor() |
|
5108 |
{ |
|
5109 |
delete m_color; |
|
5110 |
m_color = 0; |
|
5111 |
m_children &= ~Color; |
|
5112 |
} |
|
5113 |
||
5114 |
void DomGradient::clear(bool clear_all) |
|
5115 |
{ |
|
5116 |
qDeleteAll(m_gradientStop); |
|
5117 |
m_gradientStop.clear(); |
|
5118 |
||
5119 |
if (clear_all) { |
|
5120 |
m_text.clear(); |
|
5121 |
m_has_attr_startX = false; |
|
5122 |
m_attr_startX = 0.0; |
|
5123 |
m_has_attr_startY = false; |
|
5124 |
m_attr_startY = 0.0; |
|
5125 |
m_has_attr_endX = false; |
|
5126 |
m_attr_endX = 0.0; |
|
5127 |
m_has_attr_endY = false; |
|
5128 |
m_attr_endY = 0.0; |
|
5129 |
m_has_attr_centralX = false; |
|
5130 |
m_attr_centralX = 0.0; |
|
5131 |
m_has_attr_centralY = false; |
|
5132 |
m_attr_centralY = 0.0; |
|
5133 |
m_has_attr_focalX = false; |
|
5134 |
m_attr_focalX = 0.0; |
|
5135 |
m_has_attr_focalY = false; |
|
5136 |
m_attr_focalY = 0.0; |
|
5137 |
m_has_attr_radius = false; |
|
5138 |
m_attr_radius = 0.0; |
|
5139 |
m_has_attr_angle = false; |
|
5140 |
m_attr_angle = 0.0; |
|
5141 |
m_has_attr_type = false; |
|
5142 |
m_has_attr_spread = false; |
|
5143 |
m_has_attr_coordinateMode = false; |
|
5144 |
} |
|
5145 |
||
5146 |
m_children = 0; |
|
5147 |
} |
|
5148 |
||
5149 |
DomGradient::DomGradient() |
|
5150 |
{ |
|
5151 |
m_children = 0; |
|
5152 |
m_has_attr_startX = false; |
|
5153 |
m_attr_startX = 0.0; |
|
5154 |
m_has_attr_startY = false; |
|
5155 |
m_attr_startY = 0.0; |
|
5156 |
m_has_attr_endX = false; |
|
5157 |
m_attr_endX = 0.0; |
|
5158 |
m_has_attr_endY = false; |
|
5159 |
m_attr_endY = 0.0; |
|
5160 |
m_has_attr_centralX = false; |
|
5161 |
m_attr_centralX = 0.0; |
|
5162 |
m_has_attr_centralY = false; |
|
5163 |
m_attr_centralY = 0.0; |
|
5164 |
m_has_attr_focalX = false; |
|
5165 |
m_attr_focalX = 0.0; |
|
5166 |
m_has_attr_focalY = false; |
|
5167 |
m_attr_focalY = 0.0; |
|
5168 |
m_has_attr_radius = false; |
|
5169 |
m_attr_radius = 0.0; |
|
5170 |
m_has_attr_angle = false; |
|
5171 |
m_attr_angle = 0.0; |
|
5172 |
m_has_attr_type = false; |
|
5173 |
m_has_attr_spread = false; |
|
5174 |
m_has_attr_coordinateMode = false; |
|
5175 |
} |
|
5176 |
||
5177 |
DomGradient::~DomGradient() |
|
5178 |
{ |
|
5179 |
qDeleteAll(m_gradientStop); |
|
5180 |
m_gradientStop.clear(); |
|
5181 |
} |
|
5182 |
||
5183 |
void DomGradient::read(QXmlStreamReader &reader) |
|
5184 |
{ |
|
5185 |
||
5186 |
foreach (const QXmlStreamAttribute &attribute, reader.attributes()) { |
|
5187 |
QStringRef name = attribute.name(); |
|
5188 |
if (name == QLatin1String("startx")) { |
|
5189 |
setAttributeStartX(attribute.value().toString().toDouble()); |
|
5190 |
continue; |
|
5191 |
} |
|
5192 |
if (name == QLatin1String("starty")) { |
|
5193 |
setAttributeStartY(attribute.value().toString().toDouble()); |
|
5194 |
continue; |
|
5195 |
} |
|
5196 |
if (name == QLatin1String("endx")) { |
|
5197 |
setAttributeEndX(attribute.value().toString().toDouble()); |
|
5198 |
continue; |
|
5199 |
} |
|
5200 |
if (name == QLatin1String("endy")) { |
|
5201 |
setAttributeEndY(attribute.value().toString().toDouble()); |
|
5202 |
continue; |
|
5203 |
} |
|
5204 |
if (name == QLatin1String("centralx")) { |
|
5205 |
setAttributeCentralX(attribute.value().toString().toDouble()); |
|
5206 |
continue; |
|
5207 |
} |
|
5208 |
if (name == QLatin1String("centraly")) { |
|
5209 |
setAttributeCentralY(attribute.value().toString().toDouble()); |
|
5210 |
continue; |
|
5211 |
} |
|
5212 |
if (name == QLatin1String("focalx")) { |
|
5213 |
setAttributeFocalX(attribute.value().toString().toDouble()); |
|
5214 |
continue; |
|
5215 |
} |
|
5216 |
if (name == QLatin1String("focaly")) { |
|
5217 |
setAttributeFocalY(attribute.value().toString().toDouble()); |
|
5218 |
continue; |
|
5219 |
} |
|
5220 |
if (name == QLatin1String("radius")) { |
|
5221 |
setAttributeRadius(attribute.value().toString().toDouble()); |
|
5222 |
continue; |
|
5223 |
} |
|
5224 |
if (name == QLatin1String("angle")) { |
|
5225 |
setAttributeAngle(attribute.value().toString().toDouble()); |
|
5226 |
continue; |
|
5227 |
} |
|
5228 |
if (name == QLatin1String("type")) { |
|
5229 |
setAttributeType(attribute.value().toString()); |
|
5230 |
continue; |
|
5231 |
} |
|
5232 |
if (name == QLatin1String("spread")) { |
|
5233 |
setAttributeSpread(attribute.value().toString()); |
|
5234 |
continue; |
|
5235 |
} |
|
5236 |
if (name == QLatin1String("coordinatemode")) { |
|
5237 |
setAttributeCoordinateMode(attribute.value().toString()); |
|
5238 |
continue; |
|
5239 |
} |
|
5240 |
reader.raiseError(QLatin1String("Unexpected attribute ") + name.toString()); |
|
5241 |
} |
|
5242 |
||
5243 |
for (bool finished = false; !finished && !reader.hasError();) { |
|
5244 |
switch (reader.readNext()) { |
|
5245 |
case QXmlStreamReader::StartElement : { |
|
5246 |
const QString tag = reader.name().toString().toLower(); |
|
5247 |
if (tag == QLatin1String("gradientstop")) { |
|
5248 |
DomGradientStop *v = new DomGradientStop(); |
|
5249 |
v->read(reader); |
|
5250 |
m_gradientStop.append(v); |
|
5251 |
continue; |
|
5252 |
} |
|
5253 |
reader.raiseError(QLatin1String("Unexpected element ") + tag); |
|
5254 |
} |
|
5255 |
break; |
|
5256 |
case QXmlStreamReader::EndElement : |
|
5257 |
finished = true; |
|
5258 |
break; |
|
5259 |
case QXmlStreamReader::Characters : |
|
5260 |
if (!reader.isWhitespace()) |
|
5261 |
m_text.append(reader.text().toString()); |
|
5262 |
break; |
|
5263 |
default : |
|
5264 |
break; |
|
5265 |
} |
|
5266 |
} |
|
5267 |
} |
|
5268 |
||
5269 |
#ifdef QUILOADER_QDOM_READ |
|
5270 |
void DomGradient::read(const QDomElement &node) |
|
5271 |
{ |
|
5272 |
if (node.hasAttribute(QLatin1String("startx"))) |
|
5273 |
setAttributeStartX(node.attribute(QLatin1String("startx")).toDouble()); |
|
5274 |
if (node.hasAttribute(QLatin1String("starty"))) |
|
5275 |
setAttributeStartY(node.attribute(QLatin1String("starty")).toDouble()); |
|
5276 |
if (node.hasAttribute(QLatin1String("endx"))) |
|
5277 |
setAttributeEndX(node.attribute(QLatin1String("endx")).toDouble()); |
|
5278 |
if (node.hasAttribute(QLatin1String("endy"))) |
|
5279 |
setAttributeEndY(node.attribute(QLatin1String("endy")).toDouble()); |
|
5280 |
if (node.hasAttribute(QLatin1String("centralx"))) |
|
5281 |
setAttributeCentralX(node.attribute(QLatin1String("centralx")).toDouble()); |
|
5282 |
if (node.hasAttribute(QLatin1String("centraly"))) |
|
5283 |
setAttributeCentralY(node.attribute(QLatin1String("centraly")).toDouble()); |
|
5284 |
if (node.hasAttribute(QLatin1String("focalx"))) |
|
5285 |
setAttributeFocalX(node.attribute(QLatin1String("focalx")).toDouble()); |
|
5286 |
if (node.hasAttribute(QLatin1String("focaly"))) |
|
5287 |
setAttributeFocalY(node.attribute(QLatin1String("focaly")).toDouble()); |
|
5288 |
if (node.hasAttribute(QLatin1String("radius"))) |
|
5289 |
setAttributeRadius(node.attribute(QLatin1String("radius")).toDouble()); |
|
5290 |
if (node.hasAttribute(QLatin1String("angle"))) |
|
5291 |
setAttributeAngle(node.attribute(QLatin1String("angle")).toDouble()); |
|
5292 |
if (node.hasAttribute(QLatin1String("type"))) |
|
5293 |
setAttributeType(node.attribute(QLatin1String("type"))); |
|
5294 |
if (node.hasAttribute(QLatin1String("spread"))) |
|
5295 |
setAttributeSpread(node.attribute(QLatin1String("spread"))); |
|
5296 |
if (node.hasAttribute(QLatin1String("coordinatemode"))) |
|
5297 |
setAttributeCoordinateMode(node.attribute(QLatin1String("coordinatemode"))); |
|
5298 |
||
5299 |
for (QDomNode n = node.firstChild(); !n.isNull(); n = n.nextSibling()) { |
|
5300 |
if (!n.isElement()) |
|
5301 |
continue; |
|
5302 |
QDomElement e = n.toElement(); |
|
5303 |
QString tag = e.tagName().toLower(); |
|
5304 |
if (tag == QLatin1String("gradientstop")) { |
|
5305 |
DomGradientStop *v = new DomGradientStop(); |
|
5306 |
v->read(e); |
|
5307 |
m_gradientStop.append(v); |
|
5308 |
continue; |
|
5309 |
} |
|
5310 |
} |
|
5311 |
m_text.clear(); |
|
5312 |
for (QDomNode child = node.firstChild(); !child.isNull(); child = child.nextSibling()) { |
|
5313 |
if (child.isText()) |
|
5314 |
m_text.append(child.nodeValue()); |
|
5315 |
} |
|
5316 |
} |
|
5317 |
#endif |
|
5318 |
||
5319 |
void DomGradient::write(QXmlStreamWriter &writer, const QString &tagName) const |
|
5320 |
{ |
|
5321 |
writer.writeStartElement(tagName.isEmpty() ? QString::fromUtf8("gradient") : tagName.toLower()); |
|
5322 |
||
5323 |
if (hasAttributeStartX()) |
|
5324 |
writer.writeAttribute(QLatin1String("startx"), QString::number(attributeStartX(), 'f', 15)); |
|
5325 |
||
5326 |
if (hasAttributeStartY()) |
|
5327 |
writer.writeAttribute(QLatin1String("starty"), QString::number(attributeStartY(), 'f', 15)); |
|
5328 |
||
5329 |
if (hasAttributeEndX()) |
|
5330 |
writer.writeAttribute(QLatin1String("endx"), QString::number(attributeEndX(), 'f', 15)); |
|
5331 |
||
5332 |
if (hasAttributeEndY()) |
|
5333 |
writer.writeAttribute(QLatin1String("endy"), QString::number(attributeEndY(), 'f', 15)); |
|
5334 |
||
5335 |
if (hasAttributeCentralX()) |
|
5336 |
writer.writeAttribute(QLatin1String("centralx"), QString::number(attributeCentralX(), 'f', 15)); |
|
5337 |
||
5338 |
if (hasAttributeCentralY()) |
|
5339 |
writer.writeAttribute(QLatin1String("centraly"), QString::number(attributeCentralY(), 'f', 15)); |
|
5340 |
||
5341 |
if (hasAttributeFocalX()) |
|
5342 |
writer.writeAttribute(QLatin1String("focalx"), QString::number(attributeFocalX(), 'f', 15)); |
|
5343 |
||
5344 |
if (hasAttributeFocalY()) |
|
5345 |
writer.writeAttribute(QLatin1String("focaly"), QString::number(attributeFocalY(), 'f', 15)); |
|
5346 |
||
5347 |
if (hasAttributeRadius()) |
|
5348 |
writer.writeAttribute(QLatin1String("radius"), QString::number(attributeRadius(), 'f', 15)); |
|
5349 |
||
5350 |
if (hasAttributeAngle()) |
|
5351 |
writer.writeAttribute(QLatin1String("angle"), QString::number(attributeAngle(), 'f', 15)); |
|
5352 |
||
5353 |
if (hasAttributeType()) |
|
5354 |
writer.writeAttribute(QLatin1String("type"), attributeType()); |
|
5355 |
||
5356 |
if (hasAttributeSpread()) |
|
5357 |
writer.writeAttribute(QLatin1String("spread"), attributeSpread()); |
|
5358 |
||
5359 |
if (hasAttributeCoordinateMode()) |
|
5360 |
writer.writeAttribute(QLatin1String("coordinatemode"), attributeCoordinateMode()); |
|
5361 |
||
5362 |
for (int i = 0; i < m_gradientStop.size(); ++i) { |
|
5363 |
DomGradientStop* v = m_gradientStop[i]; |
|
5364 |
v->write(writer, QLatin1String("gradientstop")); |
|
5365 |
} |
|
5366 |
if (!m_text.isEmpty()) |
|
5367 |
writer.writeCharacters(m_text); |
|
5368 |
||
5369 |
writer.writeEndElement(); |
|
5370 |
} |
|
5371 |
||
5372 |
void DomGradient::setElementGradientStop(const QList<DomGradientStop*>& a) |
|
5373 |
{ |
|
5374 |
m_children |= GradientStop; |
|
5375 |
m_gradientStop = a; |
|
5376 |
} |
|
5377 |
||
5378 |
void DomBrush::clear(bool clear_all) |
|
5379 |
{ |
|
5380 |
delete m_color; |
|
5381 |
delete m_texture; |
|
5382 |
delete m_gradient; |
|
5383 |
||
5384 |
if (clear_all) { |
|
5385 |
m_text.clear(); |
|
5386 |
m_has_attr_brushStyle = false; |
|
5387 |
} |
|
5388 |
||
5389 |
m_kind = Unknown; |
|
5390 |
||
5391 |
m_color = 0; |
|
5392 |
m_texture = 0; |
|
5393 |
m_gradient = 0; |
|
5394 |
} |
|
5395 |
||
5396 |
DomBrush::DomBrush() |
|
5397 |
{ |
|
5398 |
m_kind = Unknown; |
|
5399 |
||
5400 |
m_has_attr_brushStyle = false; |
|
5401 |
m_color = 0; |
|
5402 |
m_texture = 0; |
|
5403 |
m_gradient = 0; |
|
5404 |
} |
|
5405 |
||
5406 |
DomBrush::~DomBrush() |
|
5407 |
{ |
|
5408 |
delete m_color; |
|
5409 |
delete m_texture; |
|
5410 |
delete m_gradient; |
|
5411 |
} |
|
5412 |
||
5413 |
void DomBrush::read(QXmlStreamReader &reader) |
|
5414 |
{ |
|
5415 |
||
5416 |
foreach (const QXmlStreamAttribute &attribute, reader.attributes()) { |
|
5417 |
QStringRef name = attribute.name(); |
|
5418 |
if (name == QLatin1String("brushstyle")) { |
|
5419 |
setAttributeBrushStyle(attribute.value().toString()); |
|
5420 |
continue; |
|
5421 |
} |
|
5422 |
reader.raiseError(QLatin1String("Unexpected attribute ") + name.toString()); |
|
5423 |
} |
|
5424 |
||
5425 |
for (bool finished = false; !finished && !reader.hasError();) { |
|
5426 |
switch (reader.readNext()) { |
|
5427 |
case QXmlStreamReader::StartElement : { |
|
5428 |
const QString tag = reader.name().toString().toLower(); |
|
5429 |
if (tag == QLatin1String("color")) { |
|
5430 |
DomColor *v = new DomColor(); |
|
5431 |
v->read(reader); |
|
5432 |
setElementColor(v); |
|
5433 |
continue; |
|
5434 |
} |
|
5435 |
if (tag == QLatin1String("texture")) { |
|
5436 |
DomProperty *v = new DomProperty(); |
|
5437 |
v->read(reader); |
|
5438 |
setElementTexture(v); |
|
5439 |
continue; |
|
5440 |
} |
|
5441 |
if (tag == QLatin1String("gradient")) { |
|
5442 |
DomGradient *v = new DomGradient(); |
|
5443 |
v->read(reader); |
|
5444 |
setElementGradient(v); |
|
5445 |
continue; |
|
5446 |
} |
|
5447 |
reader.raiseError(QLatin1String("Unexpected element ") + tag); |
|
5448 |
} |
|
5449 |
break; |
|
5450 |
case QXmlStreamReader::EndElement : |
|
5451 |
finished = true; |
|
5452 |
break; |
|
5453 |
case QXmlStreamReader::Characters : |
|
5454 |
if (!reader.isWhitespace()) |
|
5455 |
m_text.append(reader.text().toString()); |
|
5456 |
break; |
|
5457 |
default : |
|
5458 |
break; |
|
5459 |
} |
|
5460 |
} |
|
5461 |
} |
|
5462 |
||
5463 |
#ifdef QUILOADER_QDOM_READ |
|
5464 |
void DomBrush::read(const QDomElement &node) |
|
5465 |
{ |
|
5466 |
if (node.hasAttribute(QLatin1String("brushstyle"))) |
|
5467 |
setAttributeBrushStyle(node.attribute(QLatin1String("brushstyle"))); |
|
5468 |
||
5469 |
for (QDomNode n = node.firstChild(); !n.isNull(); n = n.nextSibling()) { |
|
5470 |
if (!n.isElement()) |
|
5471 |
continue; |
|
5472 |
QDomElement e = n.toElement(); |
|
5473 |
QString tag = e.tagName().toLower(); |
|
5474 |
if (tag == QLatin1String("color")) { |
|
5475 |
DomColor *v = new DomColor(); |
|
5476 |
v->read(e); |
|
5477 |
setElementColor(v); |
|
5478 |
continue; |
|
5479 |
} |
|
5480 |
if (tag == QLatin1String("texture")) { |
|
5481 |
DomProperty *v = new DomProperty(); |
|
5482 |
v->read(e); |
|
5483 |
setElementTexture(v); |
|
5484 |
continue; |
|
5485 |
} |
|
5486 |
if (tag == QLatin1String("gradient")) { |
|
5487 |
DomGradient *v = new DomGradient(); |
|
5488 |
v->read(e); |
|
5489 |
setElementGradient(v); |
|
5490 |
continue; |
|
5491 |
} |
|
5492 |
} |
|
5493 |
m_text.clear(); |
|
5494 |
for (QDomNode child = node.firstChild(); !child.isNull(); child = child.nextSibling()) { |
|
5495 |
if (child.isText()) |
|
5496 |
m_text.append(child.nodeValue()); |
|
5497 |
} |
|
5498 |
} |
|
5499 |
#endif |
|
5500 |
||
5501 |
void DomBrush::write(QXmlStreamWriter &writer, const QString &tagName) const |
|
5502 |
{ |
|
5503 |
writer.writeStartElement(tagName.isEmpty() ? QString::fromUtf8("brush") : tagName.toLower()); |
|
5504 |
||
5505 |
if (hasAttributeBrushStyle()) |
|
5506 |
writer.writeAttribute(QLatin1String("brushstyle"), attributeBrushStyle()); |
|
5507 |
||
5508 |
switch (kind()) { |
|
5509 |
case Color: { |
|
5510 |
DomColor* v = elementColor(); |
|
5511 |
if (v != 0) { |
|
5512 |
v->write(writer, QLatin1String("color")); |
|
5513 |
} |
|
5514 |
break; |
|
5515 |
} |
|
5516 |
case Texture: { |
|
5517 |
DomProperty* v = elementTexture(); |
|
5518 |
if (v != 0) { |
|
5519 |
v->write(writer, QLatin1String("texture")); |
|
5520 |
} |
|
5521 |
break; |
|
5522 |
} |
|
5523 |
case Gradient: { |
|
5524 |
DomGradient* v = elementGradient(); |
|
5525 |
if (v != 0) { |
|
5526 |
v->write(writer, QLatin1String("gradient")); |
|
5527 |
} |
|
5528 |
break; |
|
5529 |
} |
|
5530 |
default: |
|
5531 |
break; |
|
5532 |
} |
|
5533 |
if (!m_text.isEmpty()) |
|
5534 |
writer.writeCharacters(m_text); |
|
5535 |
||
5536 |
writer.writeEndElement(); |
|
5537 |
} |
|
5538 |
||
5539 |
DomColor* DomBrush::takeElementColor() |
|
5540 |
{ |
|
5541 |
DomColor* a = m_color; |
|
5542 |
m_color = 0; |
|
5543 |
return a; |
|
5544 |
} |
|
5545 |
||
5546 |
void DomBrush::setElementColor(DomColor* a) |
|
5547 |
{ |
|
5548 |
clear(false); |
|
5549 |
m_kind = Color; |
|
5550 |
m_color = a; |
|
5551 |
} |
|
5552 |
||
5553 |
DomProperty* DomBrush::takeElementTexture() |
|
5554 |
{ |
|
5555 |
DomProperty* a = m_texture; |
|
5556 |
m_texture = 0; |
|
5557 |
return a; |
|
5558 |
} |
|
5559 |
||
5560 |
void DomBrush::setElementTexture(DomProperty* a) |
|
5561 |
{ |
|
5562 |
clear(false); |
|
5563 |
m_kind = Texture; |
|
5564 |
m_texture = a; |
|
5565 |
} |
|
5566 |
||
5567 |
DomGradient* DomBrush::takeElementGradient() |
|
5568 |
{ |
|
5569 |
DomGradient* a = m_gradient; |
|
5570 |
m_gradient = 0; |
|
5571 |
return a; |
|
5572 |
} |
|
5573 |
||
5574 |
void DomBrush::setElementGradient(DomGradient* a) |
|
5575 |
{ |
|
5576 |
clear(false); |
|
5577 |
m_kind = Gradient; |
|
5578 |
m_gradient = a; |
|
5579 |
} |
|
5580 |
||
5581 |
void DomColorRole::clear(bool clear_all) |
|
5582 |
{ |
|
5583 |
delete m_brush; |
|
5584 |
||
5585 |
if (clear_all) { |
|
5586 |
m_text.clear(); |
|
5587 |
m_has_attr_role = false; |
|
5588 |
} |
|
5589 |
||
5590 |
m_children = 0; |
|
5591 |
m_brush = 0; |
|
5592 |
} |
|
5593 |
||
5594 |
DomColorRole::DomColorRole() |
|
5595 |
{ |
|
5596 |
m_children = 0; |
|
5597 |
m_has_attr_role = false; |
|
5598 |
m_brush = 0; |
|
5599 |
} |
|
5600 |
||
5601 |
DomColorRole::~DomColorRole() |
|
5602 |
{ |
|
5603 |
delete m_brush; |
|
5604 |
} |
|
5605 |
||
5606 |
void DomColorRole::read(QXmlStreamReader &reader) |
|
5607 |
{ |
|
5608 |
||
5609 |
foreach (const QXmlStreamAttribute &attribute, reader.attributes()) { |
|
5610 |
QStringRef name = attribute.name(); |
|
5611 |
if (name == QLatin1String("role")) { |
|
5612 |
setAttributeRole(attribute.value().toString()); |
|
5613 |
continue; |
|
5614 |
} |
|
5615 |
reader.raiseError(QLatin1String("Unexpected attribute ") + name.toString()); |
|
5616 |
} |
|
5617 |
||
5618 |
for (bool finished = false; !finished && !reader.hasError();) { |
|
5619 |
switch (reader.readNext()) { |
|
5620 |
case QXmlStreamReader::StartElement : { |
|
5621 |
const QString tag = reader.name().toString().toLower(); |
|
5622 |
if (tag == QLatin1String("brush")) { |
|
5623 |
DomBrush *v = new DomBrush(); |
|
5624 |
v->read(reader); |
|
5625 |
setElementBrush(v); |
|
5626 |
continue; |
|
5627 |
} |
|
5628 |
reader.raiseError(QLatin1String("Unexpected element ") + tag); |
|
5629 |
} |
|
5630 |
break; |
|
5631 |
case QXmlStreamReader::EndElement : |
|
5632 |
finished = true; |
|
5633 |
break; |
|
5634 |
case QXmlStreamReader::Characters : |
|
5635 |
if (!reader.isWhitespace()) |
|
5636 |
m_text.append(reader.text().toString()); |
|
5637 |
break; |
|
5638 |
default : |
|
5639 |
break; |
|
5640 |
} |
|
5641 |
} |
|
5642 |
} |
|
5643 |
||
5644 |
#ifdef QUILOADER_QDOM_READ |
|
5645 |
void DomColorRole::read(const QDomElement &node) |
|
5646 |
{ |
|
5647 |
if (node.hasAttribute(QLatin1String("role"))) |
|
5648 |
setAttributeRole(node.attribute(QLatin1String("role"))); |
|
5649 |
||
5650 |
for (QDomNode n = node.firstChild(); !n.isNull(); n = n.nextSibling()) { |
|
5651 |
if (!n.isElement()) |
|
5652 |
continue; |
|
5653 |
QDomElement e = n.toElement(); |
|
5654 |
QString tag = e.tagName().toLower(); |
|
5655 |
if (tag == QLatin1String("brush")) { |
|
5656 |
DomBrush *v = new DomBrush(); |
|
5657 |
v->read(e); |
|
5658 |
setElementBrush(v); |
|
5659 |
continue; |
|
5660 |
} |
|
5661 |
} |
|
5662 |
m_text.clear(); |
|
5663 |
for (QDomNode child = node.firstChild(); !child.isNull(); child = child.nextSibling()) { |
|
5664 |
if (child.isText()) |
|
5665 |
m_text.append(child.nodeValue()); |
|
5666 |
} |
|
5667 |
} |
|
5668 |
#endif |
|
5669 |
||
5670 |
void DomColorRole::write(QXmlStreamWriter &writer, const QString &tagName) const |
|
5671 |
{ |
|
5672 |
writer.writeStartElement(tagName.isEmpty() ? QString::fromUtf8("colorrole") : tagName.toLower()); |
|
5673 |
||
5674 |
if (hasAttributeRole()) |
|
5675 |
writer.writeAttribute(QLatin1String("role"), attributeRole()); |
|
5676 |
||
5677 |
if (m_children & Brush) { |
|
5678 |
m_brush->write(writer, QLatin1String("brush")); |
|
5679 |
} |
|
5680 |
||
5681 |
if (!m_text.isEmpty()) |
|
5682 |
writer.writeCharacters(m_text); |
|
5683 |
||
5684 |
writer.writeEndElement(); |
|
5685 |
} |
|
5686 |
||
5687 |
DomBrush* DomColorRole::takeElementBrush() |
|
5688 |
{ |
|
5689 |
DomBrush* a = m_brush; |
|
5690 |
m_brush = 0; |
|
5691 |
m_children ^= Brush; |
|
5692 |
return a; |
|
5693 |
} |
|
5694 |
||
5695 |
void DomColorRole::setElementBrush(DomBrush* a) |
|
5696 |
{ |
|
5697 |
delete m_brush; |
|
5698 |
m_children |= Brush; |
|
5699 |
m_brush = a; |
|
5700 |
} |
|
5701 |
||
5702 |
void DomColorRole::clearElementBrush() |
|
5703 |
{ |
|
5704 |
delete m_brush; |
|
5705 |
m_brush = 0; |
|
5706 |
m_children &= ~Brush; |
|
5707 |
} |
|
5708 |
||
5709 |
void DomColorGroup::clear(bool clear_all) |
|
5710 |
{ |
|
5711 |
qDeleteAll(m_colorRole); |
|
5712 |
m_colorRole.clear(); |
|
5713 |
qDeleteAll(m_color); |
|
5714 |
m_color.clear(); |
|
5715 |
||
5716 |
if (clear_all) { |
|
5717 |
m_text.clear(); |
|
5718 |
} |
|
5719 |
||
5720 |
m_children = 0; |
|
5721 |
} |
|
5722 |
||
5723 |
DomColorGroup::DomColorGroup() |
|
5724 |
{ |
|
5725 |
m_children = 0; |
|
5726 |
} |
|
5727 |
||
5728 |
DomColorGroup::~DomColorGroup() |
|
5729 |
{ |
|
5730 |
qDeleteAll(m_colorRole); |
|
5731 |
m_colorRole.clear(); |
|
5732 |
qDeleteAll(m_color); |
|
5733 |
m_color.clear(); |
|
5734 |
} |
|
5735 |
||
5736 |
void DomColorGroup::read(QXmlStreamReader &reader) |
|
5737 |
{ |
|
5738 |
||
5739 |
for (bool finished = false; !finished && !reader.hasError();) { |
|
5740 |
switch (reader.readNext()) { |
|
5741 |
case QXmlStreamReader::StartElement : { |
|
5742 |
const QString tag = reader.name().toString().toLower(); |
|
5743 |
if (tag == QLatin1String("colorrole")) { |
|
5744 |
DomColorRole *v = new DomColorRole(); |
|
5745 |
v->read(reader); |
|
5746 |
m_colorRole.append(v); |
|
5747 |
continue; |
|
5748 |
} |
|
5749 |
if (tag == QLatin1String("color")) { |
|
5750 |
DomColor *v = new DomColor(); |
|
5751 |
v->read(reader); |
|
5752 |
m_color.append(v); |
|
5753 |
continue; |
|
5754 |
} |
|
5755 |
reader.raiseError(QLatin1String("Unexpected element ") + tag); |
|
5756 |
} |
|
5757 |
break; |
|
5758 |
case QXmlStreamReader::EndElement : |
|
5759 |
finished = true; |
|
5760 |
break; |
|
5761 |
case QXmlStreamReader::Characters : |
|
5762 |
if (!reader.isWhitespace()) |
|
5763 |
m_text.append(reader.text().toString()); |
|
5764 |
break; |
|
5765 |
default : |
|
5766 |
break; |
|
5767 |
} |
|
5768 |
} |
|
5769 |
} |
|
5770 |
||
5771 |
#ifdef QUILOADER_QDOM_READ |
|
5772 |
void DomColorGroup::read(const QDomElement &node) |
|
5773 |
{ |
|
5774 |
for (QDomNode n = node.firstChild(); !n.isNull(); n = n.nextSibling()) { |
|
5775 |
if (!n.isElement()) |
|
5776 |
continue; |
|
5777 |
QDomElement e = n.toElement(); |
|
5778 |
QString tag = e.tagName().toLower(); |
|
5779 |
if (tag == QLatin1String("colorrole")) { |
|
5780 |
DomColorRole *v = new DomColorRole(); |
|
5781 |
v->read(e); |
|
5782 |
m_colorRole.append(v); |
|
5783 |
continue; |
|
5784 |
} |
|
5785 |
if (tag == QLatin1String("color")) { |
|
5786 |
DomColor *v = new DomColor(); |
|
5787 |
v->read(e); |
|
5788 |
m_color.append(v); |
|
5789 |
continue; |
|
5790 |
} |
|
5791 |
} |
|
5792 |
m_text.clear(); |
|
5793 |
for (QDomNode child = node.firstChild(); !child.isNull(); child = child.nextSibling()) { |
|
5794 |
if (child.isText()) |
|
5795 |
m_text.append(child.nodeValue()); |
|
5796 |
} |
|
5797 |
} |
|
5798 |
#endif |
|
5799 |
||
5800 |
void DomColorGroup::write(QXmlStreamWriter &writer, const QString &tagName) const |
|
5801 |
{ |
|
5802 |
writer.writeStartElement(tagName.isEmpty() ? QString::fromUtf8("colorgroup") : tagName.toLower()); |
|
5803 |
||
5804 |
for (int i = 0; i < m_colorRole.size(); ++i) { |
|
5805 |
DomColorRole* v = m_colorRole[i]; |
|
5806 |
v->write(writer, QLatin1String("colorrole")); |
|
5807 |
} |
|
5808 |
for (int i = 0; i < m_color.size(); ++i) { |
|
5809 |
DomColor* v = m_color[i]; |
|
5810 |
v->write(writer, QLatin1String("color")); |
|
5811 |
} |
|
5812 |
if (!m_text.isEmpty()) |
|
5813 |
writer.writeCharacters(m_text); |
|
5814 |
||
5815 |
writer.writeEndElement(); |
|
5816 |
} |
|
5817 |
||
5818 |
void DomColorGroup::setElementColorRole(const QList<DomColorRole*>& a) |
|
5819 |
{ |
|
5820 |
m_children |= ColorRole; |
|
5821 |
m_colorRole = a; |
|
5822 |
} |
|
5823 |
||
5824 |
void DomColorGroup::setElementColor(const QList<DomColor*>& a) |
|
5825 |
{ |
|
5826 |
m_children |= Color; |
|
5827 |
m_color = a; |
|
5828 |
} |
|
5829 |
||
5830 |
void DomPalette::clear(bool clear_all) |
|
5831 |
{ |
|
5832 |
delete m_active; |
|
5833 |
delete m_inactive; |
|
5834 |
delete m_disabled; |
|
5835 |
||
5836 |
if (clear_all) { |
|
5837 |
m_text.clear(); |
|
5838 |
} |
|
5839 |
||
5840 |
m_children = 0; |
|
5841 |
m_active = 0; |
|
5842 |
m_inactive = 0; |
|
5843 |
m_disabled = 0; |
|
5844 |
} |
|
5845 |
||
5846 |
DomPalette::DomPalette() |
|
5847 |
{ |
|
5848 |
m_children = 0; |
|
5849 |
m_active = 0; |
|
5850 |
m_inactive = 0; |
|
5851 |
m_disabled = 0; |
|
5852 |
} |
|
5853 |
||
5854 |
DomPalette::~DomPalette() |
|
5855 |
{ |
|
5856 |
delete m_active; |
|
5857 |
delete m_inactive; |
|
5858 |
delete m_disabled; |
|
5859 |
} |
|
5860 |
||
5861 |
void DomPalette::read(QXmlStreamReader &reader) |
|
5862 |
{ |
|
5863 |
||
5864 |
for (bool finished = false; !finished && !reader.hasError();) { |
|
5865 |
switch (reader.readNext()) { |
|
5866 |
case QXmlStreamReader::StartElement : { |
|
5867 |
const QString tag = reader.name().toString().toLower(); |
|
5868 |
if (tag == QLatin1String("active")) { |
|
5869 |
DomColorGroup *v = new DomColorGroup(); |
|
5870 |
v->read(reader); |
|
5871 |
setElementActive(v); |
|
5872 |
continue; |
|
5873 |
} |
|
5874 |
if (tag == QLatin1String("inactive")) { |
|
5875 |
DomColorGroup *v = new DomColorGroup(); |
|
5876 |
v->read(reader); |
|
5877 |
setElementInactive(v); |
|
5878 |
continue; |
|
5879 |
} |
|
5880 |
if (tag == QLatin1String("disabled")) { |
|
5881 |
DomColorGroup *v = new DomColorGroup(); |
|
5882 |
v->read(reader); |
|
5883 |
setElementDisabled(v); |
|
5884 |
continue; |
|
5885 |
} |
|
5886 |
reader.raiseError(QLatin1String("Unexpected element ") + tag); |
|
5887 |
} |
|
5888 |
break; |
|
5889 |
case QXmlStreamReader::EndElement : |
|
5890 |
finished = true; |
|
5891 |
break; |
|
5892 |
case QXmlStreamReader::Characters : |
|
5893 |
if (!reader.isWhitespace()) |
|
5894 |
m_text.append(reader.text().toString()); |
|
5895 |
break; |
|
5896 |
default : |
|
5897 |
break; |
|
5898 |
} |
|
5899 |
} |
|
5900 |
} |
|
5901 |
||
5902 |
#ifdef QUILOADER_QDOM_READ |
|
5903 |
void DomPalette::read(const QDomElement &node) |
|
5904 |
{ |
|
5905 |
for (QDomNode n = node.firstChild(); !n.isNull(); n = n.nextSibling()) { |
|
5906 |
if (!n.isElement()) |
|
5907 |
continue; |
|
5908 |
QDomElement e = n.toElement(); |
|
5909 |
QString tag = e.tagName().toLower(); |
|
5910 |
if (tag == QLatin1String("active")) { |
|
5911 |
DomColorGroup *v = new DomColorGroup(); |
|
5912 |
v->read(e); |
|
5913 |
setElementActive(v); |
|
5914 |
continue; |
|
5915 |
} |
|
5916 |
if (tag == QLatin1String("inactive")) { |
|
5917 |
DomColorGroup *v = new DomColorGroup(); |
|
5918 |
v->read(e); |
|
5919 |
setElementInactive(v); |
|
5920 |
continue; |
|
5921 |
} |
|
5922 |
if (tag == QLatin1String("disabled")) { |
|
5923 |
DomColorGroup *v = new DomColorGroup(); |
|
5924 |
v->read(e); |
|
5925 |
setElementDisabled(v); |
|
5926 |
continue; |
|
5927 |
} |
|
5928 |
} |
|
5929 |
m_text.clear(); |
|
5930 |
for (QDomNode child = node.firstChild(); !child.isNull(); child = child.nextSibling()) { |
|
5931 |
if (child.isText()) |
|
5932 |
m_text.append(child.nodeValue()); |
|
5933 |
} |
|
5934 |
} |
|
5935 |
#endif |
|
5936 |
||
5937 |
void DomPalette::write(QXmlStreamWriter &writer, const QString &tagName) const |
|
5938 |
{ |
|
5939 |
writer.writeStartElement(tagName.isEmpty() ? QString::fromUtf8("palette") : tagName.toLower()); |
|
5940 |
||
5941 |
if (m_children & Active) { |
|
5942 |
m_active->write(writer, QLatin1String("active")); |
|
5943 |
} |
|
5944 |
||
5945 |
if (m_children & Inactive) { |
|
5946 |
m_inactive->write(writer, QLatin1String("inactive")); |
|
5947 |
} |
|
5948 |
||
5949 |
if (m_children & Disabled) { |
|
5950 |
m_disabled->write(writer, QLatin1String("disabled")); |
|
5951 |
} |
|
5952 |
||
5953 |
if (!m_text.isEmpty()) |
|
5954 |
writer.writeCharacters(m_text); |
|
5955 |
||
5956 |
writer.writeEndElement(); |
|
5957 |
} |
|
5958 |
||
5959 |
DomColorGroup* DomPalette::takeElementActive() |
|
5960 |
{ |
|
5961 |
DomColorGroup* a = m_active; |
|
5962 |
m_active = 0; |
|
5963 |
m_children ^= Active; |
|
5964 |
return a; |
|
5965 |
} |
|
5966 |
||
5967 |
void DomPalette::setElementActive(DomColorGroup* a) |
|
5968 |
{ |
|
5969 |
delete m_active; |
|
5970 |
m_children |= Active; |
|
5971 |
m_active = a; |
|
5972 |
} |
|
5973 |
||
5974 |
DomColorGroup* DomPalette::takeElementInactive() |
|
5975 |
{ |
|
5976 |
DomColorGroup* a = m_inactive; |
|
5977 |
m_inactive = 0; |
|
5978 |
m_children ^= Inactive; |
|
5979 |
return a; |
|
5980 |
} |
|
5981 |
||
5982 |
void DomPalette::setElementInactive(DomColorGroup* a) |
|
5983 |
{ |
|
5984 |
delete m_inactive; |
|
5985 |
m_children |= Inactive; |
|
5986 |
m_inactive = a; |
|
5987 |
} |
|
5988 |
||
5989 |
DomColorGroup* DomPalette::takeElementDisabled() |
|
5990 |
{ |
|
5991 |
DomColorGroup* a = m_disabled; |
|
5992 |
m_disabled = 0; |
|
5993 |
m_children ^= Disabled; |
|
5994 |
return a; |
|
5995 |
} |
|
5996 |
||
5997 |
void DomPalette::setElementDisabled(DomColorGroup* a) |
|
5998 |
{ |
|
5999 |
delete m_disabled; |
|
6000 |
m_children |= Disabled; |
|
6001 |
m_disabled = a; |
|
6002 |
} |
|
6003 |
||
6004 |
void DomPalette::clearElementActive() |
|
6005 |
{ |
|
6006 |
delete m_active; |
|
6007 |
m_active = 0; |
|
6008 |
m_children &= ~Active; |
|
6009 |
} |
|
6010 |
||
6011 |
void DomPalette::clearElementInactive() |
|
6012 |
{ |
|
6013 |
delete m_inactive; |
|
6014 |
m_inactive = 0; |
|
6015 |
m_children &= ~Inactive; |
|
6016 |
} |
|
6017 |
||
6018 |
void DomPalette::clearElementDisabled() |
|
6019 |
{ |
|
6020 |
delete m_disabled; |
|
6021 |
m_disabled = 0; |
|
6022 |
m_children &= ~Disabled; |
|
6023 |
} |
|
6024 |
||
6025 |
void DomFont::clear(bool clear_all) |
|
6026 |
{ |
|
6027 |
||
6028 |
if (clear_all) { |
|
6029 |
m_text.clear(); |
|
6030 |
} |
|
6031 |
||
6032 |
m_children = 0; |
|
6033 |
m_pointSize = 0; |
|
6034 |
m_weight = 0; |
|
6035 |
m_italic = false; |
|
6036 |
m_bold = false; |
|
6037 |
m_underline = false; |
|
6038 |
m_strikeOut = false; |
|
6039 |
m_antialiasing = false; |
|
6040 |
m_kerning = false; |
|
6041 |
} |
|
6042 |
||
6043 |
DomFont::DomFont() |
|
6044 |
{ |
|
6045 |
m_children = 0; |
|
6046 |
m_pointSize = 0; |
|
6047 |
m_weight = 0; |
|
6048 |
m_italic = false; |
|
6049 |
m_bold = false; |
|
6050 |
m_underline = false; |
|
6051 |
m_strikeOut = false; |
|
6052 |
m_antialiasing = false; |
|
6053 |
m_kerning = false; |
|
6054 |
} |
|
6055 |
||
6056 |
DomFont::~DomFont() |
|
6057 |
{ |
|
6058 |
} |
|
6059 |
||
6060 |
void DomFont::read(QXmlStreamReader &reader) |
|
6061 |
{ |
|
6062 |
||
6063 |
for (bool finished = false; !finished && !reader.hasError();) { |
|
6064 |
switch (reader.readNext()) { |
|
6065 |
case QXmlStreamReader::StartElement : { |
|
6066 |
const QString tag = reader.name().toString().toLower(); |
|
6067 |
if (tag == QLatin1String("family")) { |
|
6068 |
setElementFamily(reader.readElementText()); |
|
6069 |
continue; |
|
6070 |
} |
|
6071 |
if (tag == QLatin1String("pointsize")) { |
|
6072 |
setElementPointSize(reader.readElementText().toInt()); |
|
6073 |
continue; |
|
6074 |
} |
|
6075 |
if (tag == QLatin1String("weight")) { |
|
6076 |
setElementWeight(reader.readElementText().toInt()); |
|
6077 |
continue; |
|
6078 |
} |
|
6079 |
if (tag == QLatin1String("italic")) { |
|
6080 |
setElementItalic((reader.readElementText() == QLatin1String("true") ? true : false)); |
|
6081 |
continue; |
|
6082 |
} |
|
6083 |
if (tag == QLatin1String("bold")) { |
|
6084 |
setElementBold((reader.readElementText() == QLatin1String("true") ? true : false)); |
|
6085 |
continue; |
|
6086 |
} |
|
6087 |
if (tag == QLatin1String("underline")) { |
|
6088 |
setElementUnderline((reader.readElementText() == QLatin1String("true") ? true : false)); |
|
6089 |
continue; |
|
6090 |
} |
|
6091 |
if (tag == QLatin1String("strikeout")) { |
|
6092 |
setElementStrikeOut((reader.readElementText() == QLatin1String("true") ? true : false)); |
|
6093 |
continue; |
|
6094 |
} |
|
6095 |
if (tag == QLatin1String("antialiasing")) { |
|
6096 |
setElementAntialiasing((reader.readElementText() == QLatin1String("true") ? true : false)); |
|
6097 |
continue; |
|
6098 |
} |
|
6099 |
if (tag == QLatin1String("stylestrategy")) { |
|
6100 |
setElementStyleStrategy(reader.readElementText()); |
|
6101 |
continue; |
|
6102 |
} |
|
6103 |
if (tag == QLatin1String("kerning")) { |
|
6104 |
setElementKerning((reader.readElementText() == QLatin1String("true") ? true : false)); |
|
6105 |
continue; |
|
6106 |
} |
|
6107 |
reader.raiseError(QLatin1String("Unexpected element ") + tag); |
|
6108 |
} |
|
6109 |
break; |
|
6110 |
case QXmlStreamReader::EndElement : |
|
6111 |
finished = true; |
|
6112 |
break; |
|
6113 |
case QXmlStreamReader::Characters : |
|
6114 |
if (!reader.isWhitespace()) |
|
6115 |
m_text.append(reader.text().toString()); |
|
6116 |
break; |
|
6117 |
default : |
|
6118 |
break; |
|
6119 |
} |
|
6120 |
} |
|
6121 |
} |
|
6122 |
||
6123 |
#ifdef QUILOADER_QDOM_READ |
|
6124 |
void DomFont::read(const QDomElement &node) |
|
6125 |
{ |
|
6126 |
for (QDomNode n = node.firstChild(); !n.isNull(); n = n.nextSibling()) { |
|
6127 |
if (!n.isElement()) |
|
6128 |
continue; |
|
6129 |
QDomElement e = n.toElement(); |
|
6130 |
QString tag = e.tagName().toLower(); |
|
6131 |
if (tag == QLatin1String("family")) { |
|
6132 |
setElementFamily(e.text()); |
|
6133 |
continue; |
|
6134 |
} |
|
6135 |
if (tag == QLatin1String("pointsize")) { |
|
6136 |
setElementPointSize(e.text().toInt()); |
|
6137 |
continue; |
|
6138 |
} |
|
6139 |
if (tag == QLatin1String("weight")) { |
|
6140 |
setElementWeight(e.text().toInt()); |
|
6141 |
continue; |
|
6142 |
} |
|
6143 |
if (tag == QLatin1String("italic")) { |
|
6144 |
setElementItalic((e.text() == QLatin1String("true") ? true : false)); |
|
6145 |
continue; |
|
6146 |
} |
|
6147 |
if (tag == QLatin1String("bold")) { |
|
6148 |
setElementBold((e.text() == QLatin1String("true") ? true : false)); |
|
6149 |
continue; |
|
6150 |
} |
|
6151 |
if (tag == QLatin1String("underline")) { |
|
6152 |
setElementUnderline((e.text() == QLatin1String("true") ? true : false)); |
|
6153 |
continue; |
|
6154 |
} |
|
6155 |
if (tag == QLatin1String("strikeout")) { |
|
6156 |
setElementStrikeOut((e.text() == QLatin1String("true") ? true : false)); |
|
6157 |
continue; |
|
6158 |
} |
|
6159 |
if (tag == QLatin1String("antialiasing")) { |
|
6160 |
setElementAntialiasing((e.text() == QLatin1String("true") ? true : false)); |
|
6161 |
continue; |
|
6162 |
} |
|
6163 |
if (tag == QLatin1String("stylestrategy")) { |
|
6164 |
setElementStyleStrategy(e.text()); |
|
6165 |
continue; |
|
6166 |
} |
|
6167 |
if (tag == QLatin1String("kerning")) { |
|
6168 |
setElementKerning((e.text() == QLatin1String("true") ? true : false)); |
|
6169 |
continue; |
|
6170 |
} |
|
6171 |
} |
|
6172 |
m_text.clear(); |
|
6173 |
for (QDomNode child = node.firstChild(); !child.isNull(); child = child.nextSibling()) { |
|
6174 |
if (child.isText()) |
|
6175 |
m_text.append(child.nodeValue()); |
|
6176 |
} |
|
6177 |
} |
|
6178 |
#endif |
|
6179 |
||
6180 |
void DomFont::write(QXmlStreamWriter &writer, const QString &tagName) const |
|
6181 |
{ |
|
6182 |
writer.writeStartElement(tagName.isEmpty() ? QString::fromUtf8("font") : tagName.toLower()); |
|
6183 |
||
6184 |
if (m_children & Family) { |
|
6185 |
writer.writeTextElement(QLatin1String("family"), m_family); |
|
6186 |
} |
|
6187 |
||
6188 |
if (m_children & PointSize) { |
|
6189 |
writer.writeTextElement(QLatin1String("pointsize"), QString::number(m_pointSize)); |
|
6190 |
} |
|
6191 |
||
6192 |
if (m_children & Weight) { |
|
6193 |
writer.writeTextElement(QLatin1String("weight"), QString::number(m_weight)); |
|
6194 |
} |
|
6195 |
||
6196 |
if (m_children & Italic) { |
|
6197 |
writer.writeTextElement(QLatin1String("italic"), (m_italic ? QLatin1String("true") : QLatin1String("false"))); |
|
6198 |
} |
|
6199 |
||
6200 |
if (m_children & Bold) { |
|
6201 |
writer.writeTextElement(QLatin1String("bold"), (m_bold ? QLatin1String("true") : QLatin1String("false"))); |
|
6202 |
} |
|
6203 |
||
6204 |
if (m_children & Underline) { |
|
6205 |
writer.writeTextElement(QLatin1String("underline"), (m_underline ? QLatin1String("true") : QLatin1String("false"))); |
|
6206 |
} |
|
6207 |
||
6208 |
if (m_children & StrikeOut) { |
|
6209 |
writer.writeTextElement(QLatin1String("strikeout"), (m_strikeOut ? QLatin1String("true") : QLatin1String("false"))); |
|
6210 |
} |
|
6211 |
||
6212 |
if (m_children & Antialiasing) { |
|
6213 |
writer.writeTextElement(QLatin1String("antialiasing"), (m_antialiasing ? QLatin1String("true") : QLatin1String("false"))); |
|
6214 |
} |
|
6215 |
||
6216 |
if (m_children & StyleStrategy) { |
|
6217 |
writer.writeTextElement(QLatin1String("stylestrategy"), m_styleStrategy); |
|
6218 |
} |
|
6219 |
||
6220 |
if (m_children & Kerning) { |
|
6221 |
writer.writeTextElement(QLatin1String("kerning"), (m_kerning ? QLatin1String("true") : QLatin1String("false"))); |
|
6222 |
} |
|
6223 |
||
6224 |
if (!m_text.isEmpty()) |
|
6225 |
writer.writeCharacters(m_text); |
|
6226 |
||
6227 |
writer.writeEndElement(); |
|
6228 |
} |
|
6229 |
||
6230 |
void DomFont::setElementFamily(const QString& a) |
|
6231 |
{ |
|
6232 |
m_children |= Family; |
|
6233 |
m_family = a; |
|
6234 |
} |
|
6235 |
||
6236 |
void DomFont::setElementPointSize(int a) |
|
6237 |
{ |
|
6238 |
m_children |= PointSize; |
|
6239 |
m_pointSize = a; |
|
6240 |
} |
|
6241 |
||
6242 |
void DomFont::setElementWeight(int a) |
|
6243 |
{ |
|
6244 |
m_children |= Weight; |
|
6245 |
m_weight = a; |
|
6246 |
} |
|
6247 |
||
6248 |
void DomFont::setElementItalic(bool a) |
|
6249 |
{ |
|
6250 |
m_children |= Italic; |
|
6251 |
m_italic = a; |
|
6252 |
} |
|
6253 |
||
6254 |
void DomFont::setElementBold(bool a) |
|
6255 |
{ |
|
6256 |
m_children |= Bold; |
|
6257 |
m_bold = a; |
|
6258 |
} |
|
6259 |
||
6260 |
void DomFont::setElementUnderline(bool a) |
|
6261 |
{ |
|
6262 |
m_children |= Underline; |
|
6263 |
m_underline = a; |
|
6264 |
} |
|
6265 |
||
6266 |
void DomFont::setElementStrikeOut(bool a) |
|
6267 |
{ |
|
6268 |
m_children |= StrikeOut; |
|
6269 |
m_strikeOut = a; |
|
6270 |
} |
|
6271 |
||
6272 |
void DomFont::setElementAntialiasing(bool a) |
|
6273 |
{ |
|
6274 |
m_children |= Antialiasing; |
|
6275 |
m_antialiasing = a; |
|
6276 |
} |
|
6277 |
||
6278 |
void DomFont::setElementStyleStrategy(const QString& a) |
|
6279 |
{ |
|
6280 |
m_children |= StyleStrategy; |
|
6281 |
m_styleStrategy = a; |
|
6282 |
} |
|
6283 |
||
6284 |
void DomFont::setElementKerning(bool a) |
|
6285 |
{ |
|
6286 |
m_children |= Kerning; |
|
6287 |
m_kerning = a; |
|
6288 |
} |
|
6289 |
||
6290 |
void DomFont::clearElementFamily() |
|
6291 |
{ |
|
6292 |
m_children &= ~Family; |
|
6293 |
} |
|
6294 |
||
6295 |
void DomFont::clearElementPointSize() |
|
6296 |
{ |
|
6297 |
m_children &= ~PointSize; |
|
6298 |
} |
|
6299 |
||
6300 |
void DomFont::clearElementWeight() |
|
6301 |
{ |
|
6302 |
m_children &= ~Weight; |
|
6303 |
} |
|
6304 |
||
6305 |
void DomFont::clearElementItalic() |
|
6306 |
{ |
|
6307 |
m_children &= ~Italic; |
|
6308 |
} |
|
6309 |
||
6310 |
void DomFont::clearElementBold() |
|
6311 |
{ |
|
6312 |
m_children &= ~Bold; |
|
6313 |
} |
|
6314 |
||
6315 |
void DomFont::clearElementUnderline() |
|
6316 |
{ |
|
6317 |
m_children &= ~Underline; |
|
6318 |
} |
|
6319 |
||
6320 |
void DomFont::clearElementStrikeOut() |
|
6321 |
{ |
|
6322 |
m_children &= ~StrikeOut; |
|
6323 |
} |
|
6324 |
||
6325 |
void DomFont::clearElementAntialiasing() |
|
6326 |
{ |
|
6327 |
m_children &= ~Antialiasing; |
|
6328 |
} |
|
6329 |
||
6330 |
void DomFont::clearElementStyleStrategy() |
|
6331 |
{ |
|
6332 |
m_children &= ~StyleStrategy; |
|
6333 |
} |
|
6334 |
||
6335 |
void DomFont::clearElementKerning() |
|
6336 |
{ |
|
6337 |
m_children &= ~Kerning; |
|
6338 |
} |
|
6339 |
||
6340 |
void DomPoint::clear(bool clear_all) |
|
6341 |
{ |
|
6342 |
||
6343 |
if (clear_all) { |
|
6344 |
m_text.clear(); |
|
6345 |
} |
|
6346 |
||
6347 |
m_children = 0; |
|
6348 |
m_x = 0; |
|
6349 |
m_y = 0; |
|
6350 |
} |
|
6351 |
||
6352 |
DomPoint::DomPoint() |
|
6353 |
{ |
|
6354 |
m_children = 0; |
|
6355 |
m_x = 0; |
|
6356 |
m_y = 0; |
|
6357 |
} |
|
6358 |
||
6359 |
DomPoint::~DomPoint() |
|
6360 |
{ |
|
6361 |
} |
|
6362 |
||
6363 |
void DomPoint::read(QXmlStreamReader &reader) |
|
6364 |
{ |
|
6365 |
||
6366 |
for (bool finished = false; !finished && !reader.hasError();) { |
|
6367 |
switch (reader.readNext()) { |
|
6368 |
case QXmlStreamReader::StartElement : { |
|
6369 |
const QString tag = reader.name().toString().toLower(); |
|
6370 |
if (tag == QString(QLatin1Char('x'))) { |
|
6371 |
setElementX(reader.readElementText().toInt()); |
|
6372 |
continue; |
|
6373 |
} |
|
6374 |
if (tag == QString(QLatin1Char('y'))) { |
|
6375 |
setElementY(reader.readElementText().toInt()); |
|
6376 |
continue; |
|
6377 |
} |
|
6378 |
reader.raiseError(QLatin1String("Unexpected element ") + tag); |
|
6379 |
} |
|
6380 |
break; |
|
6381 |
case QXmlStreamReader::EndElement : |
|
6382 |
finished = true; |
|
6383 |
break; |
|
6384 |
case QXmlStreamReader::Characters : |
|
6385 |
if (!reader.isWhitespace()) |
|
6386 |
m_text.append(reader.text().toString()); |
|
6387 |
break; |
|
6388 |
default : |
|
6389 |
break; |
|
6390 |
} |
|
6391 |
} |
|
6392 |
} |
|
6393 |
||
6394 |
#ifdef QUILOADER_QDOM_READ |
|
6395 |
void DomPoint::read(const QDomElement &node) |
|
6396 |
{ |
|
6397 |
for (QDomNode n = node.firstChild(); !n.isNull(); n = n.nextSibling()) { |
|
6398 |
if (!n.isElement()) |
|
6399 |
continue; |
|
6400 |
QDomElement e = n.toElement(); |
|
6401 |
QString tag = e.tagName().toLower(); |
|
6402 |
if (tag == QString(QLatin1Char('x'))) { |
|
6403 |
setElementX(e.text().toInt()); |
|
6404 |
continue; |
|
6405 |
} |
|
6406 |
if (tag == QString(QLatin1Char('y'))) { |
|
6407 |
setElementY(e.text().toInt()); |
|
6408 |
continue; |
|
6409 |
} |
|
6410 |
} |
|
6411 |
m_text.clear(); |
|
6412 |
for (QDomNode child = node.firstChild(); !child.isNull(); child = child.nextSibling()) { |
|
6413 |
if (child.isText()) |
|
6414 |
m_text.append(child.nodeValue()); |
|
6415 |
} |
|
6416 |
} |
|
6417 |
#endif |
|
6418 |
||
6419 |
void DomPoint::write(QXmlStreamWriter &writer, const QString &tagName) const |
|
6420 |
{ |
|
6421 |
writer.writeStartElement(tagName.isEmpty() ? QString::fromUtf8("point") : tagName.toLower()); |
|
6422 |
||
6423 |
if (m_children & X) { |
|
6424 |
writer.writeTextElement(QString(QLatin1Char('x')), QString::number(m_x)); |
|
6425 |
} |
|
6426 |
||
6427 |
if (m_children & Y) { |
|
6428 |
writer.writeTextElement(QString(QLatin1Char('y')), QString::number(m_y)); |
|
6429 |
} |
|
6430 |
||
6431 |
if (!m_text.isEmpty()) |
|
6432 |
writer.writeCharacters(m_text); |
|
6433 |
||
6434 |
writer.writeEndElement(); |
|
6435 |
} |
|
6436 |
||
6437 |
void DomPoint::setElementX(int a) |
|
6438 |
{ |
|
6439 |
m_children |= X; |
|
6440 |
m_x = a; |
|
6441 |
} |
|
6442 |
||
6443 |
void DomPoint::setElementY(int a) |
|
6444 |
{ |
|
6445 |
m_children |= Y; |
|
6446 |
m_y = a; |
|
6447 |
} |
|
6448 |
||
6449 |
void DomPoint::clearElementX() |
|
6450 |
{ |
|
6451 |
m_children &= ~X; |
|
6452 |
} |
|
6453 |
||
6454 |
void DomPoint::clearElementY() |
|
6455 |
{ |
|
6456 |
m_children &= ~Y; |
|
6457 |
} |
|
6458 |
||
6459 |
void DomRect::clear(bool clear_all) |
|
6460 |
{ |
|
6461 |
||
6462 |
if (clear_all) { |
|
6463 |
m_text.clear(); |
|
6464 |
} |
|
6465 |
||
6466 |
m_children = 0; |
|
6467 |
m_x = 0; |
|
6468 |
m_y = 0; |
|
6469 |
m_width = 0; |
|
6470 |
m_height = 0; |
|
6471 |
} |
|
6472 |
||
6473 |
DomRect::DomRect() |
|
6474 |
{ |
|
6475 |
m_children = 0; |
|
6476 |
m_x = 0; |
|
6477 |
m_y = 0; |
|
6478 |
m_width = 0; |
|
6479 |
m_height = 0; |
|
6480 |
} |
|
6481 |
||
6482 |
DomRect::~DomRect() |
|
6483 |
{ |
|
6484 |
} |
|
6485 |
||
6486 |
void DomRect::read(QXmlStreamReader &reader) |
|
6487 |
{ |
|
6488 |
||
6489 |
for (bool finished = false; !finished && !reader.hasError();) { |
|
6490 |
switch (reader.readNext()) { |
|
6491 |
case QXmlStreamReader::StartElement : { |
|
6492 |
const QString tag = reader.name().toString().toLower(); |
|
6493 |
if (tag == QString(QLatin1Char('x'))) { |
|
6494 |
setElementX(reader.readElementText().toInt()); |
|
6495 |
continue; |
|
6496 |
} |
|
6497 |
if (tag == QString(QLatin1Char('y'))) { |
|
6498 |
setElementY(reader.readElementText().toInt()); |
|
6499 |
continue; |
|
6500 |
} |
|
6501 |
if (tag == QLatin1String("width")) { |
|
6502 |
setElementWidth(reader.readElementText().toInt()); |
|
6503 |
continue; |
|
6504 |
} |
|
6505 |
if (tag == QLatin1String("height")) { |
|
6506 |
setElementHeight(reader.readElementText().toInt()); |
|
6507 |
continue; |
|
6508 |
} |
|
6509 |
reader.raiseError(QLatin1String("Unexpected element ") + tag); |
|
6510 |
} |
|
6511 |
break; |
|
6512 |
case QXmlStreamReader::EndElement : |
|
6513 |
finished = true; |
|
6514 |
break; |
|
6515 |
case QXmlStreamReader::Characters : |
|
6516 |
if (!reader.isWhitespace()) |
|
6517 |
m_text.append(reader.text().toString()); |
|
6518 |
break; |
|
6519 |
default : |
|
6520 |
break; |
|
6521 |
} |
|
6522 |
} |
|
6523 |
} |
|
6524 |
||
6525 |
#ifdef QUILOADER_QDOM_READ |
|
6526 |
void DomRect::read(const QDomElement &node) |
|
6527 |
{ |
|
6528 |
for (QDomNode n = node.firstChild(); !n.isNull(); n = n.nextSibling()) { |
|
6529 |
if (!n.isElement()) |
|
6530 |
continue; |
|
6531 |
QDomElement e = n.toElement(); |
|
6532 |
QString tag = e.tagName().toLower(); |
|
6533 |
if (tag == QString(QLatin1Char('x'))) { |
|
6534 |
setElementX(e.text().toInt()); |
|
6535 |
continue; |
|
6536 |
} |
|
6537 |
if (tag == QString(QLatin1Char('y'))) { |
|
6538 |
setElementY(e.text().toInt()); |
|
6539 |
continue; |
|
6540 |
} |
|
6541 |
if (tag == QLatin1String("width")) { |
|
6542 |
setElementWidth(e.text().toInt()); |
|
6543 |
continue; |
|
6544 |
} |
|
6545 |
if (tag == QLatin1String("height")) { |
|
6546 |
setElementHeight(e.text().toInt()); |
|
6547 |
continue; |
|
6548 |
} |
|
6549 |
} |
|
6550 |
m_text.clear(); |
|
6551 |
for (QDomNode child = node.firstChild(); !child.isNull(); child = child.nextSibling()) { |
|
6552 |
if (child.isText()) |
|
6553 |
m_text.append(child.nodeValue()); |
|
6554 |
} |
|
6555 |
} |
|
6556 |
#endif |
|
6557 |
||
6558 |
void DomRect::write(QXmlStreamWriter &writer, const QString &tagName) const |
|
6559 |
{ |
|
6560 |
writer.writeStartElement(tagName.isEmpty() ? QString::fromUtf8("rect") : tagName.toLower()); |
|
6561 |
||
6562 |
if (m_children & X) { |
|
6563 |
writer.writeTextElement(QString(QLatin1Char('x')), QString::number(m_x)); |
|
6564 |
} |
|
6565 |
||
6566 |
if (m_children & Y) { |
|
6567 |
writer.writeTextElement(QString(QLatin1Char('y')), QString::number(m_y)); |
|
6568 |
} |
|
6569 |
||
6570 |
if (m_children & Width) { |
|
6571 |
writer.writeTextElement(QLatin1String("width"), QString::number(m_width)); |
|
6572 |
} |
|
6573 |
||
6574 |
if (m_children & Height) { |
|
6575 |
writer.writeTextElement(QLatin1String("height"), QString::number(m_height)); |
|
6576 |
} |
|
6577 |
||
6578 |
if (!m_text.isEmpty()) |
|
6579 |
writer.writeCharacters(m_text); |
|
6580 |
||
6581 |
writer.writeEndElement(); |
|
6582 |
} |
|
6583 |
||
6584 |
void DomRect::setElementX(int a) |
|
6585 |
{ |
|
6586 |
m_children |= X; |
|
6587 |
m_x = a; |
|
6588 |
} |
|
6589 |
||
6590 |
void DomRect::setElementY(int a) |
|
6591 |
{ |
|
6592 |
m_children |= Y; |
|
6593 |
m_y = a; |
|
6594 |
} |
|
6595 |
||
6596 |
void DomRect::setElementWidth(int a) |
|
6597 |
{ |
|
6598 |
m_children |= Width; |
|
6599 |
m_width = a; |
|
6600 |
} |
|
6601 |
||
6602 |
void DomRect::setElementHeight(int a) |
|
6603 |
{ |
|
6604 |
m_children |= Height; |
|
6605 |
m_height = a; |
|
6606 |
} |
|
6607 |
||
6608 |
void DomRect::clearElementX() |
|
6609 |
{ |
|
6610 |
m_children &= ~X; |
|
6611 |
} |
|
6612 |
||
6613 |
void DomRect::clearElementY() |
|
6614 |
{ |
|
6615 |
m_children &= ~Y; |
|
6616 |
} |
|
6617 |
||
6618 |
void DomRect::clearElementWidth() |
|
6619 |
{ |
|
6620 |
m_children &= ~Width; |
|
6621 |
} |
|
6622 |
||
6623 |
void DomRect::clearElementHeight() |
|
6624 |
{ |
|
6625 |
m_children &= ~Height; |
|
6626 |
} |
|
6627 |
||
6628 |
void DomLocale::clear(bool clear_all) |
|
6629 |
{ |
|
6630 |
||
6631 |
if (clear_all) { |
|
6632 |
m_text.clear(); |
|
6633 |
m_has_attr_language = false; |
|
6634 |
m_has_attr_country = false; |
|
6635 |
} |
|
6636 |
||
6637 |
m_children = 0; |
|
6638 |
} |
|
6639 |
||
6640 |
DomLocale::DomLocale() |
|
6641 |
{ |
|
6642 |
m_children = 0; |
|
6643 |
m_has_attr_language = false; |
|
6644 |
m_has_attr_country = false; |
|
6645 |
} |
|
6646 |
||
6647 |
DomLocale::~DomLocale() |
|
6648 |
{ |
|
6649 |
} |
|
6650 |
||
6651 |
void DomLocale::read(QXmlStreamReader &reader) |
|
6652 |
{ |
|
6653 |
||
6654 |
foreach (const QXmlStreamAttribute &attribute, reader.attributes()) { |
|
6655 |
QStringRef name = attribute.name(); |
|
6656 |
if (name == QLatin1String("language")) { |
|
6657 |
setAttributeLanguage(attribute.value().toString()); |
|
6658 |
continue; |
|
6659 |
} |
|
6660 |
if (name == QLatin1String("country")) { |
|
6661 |
setAttributeCountry(attribute.value().toString()); |
|
6662 |
continue; |
|
6663 |
} |
|
6664 |
reader.raiseError(QLatin1String("Unexpected attribute ") + name.toString()); |
|
6665 |
} |
|
6666 |
||
6667 |
for (bool finished = false; !finished && !reader.hasError();) { |
|
6668 |
switch (reader.readNext()) { |
|
6669 |
case QXmlStreamReader::StartElement : { |
|
6670 |
const QString tag = reader.name().toString().toLower(); |
|
6671 |
reader.raiseError(QLatin1String("Unexpected element ") + tag); |
|
6672 |
} |
|
6673 |
break; |
|
6674 |
case QXmlStreamReader::EndElement : |
|
6675 |
finished = true; |
|
6676 |
break; |
|
6677 |
case QXmlStreamReader::Characters : |
|
6678 |
if (!reader.isWhitespace()) |
|
6679 |
m_text.append(reader.text().toString()); |
|
6680 |
break; |
|
6681 |
default : |
|
6682 |
break; |
|
6683 |
} |
|
6684 |
} |
|
6685 |
} |
|
6686 |
||
6687 |
#ifdef QUILOADER_QDOM_READ |
|
6688 |
void DomLocale::read(const QDomElement &node) |
|
6689 |
{ |
|
6690 |
if (node.hasAttribute(QLatin1String("language"))) |
|
6691 |
setAttributeLanguage(node.attribute(QLatin1String("language"))); |
|
6692 |
if (node.hasAttribute(QLatin1String("country"))) |
|
6693 |
setAttributeCountry(node.attribute(QLatin1String("country"))); |
|
6694 |
||
6695 |
for (QDomNode n = node.firstChild(); !n.isNull(); n = n.nextSibling()) { |
|
6696 |
if (!n.isElement()) |
|
6697 |
continue; |
|
6698 |
QDomElement e = n.toElement(); |
|
6699 |
QString tag = e.tagName().toLower(); |
|
6700 |
} |
|
6701 |
m_text.clear(); |
|
6702 |
for (QDomNode child = node.firstChild(); !child.isNull(); child = child.nextSibling()) { |
|
6703 |
if (child.isText()) |
|
6704 |
m_text.append(child.nodeValue()); |
|
6705 |
} |
|
6706 |
} |
|
6707 |
#endif |
|
6708 |
||
6709 |
void DomLocale::write(QXmlStreamWriter &writer, const QString &tagName) const |
|
6710 |
{ |
|
6711 |
writer.writeStartElement(tagName.isEmpty() ? QString::fromUtf8("locale") : tagName.toLower()); |
|
6712 |
||
6713 |
if (hasAttributeLanguage()) |
|
6714 |
writer.writeAttribute(QLatin1String("language"), attributeLanguage()); |
|
6715 |
||
6716 |
if (hasAttributeCountry()) |
|
6717 |
writer.writeAttribute(QLatin1String("country"), attributeCountry()); |
|
6718 |
||
6719 |
if (!m_text.isEmpty()) |
|
6720 |
writer.writeCharacters(m_text); |
|
6721 |
||
6722 |
writer.writeEndElement(); |
|
6723 |
} |
|
6724 |
||
6725 |
void DomSizePolicy::clear(bool clear_all) |
|
6726 |
{ |
|
6727 |
||
6728 |
if (clear_all) { |
|
6729 |
m_text.clear(); |
|
6730 |
m_has_attr_hSizeType = false; |
|
6731 |
m_has_attr_vSizeType = false; |
|
6732 |
} |
|
6733 |
||
6734 |
m_children = 0; |
|
6735 |
m_hSizeType = 0; |
|
6736 |
m_vSizeType = 0; |
|
6737 |
m_horStretch = 0; |
|
6738 |
m_verStretch = 0; |
|
6739 |
} |
|
6740 |
||
6741 |
DomSizePolicy::DomSizePolicy() |
|
6742 |
{ |
|
6743 |
m_children = 0; |
|
6744 |
m_has_attr_hSizeType = false; |
|
6745 |
m_has_attr_vSizeType = false; |
|
6746 |
m_hSizeType = 0; |
|
6747 |
m_vSizeType = 0; |
|
6748 |
m_horStretch = 0; |
|
6749 |
m_verStretch = 0; |
|
6750 |
} |
|
6751 |
||
6752 |
DomSizePolicy::~DomSizePolicy() |
|
6753 |
{ |
|
6754 |
} |
|
6755 |
||
6756 |
void DomSizePolicy::read(QXmlStreamReader &reader) |
|
6757 |
{ |
|
6758 |
||
6759 |
foreach (const QXmlStreamAttribute &attribute, reader.attributes()) { |
|
6760 |
QStringRef name = attribute.name(); |
|
6761 |
if (name == QLatin1String("hsizetype")) { |
|
6762 |
setAttributeHSizeType(attribute.value().toString()); |
|
6763 |
continue; |
|
6764 |
} |
|
6765 |
if (name == QLatin1String("vsizetype")) { |
|
6766 |
setAttributeVSizeType(attribute.value().toString()); |
|
6767 |
continue; |
|
6768 |
} |
|
6769 |
reader.raiseError(QLatin1String("Unexpected attribute ") + name.toString()); |
|
6770 |
} |
|
6771 |
||
6772 |
for (bool finished = false; !finished && !reader.hasError();) { |
|
6773 |
switch (reader.readNext()) { |
|
6774 |
case QXmlStreamReader::StartElement : { |
|
6775 |
const QString tag = reader.name().toString().toLower(); |
|
6776 |
if (tag == QLatin1String("hsizetype")) { |
|
6777 |
setElementHSizeType(reader.readElementText().toInt()); |
|
6778 |
continue; |
|
6779 |
} |
|
6780 |
if (tag == QLatin1String("vsizetype")) { |
|
6781 |
setElementVSizeType(reader.readElementText().toInt()); |
|
6782 |
continue; |
|
6783 |
} |
|
6784 |
if (tag == QLatin1String("horstretch")) { |
|
6785 |
setElementHorStretch(reader.readElementText().toInt()); |
|
6786 |
continue; |
|
6787 |
} |
|
6788 |
if (tag == QLatin1String("verstretch")) { |
|
6789 |
setElementVerStretch(reader.readElementText().toInt()); |
|
6790 |
continue; |
|
6791 |
} |
|
6792 |
reader.raiseError(QLatin1String("Unexpected element ") + tag); |
|
6793 |
} |
|
6794 |
break; |
|
6795 |
case QXmlStreamReader::EndElement : |
|
6796 |
finished = true; |
|
6797 |
break; |
|
6798 |
case QXmlStreamReader::Characters : |
|
6799 |
if (!reader.isWhitespace()) |
|
6800 |
m_text.append(reader.text().toString()); |
|
6801 |
break; |
|
6802 |
default : |
|
6803 |
break; |
|
6804 |
} |
|
6805 |
} |
|
6806 |
} |
|
6807 |
||
6808 |
#ifdef QUILOADER_QDOM_READ |
|
6809 |
void DomSizePolicy::read(const QDomElement &node) |
|
6810 |
{ |
|
6811 |
if (node.hasAttribute(QLatin1String("hsizetype"))) |
|
6812 |
setAttributeHSizeType(node.attribute(QLatin1String("hsizetype"))); |
|
6813 |
if (node.hasAttribute(QLatin1String("vsizetype"))) |
|
6814 |
setAttributeVSizeType(node.attribute(QLatin1String("vsizetype"))); |
|
6815 |
||
6816 |
for (QDomNode n = node.firstChild(); !n.isNull(); n = n.nextSibling()) { |
|
6817 |
if (!n.isElement()) |
|
6818 |
continue; |
|
6819 |
QDomElement e = n.toElement(); |
|
6820 |
QString tag = e.tagName().toLower(); |
|
6821 |
if (tag == QLatin1String("hsizetype")) { |
|
6822 |
setElementHSizeType(e.text().toInt()); |
|
6823 |
continue; |
|
6824 |
} |
|
6825 |
if (tag == QLatin1String("vsizetype")) { |
|
6826 |
setElementVSizeType(e.text().toInt()); |
|
6827 |
continue; |
|
6828 |
} |
|
6829 |
if (tag == QLatin1String("horstretch")) { |
|
6830 |
setElementHorStretch(e.text().toInt()); |
|
6831 |
continue; |
|
6832 |
} |
|
6833 |
if (tag == QLatin1String("verstretch")) { |
|
6834 |
setElementVerStretch(e.text().toInt()); |
|
6835 |
continue; |
|
6836 |
} |
|
6837 |
} |
|
6838 |
m_text.clear(); |
|
6839 |
for (QDomNode child = node.firstChild(); !child.isNull(); child = child.nextSibling()) { |
|
6840 |
if (child.isText()) |
|
6841 |
m_text.append(child.nodeValue()); |
|
6842 |
} |
|
6843 |
} |
|
6844 |
#endif |
|
6845 |
||
6846 |
void DomSizePolicy::write(QXmlStreamWriter &writer, const QString &tagName) const |
|
6847 |
{ |
|
6848 |
writer.writeStartElement(tagName.isEmpty() ? QString::fromUtf8("sizepolicy") : tagName.toLower()); |
|
6849 |
||
6850 |
if (hasAttributeHSizeType()) |
|
6851 |
writer.writeAttribute(QLatin1String("hsizetype"), attributeHSizeType()); |
|
6852 |
||
6853 |
if (hasAttributeVSizeType()) |
|
6854 |
writer.writeAttribute(QLatin1String("vsizetype"), attributeVSizeType()); |
|
6855 |
||
6856 |
if (m_children & HSizeType) { |
|
6857 |
writer.writeTextElement(QLatin1String("hsizetype"), QString::number(m_hSizeType)); |
|
6858 |
} |
|
6859 |
||
6860 |
if (m_children & VSizeType) { |
|
6861 |
writer.writeTextElement(QLatin1String("vsizetype"), QString::number(m_vSizeType)); |
|
6862 |
} |
|
6863 |
||
6864 |
if (m_children & HorStretch) { |
|
6865 |
writer.writeTextElement(QLatin1String("horstretch"), QString::number(m_horStretch)); |
|
6866 |
} |
|
6867 |
||
6868 |
if (m_children & VerStretch) { |
|
6869 |
writer.writeTextElement(QLatin1String("verstretch"), QString::number(m_verStretch)); |
|
6870 |
} |
|
6871 |
||
6872 |
if (!m_text.isEmpty()) |
|
6873 |
writer.writeCharacters(m_text); |
|
6874 |
||
6875 |
writer.writeEndElement(); |
|
6876 |
} |
|
6877 |
||
6878 |
void DomSizePolicy::setElementHSizeType(int a) |
|
6879 |
{ |
|
6880 |
m_children |= HSizeType; |
|
6881 |
m_hSizeType = a; |
|
6882 |
} |
|
6883 |
||
6884 |
void DomSizePolicy::setElementVSizeType(int a) |
|
6885 |
{ |
|
6886 |
m_children |= VSizeType; |
|
6887 |
m_vSizeType = a; |
|
6888 |
} |
|
6889 |
||
6890 |
void DomSizePolicy::setElementHorStretch(int a) |
|
6891 |
{ |
|
6892 |
m_children |= HorStretch; |
|
6893 |
m_horStretch = a; |
|
6894 |
} |
|
6895 |
||
6896 |
void DomSizePolicy::setElementVerStretch(int a) |
|
6897 |
{ |
|
6898 |
m_children |= VerStretch; |
|
6899 |
m_verStretch = a; |
|
6900 |
} |
|
6901 |
||
6902 |
void DomSizePolicy::clearElementHSizeType() |
|
6903 |
{ |
|
6904 |
m_children &= ~HSizeType; |
|
6905 |
} |
|
6906 |
||
6907 |
void DomSizePolicy::clearElementVSizeType() |
|
6908 |
{ |
|
6909 |
m_children &= ~VSizeType; |
|
6910 |
} |
|
6911 |
||
6912 |
void DomSizePolicy::clearElementHorStretch() |
|
6913 |
{ |
|
6914 |
m_children &= ~HorStretch; |
|
6915 |
} |
|
6916 |
||
6917 |
void DomSizePolicy::clearElementVerStretch() |
|
6918 |
{ |
|
6919 |
m_children &= ~VerStretch; |
|
6920 |
} |
|
6921 |
||
6922 |
void DomSize::clear(bool clear_all) |
|
6923 |
{ |
|
6924 |
||
6925 |
if (clear_all) { |
|
6926 |
m_text.clear(); |
|
6927 |
} |
|
6928 |
||
6929 |
m_children = 0; |
|
6930 |
m_width = 0; |
|
6931 |
m_height = 0; |
|
6932 |
} |
|
6933 |
||
6934 |
DomSize::DomSize() |
|
6935 |
{ |
|
6936 |
m_children = 0; |
|
6937 |
m_width = 0; |
|
6938 |
m_height = 0; |
|
6939 |
} |
|
6940 |
||
6941 |
DomSize::~DomSize() |
|
6942 |
{ |
|
6943 |
} |
|
6944 |
||
6945 |
void DomSize::read(QXmlStreamReader &reader) |
|
6946 |
{ |
|
6947 |
||
6948 |
for (bool finished = false; !finished && !reader.hasError();) { |
|
6949 |
switch (reader.readNext()) { |
|
6950 |
case QXmlStreamReader::StartElement : { |
|
6951 |
const QString tag = reader.name().toString().toLower(); |
|
6952 |
if (tag == QLatin1String("width")) { |
|
6953 |
setElementWidth(reader.readElementText().toInt()); |
|
6954 |
continue; |
|
6955 |
} |
|
6956 |
if (tag == QLatin1String("height")) { |
|
6957 |
setElementHeight(reader.readElementText().toInt()); |
|
6958 |
continue; |
|
6959 |
} |
|
6960 |
reader.raiseError(QLatin1String("Unexpected element ") + tag); |
|
6961 |
} |
|
6962 |
break; |
|
6963 |
case QXmlStreamReader::EndElement : |
|
6964 |
finished = true; |
|
6965 |
break; |
|
6966 |
case QXmlStreamReader::Characters : |
|
6967 |
if (!reader.isWhitespace()) |
|
6968 |
m_text.append(reader.text().toString()); |
|
6969 |
break; |
|
6970 |
default : |
|
6971 |
break; |
|
6972 |
} |
|
6973 |
} |
|
6974 |
} |
|
6975 |
||
6976 |
#ifdef QUILOADER_QDOM_READ |
|
6977 |
void DomSize::read(const QDomElement &node) |
|
6978 |
{ |
|
6979 |
for (QDomNode n = node.firstChild(); !n.isNull(); n = n.nextSibling()) { |
|
6980 |
if (!n.isElement()) |
|
6981 |
continue; |
|
6982 |
QDomElement e = n.toElement(); |
|
6983 |
QString tag = e.tagName().toLower(); |
|
6984 |
if (tag == QLatin1String("width")) { |
|
6985 |
setElementWidth(e.text().toInt()); |
|
6986 |
continue; |
|
6987 |
} |
|
6988 |
if (tag == QLatin1String("height")) { |
|
6989 |
setElementHeight(e.text().toInt()); |
|
6990 |
continue; |
|
6991 |
} |
|
6992 |
} |
|
6993 |
m_text.clear(); |
|
6994 |
for (QDomNode child = node.firstChild(); !child.isNull(); child = child.nextSibling()) { |
|
6995 |
if (child.isText()) |
|
6996 |
m_text.append(child.nodeValue()); |
|
6997 |
} |
|
6998 |
} |
|
6999 |
#endif |
|
7000 |
||
7001 |
void DomSize::write(QXmlStreamWriter &writer, const QString &tagName) const |
|
7002 |
{ |
|
7003 |
writer.writeStartElement(tagName.isEmpty() ? QString::fromUtf8("size") : tagName.toLower()); |
|
7004 |
||
7005 |
if (m_children & Width) { |
|
7006 |
writer.writeTextElement(QLatin1String("width"), QString::number(m_width)); |
|
7007 |
} |
|
7008 |
||
7009 |
if (m_children & Height) { |
|
7010 |
writer.writeTextElement(QLatin1String("height"), QString::number(m_height)); |
|
7011 |
} |
|
7012 |
||
7013 |
if (!m_text.isEmpty()) |
|
7014 |
writer.writeCharacters(m_text); |
|
7015 |
||
7016 |
writer.writeEndElement(); |
|
7017 |
} |
|
7018 |
||
7019 |
void DomSize::setElementWidth(int a) |
|
7020 |
{ |
|
7021 |
m_children |= Width; |
|
7022 |
m_width = a; |
|
7023 |
} |
|
7024 |
||
7025 |
void DomSize::setElementHeight(int a) |
|
7026 |
{ |
|
7027 |
m_children |= Height; |
|
7028 |
m_height = a; |
|
7029 |
} |
|
7030 |
||
7031 |
void DomSize::clearElementWidth() |
|
7032 |
{ |
|
7033 |
m_children &= ~Width; |
|
7034 |
} |
|
7035 |
||
7036 |
void DomSize::clearElementHeight() |
|
7037 |
{ |
|
7038 |
m_children &= ~Height; |
|
7039 |
} |
|
7040 |
||
7041 |
void DomDate::clear(bool clear_all) |
|
7042 |
{ |
|
7043 |
||
7044 |
if (clear_all) { |
|
7045 |
m_text.clear(); |
|
7046 |
} |
|
7047 |
||
7048 |
m_children = 0; |
|
7049 |
m_year = 0; |
|
7050 |
m_month = 0; |
|
7051 |
m_day = 0; |
|
7052 |
} |
|
7053 |
||
7054 |
DomDate::DomDate() |
|
7055 |
{ |
|
7056 |
m_children = 0; |
|
7057 |
m_year = 0; |
|
7058 |
m_month = 0; |
|
7059 |
m_day = 0; |
|
7060 |
} |
|
7061 |
||
7062 |
DomDate::~DomDate() |
|
7063 |
{ |
|
7064 |
} |
|
7065 |
||
7066 |
void DomDate::read(QXmlStreamReader &reader) |
|
7067 |
{ |
|
7068 |
||
7069 |
for (bool finished = false; !finished && !reader.hasError();) { |
|
7070 |
switch (reader.readNext()) { |
|
7071 |
case QXmlStreamReader::StartElement : { |
|
7072 |
const QString tag = reader.name().toString().toLower(); |
|
7073 |
if (tag == QLatin1String("year")) { |
|
7074 |
setElementYear(reader.readElementText().toInt()); |
|
7075 |
continue; |
|
7076 |
} |
|
7077 |
if (tag == QLatin1String("month")) { |
|
7078 |
setElementMonth(reader.readElementText().toInt()); |
|
7079 |
continue; |
|
7080 |
} |
|
7081 |
if (tag == QLatin1String("day")) { |
|
7082 |
setElementDay(reader.readElementText().toInt()); |
|
7083 |
continue; |
|
7084 |
} |
|
7085 |
reader.raiseError(QLatin1String("Unexpected element ") + tag); |
|
7086 |
} |
|
7087 |
break; |
|
7088 |
case QXmlStreamReader::EndElement : |
|
7089 |
finished = true; |
|
7090 |
break; |
|
7091 |
case QXmlStreamReader::Characters : |
|
7092 |
if (!reader.isWhitespace()) |
|
7093 |
m_text.append(reader.text().toString()); |
|
7094 |
break; |
|
7095 |
default : |
|
7096 |
break; |
|
7097 |
} |
|
7098 |
} |
|
7099 |
} |
|
7100 |
||
7101 |
#ifdef QUILOADER_QDOM_READ |
|
7102 |
void DomDate::read(const QDomElement &node) |
|
7103 |
{ |
|
7104 |
for (QDomNode n = node.firstChild(); !n.isNull(); n = n.nextSibling()) { |
|
7105 |
if (!n.isElement()) |
|
7106 |
continue; |
|
7107 |
QDomElement e = n.toElement(); |
|
7108 |
QString tag = e.tagName().toLower(); |
|
7109 |
if (tag == QLatin1String("year")) { |
|
7110 |
setElementYear(e.text().toInt()); |
|
7111 |
continue; |
|
7112 |
} |
|
7113 |
if (tag == QLatin1String("month")) { |
|
7114 |
setElementMonth(e.text().toInt()); |
|
7115 |
continue; |
|
7116 |
} |
|
7117 |
if (tag == QLatin1String("day")) { |
|
7118 |
setElementDay(e.text().toInt()); |
|
7119 |
continue; |
|
7120 |
} |
|
7121 |
} |
|
7122 |
m_text.clear(); |
|
7123 |
for (QDomNode child = node.firstChild(); !child.isNull(); child = child.nextSibling()) { |
|
7124 |
if (child.isText()) |
|
7125 |
m_text.append(child.nodeValue()); |
|
7126 |
} |
|
7127 |
} |
|
7128 |
#endif |
|
7129 |
||
7130 |
void DomDate::write(QXmlStreamWriter &writer, const QString &tagName) const |
|
7131 |
{ |
|
7132 |
writer.writeStartElement(tagName.isEmpty() ? QString::fromUtf8("date") : tagName.toLower()); |
|
7133 |
||
7134 |
if (m_children & Year) { |
|
7135 |
writer.writeTextElement(QLatin1String("year"), QString::number(m_year)); |
|
7136 |
} |
|
7137 |
||
7138 |
if (m_children & Month) { |
|
7139 |
writer.writeTextElement(QLatin1String("month"), QString::number(m_month)); |
|
7140 |
} |
|
7141 |
||
7142 |
if (m_children & Day) { |
|
7143 |
writer.writeTextElement(QLatin1String("day"), QString::number(m_day)); |
|
7144 |
} |
|
7145 |
||
7146 |
if (!m_text.isEmpty()) |
|
7147 |
writer.writeCharacters(m_text); |
|
7148 |
||
7149 |
writer.writeEndElement(); |
|
7150 |
} |
|
7151 |
||
7152 |
void DomDate::setElementYear(int a) |
|
7153 |
{ |
|
7154 |
m_children |= Year; |
|
7155 |
m_year = a; |
|
7156 |
} |
|
7157 |
||
7158 |
void DomDate::setElementMonth(int a) |
|
7159 |
{ |
|
7160 |
m_children |= Month; |
|
7161 |
m_month = a; |
|
7162 |
} |
|
7163 |
||
7164 |
void DomDate::setElementDay(int a) |
|
7165 |
{ |
|
7166 |
m_children |= Day; |
|
7167 |
m_day = a; |
|
7168 |
} |
|
7169 |
||
7170 |
void DomDate::clearElementYear() |
|
7171 |
{ |
|
7172 |
m_children &= ~Year; |
|
7173 |
} |
|
7174 |
||
7175 |
void DomDate::clearElementMonth() |
|
7176 |
{ |
|
7177 |
m_children &= ~Month; |
|
7178 |
} |
|
7179 |
||
7180 |
void DomDate::clearElementDay() |
|
7181 |
{ |
|
7182 |
m_children &= ~Day; |
|
7183 |
} |
|
7184 |
||
7185 |
void DomTime::clear(bool clear_all) |
|
7186 |
{ |
|
7187 |
||
7188 |
if (clear_all) { |
|
7189 |
m_text.clear(); |
|
7190 |
} |
|
7191 |
||
7192 |
m_children = 0; |
|
7193 |
m_hour = 0; |
|
7194 |
m_minute = 0; |
|
7195 |
m_second = 0; |
|
7196 |
} |
|
7197 |
||
7198 |
DomTime::DomTime() |
|
7199 |
{ |
|
7200 |
m_children = 0; |
|
7201 |
m_hour = 0; |
|
7202 |
m_minute = 0; |
|
7203 |
m_second = 0; |
|
7204 |
} |
|
7205 |
||
7206 |
DomTime::~DomTime() |
|
7207 |
{ |
|
7208 |
} |
|
7209 |
||
7210 |
void DomTime::read(QXmlStreamReader &reader) |
|
7211 |
{ |
|
7212 |
||
7213 |
for (bool finished = false; !finished && !reader.hasError();) { |
|
7214 |
switch (reader.readNext()) { |
|
7215 |
case QXmlStreamReader::StartElement : { |
|
7216 |
const QString tag = reader.name().toString().toLower(); |
|
7217 |
if (tag == QLatin1String("hour")) { |
|
7218 |
setElementHour(reader.readElementText().toInt()); |
|
7219 |
continue; |
|
7220 |
} |
|
7221 |
if (tag == QLatin1String("minute")) { |
|
7222 |
setElementMinute(reader.readElementText().toInt()); |
|
7223 |
continue; |
|
7224 |
} |
|
7225 |
if (tag == QLatin1String("second")) { |
|
7226 |
setElementSecond(reader.readElementText().toInt()); |
|
7227 |
continue; |
|
7228 |
} |
|
7229 |
reader.raiseError(QLatin1String("Unexpected element ") + tag); |
|
7230 |
} |
|
7231 |
break; |
|
7232 |
case QXmlStreamReader::EndElement : |
|
7233 |
finished = true; |
|
7234 |
break; |
|
7235 |
case QXmlStreamReader::Characters : |
|
7236 |
if (!reader.isWhitespace()) |
|
7237 |
m_text.append(reader.text().toString()); |
|
7238 |
break; |
|
7239 |
default : |
|
7240 |
break; |
|
7241 |
} |
|
7242 |
} |
|
7243 |
} |
|
7244 |
||
7245 |
#ifdef QUILOADER_QDOM_READ |
|
7246 |
void DomTime::read(const QDomElement &node) |
|
7247 |
{ |
|
7248 |
for (QDomNode n = node.firstChild(); !n.isNull(); n = n.nextSibling()) { |
|
7249 |
if (!n.isElement()) |
|
7250 |
continue; |
|
7251 |
QDomElement e = n.toElement(); |
|
7252 |
QString tag = e.tagName().toLower(); |
|
7253 |
if (tag == QLatin1String("hour")) { |
|
7254 |
setElementHour(e.text().toInt()); |
|
7255 |
continue; |
|
7256 |
} |
|
7257 |
if (tag == QLatin1String("minute")) { |
|
7258 |
setElementMinute(e.text().toInt()); |
|
7259 |
continue; |
|
7260 |
} |
|
7261 |
if (tag == QLatin1String("second")) { |
|
7262 |
setElementSecond(e.text().toInt()); |
|
7263 |
continue; |
|
7264 |
} |
|
7265 |
} |
|
7266 |
m_text.clear(); |
|
7267 |
for (QDomNode child = node.firstChild(); !child.isNull(); child = child.nextSibling()) { |
|
7268 |
if (child.isText()) |
|
7269 |
m_text.append(child.nodeValue()); |
|
7270 |
} |
|
7271 |
} |
|
7272 |
#endif |
|
7273 |
||
7274 |
void DomTime::write(QXmlStreamWriter &writer, const QString &tagName) const |
|
7275 |
{ |
|
7276 |
writer.writeStartElement(tagName.isEmpty() ? QString::fromUtf8("time") : tagName.toLower()); |
|
7277 |
||
7278 |
if (m_children & Hour) { |
|
7279 |
writer.writeTextElement(QLatin1String("hour"), QString::number(m_hour)); |
|
7280 |
} |
|
7281 |
||
7282 |
if (m_children & Minute) { |
|
7283 |
writer.writeTextElement(QLatin1String("minute"), QString::number(m_minute)); |
|
7284 |
} |
|
7285 |
||
7286 |
if (m_children & Second) { |
|
7287 |
writer.writeTextElement(QLatin1String("second"), QString::number(m_second)); |
|
7288 |
} |
|
7289 |
||
7290 |
if (!m_text.isEmpty()) |
|
7291 |
writer.writeCharacters(m_text); |
|
7292 |
||
7293 |
writer.writeEndElement(); |
|
7294 |
} |
|
7295 |
||
7296 |
void DomTime::setElementHour(int a) |
|
7297 |
{ |
|
7298 |
m_children |= Hour; |
|
7299 |
m_hour = a; |
|
7300 |
} |
|
7301 |
||
7302 |
void DomTime::setElementMinute(int a) |
|
7303 |
{ |
|
7304 |
m_children |= Minute; |
|
7305 |
m_minute = a; |
|
7306 |
} |
|
7307 |
||
7308 |
void DomTime::setElementSecond(int a) |
|
7309 |
{ |
|
7310 |
m_children |= Second; |
|
7311 |
m_second = a; |
|
7312 |
} |
|
7313 |
||
7314 |
void DomTime::clearElementHour() |
|
7315 |
{ |
|
7316 |
m_children &= ~Hour; |
|
7317 |
} |
|
7318 |
||
7319 |
void DomTime::clearElementMinute() |
|
7320 |
{ |
|
7321 |
m_children &= ~Minute; |
|
7322 |
} |
|
7323 |
||
7324 |
void DomTime::clearElementSecond() |
|
7325 |
{ |
|
7326 |
m_children &= ~Second; |
|
7327 |
} |
|
7328 |
||
7329 |
void DomDateTime::clear(bool clear_all) |
|
7330 |
{ |
|
7331 |
||
7332 |
if (clear_all) { |
|
7333 |
m_text.clear(); |
|
7334 |
} |
|
7335 |
||
7336 |
m_children = 0; |
|
7337 |
m_hour = 0; |
|
7338 |
m_minute = 0; |
|
7339 |
m_second = 0; |
|
7340 |
m_year = 0; |
|
7341 |
m_month = 0; |
|
7342 |
m_day = 0; |
|
7343 |
} |
|
7344 |
||
7345 |
DomDateTime::DomDateTime() |
|
7346 |
{ |
|
7347 |
m_children = 0; |
|
7348 |
m_hour = 0; |
|
7349 |
m_minute = 0; |
|
7350 |
m_second = 0; |
|
7351 |
m_year = 0; |
|
7352 |
m_month = 0; |
|
7353 |
m_day = 0; |
|
7354 |
} |
|
7355 |
||
7356 |
DomDateTime::~DomDateTime() |
|
7357 |
{ |
|
7358 |
} |
|
7359 |
||
7360 |
void DomDateTime::read(QXmlStreamReader &reader) |
|
7361 |
{ |
|
7362 |
||
7363 |
for (bool finished = false; !finished && !reader.hasError();) { |
|
7364 |
switch (reader.readNext()) { |
|
7365 |
case QXmlStreamReader::StartElement : { |
|
7366 |
const QString tag = reader.name().toString().toLower(); |
|
7367 |
if (tag == QLatin1String("hour")) { |
|
7368 |
setElementHour(reader.readElementText().toInt()); |
|
7369 |
continue; |
|
7370 |
} |
|
7371 |
if (tag == QLatin1String("minute")) { |
|
7372 |
setElementMinute(reader.readElementText().toInt()); |
|
7373 |
continue; |
|
7374 |
} |
|
7375 |
if (tag == QLatin1String("second")) { |
|
7376 |
setElementSecond(reader.readElementText().toInt()); |
|
7377 |
continue; |
|
7378 |
} |
|
7379 |
if (tag == QLatin1String("year")) { |
|
7380 |
setElementYear(reader.readElementText().toInt()); |
|
7381 |
continue; |
|
7382 |
} |
|
7383 |
if (tag == QLatin1String("month")) { |
|
7384 |
setElementMonth(reader.readElementText().toInt()); |
|
7385 |
continue; |
|
7386 |
} |
|
7387 |
if (tag == QLatin1String("day")) { |
|
7388 |
setElementDay(reader.readElementText().toInt()); |
|
7389 |
continue; |
|
7390 |
} |
|
7391 |
reader.raiseError(QLatin1String("Unexpected element ") + tag); |
|
7392 |
} |
|
7393 |
break; |
|
7394 |
case QXmlStreamReader::EndElement : |
|
7395 |
finished = true; |
|
7396 |
break; |
|
7397 |
case QXmlStreamReader::Characters : |
|
7398 |
if (!reader.isWhitespace()) |
|
7399 |
m_text.append(reader.text().toString()); |
|
7400 |
break; |
|
7401 |
default : |
|
7402 |
break; |
|
7403 |
} |
|
7404 |
} |
|
7405 |
} |
|
7406 |
||
7407 |
#ifdef QUILOADER_QDOM_READ |
|
7408 |
void DomDateTime::read(const QDomElement &node) |
|
7409 |
{ |
|
7410 |
for (QDomNode n = node.firstChild(); !n.isNull(); n = n.nextSibling()) { |
|
7411 |
if (!n.isElement()) |
|
7412 |
continue; |
|
7413 |
QDomElement e = n.toElement(); |
|
7414 |
QString tag = e.tagName().toLower(); |
|
7415 |
if (tag == QLatin1String("hour")) { |
|
7416 |
setElementHour(e.text().toInt()); |
|
7417 |
continue; |
|
7418 |
} |
|
7419 |
if (tag == QLatin1String("minute")) { |
|
7420 |
setElementMinute(e.text().toInt()); |
|
7421 |
continue; |
|
7422 |
} |
|
7423 |
if (tag == QLatin1String("second")) { |
|
7424 |
setElementSecond(e.text().toInt()); |
|
7425 |
continue; |
|
7426 |
} |
|
7427 |
if (tag == QLatin1String("year")) { |
|
7428 |
setElementYear(e.text().toInt()); |
|
7429 |
continue; |
|
7430 |
} |
|
7431 |
if (tag == QLatin1String("month")) { |
|
7432 |
setElementMonth(e.text().toInt()); |
|
7433 |
continue; |
|
7434 |
} |
|
7435 |
if (tag == QLatin1String("day")) { |
|
7436 |
setElementDay(e.text().toInt()); |
|
7437 |
continue; |
|
7438 |
} |
|
7439 |
} |
|
7440 |
m_text.clear(); |
|
7441 |
for (QDomNode child = node.firstChild(); !child.isNull(); child = child.nextSibling()) { |
|
7442 |
if (child.isText()) |
|
7443 |
m_text.append(child.nodeValue()); |
|
7444 |
} |
|
7445 |
} |
|
7446 |
#endif |
|
7447 |
||
7448 |
void DomDateTime::write(QXmlStreamWriter &writer, const QString &tagName) const |
|
7449 |
{ |
|
7450 |
writer.writeStartElement(tagName.isEmpty() ? QString::fromUtf8("datetime") : tagName.toLower()); |
|
7451 |
||
7452 |
if (m_children & Hour) { |
|
7453 |
writer.writeTextElement(QLatin1String("hour"), QString::number(m_hour)); |
|
7454 |
} |
|
7455 |
||
7456 |
if (m_children & Minute) { |
|
7457 |
writer.writeTextElement(QLatin1String("minute"), QString::number(m_minute)); |
|
7458 |
} |
|
7459 |
||
7460 |
if (m_children & Second) { |
|
7461 |
writer.writeTextElement(QLatin1String("second"), QString::number(m_second)); |
|
7462 |
} |
|
7463 |
||
7464 |
if (m_children & Year) { |
|
7465 |
writer.writeTextElement(QLatin1String("year"), QString::number(m_year)); |
|
7466 |
} |
|
7467 |
||
7468 |
if (m_children & Month) { |
|
7469 |
writer.writeTextElement(QLatin1String("month"), QString::number(m_month)); |
|
7470 |
} |
|
7471 |
||
7472 |
if (m_children & Day) { |
|
7473 |
writer.writeTextElement(QLatin1String("day"), QString::number(m_day)); |
|
7474 |
} |
|
7475 |
||
7476 |
if (!m_text.isEmpty()) |
|
7477 |
writer.writeCharacters(m_text); |
|
7478 |
||
7479 |
writer.writeEndElement(); |
|
7480 |
} |
|
7481 |
||
7482 |
void DomDateTime::setElementHour(int a) |
|
7483 |
{ |
|
7484 |
m_children |= Hour; |
|
7485 |
m_hour = a; |
|
7486 |
} |
|
7487 |
||
7488 |
void DomDateTime::setElementMinute(int a) |
|
7489 |
{ |
|
7490 |
m_children |= Minute; |
|
7491 |
m_minute = a; |
|
7492 |
} |
|
7493 |
||
7494 |
void DomDateTime::setElementSecond(int a) |
|
7495 |
{ |
|
7496 |
m_children |= Second; |
|
7497 |
m_second = a; |
|
7498 |
} |
|
7499 |
||
7500 |
void DomDateTime::setElementYear(int a) |
|
7501 |
{ |
|
7502 |
m_children |= Year; |
|
7503 |
m_year = a; |
|
7504 |
} |
|
7505 |
||
7506 |
void DomDateTime::setElementMonth(int a) |
|
7507 |
{ |
|
7508 |
m_children |= Month; |
|
7509 |
m_month = a; |
|
7510 |
} |
|
7511 |
||
7512 |
void DomDateTime::setElementDay(int a) |
|
7513 |
{ |
|
7514 |
m_children |= Day; |
|
7515 |
m_day = a; |
|
7516 |
} |
|
7517 |
||
7518 |
void DomDateTime::clearElementHour() |
|
7519 |
{ |
|
7520 |
m_children &= ~Hour; |
|
7521 |
} |
|
7522 |
||
7523 |
void DomDateTime::clearElementMinute() |
|
7524 |
{ |
|
7525 |
m_children &= ~Minute; |
|
7526 |
} |
|
7527 |
||
7528 |
void DomDateTime::clearElementSecond() |
|
7529 |
{ |
|
7530 |
m_children &= ~Second; |
|
7531 |
} |
|
7532 |
||
7533 |
void DomDateTime::clearElementYear() |
|
7534 |
{ |
|
7535 |
m_children &= ~Year; |
|
7536 |
} |
|
7537 |
||
7538 |
void DomDateTime::clearElementMonth() |
|
7539 |
{ |
|
7540 |
m_children &= ~Month; |
|
7541 |
} |
|
7542 |
||
7543 |
void DomDateTime::clearElementDay() |
|
7544 |
{ |
|
7545 |
m_children &= ~Day; |
|
7546 |
} |
|
7547 |
||
7548 |
void DomStringList::clear(bool clear_all) |
|
7549 |
{ |
|
7550 |
m_string.clear(); |
|
7551 |
||
7552 |
if (clear_all) { |
|
7553 |
m_text.clear(); |
|
7554 |
} |
|
7555 |
||
7556 |
m_children = 0; |
|
7557 |
} |
|
7558 |
||
7559 |
DomStringList::DomStringList() |
|
7560 |
{ |
|
7561 |
m_children = 0; |
|
7562 |
} |
|
7563 |
||
7564 |
DomStringList::~DomStringList() |
|
7565 |
{ |
|
7566 |
m_string.clear(); |
|
7567 |
} |
|
7568 |
||
7569 |
void DomStringList::read(QXmlStreamReader &reader) |
|
7570 |
{ |
|
7571 |
||
7572 |
for (bool finished = false; !finished && !reader.hasError();) { |
|
7573 |
switch (reader.readNext()) { |
|
7574 |
case QXmlStreamReader::StartElement : { |
|
7575 |
const QString tag = reader.name().toString().toLower(); |
|
7576 |
if (tag == QLatin1String("string")) { |
|
7577 |
m_string.append(reader.readElementText()); |
|
7578 |
continue; |
|
7579 |
} |
|
7580 |
reader.raiseError(QLatin1String("Unexpected element ") + tag); |
|
7581 |
} |
|
7582 |
break; |
|
7583 |
case QXmlStreamReader::EndElement : |
|
7584 |
finished = true; |
|
7585 |
break; |
|
7586 |
case QXmlStreamReader::Characters : |
|
7587 |
if (!reader.isWhitespace()) |
|
7588 |
m_text.append(reader.text().toString()); |
|
7589 |
break; |
|
7590 |
default : |
|
7591 |
break; |
|
7592 |
} |
|
7593 |
} |
|
7594 |
} |
|
7595 |
||
7596 |
#ifdef QUILOADER_QDOM_READ |
|
7597 |
void DomStringList::read(const QDomElement &node) |
|
7598 |
{ |
|
7599 |
for (QDomNode n = node.firstChild(); !n.isNull(); n = n.nextSibling()) { |
|
7600 |
if (!n.isElement()) |
|
7601 |
continue; |
|
7602 |
QDomElement e = n.toElement(); |
|
7603 |
QString tag = e.tagName().toLower(); |
|
7604 |
if (tag == QLatin1String("string")) { |
|
7605 |
m_string.append(e.text()); |
|
7606 |
continue; |
|
7607 |
} |
|
7608 |
} |
|
7609 |
m_text.clear(); |
|
7610 |
for (QDomNode child = node.firstChild(); !child.isNull(); child = child.nextSibling()) { |
|
7611 |
if (child.isText()) |
|
7612 |
m_text.append(child.nodeValue()); |
|
7613 |
} |
|
7614 |
} |
|
7615 |
#endif |
|
7616 |
||
7617 |
void DomStringList::write(QXmlStreamWriter &writer, const QString &tagName) const |
|
7618 |
{ |
|
7619 |
writer.writeStartElement(tagName.isEmpty() ? QString::fromUtf8("stringlist") : tagName.toLower()); |
|
7620 |
||
7621 |
for (int i = 0; i < m_string.size(); ++i) { |
|
7622 |
QString v = m_string[i]; |
|
7623 |
writer.writeTextElement(QLatin1String("string"), v); |
|
7624 |
} |
|
7625 |
if (!m_text.isEmpty()) |
|
7626 |
writer.writeCharacters(m_text); |
|
7627 |
||
7628 |
writer.writeEndElement(); |
|
7629 |
} |
|
7630 |
||
7631 |
void DomStringList::setElementString(const QStringList& a) |
|
7632 |
{ |
|
7633 |
m_children |= String; |
|
7634 |
m_string = a; |
|
7635 |
} |
|
7636 |
||
7637 |
void DomResourcePixmap::clear(bool clear_all) |
|
7638 |
{ |
|
7639 |
||
7640 |
if (clear_all) { |
|
7641 |
m_text = QLatin1String(""); |
|
7642 |
m_has_attr_resource = false; |
|
7643 |
m_has_attr_alias = false; |
|
7644 |
} |
|
7645 |
||
7646 |
m_children = 0; |
|
7647 |
} |
|
7648 |
||
7649 |
DomResourcePixmap::DomResourcePixmap() |
|
7650 |
{ |
|
7651 |
m_children = 0; |
|
7652 |
m_has_attr_resource = false; |
|
7653 |
m_has_attr_alias = false; |
|
7654 |
m_text = QLatin1String(""); |
|
7655 |
} |
|
7656 |
||
7657 |
DomResourcePixmap::~DomResourcePixmap() |
|
7658 |
{ |
|
7659 |
} |
|
7660 |
||
7661 |
void DomResourcePixmap::read(QXmlStreamReader &reader) |
|
7662 |
{ |
|
7663 |
||
7664 |
foreach (const QXmlStreamAttribute &attribute, reader.attributes()) { |
|
7665 |
QStringRef name = attribute.name(); |
|
7666 |
if (name == QLatin1String("resource")) { |
|
7667 |
setAttributeResource(attribute.value().toString()); |
|
7668 |
continue; |
|
7669 |
} |
|
7670 |
if (name == QLatin1String("alias")) { |
|
7671 |
setAttributeAlias(attribute.value().toString()); |
|
7672 |
continue; |
|
7673 |
} |
|
7674 |
reader.raiseError(QLatin1String("Unexpected attribute ") + name.toString()); |
|
7675 |
} |
|
7676 |
||
7677 |
for (bool finished = false; !finished && !reader.hasError();) { |
|
7678 |
switch (reader.readNext()) { |
|
7679 |
case QXmlStreamReader::StartElement : { |
|
7680 |
const QString tag = reader.name().toString().toLower(); |
|
7681 |
reader.raiseError(QLatin1String("Unexpected element ") + tag); |
|
7682 |
} |
|
7683 |
break; |
|
7684 |
case QXmlStreamReader::EndElement : |
|
7685 |
finished = true; |
|
7686 |
break; |
|
7687 |
case QXmlStreamReader::Characters : |
|
7688 |
if (!reader.isWhitespace()) |
|
7689 |
m_text.append(reader.text().toString()); |
|
7690 |
break; |
|
7691 |
default : |
|
7692 |
break; |
|
7693 |
} |
|
7694 |
} |
|
7695 |
} |
|
7696 |
||
7697 |
#ifdef QUILOADER_QDOM_READ |
|
7698 |
void DomResourcePixmap::read(const QDomElement &node) |
|
7699 |
{ |
|
7700 |
if (node.hasAttribute(QLatin1String("resource"))) |
|
7701 |
setAttributeResource(node.attribute(QLatin1String("resource"))); |
|
7702 |
if (node.hasAttribute(QLatin1String("alias"))) |
|
7703 |
setAttributeAlias(node.attribute(QLatin1String("alias"))); |
|
7704 |
||
7705 |
for (QDomNode n = node.firstChild(); !n.isNull(); n = n.nextSibling()) { |
|
7706 |
if (!n.isElement()) |
|
7707 |
continue; |
|
7708 |
QDomElement e = n.toElement(); |
|
7709 |
QString tag = e.tagName().toLower(); |
|
7710 |
} |
|
7711 |
m_text = QLatin1String(""); |
|
7712 |
for (QDomNode child = node.firstChild(); !child.isNull(); child = child.nextSibling()) { |
|
7713 |
if (child.isText()) |
|
7714 |
m_text.append(child.nodeValue()); |
|
7715 |
} |
|
7716 |
} |
|
7717 |
#endif |
|
7718 |
||
7719 |
void DomResourcePixmap::write(QXmlStreamWriter &writer, const QString &tagName) const |
|
7720 |
{ |
|
7721 |
writer.writeStartElement(tagName.isEmpty() ? QString::fromUtf8("resourcepixmap") : tagName.toLower()); |
|
7722 |
||
7723 |
if (hasAttributeResource()) |
|
7724 |
writer.writeAttribute(QLatin1String("resource"), attributeResource()); |
|
7725 |
||
7726 |
if (hasAttributeAlias()) |
|
7727 |
writer.writeAttribute(QLatin1String("alias"), attributeAlias()); |
|
7728 |
||
7729 |
if (!m_text.isEmpty()) |
|
7730 |
writer.writeCharacters(m_text); |
|
7731 |
||
7732 |
writer.writeEndElement(); |
|
7733 |
} |
|
7734 |
||
7735 |
void DomResourceIcon::clear(bool clear_all) |
|
7736 |
{ |
|
7737 |
delete m_normalOff; |
|
7738 |
delete m_normalOn; |
|
7739 |
delete m_disabledOff; |
|
7740 |
delete m_disabledOn; |
|
7741 |
delete m_activeOff; |
|
7742 |
delete m_activeOn; |
|
7743 |
delete m_selectedOff; |
|
7744 |
delete m_selectedOn; |
|
7745 |
||
7746 |
if (clear_all) { |
|
7747 |
m_text = QLatin1String(""); |
|
7748 |
m_has_attr_resource = false; |
|
7749 |
} |
|
7750 |
||
7751 |
m_children = 0; |
|
7752 |
m_normalOff = 0; |
|
7753 |
m_normalOn = 0; |
|
7754 |
m_disabledOff = 0; |
|
7755 |
m_disabledOn = 0; |
|
7756 |
m_activeOff = 0; |
|
7757 |
m_activeOn = 0; |
|
7758 |
m_selectedOff = 0; |
|
7759 |
m_selectedOn = 0; |
|
7760 |
} |
|
7761 |
||
7762 |
DomResourceIcon::DomResourceIcon() |
|
7763 |
{ |
|
7764 |
m_children = 0; |
|
7765 |
m_has_attr_resource = false; |
|
7766 |
m_text = QLatin1String(""); |
|
7767 |
m_normalOff = 0; |
|
7768 |
m_normalOn = 0; |
|
7769 |
m_disabledOff = 0; |
|
7770 |
m_disabledOn = 0; |
|
7771 |
m_activeOff = 0; |
|
7772 |
m_activeOn = 0; |
|
7773 |
m_selectedOff = 0; |
|
7774 |
m_selectedOn = 0; |
|
7775 |
} |
|
7776 |
||
7777 |
DomResourceIcon::~DomResourceIcon() |
|
7778 |
{ |
|
7779 |
delete m_normalOff; |
|
7780 |
delete m_normalOn; |
|
7781 |
delete m_disabledOff; |
|
7782 |
delete m_disabledOn; |
|
7783 |
delete m_activeOff; |
|
7784 |
delete m_activeOn; |
|
7785 |
delete m_selectedOff; |
|
7786 |
delete m_selectedOn; |
|
7787 |
} |
|
7788 |
||
7789 |
void DomResourceIcon::read(QXmlStreamReader &reader) |
|
7790 |
{ |
|
7791 |
||
7792 |
foreach (const QXmlStreamAttribute &attribute, reader.attributes()) { |
|
7793 |
QStringRef name = attribute.name(); |
|
7794 |
if (name == QLatin1String("resource")) { |
|
7795 |
setAttributeResource(attribute.value().toString()); |
|
7796 |
continue; |
|
7797 |
} |
|
7798 |
reader.raiseError(QLatin1String("Unexpected attribute ") + name.toString()); |
|
7799 |
} |
|
7800 |
||
7801 |
for (bool finished = false; !finished && !reader.hasError();) { |
|
7802 |
switch (reader.readNext()) { |
|
7803 |
case QXmlStreamReader::StartElement : { |
|
7804 |
const QString tag = reader.name().toString().toLower(); |
|
7805 |
if (tag == QLatin1String("normaloff")) { |
|
7806 |
DomResourcePixmap *v = new DomResourcePixmap(); |
|
7807 |
v->read(reader); |
|
7808 |
setElementNormalOff(v); |
|
7809 |
continue; |
|
7810 |
} |
|
7811 |
if (tag == QLatin1String("normalon")) { |
|
7812 |
DomResourcePixmap *v = new DomResourcePixmap(); |
|
7813 |
v->read(reader); |
|
7814 |
setElementNormalOn(v); |
|
7815 |
continue; |
|
7816 |
} |
|
7817 |
if (tag == QLatin1String("disabledoff")) { |
|
7818 |
DomResourcePixmap *v = new DomResourcePixmap(); |
|
7819 |
v->read(reader); |
|
7820 |
setElementDisabledOff(v); |
|
7821 |
continue; |
|
7822 |
} |
|
7823 |
if (tag == QLatin1String("disabledon")) { |
|
7824 |
DomResourcePixmap *v = new DomResourcePixmap(); |
|
7825 |
v->read(reader); |
|
7826 |
setElementDisabledOn(v); |
|
7827 |
continue; |
|
7828 |
} |
|
7829 |
if (tag == QLatin1String("activeoff")) { |
|
7830 |
DomResourcePixmap *v = new DomResourcePixmap(); |
|
7831 |
v->read(reader); |
|
7832 |
setElementActiveOff(v); |
|
7833 |
continue; |
|
7834 |
} |
|
7835 |
if (tag == QLatin1String("activeon")) { |
|
7836 |
DomResourcePixmap *v = new DomResourcePixmap(); |
|
7837 |
v->read(reader); |
|
7838 |
setElementActiveOn(v); |
|
7839 |
continue; |
|
7840 |
} |
|
7841 |
if (tag == QLatin1String("selectedoff")) { |
|
7842 |
DomResourcePixmap *v = new DomResourcePixmap(); |
|
7843 |
v->read(reader); |
|
7844 |
setElementSelectedOff(v); |
|
7845 |
continue; |
|
7846 |
} |
|
7847 |
if (tag == QLatin1String("selectedon")) { |
|
7848 |
DomResourcePixmap *v = new DomResourcePixmap(); |
|
7849 |
v->read(reader); |
|
7850 |
setElementSelectedOn(v); |
|
7851 |
continue; |
|
7852 |
} |
|
7853 |
reader.raiseError(QLatin1String("Unexpected element ") + tag); |
|
7854 |
} |
|
7855 |
break; |
|
7856 |
case QXmlStreamReader::EndElement : |
|
7857 |
finished = true; |
|
7858 |
break; |
|
7859 |
case QXmlStreamReader::Characters : |
|
7860 |
if (!reader.isWhitespace()) |
|
7861 |
m_text.append(reader.text().toString()); |
|
7862 |
break; |
|
7863 |
default : |
|
7864 |
break; |
|
7865 |
} |
|
7866 |
} |
|
7867 |
} |
|
7868 |
||
7869 |
#ifdef QUILOADER_QDOM_READ |
|
7870 |
void DomResourceIcon::read(const QDomElement &node) |
|
7871 |
{ |
|
7872 |
if (node.hasAttribute(QLatin1String("resource"))) |
|
7873 |
setAttributeResource(node.attribute(QLatin1String("resource"))); |
|
7874 |
||
7875 |
for (QDomNode n = node.firstChild(); !n.isNull(); n = n.nextSibling()) { |
|
7876 |
if (!n.isElement()) |
|
7877 |
continue; |
|
7878 |
QDomElement e = n.toElement(); |
|
7879 |
QString tag = e.tagName().toLower(); |
|
7880 |
if (tag == QLatin1String("normaloff")) { |
|
7881 |
DomResourcePixmap *v = new DomResourcePixmap(); |
|
7882 |
v->read(e); |
|
7883 |
setElementNormalOff(v); |
|
7884 |
continue; |
|
7885 |
} |
|
7886 |
if (tag == QLatin1String("normalon")) { |
|
7887 |
DomResourcePixmap *v = new DomResourcePixmap(); |
|
7888 |
v->read(e); |
|
7889 |
setElementNormalOn(v); |
|
7890 |
continue; |
|
7891 |
} |
|
7892 |
if (tag == QLatin1String("disabledoff")) { |
|
7893 |
DomResourcePixmap *v = new DomResourcePixmap(); |
|
7894 |
v->read(e); |
|
7895 |
setElementDisabledOff(v); |
|
7896 |
continue; |
|
7897 |
} |
|
7898 |
if (tag == QLatin1String("disabledon")) { |
|
7899 |
DomResourcePixmap *v = new DomResourcePixmap(); |
|
7900 |
v->read(e); |
|
7901 |
setElementDisabledOn(v); |
|
7902 |
continue; |
|
7903 |
} |
|
7904 |
if (tag == QLatin1String("activeoff")) { |
|
7905 |
DomResourcePixmap *v = new DomResourcePixmap(); |
|
7906 |
v->read(e); |
|
7907 |
setElementActiveOff(v); |
|
7908 |
continue; |
|
7909 |
} |
|
7910 |
if (tag == QLatin1String("activeon")) { |
|
7911 |
DomResourcePixmap *v = new DomResourcePixmap(); |
|
7912 |
v->read(e); |
|
7913 |
setElementActiveOn(v); |
|
7914 |
continue; |
|
7915 |
} |
|
7916 |
if (tag == QLatin1String("selectedoff")) { |
|
7917 |
DomResourcePixmap *v = new DomResourcePixmap(); |
|
7918 |
v->read(e); |
|
7919 |
setElementSelectedOff(v); |
|
7920 |
continue; |
|
7921 |
} |
|
7922 |
if (tag == QLatin1String("selectedon")) { |
|
7923 |
DomResourcePixmap *v = new DomResourcePixmap(); |
|
7924 |
v->read(e); |
|
7925 |
setElementSelectedOn(v); |
|
7926 |
continue; |
|
7927 |
} |
|
7928 |
} |
|
7929 |
m_text = QLatin1String(""); |
|
7930 |
for (QDomNode child = node.firstChild(); !child.isNull(); child = child.nextSibling()) { |
|
7931 |
if (child.isText()) |
|
7932 |
m_text.append(child.nodeValue()); |
|
7933 |
} |
|
7934 |
} |
|
7935 |
#endif |
|
7936 |
||
7937 |
void DomResourceIcon::write(QXmlStreamWriter &writer, const QString &tagName) const |
|
7938 |
{ |
|
7939 |
writer.writeStartElement(tagName.isEmpty() ? QString::fromUtf8("resourceicon") : tagName.toLower()); |
|
7940 |
||
7941 |
if (hasAttributeResource()) |
|
7942 |
writer.writeAttribute(QLatin1String("resource"), attributeResource()); |
|
7943 |
||
7944 |
if (m_children & NormalOff) { |
|
7945 |
m_normalOff->write(writer, QLatin1String("normaloff")); |
|
7946 |
} |
|
7947 |
||
7948 |
if (m_children & NormalOn) { |
|
7949 |
m_normalOn->write(writer, QLatin1String("normalon")); |
|
7950 |
} |
|
7951 |
||
7952 |
if (m_children & DisabledOff) { |
|
7953 |
m_disabledOff->write(writer, QLatin1String("disabledoff")); |
|
7954 |
} |
|
7955 |
||
7956 |
if (m_children & DisabledOn) { |
|
7957 |
m_disabledOn->write(writer, QLatin1String("disabledon")); |
|
7958 |
} |
|
7959 |
||
7960 |
if (m_children & ActiveOff) { |
|
7961 |
m_activeOff->write(writer, QLatin1String("activeoff")); |
|
7962 |
} |
|
7963 |
||
7964 |
if (m_children & ActiveOn) { |
|
7965 |
m_activeOn->write(writer, QLatin1String("activeon")); |
|
7966 |
} |
|
7967 |
||
7968 |
if (m_children & SelectedOff) { |
|
7969 |
m_selectedOff->write(writer, QLatin1String("selectedoff")); |
|
7970 |
} |
|
7971 |
||
7972 |
if (m_children & SelectedOn) { |
|
7973 |
m_selectedOn->write(writer, QLatin1String("selectedon")); |
|
7974 |
} |
|
7975 |
||
7976 |
if (!m_text.isEmpty()) |
|
7977 |
writer.writeCharacters(m_text); |
|
7978 |
||
7979 |
writer.writeEndElement(); |
|
7980 |
} |
|
7981 |
||
7982 |
DomResourcePixmap* DomResourceIcon::takeElementNormalOff() |
|
7983 |
{ |
|
7984 |
DomResourcePixmap* a = m_normalOff; |
|
7985 |
m_normalOff = 0; |
|
7986 |
m_children ^= NormalOff; |
|
7987 |
return a; |
|
7988 |
} |
|
7989 |
||
7990 |
void DomResourceIcon::setElementNormalOff(DomResourcePixmap* a) |
|
7991 |
{ |
|
7992 |
delete m_normalOff; |
|
7993 |
m_children |= NormalOff; |
|
7994 |
m_normalOff = a; |
|
7995 |
} |
|
7996 |
||
7997 |
DomResourcePixmap* DomResourceIcon::takeElementNormalOn() |
|
7998 |
{ |
|
7999 |
DomResourcePixmap* a = m_normalOn; |
|
8000 |
m_normalOn = 0; |
|
8001 |
m_children ^= NormalOn; |
|
8002 |
return a; |
|
8003 |
} |
|
8004 |
||
8005 |
void DomResourceIcon::setElementNormalOn(DomResourcePixmap* a) |
|
8006 |
{ |
|
8007 |
delete m_normalOn; |
|
8008 |
m_children |= NormalOn; |
|
8009 |
m_normalOn = a; |
|
8010 |
} |
|
8011 |
||
8012 |
DomResourcePixmap* DomResourceIcon::takeElementDisabledOff() |
|
8013 |
{ |
|
8014 |
DomResourcePixmap* a = m_disabledOff; |
|
8015 |
m_disabledOff = 0; |
|
8016 |
m_children ^= DisabledOff; |
|
8017 |
return a; |
|
8018 |
} |
|
8019 |
||
8020 |
void DomResourceIcon::setElementDisabledOff(DomResourcePixmap* a) |
|
8021 |
{ |
|
8022 |
delete m_disabledOff; |
|
8023 |
m_children |= DisabledOff; |
|
8024 |
m_disabledOff = a; |
|
8025 |
} |
|
8026 |
||
8027 |
DomResourcePixmap* DomResourceIcon::takeElementDisabledOn() |
|
8028 |
{ |
|
8029 |
DomResourcePixmap* a = m_disabledOn; |
|
8030 |
m_disabledOn = 0; |
|
8031 |
m_children ^= DisabledOn; |
|
8032 |
return a; |
|
8033 |
} |
|
8034 |
||
8035 |
void DomResourceIcon::setElementDisabledOn(DomResourcePixmap* a) |
|
8036 |
{ |
|
8037 |
delete m_disabledOn; |
|
8038 |
m_children |= DisabledOn; |
|
8039 |
m_disabledOn = a; |
|
8040 |
} |
|
8041 |
||
8042 |
DomResourcePixmap* DomResourceIcon::takeElementActiveOff() |
|
8043 |
{ |
|
8044 |
DomResourcePixmap* a = m_activeOff; |
|
8045 |
m_activeOff = 0; |
|
8046 |
m_children ^= ActiveOff; |
|
8047 |
return a; |
|
8048 |
} |
|
8049 |
||
8050 |
void DomResourceIcon::setElementActiveOff(DomResourcePixmap* a) |
|
8051 |
{ |
|
8052 |
delete m_activeOff; |
|
8053 |
m_children |= ActiveOff; |
|
8054 |
m_activeOff = a; |
|
8055 |
} |
|
8056 |
||
8057 |
DomResourcePixmap* DomResourceIcon::takeElementActiveOn() |
|
8058 |
{ |
|
8059 |
DomResourcePixmap* a = m_activeOn; |
|
8060 |
m_activeOn = 0; |
|
8061 |
m_children ^= ActiveOn; |
|
8062 |
return a; |
|
8063 |
} |
|
8064 |
||
8065 |
void DomResourceIcon::setElementActiveOn(DomResourcePixmap* a) |
|
8066 |
{ |
|
8067 |
delete m_activeOn; |
|
8068 |
m_children |= ActiveOn; |
|
8069 |
m_activeOn = a; |
|
8070 |
} |
|
8071 |
||
8072 |
DomResourcePixmap* DomResourceIcon::takeElementSelectedOff() |
|
8073 |
{ |
|
8074 |
DomResourcePixmap* a = m_selectedOff; |
|
8075 |
m_selectedOff = 0; |
|
8076 |
m_children ^= SelectedOff; |
|
8077 |
return a; |
|
8078 |
} |
|
8079 |
||
8080 |
void DomResourceIcon::setElementSelectedOff(DomResourcePixmap* a) |
|
8081 |
{ |
|
8082 |
delete m_selectedOff; |
|
8083 |
m_children |= SelectedOff; |
|
8084 |
m_selectedOff = a; |
|
8085 |
} |
|
8086 |
||
8087 |
DomResourcePixmap* DomResourceIcon::takeElementSelectedOn() |
|
8088 |
{ |
|
8089 |
DomResourcePixmap* a = m_selectedOn; |
|
8090 |
m_selectedOn = 0; |
|
8091 |
m_children ^= SelectedOn; |
|
8092 |
return a; |
|
8093 |
} |
|
8094 |
||
8095 |
void DomResourceIcon::setElementSelectedOn(DomResourcePixmap* a) |
|
8096 |
{ |
|
8097 |
delete m_selectedOn; |
|
8098 |
m_children |= SelectedOn; |
|
8099 |
m_selectedOn = a; |
|
8100 |
} |
|
8101 |
||
8102 |
void DomResourceIcon::clearElementNormalOff() |
|
8103 |
{ |
|
8104 |
delete m_normalOff; |
|
8105 |
m_normalOff = 0; |
|
8106 |
m_children &= ~NormalOff; |
|
8107 |
} |
|
8108 |
||
8109 |
void DomResourceIcon::clearElementNormalOn() |
|
8110 |
{ |
|
8111 |
delete m_normalOn; |
|
8112 |
m_normalOn = 0; |
|
8113 |
m_children &= ~NormalOn; |
|
8114 |
} |
|
8115 |
||
8116 |
void DomResourceIcon::clearElementDisabledOff() |
|
8117 |
{ |
|
8118 |
delete m_disabledOff; |
|
8119 |
m_disabledOff = 0; |
|
8120 |
m_children &= ~DisabledOff; |
|
8121 |
} |
|
8122 |
||
8123 |
void DomResourceIcon::clearElementDisabledOn() |
|
8124 |
{ |
|
8125 |
delete m_disabledOn; |
|
8126 |
m_disabledOn = 0; |
|
8127 |
m_children &= ~DisabledOn; |
|
8128 |
} |
|
8129 |
||
8130 |
void DomResourceIcon::clearElementActiveOff() |
|
8131 |
{ |
|
8132 |
delete m_activeOff; |
|
8133 |
m_activeOff = 0; |
|
8134 |
m_children &= ~ActiveOff; |
|
8135 |
} |
|
8136 |
||
8137 |
void DomResourceIcon::clearElementActiveOn() |
|
8138 |
{ |
|
8139 |
delete m_activeOn; |
|
8140 |
m_activeOn = 0; |
|
8141 |
m_children &= ~ActiveOn; |
|
8142 |
} |
|
8143 |
||
8144 |
void DomResourceIcon::clearElementSelectedOff() |
|
8145 |
{ |
|
8146 |
delete m_selectedOff; |
|
8147 |
m_selectedOff = 0; |
|
8148 |
m_children &= ~SelectedOff; |
|
8149 |
} |
|
8150 |
||
8151 |
void DomResourceIcon::clearElementSelectedOn() |
|
8152 |
{ |
|
8153 |
delete m_selectedOn; |
|
8154 |
m_selectedOn = 0; |
|
8155 |
m_children &= ~SelectedOn; |
|
8156 |
} |
|
8157 |
||
8158 |
void DomString::clear(bool clear_all) |
|
8159 |
{ |
|
8160 |
||
8161 |
if (clear_all) { |
|
8162 |
m_text = QLatin1String(""); |
|
8163 |
m_has_attr_notr = false; |
|
8164 |
m_has_attr_comment = false; |
|
8165 |
m_has_attr_extraComment = false; |
|
8166 |
} |
|
8167 |
||
8168 |
m_children = 0; |
|
8169 |
} |
|
8170 |
||
8171 |
DomString::DomString() |
|
8172 |
{ |
|
8173 |
m_children = 0; |
|
8174 |
m_has_attr_notr = false; |
|
8175 |
m_has_attr_comment = false; |
|
8176 |
m_has_attr_extraComment = false; |
|
8177 |
m_text = QLatin1String(""); |
|
8178 |
} |
|
8179 |
||
8180 |
DomString::~DomString() |
|
8181 |
{ |
|
8182 |
} |
|
8183 |
||
8184 |
void DomString::read(QXmlStreamReader &reader) |
|
8185 |
{ |
|
8186 |
||
8187 |
foreach (const QXmlStreamAttribute &attribute, reader.attributes()) { |
|
8188 |
QStringRef name = attribute.name(); |
|
8189 |
if (name == QLatin1String("notr")) { |
|
8190 |
setAttributeNotr(attribute.value().toString()); |
|
8191 |
continue; |
|
8192 |
} |
|
8193 |
if (name == QLatin1String("comment")) { |
|
8194 |
setAttributeComment(attribute.value().toString()); |
|
8195 |
continue; |
|
8196 |
} |
|
8197 |
if (name == QLatin1String("extracomment")) { |
|
8198 |
setAttributeExtraComment(attribute.value().toString()); |
|
8199 |
continue; |
|
8200 |
} |
|
8201 |
reader.raiseError(QLatin1String("Unexpected attribute ") + name.toString()); |
|
8202 |
} |
|
8203 |
||
8204 |
for (bool finished = false; !finished && !reader.hasError();) { |
|
8205 |
switch (reader.readNext()) { |
|
8206 |
case QXmlStreamReader::StartElement : { |
|
8207 |
const QString tag = reader.name().toString().toLower(); |
|
8208 |
reader.raiseError(QLatin1String("Unexpected element ") + tag); |
|
8209 |
} |
|
8210 |
break; |
|
8211 |
case QXmlStreamReader::EndElement : |
|
8212 |
finished = true; |
|
8213 |
break; |
|
8214 |
case QXmlStreamReader::Characters : |
|
8215 |
if (!reader.isWhitespace()) |
|
8216 |
m_text.append(reader.text().toString()); |
|
8217 |
break; |
|
8218 |
default : |
|
8219 |
break; |
|
8220 |
} |
|
8221 |
} |
|
8222 |
} |
|
8223 |
||
8224 |
#ifdef QUILOADER_QDOM_READ |
|
8225 |
void DomString::read(const QDomElement &node) |
|
8226 |
{ |
|
8227 |
if (node.hasAttribute(QLatin1String("notr"))) |
|
8228 |
setAttributeNotr(node.attribute(QLatin1String("notr"))); |
|
8229 |
if (node.hasAttribute(QLatin1String("comment"))) |
|
8230 |
setAttributeComment(node.attribute(QLatin1String("comment"))); |
|
8231 |
if (node.hasAttribute(QLatin1String("extracomment"))) |
|
8232 |
setAttributeExtraComment(node.attribute(QLatin1String("extracomment"))); |
|
8233 |
||
8234 |
for (QDomNode n = node.firstChild(); !n.isNull(); n = n.nextSibling()) { |
|
8235 |
if (!n.isElement()) |
|
8236 |
continue; |
|
8237 |
QDomElement e = n.toElement(); |
|
8238 |
QString tag = e.tagName().toLower(); |
|
8239 |
} |
|
8240 |
m_text = QLatin1String(""); |
|
8241 |
for (QDomNode child = node.firstChild(); !child.isNull(); child = child.nextSibling()) { |
|
8242 |
if (child.isText()) |
|
8243 |
m_text.append(child.nodeValue()); |
|
8244 |
} |
|
8245 |
} |
|
8246 |
#endif |
|
8247 |
||
8248 |
void DomString::write(QXmlStreamWriter &writer, const QString &tagName) const |
|
8249 |
{ |
|
8250 |
writer.writeStartElement(tagName.isEmpty() ? QString::fromUtf8("string") : tagName.toLower()); |
|
8251 |
||
8252 |
if (hasAttributeNotr()) |
|
8253 |
writer.writeAttribute(QLatin1String("notr"), attributeNotr()); |
|
8254 |
||
8255 |
if (hasAttributeComment()) |
|
8256 |
writer.writeAttribute(QLatin1String("comment"), attributeComment()); |
|
8257 |
||
8258 |
if (hasAttributeExtraComment()) |
|
8259 |
writer.writeAttribute(QLatin1String("extracomment"), attributeExtraComment()); |
|
8260 |
||
8261 |
if (!m_text.isEmpty()) |
|
8262 |
writer.writeCharacters(m_text); |
|
8263 |
||
8264 |
writer.writeEndElement(); |
|
8265 |
} |
|
8266 |
||
8267 |
void DomPointF::clear(bool clear_all) |
|
8268 |
{ |
|
8269 |
||
8270 |
if (clear_all) { |
|
8271 |
m_text.clear(); |
|
8272 |
} |
|
8273 |
||
8274 |
m_children = 0; |
|
8275 |
m_x = 0; |
|
8276 |
m_y = 0; |
|
8277 |
} |
|
8278 |
||
8279 |
DomPointF::DomPointF() |
|
8280 |
{ |
|
8281 |
m_children = 0; |
|
8282 |
m_x = 0; |
|
8283 |
m_y = 0; |
|
8284 |
} |
|
8285 |
||
8286 |
DomPointF::~DomPointF() |
|
8287 |
{ |
|
8288 |
} |
|
8289 |
||
8290 |
void DomPointF::read(QXmlStreamReader &reader) |
|
8291 |
{ |
|
8292 |
||
8293 |
for (bool finished = false; !finished && !reader.hasError();) { |
|
8294 |
switch (reader.readNext()) { |
|
8295 |
case QXmlStreamReader::StartElement : { |
|
8296 |
const QString tag = reader.name().toString().toLower(); |
|
8297 |
if (tag == QString(QLatin1Char('x'))) { |
|
8298 |
setElementX(reader.readElementText().toDouble()); |
|
8299 |
continue; |
|
8300 |
} |
|
8301 |
if (tag == QString(QLatin1Char('y'))) { |
|
8302 |
setElementY(reader.readElementText().toDouble()); |
|
8303 |
continue; |
|
8304 |
} |
|
8305 |
reader.raiseError(QLatin1String("Unexpected element ") + tag); |
|
8306 |
} |
|
8307 |
break; |
|
8308 |
case QXmlStreamReader::EndElement : |
|
8309 |
finished = true; |
|
8310 |
break; |
|
8311 |
case QXmlStreamReader::Characters : |
|
8312 |
if (!reader.isWhitespace()) |
|
8313 |
m_text.append(reader.text().toString()); |
|
8314 |
break; |
|
8315 |
default : |
|
8316 |
break; |
|
8317 |
} |
|
8318 |
} |
|
8319 |
} |
|
8320 |
||
8321 |
#ifdef QUILOADER_QDOM_READ |
|
8322 |
void DomPointF::read(const QDomElement &node) |
|
8323 |
{ |
|
8324 |
for (QDomNode n = node.firstChild(); !n.isNull(); n = n.nextSibling()) { |
|
8325 |
if (!n.isElement()) |
|
8326 |
continue; |
|
8327 |
QDomElement e = n.toElement(); |
|
8328 |
QString tag = e.tagName().toLower(); |
|
8329 |
if (tag == QString(QLatin1Char('x'))) { |
|
8330 |
setElementX(e.text().toDouble()); |
|
8331 |
continue; |
|
8332 |
} |
|
8333 |
if (tag == QString(QLatin1Char('y'))) { |
|
8334 |
setElementY(e.text().toDouble()); |
|
8335 |
continue; |
|
8336 |
} |
|
8337 |
} |
|
8338 |
m_text.clear(); |
|
8339 |
for (QDomNode child = node.firstChild(); !child.isNull(); child = child.nextSibling()) { |
|
8340 |
if (child.isText()) |
|
8341 |
m_text.append(child.nodeValue()); |
|
8342 |
} |
|
8343 |
} |
|
8344 |
#endif |
|
8345 |
||
8346 |
void DomPointF::write(QXmlStreamWriter &writer, const QString &tagName) const |
|
8347 |
{ |
|
8348 |
writer.writeStartElement(tagName.isEmpty() ? QString::fromUtf8("pointf") : tagName.toLower()); |
|
8349 |
||
8350 |
if (m_children & X) { |
|
8351 |
writer.writeTextElement(QString(QLatin1Char('x')), QString::number(m_x, 'f', 15)); |
|
8352 |
} |
|
8353 |
||
8354 |
if (m_children & Y) { |
|
8355 |
writer.writeTextElement(QString(QLatin1Char('y')), QString::number(m_y, 'f', 15)); |
|
8356 |
} |
|
8357 |
||
8358 |
if (!m_text.isEmpty()) |
|
8359 |
writer.writeCharacters(m_text); |
|
8360 |
||
8361 |
writer.writeEndElement(); |
|
8362 |
} |
|
8363 |
||
8364 |
void DomPointF::setElementX(double a) |
|
8365 |
{ |
|
8366 |
m_children |= X; |
|
8367 |
m_x = a; |
|
8368 |
} |
|
8369 |
||
8370 |
void DomPointF::setElementY(double a) |
|
8371 |
{ |
|
8372 |
m_children |= Y; |
|
8373 |
m_y = a; |
|
8374 |
} |
|
8375 |
||
8376 |
void DomPointF::clearElementX() |
|
8377 |
{ |
|
8378 |
m_children &= ~X; |
|
8379 |
} |
|
8380 |
||
8381 |
void DomPointF::clearElementY() |
|
8382 |
{ |
|
8383 |
m_children &= ~Y; |
|
8384 |
} |
|
8385 |
||
8386 |
void DomRectF::clear(bool clear_all) |
|
8387 |
{ |
|
8388 |
||
8389 |
if (clear_all) { |
|
8390 |
m_text.clear(); |
|
8391 |
} |
|
8392 |
||
8393 |
m_children = 0; |
|
8394 |
m_x = 0; |
|
8395 |
m_y = 0; |
|
8396 |
m_width = 0; |
|
8397 |
m_height = 0; |
|
8398 |
} |
|
8399 |
||
8400 |
DomRectF::DomRectF() |
|
8401 |
{ |
|
8402 |
m_children = 0; |
|
8403 |
m_x = 0; |
|
8404 |
m_y = 0; |
|
8405 |
m_width = 0; |
|
8406 |
m_height = 0; |
|
8407 |
} |
|
8408 |
||
8409 |
DomRectF::~DomRectF() |
|
8410 |
{ |
|
8411 |
} |
|
8412 |
||
8413 |
void DomRectF::read(QXmlStreamReader &reader) |
|
8414 |
{ |
|
8415 |
||
8416 |
for (bool finished = false; !finished && !reader.hasError();) { |
|
8417 |
switch (reader.readNext()) { |
|
8418 |
case QXmlStreamReader::StartElement : { |
|
8419 |
const QString tag = reader.name().toString().toLower(); |
|
8420 |
if (tag == QString(QLatin1Char('x'))) { |
|
8421 |
setElementX(reader.readElementText().toDouble()); |
|
8422 |
continue; |
|
8423 |
} |
|
8424 |
if (tag == QString(QLatin1Char('y'))) { |
|
8425 |
setElementY(reader.readElementText().toDouble()); |
|
8426 |
continue; |
|
8427 |
} |
|
8428 |
if (tag == QLatin1String("width")) { |
|
8429 |
setElementWidth(reader.readElementText().toDouble()); |
|
8430 |
continue; |
|
8431 |
} |
|
8432 |
if (tag == QLatin1String("height")) { |
|
8433 |
setElementHeight(reader.readElementText().toDouble()); |
|
8434 |
continue; |
|
8435 |
} |
|
8436 |
reader.raiseError(QLatin1String("Unexpected element ") + tag); |
|
8437 |
} |
|
8438 |
break; |
|
8439 |
case QXmlStreamReader::EndElement : |
|
8440 |
finished = true; |
|
8441 |
break; |
|
8442 |
case QXmlStreamReader::Characters : |
|
8443 |
if (!reader.isWhitespace()) |
|
8444 |
m_text.append(reader.text().toString()); |
|
8445 |
break; |
|
8446 |
default : |
|
8447 |
break; |
|
8448 |
} |
|
8449 |
} |
|
8450 |
} |
|
8451 |
||
8452 |
#ifdef QUILOADER_QDOM_READ |
|
8453 |
void DomRectF::read(const QDomElement &node) |
|
8454 |
{ |
|
8455 |
for (QDomNode n = node.firstChild(); !n.isNull(); n = n.nextSibling()) { |
|
8456 |
if (!n.isElement()) |
|
8457 |
continue; |
|
8458 |
QDomElement e = n.toElement(); |
|
8459 |
QString tag = e.tagName().toLower(); |
|
8460 |
if (tag == QString(QLatin1Char('x'))) { |
|
8461 |
setElementX(e.text().toDouble()); |
|
8462 |
continue; |
|
8463 |
} |
|
8464 |
if (tag == QString(QLatin1Char('y'))) { |
|
8465 |
setElementY(e.text().toDouble()); |
|
8466 |
continue; |
|
8467 |
} |
|
8468 |
if (tag == QLatin1String("width")) { |
|
8469 |
setElementWidth(e.text().toDouble()); |
|
8470 |
continue; |
|
8471 |
} |
|
8472 |
if (tag == QLatin1String("height")) { |
|
8473 |
setElementHeight(e.text().toDouble()); |
|
8474 |
continue; |
|
8475 |
} |
|
8476 |
} |
|
8477 |
m_text.clear(); |
|
8478 |
for (QDomNode child = node.firstChild(); !child.isNull(); child = child.nextSibling()) { |
|
8479 |
if (child.isText()) |
|
8480 |
m_text.append(child.nodeValue()); |
|
8481 |
} |
|
8482 |
} |
|
8483 |
#endif |
|
8484 |
||
8485 |
void DomRectF::write(QXmlStreamWriter &writer, const QString &tagName) const |
|
8486 |
{ |
|
8487 |
writer.writeStartElement(tagName.isEmpty() ? QString::fromUtf8("rectf") : tagName.toLower()); |
|
8488 |
||
8489 |
if (m_children & X) { |
|
8490 |
writer.writeTextElement(QString(QLatin1Char('x')), QString::number(m_x, 'f', 15)); |
|
8491 |
} |
|
8492 |
||
8493 |
if (m_children & Y) { |
|
8494 |
writer.writeTextElement(QString(QLatin1Char('y')), QString::number(m_y, 'f', 15)); |
|
8495 |
} |
|
8496 |
||
8497 |
if (m_children & Width) { |
|
8498 |
writer.writeTextElement(QLatin1String("width"), QString::number(m_width, 'f', 15)); |
|
8499 |
} |
|
8500 |
||
8501 |
if (m_children & Height) { |
|
8502 |
writer.writeTextElement(QLatin1String("height"), QString::number(m_height, 'f', 15)); |
|
8503 |
} |
|
8504 |
||
8505 |
if (!m_text.isEmpty()) |
|
8506 |
writer.writeCharacters(m_text); |
|
8507 |
||
8508 |
writer.writeEndElement(); |
|
8509 |
} |
|
8510 |
||
8511 |
void DomRectF::setElementX(double a) |
|
8512 |
{ |
|
8513 |
m_children |= X; |
|
8514 |
m_x = a; |
|
8515 |
} |
|
8516 |
||
8517 |
void DomRectF::setElementY(double a) |
|
8518 |
{ |
|
8519 |
m_children |= Y; |
|
8520 |
m_y = a; |
|
8521 |
} |
|
8522 |
||
8523 |
void DomRectF::setElementWidth(double a) |
|
8524 |
{ |
|
8525 |
m_children |= Width; |
|
8526 |
m_width = a; |
|
8527 |
} |
|
8528 |
||
8529 |
void DomRectF::setElementHeight(double a) |
|
8530 |
{ |
|
8531 |
m_children |= Height; |
|
8532 |
m_height = a; |
|
8533 |
} |
|
8534 |
||
8535 |
void DomRectF::clearElementX() |
|
8536 |
{ |
|
8537 |
m_children &= ~X; |
|
8538 |
} |
|
8539 |
||
8540 |
void DomRectF::clearElementY() |
|
8541 |
{ |
|
8542 |
m_children &= ~Y; |
|
8543 |
} |
|
8544 |
||
8545 |
void DomRectF::clearElementWidth() |
|
8546 |
{ |
|
8547 |
m_children &= ~Width; |
|
8548 |
} |
|
8549 |
||
8550 |
void DomRectF::clearElementHeight() |
|
8551 |
{ |
|
8552 |
m_children &= ~Height; |
|
8553 |
} |
|
8554 |
||
8555 |
void DomSizeF::clear(bool clear_all) |
|
8556 |
{ |
|
8557 |
||
8558 |
if (clear_all) { |
|
8559 |
m_text.clear(); |
|
8560 |
} |
|
8561 |
||
8562 |
m_children = 0; |
|
8563 |
m_width = 0; |
|
8564 |
m_height = 0; |
|
8565 |
} |
|
8566 |
||
8567 |
DomSizeF::DomSizeF() |
|
8568 |
{ |
|
8569 |
m_children = 0; |
|
8570 |
m_width = 0; |
|
8571 |
m_height = 0; |
|
8572 |
} |
|
8573 |
||
8574 |
DomSizeF::~DomSizeF() |
|
8575 |
{ |
|
8576 |
} |
|
8577 |
||
8578 |
void DomSizeF::read(QXmlStreamReader &reader) |
|
8579 |
{ |
|
8580 |
||
8581 |
for (bool finished = false; !finished && !reader.hasError();) { |
|
8582 |
switch (reader.readNext()) { |
|
8583 |
case QXmlStreamReader::StartElement : { |
|
8584 |
const QString tag = reader.name().toString().toLower(); |
|
8585 |
if (tag == QLatin1String("width")) { |
|
8586 |
setElementWidth(reader.readElementText().toDouble()); |
|
8587 |
continue; |
|
8588 |
} |
|
8589 |
if (tag == QLatin1String("height")) { |
|
8590 |
setElementHeight(reader.readElementText().toDouble()); |
|
8591 |
continue; |
|
8592 |
} |
|
8593 |
reader.raiseError(QLatin1String("Unexpected element ") + tag); |
|
8594 |
} |
|
8595 |
break; |
|
8596 |
case QXmlStreamReader::EndElement : |
|
8597 |
finished = true; |
|
8598 |
break; |
|
8599 |
case QXmlStreamReader::Characters : |
|
8600 |
if (!reader.isWhitespace()) |
|
8601 |
m_text.append(reader.text().toString()); |
|
8602 |
break; |
|
8603 |
default : |
|
8604 |
break; |
|
8605 |
} |
|
8606 |
} |
|
8607 |
} |
|
8608 |
||
8609 |
#ifdef QUILOADER_QDOM_READ |
|
8610 |
void DomSizeF::read(const QDomElement &node) |
|
8611 |
{ |
|
8612 |
for (QDomNode n = node.firstChild(); !n.isNull(); n = n.nextSibling()) { |
|
8613 |
if (!n.isElement()) |
|
8614 |
continue; |
|
8615 |
QDomElement e = n.toElement(); |
|
8616 |
QString tag = e.tagName().toLower(); |
|
8617 |
if (tag == QLatin1String("width")) { |
|
8618 |
setElementWidth(e.text().toDouble()); |
|
8619 |
continue; |
|
8620 |
} |
|
8621 |
if (tag == QLatin1String("height")) { |
|
8622 |
setElementHeight(e.text().toDouble()); |
|
8623 |
continue; |
|
8624 |
} |
|
8625 |
} |
|
8626 |
m_text.clear(); |
|
8627 |
for (QDomNode child = node.firstChild(); !child.isNull(); child = child.nextSibling()) { |
|
8628 |
if (child.isText()) |
|
8629 |
m_text.append(child.nodeValue()); |
|
8630 |
} |
|
8631 |
} |
|
8632 |
#endif |
|
8633 |
||
8634 |
void DomSizeF::write(QXmlStreamWriter &writer, const QString &tagName) const |
|
8635 |
{ |
|
8636 |
writer.writeStartElement(tagName.isEmpty() ? QString::fromUtf8("sizef") : tagName.toLower()); |
|
8637 |
||
8638 |
if (m_children & Width) { |
|
8639 |
writer.writeTextElement(QLatin1String("width"), QString::number(m_width, 'f', 15)); |
|
8640 |
} |
|
8641 |
||
8642 |
if (m_children & Height) { |
|
8643 |
writer.writeTextElement(QLatin1String("height"), QString::number(m_height, 'f', 15)); |
|
8644 |
} |
|
8645 |
||
8646 |
if (!m_text.isEmpty()) |
|
8647 |
writer.writeCharacters(m_text); |
|
8648 |
||
8649 |
writer.writeEndElement(); |
|
8650 |
} |
|
8651 |
||
8652 |
void DomSizeF::setElementWidth(double a) |
|
8653 |
{ |
|
8654 |
m_children |= Width; |
|
8655 |
m_width = a; |
|
8656 |
} |
|
8657 |
||
8658 |
void DomSizeF::setElementHeight(double a) |
|
8659 |
{ |
|
8660 |
m_children |= Height; |
|
8661 |
m_height = a; |
|
8662 |
} |
|
8663 |
||
8664 |
void DomSizeF::clearElementWidth() |
|
8665 |
{ |
|
8666 |
m_children &= ~Width; |
|
8667 |
} |
|
8668 |
||
8669 |
void DomSizeF::clearElementHeight() |
|
8670 |
{ |
|
8671 |
m_children &= ~Height; |
|
8672 |
} |
|
8673 |
||
8674 |
void DomChar::clear(bool clear_all) |
|
8675 |
{ |
|
8676 |
||
8677 |
if (clear_all) { |
|
8678 |
m_text.clear(); |
|
8679 |
} |
|
8680 |
||
8681 |
m_children = 0; |
|
8682 |
m_unicode = 0; |
|
8683 |
} |
|
8684 |
||
8685 |
DomChar::DomChar() |
|
8686 |
{ |
|
8687 |
m_children = 0; |
|
8688 |
m_unicode = 0; |
|
8689 |
} |
|
8690 |
||
8691 |
DomChar::~DomChar() |
|
8692 |
{ |
|
8693 |
} |
|
8694 |
||
8695 |
void DomChar::read(QXmlStreamReader &reader) |
|
8696 |
{ |
|
8697 |
||
8698 |
for (bool finished = false; !finished && !reader.hasError();) { |
|
8699 |
switch (reader.readNext()) { |
|
8700 |
case QXmlStreamReader::StartElement : { |
|
8701 |
const QString tag = reader.name().toString().toLower(); |
|
8702 |
if (tag == QLatin1String("unicode")) { |
|
8703 |
setElementUnicode(reader.readElementText().toInt()); |
|
8704 |
continue; |
|
8705 |
} |
|
8706 |
reader.raiseError(QLatin1String("Unexpected element ") + tag); |
|
8707 |
} |
|
8708 |
break; |
|
8709 |
case QXmlStreamReader::EndElement : |
|
8710 |
finished = true; |
|
8711 |
break; |
|
8712 |
case QXmlStreamReader::Characters : |
|
8713 |
if (!reader.isWhitespace()) |
|
8714 |
m_text.append(reader.text().toString()); |
|
8715 |
break; |
|
8716 |
default : |
|
8717 |
break; |
|
8718 |
} |
|
8719 |
} |
|
8720 |
} |
|
8721 |
||
8722 |
#ifdef QUILOADER_QDOM_READ |
|
8723 |
void DomChar::read(const QDomElement &node) |
|
8724 |
{ |
|
8725 |
for (QDomNode n = node.firstChild(); !n.isNull(); n = n.nextSibling()) { |
|
8726 |
if (!n.isElement()) |
|
8727 |
continue; |
|
8728 |
QDomElement e = n.toElement(); |
|
8729 |
QString tag = e.tagName().toLower(); |
|
8730 |
if (tag == QLatin1String("unicode")) { |
|
8731 |
setElementUnicode(e.text().toInt()); |
|
8732 |
continue; |
|
8733 |
} |
|
8734 |
} |
|
8735 |
m_text.clear(); |
|
8736 |
for (QDomNode child = node.firstChild(); !child.isNull(); child = child.nextSibling()) { |
|
8737 |
if (child.isText()) |
|
8738 |
m_text.append(child.nodeValue()); |
|
8739 |
} |
|
8740 |
} |
|
8741 |
#endif |
|
8742 |
||
8743 |
void DomChar::write(QXmlStreamWriter &writer, const QString &tagName) const |
|
8744 |
{ |
|
8745 |
writer.writeStartElement(tagName.isEmpty() ? QString::fromUtf8("char") : tagName.toLower()); |
|
8746 |
||
8747 |
if (m_children & Unicode) { |
|
8748 |
writer.writeTextElement(QLatin1String("unicode"), QString::number(m_unicode)); |
|
8749 |
} |
|
8750 |
||
8751 |
if (!m_text.isEmpty()) |
|
8752 |
writer.writeCharacters(m_text); |
|
8753 |
||
8754 |
writer.writeEndElement(); |
|
8755 |
} |
|
8756 |
||
8757 |
void DomChar::setElementUnicode(int a) |
|
8758 |
{ |
|
8759 |
m_children |= Unicode; |
|
8760 |
m_unicode = a; |
|
8761 |
} |
|
8762 |
||
8763 |
void DomChar::clearElementUnicode() |
|
8764 |
{ |
|
8765 |
m_children &= ~Unicode; |
|
8766 |
} |
|
8767 |
||
8768 |
void DomUrl::clear(bool clear_all) |
|
8769 |
{ |
|
8770 |
delete m_string; |
|
8771 |
||
8772 |
if (clear_all) { |
|
8773 |
m_text.clear(); |
|
8774 |
} |
|
8775 |
||
8776 |
m_children = 0; |
|
8777 |
m_string = 0; |
|
8778 |
} |
|
8779 |
||
8780 |
DomUrl::DomUrl() |
|
8781 |
{ |
|
8782 |
m_children = 0; |
|
8783 |
m_string = 0; |
|
8784 |
} |
|
8785 |
||
8786 |
DomUrl::~DomUrl() |
|
8787 |
{ |
|
8788 |
delete m_string; |
|
8789 |
} |
|
8790 |
||
8791 |
void DomUrl::read(QXmlStreamReader &reader) |
|
8792 |
{ |
|
8793 |
||
8794 |
for (bool finished = false; !finished && !reader.hasError();) { |
|
8795 |
switch (reader.readNext()) { |
|
8796 |
case QXmlStreamReader::StartElement : { |
|
8797 |
const QString tag = reader.name().toString().toLower(); |
|
8798 |
if (tag == QLatin1String("string")) { |
|
8799 |
DomString *v = new DomString(); |
|
8800 |
v->read(reader); |
|
8801 |
setElementString(v); |
|
8802 |
continue; |
|
8803 |
} |
|
8804 |
reader.raiseError(QLatin1String("Unexpected element ") + tag); |
|
8805 |
} |
|
8806 |
break; |
|
8807 |
case QXmlStreamReader::EndElement : |
|
8808 |
finished = true; |
|
8809 |
break; |
|
8810 |
case QXmlStreamReader::Characters : |
|
8811 |
if (!reader.isWhitespace()) |
|
8812 |
m_text.append(reader.text().toString()); |
|
8813 |
break; |
|
8814 |
default : |
|
8815 |
break; |
|
8816 |
} |
|
8817 |
} |
|
8818 |
} |
|
8819 |
||
8820 |
#ifdef QUILOADER_QDOM_READ |
|
8821 |
void DomUrl::read(const QDomElement &node) |
|
8822 |
{ |
|
8823 |
for (QDomNode n = node.firstChild(); !n.isNull(); n = n.nextSibling()) { |
|
8824 |
if (!n.isElement()) |
|
8825 |
continue; |
|
8826 |
QDomElement e = n.toElement(); |
|
8827 |
QString tag = e.tagName().toLower(); |
|
8828 |
if (tag == QLatin1String("string")) { |
|
8829 |
DomString *v = new DomString(); |
|
8830 |
v->read(e); |
|
8831 |
setElementString(v); |
|
8832 |
continue; |
|
8833 |
} |
|
8834 |
} |
|
8835 |
m_text.clear(); |
|
8836 |
for (QDomNode child = node.firstChild(); !child.isNull(); child = child.nextSibling()) { |
|
8837 |
if (child.isText()) |
|
8838 |
m_text.append(child.nodeValue()); |
|
8839 |
} |
|
8840 |
} |
|
8841 |
#endif |
|
8842 |
||
8843 |
void DomUrl::write(QXmlStreamWriter &writer, const QString &tagName) const |
|
8844 |
{ |
|
8845 |
writer.writeStartElement(tagName.isEmpty() ? QString::fromUtf8("url") : tagName.toLower()); |
|
8846 |
||
8847 |
if (m_children & String) { |
|
8848 |
m_string->write(writer, QLatin1String("string")); |
|
8849 |
} |
|
8850 |
||
8851 |
if (!m_text.isEmpty()) |
|
8852 |
writer.writeCharacters(m_text); |
|
8853 |
||
8854 |
writer.writeEndElement(); |
|
8855 |
} |
|
8856 |
||
8857 |
DomString* DomUrl::takeElementString() |
|
8858 |
{ |
|
8859 |
DomString* a = m_string; |
|
8860 |
m_string = 0; |
|
8861 |
m_children ^= String; |
|
8862 |
return a; |
|
8863 |
} |
|
8864 |
||
8865 |
void DomUrl::setElementString(DomString* a) |
|
8866 |
{ |
|
8867 |
delete m_string; |
|
8868 |
m_children |= String; |
|
8869 |
m_string = a; |
|
8870 |
} |
|
8871 |
||
8872 |
void DomUrl::clearElementString() |
|
8873 |
{ |
|
8874 |
delete m_string; |
|
8875 |
m_string = 0; |
|
8876 |
m_children &= ~String; |
|
8877 |
} |
|
8878 |
||
8879 |
void DomProperty::clear(bool clear_all) |
|
8880 |
{ |
|
8881 |
delete m_color; |
|
8882 |
delete m_font; |
|
8883 |
delete m_iconSet; |
|
8884 |
delete m_pixmap; |
|
8885 |
delete m_palette; |
|
8886 |
delete m_point; |
|
8887 |
delete m_rect; |
|
8888 |
delete m_locale; |
|
8889 |
delete m_sizePolicy; |
|
8890 |
delete m_size; |
|
8891 |
delete m_string; |
|
8892 |
delete m_stringList; |
|
8893 |
delete m_date; |
|
8894 |
delete m_time; |
|
8895 |
delete m_dateTime; |
|
8896 |
delete m_pointF; |
|
8897 |
delete m_rectF; |
|
8898 |
delete m_sizeF; |
|
8899 |
delete m_char; |
|
8900 |
delete m_url; |
|
8901 |
delete m_brush; |
|
8902 |
||
8903 |
if (clear_all) { |
|
8904 |
m_text.clear(); |
|
8905 |
m_has_attr_name = false; |
|
8906 |
m_has_attr_stdset = false; |
|
8907 |
m_attr_stdset = 0; |
|
8908 |
} |
|
8909 |
||
8910 |
m_kind = Unknown; |
|
8911 |
||
8912 |
m_color = 0; |
|
8913 |
m_cursor = 0; |
|
8914 |
m_font = 0; |
|
8915 |
m_iconSet = 0; |
|
8916 |
m_pixmap = 0; |
|
8917 |
m_palette = 0; |
|
8918 |
m_point = 0; |
|
8919 |
m_rect = 0; |
|
8920 |
m_locale = 0; |
|
8921 |
m_sizePolicy = 0; |
|
8922 |
m_size = 0; |
|
8923 |
m_string = 0; |
|
8924 |
m_stringList = 0; |
|
8925 |
m_number = 0; |
|
8926 |
m_float = 0.0; |
|
8927 |
m_double = 0; |
|
8928 |
m_date = 0; |
|
8929 |
m_time = 0; |
|
8930 |
m_dateTime = 0; |
|
8931 |
m_pointF = 0; |
|
8932 |
m_rectF = 0; |
|
8933 |
m_sizeF = 0; |
|
8934 |
m_longLong = 0; |
|
8935 |
m_char = 0; |
|
8936 |
m_url = 0; |
|
8937 |
m_UInt = 0; |
|
8938 |
m_uLongLong = 0; |
|
8939 |
m_brush = 0; |
|
8940 |
} |
|
8941 |
||
8942 |
DomProperty::DomProperty() |
|
8943 |
{ |
|
8944 |
m_kind = Unknown; |
|
8945 |
||
8946 |
m_has_attr_name = false; |
|
8947 |
m_has_attr_stdset = false; |
|
8948 |
m_attr_stdset = 0; |
|
8949 |
m_color = 0; |
|
8950 |
m_cursor = 0; |
|
8951 |
m_font = 0; |
|
8952 |
m_iconSet = 0; |
|
8953 |
m_pixmap = 0; |
|
8954 |
m_palette = 0; |
|
8955 |
m_point = 0; |
|
8956 |
m_rect = 0; |
|
8957 |
m_locale = 0; |
|
8958 |
m_sizePolicy = 0; |
|
8959 |
m_size = 0; |
|
8960 |
m_string = 0; |
|
8961 |
m_stringList = 0; |
|
8962 |
m_number = 0; |
|
8963 |
m_float = 0.0; |
|
8964 |
m_double = 0; |
|
8965 |
m_date = 0; |
|
8966 |
m_time = 0; |
|
8967 |
m_dateTime = 0; |
|
8968 |
m_pointF = 0; |
|
8969 |
m_rectF = 0; |
|
8970 |
m_sizeF = 0; |
|
8971 |
m_longLong = 0; |
|
8972 |
m_char = 0; |
|
8973 |
m_url = 0; |
|
8974 |
m_UInt = 0; |
|
8975 |
m_uLongLong = 0; |
|
8976 |
m_brush = 0; |
|
8977 |
} |
|
8978 |
||
8979 |
DomProperty::~DomProperty() |
|
8980 |
{ |
|
8981 |
delete m_color; |
|
8982 |
delete m_font; |
|
8983 |
delete m_iconSet; |
|
8984 |
delete m_pixmap; |
|
8985 |
delete m_palette; |
|
8986 |
delete m_point; |
|
8987 |
delete m_rect; |
|
8988 |
delete m_locale; |
|
8989 |
delete m_sizePolicy; |
|
8990 |
delete m_size; |
|
8991 |
delete m_string; |
|
8992 |
delete m_stringList; |
|
8993 |
delete m_date; |
|
8994 |
delete m_time; |
|
8995 |
delete m_dateTime; |
|
8996 |
delete m_pointF; |
|
8997 |
delete m_rectF; |
|
8998 |
delete m_sizeF; |
|
8999 |
delete m_char; |
|
9000 |
delete m_url; |
|
9001 |
delete m_brush; |
|
9002 |
} |
|
9003 |
||
9004 |
void DomProperty::read(QXmlStreamReader &reader) |
|
9005 |
{ |
|
9006 |
||
9007 |
foreach (const QXmlStreamAttribute &attribute, reader.attributes()) { |
|
9008 |
QStringRef name = attribute.name(); |
|
9009 |
if (name == QLatin1String("name")) { |
|
9010 |
setAttributeName(attribute.value().toString()); |
|
9011 |
continue; |
|
9012 |
} |
|
9013 |
if (name == QLatin1String("stdset")) { |
|
9014 |
setAttributeStdset(attribute.value().toString().toInt()); |
|
9015 |
continue; |
|
9016 |
} |
|
9017 |
reader.raiseError(QLatin1String("Unexpected attribute ") + name.toString()); |
|
9018 |
} |
|
9019 |
||
9020 |
for (bool finished = false; !finished && !reader.hasError();) { |
|
9021 |
switch (reader.readNext()) { |
|
9022 |
case QXmlStreamReader::StartElement : { |
|
9023 |
const QString tag = reader.name().toString().toLower(); |
|
9024 |
if (tag == QLatin1String("bool")) { |
|
9025 |
setElementBool(reader.readElementText()); |
|
9026 |
continue; |
|
9027 |
} |
|
9028 |
if (tag == QLatin1String("color")) { |
|
9029 |
DomColor *v = new DomColor(); |
|
9030 |
v->read(reader); |
|
9031 |
setElementColor(v); |
|
9032 |
continue; |
|
9033 |
} |
|
9034 |
if (tag == QLatin1String("cstring")) { |
|
9035 |
setElementCstring(reader.readElementText()); |
|
9036 |
continue; |
|
9037 |
} |
|
9038 |
if (tag == QLatin1String("cursor")) { |
|
9039 |
setElementCursor(reader.readElementText().toInt()); |
|
9040 |
continue; |
|
9041 |
} |
|
9042 |
if (tag == QLatin1String("cursorshape")) { |
|
9043 |
setElementCursorShape(reader.readElementText()); |
|
9044 |
continue; |
|
9045 |
} |
|
9046 |
if (tag == QLatin1String("enum")) { |
|
9047 |
setElementEnum(reader.readElementText()); |
|
9048 |
continue; |
|
9049 |
} |
|
9050 |
if (tag == QLatin1String("font")) { |
|
9051 |
DomFont *v = new DomFont(); |
|
9052 |
v->read(reader); |
|
9053 |
setElementFont(v); |
|
9054 |
continue; |
|
9055 |
} |
|
9056 |
if (tag == QLatin1String("iconset")) { |
|
9057 |
DomResourceIcon *v = new DomResourceIcon(); |
|
9058 |
v->read(reader); |
|
9059 |
setElementIconSet(v); |
|
9060 |
continue; |
|
9061 |
} |
|
9062 |
if (tag == QLatin1String("pixmap")) { |
|
9063 |
DomResourcePixmap *v = new DomResourcePixmap(); |
|
9064 |
v->read(reader); |
|
9065 |
setElementPixmap(v); |
|
9066 |
continue; |
|
9067 |
} |
|
9068 |
if (tag == QLatin1String("palette")) { |
|
9069 |
DomPalette *v = new DomPalette(); |
|
9070 |
v->read(reader); |
|
9071 |
setElementPalette(v); |
|
9072 |
continue; |
|
9073 |
} |
|
9074 |
if (tag == QLatin1String("point")) { |
|
9075 |
DomPoint *v = new DomPoint(); |
|
9076 |
v->read(reader); |
|
9077 |
setElementPoint(v); |
|
9078 |
continue; |
|
9079 |
} |
|
9080 |
if (tag == QLatin1String("rect")) { |
|
9081 |
DomRect *v = new DomRect(); |
|
9082 |
v->read(reader); |
|
9083 |
setElementRect(v); |
|
9084 |
continue; |
|
9085 |
} |
|
9086 |
if (tag == QLatin1String("set")) { |
|
9087 |
setElementSet(reader.readElementText()); |
|
9088 |
continue; |
|
9089 |
} |
|
9090 |
if (tag == QLatin1String("locale")) { |
|
9091 |
DomLocale *v = new DomLocale(); |
|
9092 |
v->read(reader); |
|
9093 |
setElementLocale(v); |
|
9094 |
continue; |
|
9095 |
} |
|
9096 |
if (tag == QLatin1String("sizepolicy")) { |
|
9097 |
DomSizePolicy *v = new DomSizePolicy(); |
|
9098 |
v->read(reader); |
|
9099 |
setElementSizePolicy(v); |
|
9100 |
continue; |
|
9101 |
} |
|
9102 |
if (tag == QLatin1String("size")) { |
|
9103 |
DomSize *v = new DomSize(); |
|
9104 |
v->read(reader); |
|
9105 |
setElementSize(v); |
|
9106 |
continue; |
|
9107 |
} |
|
9108 |
if (tag == QLatin1String("string")) { |
|
9109 |
DomString *v = new DomString(); |
|
9110 |
v->read(reader); |
|
9111 |
setElementString(v); |
|
9112 |
continue; |
|
9113 |
} |
|
9114 |
if (tag == QLatin1String("stringlist")) { |
|
9115 |
DomStringList *v = new DomStringList(); |
|
9116 |
v->read(reader); |
|
9117 |
setElementStringList(v); |
|
9118 |
continue; |
|
9119 |
} |
|
9120 |
if (tag == QLatin1String("number")) { |
|
9121 |
setElementNumber(reader.readElementText().toInt()); |
|
9122 |
continue; |
|
9123 |
} |
|
9124 |
if (tag == QLatin1String("float")) { |
|
9125 |
setElementFloat(reader.readElementText().toFloat()); |
|
9126 |
continue; |
|
9127 |
} |
|
9128 |
if (tag == QLatin1String("double")) { |
|
9129 |
setElementDouble(reader.readElementText().toDouble()); |
|
9130 |
continue; |
|
9131 |
} |
|
9132 |
if (tag == QLatin1String("date")) { |
|
9133 |
DomDate *v = new DomDate(); |
|
9134 |
v->read(reader); |
|
9135 |
setElementDate(v); |
|
9136 |
continue; |
|
9137 |
} |
|
9138 |
if (tag == QLatin1String("time")) { |
|
9139 |
DomTime *v = new DomTime(); |
|
9140 |
v->read(reader); |
|
9141 |
setElementTime(v); |
|
9142 |
continue; |
|
9143 |
} |
|
9144 |
if (tag == QLatin1String("datetime")) { |
|
9145 |
DomDateTime *v = new DomDateTime(); |
|
9146 |
v->read(reader); |
|
9147 |
setElementDateTime(v); |
|
9148 |
continue; |
|
9149 |
} |
|
9150 |
if (tag == QLatin1String("pointf")) { |
|
9151 |
DomPointF *v = new DomPointF(); |
|
9152 |
v->read(reader); |
|
9153 |
setElementPointF(v); |
|
9154 |
continue; |
|
9155 |
} |
|
9156 |
if (tag == QLatin1String("rectf")) { |
|
9157 |
DomRectF *v = new DomRectF(); |
|
9158 |
v->read(reader); |
|
9159 |
setElementRectF(v); |
|
9160 |
continue; |
|
9161 |
} |
|
9162 |
if (tag == QLatin1String("sizef")) { |
|
9163 |
DomSizeF *v = new DomSizeF(); |
|
9164 |
v->read(reader); |
|
9165 |
setElementSizeF(v); |
|
9166 |
continue; |
|
9167 |
} |
|
9168 |
if (tag == QLatin1String("longlong")) { |
|
9169 |
setElementLongLong(reader.readElementText().toLongLong()); |
|
9170 |
continue; |
|
9171 |
} |
|
9172 |
if (tag == QLatin1String("char")) { |
|
9173 |
DomChar *v = new DomChar(); |
|
9174 |
v->read(reader); |
|
9175 |
setElementChar(v); |
|
9176 |
continue; |
|
9177 |
} |
|
9178 |
if (tag == QLatin1String("url")) { |
|
9179 |
DomUrl *v = new DomUrl(); |
|
9180 |
v->read(reader); |
|
9181 |
setElementUrl(v); |
|
9182 |
continue; |
|
9183 |
} |
|
9184 |
if (tag == QLatin1String("uint")) { |
|
9185 |
setElementUInt(reader.readElementText().toUInt()); |
|
9186 |
continue; |
|
9187 |
} |
|
9188 |
if (tag == QLatin1String("ulonglong")) { |
|
9189 |
setElementULongLong(reader.readElementText().toULongLong()); |
|
9190 |
continue; |
|
9191 |
} |
|
9192 |
if (tag == QLatin1String("brush")) { |
|
9193 |
DomBrush *v = new DomBrush(); |
|
9194 |
v->read(reader); |
|
9195 |
setElementBrush(v); |
|
9196 |
continue; |
|
9197 |
} |
|
9198 |
reader.raiseError(QLatin1String("Unexpected element ") + tag); |
|
9199 |
} |
|
9200 |
break; |
|
9201 |
case QXmlStreamReader::EndElement : |
|
9202 |
finished = true; |
|
9203 |
break; |
|
9204 |
case QXmlStreamReader::Characters : |
|
9205 |
if (!reader.isWhitespace()) |
|
9206 |
m_text.append(reader.text().toString()); |
|
9207 |
break; |
|
9208 |
default : |
|
9209 |
break; |
|
9210 |
} |
|
9211 |
} |
|
9212 |
} |
|
9213 |
||
9214 |
#ifdef QUILOADER_QDOM_READ |
|
9215 |
void DomProperty::read(const QDomElement &node) |
|
9216 |
{ |
|
9217 |
if (node.hasAttribute(QLatin1String("name"))) |
|
9218 |
setAttributeName(node.attribute(QLatin1String("name"))); |
|
9219 |
if (node.hasAttribute(QLatin1String("stdset"))) |
|
9220 |
setAttributeStdset(node.attribute(QLatin1String("stdset")).toInt()); |
|
9221 |
||
9222 |
for (QDomNode n = node.firstChild(); !n.isNull(); n = n.nextSibling()) { |
|
9223 |
if (!n.isElement()) |
|
9224 |
continue; |
|
9225 |
QDomElement e = n.toElement(); |
|
9226 |
QString tag = e.tagName().toLower(); |
|
9227 |
if (tag == QLatin1String("bool")) { |
|
9228 |
setElementBool(e.text()); |
|
9229 |
continue; |
|
9230 |
} |
|
9231 |
if (tag == QLatin1String("color")) { |
|
9232 |
DomColor *v = new DomColor(); |
|
9233 |
v->read(e); |
|
9234 |
setElementColor(v); |
|
9235 |
continue; |
|
9236 |
} |
|
9237 |
if (tag == QLatin1String("cstring")) { |
|
9238 |
setElementCstring(e.text()); |
|
9239 |
continue; |
|
9240 |
} |
|
9241 |
if (tag == QLatin1String("cursor")) { |
|
9242 |
setElementCursor(e.text().toInt()); |
|
9243 |
continue; |
|
9244 |
} |
|
9245 |
if (tag == QLatin1String("cursorshape")) { |
|
9246 |
setElementCursorShape(e.text()); |
|
9247 |
continue; |
|
9248 |
} |
|
9249 |
if (tag == QLatin1String("enum")) { |
|
9250 |
setElementEnum(e.text()); |
|
9251 |
continue; |
|
9252 |
} |
|
9253 |
if (tag == QLatin1String("font")) { |
|
9254 |
DomFont *v = new DomFont(); |
|
9255 |
v->read(e); |
|
9256 |
setElementFont(v); |
|
9257 |
continue; |
|
9258 |
} |
|
9259 |
if (tag == QLatin1String("iconset")) { |
|
9260 |
DomResourceIcon *v = new DomResourceIcon(); |
|
9261 |
v->read(e); |
|
9262 |
setElementIconSet(v); |
|
9263 |
continue; |
|
9264 |
} |
|
9265 |
if (tag == QLatin1String("pixmap")) { |
|
9266 |
DomResourcePixmap *v = new DomResourcePixmap(); |
|
9267 |
v->read(e); |
|
9268 |
setElementPixmap(v); |
|
9269 |
continue; |
|
9270 |
} |
|
9271 |
if (tag == QLatin1String("palette")) { |
|
9272 |
DomPalette *v = new DomPalette(); |
|
9273 |
v->read(e); |
|
9274 |
setElementPalette(v); |
|
9275 |
continue; |
|
9276 |
} |
|
9277 |
if (tag == QLatin1String("point")) { |
|
9278 |
DomPoint *v = new DomPoint(); |
|
9279 |
v->read(e); |
|
9280 |
setElementPoint(v); |
|
9281 |
continue; |
|
9282 |
} |
|
9283 |
if (tag == QLatin1String("rect")) { |
|
9284 |
DomRect *v = new DomRect(); |
|
9285 |
v->read(e); |
|
9286 |
setElementRect(v); |
|
9287 |
continue; |
|
9288 |
} |
|
9289 |
if (tag == QLatin1String("set")) { |
|
9290 |
setElementSet(e.text()); |
|
9291 |
continue; |
|
9292 |
} |
|
9293 |
if (tag == QLatin1String("locale")) { |
|
9294 |
DomLocale *v = new DomLocale(); |
|
9295 |
v->read(e); |
|
9296 |
setElementLocale(v); |
|
9297 |
continue; |
|
9298 |
} |
|
9299 |
if (tag == QLatin1String("sizepolicy")) { |
|
9300 |
DomSizePolicy *v = new DomSizePolicy(); |
|
9301 |
v->read(e); |
|
9302 |
setElementSizePolicy(v); |
|
9303 |
continue; |
|
9304 |
} |
|
9305 |
if (tag == QLatin1String("size")) { |
|
9306 |
DomSize *v = new DomSize(); |
|
9307 |
v->read(e); |
|
9308 |
setElementSize(v); |
|
9309 |
continue; |
|
9310 |
} |
|
9311 |
if (tag == QLatin1String("string")) { |
|
9312 |
DomString *v = new DomString(); |
|
9313 |
v->read(e); |
|
9314 |
setElementString(v); |
|
9315 |
continue; |
|
9316 |
} |
|
9317 |
if (tag == QLatin1String("stringlist")) { |
|
9318 |
DomStringList *v = new DomStringList(); |
|
9319 |
v->read(e); |
|
9320 |
setElementStringList(v); |
|
9321 |
continue; |
|
9322 |
} |
|
9323 |
if (tag == QLatin1String("number")) { |
|
9324 |
setElementNumber(e.text().toInt()); |
|
9325 |
continue; |
|
9326 |
} |
|
9327 |
if (tag == QLatin1String("float")) { |
|
9328 |
setElementFloat(e.text().toFloat()); |
|
9329 |
continue; |
|
9330 |
} |
|
9331 |
if (tag == QLatin1String("double")) { |
|
9332 |
setElementDouble(e.text().toDouble()); |
|
9333 |
continue; |
|
9334 |
} |
|
9335 |
if (tag == QLatin1String("date")) { |
|
9336 |
DomDate *v = new DomDate(); |
|
9337 |
v->read(e); |
|
9338 |
setElementDate(v); |
|
9339 |
continue; |
|
9340 |
} |
|
9341 |
if (tag == QLatin1String("time")) { |
|
9342 |
DomTime *v = new DomTime(); |
|
9343 |
v->read(e); |
|
9344 |
setElementTime(v); |
|
9345 |
continue; |
|
9346 |
} |
|
9347 |
if (tag == QLatin1String("datetime")) { |
|
9348 |
DomDateTime *v = new DomDateTime(); |
|
9349 |
v->read(e); |
|
9350 |
setElementDateTime(v); |
|
9351 |
continue; |
|
9352 |
} |
|
9353 |
if (tag == QLatin1String("pointf")) { |
|
9354 |
DomPointF *v = new DomPointF(); |
|
9355 |
v->read(e); |
|
9356 |
setElementPointF(v); |
|
9357 |
continue; |
|
9358 |
} |
|
9359 |
if (tag == QLatin1String("rectf")) { |
|
9360 |
DomRectF *v = new DomRectF(); |
|
9361 |
v->read(e); |
|
9362 |
setElementRectF(v); |
|
9363 |
continue; |
|
9364 |
} |
|
9365 |
if (tag == QLatin1String("sizef")) { |
|
9366 |
DomSizeF *v = new DomSizeF(); |
|
9367 |
v->read(e); |
|
9368 |
setElementSizeF(v); |
|
9369 |
continue; |
|
9370 |
} |
|
9371 |
if (tag == QLatin1String("longlong")) { |
|
9372 |
setElementLongLong(e.text().toLongLong()); |
|
9373 |
continue; |
|
9374 |
} |
|
9375 |
if (tag == QLatin1String("char")) { |
|
9376 |
DomChar *v = new DomChar(); |
|
9377 |
v->read(e); |
|
9378 |
setElementChar(v); |
|
9379 |
continue; |
|
9380 |
} |
|
9381 |
if (tag == QLatin1String("url")) { |
|
9382 |
DomUrl *v = new DomUrl(); |
|
9383 |
v->read(e); |
|
9384 |
setElementUrl(v); |
|
9385 |
continue; |
|
9386 |
} |
|
9387 |
if (tag == QLatin1String("uint")) { |
|
9388 |
setElementUInt(e.text().toUInt()); |
|
9389 |
continue; |
|
9390 |
} |
|
9391 |
if (tag == QLatin1String("ulonglong")) { |
|
9392 |
setElementULongLong(e.text().toULongLong()); |
|
9393 |
continue; |
|
9394 |
} |
|
9395 |
if (tag == QLatin1String("brush")) { |
|
9396 |
DomBrush *v = new DomBrush(); |
|
9397 |
v->read(e); |
|
9398 |
setElementBrush(v); |
|
9399 |
continue; |
|
9400 |
} |
|
9401 |
} |
|
9402 |
m_text.clear(); |
|
9403 |
for (QDomNode child = node.firstChild(); !child.isNull(); child = child.nextSibling()) { |
|
9404 |
if (child.isText()) |
|
9405 |
m_text.append(child.nodeValue()); |
|
9406 |
} |
|
9407 |
} |
|
9408 |
#endif |
|
9409 |
||
9410 |
void DomProperty::write(QXmlStreamWriter &writer, const QString &tagName) const |
|
9411 |
{ |
|
9412 |
writer.writeStartElement(tagName.isEmpty() ? QString::fromUtf8("property") : tagName.toLower()); |
|
9413 |
||
9414 |
if (hasAttributeName()) |
|
9415 |
writer.writeAttribute(QLatin1String("name"), attributeName()); |
|
9416 |
||
9417 |
if (hasAttributeStdset()) |
|
9418 |
writer.writeAttribute(QLatin1String("stdset"), QString::number(attributeStdset())); |
|
9419 |
||
9420 |
switch (kind()) { |
|
9421 |
case Bool: { |
|
9422 |
writer.writeTextElement(QLatin1String("bool"), elementBool()); |
|
9423 |
break; |
|
9424 |
} |
|
9425 |
case Color: { |
|
9426 |
DomColor* v = elementColor(); |
|
9427 |
if (v != 0) { |
|
9428 |
v->write(writer, QLatin1String("color")); |
|
9429 |
} |
|
9430 |
break; |
|
9431 |
} |
|
9432 |
case Cstring: { |
|
9433 |
writer.writeTextElement(QLatin1String("cstring"), elementCstring()); |
|
9434 |
break; |
|
9435 |
} |
|
9436 |
case Cursor: { |
|
9437 |
writer.writeTextElement(QLatin1String("cursor"), QString::number(elementCursor())); |
|
9438 |
break; |
|
9439 |
} |
|
9440 |
case CursorShape: { |
|
9441 |
writer.writeTextElement(QLatin1String("cursorShape"), elementCursorShape()); |
|
9442 |
break; |
|
9443 |
} |
|
9444 |
case Enum: { |
|
9445 |
writer.writeTextElement(QLatin1String("enum"), elementEnum()); |
|
9446 |
break; |
|
9447 |
} |
|
9448 |
case Font: { |
|
9449 |
DomFont* v = elementFont(); |
|
9450 |
if (v != 0) { |
|
9451 |
v->write(writer, QLatin1String("font")); |
|
9452 |
} |
|
9453 |
break; |
|
9454 |
} |
|
9455 |
case IconSet: { |
|
9456 |
DomResourceIcon* v = elementIconSet(); |
|
9457 |
if (v != 0) { |
|
9458 |
v->write(writer, QLatin1String("iconset")); |
|
9459 |
} |
|
9460 |
break; |
|
9461 |
} |
|
9462 |
case Pixmap: { |
|
9463 |
DomResourcePixmap* v = elementPixmap(); |
|
9464 |
if (v != 0) { |
|
9465 |
v->write(writer, QLatin1String("pixmap")); |
|
9466 |
} |
|
9467 |
break; |
|
9468 |
} |
|
9469 |
case Palette: { |
|
9470 |
DomPalette* v = elementPalette(); |
|
9471 |
if (v != 0) { |
|
9472 |
v->write(writer, QLatin1String("palette")); |
|
9473 |
} |
|
9474 |
break; |
|
9475 |
} |
|
9476 |
case Point: { |
|
9477 |
DomPoint* v = elementPoint(); |
|
9478 |
if (v != 0) { |
|
9479 |
v->write(writer, QLatin1String("point")); |
|
9480 |
} |
|
9481 |
break; |
|
9482 |
} |
|
9483 |
case Rect: { |
|
9484 |
DomRect* v = elementRect(); |
|
9485 |
if (v != 0) { |
|
9486 |
v->write(writer, QLatin1String("rect")); |
|
9487 |
} |
|
9488 |
break; |
|
9489 |
} |
|
9490 |
case Set: { |
|
9491 |
writer.writeTextElement(QLatin1String("set"), elementSet()); |
|
9492 |
break; |
|
9493 |
} |
|
9494 |
case Locale: { |
|
9495 |
DomLocale* v = elementLocale(); |
|
9496 |
if (v != 0) { |
|
9497 |
v->write(writer, QLatin1String("locale")); |
|
9498 |
} |
|
9499 |
break; |
|
9500 |
} |
|
9501 |
case SizePolicy: { |
|
9502 |
DomSizePolicy* v = elementSizePolicy(); |
|
9503 |
if (v != 0) { |
|
9504 |
v->write(writer, QLatin1String("sizepolicy")); |
|
9505 |
} |
|
9506 |
break; |
|
9507 |
} |
|
9508 |
case Size: { |
|
9509 |
DomSize* v = elementSize(); |
|
9510 |
if (v != 0) { |
|
9511 |
v->write(writer, QLatin1String("size")); |
|
9512 |
} |
|
9513 |
break; |
|
9514 |
} |
|
9515 |
case String: { |
|
9516 |
DomString* v = elementString(); |
|
9517 |
if (v != 0) { |
|
9518 |
v->write(writer, QLatin1String("string")); |
|
9519 |
} |
|
9520 |
break; |
|
9521 |
} |
|
9522 |
case StringList: { |
|
9523 |
DomStringList* v = elementStringList(); |
|
9524 |
if (v != 0) { |
|
9525 |
v->write(writer, QLatin1String("stringlist")); |
|
9526 |
} |
|
9527 |
break; |
|
9528 |
} |
|
9529 |
case Number: { |
|
9530 |
writer.writeTextElement(QLatin1String("number"), QString::number(elementNumber())); |
|
9531 |
break; |
|
9532 |
} |
|
9533 |
case Float: { |
|
9534 |
writer.writeTextElement(QLatin1String("float"), QString::number(elementFloat(), 'f', 8)); |
|
9535 |
break; |
|
9536 |
} |
|
9537 |
case Double: { |
|
9538 |
writer.writeTextElement(QLatin1String("double"), QString::number(elementDouble(), 'f', 15)); |
|
9539 |
break; |
|
9540 |
} |
|
9541 |
case Date: { |
|
9542 |
DomDate* v = elementDate(); |
|
9543 |
if (v != 0) { |
|
9544 |
v->write(writer, QLatin1String("date")); |
|
9545 |
} |
|
9546 |
break; |
|
9547 |
} |
|
9548 |
case Time: { |
|
9549 |
DomTime* v = elementTime(); |
|
9550 |
if (v != 0) { |
|
9551 |
v->write(writer, QLatin1String("time")); |
|
9552 |
} |
|
9553 |
break; |
|
9554 |
} |
|
9555 |
case DateTime: { |
|
9556 |
DomDateTime* v = elementDateTime(); |
|
9557 |
if (v != 0) { |
|
9558 |
v->write(writer, QLatin1String("datetime")); |
|
9559 |
} |
|
9560 |
break; |
|
9561 |
} |
|
9562 |
case PointF: { |
|
9563 |
DomPointF* v = elementPointF(); |
|
9564 |
if (v != 0) { |
|
9565 |
v->write(writer, QLatin1String("pointf")); |
|
9566 |
} |
|
9567 |
break; |
|
9568 |
} |
|
9569 |
case RectF: { |
|
9570 |
DomRectF* v = elementRectF(); |
|
9571 |
if (v != 0) { |
|
9572 |
v->write(writer, QLatin1String("rectf")); |
|
9573 |
} |
|
9574 |
break; |
|
9575 |
} |
|
9576 |
case SizeF: { |
|
9577 |
DomSizeF* v = elementSizeF(); |
|
9578 |
if (v != 0) { |
|
9579 |
v->write(writer, QLatin1String("sizef")); |
|
9580 |
} |
|
9581 |
break; |
|
9582 |
} |
|
9583 |
case LongLong: { |
|
9584 |
writer.writeTextElement(QLatin1String("longLong"), QString::number(elementLongLong())); |
|
9585 |
break; |
|
9586 |
} |
|
9587 |
case Char: { |
|
9588 |
DomChar* v = elementChar(); |
|
9589 |
if (v != 0) { |
|
9590 |
v->write(writer, QLatin1String("char")); |
|
9591 |
} |
|
9592 |
break; |
|
9593 |
} |
|
9594 |
case Url: { |
|
9595 |
DomUrl* v = elementUrl(); |
|
9596 |
if (v != 0) { |
|
9597 |
v->write(writer, QLatin1String("url")); |
|
9598 |
} |
|
9599 |
break; |
|
9600 |
} |
|
9601 |
case UInt: { |
|
9602 |
writer.writeTextElement(QLatin1String("UInt"), QString::number(elementUInt())); |
|
9603 |
break; |
|
9604 |
} |
|
9605 |
case ULongLong: { |
|
9606 |
writer.writeTextElement(QLatin1String("uLongLong"), QString::number(elementULongLong())); |
|
9607 |
break; |
|
9608 |
} |
|
9609 |
case Brush: { |
|
9610 |
DomBrush* v = elementBrush(); |
|
9611 |
if (v != 0) { |
|
9612 |
v->write(writer, QLatin1String("brush")); |
|
9613 |
} |
|
9614 |
break; |
|
9615 |
} |
|
9616 |
default: |
|
9617 |
break; |
|
9618 |
} |
|
9619 |
if (!m_text.isEmpty()) |
|
9620 |
writer.writeCharacters(m_text); |
|
9621 |
||
9622 |
writer.writeEndElement(); |
|
9623 |
} |
|
9624 |
||
9625 |
void DomProperty::setElementBool(const QString& a) |
|
9626 |
{ |
|
9627 |
clear(false); |
|
9628 |
m_kind = Bool; |
|
9629 |
m_bool = a; |
|
9630 |
} |
|
9631 |
||
9632 |
DomColor* DomProperty::takeElementColor() |
|
9633 |
{ |
|
9634 |
DomColor* a = m_color; |
|
9635 |
m_color = 0; |
|
9636 |
return a; |
|
9637 |
} |
|
9638 |
||
9639 |
void DomProperty::setElementColor(DomColor* a) |
|
9640 |
{ |
|
9641 |
clear(false); |
|
9642 |
m_kind = Color; |
|
9643 |
m_color = a; |
|
9644 |
} |
|
9645 |
||
9646 |
void DomProperty::setElementCstring(const QString& a) |
|
9647 |
{ |
|
9648 |
clear(false); |
|
9649 |
m_kind = Cstring; |
|
9650 |
m_cstring = a; |
|
9651 |
} |
|
9652 |
||
9653 |
void DomProperty::setElementCursor(int a) |
|
9654 |
{ |
|
9655 |
clear(false); |
|
9656 |
m_kind = Cursor; |
|
9657 |
m_cursor = a; |
|
9658 |
} |
|
9659 |
||
9660 |
void DomProperty::setElementCursorShape(const QString& a) |
|
9661 |
{ |
|
9662 |
clear(false); |
|
9663 |
m_kind = CursorShape; |
|
9664 |
m_cursorShape = a; |
|
9665 |
} |
|
9666 |
||
9667 |
void DomProperty::setElementEnum(const QString& a) |
|
9668 |
{ |
|
9669 |
clear(false); |
|
9670 |
m_kind = Enum; |
|
9671 |
m_enum = a; |
|
9672 |
} |
|
9673 |
||
9674 |
DomFont* DomProperty::takeElementFont() |
|
9675 |
{ |
|
9676 |
DomFont* a = m_font; |
|
9677 |
m_font = 0; |
|
9678 |
return a; |
|
9679 |
} |
|
9680 |
||
9681 |
void DomProperty::setElementFont(DomFont* a) |
|
9682 |
{ |
|
9683 |
clear(false); |
|
9684 |
m_kind = Font; |
|
9685 |
m_font = a; |
|
9686 |
} |
|
9687 |
||
9688 |
DomResourceIcon* DomProperty::takeElementIconSet() |
|
9689 |
{ |
|
9690 |
DomResourceIcon* a = m_iconSet; |
|
9691 |
m_iconSet = 0; |
|
9692 |
return a; |
|
9693 |
} |
|
9694 |
||
9695 |
void DomProperty::setElementIconSet(DomResourceIcon* a) |
|
9696 |
{ |
|
9697 |
clear(false); |
|
9698 |
m_kind = IconSet; |
|
9699 |
m_iconSet = a; |
|
9700 |
} |
|
9701 |
||
9702 |
DomResourcePixmap* DomProperty::takeElementPixmap() |
|
9703 |
{ |
|
9704 |
DomResourcePixmap* a = m_pixmap; |
|
9705 |
m_pixmap = 0; |
|
9706 |
return a; |
|
9707 |
} |
|
9708 |
||
9709 |
void DomProperty::setElementPixmap(DomResourcePixmap* a) |
|
9710 |
{ |
|
9711 |
clear(false); |
|
9712 |
m_kind = Pixmap; |
|
9713 |
m_pixmap = a; |
|
9714 |
} |
|
9715 |
||
9716 |
DomPalette* DomProperty::takeElementPalette() |
|
9717 |
{ |
|
9718 |
DomPalette* a = m_palette; |
|
9719 |
m_palette = 0; |
|
9720 |
return a; |
|
9721 |
} |
|
9722 |
||
9723 |
void DomProperty::setElementPalette(DomPalette* a) |
|
9724 |
{ |
|
9725 |
clear(false); |
|
9726 |
m_kind = Palette; |
|
9727 |
m_palette = a; |
|
9728 |
} |
|
9729 |
||
9730 |
DomPoint* DomProperty::takeElementPoint() |
|
9731 |
{ |
|
9732 |
DomPoint* a = m_point; |
|
9733 |
m_point = 0; |
|
9734 |
return a; |
|
9735 |
} |
|
9736 |
||
9737 |
void DomProperty::setElementPoint(DomPoint* a) |
|
9738 |
{ |
|
9739 |
clear(false); |
|
9740 |
m_kind = Point; |
|
9741 |
m_point = a; |
|
9742 |
} |
|
9743 |
||
9744 |
DomRect* DomProperty::takeElementRect() |
|
9745 |
{ |
|
9746 |
DomRect* a = m_rect; |
|
9747 |
m_rect = 0; |
|
9748 |
return a; |
|
9749 |
} |
|
9750 |
||
9751 |
void DomProperty::setElementRect(DomRect* a) |
|
9752 |
{ |
|
9753 |
clear(false); |
|
9754 |
m_kind = Rect; |
|
9755 |
m_rect = a; |
|
9756 |
} |
|
9757 |
||
9758 |
void DomProperty::setElementSet(const QString& a) |
|
9759 |
{ |
|
9760 |
clear(false); |
|
9761 |
m_kind = Set; |
|
9762 |
m_set = a; |
|
9763 |
} |
|
9764 |
||
9765 |
DomLocale* DomProperty::takeElementLocale() |
|
9766 |
{ |
|
9767 |
DomLocale* a = m_locale; |
|
9768 |
m_locale = 0; |
|
9769 |
return a; |
|
9770 |
} |
|
9771 |
||
9772 |
void DomProperty::setElementLocale(DomLocale* a) |
|
9773 |
{ |
|
9774 |
clear(false); |
|
9775 |
m_kind = Locale; |
|
9776 |
m_locale = a; |
|
9777 |
} |
|
9778 |
||
9779 |
DomSizePolicy* DomProperty::takeElementSizePolicy() |
|
9780 |
{ |
|
9781 |
DomSizePolicy* a = m_sizePolicy; |
|
9782 |
m_sizePolicy = 0; |
|
9783 |
return a; |
|
9784 |
} |
|
9785 |
||
9786 |
void DomProperty::setElementSizePolicy(DomSizePolicy* a) |
|
9787 |
{ |
|
9788 |
clear(false); |
|
9789 |
m_kind = SizePolicy; |
|
9790 |
m_sizePolicy = a; |
|
9791 |
} |
|
9792 |
||
9793 |
DomSize* DomProperty::takeElementSize() |
|
9794 |
{ |
|
9795 |
DomSize* a = m_size; |
|
9796 |
m_size = 0; |
|
9797 |
return a; |
|
9798 |
} |
|
9799 |
||
9800 |
void DomProperty::setElementSize(DomSize* a) |
|
9801 |
{ |
|
9802 |
clear(false); |
|
9803 |
m_kind = Size; |
|
9804 |
m_size = a; |
|
9805 |
} |
|
9806 |
||
9807 |
DomString* DomProperty::takeElementString() |
|
9808 |
{ |
|
9809 |
DomString* a = m_string; |
|
9810 |
m_string = 0; |
|
9811 |
return a; |
|
9812 |
} |
|
9813 |
||
9814 |
void DomProperty::setElementString(DomString* a) |
|
9815 |
{ |
|
9816 |
clear(false); |
|
9817 |
m_kind = String; |
|
9818 |
m_string = a; |
|
9819 |
} |
|
9820 |
||
9821 |
DomStringList* DomProperty::takeElementStringList() |
|
9822 |
{ |
|
9823 |
DomStringList* a = m_stringList; |
|
9824 |
m_stringList = 0; |
|
9825 |
return a; |
|
9826 |
} |
|
9827 |
||
9828 |
void DomProperty::setElementStringList(DomStringList* a) |
|
9829 |
{ |
|
9830 |
clear(false); |
|
9831 |
m_kind = StringList; |
|
9832 |
m_stringList = a; |
|
9833 |
} |
|
9834 |
||
9835 |
void DomProperty::setElementNumber(int a) |
|
9836 |
{ |
|
9837 |
clear(false); |
|
9838 |
m_kind = Number; |
|
9839 |
m_number = a; |
|
9840 |
} |
|
9841 |
||
9842 |
void DomProperty::setElementFloat(float a) |
|
9843 |
{ |
|
9844 |
clear(false); |
|
9845 |
m_kind = Float; |
|
9846 |
m_float = a; |
|
9847 |
} |
|
9848 |
||
9849 |
void DomProperty::setElementDouble(double a) |
|
9850 |
{ |
|
9851 |
clear(false); |
|
9852 |
m_kind = Double; |
|
9853 |
m_double = a; |
|
9854 |
} |
|
9855 |
||
9856 |
DomDate* DomProperty::takeElementDate() |
|
9857 |
{ |
|
9858 |
DomDate* a = m_date; |
|
9859 |
m_date = 0; |
|
9860 |
return a; |
|
9861 |
} |
|
9862 |
||
9863 |
void DomProperty::setElementDate(DomDate* a) |
|
9864 |
{ |
|
9865 |
clear(false); |
|
9866 |
m_kind = Date; |
|
9867 |
m_date = a; |
|
9868 |
} |
|
9869 |
||
9870 |
DomTime* DomProperty::takeElementTime() |
|
9871 |
{ |
|
9872 |
DomTime* a = m_time; |
|
9873 |
m_time = 0; |
|
9874 |
return a; |
|
9875 |
} |
|
9876 |
||
9877 |
void DomProperty::setElementTime(DomTime* a) |
|
9878 |
{ |
|
9879 |
clear(false); |
|
9880 |
m_kind = Time; |
|
9881 |
m_time = a; |
|
9882 |
} |
|
9883 |
||
9884 |
DomDateTime* DomProperty::takeElementDateTime() |
|
9885 |
{ |
|
9886 |
DomDateTime* a = m_dateTime; |
|
9887 |
m_dateTime = 0; |
|
9888 |
return a; |
|
9889 |
} |
|
9890 |
||
9891 |
void DomProperty::setElementDateTime(DomDateTime* a) |
|
9892 |
{ |
|
9893 |
clear(false); |
|
9894 |
m_kind = DateTime; |
|
9895 |
m_dateTime = a; |
|
9896 |
} |
|
9897 |
||
9898 |
DomPointF* DomProperty::takeElementPointF() |
|
9899 |
{ |
|
9900 |
DomPointF* a = m_pointF; |
|
9901 |
m_pointF = 0; |
|
9902 |
return a; |
|
9903 |
} |
|
9904 |
||
9905 |
void DomProperty::setElementPointF(DomPointF* a) |
|
9906 |
{ |
|
9907 |
clear(false); |
|
9908 |
m_kind = PointF; |
|
9909 |
m_pointF = a; |
|
9910 |
} |
|
9911 |
||
9912 |
DomRectF* DomProperty::takeElementRectF() |
|
9913 |
{ |
|
9914 |
DomRectF* a = m_rectF; |
|
9915 |
m_rectF = 0; |
|
9916 |
return a; |
|
9917 |
} |
|
9918 |
||
9919 |
void DomProperty::setElementRectF(DomRectF* a) |
|
9920 |
{ |
|
9921 |
clear(false); |
|
9922 |
m_kind = RectF; |
|
9923 |
m_rectF = a; |
|
9924 |
} |
|
9925 |
||
9926 |
DomSizeF* DomProperty::takeElementSizeF() |
|
9927 |
{ |
|
9928 |
DomSizeF* a = m_sizeF; |
|
9929 |
m_sizeF = 0; |
|
9930 |
return a; |
|
9931 |
} |
|
9932 |
||
9933 |
void DomProperty::setElementSizeF(DomSizeF* a) |
|
9934 |
{ |
|
9935 |
clear(false); |
|
9936 |
m_kind = SizeF; |
|
9937 |
m_sizeF = a; |
|
9938 |
} |
|
9939 |
||
9940 |
void DomProperty::setElementLongLong(qlonglong a) |
|
9941 |
{ |
|
9942 |
clear(false); |
|
9943 |
m_kind = LongLong; |
|
9944 |
m_longLong = a; |
|
9945 |
} |
|
9946 |
||
9947 |
DomChar* DomProperty::takeElementChar() |
|
9948 |
{ |
|
9949 |
DomChar* a = m_char; |
|
9950 |
m_char = 0; |
|
9951 |
return a; |
|
9952 |
} |
|
9953 |
||
9954 |
void DomProperty::setElementChar(DomChar* a) |
|
9955 |
{ |
|
9956 |
clear(false); |
|
9957 |
m_kind = Char; |
|
9958 |
m_char = a; |
|
9959 |
} |
|
9960 |
||
9961 |
DomUrl* DomProperty::takeElementUrl() |
|
9962 |
{ |
|
9963 |
DomUrl* a = m_url; |
|
9964 |
m_url = 0; |
|
9965 |
return a; |
|
9966 |
} |
|
9967 |
||
9968 |
void DomProperty::setElementUrl(DomUrl* a) |
|
9969 |
{ |
|
9970 |
clear(false); |
|
9971 |
m_kind = Url; |
|
9972 |
m_url = a; |
|
9973 |
} |
|
9974 |
||
9975 |
void DomProperty::setElementUInt(uint a) |
|
9976 |
{ |
|
9977 |
clear(false); |
|
9978 |
m_kind = UInt; |
|
9979 |
m_UInt = a; |
|
9980 |
} |
|
9981 |
||
9982 |
void DomProperty::setElementULongLong(qulonglong a) |
|
9983 |
{ |
|
9984 |
clear(false); |
|
9985 |
m_kind = ULongLong; |
|
9986 |
m_uLongLong = a; |
|
9987 |
} |
|
9988 |
||
9989 |
DomBrush* DomProperty::takeElementBrush() |
|
9990 |
{ |
|
9991 |
DomBrush* a = m_brush; |
|
9992 |
m_brush = 0; |
|
9993 |
return a; |
|
9994 |
} |
|
9995 |
||
9996 |
void DomProperty::setElementBrush(DomBrush* a) |
|
9997 |
{ |
|
9998 |
clear(false); |
|
9999 |
m_kind = Brush; |
|
10000 |
m_brush = a; |
|
10001 |
} |
|
10002 |
||
10003 |
void DomConnections::clear(bool clear_all) |
|
10004 |
{ |
|
10005 |
qDeleteAll(m_connection); |
|
10006 |
m_connection.clear(); |
|
10007 |
||
10008 |
if (clear_all) { |
|
10009 |
m_text.clear(); |
|
10010 |
} |
|
10011 |
||
10012 |
m_children = 0; |
|
10013 |
} |
|
10014 |
||
10015 |
DomConnections::DomConnections() |
|
10016 |
{ |
|
10017 |
m_children = 0; |
|
10018 |
} |
|
10019 |
||
10020 |
DomConnections::~DomConnections() |
|
10021 |
{ |
|
10022 |
qDeleteAll(m_connection); |
|
10023 |
m_connection.clear(); |
|
10024 |
} |
|
10025 |
||
10026 |
void DomConnections::read(QXmlStreamReader &reader) |
|
10027 |
{ |
|
10028 |
||
10029 |
for (bool finished = false; !finished && !reader.hasError();) { |
|
10030 |
switch (reader.readNext()) { |
|
10031 |
case QXmlStreamReader::StartElement : { |
|
10032 |
const QString tag = reader.name().toString().toLower(); |
|
10033 |
if (tag == QLatin1String("connection")) { |
|
10034 |
DomConnection *v = new DomConnection(); |
|
10035 |
v->read(reader); |
|
10036 |
m_connection.append(v); |
|
10037 |
continue; |
|
10038 |
} |
|
10039 |
reader.raiseError(QLatin1String("Unexpected element ") + tag); |
|
10040 |
} |
|
10041 |
break; |
|
10042 |
case QXmlStreamReader::EndElement : |
|
10043 |
finished = true; |
|
10044 |
break; |
|
10045 |
case QXmlStreamReader::Characters : |
|
10046 |
if (!reader.isWhitespace()) |
|
10047 |
m_text.append(reader.text().toString()); |
|
10048 |
break; |
|
10049 |
default : |
|
10050 |
break; |
|
10051 |
} |
|
10052 |
} |
|
10053 |
} |
|
10054 |
||
10055 |
#ifdef QUILOADER_QDOM_READ |
|
10056 |
void DomConnections::read(const QDomElement &node) |
|
10057 |
{ |
|
10058 |
for (QDomNode n = node.firstChild(); !n.isNull(); n = n.nextSibling()) { |
|
10059 |
if (!n.isElement()) |
|
10060 |
continue; |
|
10061 |
QDomElement e = n.toElement(); |
|
10062 |
QString tag = e.tagName().toLower(); |
|
10063 |
if (tag == QLatin1String("connection")) { |
|
10064 |
DomConnection *v = new DomConnection(); |
|
10065 |
v->read(e); |
|
10066 |
m_connection.append(v); |
|
10067 |
continue; |
|
10068 |
} |
|
10069 |
} |
|
10070 |
m_text.clear(); |
|
10071 |
for (QDomNode child = node.firstChild(); !child.isNull(); child = child.nextSibling()) { |
|
10072 |
if (child.isText()) |
|
10073 |
m_text.append(child.nodeValue()); |
|
10074 |
} |
|
10075 |
} |
|
10076 |
#endif |
|
10077 |
||
10078 |
void DomConnections::write(QXmlStreamWriter &writer, const QString &tagName) const |
|
10079 |
{ |
|
10080 |
writer.writeStartElement(tagName.isEmpty() ? QString::fromUtf8("connections") : tagName.toLower()); |
|
10081 |
||
10082 |
for (int i = 0; i < m_connection.size(); ++i) { |
|
10083 |
DomConnection* v = m_connection[i]; |
|
10084 |
v->write(writer, QLatin1String("connection")); |
|
10085 |
} |
|
10086 |
if (!m_text.isEmpty()) |
|
10087 |
writer.writeCharacters(m_text); |
|
10088 |
||
10089 |
writer.writeEndElement(); |
|
10090 |
} |
|
10091 |
||
10092 |
void DomConnections::setElementConnection(const QList<DomConnection*>& a) |
|
10093 |
{ |
|
10094 |
m_children |= Connection; |
|
10095 |
m_connection = a; |
|
10096 |
} |
|
10097 |
||
10098 |
void DomConnection::clear(bool clear_all) |
|
10099 |
{ |
|
10100 |
delete m_hints; |
|
10101 |
||
10102 |
if (clear_all) { |
|
10103 |
m_text.clear(); |
|
10104 |
} |
|
10105 |
||
10106 |
m_children = 0; |
|
10107 |
m_hints = 0; |
|
10108 |
} |
|
10109 |
||
10110 |
DomConnection::DomConnection() |
|
10111 |
{ |
|
10112 |
m_children = 0; |
|
10113 |
m_hints = 0; |
|
10114 |
} |
|
10115 |
||
10116 |
DomConnection::~DomConnection() |
|
10117 |
{ |
|
10118 |
delete m_hints; |
|
10119 |
} |
|
10120 |
||
10121 |
void DomConnection::read(QXmlStreamReader &reader) |
|
10122 |
{ |
|
10123 |
||
10124 |
for (bool finished = false; !finished && !reader.hasError();) { |
|
10125 |
switch (reader.readNext()) { |
|
10126 |
case QXmlStreamReader::StartElement : { |
|
10127 |
const QString tag = reader.name().toString().toLower(); |
|
10128 |
if (tag == QLatin1String("sender")) { |
|
10129 |
setElementSender(reader.readElementText()); |
|
10130 |
continue; |
|
10131 |
} |
|
10132 |
if (tag == QLatin1String("signal")) { |
|
10133 |
setElementSignal(reader.readElementText()); |
|
10134 |
continue; |
|
10135 |
} |
|
10136 |
if (tag == QLatin1String("receiver")) { |
|
10137 |
setElementReceiver(reader.readElementText()); |
|
10138 |
continue; |
|
10139 |
} |
|
10140 |
if (tag == QLatin1String("slot")) { |
|
10141 |
setElementSlot(reader.readElementText()); |
|
10142 |
continue; |
|
10143 |
} |
|
10144 |
if (tag == QLatin1String("hints")) { |
|
10145 |
DomConnectionHints *v = new DomConnectionHints(); |
|
10146 |
v->read(reader); |
|
10147 |
setElementHints(v); |
|
10148 |
continue; |
|
10149 |
} |
|
10150 |
reader.raiseError(QLatin1String("Unexpected element ") + tag); |
|
10151 |
} |
|
10152 |
break; |
|
10153 |
case QXmlStreamReader::EndElement : |
|
10154 |
finished = true; |
|
10155 |
break; |
|
10156 |
case QXmlStreamReader::Characters : |
|
10157 |
if (!reader.isWhitespace()) |
|
10158 |
m_text.append(reader.text().toString()); |
|
10159 |
break; |
|
10160 |
default : |
|
10161 |
break; |
|
10162 |
} |
|
10163 |
} |
|
10164 |
} |
|
10165 |
||
10166 |
#ifdef QUILOADER_QDOM_READ |
|
10167 |
void DomConnection::read(const QDomElement &node) |
|
10168 |
{ |
|
10169 |
for (QDomNode n = node.firstChild(); !n.isNull(); n = n.nextSibling()) { |
|
10170 |
if (!n.isElement()) |
|
10171 |
continue; |
|
10172 |
QDomElement e = n.toElement(); |
|
10173 |
QString tag = e.tagName().toLower(); |
|
10174 |
if (tag == QLatin1String("sender")) { |
|
10175 |
setElementSender(e.text()); |
|
10176 |
continue; |
|
10177 |
} |
|
10178 |
if (tag == QLatin1String("signal")) { |
|
10179 |
setElementSignal(e.text()); |
|
10180 |
continue; |
|
10181 |
} |
|
10182 |
if (tag == QLatin1String("receiver")) { |
|
10183 |
setElementReceiver(e.text()); |
|
10184 |
continue; |
|
10185 |
} |
|
10186 |
if (tag == QLatin1String("slot")) { |
|
10187 |
setElementSlot(e.text()); |
|
10188 |
continue; |
|
10189 |
} |
|
10190 |
if (tag == QLatin1String("hints")) { |
|
10191 |
DomConnectionHints *v = new DomConnectionHints(); |
|
10192 |
v->read(e); |
|
10193 |
setElementHints(v); |
|
10194 |
continue; |
|
10195 |
} |
|
10196 |
} |
|
10197 |
m_text.clear(); |
|
10198 |
for (QDomNode child = node.firstChild(); !child.isNull(); child = child.nextSibling()) { |
|
10199 |
if (child.isText()) |
|
10200 |
m_text.append(child.nodeValue()); |
|
10201 |
} |
|
10202 |
} |
|
10203 |
#endif |
|
10204 |
||
10205 |
void DomConnection::write(QXmlStreamWriter &writer, const QString &tagName) const |
|
10206 |
{ |
|
10207 |
writer.writeStartElement(tagName.isEmpty() ? QString::fromUtf8("connection") : tagName.toLower()); |
|
10208 |
||
10209 |
if (m_children & Sender) { |
|
10210 |
writer.writeTextElement(QLatin1String("sender"), m_sender); |
|
10211 |
} |
|
10212 |
||
10213 |
if (m_children & Signal) { |
|
10214 |
writer.writeTextElement(QLatin1String("signal"), m_signal); |
|
10215 |
} |
|
10216 |
||
10217 |
if (m_children & Receiver) { |
|
10218 |
writer.writeTextElement(QLatin1String("receiver"), m_receiver); |
|
10219 |
} |
|
10220 |
||
10221 |
if (m_children & Slot) { |
|
10222 |
writer.writeTextElement(QLatin1String("slot"), m_slot); |
|
10223 |
} |
|
10224 |
||
10225 |
if (m_children & Hints) { |
|
10226 |
m_hints->write(writer, QLatin1String("hints")); |
|
10227 |
} |
|
10228 |
||
10229 |
if (!m_text.isEmpty()) |
|
10230 |
writer.writeCharacters(m_text); |
|
10231 |
||
10232 |
writer.writeEndElement(); |
|
10233 |
} |
|
10234 |
||
10235 |
void DomConnection::setElementSender(const QString& a) |
|
10236 |
{ |
|
10237 |
m_children |= Sender; |
|
10238 |
m_sender = a; |
|
10239 |
} |
|
10240 |
||
10241 |
void DomConnection::setElementSignal(const QString& a) |
|
10242 |
{ |
|
10243 |
m_children |= Signal; |
|
10244 |
m_signal = a; |
|
10245 |
} |
|
10246 |
||
10247 |
void DomConnection::setElementReceiver(const QString& a) |
|
10248 |
{ |
|
10249 |
m_children |= Receiver; |
|
10250 |
m_receiver = a; |
|
10251 |
} |
|
10252 |
||
10253 |
void DomConnection::setElementSlot(const QString& a) |
|
10254 |
{ |
|
10255 |
m_children |= Slot; |
|
10256 |
m_slot = a; |
|
10257 |
} |
|
10258 |
||
10259 |
DomConnectionHints* DomConnection::takeElementHints() |
|
10260 |
{ |
|
10261 |
DomConnectionHints* a = m_hints; |
|
10262 |
m_hints = 0; |
|
10263 |
m_children ^= Hints; |
|
10264 |
return a; |
|
10265 |
} |
|
10266 |
||
10267 |
void DomConnection::setElementHints(DomConnectionHints* a) |
|
10268 |
{ |
|
10269 |
delete m_hints; |
|
10270 |
m_children |= Hints; |
|
10271 |
m_hints = a; |
|
10272 |
} |
|
10273 |
||
10274 |
void DomConnection::clearElementSender() |
|
10275 |
{ |
|
10276 |
m_children &= ~Sender; |
|
10277 |
} |
|
10278 |
||
10279 |
void DomConnection::clearElementSignal() |
|
10280 |
{ |
|
10281 |
m_children &= ~Signal; |
|
10282 |
} |
|
10283 |
||
10284 |
void DomConnection::clearElementReceiver() |
|
10285 |
{ |
|
10286 |
m_children &= ~Receiver; |
|
10287 |
} |
|
10288 |
||
10289 |
void DomConnection::clearElementSlot() |
|
10290 |
{ |
|
10291 |
m_children &= ~Slot; |
|
10292 |
} |
|
10293 |
||
10294 |
void DomConnection::clearElementHints() |
|
10295 |
{ |
|
10296 |
delete m_hints; |
|
10297 |
m_hints = 0; |
|
10298 |
m_children &= ~Hints; |
|
10299 |
} |
|
10300 |
||
10301 |
void DomConnectionHints::clear(bool clear_all) |
|
10302 |
{ |
|
10303 |
qDeleteAll(m_hint); |
|
10304 |
m_hint.clear(); |
|
10305 |
||
10306 |
if (clear_all) { |
|
10307 |
m_text.clear(); |
|
10308 |
} |
|
10309 |
||
10310 |
m_children = 0; |
|
10311 |
} |
|
10312 |
||
10313 |
DomConnectionHints::DomConnectionHints() |
|
10314 |
{ |
|
10315 |
m_children = 0; |
|
10316 |
} |
|
10317 |
||
10318 |
DomConnectionHints::~DomConnectionHints() |
|
10319 |
{ |
|
10320 |
qDeleteAll(m_hint); |
|
10321 |
m_hint.clear(); |
|
10322 |
} |
|
10323 |
||
10324 |
void DomConnectionHints::read(QXmlStreamReader &reader) |
|
10325 |
{ |
|
10326 |
||
10327 |
for (bool finished = false; !finished && !reader.hasError();) { |
|
10328 |
switch (reader.readNext()) { |
|
10329 |
case QXmlStreamReader::StartElement : { |
|
10330 |
const QString tag = reader.name().toString().toLower(); |
|
10331 |
if (tag == QLatin1String("hint")) { |
|
10332 |
DomConnectionHint *v = new DomConnectionHint(); |
|
10333 |
v->read(reader); |
|
10334 |
m_hint.append(v); |
|
10335 |
continue; |
|
10336 |
} |
|
10337 |
reader.raiseError(QLatin1String("Unexpected element ") + tag); |
|
10338 |
} |
|
10339 |
break; |
|
10340 |
case QXmlStreamReader::EndElement : |
|
10341 |
finished = true; |
|
10342 |
break; |
|
10343 |
case QXmlStreamReader::Characters : |
|
10344 |
if (!reader.isWhitespace()) |
|
10345 |
m_text.append(reader.text().toString()); |
|
10346 |
break; |
|
10347 |
default : |
|
10348 |
break; |
|
10349 |
} |
|
10350 |
} |
|
10351 |
} |
|
10352 |
||
10353 |
#ifdef QUILOADER_QDOM_READ |
|
10354 |
void DomConnectionHints::read(const QDomElement &node) |
|
10355 |
{ |
|
10356 |
for (QDomNode n = node.firstChild(); !n.isNull(); n = n.nextSibling()) { |
|
10357 |
if (!n.isElement()) |
|
10358 |
continue; |
|
10359 |
QDomElement e = n.toElement(); |
|
10360 |
QString tag = e.tagName().toLower(); |
|
10361 |
if (tag == QLatin1String("hint")) { |
|
10362 |
DomConnectionHint *v = new DomConnectionHint(); |
|
10363 |
v->read(e); |
|
10364 |
m_hint.append(v); |
|
10365 |
continue; |
|
10366 |
} |
|
10367 |
} |
|
10368 |
m_text.clear(); |
|
10369 |
for (QDomNode child = node.firstChild(); !child.isNull(); child = child.nextSibling()) { |
|
10370 |
if (child.isText()) |
|
10371 |
m_text.append(child.nodeValue()); |
|
10372 |
} |
|
10373 |
} |
|
10374 |
#endif |
|
10375 |
||
10376 |
void DomConnectionHints::write(QXmlStreamWriter &writer, const QString &tagName) const |
|
10377 |
{ |
|
10378 |
writer.writeStartElement(tagName.isEmpty() ? QString::fromUtf8("connectionhints") : tagName.toLower()); |
|
10379 |
||
10380 |
for (int i = 0; i < m_hint.size(); ++i) { |
|
10381 |
DomConnectionHint* v = m_hint[i]; |
|
10382 |
v->write(writer, QLatin1String("hint")); |
|
10383 |
} |
|
10384 |
if (!m_text.isEmpty()) |
|
10385 |
writer.writeCharacters(m_text); |
|
10386 |
||
10387 |
writer.writeEndElement(); |
|
10388 |
} |
|
10389 |
||
10390 |
void DomConnectionHints::setElementHint(const QList<DomConnectionHint*>& a) |
|
10391 |
{ |
|
10392 |
m_children |= Hint; |
|
10393 |
m_hint = a; |
|
10394 |
} |
|
10395 |
||
10396 |
void DomConnectionHint::clear(bool clear_all) |
|
10397 |
{ |
|
10398 |
||
10399 |
if (clear_all) { |
|
10400 |
m_text.clear(); |
|
10401 |
m_has_attr_type = false; |
|
10402 |
} |
|
10403 |
||
10404 |
m_children = 0; |
|
10405 |
m_x = 0; |
|
10406 |
m_y = 0; |
|
10407 |
} |
|
10408 |
||
10409 |
DomConnectionHint::DomConnectionHint() |
|
10410 |
{ |
|
10411 |
m_children = 0; |
|
10412 |
m_has_attr_type = false; |
|
10413 |
m_x = 0; |
|
10414 |
m_y = 0; |
|
10415 |
} |
|
10416 |
||
10417 |
DomConnectionHint::~DomConnectionHint() |
|
10418 |
{ |
|
10419 |
} |
|
10420 |
||
10421 |
void DomConnectionHint::read(QXmlStreamReader &reader) |
|
10422 |
{ |
|
10423 |
||
10424 |
foreach (const QXmlStreamAttribute &attribute, reader.attributes()) { |
|
10425 |
QStringRef name = attribute.name(); |
|
10426 |
if (name == QLatin1String("type")) { |
|
10427 |
setAttributeType(attribute.value().toString()); |
|
10428 |
continue; |
|
10429 |
} |
|
10430 |
reader.raiseError(QLatin1String("Unexpected attribute ") + name.toString()); |
|
10431 |
} |
|
10432 |
||
10433 |
for (bool finished = false; !finished && !reader.hasError();) { |
|
10434 |
switch (reader.readNext()) { |
|
10435 |
case QXmlStreamReader::StartElement : { |
|
10436 |
const QString tag = reader.name().toString().toLower(); |
|
10437 |
if (tag == QString(QLatin1Char('x'))) { |
|
10438 |
setElementX(reader.readElementText().toInt()); |
|
10439 |
continue; |
|
10440 |
} |
|
10441 |
if (tag == QString(QLatin1Char('y'))) { |
|
10442 |
setElementY(reader.readElementText().toInt()); |
|
10443 |
continue; |
|
10444 |
} |
|
10445 |
reader.raiseError(QLatin1String("Unexpected element ") + tag); |
|
10446 |
} |
|
10447 |
break; |
|
10448 |
case QXmlStreamReader::EndElement : |
|
10449 |
finished = true; |
|
10450 |
break; |
|
10451 |
case QXmlStreamReader::Characters : |
|
10452 |
if (!reader.isWhitespace()) |
|
10453 |
m_text.append(reader.text().toString()); |
|
10454 |
break; |
|
10455 |
default : |
|
10456 |
break; |
|
10457 |
} |
|
10458 |
} |
|
10459 |
} |
|
10460 |
||
10461 |
#ifdef QUILOADER_QDOM_READ |
|
10462 |
void DomConnectionHint::read(const QDomElement &node) |
|
10463 |
{ |
|
10464 |
if (node.hasAttribute(QLatin1String("type"))) |
|
10465 |
setAttributeType(node.attribute(QLatin1String("type"))); |
|
10466 |
||
10467 |
for (QDomNode n = node.firstChild(); !n.isNull(); n = n.nextSibling()) { |
|
10468 |
if (!n.isElement()) |
|
10469 |
continue; |
|
10470 |
QDomElement e = n.toElement(); |
|
10471 |
QString tag = e.tagName().toLower(); |
|
10472 |
if (tag == QString(QLatin1Char('x'))) { |
|
10473 |
setElementX(e.text().toInt()); |
|
10474 |
continue; |
|
10475 |
} |
|
10476 |
if (tag == QString(QLatin1Char('y'))) { |
|
10477 |
setElementY(e.text().toInt()); |
|
10478 |
continue; |
|
10479 |
} |
|
10480 |
} |
|
10481 |
m_text.clear(); |
|
10482 |
for (QDomNode child = node.firstChild(); !child.isNull(); child = child.nextSibling()) { |
|
10483 |
if (child.isText()) |
|
10484 |
m_text.append(child.nodeValue()); |
|
10485 |
} |
|
10486 |
} |
|
10487 |
#endif |
|
10488 |
||
10489 |
void DomConnectionHint::write(QXmlStreamWriter &writer, const QString &tagName) const |
|
10490 |
{ |
|
10491 |
writer.writeStartElement(tagName.isEmpty() ? QString::fromUtf8("connectionhint") : tagName.toLower()); |
|
10492 |
||
10493 |
if (hasAttributeType()) |
|
10494 |
writer.writeAttribute(QLatin1String("type"), attributeType()); |
|
10495 |
||
10496 |
if (m_children & X) { |
|
10497 |
writer.writeTextElement(QString(QLatin1Char('x')), QString::number(m_x)); |
|
10498 |
} |
|
10499 |
||
10500 |
if (m_children & Y) { |
|
10501 |
writer.writeTextElement(QString(QLatin1Char('y')), QString::number(m_y)); |
|
10502 |
} |
|
10503 |
||
10504 |
if (!m_text.isEmpty()) |
|
10505 |
writer.writeCharacters(m_text); |
|
10506 |
||
10507 |
writer.writeEndElement(); |
|
10508 |
} |
|
10509 |
||
10510 |
void DomConnectionHint::setElementX(int a) |
|
10511 |
{ |
|
10512 |
m_children |= X; |
|
10513 |
m_x = a; |
|
10514 |
} |
|
10515 |
||
10516 |
void DomConnectionHint::setElementY(int a) |
|
10517 |
{ |
|
10518 |
m_children |= Y; |
|
10519 |
m_y = a; |
|
10520 |
} |
|
10521 |
||
10522 |
void DomConnectionHint::clearElementX() |
|
10523 |
{ |
|
10524 |
m_children &= ~X; |
|
10525 |
} |
|
10526 |
||
10527 |
void DomConnectionHint::clearElementY() |
|
10528 |
{ |
|
10529 |
m_children &= ~Y; |
|
10530 |
} |
|
10531 |
||
10532 |
void DomScript::clear(bool clear_all) |
|
10533 |
{ |
|
10534 |
||
10535 |
if (clear_all) { |
|
10536 |
m_text.clear(); |
|
10537 |
m_has_attr_source = false; |
|
10538 |
m_has_attr_language = false; |
|
10539 |
} |
|
10540 |
||
10541 |
m_children = 0; |
|
10542 |
} |
|
10543 |
||
10544 |
DomScript::DomScript() |
|
10545 |
{ |
|
10546 |
m_children = 0; |
|
10547 |
m_has_attr_source = false; |
|
10548 |
m_has_attr_language = false; |
|
10549 |
} |
|
10550 |
||
10551 |
DomScript::~DomScript() |
|
10552 |
{ |
|
10553 |
} |
|
10554 |
||
10555 |
void DomScript::read(QXmlStreamReader &reader) |
|
10556 |
{ |
|
10557 |
||
10558 |
foreach (const QXmlStreamAttribute &attribute, reader.attributes()) { |
|
10559 |
QStringRef name = attribute.name(); |
|
10560 |
if (name == QLatin1String("source")) { |
|
10561 |
setAttributeSource(attribute.value().toString()); |
|
10562 |
continue; |
|
10563 |
} |
|
10564 |
if (name == QLatin1String("language")) { |
|
10565 |
setAttributeLanguage(attribute.value().toString()); |
|
10566 |
continue; |
|
10567 |
} |
|
10568 |
reader.raiseError(QLatin1String("Unexpected attribute ") + name.toString()); |
|
10569 |
} |
|
10570 |
||
10571 |
for (bool finished = false; !finished && !reader.hasError();) { |
|
10572 |
switch (reader.readNext()) { |
|
10573 |
case QXmlStreamReader::StartElement : { |
|
10574 |
const QString tag = reader.name().toString().toLower(); |
|
10575 |
reader.raiseError(QLatin1String("Unexpected element ") + tag); |
|
10576 |
} |
|
10577 |
break; |
|
10578 |
case QXmlStreamReader::EndElement : |
|
10579 |
finished = true; |
|
10580 |
break; |
|
10581 |
case QXmlStreamReader::Characters : |
|
10582 |
if (!reader.isWhitespace()) |
|
10583 |
m_text.append(reader.text().toString()); |
|
10584 |
break; |
|
10585 |
default : |
|
10586 |
break; |
|
10587 |
} |
|
10588 |
} |
|
10589 |
} |
|
10590 |
||
10591 |
#ifdef QUILOADER_QDOM_READ |
|
10592 |
void DomScript::read(const QDomElement &node) |
|
10593 |
{ |
|
10594 |
if (node.hasAttribute(QLatin1String("source"))) |
|
10595 |
setAttributeSource(node.attribute(QLatin1String("source"))); |
|
10596 |
if (node.hasAttribute(QLatin1String("language"))) |
|
10597 |
setAttributeLanguage(node.attribute(QLatin1String("language"))); |
|
10598 |
||
10599 |
for (QDomNode n = node.firstChild(); !n.isNull(); n = n.nextSibling()) { |
|
10600 |
if (!n.isElement()) |
|
10601 |
continue; |
|
10602 |
QDomElement e = n.toElement(); |
|
10603 |
QString tag = e.tagName().toLower(); |
|
10604 |
} |
|
10605 |
m_text.clear(); |
|
10606 |
for (QDomNode child = node.firstChild(); !child.isNull(); child = child.nextSibling()) { |
|
10607 |
if (child.isText()) |
|
10608 |
m_text.append(child.nodeValue()); |
|
10609 |
} |
|
10610 |
} |
|
10611 |
#endif |
|
10612 |
||
10613 |
void DomScript::write(QXmlStreamWriter &writer, const QString &tagName) const |
|
10614 |
{ |
|
10615 |
writer.writeStartElement(tagName.isEmpty() ? QString::fromUtf8("script") : tagName.toLower()); |
|
10616 |
||
10617 |
if (hasAttributeSource()) |
|
10618 |
writer.writeAttribute(QLatin1String("source"), attributeSource()); |
|
10619 |
||
10620 |
if (hasAttributeLanguage()) |
|
10621 |
writer.writeAttribute(QLatin1String("language"), attributeLanguage()); |
|
10622 |
||
10623 |
if (!m_text.isEmpty()) |
|
10624 |
writer.writeCharacters(m_text); |
|
10625 |
||
10626 |
writer.writeEndElement(); |
|
10627 |
} |
|
10628 |
||
10629 |
void DomWidgetData::clear(bool clear_all) |
|
10630 |
{ |
|
10631 |
qDeleteAll(m_property); |
|
10632 |
m_property.clear(); |
|
10633 |
||
10634 |
if (clear_all) { |
|
10635 |
m_text.clear(); |
|
10636 |
} |
|
10637 |
||
10638 |
m_children = 0; |
|
10639 |
} |
|
10640 |
||
10641 |
DomWidgetData::DomWidgetData() |
|
10642 |
{ |
|
10643 |
m_children = 0; |
|
10644 |
} |
|
10645 |
||
10646 |
DomWidgetData::~DomWidgetData() |
|
10647 |
{ |
|
10648 |
qDeleteAll(m_property); |
|
10649 |
m_property.clear(); |
|
10650 |
} |
|
10651 |
||
10652 |
void DomWidgetData::read(QXmlStreamReader &reader) |
|
10653 |
{ |
|
10654 |
||
10655 |
for (bool finished = false; !finished && !reader.hasError();) { |
|
10656 |
switch (reader.readNext()) { |
|
10657 |
case QXmlStreamReader::StartElement : { |
|
10658 |
const QString tag = reader.name().toString().toLower(); |
|
10659 |
if (tag == QLatin1String("property")) { |
|
10660 |
DomProperty *v = new DomProperty(); |
|
10661 |
v->read(reader); |
|
10662 |
m_property.append(v); |
|
10663 |
continue; |
|
10664 |
} |
|
10665 |
reader.raiseError(QLatin1String("Unexpected element ") + tag); |
|
10666 |
} |
|
10667 |
break; |
|
10668 |
case QXmlStreamReader::EndElement : |
|
10669 |
finished = true; |
|
10670 |
break; |
|
10671 |
case QXmlStreamReader::Characters : |
|
10672 |
if (!reader.isWhitespace()) |
|
10673 |
m_text.append(reader.text().toString()); |
|
10674 |
break; |
|
10675 |
default : |
|
10676 |
break; |
|
10677 |
} |
|
10678 |
} |
|
10679 |
} |
|
10680 |
||
10681 |
#ifdef QUILOADER_QDOM_READ |
|
10682 |
void DomWidgetData::read(const QDomElement &node) |
|
10683 |
{ |
|
10684 |
for (QDomNode n = node.firstChild(); !n.isNull(); n = n.nextSibling()) { |
|
10685 |
if (!n.isElement()) |
|
10686 |
continue; |
|
10687 |
QDomElement e = n.toElement(); |
|
10688 |
QString tag = e.tagName().toLower(); |
|
10689 |
if (tag == QLatin1String("property")) { |
|
10690 |
DomProperty *v = new DomProperty(); |
|
10691 |
v->read(e); |
|
10692 |
m_property.append(v); |
|
10693 |
continue; |
|
10694 |
} |
|
10695 |
} |
|
10696 |
m_text.clear(); |
|
10697 |
for (QDomNode child = node.firstChild(); !child.isNull(); child = child.nextSibling()) { |
|
10698 |
if (child.isText()) |
|
10699 |
m_text.append(child.nodeValue()); |
|
10700 |
} |
|
10701 |
} |
|
10702 |
#endif |
|
10703 |
||
10704 |
void DomWidgetData::write(QXmlStreamWriter &writer, const QString &tagName) const |
|
10705 |
{ |
|
10706 |
writer.writeStartElement(tagName.isEmpty() ? QString::fromUtf8("widgetdata") : tagName.toLower()); |
|
10707 |
||
10708 |
for (int i = 0; i < m_property.size(); ++i) { |
|
10709 |
DomProperty* v = m_property[i]; |
|
10710 |
v->write(writer, QLatin1String("property")); |
|
10711 |
} |
|
10712 |
if (!m_text.isEmpty()) |
|
10713 |
writer.writeCharacters(m_text); |
|
10714 |
||
10715 |
writer.writeEndElement(); |
|
10716 |
} |
|
10717 |
||
10718 |
void DomWidgetData::setElementProperty(const QList<DomProperty*>& a) |
|
10719 |
{ |
|
10720 |
m_children |= Property; |
|
10721 |
m_property = a; |
|
10722 |
} |
|
10723 |
||
10724 |
void DomDesignerData::clear(bool clear_all) |
|
10725 |
{ |
|
10726 |
qDeleteAll(m_property); |
|
10727 |
m_property.clear(); |
|
10728 |
||
10729 |
if (clear_all) { |
|
10730 |
m_text.clear(); |
|
10731 |
} |
|
10732 |
||
10733 |
m_children = 0; |
|
10734 |
} |
|
10735 |
||
10736 |
DomDesignerData::DomDesignerData() |
|
10737 |
{ |
|
10738 |
m_children = 0; |
|
10739 |
} |
|
10740 |
||
10741 |
DomDesignerData::~DomDesignerData() |
|
10742 |
{ |
|
10743 |
qDeleteAll(m_property); |
|
10744 |
m_property.clear(); |
|
10745 |
} |
|
10746 |
||
10747 |
void DomDesignerData::read(QXmlStreamReader &reader) |
|
10748 |
{ |
|
10749 |
||
10750 |
for (bool finished = false; !finished && !reader.hasError();) { |
|
10751 |
switch (reader.readNext()) { |
|
10752 |
case QXmlStreamReader::StartElement : { |
|
10753 |
const QString tag = reader.name().toString().toLower(); |
|
10754 |
if (tag == QLatin1String("property")) { |
|
10755 |
DomProperty *v = new DomProperty(); |
|
10756 |
v->read(reader); |
|
10757 |
m_property.append(v); |
|
10758 |
continue; |
|
10759 |
} |
|
10760 |
reader.raiseError(QLatin1String("Unexpected element ") + tag); |
|
10761 |
} |
|
10762 |
break; |
|
10763 |
case QXmlStreamReader::EndElement : |
|
10764 |
finished = true; |
|
10765 |
break; |
|
10766 |
case QXmlStreamReader::Characters : |
|
10767 |
if (!reader.isWhitespace()) |
|
10768 |
m_text.append(reader.text().toString()); |
|
10769 |
break; |
|
10770 |
default : |
|
10771 |
break; |
|
10772 |
} |
|
10773 |
} |
|
10774 |
} |
|
10775 |
||
10776 |
#ifdef QUILOADER_QDOM_READ |
|
10777 |
void DomDesignerData::read(const QDomElement &node) |
|
10778 |
{ |
|
10779 |
for (QDomNode n = node.firstChild(); !n.isNull(); n = n.nextSibling()) { |
|
10780 |
if (!n.isElement()) |
|
10781 |
continue; |
|
10782 |
QDomElement e = n.toElement(); |
|
10783 |
QString tag = e.tagName().toLower(); |
|
10784 |
if (tag == QLatin1String("property")) { |
|
10785 |
DomProperty *v = new DomProperty(); |
|
10786 |
v->read(e); |
|
10787 |
m_property.append(v); |
|
10788 |
continue; |
|
10789 |
} |
|
10790 |
} |
|
10791 |
m_text.clear(); |
|
10792 |
for (QDomNode child = node.firstChild(); !child.isNull(); child = child.nextSibling()) { |
|
10793 |
if (child.isText()) |
|
10794 |
m_text.append(child.nodeValue()); |
|
10795 |
} |
|
10796 |
} |
|
10797 |
#endif |
|
10798 |
||
10799 |
void DomDesignerData::write(QXmlStreamWriter &writer, const QString &tagName) const |
|
10800 |
{ |
|
10801 |
writer.writeStartElement(tagName.isEmpty() ? QString::fromUtf8("designerdata") : tagName.toLower()); |
|
10802 |
||
10803 |
for (int i = 0; i < m_property.size(); ++i) { |
|
10804 |
DomProperty* v = m_property[i]; |
|
10805 |
v->write(writer, QLatin1String("property")); |
|
10806 |
} |
|
10807 |
if (!m_text.isEmpty()) |
|
10808 |
writer.writeCharacters(m_text); |
|
10809 |
||
10810 |
writer.writeEndElement(); |
|
10811 |
} |
|
10812 |
||
10813 |
void DomDesignerData::setElementProperty(const QList<DomProperty*>& a) |
|
10814 |
{ |
|
10815 |
m_children |= Property; |
|
10816 |
m_property = a; |
|
10817 |
} |
|
10818 |
||
10819 |
void DomSlots::clear(bool clear_all) |
|
10820 |
{ |
|
10821 |
m_signal.clear(); |
|
10822 |
m_slot.clear(); |
|
10823 |
||
10824 |
if (clear_all) { |
|
10825 |
m_text.clear(); |
|
10826 |
} |
|
10827 |
||
10828 |
m_children = 0; |
|
10829 |
} |
|
10830 |
||
10831 |
DomSlots::DomSlots() |
|
10832 |
{ |
|
10833 |
m_children = 0; |
|
10834 |
} |
|
10835 |
||
10836 |
DomSlots::~DomSlots() |
|
10837 |
{ |
|
10838 |
m_signal.clear(); |
|
10839 |
m_slot.clear(); |
|
10840 |
} |
|
10841 |
||
10842 |
void DomSlots::read(QXmlStreamReader &reader) |
|
10843 |
{ |
|
10844 |
||
10845 |
for (bool finished = false; !finished && !reader.hasError();) { |
|
10846 |
switch (reader.readNext()) { |
|
10847 |
case QXmlStreamReader::StartElement : { |
|
10848 |
const QString tag = reader.name().toString().toLower(); |
|
10849 |
if (tag == QLatin1String("signal")) { |
|
10850 |
m_signal.append(reader.readElementText()); |
|
10851 |
continue; |
|
10852 |
} |
|
10853 |
if (tag == QLatin1String("slot")) { |
|
10854 |
m_slot.append(reader.readElementText()); |
|
10855 |
continue; |
|
10856 |
} |
|
10857 |
reader.raiseError(QLatin1String("Unexpected element ") + tag); |
|
10858 |
} |
|
10859 |
break; |
|
10860 |
case QXmlStreamReader::EndElement : |
|
10861 |
finished = true; |
|
10862 |
break; |
|
10863 |
case QXmlStreamReader::Characters : |
|
10864 |
if (!reader.isWhitespace()) |
|
10865 |
m_text.append(reader.text().toString()); |
|
10866 |
break; |
|
10867 |
default : |
|
10868 |
break; |
|
10869 |
} |
|
10870 |
} |
|
10871 |
} |
|
10872 |
||
10873 |
#ifdef QUILOADER_QDOM_READ |
|
10874 |
void DomSlots::read(const QDomElement &node) |
|
10875 |
{ |
|
10876 |
for (QDomNode n = node.firstChild(); !n.isNull(); n = n.nextSibling()) { |
|
10877 |
if (!n.isElement()) |
|
10878 |
continue; |
|
10879 |
QDomElement e = n.toElement(); |
|
10880 |
QString tag = e.tagName().toLower(); |
|
10881 |
if (tag == QLatin1String("signal")) { |
|
10882 |
m_signal.append(e.text()); |
|
10883 |
continue; |
|
10884 |
} |
|
10885 |
if (tag == QLatin1String("slot")) { |
|
10886 |
m_slot.append(e.text()); |
|
10887 |
continue; |
|
10888 |
} |
|
10889 |
} |
|
10890 |
m_text.clear(); |
|
10891 |
for (QDomNode child = node.firstChild(); !child.isNull(); child = child.nextSibling()) { |
|
10892 |
if (child.isText()) |
|
10893 |
m_text.append(child.nodeValue()); |
|
10894 |
} |
|
10895 |
} |
|
10896 |
#endif |
|
10897 |
||
10898 |
void DomSlots::write(QXmlStreamWriter &writer, const QString &tagName) const |
|
10899 |
{ |
|
10900 |
writer.writeStartElement(tagName.isEmpty() ? QString::fromUtf8("slots") : tagName.toLower()); |
|
10901 |
||
10902 |
for (int i = 0; i < m_signal.size(); ++i) { |
|
10903 |
QString v = m_signal[i]; |
|
10904 |
writer.writeTextElement(QLatin1String("signal"), v); |
|
10905 |
} |
|
10906 |
for (int i = 0; i < m_slot.size(); ++i) { |
|
10907 |
QString v = m_slot[i]; |
|
10908 |
writer.writeTextElement(QLatin1String("slot"), v); |
|
10909 |
} |
|
10910 |
if (!m_text.isEmpty()) |
|
10911 |
writer.writeCharacters(m_text); |
|
10912 |
||
10913 |
writer.writeEndElement(); |
|
10914 |
} |
|
10915 |
||
10916 |
void DomSlots::setElementSignal(const QStringList& a) |
|
10917 |
{ |
|
10918 |
m_children |= Signal; |
|
10919 |
m_signal = a; |
|
10920 |
} |
|
10921 |
||
10922 |
void DomSlots::setElementSlot(const QStringList& a) |
|
10923 |
{ |
|
10924 |
m_children |= Slot; |
|
10925 |
m_slot = a; |
|
10926 |
} |
|
10927 |
||
10928 |
void DomPropertySpecifications::clear(bool clear_all) |
|
10929 |
{ |
|
10930 |
qDeleteAll(m_stringpropertyspecification); |
|
10931 |
m_stringpropertyspecification.clear(); |
|
10932 |
||
10933 |
if (clear_all) { |
|
10934 |
m_text.clear(); |
|
10935 |
} |
|
10936 |
||
10937 |
m_children = 0; |
|
10938 |
} |
|
10939 |
||
10940 |
DomPropertySpecifications::DomPropertySpecifications() |
|
10941 |
{ |
|
10942 |
m_children = 0; |
|
10943 |
} |
|
10944 |
||
10945 |
DomPropertySpecifications::~DomPropertySpecifications() |
|
10946 |
{ |
|
10947 |
qDeleteAll(m_stringpropertyspecification); |
|
10948 |
m_stringpropertyspecification.clear(); |
|
10949 |
} |
|
10950 |
||
10951 |
void DomPropertySpecifications::read(QXmlStreamReader &reader) |
|
10952 |
{ |
|
10953 |
||
10954 |
for (bool finished = false; !finished && !reader.hasError();) { |
|
10955 |
switch (reader.readNext()) { |
|
10956 |
case QXmlStreamReader::StartElement : { |
|
10957 |
const QString tag = reader.name().toString().toLower(); |
|
10958 |
if (tag == QLatin1String("stringpropertyspecification")) { |
|
10959 |
DomStringPropertySpecification *v = new DomStringPropertySpecification(); |
|
10960 |
v->read(reader); |
|
10961 |
m_stringpropertyspecification.append(v); |
|
10962 |
continue; |
|
10963 |
} |
|
10964 |
reader.raiseError(QLatin1String("Unexpected element ") + tag); |
|
10965 |
} |
|
10966 |
break; |
|
10967 |
case QXmlStreamReader::EndElement : |
|
10968 |
finished = true; |
|
10969 |
break; |
|
10970 |
case QXmlStreamReader::Characters : |
|
10971 |
if (!reader.isWhitespace()) |
|
10972 |
m_text.append(reader.text().toString()); |
|
10973 |
break; |
|
10974 |
default : |
|
10975 |
break; |
|
10976 |
} |
|
10977 |
} |
|
10978 |
} |
|
10979 |
||
10980 |
#ifdef QUILOADER_QDOM_READ |
|
10981 |
void DomPropertySpecifications::read(const QDomElement &node) |
|
10982 |
{ |
|
10983 |
for (QDomNode n = node.firstChild(); !n.isNull(); n = n.nextSibling()) { |
|
10984 |
if (!n.isElement()) |
|
10985 |
continue; |
|
10986 |
QDomElement e = n.toElement(); |
|
10987 |
QString tag = e.tagName().toLower(); |
|
10988 |
if (tag == QLatin1String("stringpropertyspecification")) { |
|
10989 |
DomStringPropertySpecification *v = new DomStringPropertySpecification(); |
|
10990 |
v->read(e); |
|
10991 |
m_stringpropertyspecification.append(v); |
|
10992 |
continue; |
|
10993 |
} |
|
10994 |
} |
|
10995 |
m_text.clear(); |
|
10996 |
for (QDomNode child = node.firstChild(); !child.isNull(); child = child.nextSibling()) { |
|
10997 |
if (child.isText()) |
|
10998 |
m_text.append(child.nodeValue()); |
|
10999 |
} |
|
11000 |
} |
|
11001 |
#endif |
|
11002 |
||
11003 |
void DomPropertySpecifications::write(QXmlStreamWriter &writer, const QString &tagName) const |
|
11004 |
{ |
|
11005 |
writer.writeStartElement(tagName.isEmpty() ? QString::fromUtf8("propertyspecifications") : tagName.toLower()); |
|
11006 |
||
11007 |
for (int i = 0; i < m_stringpropertyspecification.size(); ++i) { |
|
11008 |
DomStringPropertySpecification* v = m_stringpropertyspecification[i]; |
|
11009 |
v->write(writer, QLatin1String("stringpropertyspecification")); |
|
11010 |
} |
|
11011 |
if (!m_text.isEmpty()) |
|
11012 |
writer.writeCharacters(m_text); |
|
11013 |
||
11014 |
writer.writeEndElement(); |
|
11015 |
} |
|
11016 |
||
11017 |
void DomPropertySpecifications::setElementStringpropertyspecification(const QList<DomStringPropertySpecification*>& a) |
|
11018 |
{ |
|
11019 |
m_children |= Stringpropertyspecification; |
|
11020 |
m_stringpropertyspecification = a; |
|
11021 |
} |
|
11022 |
||
11023 |
void DomStringPropertySpecification::clear(bool clear_all) |
|
11024 |
{ |
|
11025 |
||
11026 |
if (clear_all) { |
|
11027 |
m_text.clear(); |
|
11028 |
m_has_attr_name = false; |
|
11029 |
m_has_attr_type = false; |
|
11030 |
m_has_attr_notr = false; |
|
11031 |
} |
|
11032 |
||
11033 |
m_children = 0; |
|
11034 |
} |
|
11035 |
||
11036 |
DomStringPropertySpecification::DomStringPropertySpecification() |
|
11037 |
{ |
|
11038 |
m_children = 0; |
|
11039 |
m_has_attr_name = false; |
|
11040 |
m_has_attr_type = false; |
|
11041 |
m_has_attr_notr = false; |
|
11042 |
} |
|
11043 |
||
11044 |
DomStringPropertySpecification::~DomStringPropertySpecification() |
|
11045 |
{ |
|
11046 |
} |
|
11047 |
||
11048 |
void DomStringPropertySpecification::read(QXmlStreamReader &reader) |
|
11049 |
{ |
|
11050 |
||
11051 |
foreach (const QXmlStreamAttribute &attribute, reader.attributes()) { |
|
11052 |
QStringRef name = attribute.name(); |
|
11053 |
if (name == QLatin1String("name")) { |
|
11054 |
setAttributeName(attribute.value().toString()); |
|
11055 |
continue; |
|
11056 |
} |
|
11057 |
if (name == QLatin1String("type")) { |
|
11058 |
setAttributeType(attribute.value().toString()); |
|
11059 |
continue; |
|
11060 |
} |
|
11061 |
if (name == QLatin1String("notr")) { |
|
11062 |
setAttributeNotr(attribute.value().toString()); |
|
11063 |
continue; |
|
11064 |
} |
|
11065 |
reader.raiseError(QLatin1String("Unexpected attribute ") + name.toString()); |
|
11066 |
} |
|
11067 |
||
11068 |
for (bool finished = false; !finished && !reader.hasError();) { |
|
11069 |
switch (reader.readNext()) { |
|
11070 |
case QXmlStreamReader::StartElement : { |
|
11071 |
const QString tag = reader.name().toString().toLower(); |
|
11072 |
reader.raiseError(QLatin1String("Unexpected element ") + tag); |
|
11073 |
} |
|
11074 |
break; |
|
11075 |
case QXmlStreamReader::EndElement : |
|
11076 |
finished = true; |
|
11077 |
break; |
|
11078 |
case QXmlStreamReader::Characters : |
|
11079 |
if (!reader.isWhitespace()) |
|
11080 |
m_text.append(reader.text().toString()); |
|
11081 |
break; |
|
11082 |
default : |
|
11083 |
break; |
|
11084 |
} |
|
11085 |
} |
|
11086 |
} |
|
11087 |
||
11088 |
#ifdef QUILOADER_QDOM_READ |
|
11089 |
void DomStringPropertySpecification::read(const QDomElement &node) |
|
11090 |
{ |
|
11091 |
if (node.hasAttribute(QLatin1String("name"))) |
|
11092 |
setAttributeName(node.attribute(QLatin1String("name"))); |
|
11093 |
if (node.hasAttribute(QLatin1String("type"))) |
|
11094 |
setAttributeType(node.attribute(QLatin1String("type"))); |
|
11095 |
if (node.hasAttribute(QLatin1String("notr"))) |
|
11096 |
setAttributeNotr(node.attribute(QLatin1String("notr"))); |
|
11097 |
||
11098 |
for (QDomNode n = node.firstChild(); !n.isNull(); n = n.nextSibling()) { |
|
11099 |
if (!n.isElement()) |
|
11100 |
continue; |
|
11101 |
QDomElement e = n.toElement(); |
|
11102 |
QString tag = e.tagName().toLower(); |
|
11103 |
} |
|
11104 |
m_text.clear(); |
|
11105 |
for (QDomNode child = node.firstChild(); !child.isNull(); child = child.nextSibling()) { |
|
11106 |
if (child.isText()) |
|
11107 |
m_text.append(child.nodeValue()); |
|
11108 |
} |
|
11109 |
} |
|
11110 |
#endif |
|
11111 |
||
11112 |
void DomStringPropertySpecification::write(QXmlStreamWriter &writer, const QString &tagName) const |
|
11113 |
{ |
|
11114 |
writer.writeStartElement(tagName.isEmpty() ? QString::fromUtf8("stringpropertyspecification") : tagName.toLower()); |
|
11115 |
||
11116 |
if (hasAttributeName()) |
|
11117 |
writer.writeAttribute(QLatin1String("name"), attributeName()); |
|
11118 |
||
11119 |
if (hasAttributeType()) |
|
11120 |
writer.writeAttribute(QLatin1String("type"), attributeType()); |
|
11121 |
||
11122 |
if (hasAttributeNotr()) |
|
11123 |
writer.writeAttribute(QLatin1String("notr"), attributeNotr()); |
|
11124 |
||
11125 |
if (!m_text.isEmpty()) |
|
11126 |
writer.writeCharacters(m_text); |
|
11127 |
||
11128 |
writer.writeEndElement(); |
|
11129 |
} |
|
11130 |
||
11131 |
QT_END_NAMESPACE |
|
11132 |