~oif-team/ubuntu/natty/qt4-x11/xi2.1

« back to all changes in this revision

Viewing changes to src/tools/uic/ui4.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Adam Conrad
  • Date: 2005-08-24 04:09:09 UTC
  • Revision ID: james.westby@ubuntu.com-20050824040909-xmxe9jfr4a0w5671
Tags: upstream-4.0.0
ImportĀ upstreamĀ versionĀ 4.0.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/****************************************************************************
 
2
**
 
3
** Copyright (C) 1992-2005 Trolltech AS. All rights reserved.
 
4
**
 
5
** This file is part of the tools applications of the Qt Toolkit.
 
6
**
 
7
** This file may be distributed under the terms of the Q Public License
 
8
** as defined by Trolltech AS of Norway and appearing in the file
 
9
** LICENSE.QPL included in the packaging of this file.
 
10
**
 
11
** This file may be distributed and/or modified under the terms of the
 
12
** GNU General Public License version 2 as published by the Free Software
 
13
** Foundation and appearing in the file LICENSE.GPL included in the
 
14
** packaging of this file.
 
15
**
 
16
** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for
 
17
**   information about Qt Commercial License Agreements.
 
18
** See http://www.trolltech.com/qpl/ for QPL licensing information.
 
19
** See http://www.trolltech.com/gpl/ for GPL licensing information.
 
20
**
 
21
** Contact info@trolltech.com if any conditions of this licensing are
 
22
** not clear to you.
 
23
**
 
24
** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
 
25
** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
 
26
**
 
27
****************************************************************************/
 
28
#include "ui4.h"
 
29
#include <QtXml/QDomDocument>
 
30
 
 
31
/*******************************************************************************
 
32
** Implementations
 
33
*/
 
34
 
 
35
void DomUI::clear(bool clear_all)
 
36
{
 
37
    delete m_widget;
 
38
    delete m_layoutDefault;
 
39
    delete m_layoutFunction;
 
40
    delete m_customWidgets;
 
41
    delete m_tabStops;
 
42
    delete m_images;
 
43
    delete m_includes;
 
44
    delete m_resources;
 
45
    delete m_connections;
 
46
 
 
47
    if (clear_all) {
 
48
    m_text = QString();
 
49
    m_has_attr_version = false;
 
50
    m_has_attr_stdSetDef = false;
 
51
    m_attr_stdSetDef = 0;
 
52
    }
 
53
 
 
54
    m_widget = 0;
 
55
    m_layoutDefault = 0;
 
56
    m_layoutFunction = 0;
 
57
    m_customWidgets = 0;
 
58
    m_tabStops = 0;
 
59
    m_images = 0;
 
60
    m_includes = 0;
 
61
    m_resources = 0;
 
62
    m_connections = 0;
 
63
}
 
64
 
 
65
DomUI::DomUI()
 
66
{
 
67
    m_has_attr_version = false;
 
68
    m_has_attr_stdSetDef = false;
 
69
    m_attr_stdSetDef = 0;
 
70
    m_widget = 0;
 
71
    m_layoutDefault = 0;
 
72
    m_layoutFunction = 0;
 
73
    m_customWidgets = 0;
 
74
    m_tabStops = 0;
 
75
    m_images = 0;
 
76
    m_includes = 0;
 
77
    m_resources = 0;
 
78
    m_connections = 0;
 
79
}
 
80
 
 
81
DomUI::~DomUI()
 
82
{
 
83
    delete m_widget;
 
84
    delete m_layoutDefault;
 
85
    delete m_layoutFunction;
 
86
    delete m_customWidgets;
 
87
    delete m_tabStops;
 
88
    delete m_images;
 
89
    delete m_includes;
 
90
    delete m_resources;
 
91
    delete m_connections;
 
92
}
 
93
 
 
94
void DomUI::read(const QDomElement &node)
 
95
{
 
96
    if (node.hasAttribute(QLatin1String("version")))
 
97
        setAttributeVersion(node.attribute(QLatin1String("version")));
 
98
    if (node.hasAttribute(QLatin1String("stdsetdef")))
 
99
        setAttributeStdSetDef(node.attribute(QLatin1String("stdsetdef")).toInt());
 
100
 
 
101
    for (QDomNode n = node.firstChild(); !n.isNull(); n = n.nextSibling()) {
 
102
        if (!n.isElement())
 
103
            continue;
 
104
        QDomElement e = n.toElement();
 
105
        QString tag = e.tagName().toLower();
 
106
        if (tag == QLatin1String("author")) {
 
107
            setElementAuthor(e.text());
 
108
            continue;
 
109
        }
 
110
        if (tag == QLatin1String("comment")) {
 
111
            setElementComment(e.text());
 
112
            continue;
 
113
        }
 
114
        if (tag == QLatin1String("exportmacro")) {
 
115
            setElementExportMacro(e.text());
 
116
            continue;
 
117
        }
 
118
        if (tag == QLatin1String("class")) {
 
119
            setElementClass(e.text());
 
120
            continue;
 
121
        }
 
122
        if (tag == QLatin1String("widget")) {
 
123
            DomWidget *v = new DomWidget();
 
124
            v->read(e);
 
125
            setElementWidget(v);
 
126
            continue;
 
127
        }
 
128
        if (tag == QLatin1String("layoutdefault")) {
 
129
            DomLayoutDefault *v = new DomLayoutDefault();
 
130
            v->read(e);
 
131
            setElementLayoutDefault(v);
 
132
            continue;
 
133
        }
 
134
        if (tag == QLatin1String("layoutfunction")) {
 
135
            DomLayoutFunction *v = new DomLayoutFunction();
 
136
            v->read(e);
 
137
            setElementLayoutFunction(v);
 
138
            continue;
 
139
        }
 
140
        if (tag == QLatin1String("pixmapfunction")) {
 
141
            setElementPixmapFunction(e.text());
 
142
            continue;
 
143
        }
 
144
        if (tag == QLatin1String("customwidgets")) {
 
145
            DomCustomWidgets *v = new DomCustomWidgets();
 
146
            v->read(e);
 
147
            setElementCustomWidgets(v);
 
148
            continue;
 
149
        }
 
150
        if (tag == QLatin1String("tabstops")) {
 
151
            DomTabStops *v = new DomTabStops();
 
152
            v->read(e);
 
153
            setElementTabStops(v);
 
154
            continue;
 
155
        }
 
156
        if (tag == QLatin1String("images")) {
 
157
            DomImages *v = new DomImages();
 
158
            v->read(e);
 
159
            setElementImages(v);
 
160
            continue;
 
161
        }
 
162
        if (tag == QLatin1String("includes")) {
 
163
            DomIncludes *v = new DomIncludes();
 
164
            v->read(e);
 
165
            setElementIncludes(v);
 
166
            continue;
 
167
        }
 
168
        if (tag == QLatin1String("resources")) {
 
169
            DomResources *v = new DomResources();
 
170
            v->read(e);
 
171
            setElementResources(v);
 
172
            continue;
 
173
        }
 
174
        if (tag == QLatin1String("connections")) {
 
175
            DomConnections *v = new DomConnections();
 
176
            v->read(e);
 
177
            setElementConnections(v);
 
178
            continue;
 
179
        }
 
180
    }
 
181
 
 
182
    m_text.clear();
 
183
    for (QDomNode child = node.firstChild(); !child.isNull(); child = child.nextSibling()) {
 
184
        if (child.isText())
 
185
            m_text.append(child.nodeValue());
 
186
    }
 
187
}
 
188
 
 
189
QDomElement DomUI::write(QDomDocument &doc, const QString &tagName)
 
190
{
 
191
    QDomElement e = doc.createElement(tagName.isEmpty() ? QString::fromLatin1("ui") : tagName.toLower());
 
192
 
 
193
    QDomElement child;
 
194
 
 
195
    if (hasAttributeVersion())
 
196
        e.setAttribute(QLatin1String("version"), attributeVersion());
 
197
 
 
198
    if (hasAttributeStdSetDef())
 
199
        e.setAttribute(QLatin1String("stdsetdef"), attributeStdSetDef());
 
200
 
 
201
    child = doc.createElement(QLatin1String("author"));
 
202
    child.appendChild(doc.createTextNode(m_author));
 
203
    e.appendChild(child);
 
204
 
 
205
    child = doc.createElement(QLatin1String("comment"));
 
206
    child.appendChild(doc.createTextNode(m_comment));
 
207
    e.appendChild(child);
 
208
 
 
209
    child = doc.createElement(QLatin1String("exportmacro"));
 
210
    child.appendChild(doc.createTextNode(m_exportMacro));
 
211
    e.appendChild(child);
 
212
 
 
213
    child = doc.createElement(QLatin1String("class"));
 
214
    child.appendChild(doc.createTextNode(m_class));
 
215
    e.appendChild(child);
 
216
 
 
217
    if (m_widget != 0)
 
218
        e.appendChild(m_widget->write(doc, QLatin1String("widget")));
 
219
 
 
220
    if (m_layoutDefault != 0)
 
221
        e.appendChild(m_layoutDefault->write(doc, QLatin1String("layoutdefault")));
 
222
 
 
223
    if (m_layoutFunction != 0)
 
224
        e.appendChild(m_layoutFunction->write(doc, QLatin1String("layoutfunction")));
 
225
 
 
226
    child = doc.createElement(QLatin1String("pixmapfunction"));
 
227
    child.appendChild(doc.createTextNode(m_pixmapFunction));
 
228
    e.appendChild(child);
 
229
 
 
230
    if (m_customWidgets != 0)
 
231
        e.appendChild(m_customWidgets->write(doc, QLatin1String("customwidgets")));
 
232
 
 
233
    if (m_tabStops != 0)
 
234
        e.appendChild(m_tabStops->write(doc, QLatin1String("tabstops")));
 
235
 
 
236
    if (m_images != 0)
 
237
        e.appendChild(m_images->write(doc, QLatin1String("images")));
 
238
 
 
239
    if (m_includes != 0)
 
240
        e.appendChild(m_includes->write(doc, QLatin1String("includes")));
 
241
 
 
242
    if (m_resources != 0)
 
243
        e.appendChild(m_resources->write(doc, QLatin1String("resources")));
 
244
 
 
245
    if (m_connections != 0)
 
246
        e.appendChild(m_connections->write(doc, QLatin1String("connections")));
 
247
 
 
248
    if (!m_text.isEmpty())
 
249
        e.appendChild(doc.createTextNode(m_text));
 
250
 
 
251
    return e;
 
252
}
 
253
 
 
254
void DomUI::setElementAuthor(const QString& a)
 
255
{
 
256
    m_author = a;
 
257
}
 
258
 
 
259
void DomUI::setElementComment(const QString& a)
 
260
{
 
261
    m_comment = a;
 
262
}
 
263
 
 
264
void DomUI::setElementExportMacro(const QString& a)
 
265
{
 
266
    m_exportMacro = a;
 
267
}
 
268
 
 
269
void DomUI::setElementClass(const QString& a)
 
270
{
 
271
    m_class = a;
 
272
}
 
273
 
 
274
void DomUI::setElementWidget(DomWidget* a)
 
275
{
 
276
    delete m_widget;
 
277
    m_widget = a;
 
278
}
 
279
 
 
280
void DomUI::setElementLayoutDefault(DomLayoutDefault* a)
 
281
{
 
282
    delete m_layoutDefault;
 
283
    m_layoutDefault = a;
 
284
}
 
285
 
 
286
void DomUI::setElementLayoutFunction(DomLayoutFunction* a)
 
287
{
 
288
    delete m_layoutFunction;
 
289
    m_layoutFunction = a;
 
290
}
 
291
 
 
292
void DomUI::setElementPixmapFunction(const QString& a)
 
293
{
 
294
    m_pixmapFunction = a;
 
295
}
 
296
 
 
297
void DomUI::setElementCustomWidgets(DomCustomWidgets* a)
 
298
{
 
299
    delete m_customWidgets;
 
300
    m_customWidgets = a;
 
301
}
 
302
 
 
303
void DomUI::setElementTabStops(DomTabStops* a)
 
304
{
 
305
    delete m_tabStops;
 
306
    m_tabStops = a;
 
307
}
 
308
 
 
309
void DomUI::setElementImages(DomImages* a)
 
310
{
 
311
    delete m_images;
 
312
    m_images = a;
 
313
}
 
314
 
 
315
void DomUI::setElementIncludes(DomIncludes* a)
 
316
{
 
317
    delete m_includes;
 
318
    m_includes = a;
 
319
}
 
320
 
 
321
void DomUI::setElementResources(DomResources* a)
 
322
{
 
323
    delete m_resources;
 
324
    m_resources = a;
 
325
}
 
326
 
 
327
void DomUI::setElementConnections(DomConnections* a)
 
328
{
 
329
    delete m_connections;
 
330
    m_connections = a;
 
331
}
 
332
 
 
333
void DomIncludes::clear(bool clear_all)
 
334
{
 
335
    for (int i = 0; i < m_include.size(); ++i)
 
336
        delete m_include[i];
 
337
    m_include.clear();
 
338
 
 
339
    if (clear_all) {
 
340
    m_text = QString();
 
341
    }
 
342
 
 
343
}
 
344
 
 
345
DomIncludes::DomIncludes()
 
346
{
 
347
}
 
348
 
 
349
DomIncludes::~DomIncludes()
 
350
{
 
351
    for (int i = 0; i < m_include.size(); ++i)
 
352
        delete m_include[i];
 
353
    m_include.clear();
 
354
}
 
355
 
 
356
void DomIncludes::read(const QDomElement &node)
 
357
{
 
358
 
 
359
    for (QDomNode n = node.firstChild(); !n.isNull(); n = n.nextSibling()) {
 
360
        if (!n.isElement())
 
361
            continue;
 
362
        QDomElement e = n.toElement();
 
363
        QString tag = e.tagName().toLower();
 
364
        if (tag == QLatin1String("include")) {
 
365
            DomInclude *v = new DomInclude();
 
366
            v->read(e);
 
367
            m_include.append(v);
 
368
            continue;
 
369
        }
 
370
    }
 
371
 
 
372
    m_text.clear();
 
373
    for (QDomNode child = node.firstChild(); !child.isNull(); child = child.nextSibling()) {
 
374
        if (child.isText())
 
375
            m_text.append(child.nodeValue());
 
376
    }
 
377
}
 
378
 
 
379
QDomElement DomIncludes::write(QDomDocument &doc, const QString &tagName)
 
380
{
 
381
    QDomElement e = doc.createElement(tagName.isEmpty() ? QString::fromLatin1("includes") : tagName.toLower());
 
382
 
 
383
    QDomElement child;
 
384
 
 
385
    for (int i = 0; i < m_include.size(); ++i) {
 
386
        DomInclude* v = m_include[i];
 
387
        QDomNode child = v->write(doc, QLatin1String("include"));
 
388
        e.appendChild(child);
 
389
    }
 
390
    if (!m_text.isEmpty())
 
391
        e.appendChild(doc.createTextNode(m_text));
 
392
 
 
393
    return e;
 
394
}
 
395
 
 
396
void DomIncludes::setElementInclude(const QList<DomInclude*>& a)
 
397
{
 
398
    m_include = a;
 
399
}
 
400
 
 
401
void DomInclude::clear(bool clear_all)
 
402
{
 
403
 
 
404
    if (clear_all) {
 
405
    m_text = QString();
 
406
    m_has_attr_location = false;
 
407
    m_has_attr_impldecl = false;
 
408
    }
 
409
 
 
410
}
 
411
 
 
412
DomInclude::DomInclude()
 
413
{
 
414
    m_has_attr_location = false;
 
415
    m_has_attr_impldecl = false;
 
416
}
 
417
 
 
418
DomInclude::~DomInclude()
 
419
{
 
420
}
 
421
 
 
422
void DomInclude::read(const QDomElement &node)
 
423
{
 
424
    if (node.hasAttribute(QLatin1String("location")))
 
425
        setAttributeLocation(node.attribute(QLatin1String("location")));
 
426
    if (node.hasAttribute(QLatin1String("impldecl")))
 
427
        setAttributeImpldecl(node.attribute(QLatin1String("impldecl")));
 
428
 
 
429
    for (QDomNode n = node.firstChild(); !n.isNull(); n = n.nextSibling()) {
 
430
        if (!n.isElement())
 
431
            continue;
 
432
        QDomElement e = n.toElement();
 
433
        QString tag = e.tagName().toLower();
 
434
    }
 
435
 
 
436
    m_text.clear();
 
437
    for (QDomNode child = node.firstChild(); !child.isNull(); child = child.nextSibling()) {
 
438
        if (child.isText())
 
439
            m_text.append(child.nodeValue());
 
440
    }
 
441
}
 
442
 
 
443
QDomElement DomInclude::write(QDomDocument &doc, const QString &tagName)
 
444
{
 
445
    QDomElement e = doc.createElement(tagName.isEmpty() ? QString::fromLatin1("include") : tagName.toLower());
 
446
 
 
447
    QDomElement child;
 
448
 
 
449
    if (hasAttributeLocation())
 
450
        e.setAttribute(QLatin1String("location"), attributeLocation());
 
451
 
 
452
    if (hasAttributeImpldecl())
 
453
        e.setAttribute(QLatin1String("impldecl"), attributeImpldecl());
 
454
 
 
455
    if (!m_text.isEmpty())
 
456
        e.appendChild(doc.createTextNode(m_text));
 
457
 
 
458
    return e;
 
459
}
 
460
 
 
461
void DomResources::clear(bool clear_all)
 
462
{
 
463
    for (int i = 0; i < m_include.size(); ++i)
 
464
        delete m_include[i];
 
465
    m_include.clear();
 
466
 
 
467
    if (clear_all) {
 
468
    m_text = QString();
 
469
    m_has_attr_name = false;
 
470
    }
 
471
 
 
472
}
 
473
 
 
474
DomResources::DomResources()
 
475
{
 
476
    m_has_attr_name = false;
 
477
}
 
478
 
 
479
DomResources::~DomResources()
 
480
{
 
481
    for (int i = 0; i < m_include.size(); ++i)
 
482
        delete m_include[i];
 
483
    m_include.clear();
 
484
}
 
485
 
 
486
void DomResources::read(const QDomElement &node)
 
487
{
 
488
    if (node.hasAttribute(QLatin1String("name")))
 
489
        setAttributeName(node.attribute(QLatin1String("name")));
 
490
 
 
491
    for (QDomNode n = node.firstChild(); !n.isNull(); n = n.nextSibling()) {
 
492
        if (!n.isElement())
 
493
            continue;
 
494
        QDomElement e = n.toElement();
 
495
        QString tag = e.tagName().toLower();
 
496
        if (tag == QLatin1String("include")) {
 
497
            DomResource *v = new DomResource();
 
498
            v->read(e);
 
499
            m_include.append(v);
 
500
            continue;
 
501
        }
 
502
    }
 
503
 
 
504
    m_text.clear();
 
505
    for (QDomNode child = node.firstChild(); !child.isNull(); child = child.nextSibling()) {
 
506
        if (child.isText())
 
507
            m_text.append(child.nodeValue());
 
508
    }
 
509
}
 
510
 
 
511
QDomElement DomResources::write(QDomDocument &doc, const QString &tagName)
 
512
{
 
513
    QDomElement e = doc.createElement(tagName.isEmpty() ? QString::fromLatin1("resources") : tagName.toLower());
 
514
 
 
515
    QDomElement child;
 
516
 
 
517
    if (hasAttributeName())
 
518
        e.setAttribute(QLatin1String("name"), attributeName());
 
519
 
 
520
    for (int i = 0; i < m_include.size(); ++i) {
 
521
        DomResource* v = m_include[i];
 
522
        QDomNode child = v->write(doc, QLatin1String("include"));
 
523
        e.appendChild(child);
 
524
    }
 
525
    if (!m_text.isEmpty())
 
526
        e.appendChild(doc.createTextNode(m_text));
 
527
 
 
528
    return e;
 
529
}
 
530
 
 
531
void DomResources::setElementInclude(const QList<DomResource*>& a)
 
532
{
 
533
    m_include = a;
 
534
}
 
535
 
 
536
void DomResource::clear(bool clear_all)
 
537
{
 
538
 
 
539
    if (clear_all) {
 
540
    m_text = QString();
 
541
    m_has_attr_location = false;
 
542
    }
 
543
 
 
544
}
 
545
 
 
546
DomResource::DomResource()
 
547
{
 
548
    m_has_attr_location = false;
 
549
}
 
550
 
 
551
DomResource::~DomResource()
 
552
{
 
553
}
 
554
 
 
555
void DomResource::read(const QDomElement &node)
 
556
{
 
557
    if (node.hasAttribute(QLatin1String("location")))
 
558
        setAttributeLocation(node.attribute(QLatin1String("location")));
 
559
 
 
560
    for (QDomNode n = node.firstChild(); !n.isNull(); n = n.nextSibling()) {
 
561
        if (!n.isElement())
 
562
            continue;
 
563
        QDomElement e = n.toElement();
 
564
        QString tag = e.tagName().toLower();
 
565
    }
 
566
 
 
567
    m_text.clear();
 
568
    for (QDomNode child = node.firstChild(); !child.isNull(); child = child.nextSibling()) {
 
569
        if (child.isText())
 
570
            m_text.append(child.nodeValue());
 
571
    }
 
572
}
 
573
 
 
574
QDomElement DomResource::write(QDomDocument &doc, const QString &tagName)
 
575
{
 
576
    QDomElement e = doc.createElement(tagName.isEmpty() ? QString::fromLatin1("resource") : tagName.toLower());
 
577
 
 
578
    QDomElement child;
 
579
 
 
580
    if (hasAttributeLocation())
 
581
        e.setAttribute(QLatin1String("location"), attributeLocation());
 
582
 
 
583
    if (!m_text.isEmpty())
 
584
        e.appendChild(doc.createTextNode(m_text));
 
585
 
 
586
    return e;
 
587
}
 
588
 
 
589
void DomActionGroup::clear(bool clear_all)
 
590
{
 
591
    for (int i = 0; i < m_action.size(); ++i)
 
592
        delete m_action[i];
 
593
    m_action.clear();
 
594
    for (int i = 0; i < m_actionGroup.size(); ++i)
 
595
        delete m_actionGroup[i];
 
596
    m_actionGroup.clear();
 
597
    for (int i = 0; i < m_property.size(); ++i)
 
598
        delete m_property[i];
 
599
    m_property.clear();
 
600
    for (int i = 0; i < m_attribute.size(); ++i)
 
601
        delete m_attribute[i];
 
602
    m_attribute.clear();
 
603
 
 
604
    if (clear_all) {
 
605
    m_text = QString();
 
606
    m_has_attr_name = false;
 
607
    }
 
608
 
 
609
}
 
610
 
 
611
DomActionGroup::DomActionGroup()
 
612
{
 
613
    m_has_attr_name = false;
 
614
}
 
615
 
 
616
DomActionGroup::~DomActionGroup()
 
617
{
 
618
    for (int i = 0; i < m_action.size(); ++i)
 
619
        delete m_action[i];
 
620
    m_action.clear();
 
621
    for (int i = 0; i < m_actionGroup.size(); ++i)
 
622
        delete m_actionGroup[i];
 
623
    m_actionGroup.clear();
 
624
    for (int i = 0; i < m_property.size(); ++i)
 
625
        delete m_property[i];
 
626
    m_property.clear();
 
627
    for (int i = 0; i < m_attribute.size(); ++i)
 
628
        delete m_attribute[i];
 
629
    m_attribute.clear();
 
630
}
 
631
 
 
632
void DomActionGroup::read(const QDomElement &node)
 
633
{
 
634
    if (node.hasAttribute(QLatin1String("name")))
 
635
        setAttributeName(node.attribute(QLatin1String("name")));
 
636
 
 
637
    for (QDomNode n = node.firstChild(); !n.isNull(); n = n.nextSibling()) {
 
638
        if (!n.isElement())
 
639
            continue;
 
640
        QDomElement e = n.toElement();
 
641
        QString tag = e.tagName().toLower();
 
642
        if (tag == QLatin1String("action")) {
 
643
            DomAction *v = new DomAction();
 
644
            v->read(e);
 
645
            m_action.append(v);
 
646
            continue;
 
647
        }
 
648
        if (tag == QLatin1String("actiongroup")) {
 
649
            DomActionGroup *v = new DomActionGroup();
 
650
            v->read(e);
 
651
            m_actionGroup.append(v);
 
652
            continue;
 
653
        }
 
654
        if (tag == QLatin1String("property")) {
 
655
            DomProperty *v = new DomProperty();
 
656
            v->read(e);
 
657
            m_property.append(v);
 
658
            continue;
 
659
        }
 
660
        if (tag == QLatin1String("attribute")) {
 
661
            DomProperty *v = new DomProperty();
 
662
            v->read(e);
 
663
            m_attribute.append(v);
 
664
            continue;
 
665
        }
 
666
    }
 
667
 
 
668
    m_text.clear();
 
669
    for (QDomNode child = node.firstChild(); !child.isNull(); child = child.nextSibling()) {
 
670
        if (child.isText())
 
671
            m_text.append(child.nodeValue());
 
672
    }
 
673
}
 
674
 
 
675
QDomElement DomActionGroup::write(QDomDocument &doc, const QString &tagName)
 
676
{
 
677
    QDomElement e = doc.createElement(tagName.isEmpty() ? QString::fromLatin1("actiongroup") : tagName.toLower());
 
678
 
 
679
    QDomElement child;
 
680
 
 
681
    if (hasAttributeName())
 
682
        e.setAttribute(QLatin1String("name"), attributeName());
 
683
 
 
684
    for (int i = 0; i < m_action.size(); ++i) {
 
685
        DomAction* v = m_action[i];
 
686
        QDomNode child = v->write(doc, QLatin1String("action"));
 
687
        e.appendChild(child);
 
688
    }
 
689
    for (int i = 0; i < m_actionGroup.size(); ++i) {
 
690
        DomActionGroup* v = m_actionGroup[i];
 
691
        QDomNode child = v->write(doc, QLatin1String("actiongroup"));
 
692
        e.appendChild(child);
 
693
    }
 
694
    for (int i = 0; i < m_property.size(); ++i) {
 
695
        DomProperty* v = m_property[i];
 
696
        QDomNode child = v->write(doc, QLatin1String("property"));
 
697
        e.appendChild(child);
 
698
    }
 
699
    for (int i = 0; i < m_attribute.size(); ++i) {
 
700
        DomProperty* v = m_attribute[i];
 
701
        QDomNode child = v->write(doc, QLatin1String("attribute"));
 
702
        e.appendChild(child);
 
703
    }
 
704
    if (!m_text.isEmpty())
 
705
        e.appendChild(doc.createTextNode(m_text));
 
706
 
 
707
    return e;
 
708
}
 
709
 
 
710
void DomActionGroup::setElementAction(const QList<DomAction*>& a)
 
711
{
 
712
    m_action = a;
 
713
}
 
714
 
 
715
void DomActionGroup::setElementActionGroup(const QList<DomActionGroup*>& a)
 
716
{
 
717
    m_actionGroup = a;
 
718
}
 
719
 
 
720
void DomActionGroup::setElementProperty(const QList<DomProperty*>& a)
 
721
{
 
722
    m_property = a;
 
723
}
 
724
 
 
725
void DomActionGroup::setElementAttribute(const QList<DomProperty*>& a)
 
726
{
 
727
    m_attribute = a;
 
728
}
 
729
 
 
730
void DomAction::clear(bool clear_all)
 
731
{
 
732
    for (int i = 0; i < m_property.size(); ++i)
 
733
        delete m_property[i];
 
734
    m_property.clear();
 
735
    for (int i = 0; i < m_attribute.size(); ++i)
 
736
        delete m_attribute[i];
 
737
    m_attribute.clear();
 
738
 
 
739
    if (clear_all) {
 
740
    m_text = QString();
 
741
    m_has_attr_name = false;
 
742
    m_has_attr_menu = false;
 
743
    }
 
744
 
 
745
}
 
746
 
 
747
DomAction::DomAction()
 
748
{
 
749
    m_has_attr_name = false;
 
750
    m_has_attr_menu = false;
 
751
}
 
752
 
 
753
DomAction::~DomAction()
 
754
{
 
755
    for (int i = 0; i < m_property.size(); ++i)
 
756
        delete m_property[i];
 
757
    m_property.clear();
 
758
    for (int i = 0; i < m_attribute.size(); ++i)
 
759
        delete m_attribute[i];
 
760
    m_attribute.clear();
 
761
}
 
762
 
 
763
void DomAction::read(const QDomElement &node)
 
764
{
 
765
    if (node.hasAttribute(QLatin1String("name")))
 
766
        setAttributeName(node.attribute(QLatin1String("name")));
 
767
    if (node.hasAttribute(QLatin1String("menu")))
 
768
        setAttributeMenu(node.attribute(QLatin1String("menu")));
 
769
 
 
770
    for (QDomNode n = node.firstChild(); !n.isNull(); n = n.nextSibling()) {
 
771
        if (!n.isElement())
 
772
            continue;
 
773
        QDomElement e = n.toElement();
 
774
        QString tag = e.tagName().toLower();
 
775
        if (tag == QLatin1String("property")) {
 
776
            DomProperty *v = new DomProperty();
 
777
            v->read(e);
 
778
            m_property.append(v);
 
779
            continue;
 
780
        }
 
781
        if (tag == QLatin1String("attribute")) {
 
782
            DomProperty *v = new DomProperty();
 
783
            v->read(e);
 
784
            m_attribute.append(v);
 
785
            continue;
 
786
        }
 
787
    }
 
788
 
 
789
    m_text.clear();
 
790
    for (QDomNode child = node.firstChild(); !child.isNull(); child = child.nextSibling()) {
 
791
        if (child.isText())
 
792
            m_text.append(child.nodeValue());
 
793
    }
 
794
}
 
795
 
 
796
QDomElement DomAction::write(QDomDocument &doc, const QString &tagName)
 
797
{
 
798
    QDomElement e = doc.createElement(tagName.isEmpty() ? QString::fromLatin1("action") : tagName.toLower());
 
799
 
 
800
    QDomElement child;
 
801
 
 
802
    if (hasAttributeName())
 
803
        e.setAttribute(QLatin1String("name"), attributeName());
 
804
 
 
805
    if (hasAttributeMenu())
 
806
        e.setAttribute(QLatin1String("menu"), attributeMenu());
 
807
 
 
808
    for (int i = 0; i < m_property.size(); ++i) {
 
809
        DomProperty* v = m_property[i];
 
810
        QDomNode child = v->write(doc, QLatin1String("property"));
 
811
        e.appendChild(child);
 
812
    }
 
813
    for (int i = 0; i < m_attribute.size(); ++i) {
 
814
        DomProperty* v = m_attribute[i];
 
815
        QDomNode child = v->write(doc, QLatin1String("attribute"));
 
816
        e.appendChild(child);
 
817
    }
 
818
    if (!m_text.isEmpty())
 
819
        e.appendChild(doc.createTextNode(m_text));
 
820
 
 
821
    return e;
 
822
}
 
823
 
 
824
void DomAction::setElementProperty(const QList<DomProperty*>& a)
 
825
{
 
826
    m_property = a;
 
827
}
 
828
 
 
829
void DomAction::setElementAttribute(const QList<DomProperty*>& a)
 
830
{
 
831
    m_attribute = a;
 
832
}
 
833
 
 
834
void DomActionRef::clear(bool clear_all)
 
835
{
 
836
 
 
837
    if (clear_all) {
 
838
    m_text = QString();
 
839
    m_has_attr_name = false;
 
840
    }
 
841
 
 
842
}
 
843
 
 
844
DomActionRef::DomActionRef()
 
845
{
 
846
    m_has_attr_name = false;
 
847
}
 
848
 
 
849
DomActionRef::~DomActionRef()
 
850
{
 
851
}
 
852
 
 
853
void DomActionRef::read(const QDomElement &node)
 
854
{
 
855
    if (node.hasAttribute(QLatin1String("name")))
 
856
        setAttributeName(node.attribute(QLatin1String("name")));
 
857
 
 
858
    for (QDomNode n = node.firstChild(); !n.isNull(); n = n.nextSibling()) {
 
859
        if (!n.isElement())
 
860
            continue;
 
861
        QDomElement e = n.toElement();
 
862
        QString tag = e.tagName().toLower();
 
863
    }
 
864
 
 
865
    m_text.clear();
 
866
    for (QDomNode child = node.firstChild(); !child.isNull(); child = child.nextSibling()) {
 
867
        if (child.isText())
 
868
            m_text.append(child.nodeValue());
 
869
    }
 
870
}
 
871
 
 
872
QDomElement DomActionRef::write(QDomDocument &doc, const QString &tagName)
 
873
{
 
874
    QDomElement e = doc.createElement(tagName.isEmpty() ? QString::fromLatin1("actionref") : tagName.toLower());
 
875
 
 
876
    QDomElement child;
 
877
 
 
878
    if (hasAttributeName())
 
879
        e.setAttribute(QLatin1String("name"), attributeName());
 
880
 
 
881
    if (!m_text.isEmpty())
 
882
        e.appendChild(doc.createTextNode(m_text));
 
883
 
 
884
    return e;
 
885
}
 
886
 
 
887
void DomImages::clear(bool clear_all)
 
888
{
 
889
    for (int i = 0; i < m_image.size(); ++i)
 
890
        delete m_image[i];
 
891
    m_image.clear();
 
892
 
 
893
    if (clear_all) {
 
894
    m_text = QString();
 
895
    }
 
896
 
 
897
}
 
898
 
 
899
DomImages::DomImages()
 
900
{
 
901
}
 
902
 
 
903
DomImages::~DomImages()
 
904
{
 
905
    for (int i = 0; i < m_image.size(); ++i)
 
906
        delete m_image[i];
 
907
    m_image.clear();
 
908
}
 
909
 
 
910
void DomImages::read(const QDomElement &node)
 
911
{
 
912
 
 
913
    for (QDomNode n = node.firstChild(); !n.isNull(); n = n.nextSibling()) {
 
914
        if (!n.isElement())
 
915
            continue;
 
916
        QDomElement e = n.toElement();
 
917
        QString tag = e.tagName().toLower();
 
918
        if (tag == QLatin1String("image")) {
 
919
            DomImage *v = new DomImage();
 
920
            v->read(e);
 
921
            m_image.append(v);
 
922
            continue;
 
923
        }
 
924
    }
 
925
 
 
926
    m_text.clear();
 
927
    for (QDomNode child = node.firstChild(); !child.isNull(); child = child.nextSibling()) {
 
928
        if (child.isText())
 
929
            m_text.append(child.nodeValue());
 
930
    }
 
931
}
 
932
 
 
933
QDomElement DomImages::write(QDomDocument &doc, const QString &tagName)
 
934
{
 
935
    QDomElement e = doc.createElement(tagName.isEmpty() ? QString::fromLatin1("images") : tagName.toLower());
 
936
 
 
937
    QDomElement child;
 
938
 
 
939
    for (int i = 0; i < m_image.size(); ++i) {
 
940
        DomImage* v = m_image[i];
 
941
        QDomNode child = v->write(doc, QLatin1String("image"));
 
942
        e.appendChild(child);
 
943
    }
 
944
    if (!m_text.isEmpty())
 
945
        e.appendChild(doc.createTextNode(m_text));
 
946
 
 
947
    return e;
 
948
}
 
949
 
 
950
void DomImages::setElementImage(const QList<DomImage*>& a)
 
951
{
 
952
    m_image = a;
 
953
}
 
954
 
 
955
void DomImage::clear(bool clear_all)
 
956
{
 
957
    delete m_data;
 
958
 
 
959
    if (clear_all) {
 
960
    m_text = QString();
 
961
    m_has_attr_name = false;
 
962
    }
 
963
 
 
964
    m_data = 0;
 
965
}
 
966
 
 
967
DomImage::DomImage()
 
968
{
 
969
    m_has_attr_name = false;
 
970
    m_data = 0;
 
971
}
 
972
 
 
973
DomImage::~DomImage()
 
974
{
 
975
    delete m_data;
 
976
}
 
977
 
 
978
void DomImage::read(const QDomElement &node)
 
979
{
 
980
    if (node.hasAttribute(QLatin1String("name")))
 
981
        setAttributeName(node.attribute(QLatin1String("name")));
 
982
 
 
983
    for (QDomNode n = node.firstChild(); !n.isNull(); n = n.nextSibling()) {
 
984
        if (!n.isElement())
 
985
            continue;
 
986
        QDomElement e = n.toElement();
 
987
        QString tag = e.tagName().toLower();
 
988
        if (tag == QLatin1String("data")) {
 
989
            DomImageData *v = new DomImageData();
 
990
            v->read(e);
 
991
            setElementData(v);
 
992
            continue;
 
993
        }
 
994
    }
 
995
 
 
996
    m_text.clear();
 
997
    for (QDomNode child = node.firstChild(); !child.isNull(); child = child.nextSibling()) {
 
998
        if (child.isText())
 
999
            m_text.append(child.nodeValue());
 
1000
    }
 
1001
}
 
1002
 
 
1003
QDomElement DomImage::write(QDomDocument &doc, const QString &tagName)
 
1004
{
 
1005
    QDomElement e = doc.createElement(tagName.isEmpty() ? QString::fromLatin1("image") : tagName.toLower());
 
1006
 
 
1007
    QDomElement child;
 
1008
 
 
1009
    if (hasAttributeName())
 
1010
        e.setAttribute(QLatin1String("name"), attributeName());
 
1011
 
 
1012
    if (m_data != 0)
 
1013
        e.appendChild(m_data->write(doc, QLatin1String("data")));
 
1014
 
 
1015
    if (!m_text.isEmpty())
 
1016
        e.appendChild(doc.createTextNode(m_text));
 
1017
 
 
1018
    return e;
 
1019
}
 
1020
 
 
1021
void DomImage::setElementData(DomImageData* a)
 
1022
{
 
1023
    delete m_data;
 
1024
    m_data = a;
 
1025
}
 
1026
 
 
1027
void DomImageData::clear(bool clear_all)
 
1028
{
 
1029
 
 
1030
    if (clear_all) {
 
1031
    m_text = QString();
 
1032
    m_has_attr_format = false;
 
1033
    m_has_attr_length = false;
 
1034
    m_attr_length = 0;
 
1035
    }
 
1036
 
 
1037
}
 
1038
 
 
1039
DomImageData::DomImageData()
 
1040
{
 
1041
    m_has_attr_format = false;
 
1042
    m_has_attr_length = false;
 
1043
    m_attr_length = 0;
 
1044
}
 
1045
 
 
1046
DomImageData::~DomImageData()
 
1047
{
 
1048
}
 
1049
 
 
1050
void DomImageData::read(const QDomElement &node)
 
1051
{
 
1052
    if (node.hasAttribute(QLatin1String("format")))
 
1053
        setAttributeFormat(node.attribute(QLatin1String("format")));
 
1054
    if (node.hasAttribute(QLatin1String("length")))
 
1055
        setAttributeLength(node.attribute(QLatin1String("length")).toInt());
 
1056
 
 
1057
    for (QDomNode n = node.firstChild(); !n.isNull(); n = n.nextSibling()) {
 
1058
        if (!n.isElement())
 
1059
            continue;
 
1060
        QDomElement e = n.toElement();
 
1061
        QString tag = e.tagName().toLower();
 
1062
    }
 
1063
 
 
1064
    m_text.clear();
 
1065
    for (QDomNode child = node.firstChild(); !child.isNull(); child = child.nextSibling()) {
 
1066
        if (child.isText())
 
1067
            m_text.append(child.nodeValue());
 
1068
    }
 
1069
}
 
1070
 
 
1071
QDomElement DomImageData::write(QDomDocument &doc, const QString &tagName)
 
1072
{
 
1073
    QDomElement e = doc.createElement(tagName.isEmpty() ? QString::fromLatin1("imagedata") : tagName.toLower());
 
1074
 
 
1075
    QDomElement child;
 
1076
 
 
1077
    if (hasAttributeFormat())
 
1078
        e.setAttribute(QLatin1String("format"), attributeFormat());
 
1079
 
 
1080
    if (hasAttributeLength())
 
1081
        e.setAttribute(QLatin1String("length"), attributeLength());
 
1082
 
 
1083
    if (!m_text.isEmpty())
 
1084
        e.appendChild(doc.createTextNode(m_text));
 
1085
 
 
1086
    return e;
 
1087
}
 
1088
 
 
1089
void DomCustomWidgets::clear(bool clear_all)
 
1090
{
 
1091
    for (int i = 0; i < m_customWidget.size(); ++i)
 
1092
        delete m_customWidget[i];
 
1093
    m_customWidget.clear();
 
1094
 
 
1095
    if (clear_all) {
 
1096
    m_text = QString();
 
1097
    }
 
1098
 
 
1099
}
 
1100
 
 
1101
DomCustomWidgets::DomCustomWidgets()
 
1102
{
 
1103
}
 
1104
 
 
1105
DomCustomWidgets::~DomCustomWidgets()
 
1106
{
 
1107
    for (int i = 0; i < m_customWidget.size(); ++i)
 
1108
        delete m_customWidget[i];
 
1109
    m_customWidget.clear();
 
1110
}
 
1111
 
 
1112
void DomCustomWidgets::read(const QDomElement &node)
 
1113
{
 
1114
 
 
1115
    for (QDomNode n = node.firstChild(); !n.isNull(); n = n.nextSibling()) {
 
1116
        if (!n.isElement())
 
1117
            continue;
 
1118
        QDomElement e = n.toElement();
 
1119
        QString tag = e.tagName().toLower();
 
1120
        if (tag == QLatin1String("customwidget")) {
 
1121
            DomCustomWidget *v = new DomCustomWidget();
 
1122
            v->read(e);
 
1123
            m_customWidget.append(v);
 
1124
            continue;
 
1125
        }
 
1126
    }
 
1127
 
 
1128
    m_text.clear();
 
1129
    for (QDomNode child = node.firstChild(); !child.isNull(); child = child.nextSibling()) {
 
1130
        if (child.isText())
 
1131
            m_text.append(child.nodeValue());
 
1132
    }
 
1133
}
 
1134
 
 
1135
QDomElement DomCustomWidgets::write(QDomDocument &doc, const QString &tagName)
 
1136
{
 
1137
    QDomElement e = doc.createElement(tagName.isEmpty() ? QString::fromLatin1("customwidgets") : tagName.toLower());
 
1138
 
 
1139
    QDomElement child;
 
1140
 
 
1141
    for (int i = 0; i < m_customWidget.size(); ++i) {
 
1142
        DomCustomWidget* v = m_customWidget[i];
 
1143
        QDomNode child = v->write(doc, QLatin1String("customwidget"));
 
1144
        e.appendChild(child);
 
1145
    }
 
1146
    if (!m_text.isEmpty())
 
1147
        e.appendChild(doc.createTextNode(m_text));
 
1148
 
 
1149
    return e;
 
1150
}
 
1151
 
 
1152
void DomCustomWidgets::setElementCustomWidget(const QList<DomCustomWidget*>& a)
 
1153
{
 
1154
    m_customWidget = a;
 
1155
}
 
1156
 
 
1157
void DomHeader::clear(bool clear_all)
 
1158
{
 
1159
 
 
1160
    if (clear_all) {
 
1161
    m_text = QString();
 
1162
    m_has_attr_location = false;
 
1163
    }
 
1164
 
 
1165
}
 
1166
 
 
1167
DomHeader::DomHeader()
 
1168
{
 
1169
    m_has_attr_location = false;
 
1170
}
 
1171
 
 
1172
DomHeader::~DomHeader()
 
1173
{
 
1174
}
 
1175
 
 
1176
void DomHeader::read(const QDomElement &node)
 
1177
{
 
1178
    if (node.hasAttribute(QLatin1String("location")))
 
1179
        setAttributeLocation(node.attribute(QLatin1String("location")));
 
1180
 
 
1181
    m_text.clear();
 
1182
    for (QDomNode child = node.firstChild(); !child.isNull(); child = child.nextSibling()) {
 
1183
        if (child.isText())
 
1184
            m_text.append(child.nodeValue());
 
1185
    }
 
1186
}
 
1187
 
 
1188
QDomElement DomHeader::write(QDomDocument &doc, const QString &tagName)
 
1189
{
 
1190
    QDomElement e = doc.createElement(tagName.isEmpty() ? QString::fromLatin1("header") : tagName.toLower());
 
1191
 
 
1192
    QDomElement child;
 
1193
 
 
1194
    if (hasAttributeLocation())
 
1195
        e.setAttribute(QLatin1String("location"), attributeLocation());
 
1196
 
 
1197
    if (!m_text.isEmpty())
 
1198
        e.appendChild(doc.createTextNode(m_text));
 
1199
 
 
1200
    return e;
 
1201
}
 
1202
 
 
1203
void DomCustomWidget::clear(bool clear_all)
 
1204
{
 
1205
    delete m_header;
 
1206
    delete m_sizeHint;
 
1207
    delete m_sizePolicy;
 
1208
    delete m_properties;
 
1209
 
 
1210
    if (clear_all) {
 
1211
    m_text = QString();
 
1212
    }
 
1213
 
 
1214
    m_header = 0;
 
1215
    m_sizeHint = 0;
 
1216
    m_container = 0;
 
1217
    m_sizePolicy = 0;
 
1218
    m_properties = 0;
 
1219
}
 
1220
 
 
1221
DomCustomWidget::DomCustomWidget()
 
1222
{
 
1223
    m_header = 0;
 
1224
    m_sizeHint = 0;
 
1225
    m_container = 0;
 
1226
    m_sizePolicy = 0;
 
1227
    m_properties = 0;
 
1228
}
 
1229
 
 
1230
DomCustomWidget::~DomCustomWidget()
 
1231
{
 
1232
    delete m_header;
 
1233
    delete m_sizeHint;
 
1234
    delete m_sizePolicy;
 
1235
    delete m_properties;
 
1236
}
 
1237
 
 
1238
void DomCustomWidget::read(const QDomElement &node)
 
1239
{
 
1240
 
 
1241
    for (QDomNode n = node.firstChild(); !n.isNull(); n = n.nextSibling()) {
 
1242
        if (!n.isElement())
 
1243
            continue;
 
1244
        QDomElement e = n.toElement();
 
1245
        QString tag = e.tagName().toLower();
 
1246
        if (tag == QLatin1String("class")) {
 
1247
            setElementClass(e.text());
 
1248
            continue;
 
1249
        }
 
1250
        if (tag == QLatin1String("extends")) {
 
1251
            setElementExtends(e.text());
 
1252
            continue;
 
1253
        }
 
1254
        if (tag == QLatin1String("header")) {
 
1255
            DomHeader *v = new DomHeader();
 
1256
            v->read(e);
 
1257
            setElementHeader(v);
 
1258
            continue;
 
1259
        }
 
1260
        if (tag == QLatin1String("sizehint")) {
 
1261
            DomSize *v = new DomSize();
 
1262
            v->read(e);
 
1263
            setElementSizeHint(v);
 
1264
            continue;
 
1265
        }
 
1266
        if (tag == QLatin1String("container")) {
 
1267
            setElementContainer(e.text().toInt());
 
1268
            continue;
 
1269
        }
 
1270
        if (tag == QLatin1String("sizepolicy")) {
 
1271
            DomSizePolicyData *v = new DomSizePolicyData();
 
1272
            v->read(e);
 
1273
            setElementSizePolicy(v);
 
1274
            continue;
 
1275
        }
 
1276
        if (tag == QLatin1String("pixmap")) {
 
1277
            setElementPixmap(e.text());
 
1278
            continue;
 
1279
        }
 
1280
        if (tag == QLatin1String("properties")) {
 
1281
            DomProperties *v = new DomProperties();
 
1282
            v->read(e);
 
1283
            setElementProperties(v);
 
1284
            continue;
 
1285
        }
 
1286
    }
 
1287
 
 
1288
    m_text.clear();
 
1289
    for (QDomNode child = node.firstChild(); !child.isNull(); child = child.nextSibling()) {
 
1290
        if (child.isText())
 
1291
            m_text.append(child.nodeValue());
 
1292
    }
 
1293
}
 
1294
 
 
1295
QDomElement DomCustomWidget::write(QDomDocument &doc, const QString &tagName)
 
1296
{
 
1297
    QDomElement e = doc.createElement(tagName.isEmpty() ? QString::fromLatin1("customwidget") : tagName.toLower());
 
1298
 
 
1299
    QDomElement child;
 
1300
 
 
1301
    child = doc.createElement(QLatin1String("class"));
 
1302
    child.appendChild(doc.createTextNode(m_class));
 
1303
    e.appendChild(child);
 
1304
 
 
1305
    child = doc.createElement(QLatin1String("extends"));
 
1306
    child.appendChild(doc.createTextNode(m_extends));
 
1307
    e.appendChild(child);
 
1308
 
 
1309
    if (m_header != 0)
 
1310
        e.appendChild(m_header->write(doc, QLatin1String("header")));
 
1311
 
 
1312
    if (m_sizeHint != 0)
 
1313
        e.appendChild(m_sizeHint->write(doc, QLatin1String("sizehint")));
 
1314
 
 
1315
    child = doc.createElement(QLatin1String("container"));
 
1316
    child.appendChild(doc.createTextNode(QString::number(m_container)));
 
1317
    e.appendChild(child);
 
1318
 
 
1319
    if (m_sizePolicy != 0)
 
1320
        e.appendChild(m_sizePolicy->write(doc, QLatin1String("sizepolicy")));
 
1321
 
 
1322
    child = doc.createElement(QLatin1String("pixmap"));
 
1323
    child.appendChild(doc.createTextNode(m_pixmap));
 
1324
    e.appendChild(child);
 
1325
 
 
1326
    if (m_properties != 0)
 
1327
        e.appendChild(m_properties->write(doc, QLatin1String("properties")));
 
1328
 
 
1329
    if (!m_text.isEmpty())
 
1330
        e.appendChild(doc.createTextNode(m_text));
 
1331
 
 
1332
    return e;
 
1333
}
 
1334
 
 
1335
void DomCustomWidget::setElementClass(const QString& a)
 
1336
{
 
1337
    m_class = a;
 
1338
}
 
1339
 
 
1340
void DomCustomWidget::setElementExtends(const QString& a)
 
1341
{
 
1342
    m_extends = a;
 
1343
}
 
1344
 
 
1345
void DomCustomWidget::setElementHeader(DomHeader* a)
 
1346
{
 
1347
    delete m_header;
 
1348
    m_header = a;
 
1349
}
 
1350
 
 
1351
void DomCustomWidget::setElementSizeHint(DomSize* a)
 
1352
{
 
1353
    delete m_sizeHint;
 
1354
    m_sizeHint = a;
 
1355
}
 
1356
 
 
1357
void DomCustomWidget::setElementContainer(int a)
 
1358
{
 
1359
    m_container = a;
 
1360
}
 
1361
 
 
1362
void DomCustomWidget::setElementSizePolicy(DomSizePolicyData* a)
 
1363
{
 
1364
    delete m_sizePolicy;
 
1365
    m_sizePolicy = a;
 
1366
}
 
1367
 
 
1368
void DomCustomWidget::setElementPixmap(const QString& a)
 
1369
{
 
1370
    m_pixmap = a;
 
1371
}
 
1372
 
 
1373
void DomCustomWidget::setElementProperties(DomProperties* a)
 
1374
{
 
1375
    delete m_properties;
 
1376
    m_properties = a;
 
1377
}
 
1378
 
 
1379
void DomProperties::clear(bool clear_all)
 
1380
{
 
1381
    for (int i = 0; i < m_property.size(); ++i)
 
1382
        delete m_property[i];
 
1383
    m_property.clear();
 
1384
 
 
1385
    if (clear_all) {
 
1386
    m_text = QString();
 
1387
    }
 
1388
 
 
1389
}
 
1390
 
 
1391
DomProperties::DomProperties()
 
1392
{
 
1393
}
 
1394
 
 
1395
DomProperties::~DomProperties()
 
1396
{
 
1397
    for (int i = 0; i < m_property.size(); ++i)
 
1398
        delete m_property[i];
 
1399
    m_property.clear();
 
1400
}
 
1401
 
 
1402
void DomProperties::read(const QDomElement &node)
 
1403
{
 
1404
 
 
1405
    for (QDomNode n = node.firstChild(); !n.isNull(); n = n.nextSibling()) {
 
1406
        if (!n.isElement())
 
1407
            continue;
 
1408
        QDomElement e = n.toElement();
 
1409
        QString tag = e.tagName().toLower();
 
1410
        if (tag == QLatin1String("property")) {
 
1411
            DomPropertyData *v = new DomPropertyData();
 
1412
            v->read(e);
 
1413
            m_property.append(v);
 
1414
            continue;
 
1415
        }
 
1416
    }
 
1417
 
 
1418
    m_text.clear();
 
1419
    for (QDomNode child = node.firstChild(); !child.isNull(); child = child.nextSibling()) {
 
1420
        if (child.isText())
 
1421
            m_text.append(child.nodeValue());
 
1422
    }
 
1423
}
 
1424
 
 
1425
QDomElement DomProperties::write(QDomDocument &doc, const QString &tagName)
 
1426
{
 
1427
    QDomElement e = doc.createElement(tagName.isEmpty() ? QString::fromLatin1("properties") : tagName.toLower());
 
1428
 
 
1429
    QDomElement child;
 
1430
 
 
1431
    for (int i = 0; i < m_property.size(); ++i) {
 
1432
        DomPropertyData* v = m_property[i];
 
1433
        QDomNode child = v->write(doc, QLatin1String("property"));
 
1434
        e.appendChild(child);
 
1435
    }
 
1436
    if (!m_text.isEmpty())
 
1437
        e.appendChild(doc.createTextNode(m_text));
 
1438
 
 
1439
    return e;
 
1440
}
 
1441
 
 
1442
void DomProperties::setElementProperty(const QList<DomPropertyData*>& a)
 
1443
{
 
1444
    m_property = a;
 
1445
}
 
1446
 
 
1447
void DomPropertyData::clear(bool clear_all)
 
1448
{
 
1449
 
 
1450
    if (clear_all) {
 
1451
    m_text = QString();
 
1452
    m_has_attr_type = false;
 
1453
    }
 
1454
 
 
1455
}
 
1456
 
 
1457
DomPropertyData::DomPropertyData()
 
1458
{
 
1459
    m_has_attr_type = false;
 
1460
}
 
1461
 
 
1462
DomPropertyData::~DomPropertyData()
 
1463
{
 
1464
}
 
1465
 
 
1466
void DomPropertyData::read(const QDomElement &node)
 
1467
{
 
1468
    if (node.hasAttribute(QLatin1String("type")))
 
1469
        setAttributeType(node.attribute(QLatin1String("type")));
 
1470
 
 
1471
    for (QDomNode n = node.firstChild(); !n.isNull(); n = n.nextSibling()) {
 
1472
        if (!n.isElement())
 
1473
            continue;
 
1474
        QDomElement e = n.toElement();
 
1475
        QString tag = e.tagName().toLower();
 
1476
    }
 
1477
 
 
1478
    m_text.clear();
 
1479
    for (QDomNode child = node.firstChild(); !child.isNull(); child = child.nextSibling()) {
 
1480
        if (child.isText())
 
1481
            m_text.append(child.nodeValue());
 
1482
    }
 
1483
}
 
1484
 
 
1485
QDomElement DomPropertyData::write(QDomDocument &doc, const QString &tagName)
 
1486
{
 
1487
    QDomElement e = doc.createElement(tagName.isEmpty() ? QString::fromLatin1("propertydata") : tagName.toLower());
 
1488
 
 
1489
    QDomElement child;
 
1490
 
 
1491
    if (hasAttributeType())
 
1492
        e.setAttribute(QLatin1String("type"), attributeType());
 
1493
 
 
1494
    if (!m_text.isEmpty())
 
1495
        e.appendChild(doc.createTextNode(m_text));
 
1496
 
 
1497
    return e;
 
1498
}
 
1499
 
 
1500
void DomSizePolicyData::clear(bool clear_all)
 
1501
{
 
1502
 
 
1503
    if (clear_all) {
 
1504
    m_text = QString();
 
1505
    }
 
1506
 
 
1507
    m_horData = 0;
 
1508
    m_verData = 0;
 
1509
}
 
1510
 
 
1511
DomSizePolicyData::DomSizePolicyData()
 
1512
{
 
1513
    m_horData = 0;
 
1514
    m_verData = 0;
 
1515
}
 
1516
 
 
1517
DomSizePolicyData::~DomSizePolicyData()
 
1518
{
 
1519
}
 
1520
 
 
1521
void DomSizePolicyData::read(const QDomElement &node)
 
1522
{
 
1523
 
 
1524
    for (QDomNode n = node.firstChild(); !n.isNull(); n = n.nextSibling()) {
 
1525
        if (!n.isElement())
 
1526
            continue;
 
1527
        QDomElement e = n.toElement();
 
1528
        QString tag = e.tagName().toLower();
 
1529
        if (tag == QLatin1String("hordata")) {
 
1530
            setElementHorData(e.text().toInt());
 
1531
            continue;
 
1532
        }
 
1533
        if (tag == QLatin1String("verdata")) {
 
1534
            setElementVerData(e.text().toInt());
 
1535
            continue;
 
1536
        }
 
1537
    }
 
1538
 
 
1539
    m_text.clear();
 
1540
    for (QDomNode child = node.firstChild(); !child.isNull(); child = child.nextSibling()) {
 
1541
        if (child.isText())
 
1542
            m_text.append(child.nodeValue());
 
1543
    }
 
1544
}
 
1545
 
 
1546
QDomElement DomSizePolicyData::write(QDomDocument &doc, const QString &tagName)
 
1547
{
 
1548
    QDomElement e = doc.createElement(tagName.isEmpty() ? QString::fromLatin1("sizepolicydata") : tagName.toLower());
 
1549
 
 
1550
    QDomElement child;
 
1551
 
 
1552
    child = doc.createElement(QLatin1String("hordata"));
 
1553
    child.appendChild(doc.createTextNode(QString::number(m_horData)));
 
1554
    e.appendChild(child);
 
1555
 
 
1556
    child = doc.createElement(QLatin1String("verdata"));
 
1557
    child.appendChild(doc.createTextNode(QString::number(m_verData)));
 
1558
    e.appendChild(child);
 
1559
 
 
1560
    if (!m_text.isEmpty())
 
1561
        e.appendChild(doc.createTextNode(m_text));
 
1562
 
 
1563
    return e;
 
1564
}
 
1565
 
 
1566
void DomSizePolicyData::setElementHorData(int a)
 
1567
{
 
1568
    m_horData = a;
 
1569
}
 
1570
 
 
1571
void DomSizePolicyData::setElementVerData(int a)
 
1572
{
 
1573
    m_verData = a;
 
1574
}
 
1575
 
 
1576
void DomLayoutDefault::clear(bool clear_all)
 
1577
{
 
1578
 
 
1579
    if (clear_all) {
 
1580
    m_text = QString();
 
1581
    m_has_attr_spacing = false;
 
1582
    m_attr_spacing = 0;
 
1583
    m_has_attr_margin = false;
 
1584
    m_attr_margin = 0;
 
1585
    }
 
1586
 
 
1587
}
 
1588
 
 
1589
DomLayoutDefault::DomLayoutDefault()
 
1590
{
 
1591
    m_has_attr_spacing = false;
 
1592
    m_attr_spacing = 0;
 
1593
    m_has_attr_margin = false;
 
1594
    m_attr_margin = 0;
 
1595
}
 
1596
 
 
1597
DomLayoutDefault::~DomLayoutDefault()
 
1598
{
 
1599
}
 
1600
 
 
1601
void DomLayoutDefault::read(const QDomElement &node)
 
1602
{
 
1603
    if (node.hasAttribute(QLatin1String("spacing")))
 
1604
        setAttributeSpacing(node.attribute(QLatin1String("spacing")).toInt());
 
1605
    if (node.hasAttribute(QLatin1String("margin")))
 
1606
        setAttributeMargin(node.attribute(QLatin1String("margin")).toInt());
 
1607
 
 
1608
    for (QDomNode n = node.firstChild(); !n.isNull(); n = n.nextSibling()) {
 
1609
        if (!n.isElement())
 
1610
            continue;
 
1611
        QDomElement e = n.toElement();
 
1612
        QString tag = e.tagName().toLower();
 
1613
    }
 
1614
 
 
1615
    m_text.clear();
 
1616
    for (QDomNode child = node.firstChild(); !child.isNull(); child = child.nextSibling()) {
 
1617
        if (child.isText())
 
1618
            m_text.append(child.nodeValue());
 
1619
    }
 
1620
}
 
1621
 
 
1622
QDomElement DomLayoutDefault::write(QDomDocument &doc, const QString &tagName)
 
1623
{
 
1624
    QDomElement e = doc.createElement(tagName.isEmpty() ? QString::fromLatin1("layoutdefault") : tagName.toLower());
 
1625
 
 
1626
    QDomElement child;
 
1627
 
 
1628
    if (hasAttributeSpacing())
 
1629
        e.setAttribute(QLatin1String("spacing"), attributeSpacing());
 
1630
 
 
1631
    if (hasAttributeMargin())
 
1632
        e.setAttribute(QLatin1String("margin"), attributeMargin());
 
1633
 
 
1634
    if (!m_text.isEmpty())
 
1635
        e.appendChild(doc.createTextNode(m_text));
 
1636
 
 
1637
    return e;
 
1638
}
 
1639
 
 
1640
void DomLayoutFunction::clear(bool clear_all)
 
1641
{
 
1642
 
 
1643
    if (clear_all) {
 
1644
    m_text = QString();
 
1645
    m_has_attr_spacing = false;
 
1646
    m_has_attr_margin = false;
 
1647
    }
 
1648
 
 
1649
}
 
1650
 
 
1651
DomLayoutFunction::DomLayoutFunction()
 
1652
{
 
1653
    m_has_attr_spacing = false;
 
1654
    m_has_attr_margin = false;
 
1655
}
 
1656
 
 
1657
DomLayoutFunction::~DomLayoutFunction()
 
1658
{
 
1659
}
 
1660
 
 
1661
void DomLayoutFunction::read(const QDomElement &node)
 
1662
{
 
1663
    if (node.hasAttribute(QLatin1String("spacing")))
 
1664
        setAttributeSpacing(node.attribute(QLatin1String("spacing")));
 
1665
    if (node.hasAttribute(QLatin1String("margin")))
 
1666
        setAttributeMargin(node.attribute(QLatin1String("margin")));
 
1667
 
 
1668
    for (QDomNode n = node.firstChild(); !n.isNull(); n = n.nextSibling()) {
 
1669
        if (!n.isElement())
 
1670
            continue;
 
1671
        QDomElement e = n.toElement();
 
1672
        QString tag = e.tagName().toLower();
 
1673
    }
 
1674
 
 
1675
    m_text.clear();
 
1676
    for (QDomNode child = node.firstChild(); !child.isNull(); child = child.nextSibling()) {
 
1677
        if (child.isText())
 
1678
            m_text.append(child.nodeValue());
 
1679
    }
 
1680
}
 
1681
 
 
1682
QDomElement DomLayoutFunction::write(QDomDocument &doc, const QString &tagName)
 
1683
{
 
1684
    QDomElement e = doc.createElement(tagName.isEmpty() ? QString::fromLatin1("layoutfunction") : tagName.toLower());
 
1685
 
 
1686
    QDomElement child;
 
1687
 
 
1688
    if (hasAttributeSpacing())
 
1689
        e.setAttribute(QLatin1String("spacing"), attributeSpacing());
 
1690
 
 
1691
    if (hasAttributeMargin())
 
1692
        e.setAttribute(QLatin1String("margin"), attributeMargin());
 
1693
 
 
1694
    if (!m_text.isEmpty())
 
1695
        e.appendChild(doc.createTextNode(m_text));
 
1696
 
 
1697
    return e;
 
1698
}
 
1699
 
 
1700
void DomTabStops::clear(bool clear_all)
 
1701
{
 
1702
    m_tabStop.clear();
 
1703
 
 
1704
    if (clear_all) {
 
1705
    m_text = QString();
 
1706
    }
 
1707
 
 
1708
}
 
1709
 
 
1710
DomTabStops::DomTabStops()
 
1711
{
 
1712
}
 
1713
 
 
1714
DomTabStops::~DomTabStops()
 
1715
{
 
1716
    m_tabStop.clear();
 
1717
}
 
1718
 
 
1719
void DomTabStops::read(const QDomElement &node)
 
1720
{
 
1721
 
 
1722
    for (QDomNode n = node.firstChild(); !n.isNull(); n = n.nextSibling()) {
 
1723
        if (!n.isElement())
 
1724
            continue;
 
1725
        QDomElement e = n.toElement();
 
1726
        QString tag = e.tagName().toLower();
 
1727
        if (tag == QLatin1String("tabstop")) {
 
1728
            m_tabStop.append(e.text());
 
1729
            continue;
 
1730
        }
 
1731
    }
 
1732
 
 
1733
    m_text.clear();
 
1734
    for (QDomNode child = node.firstChild(); !child.isNull(); child = child.nextSibling()) {
 
1735
        if (child.isText())
 
1736
            m_text.append(child.nodeValue());
 
1737
    }
 
1738
}
 
1739
 
 
1740
QDomElement DomTabStops::write(QDomDocument &doc, const QString &tagName)
 
1741
{
 
1742
    QDomElement e = doc.createElement(tagName.isEmpty() ? QString::fromLatin1("tabstops") : tagName.toLower());
 
1743
 
 
1744
    QDomElement child;
 
1745
 
 
1746
    for (int i = 0; i < m_tabStop.size(); ++i) {
 
1747
        QString v = m_tabStop[i];
 
1748
        QDomNode child = doc.createElement(QLatin1String("tabstop"));
 
1749
        child.appendChild(doc.createTextNode(v));
 
1750
        e.appendChild(child);
 
1751
    }
 
1752
    if (!m_text.isEmpty())
 
1753
        e.appendChild(doc.createTextNode(m_text));
 
1754
 
 
1755
    return e;
 
1756
}
 
1757
 
 
1758
void DomTabStops::setElementTabStop(const QStringList& a)
 
1759
{
 
1760
    m_tabStop = a;
 
1761
}
 
1762
 
 
1763
void DomLayout::clear(bool clear_all)
 
1764
{
 
1765
    for (int i = 0; i < m_property.size(); ++i)
 
1766
        delete m_property[i];
 
1767
    m_property.clear();
 
1768
    for (int i = 0; i < m_attribute.size(); ++i)
 
1769
        delete m_attribute[i];
 
1770
    m_attribute.clear();
 
1771
    for (int i = 0; i < m_item.size(); ++i)
 
1772
        delete m_item[i];
 
1773
    m_item.clear();
 
1774
 
 
1775
    if (clear_all) {
 
1776
    m_text = QString();
 
1777
    m_has_attr_class = false;
 
1778
    }
 
1779
 
 
1780
}
 
1781
 
 
1782
DomLayout::DomLayout()
 
1783
{
 
1784
    m_has_attr_class = false;
 
1785
}
 
1786
 
 
1787
DomLayout::~DomLayout()
 
1788
{
 
1789
    for (int i = 0; i < m_property.size(); ++i)
 
1790
        delete m_property[i];
 
1791
    m_property.clear();
 
1792
    for (int i = 0; i < m_attribute.size(); ++i)
 
1793
        delete m_attribute[i];
 
1794
    m_attribute.clear();
 
1795
    for (int i = 0; i < m_item.size(); ++i)
 
1796
        delete m_item[i];
 
1797
    m_item.clear();
 
1798
}
 
1799
 
 
1800
void DomLayout::read(const QDomElement &node)
 
1801
{
 
1802
    if (node.hasAttribute(QLatin1String("class")))
 
1803
        setAttributeClass(node.attribute(QLatin1String("class")));
 
1804
 
 
1805
    for (QDomNode n = node.firstChild(); !n.isNull(); n = n.nextSibling()) {
 
1806
        if (!n.isElement())
 
1807
            continue;
 
1808
        QDomElement e = n.toElement();
 
1809
        QString tag = e.tagName().toLower();
 
1810
        if (tag == QLatin1String("property")) {
 
1811
            DomProperty *v = new DomProperty();
 
1812
            v->read(e);
 
1813
            m_property.append(v);
 
1814
            continue;
 
1815
        }
 
1816
        if (tag == QLatin1String("attribute")) {
 
1817
            DomProperty *v = new DomProperty();
 
1818
            v->read(e);
 
1819
            m_attribute.append(v);
 
1820
            continue;
 
1821
        }
 
1822
        if (tag == QLatin1String("item")) {
 
1823
            DomLayoutItem *v = new DomLayoutItem();
 
1824
            v->read(e);
 
1825
            m_item.append(v);
 
1826
            continue;
 
1827
        }
 
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
 
 
1837
QDomElement DomLayout::write(QDomDocument &doc, const QString &tagName)
 
1838
{
 
1839
    QDomElement e = doc.createElement(tagName.isEmpty() ? QString::fromLatin1("layout") : tagName.toLower());
 
1840
 
 
1841
    QDomElement child;
 
1842
 
 
1843
    if (hasAttributeClass())
 
1844
        e.setAttribute(QLatin1String("class"), attributeClass());
 
1845
 
 
1846
    for (int i = 0; i < m_property.size(); ++i) {
 
1847
        DomProperty* v = m_property[i];
 
1848
        QDomNode child = v->write(doc, QLatin1String("property"));
 
1849
        e.appendChild(child);
 
1850
    }
 
1851
    for (int i = 0; i < m_attribute.size(); ++i) {
 
1852
        DomProperty* v = m_attribute[i];
 
1853
        QDomNode child = v->write(doc, QLatin1String("attribute"));
 
1854
        e.appendChild(child);
 
1855
    }
 
1856
    for (int i = 0; i < m_item.size(); ++i) {
 
1857
        DomLayoutItem* v = m_item[i];
 
1858
        QDomNode child = v->write(doc, QLatin1String("item"));
 
1859
        e.appendChild(child);
 
1860
    }
 
1861
    if (!m_text.isEmpty())
 
1862
        e.appendChild(doc.createTextNode(m_text));
 
1863
 
 
1864
    return e;
 
1865
}
 
1866
 
 
1867
void DomLayout::setElementProperty(const QList<DomProperty*>& a)
 
1868
{
 
1869
    m_property = a;
 
1870
}
 
1871
 
 
1872
void DomLayout::setElementAttribute(const QList<DomProperty*>& a)
 
1873
{
 
1874
    m_attribute = a;
 
1875
}
 
1876
 
 
1877
void DomLayout::setElementItem(const QList<DomLayoutItem*>& a)
 
1878
{
 
1879
    m_item = a;
 
1880
}
 
1881
 
 
1882
void DomLayoutItem::clear(bool clear_all)
 
1883
{
 
1884
    delete m_widget;
 
1885
    delete m_layout;
 
1886
    delete m_spacer;
 
1887
 
 
1888
    if (clear_all) {
 
1889
    m_text = QString();
 
1890
    m_has_attr_row = false;
 
1891
    m_attr_row = 0;
 
1892
    m_has_attr_column = false;
 
1893
    m_attr_column = 0;
 
1894
    m_has_attr_rowSpan = false;
 
1895
    m_attr_rowSpan = 0;
 
1896
    m_has_attr_colSpan = false;
 
1897
    m_attr_colSpan = 0;
 
1898
    }
 
1899
 
 
1900
    m_kind = Unknown;
 
1901
 
 
1902
    m_widget = 0;
 
1903
    m_layout = 0;
 
1904
    m_spacer = 0;
 
1905
}
 
1906
 
 
1907
DomLayoutItem::DomLayoutItem()
 
1908
{
 
1909
    m_kind = Unknown;
 
1910
 
 
1911
    m_has_attr_row = false;
 
1912
    m_attr_row = 0;
 
1913
    m_has_attr_column = false;
 
1914
    m_attr_column = 0;
 
1915
    m_has_attr_rowSpan = false;
 
1916
    m_attr_rowSpan = 0;
 
1917
    m_has_attr_colSpan = false;
 
1918
    m_attr_colSpan = 0;
 
1919
    m_widget = 0;
 
1920
    m_layout = 0;
 
1921
    m_spacer = 0;
 
1922
}
 
1923
 
 
1924
DomLayoutItem::~DomLayoutItem()
 
1925
{
 
1926
    delete m_widget;
 
1927
    delete m_layout;
 
1928
    delete m_spacer;
 
1929
}
 
1930
 
 
1931
void DomLayoutItem::read(const QDomElement &node)
 
1932
{
 
1933
    if (node.hasAttribute(QLatin1String("row")))
 
1934
        setAttributeRow(node.attribute(QLatin1String("row")).toInt());
 
1935
    if (node.hasAttribute(QLatin1String("column")))
 
1936
        setAttributeColumn(node.attribute(QLatin1String("column")).toInt());
 
1937
    if (node.hasAttribute(QLatin1String("rowspan")))
 
1938
        setAttributeRowSpan(node.attribute(QLatin1String("rowspan")).toInt());
 
1939
    if (node.hasAttribute(QLatin1String("colspan")))
 
1940
        setAttributeColSpan(node.attribute(QLatin1String("colspan")).toInt());
 
1941
 
 
1942
    for (QDomNode n = node.firstChild(); !n.isNull(); n = n.nextSibling()) {
 
1943
        if (!n.isElement())
 
1944
            continue;
 
1945
        QDomElement e = n.toElement();
 
1946
        QString tag = e.tagName().toLower();
 
1947
        if (tag == QLatin1String("widget")) {
 
1948
            DomWidget *v = new DomWidget();
 
1949
            v->read(e);
 
1950
            setElementWidget(v);
 
1951
            continue;
 
1952
        }
 
1953
        if (tag == QLatin1String("layout")) {
 
1954
            DomLayout *v = new DomLayout();
 
1955
            v->read(e);
 
1956
            setElementLayout(v);
 
1957
            continue;
 
1958
        }
 
1959
        if (tag == QLatin1String("spacer")) {
 
1960
            DomSpacer *v = new DomSpacer();
 
1961
            v->read(e);
 
1962
            setElementSpacer(v);
 
1963
            continue;
 
1964
        }
 
1965
    }
 
1966
 
 
1967
    m_text.clear();
 
1968
    for (QDomNode child = node.firstChild(); !child.isNull(); child = child.nextSibling()) {
 
1969
        if (child.isText())
 
1970
            m_text.append(child.nodeValue());
 
1971
    }
 
1972
}
 
1973
 
 
1974
QDomElement DomLayoutItem::write(QDomDocument &doc, const QString &tagName)
 
1975
{
 
1976
    QDomElement e = doc.createElement(tagName.isEmpty() ? QString::fromLatin1("layoutitem") : tagName.toLower());
 
1977
 
 
1978
    QDomElement child;
 
1979
 
 
1980
    if (hasAttributeRow())
 
1981
        e.setAttribute(QLatin1String("row"), attributeRow());
 
1982
 
 
1983
    if (hasAttributeColumn())
 
1984
        e.setAttribute(QLatin1String("column"), attributeColumn());
 
1985
 
 
1986
    if (hasAttributeRowSpan())
 
1987
        e.setAttribute(QLatin1String("rowspan"), attributeRowSpan());
 
1988
 
 
1989
    if (hasAttributeColSpan())
 
1990
        e.setAttribute(QLatin1String("colspan"), attributeColSpan());
 
1991
 
 
1992
    switch(kind()) {
 
1993
        case Widget: {
 
1994
            DomWidget* v = elementWidget();
 
1995
            if (v != 0) {
 
1996
                QDomElement child = v->write(doc, QLatin1String("widget"));
 
1997
                e.appendChild(child);
 
1998
            }
 
1999
            break;
 
2000
        }
 
2001
        case Layout: {
 
2002
            DomLayout* v = elementLayout();
 
2003
            if (v != 0) {
 
2004
                QDomElement child = v->write(doc, QLatin1String("layout"));
 
2005
                e.appendChild(child);
 
2006
            }
 
2007
            break;
 
2008
        }
 
2009
        case Spacer: {
 
2010
            DomSpacer* v = elementSpacer();
 
2011
            if (v != 0) {
 
2012
                QDomElement child = v->write(doc, QLatin1String("spacer"));
 
2013
                e.appendChild(child);
 
2014
            }
 
2015
            break;
 
2016
        }
 
2017
        default:
 
2018
            break;
 
2019
    }
 
2020
    if (!m_text.isEmpty())
 
2021
        e.appendChild(doc.createTextNode(m_text));
 
2022
 
 
2023
    return e;
 
2024
}
 
2025
 
 
2026
void DomLayoutItem::setElementWidget(DomWidget* a)
 
2027
{
 
2028
    clear(false);
 
2029
    m_kind = Widget;
 
2030
    m_widget = a;
 
2031
}
 
2032
 
 
2033
void DomLayoutItem::setElementLayout(DomLayout* a)
 
2034
{
 
2035
    clear(false);
 
2036
    m_kind = Layout;
 
2037
    m_layout = a;
 
2038
}
 
2039
 
 
2040
void DomLayoutItem::setElementSpacer(DomSpacer* a)
 
2041
{
 
2042
    clear(false);
 
2043
    m_kind = Spacer;
 
2044
    m_spacer = a;
 
2045
}
 
2046
 
 
2047
void DomRow::clear(bool clear_all)
 
2048
{
 
2049
    for (int i = 0; i < m_property.size(); ++i)
 
2050
        delete m_property[i];
 
2051
    m_property.clear();
 
2052
 
 
2053
    if (clear_all) {
 
2054
    m_text = QString();
 
2055
    }
 
2056
 
 
2057
}
 
2058
 
 
2059
DomRow::DomRow()
 
2060
{
 
2061
}
 
2062
 
 
2063
DomRow::~DomRow()
 
2064
{
 
2065
    for (int i = 0; i < m_property.size(); ++i)
 
2066
        delete m_property[i];
 
2067
    m_property.clear();
 
2068
}
 
2069
 
 
2070
void DomRow::read(const QDomElement &node)
 
2071
{
 
2072
 
 
2073
    for (QDomNode n = node.firstChild(); !n.isNull(); n = n.nextSibling()) {
 
2074
        if (!n.isElement())
 
2075
            continue;
 
2076
        QDomElement e = n.toElement();
 
2077
        QString tag = e.tagName().toLower();
 
2078
        if (tag == QLatin1String("property")) {
 
2079
            DomProperty *v = new DomProperty();
 
2080
            v->read(e);
 
2081
            m_property.append(v);
 
2082
            continue;
 
2083
        }
 
2084
    }
 
2085
 
 
2086
    m_text.clear();
 
2087
    for (QDomNode child = node.firstChild(); !child.isNull(); child = child.nextSibling()) {
 
2088
        if (child.isText())
 
2089
            m_text.append(child.nodeValue());
 
2090
    }
 
2091
}
 
2092
 
 
2093
QDomElement DomRow::write(QDomDocument &doc, const QString &tagName)
 
2094
{
 
2095
    QDomElement e = doc.createElement(tagName.isEmpty() ? QString::fromLatin1("row") : tagName.toLower());
 
2096
 
 
2097
    QDomElement child;
 
2098
 
 
2099
    for (int i = 0; i < m_property.size(); ++i) {
 
2100
        DomProperty* v = m_property[i];
 
2101
        QDomNode child = v->write(doc, QLatin1String("property"));
 
2102
        e.appendChild(child);
 
2103
    }
 
2104
    if (!m_text.isEmpty())
 
2105
        e.appendChild(doc.createTextNode(m_text));
 
2106
 
 
2107
    return e;
 
2108
}
 
2109
 
 
2110
void DomRow::setElementProperty(const QList<DomProperty*>& a)
 
2111
{
 
2112
    m_property = a;
 
2113
}
 
2114
 
 
2115
void DomColumn::clear(bool clear_all)
 
2116
{
 
2117
    for (int i = 0; i < m_property.size(); ++i)
 
2118
        delete m_property[i];
 
2119
    m_property.clear();
 
2120
 
 
2121
    if (clear_all) {
 
2122
    m_text = QString();
 
2123
    }
 
2124
 
 
2125
}
 
2126
 
 
2127
DomColumn::DomColumn()
 
2128
{
 
2129
}
 
2130
 
 
2131
DomColumn::~DomColumn()
 
2132
{
 
2133
    for (int i = 0; i < m_property.size(); ++i)
 
2134
        delete m_property[i];
 
2135
    m_property.clear();
 
2136
}
 
2137
 
 
2138
void DomColumn::read(const QDomElement &node)
 
2139
{
 
2140
 
 
2141
    for (QDomNode n = node.firstChild(); !n.isNull(); n = n.nextSibling()) {
 
2142
        if (!n.isElement())
 
2143
            continue;
 
2144
        QDomElement e = n.toElement();
 
2145
        QString tag = e.tagName().toLower();
 
2146
        if (tag == QLatin1String("property")) {
 
2147
            DomProperty *v = new DomProperty();
 
2148
            v->read(e);
 
2149
            m_property.append(v);
 
2150
            continue;
 
2151
        }
 
2152
    }
 
2153
 
 
2154
    m_text.clear();
 
2155
    for (QDomNode child = node.firstChild(); !child.isNull(); child = child.nextSibling()) {
 
2156
        if (child.isText())
 
2157
            m_text.append(child.nodeValue());
 
2158
    }
 
2159
}
 
2160
 
 
2161
QDomElement DomColumn::write(QDomDocument &doc, const QString &tagName)
 
2162
{
 
2163
    QDomElement e = doc.createElement(tagName.isEmpty() ? QString::fromLatin1("column") : tagName.toLower());
 
2164
 
 
2165
    QDomElement child;
 
2166
 
 
2167
    for (int i = 0; i < m_property.size(); ++i) {
 
2168
        DomProperty* v = m_property[i];
 
2169
        QDomNode child = v->write(doc, QLatin1String("property"));
 
2170
        e.appendChild(child);
 
2171
    }
 
2172
    if (!m_text.isEmpty())
 
2173
        e.appendChild(doc.createTextNode(m_text));
 
2174
 
 
2175
    return e;
 
2176
}
 
2177
 
 
2178
void DomColumn::setElementProperty(const QList<DomProperty*>& a)
 
2179
{
 
2180
    m_property = a;
 
2181
}
 
2182
 
 
2183
void DomItem::clear(bool clear_all)
 
2184
{
 
2185
    for (int i = 0; i < m_property.size(); ++i)
 
2186
        delete m_property[i];
 
2187
    m_property.clear();
 
2188
    for (int i = 0; i < m_item.size(); ++i)
 
2189
        delete m_item[i];
 
2190
    m_item.clear();
 
2191
 
 
2192
    if (clear_all) {
 
2193
    m_text = QString();
 
2194
    }
 
2195
 
 
2196
}
 
2197
 
 
2198
DomItem::DomItem()
 
2199
{
 
2200
}
 
2201
 
 
2202
DomItem::~DomItem()
 
2203
{
 
2204
    for (int i = 0; i < m_property.size(); ++i)
 
2205
        delete m_property[i];
 
2206
    m_property.clear();
 
2207
    for (int i = 0; i < m_item.size(); ++i)
 
2208
        delete m_item[i];
 
2209
    m_item.clear();
 
2210
}
 
2211
 
 
2212
void DomItem::read(const QDomElement &node)
 
2213
{
 
2214
 
 
2215
    for (QDomNode n = node.firstChild(); !n.isNull(); n = n.nextSibling()) {
 
2216
        if (!n.isElement())
 
2217
            continue;
 
2218
        QDomElement e = n.toElement();
 
2219
        QString tag = e.tagName().toLower();
 
2220
        if (tag == QLatin1String("property")) {
 
2221
            DomProperty *v = new DomProperty();
 
2222
            v->read(e);
 
2223
            m_property.append(v);
 
2224
            continue;
 
2225
        }
 
2226
        if (tag == QLatin1String("item")) {
 
2227
            DomItem *v = new DomItem();
 
2228
            v->read(e);
 
2229
            m_item.append(v);
 
2230
            continue;
 
2231
        }
 
2232
    }
 
2233
 
 
2234
    m_text.clear();
 
2235
    for (QDomNode child = node.firstChild(); !child.isNull(); child = child.nextSibling()) {
 
2236
        if (child.isText())
 
2237
            m_text.append(child.nodeValue());
 
2238
    }
 
2239
}
 
2240
 
 
2241
QDomElement DomItem::write(QDomDocument &doc, const QString &tagName)
 
2242
{
 
2243
    QDomElement e = doc.createElement(tagName.isEmpty() ? QString::fromLatin1("item") : tagName.toLower());
 
2244
 
 
2245
    QDomElement child;
 
2246
 
 
2247
    for (int i = 0; i < m_property.size(); ++i) {
 
2248
        DomProperty* v = m_property[i];
 
2249
        QDomNode child = v->write(doc, QLatin1String("property"));
 
2250
        e.appendChild(child);
 
2251
    }
 
2252
    for (int i = 0; i < m_item.size(); ++i) {
 
2253
        DomItem* v = m_item[i];
 
2254
        QDomNode child = v->write(doc, QLatin1String("item"));
 
2255
        e.appendChild(child);
 
2256
    }
 
2257
    if (!m_text.isEmpty())
 
2258
        e.appendChild(doc.createTextNode(m_text));
 
2259
 
 
2260
    return e;
 
2261
}
 
2262
 
 
2263
void DomItem::setElementProperty(const QList<DomProperty*>& a)
 
2264
{
 
2265
    m_property = a;
 
2266
}
 
2267
 
 
2268
void DomItem::setElementItem(const QList<DomItem*>& a)
 
2269
{
 
2270
    m_item = a;
 
2271
}
 
2272
 
 
2273
void DomWidget::clear(bool clear_all)
 
2274
{
 
2275
    m_class.clear();
 
2276
    for (int i = 0; i < m_property.size(); ++i)
 
2277
        delete m_property[i];
 
2278
    m_property.clear();
 
2279
    for (int i = 0; i < m_attribute.size(); ++i)
 
2280
        delete m_attribute[i];
 
2281
    m_attribute.clear();
 
2282
    for (int i = 0; i < m_row.size(); ++i)
 
2283
        delete m_row[i];
 
2284
    m_row.clear();
 
2285
    for (int i = 0; i < m_column.size(); ++i)
 
2286
        delete m_column[i];
 
2287
    m_column.clear();
 
2288
    for (int i = 0; i < m_item.size(); ++i)
 
2289
        delete m_item[i];
 
2290
    m_item.clear();
 
2291
    for (int i = 0; i < m_layout.size(); ++i)
 
2292
        delete m_layout[i];
 
2293
    m_layout.clear();
 
2294
    for (int i = 0; i < m_widget.size(); ++i)
 
2295
        delete m_widget[i];
 
2296
    m_widget.clear();
 
2297
    for (int i = 0; i < m_action.size(); ++i)
 
2298
        delete m_action[i];
 
2299
    m_action.clear();
 
2300
    for (int i = 0; i < m_actionGroup.size(); ++i)
 
2301
        delete m_actionGroup[i];
 
2302
    m_actionGroup.clear();
 
2303
    for (int i = 0; i < m_addAction.size(); ++i)
 
2304
        delete m_addAction[i];
 
2305
    m_addAction.clear();
 
2306
 
 
2307
    if (clear_all) {
 
2308
    m_text = QString();
 
2309
    m_has_attr_class = false;
 
2310
    m_has_attr_name = false;
 
2311
    }
 
2312
 
 
2313
}
 
2314
 
 
2315
DomWidget::DomWidget()
 
2316
{
 
2317
    m_has_attr_class = false;
 
2318
    m_has_attr_name = false;
 
2319
}
 
2320
 
 
2321
DomWidget::~DomWidget()
 
2322
{
 
2323
    m_class.clear();
 
2324
    for (int i = 0; i < m_property.size(); ++i)
 
2325
        delete m_property[i];
 
2326
    m_property.clear();
 
2327
    for (int i = 0; i < m_attribute.size(); ++i)
 
2328
        delete m_attribute[i];
 
2329
    m_attribute.clear();
 
2330
    for (int i = 0; i < m_row.size(); ++i)
 
2331
        delete m_row[i];
 
2332
    m_row.clear();
 
2333
    for (int i = 0; i < m_column.size(); ++i)
 
2334
        delete m_column[i];
 
2335
    m_column.clear();
 
2336
    for (int i = 0; i < m_item.size(); ++i)
 
2337
        delete m_item[i];
 
2338
    m_item.clear();
 
2339
    for (int i = 0; i < m_layout.size(); ++i)
 
2340
        delete m_layout[i];
 
2341
    m_layout.clear();
 
2342
    for (int i = 0; i < m_widget.size(); ++i)
 
2343
        delete m_widget[i];
 
2344
    m_widget.clear();
 
2345
    for (int i = 0; i < m_action.size(); ++i)
 
2346
        delete m_action[i];
 
2347
    m_action.clear();
 
2348
    for (int i = 0; i < m_actionGroup.size(); ++i)
 
2349
        delete m_actionGroup[i];
 
2350
    m_actionGroup.clear();
 
2351
    for (int i = 0; i < m_addAction.size(); ++i)
 
2352
        delete m_addAction[i];
 
2353
    m_addAction.clear();
 
2354
}
 
2355
 
 
2356
void DomWidget::read(const QDomElement &node)
 
2357
{
 
2358
    if (node.hasAttribute(QLatin1String("class")))
 
2359
        setAttributeClass(node.attribute(QLatin1String("class")));
 
2360
    if (node.hasAttribute(QLatin1String("name")))
 
2361
        setAttributeName(node.attribute(QLatin1String("name")));
 
2362
 
 
2363
    for (QDomNode n = node.firstChild(); !n.isNull(); n = n.nextSibling()) {
 
2364
        if (!n.isElement())
 
2365
            continue;
 
2366
        QDomElement e = n.toElement();
 
2367
        QString tag = e.tagName().toLower();
 
2368
        if (tag == QLatin1String("class")) {
 
2369
            m_class.append(e.text());
 
2370
            continue;
 
2371
        }
 
2372
        if (tag == QLatin1String("property")) {
 
2373
            DomProperty *v = new DomProperty();
 
2374
            v->read(e);
 
2375
            m_property.append(v);
 
2376
            continue;
 
2377
        }
 
2378
        if (tag == QLatin1String("attribute")) {
 
2379
            DomProperty *v = new DomProperty();
 
2380
            v->read(e);
 
2381
            m_attribute.append(v);
 
2382
            continue;
 
2383
        }
 
2384
        if (tag == QLatin1String("row")) {
 
2385
            DomRow *v = new DomRow();
 
2386
            v->read(e);
 
2387
            m_row.append(v);
 
2388
            continue;
 
2389
        }
 
2390
        if (tag == QLatin1String("column")) {
 
2391
            DomColumn *v = new DomColumn();
 
2392
            v->read(e);
 
2393
            m_column.append(v);
 
2394
            continue;
 
2395
        }
 
2396
        if (tag == QLatin1String("item")) {
 
2397
            DomItem *v = new DomItem();
 
2398
            v->read(e);
 
2399
            m_item.append(v);
 
2400
            continue;
 
2401
        }
 
2402
        if (tag == QLatin1String("layout")) {
 
2403
            DomLayout *v = new DomLayout();
 
2404
            v->read(e);
 
2405
            m_layout.append(v);
 
2406
            continue;
 
2407
        }
 
2408
        if (tag == QLatin1String("widget")) {
 
2409
            DomWidget *v = new DomWidget();
 
2410
            v->read(e);
 
2411
            m_widget.append(v);
 
2412
            continue;
 
2413
        }
 
2414
        if (tag == QLatin1String("action")) {
 
2415
            DomAction *v = new DomAction();
 
2416
            v->read(e);
 
2417
            m_action.append(v);
 
2418
            continue;
 
2419
        }
 
2420
        if (tag == QLatin1String("actiongroup")) {
 
2421
            DomActionGroup *v = new DomActionGroup();
 
2422
            v->read(e);
 
2423
            m_actionGroup.append(v);
 
2424
            continue;
 
2425
        }
 
2426
        if (tag == QLatin1String("addaction")) {
 
2427
            DomActionRef *v = new DomActionRef();
 
2428
            v->read(e);
 
2429
            m_addAction.append(v);
 
2430
            continue;
 
2431
        }
 
2432
    }
 
2433
 
 
2434
    m_text.clear();
 
2435
    for (QDomNode child = node.firstChild(); !child.isNull(); child = child.nextSibling()) {
 
2436
        if (child.isText())
 
2437
            m_text.append(child.nodeValue());
 
2438
    }
 
2439
}
 
2440
 
 
2441
QDomElement DomWidget::write(QDomDocument &doc, const QString &tagName)
 
2442
{
 
2443
    QDomElement e = doc.createElement(tagName.isEmpty() ? QString::fromLatin1("widget") : tagName.toLower());
 
2444
 
 
2445
    QDomElement child;
 
2446
 
 
2447
    if (hasAttributeClass())
 
2448
        e.setAttribute(QLatin1String("class"), attributeClass());
 
2449
 
 
2450
    if (hasAttributeName())
 
2451
        e.setAttribute(QLatin1String("name"), attributeName());
 
2452
 
 
2453
    for (int i = 0; i < m_class.size(); ++i) {
 
2454
        QString v = m_class[i];
 
2455
        QDomNode child = doc.createElement(QLatin1String("class"));
 
2456
        child.appendChild(doc.createTextNode(v));
 
2457
        e.appendChild(child);
 
2458
    }
 
2459
    for (int i = 0; i < m_property.size(); ++i) {
 
2460
        DomProperty* v = m_property[i];
 
2461
        QDomNode child = v->write(doc, QLatin1String("property"));
 
2462
        e.appendChild(child);
 
2463
    }
 
2464
    for (int i = 0; i < m_attribute.size(); ++i) {
 
2465
        DomProperty* v = m_attribute[i];
 
2466
        QDomNode child = v->write(doc, QLatin1String("attribute"));
 
2467
        e.appendChild(child);
 
2468
    }
 
2469
    for (int i = 0; i < m_row.size(); ++i) {
 
2470
        DomRow* v = m_row[i];
 
2471
        QDomNode child = v->write(doc, QLatin1String("row"));
 
2472
        e.appendChild(child);
 
2473
    }
 
2474
    for (int i = 0; i < m_column.size(); ++i) {
 
2475
        DomColumn* v = m_column[i];
 
2476
        QDomNode child = v->write(doc, QLatin1String("column"));
 
2477
        e.appendChild(child);
 
2478
    }
 
2479
    for (int i = 0; i < m_item.size(); ++i) {
 
2480
        DomItem* v = m_item[i];
 
2481
        QDomNode child = v->write(doc, QLatin1String("item"));
 
2482
        e.appendChild(child);
 
2483
    }
 
2484
    for (int i = 0; i < m_layout.size(); ++i) {
 
2485
        DomLayout* v = m_layout[i];
 
2486
        QDomNode child = v->write(doc, QLatin1String("layout"));
 
2487
        e.appendChild(child);
 
2488
    }
 
2489
    for (int i = 0; i < m_widget.size(); ++i) {
 
2490
        DomWidget* v = m_widget[i];
 
2491
        QDomNode child = v->write(doc, QLatin1String("widget"));
 
2492
        e.appendChild(child);
 
2493
    }
 
2494
    for (int i = 0; i < m_action.size(); ++i) {
 
2495
        DomAction* v = m_action[i];
 
2496
        QDomNode child = v->write(doc, QLatin1String("action"));
 
2497
        e.appendChild(child);
 
2498
    }
 
2499
    for (int i = 0; i < m_actionGroup.size(); ++i) {
 
2500
        DomActionGroup* v = m_actionGroup[i];
 
2501
        QDomNode child = v->write(doc, QLatin1String("actiongroup"));
 
2502
        e.appendChild(child);
 
2503
    }
 
2504
    for (int i = 0; i < m_addAction.size(); ++i) {
 
2505
        DomActionRef* v = m_addAction[i];
 
2506
        QDomNode child = v->write(doc, QLatin1String("addaction"));
 
2507
        e.appendChild(child);
 
2508
    }
 
2509
    if (!m_text.isEmpty())
 
2510
        e.appendChild(doc.createTextNode(m_text));
 
2511
 
 
2512
    return e;
 
2513
}
 
2514
 
 
2515
void DomWidget::setElementClass(const QStringList& a)
 
2516
{
 
2517
    m_class = a;
 
2518
}
 
2519
 
 
2520
void DomWidget::setElementProperty(const QList<DomProperty*>& a)
 
2521
{
 
2522
    m_property = a;
 
2523
}
 
2524
 
 
2525
void DomWidget::setElementAttribute(const QList<DomProperty*>& a)
 
2526
{
 
2527
    m_attribute = a;
 
2528
}
 
2529
 
 
2530
void DomWidget::setElementRow(const QList<DomRow*>& a)
 
2531
{
 
2532
    m_row = a;
 
2533
}
 
2534
 
 
2535
void DomWidget::setElementColumn(const QList<DomColumn*>& a)
 
2536
{
 
2537
    m_column = a;
 
2538
}
 
2539
 
 
2540
void DomWidget::setElementItem(const QList<DomItem*>& a)
 
2541
{
 
2542
    m_item = a;
 
2543
}
 
2544
 
 
2545
void DomWidget::setElementLayout(const QList<DomLayout*>& a)
 
2546
{
 
2547
    m_layout = a;
 
2548
}
 
2549
 
 
2550
void DomWidget::setElementWidget(const QList<DomWidget*>& a)
 
2551
{
 
2552
    m_widget = a;
 
2553
}
 
2554
 
 
2555
void DomWidget::setElementAction(const QList<DomAction*>& a)
 
2556
{
 
2557
    m_action = a;
 
2558
}
 
2559
 
 
2560
void DomWidget::setElementActionGroup(const QList<DomActionGroup*>& a)
 
2561
{
 
2562
    m_actionGroup = a;
 
2563
}
 
2564
 
 
2565
void DomWidget::setElementAddAction(const QList<DomActionRef*>& a)
 
2566
{
 
2567
    m_addAction = a;
 
2568
}
 
2569
 
 
2570
void DomSpacer::clear(bool clear_all)
 
2571
{
 
2572
    for (int i = 0; i < m_property.size(); ++i)
 
2573
        delete m_property[i];
 
2574
    m_property.clear();
 
2575
 
 
2576
    if (clear_all) {
 
2577
    m_text = QString();
 
2578
    m_has_attr_name = false;
 
2579
    }
 
2580
 
 
2581
}
 
2582
 
 
2583
DomSpacer::DomSpacer()
 
2584
{
 
2585
    m_has_attr_name = false;
 
2586
}
 
2587
 
 
2588
DomSpacer::~DomSpacer()
 
2589
{
 
2590
    for (int i = 0; i < m_property.size(); ++i)
 
2591
        delete m_property[i];
 
2592
    m_property.clear();
 
2593
}
 
2594
 
 
2595
void DomSpacer::read(const QDomElement &node)
 
2596
{
 
2597
    if (node.hasAttribute(QLatin1String("name")))
 
2598
        setAttributeName(node.attribute(QLatin1String("name")));
 
2599
 
 
2600
    for (QDomNode n = node.firstChild(); !n.isNull(); n = n.nextSibling()) {
 
2601
        if (!n.isElement())
 
2602
            continue;
 
2603
        QDomElement e = n.toElement();
 
2604
        QString tag = e.tagName().toLower();
 
2605
        if (tag == QLatin1String("property")) {
 
2606
            DomProperty *v = new DomProperty();
 
2607
            v->read(e);
 
2608
            m_property.append(v);
 
2609
            continue;
 
2610
        }
 
2611
    }
 
2612
 
 
2613
    m_text.clear();
 
2614
    for (QDomNode child = node.firstChild(); !child.isNull(); child = child.nextSibling()) {
 
2615
        if (child.isText())
 
2616
            m_text.append(child.nodeValue());
 
2617
    }
 
2618
}
 
2619
 
 
2620
QDomElement DomSpacer::write(QDomDocument &doc, const QString &tagName)
 
2621
{
 
2622
    QDomElement e = doc.createElement(tagName.isEmpty() ? QString::fromLatin1("spacer") : tagName.toLower());
 
2623
 
 
2624
    QDomElement child;
 
2625
 
 
2626
    if (hasAttributeName())
 
2627
        e.setAttribute(QLatin1String("name"), attributeName());
 
2628
 
 
2629
    for (int i = 0; i < m_property.size(); ++i) {
 
2630
        DomProperty* v = m_property[i];
 
2631
        QDomNode child = v->write(doc, QLatin1String("property"));
 
2632
        e.appendChild(child);
 
2633
    }
 
2634
    if (!m_text.isEmpty())
 
2635
        e.appendChild(doc.createTextNode(m_text));
 
2636
 
 
2637
    return e;
 
2638
}
 
2639
 
 
2640
void DomSpacer::setElementProperty(const QList<DomProperty*>& a)
 
2641
{
 
2642
    m_property = a;
 
2643
}
 
2644
 
 
2645
void DomColor::clear(bool clear_all)
 
2646
{
 
2647
 
 
2648
    if (clear_all) {
 
2649
    m_text = QString();
 
2650
    }
 
2651
 
 
2652
    m_red = 0;
 
2653
    m_green = 0;
 
2654
    m_blue = 0;
 
2655
}
 
2656
 
 
2657
DomColor::DomColor()
 
2658
{
 
2659
    m_red = 0;
 
2660
    m_green = 0;
 
2661
    m_blue = 0;
 
2662
}
 
2663
 
 
2664
DomColor::~DomColor()
 
2665
{
 
2666
}
 
2667
 
 
2668
void DomColor::read(const QDomElement &node)
 
2669
{
 
2670
 
 
2671
    for (QDomNode n = node.firstChild(); !n.isNull(); n = n.nextSibling()) {
 
2672
        if (!n.isElement())
 
2673
            continue;
 
2674
        QDomElement e = n.toElement();
 
2675
        QString tag = e.tagName().toLower();
 
2676
        if (tag == QLatin1String("red")) {
 
2677
            setElementRed(e.text().toInt());
 
2678
            continue;
 
2679
        }
 
2680
        if (tag == QLatin1String("green")) {
 
2681
            setElementGreen(e.text().toInt());
 
2682
            continue;
 
2683
        }
 
2684
        if (tag == QLatin1String("blue")) {
 
2685
            setElementBlue(e.text().toInt());
 
2686
            continue;
 
2687
        }
 
2688
    }
 
2689
 
 
2690
    m_text.clear();
 
2691
    for (QDomNode child = node.firstChild(); !child.isNull(); child = child.nextSibling()) {
 
2692
        if (child.isText())
 
2693
            m_text.append(child.nodeValue());
 
2694
    }
 
2695
}
 
2696
 
 
2697
QDomElement DomColor::write(QDomDocument &doc, const QString &tagName)
 
2698
{
 
2699
    QDomElement e = doc.createElement(tagName.isEmpty() ? QString::fromLatin1("color") : tagName.toLower());
 
2700
 
 
2701
    QDomElement child;
 
2702
 
 
2703
    child = doc.createElement(QLatin1String("red"));
 
2704
    child.appendChild(doc.createTextNode(QString::number(m_red)));
 
2705
    e.appendChild(child);
 
2706
 
 
2707
    child = doc.createElement(QLatin1String("green"));
 
2708
    child.appendChild(doc.createTextNode(QString::number(m_green)));
 
2709
    e.appendChild(child);
 
2710
 
 
2711
    child = doc.createElement(QLatin1String("blue"));
 
2712
    child.appendChild(doc.createTextNode(QString::number(m_blue)));
 
2713
    e.appendChild(child);
 
2714
 
 
2715
    if (!m_text.isEmpty())
 
2716
        e.appendChild(doc.createTextNode(m_text));
 
2717
 
 
2718
    return e;
 
2719
}
 
2720
 
 
2721
void DomColor::setElementRed(int a)
 
2722
{
 
2723
    m_red = a;
 
2724
}
 
2725
 
 
2726
void DomColor::setElementGreen(int a)
 
2727
{
 
2728
    m_green = a;
 
2729
}
 
2730
 
 
2731
void DomColor::setElementBlue(int a)
 
2732
{
 
2733
    m_blue = a;
 
2734
}
 
2735
 
 
2736
void DomColorGroup::clear(bool clear_all)
 
2737
{
 
2738
    for (int i = 0; i < m_color.size(); ++i)
 
2739
        delete m_color[i];
 
2740
    m_color.clear();
 
2741
 
 
2742
    if (clear_all) {
 
2743
    m_text = QString();
 
2744
    }
 
2745
 
 
2746
}
 
2747
 
 
2748
DomColorGroup::DomColorGroup()
 
2749
{
 
2750
}
 
2751
 
 
2752
DomColorGroup::~DomColorGroup()
 
2753
{
 
2754
    for (int i = 0; i < m_color.size(); ++i)
 
2755
        delete m_color[i];
 
2756
    m_color.clear();
 
2757
}
 
2758
 
 
2759
void DomColorGroup::read(const QDomElement &node)
 
2760
{
 
2761
 
 
2762
    for (QDomNode n = node.firstChild(); !n.isNull(); n = n.nextSibling()) {
 
2763
        if (!n.isElement())
 
2764
            continue;
 
2765
        QDomElement e = n.toElement();
 
2766
        QString tag = e.tagName().toLower();
 
2767
        if (tag == QLatin1String("color")) {
 
2768
            DomColor *v = new DomColor();
 
2769
            v->read(e);
 
2770
            m_color.append(v);
 
2771
            continue;
 
2772
        }
 
2773
    }
 
2774
 
 
2775
    m_text.clear();
 
2776
    for (QDomNode child = node.firstChild(); !child.isNull(); child = child.nextSibling()) {
 
2777
        if (child.isText())
 
2778
            m_text.append(child.nodeValue());
 
2779
    }
 
2780
}
 
2781
 
 
2782
QDomElement DomColorGroup::write(QDomDocument &doc, const QString &tagName)
 
2783
{
 
2784
    QDomElement e = doc.createElement(tagName.isEmpty() ? QString::fromLatin1("colorgroup") : tagName.toLower());
 
2785
 
 
2786
    QDomElement child;
 
2787
 
 
2788
    for (int i = 0; i < m_color.size(); ++i) {
 
2789
        DomColor* v = m_color[i];
 
2790
        QDomNode child = v->write(doc, QLatin1String("color"));
 
2791
        e.appendChild(child);
 
2792
    }
 
2793
    if (!m_text.isEmpty())
 
2794
        e.appendChild(doc.createTextNode(m_text));
 
2795
 
 
2796
    return e;
 
2797
}
 
2798
 
 
2799
void DomColorGroup::setElementColor(const QList<DomColor*>& a)
 
2800
{
 
2801
    m_color = a;
 
2802
}
 
2803
 
 
2804
void DomPalette::clear(bool clear_all)
 
2805
{
 
2806
    delete m_active;
 
2807
    delete m_inactive;
 
2808
    delete m_disabled;
 
2809
 
 
2810
    if (clear_all) {
 
2811
    m_text = QString();
 
2812
    }
 
2813
 
 
2814
    m_active = 0;
 
2815
    m_inactive = 0;
 
2816
    m_disabled = 0;
 
2817
}
 
2818
 
 
2819
DomPalette::DomPalette()
 
2820
{
 
2821
    m_active = 0;
 
2822
    m_inactive = 0;
 
2823
    m_disabled = 0;
 
2824
}
 
2825
 
 
2826
DomPalette::~DomPalette()
 
2827
{
 
2828
    delete m_active;
 
2829
    delete m_inactive;
 
2830
    delete m_disabled;
 
2831
}
 
2832
 
 
2833
void DomPalette::read(const QDomElement &node)
 
2834
{
 
2835
 
 
2836
    for (QDomNode n = node.firstChild(); !n.isNull(); n = n.nextSibling()) {
 
2837
        if (!n.isElement())
 
2838
            continue;
 
2839
        QDomElement e = n.toElement();
 
2840
        QString tag = e.tagName().toLower();
 
2841
        if (tag == QLatin1String("active")) {
 
2842
            DomColorGroup *v = new DomColorGroup();
 
2843
            v->read(e);
 
2844
            setElementActive(v);
 
2845
            continue;
 
2846
        }
 
2847
        if (tag == QLatin1String("inactive")) {
 
2848
            DomColorGroup *v = new DomColorGroup();
 
2849
            v->read(e);
 
2850
            setElementInactive(v);
 
2851
            continue;
 
2852
        }
 
2853
        if (tag == QLatin1String("disabled")) {
 
2854
            DomColorGroup *v = new DomColorGroup();
 
2855
            v->read(e);
 
2856
            setElementDisabled(v);
 
2857
            continue;
 
2858
        }
 
2859
    }
 
2860
 
 
2861
    m_text.clear();
 
2862
    for (QDomNode child = node.firstChild(); !child.isNull(); child = child.nextSibling()) {
 
2863
        if (child.isText())
 
2864
            m_text.append(child.nodeValue());
 
2865
    }
 
2866
}
 
2867
 
 
2868
QDomElement DomPalette::write(QDomDocument &doc, const QString &tagName)
 
2869
{
 
2870
    QDomElement e = doc.createElement(tagName.isEmpty() ? QString::fromLatin1("palette") : tagName.toLower());
 
2871
 
 
2872
    QDomElement child;
 
2873
 
 
2874
    if (m_active != 0)
 
2875
        e.appendChild(m_active->write(doc, QLatin1String("active")));
 
2876
 
 
2877
    if (m_inactive != 0)
 
2878
        e.appendChild(m_inactive->write(doc, QLatin1String("inactive")));
 
2879
 
 
2880
    if (m_disabled != 0)
 
2881
        e.appendChild(m_disabled->write(doc, QLatin1String("disabled")));
 
2882
 
 
2883
    if (!m_text.isEmpty())
 
2884
        e.appendChild(doc.createTextNode(m_text));
 
2885
 
 
2886
    return e;
 
2887
}
 
2888
 
 
2889
void DomPalette::setElementActive(DomColorGroup* a)
 
2890
{
 
2891
    delete m_active;
 
2892
    m_active = a;
 
2893
}
 
2894
 
 
2895
void DomPalette::setElementInactive(DomColorGroup* a)
 
2896
{
 
2897
    delete m_inactive;
 
2898
    m_inactive = a;
 
2899
}
 
2900
 
 
2901
void DomPalette::setElementDisabled(DomColorGroup* a)
 
2902
{
 
2903
    delete m_disabled;
 
2904
    m_disabled = a;
 
2905
}
 
2906
 
 
2907
void DomFont::clear(bool clear_all)
 
2908
{
 
2909
 
 
2910
    if (clear_all) {
 
2911
    m_text = QString();
 
2912
    }
 
2913
 
 
2914
    m_pointSize = 0;
 
2915
    m_weight = 0;
 
2916
    m_italic = false;
 
2917
    m_bold = false;
 
2918
    m_underline = false;
 
2919
    m_strikeOut = false;
 
2920
}
 
2921
 
 
2922
DomFont::DomFont()
 
2923
{
 
2924
    m_pointSize = 0;
 
2925
    m_weight = 0;
 
2926
    m_italic = false;
 
2927
    m_bold = false;
 
2928
    m_underline = false;
 
2929
    m_strikeOut = false;
 
2930
}
 
2931
 
 
2932
DomFont::~DomFont()
 
2933
{
 
2934
}
 
2935
 
 
2936
void DomFont::read(const QDomElement &node)
 
2937
{
 
2938
 
 
2939
    for (QDomNode n = node.firstChild(); !n.isNull(); n = n.nextSibling()) {
 
2940
        if (!n.isElement())
 
2941
            continue;
 
2942
        QDomElement e = n.toElement();
 
2943
        QString tag = e.tagName().toLower();
 
2944
        if (tag == QLatin1String("family")) {
 
2945
            setElementFamily(e.text());
 
2946
            continue;
 
2947
        }
 
2948
        if (tag == QLatin1String("pointsize")) {
 
2949
            setElementPointSize(e.text().toInt());
 
2950
            continue;
 
2951
        }
 
2952
        if (tag == QLatin1String("weight")) {
 
2953
            setElementWeight(e.text().toInt());
 
2954
            continue;
 
2955
        }
 
2956
        if (tag == QLatin1String("italic")) {
 
2957
            setElementItalic((e.text() == QLatin1String("true") ? true : false));
 
2958
            continue;
 
2959
        }
 
2960
        if (tag == QLatin1String("bold")) {
 
2961
            setElementBold((e.text() == QLatin1String("true") ? true : false));
 
2962
            continue;
 
2963
        }
 
2964
        if (tag == QLatin1String("underline")) {
 
2965
            setElementUnderline((e.text() == QLatin1String("true") ? true : false));
 
2966
            continue;
 
2967
        }
 
2968
        if (tag == QLatin1String("strikeout")) {
 
2969
            setElementStrikeOut((e.text() == QLatin1String("true") ? true : false));
 
2970
            continue;
 
2971
        }
 
2972
    }
 
2973
 
 
2974
    m_text.clear();
 
2975
    for (QDomNode child = node.firstChild(); !child.isNull(); child = child.nextSibling()) {
 
2976
        if (child.isText())
 
2977
            m_text.append(child.nodeValue());
 
2978
    }
 
2979
}
 
2980
 
 
2981
QDomElement DomFont::write(QDomDocument &doc, const QString &tagName)
 
2982
{
 
2983
    QDomElement e = doc.createElement(tagName.isEmpty() ? QString::fromLatin1("font") : tagName.toLower());
 
2984
 
 
2985
    QDomElement child;
 
2986
 
 
2987
    child = doc.createElement(QLatin1String("family"));
 
2988
    child.appendChild(doc.createTextNode(m_family));
 
2989
    e.appendChild(child);
 
2990
 
 
2991
    child = doc.createElement(QLatin1String("pointsize"));
 
2992
    child.appendChild(doc.createTextNode(QString::number(m_pointSize)));
 
2993
    e.appendChild(child);
 
2994
 
 
2995
    child = doc.createElement(QLatin1String("weight"));
 
2996
    child.appendChild(doc.createTextNode(QString::number(m_weight)));
 
2997
    e.appendChild(child);
 
2998
 
 
2999
    child = doc.createElement(QLatin1String("italic"));
 
3000
    child.appendChild(doc.createTextNode((m_italic ? QLatin1String("true") : QLatin1String("false"))));
 
3001
    e.appendChild(child);
 
3002
 
 
3003
    child = doc.createElement(QLatin1String("bold"));
 
3004
    child.appendChild(doc.createTextNode((m_bold ? QLatin1String("true") : QLatin1String("false"))));
 
3005
    e.appendChild(child);
 
3006
 
 
3007
    child = doc.createElement(QLatin1String("underline"));
 
3008
    child.appendChild(doc.createTextNode((m_underline ? QLatin1String("true") : QLatin1String("false"))));
 
3009
    e.appendChild(child);
 
3010
 
 
3011
    child = doc.createElement(QLatin1String("strikeout"));
 
3012
    child.appendChild(doc.createTextNode((m_strikeOut ? QLatin1String("true") : QLatin1String("false"))));
 
3013
    e.appendChild(child);
 
3014
 
 
3015
    if (!m_text.isEmpty())
 
3016
        e.appendChild(doc.createTextNode(m_text));
 
3017
 
 
3018
    return e;
 
3019
}
 
3020
 
 
3021
void DomFont::setElementFamily(const QString& a)
 
3022
{
 
3023
    m_family = a;
 
3024
}
 
3025
 
 
3026
void DomFont::setElementPointSize(int a)
 
3027
{
 
3028
    m_pointSize = a;
 
3029
}
 
3030
 
 
3031
void DomFont::setElementWeight(int a)
 
3032
{
 
3033
    m_weight = a;
 
3034
}
 
3035
 
 
3036
void DomFont::setElementItalic(bool a)
 
3037
{
 
3038
    m_italic = a;
 
3039
}
 
3040
 
 
3041
void DomFont::setElementBold(bool a)
 
3042
{
 
3043
    m_bold = a;
 
3044
}
 
3045
 
 
3046
void DomFont::setElementUnderline(bool a)
 
3047
{
 
3048
    m_underline = a;
 
3049
}
 
3050
 
 
3051
void DomFont::setElementStrikeOut(bool a)
 
3052
{
 
3053
    m_strikeOut = a;
 
3054
}
 
3055
 
 
3056
void DomPoint::clear(bool clear_all)
 
3057
{
 
3058
 
 
3059
    if (clear_all) {
 
3060
    m_text = QString();
 
3061
    }
 
3062
 
 
3063
    m_x = 0;
 
3064
    m_y = 0;
 
3065
}
 
3066
 
 
3067
DomPoint::DomPoint()
 
3068
{
 
3069
    m_x = 0;
 
3070
    m_y = 0;
 
3071
}
 
3072
 
 
3073
DomPoint::~DomPoint()
 
3074
{
 
3075
}
 
3076
 
 
3077
void DomPoint::read(const QDomElement &node)
 
3078
{
 
3079
 
 
3080
    for (QDomNode n = node.firstChild(); !n.isNull(); n = n.nextSibling()) {
 
3081
        if (!n.isElement())
 
3082
            continue;
 
3083
        QDomElement e = n.toElement();
 
3084
        QString tag = e.tagName().toLower();
 
3085
        if (tag == QLatin1String("x")) {
 
3086
            setElementX(e.text().toInt());
 
3087
            continue;
 
3088
        }
 
3089
        if (tag == QLatin1String("y")) {
 
3090
            setElementY(e.text().toInt());
 
3091
            continue;
 
3092
        }
 
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
 
 
3102
QDomElement DomPoint::write(QDomDocument &doc, const QString &tagName)
 
3103
{
 
3104
    QDomElement e = doc.createElement(tagName.isEmpty() ? QString::fromLatin1("point") : tagName.toLower());
 
3105
 
 
3106
    QDomElement child;
 
3107
 
 
3108
    child = doc.createElement(QLatin1String("x"));
 
3109
    child.appendChild(doc.createTextNode(QString::number(m_x)));
 
3110
    e.appendChild(child);
 
3111
 
 
3112
    child = doc.createElement(QLatin1String("y"));
 
3113
    child.appendChild(doc.createTextNode(QString::number(m_y)));
 
3114
    e.appendChild(child);
 
3115
 
 
3116
    if (!m_text.isEmpty())
 
3117
        e.appendChild(doc.createTextNode(m_text));
 
3118
 
 
3119
    return e;
 
3120
}
 
3121
 
 
3122
void DomPoint::setElementX(int a)
 
3123
{
 
3124
    m_x = a;
 
3125
}
 
3126
 
 
3127
void DomPoint::setElementY(int a)
 
3128
{
 
3129
    m_y = a;
 
3130
}
 
3131
 
 
3132
void DomRect::clear(bool clear_all)
 
3133
{
 
3134
 
 
3135
    if (clear_all) {
 
3136
    m_text = QString();
 
3137
    }
 
3138
 
 
3139
    m_x = 0;
 
3140
    m_y = 0;
 
3141
    m_width = 0;
 
3142
    m_height = 0;
 
3143
}
 
3144
 
 
3145
DomRect::DomRect()
 
3146
{
 
3147
    m_x = 0;
 
3148
    m_y = 0;
 
3149
    m_width = 0;
 
3150
    m_height = 0;
 
3151
}
 
3152
 
 
3153
DomRect::~DomRect()
 
3154
{
 
3155
}
 
3156
 
 
3157
void DomRect::read(const QDomElement &node)
 
3158
{
 
3159
 
 
3160
    for (QDomNode n = node.firstChild(); !n.isNull(); n = n.nextSibling()) {
 
3161
        if (!n.isElement())
 
3162
            continue;
 
3163
        QDomElement e = n.toElement();
 
3164
        QString tag = e.tagName().toLower();
 
3165
        if (tag == QLatin1String("x")) {
 
3166
            setElementX(e.text().toInt());
 
3167
            continue;
 
3168
        }
 
3169
        if (tag == QLatin1String("y")) {
 
3170
            setElementY(e.text().toInt());
 
3171
            continue;
 
3172
        }
 
3173
        if (tag == QLatin1String("width")) {
 
3174
            setElementWidth(e.text().toInt());
 
3175
            continue;
 
3176
        }
 
3177
        if (tag == QLatin1String("height")) {
 
3178
            setElementHeight(e.text().toInt());
 
3179
            continue;
 
3180
        }
 
3181
    }
 
3182
 
 
3183
    m_text.clear();
 
3184
    for (QDomNode child = node.firstChild(); !child.isNull(); child = child.nextSibling()) {
 
3185
        if (child.isText())
 
3186
            m_text.append(child.nodeValue());
 
3187
    }
 
3188
}
 
3189
 
 
3190
QDomElement DomRect::write(QDomDocument &doc, const QString &tagName)
 
3191
{
 
3192
    QDomElement e = doc.createElement(tagName.isEmpty() ? QString::fromLatin1("rect") : tagName.toLower());
 
3193
 
 
3194
    QDomElement child;
 
3195
 
 
3196
    child = doc.createElement(QLatin1String("x"));
 
3197
    child.appendChild(doc.createTextNode(QString::number(m_x)));
 
3198
    e.appendChild(child);
 
3199
 
 
3200
    child = doc.createElement(QLatin1String("y"));
 
3201
    child.appendChild(doc.createTextNode(QString::number(m_y)));
 
3202
    e.appendChild(child);
 
3203
 
 
3204
    child = doc.createElement(QLatin1String("width"));
 
3205
    child.appendChild(doc.createTextNode(QString::number(m_width)));
 
3206
    e.appendChild(child);
 
3207
 
 
3208
    child = doc.createElement(QLatin1String("height"));
 
3209
    child.appendChild(doc.createTextNode(QString::number(m_height)));
 
3210
    e.appendChild(child);
 
3211
 
 
3212
    if (!m_text.isEmpty())
 
3213
        e.appendChild(doc.createTextNode(m_text));
 
3214
 
 
3215
    return e;
 
3216
}
 
3217
 
 
3218
void DomRect::setElementX(int a)
 
3219
{
 
3220
    m_x = a;
 
3221
}
 
3222
 
 
3223
void DomRect::setElementY(int a)
 
3224
{
 
3225
    m_y = a;
 
3226
}
 
3227
 
 
3228
void DomRect::setElementWidth(int a)
 
3229
{
 
3230
    m_width = a;
 
3231
}
 
3232
 
 
3233
void DomRect::setElementHeight(int a)
 
3234
{
 
3235
    m_height = a;
 
3236
}
 
3237
 
 
3238
void DomSizePolicy::clear(bool clear_all)
 
3239
{
 
3240
 
 
3241
    if (clear_all) {
 
3242
    m_text = QString();
 
3243
    }
 
3244
 
 
3245
    m_hSizeType = 0;
 
3246
    m_vSizeType = 0;
 
3247
    m_horStretch = 0;
 
3248
    m_verStretch = 0;
 
3249
}
 
3250
 
 
3251
DomSizePolicy::DomSizePolicy()
 
3252
{
 
3253
    m_hSizeType = 0;
 
3254
    m_vSizeType = 0;
 
3255
    m_horStretch = 0;
 
3256
    m_verStretch = 0;
 
3257
}
 
3258
 
 
3259
DomSizePolicy::~DomSizePolicy()
 
3260
{
 
3261
}
 
3262
 
 
3263
void DomSizePolicy::read(const QDomElement &node)
 
3264
{
 
3265
 
 
3266
    for (QDomNode n = node.firstChild(); !n.isNull(); n = n.nextSibling()) {
 
3267
        if (!n.isElement())
 
3268
            continue;
 
3269
        QDomElement e = n.toElement();
 
3270
        QString tag = e.tagName().toLower();
 
3271
        if (tag == QLatin1String("hsizetype")) {
 
3272
            setElementHSizeType(e.text().toInt());
 
3273
            continue;
 
3274
        }
 
3275
        if (tag == QLatin1String("vsizetype")) {
 
3276
            setElementVSizeType(e.text().toInt());
 
3277
            continue;
 
3278
        }
 
3279
        if (tag == QLatin1String("horstretch")) {
 
3280
            setElementHorStretch(e.text().toInt());
 
3281
            continue;
 
3282
        }
 
3283
        if (tag == QLatin1String("verstretch")) {
 
3284
            setElementVerStretch(e.text().toInt());
 
3285
            continue;
 
3286
        }
 
3287
    }
 
3288
 
 
3289
    m_text.clear();
 
3290
    for (QDomNode child = node.firstChild(); !child.isNull(); child = child.nextSibling()) {
 
3291
        if (child.isText())
 
3292
            m_text.append(child.nodeValue());
 
3293
    }
 
3294
}
 
3295
 
 
3296
QDomElement DomSizePolicy::write(QDomDocument &doc, const QString &tagName)
 
3297
{
 
3298
    QDomElement e = doc.createElement(tagName.isEmpty() ? QString::fromLatin1("sizepolicy") : tagName.toLower());
 
3299
 
 
3300
    QDomElement child;
 
3301
 
 
3302
    child = doc.createElement(QLatin1String("hsizetype"));
 
3303
    child.appendChild(doc.createTextNode(QString::number(m_hSizeType)));
 
3304
    e.appendChild(child);
 
3305
 
 
3306
    child = doc.createElement(QLatin1String("vsizetype"));
 
3307
    child.appendChild(doc.createTextNode(QString::number(m_vSizeType)));
 
3308
    e.appendChild(child);
 
3309
 
 
3310
    child = doc.createElement(QLatin1String("horstretch"));
 
3311
    child.appendChild(doc.createTextNode(QString::number(m_horStretch)));
 
3312
    e.appendChild(child);
 
3313
 
 
3314
    child = doc.createElement(QLatin1String("verstretch"));
 
3315
    child.appendChild(doc.createTextNode(QString::number(m_verStretch)));
 
3316
    e.appendChild(child);
 
3317
 
 
3318
    if (!m_text.isEmpty())
 
3319
        e.appendChild(doc.createTextNode(m_text));
 
3320
 
 
3321
    return e;
 
3322
}
 
3323
 
 
3324
void DomSizePolicy::setElementHSizeType(int a)
 
3325
{
 
3326
    m_hSizeType = a;
 
3327
}
 
3328
 
 
3329
void DomSizePolicy::setElementVSizeType(int a)
 
3330
{
 
3331
    m_vSizeType = a;
 
3332
}
 
3333
 
 
3334
void DomSizePolicy::setElementHorStretch(int a)
 
3335
{
 
3336
    m_horStretch = a;
 
3337
}
 
3338
 
 
3339
void DomSizePolicy::setElementVerStretch(int a)
 
3340
{
 
3341
    m_verStretch = a;
 
3342
}
 
3343
 
 
3344
void DomSize::clear(bool clear_all)
 
3345
{
 
3346
 
 
3347
    if (clear_all) {
 
3348
    m_text = QString();
 
3349
    }
 
3350
 
 
3351
    m_width = 0;
 
3352
    m_height = 0;
 
3353
}
 
3354
 
 
3355
DomSize::DomSize()
 
3356
{
 
3357
    m_width = 0;
 
3358
    m_height = 0;
 
3359
}
 
3360
 
 
3361
DomSize::~DomSize()
 
3362
{
 
3363
}
 
3364
 
 
3365
void DomSize::read(const QDomElement &node)
 
3366
{
 
3367
 
 
3368
    for (QDomNode n = node.firstChild(); !n.isNull(); n = n.nextSibling()) {
 
3369
        if (!n.isElement())
 
3370
            continue;
 
3371
        QDomElement e = n.toElement();
 
3372
        QString tag = e.tagName().toLower();
 
3373
        if (tag == QLatin1String("width")) {
 
3374
            setElementWidth(e.text().toInt());
 
3375
            continue;
 
3376
        }
 
3377
        if (tag == QLatin1String("height")) {
 
3378
            setElementHeight(e.text().toInt());
 
3379
            continue;
 
3380
        }
 
3381
    }
 
3382
 
 
3383
    m_text.clear();
 
3384
    for (QDomNode child = node.firstChild(); !child.isNull(); child = child.nextSibling()) {
 
3385
        if (child.isText())
 
3386
            m_text.append(child.nodeValue());
 
3387
    }
 
3388
}
 
3389
 
 
3390
QDomElement DomSize::write(QDomDocument &doc, const QString &tagName)
 
3391
{
 
3392
    QDomElement e = doc.createElement(tagName.isEmpty() ? QString::fromLatin1("size") : tagName.toLower());
 
3393
 
 
3394
    QDomElement child;
 
3395
 
 
3396
    child = doc.createElement(QLatin1String("width"));
 
3397
    child.appendChild(doc.createTextNode(QString::number(m_width)));
 
3398
    e.appendChild(child);
 
3399
 
 
3400
    child = doc.createElement(QLatin1String("height"));
 
3401
    child.appendChild(doc.createTextNode(QString::number(m_height)));
 
3402
    e.appendChild(child);
 
3403
 
 
3404
    if (!m_text.isEmpty())
 
3405
        e.appendChild(doc.createTextNode(m_text));
 
3406
 
 
3407
    return e;
 
3408
}
 
3409
 
 
3410
void DomSize::setElementWidth(int a)
 
3411
{
 
3412
    m_width = a;
 
3413
}
 
3414
 
 
3415
void DomSize::setElementHeight(int a)
 
3416
{
 
3417
    m_height = a;
 
3418
}
 
3419
 
 
3420
void DomDate::clear(bool clear_all)
 
3421
{
 
3422
 
 
3423
    if (clear_all) {
 
3424
    m_text = QString();
 
3425
    }
 
3426
 
 
3427
    m_year = 0;
 
3428
    m_month = 0;
 
3429
    m_day = 0;
 
3430
}
 
3431
 
 
3432
DomDate::DomDate()
 
3433
{
 
3434
    m_year = 0;
 
3435
    m_month = 0;
 
3436
    m_day = 0;
 
3437
}
 
3438
 
 
3439
DomDate::~DomDate()
 
3440
{
 
3441
}
 
3442
 
 
3443
void DomDate::read(const QDomElement &node)
 
3444
{
 
3445
 
 
3446
    for (QDomNode n = node.firstChild(); !n.isNull(); n = n.nextSibling()) {
 
3447
        if (!n.isElement())
 
3448
            continue;
 
3449
        QDomElement e = n.toElement();
 
3450
        QString tag = e.tagName().toLower();
 
3451
        if (tag == QLatin1String("year")) {
 
3452
            setElementYear(e.text().toInt());
 
3453
            continue;
 
3454
        }
 
3455
        if (tag == QLatin1String("month")) {
 
3456
            setElementMonth(e.text().toInt());
 
3457
            continue;
 
3458
        }
 
3459
        if (tag == QLatin1String("day")) {
 
3460
            setElementDay(e.text().toInt());
 
3461
            continue;
 
3462
        }
 
3463
    }
 
3464
 
 
3465
    m_text.clear();
 
3466
    for (QDomNode child = node.firstChild(); !child.isNull(); child = child.nextSibling()) {
 
3467
        if (child.isText())
 
3468
            m_text.append(child.nodeValue());
 
3469
    }
 
3470
}
 
3471
 
 
3472
QDomElement DomDate::write(QDomDocument &doc, const QString &tagName)
 
3473
{
 
3474
    QDomElement e = doc.createElement(tagName.isEmpty() ? QString::fromLatin1("date") : tagName.toLower());
 
3475
 
 
3476
    QDomElement child;
 
3477
 
 
3478
    child = doc.createElement(QLatin1String("year"));
 
3479
    child.appendChild(doc.createTextNode(QString::number(m_year)));
 
3480
    e.appendChild(child);
 
3481
 
 
3482
    child = doc.createElement(QLatin1String("month"));
 
3483
    child.appendChild(doc.createTextNode(QString::number(m_month)));
 
3484
    e.appendChild(child);
 
3485
 
 
3486
    child = doc.createElement(QLatin1String("day"));
 
3487
    child.appendChild(doc.createTextNode(QString::number(m_day)));
 
3488
    e.appendChild(child);
 
3489
 
 
3490
    if (!m_text.isEmpty())
 
3491
        e.appendChild(doc.createTextNode(m_text));
 
3492
 
 
3493
    return e;
 
3494
}
 
3495
 
 
3496
void DomDate::setElementYear(int a)
 
3497
{
 
3498
    m_year = a;
 
3499
}
 
3500
 
 
3501
void DomDate::setElementMonth(int a)
 
3502
{
 
3503
    m_month = a;
 
3504
}
 
3505
 
 
3506
void DomDate::setElementDay(int a)
 
3507
{
 
3508
    m_day = a;
 
3509
}
 
3510
 
 
3511
void DomTime::clear(bool clear_all)
 
3512
{
 
3513
 
 
3514
    if (clear_all) {
 
3515
    m_text = QString();
 
3516
    }
 
3517
 
 
3518
    m_hour = 0;
 
3519
    m_minute = 0;
 
3520
    m_second = 0;
 
3521
}
 
3522
 
 
3523
DomTime::DomTime()
 
3524
{
 
3525
    m_hour = 0;
 
3526
    m_minute = 0;
 
3527
    m_second = 0;
 
3528
}
 
3529
 
 
3530
DomTime::~DomTime()
 
3531
{
 
3532
}
 
3533
 
 
3534
void DomTime::read(const QDomElement &node)
 
3535
{
 
3536
 
 
3537
    for (QDomNode n = node.firstChild(); !n.isNull(); n = n.nextSibling()) {
 
3538
        if (!n.isElement())
 
3539
            continue;
 
3540
        QDomElement e = n.toElement();
 
3541
        QString tag = e.tagName().toLower();
 
3542
        if (tag == QLatin1String("hour")) {
 
3543
            setElementHour(e.text().toInt());
 
3544
            continue;
 
3545
        }
 
3546
        if (tag == QLatin1String("minute")) {
 
3547
            setElementMinute(e.text().toInt());
 
3548
            continue;
 
3549
        }
 
3550
        if (tag == QLatin1String("second")) {
 
3551
            setElementSecond(e.text().toInt());
 
3552
            continue;
 
3553
        }
 
3554
    }
 
3555
 
 
3556
    m_text.clear();
 
3557
    for (QDomNode child = node.firstChild(); !child.isNull(); child = child.nextSibling()) {
 
3558
        if (child.isText())
 
3559
            m_text.append(child.nodeValue());
 
3560
    }
 
3561
}
 
3562
 
 
3563
QDomElement DomTime::write(QDomDocument &doc, const QString &tagName)
 
3564
{
 
3565
    QDomElement e = doc.createElement(tagName.isEmpty() ? QString::fromLatin1("time") : tagName.toLower());
 
3566
 
 
3567
    QDomElement child;
 
3568
 
 
3569
    child = doc.createElement(QLatin1String("hour"));
 
3570
    child.appendChild(doc.createTextNode(QString::number(m_hour)));
 
3571
    e.appendChild(child);
 
3572
 
 
3573
    child = doc.createElement(QLatin1String("minute"));
 
3574
    child.appendChild(doc.createTextNode(QString::number(m_minute)));
 
3575
    e.appendChild(child);
 
3576
 
 
3577
    child = doc.createElement(QLatin1String("second"));
 
3578
    child.appendChild(doc.createTextNode(QString::number(m_second)));
 
3579
    e.appendChild(child);
 
3580
 
 
3581
    if (!m_text.isEmpty())
 
3582
        e.appendChild(doc.createTextNode(m_text));
 
3583
 
 
3584
    return e;
 
3585
}
 
3586
 
 
3587
void DomTime::setElementHour(int a)
 
3588
{
 
3589
    m_hour = a;
 
3590
}
 
3591
 
 
3592
void DomTime::setElementMinute(int a)
 
3593
{
 
3594
    m_minute = a;
 
3595
}
 
3596
 
 
3597
void DomTime::setElementSecond(int a)
 
3598
{
 
3599
    m_second = a;
 
3600
}
 
3601
 
 
3602
void DomDateTime::clear(bool clear_all)
 
3603
{
 
3604
 
 
3605
    if (clear_all) {
 
3606
    m_text = QString();
 
3607
    }
 
3608
 
 
3609
    m_hour = 0;
 
3610
    m_minute = 0;
 
3611
    m_second = 0;
 
3612
    m_year = 0;
 
3613
    m_month = 0;
 
3614
    m_day = 0;
 
3615
}
 
3616
 
 
3617
DomDateTime::DomDateTime()
 
3618
{
 
3619
    m_hour = 0;
 
3620
    m_minute = 0;
 
3621
    m_second = 0;
 
3622
    m_year = 0;
 
3623
    m_month = 0;
 
3624
    m_day = 0;
 
3625
}
 
3626
 
 
3627
DomDateTime::~DomDateTime()
 
3628
{
 
3629
}
 
3630
 
 
3631
void DomDateTime::read(const QDomElement &node)
 
3632
{
 
3633
 
 
3634
    for (QDomNode n = node.firstChild(); !n.isNull(); n = n.nextSibling()) {
 
3635
        if (!n.isElement())
 
3636
            continue;
 
3637
        QDomElement e = n.toElement();
 
3638
        QString tag = e.tagName().toLower();
 
3639
        if (tag == QLatin1String("hour")) {
 
3640
            setElementHour(e.text().toInt());
 
3641
            continue;
 
3642
        }
 
3643
        if (tag == QLatin1String("minute")) {
 
3644
            setElementMinute(e.text().toInt());
 
3645
            continue;
 
3646
        }
 
3647
        if (tag == QLatin1String("second")) {
 
3648
            setElementSecond(e.text().toInt());
 
3649
            continue;
 
3650
        }
 
3651
        if (tag == QLatin1String("year")) {
 
3652
            setElementYear(e.text().toInt());
 
3653
            continue;
 
3654
        }
 
3655
        if (tag == QLatin1String("month")) {
 
3656
            setElementMonth(e.text().toInt());
 
3657
            continue;
 
3658
        }
 
3659
        if (tag == QLatin1String("day")) {
 
3660
            setElementDay(e.text().toInt());
 
3661
            continue;
 
3662
        }
 
3663
    }
 
3664
 
 
3665
    m_text.clear();
 
3666
    for (QDomNode child = node.firstChild(); !child.isNull(); child = child.nextSibling()) {
 
3667
        if (child.isText())
 
3668
            m_text.append(child.nodeValue());
 
3669
    }
 
3670
}
 
3671
 
 
3672
QDomElement DomDateTime::write(QDomDocument &doc, const QString &tagName)
 
3673
{
 
3674
    QDomElement e = doc.createElement(tagName.isEmpty() ? QString::fromLatin1("datetime") : tagName.toLower());
 
3675
 
 
3676
    QDomElement child;
 
3677
 
 
3678
    child = doc.createElement(QLatin1String("hour"));
 
3679
    child.appendChild(doc.createTextNode(QString::number(m_hour)));
 
3680
    e.appendChild(child);
 
3681
 
 
3682
    child = doc.createElement(QLatin1String("minute"));
 
3683
    child.appendChild(doc.createTextNode(QString::number(m_minute)));
 
3684
    e.appendChild(child);
 
3685
 
 
3686
    child = doc.createElement(QLatin1String("second"));
 
3687
    child.appendChild(doc.createTextNode(QString::number(m_second)));
 
3688
    e.appendChild(child);
 
3689
 
 
3690
    child = doc.createElement(QLatin1String("year"));
 
3691
    child.appendChild(doc.createTextNode(QString::number(m_year)));
 
3692
    e.appendChild(child);
 
3693
 
 
3694
    child = doc.createElement(QLatin1String("month"));
 
3695
    child.appendChild(doc.createTextNode(QString::number(m_month)));
 
3696
    e.appendChild(child);
 
3697
 
 
3698
    child = doc.createElement(QLatin1String("day"));
 
3699
    child.appendChild(doc.createTextNode(QString::number(m_day)));
 
3700
    e.appendChild(child);
 
3701
 
 
3702
    if (!m_text.isEmpty())
 
3703
        e.appendChild(doc.createTextNode(m_text));
 
3704
 
 
3705
    return e;
 
3706
}
 
3707
 
 
3708
void DomDateTime::setElementHour(int a)
 
3709
{
 
3710
    m_hour = a;
 
3711
}
 
3712
 
 
3713
void DomDateTime::setElementMinute(int a)
 
3714
{
 
3715
    m_minute = a;
 
3716
}
 
3717
 
 
3718
void DomDateTime::setElementSecond(int a)
 
3719
{
 
3720
    m_second = a;
 
3721
}
 
3722
 
 
3723
void DomDateTime::setElementYear(int a)
 
3724
{
 
3725
    m_year = a;
 
3726
}
 
3727
 
 
3728
void DomDateTime::setElementMonth(int a)
 
3729
{
 
3730
    m_month = a;
 
3731
}
 
3732
 
 
3733
void DomDateTime::setElementDay(int a)
 
3734
{
 
3735
    m_day = a;
 
3736
}
 
3737
 
 
3738
void DomStringList::clear(bool clear_all)
 
3739
{
 
3740
    m_string.clear();
 
3741
 
 
3742
    if (clear_all) {
 
3743
    m_text = QString();
 
3744
    }
 
3745
 
 
3746
}
 
3747
 
 
3748
DomStringList::DomStringList()
 
3749
{
 
3750
}
 
3751
 
 
3752
DomStringList::~DomStringList()
 
3753
{
 
3754
    m_string.clear();
 
3755
}
 
3756
 
 
3757
void DomStringList::read(const QDomElement &node)
 
3758
{
 
3759
 
 
3760
    for (QDomNode n = node.firstChild(); !n.isNull(); n = n.nextSibling()) {
 
3761
        if (!n.isElement())
 
3762
            continue;
 
3763
        QDomElement e = n.toElement();
 
3764
        QString tag = e.tagName().toLower();
 
3765
        if (tag == QLatin1String("string")) {
 
3766
            m_string.append(e.text());
 
3767
            continue;
 
3768
        }
 
3769
    }
 
3770
 
 
3771
    m_text.clear();
 
3772
    for (QDomNode child = node.firstChild(); !child.isNull(); child = child.nextSibling()) {
 
3773
        if (child.isText())
 
3774
            m_text.append(child.nodeValue());
 
3775
    }
 
3776
}
 
3777
 
 
3778
QDomElement DomStringList::write(QDomDocument &doc, const QString &tagName)
 
3779
{
 
3780
    QDomElement e = doc.createElement(tagName.isEmpty() ? QString::fromLatin1("stringlist") : tagName.toLower());
 
3781
 
 
3782
    QDomElement child;
 
3783
 
 
3784
    for (int i = 0; i < m_string.size(); ++i) {
 
3785
        QString v = m_string[i];
 
3786
        QDomNode child = doc.createElement(QLatin1String("string"));
 
3787
        child.appendChild(doc.createTextNode(v));
 
3788
        e.appendChild(child);
 
3789
    }
 
3790
    if (!m_text.isEmpty())
 
3791
        e.appendChild(doc.createTextNode(m_text));
 
3792
 
 
3793
    return e;
 
3794
}
 
3795
 
 
3796
void DomStringList::setElementString(const QStringList& a)
 
3797
{
 
3798
    m_string = a;
 
3799
}
 
3800
 
 
3801
void DomResourcePixmap::clear(bool clear_all)
 
3802
{
 
3803
 
 
3804
    if (clear_all) {
 
3805
    m_text = QString();
 
3806
    m_has_attr_resource = false;
 
3807
    }
 
3808
 
 
3809
}
 
3810
 
 
3811
DomResourcePixmap::DomResourcePixmap()
 
3812
{
 
3813
    m_has_attr_resource = false;
 
3814
}
 
3815
 
 
3816
DomResourcePixmap::~DomResourcePixmap()
 
3817
{
 
3818
}
 
3819
 
 
3820
void DomResourcePixmap::read(const QDomElement &node)
 
3821
{
 
3822
    if (node.hasAttribute(QLatin1String("resource")))
 
3823
        setAttributeResource(node.attribute(QLatin1String("resource")));
 
3824
 
 
3825
    for (QDomNode n = node.firstChild(); !n.isNull(); n = n.nextSibling()) {
 
3826
        if (!n.isElement())
 
3827
            continue;
 
3828
        QDomElement e = n.toElement();
 
3829
        QString tag = e.tagName().toLower();
 
3830
    }
 
3831
 
 
3832
    m_text.clear();
 
3833
    for (QDomNode child = node.firstChild(); !child.isNull(); child = child.nextSibling()) {
 
3834
        if (child.isText())
 
3835
            m_text.append(child.nodeValue());
 
3836
    }
 
3837
}
 
3838
 
 
3839
QDomElement DomResourcePixmap::write(QDomDocument &doc, const QString &tagName)
 
3840
{
 
3841
    QDomElement e = doc.createElement(tagName.isEmpty() ? QString::fromLatin1("resourcepixmap") : tagName.toLower());
 
3842
 
 
3843
    QDomElement child;
 
3844
 
 
3845
    if (hasAttributeResource())
 
3846
        e.setAttribute(QLatin1String("resource"), attributeResource());
 
3847
 
 
3848
    if (!m_text.isEmpty())
 
3849
        e.appendChild(doc.createTextNode(m_text));
 
3850
 
 
3851
    return e;
 
3852
}
 
3853
 
 
3854
void DomString::clear(bool clear_all)
 
3855
{
 
3856
 
 
3857
    if (clear_all) {
 
3858
    m_text = QString();
 
3859
    m_has_attr_notr = false;
 
3860
    }
 
3861
 
 
3862
}
 
3863
 
 
3864
DomString::DomString()
 
3865
{
 
3866
    m_has_attr_notr = false;
 
3867
}
 
3868
 
 
3869
DomString::~DomString()
 
3870
{
 
3871
}
 
3872
 
 
3873
void DomString::read(const QDomElement &node)
 
3874
{
 
3875
    if (node.hasAttribute(QLatin1String("notr")))
 
3876
        setAttributeNotr(node.attribute(QLatin1String("notr")));
 
3877
 
 
3878
    for (QDomNode n = node.firstChild(); !n.isNull(); n = n.nextSibling()) {
 
3879
        if (!n.isElement())
 
3880
            continue;
 
3881
        QDomElement e = n.toElement();
 
3882
        QString tag = e.tagName().toLower();
 
3883
    }
 
3884
 
 
3885
    m_text.clear();
 
3886
    for (QDomNode child = node.firstChild(); !child.isNull(); child = child.nextSibling()) {
 
3887
        if (child.isText())
 
3888
            m_text.append(child.nodeValue());
 
3889
    }
 
3890
}
 
3891
 
 
3892
QDomElement DomString::write(QDomDocument &doc, const QString &tagName)
 
3893
{
 
3894
    QDomElement e = doc.createElement(tagName.isEmpty() ? QString::fromLatin1("string") : tagName.toLower());
 
3895
 
 
3896
    QDomElement child;
 
3897
 
 
3898
    if (hasAttributeNotr())
 
3899
        e.setAttribute(QLatin1String("notr"), attributeNotr());
 
3900
 
 
3901
    if (!m_text.isEmpty())
 
3902
        e.appendChild(doc.createTextNode(m_text));
 
3903
 
 
3904
    return e;
 
3905
}
 
3906
 
 
3907
void DomProperty::clear(bool clear_all)
 
3908
{
 
3909
    delete m_color;
 
3910
    delete m_font;
 
3911
    delete m_iconSet;
 
3912
    delete m_pixmap;
 
3913
    delete m_palette;
 
3914
    delete m_point;
 
3915
    delete m_rect;
 
3916
    delete m_sizePolicy;
 
3917
    delete m_size;
 
3918
    delete m_string;
 
3919
    delete m_stringList;
 
3920
    delete m_date;
 
3921
    delete m_time;
 
3922
    delete m_dateTime;
 
3923
 
 
3924
    if (clear_all) {
 
3925
    m_text = QString();
 
3926
    m_has_attr_name = false;
 
3927
    m_has_attr_stdset = false;
 
3928
    m_attr_stdset = 0;
 
3929
    }
 
3930
 
 
3931
    m_kind = Unknown;
 
3932
 
 
3933
    m_color = 0;
 
3934
    m_cursor = 0;
 
3935
    m_font = 0;
 
3936
    m_iconSet = 0;
 
3937
    m_pixmap = 0;
 
3938
    m_palette = 0;
 
3939
    m_point = 0;
 
3940
    m_rect = 0;
 
3941
    m_sizePolicy = 0;
 
3942
    m_size = 0;
 
3943
    m_string = 0;
 
3944
    m_stringList = 0;
 
3945
    m_number = 0;
 
3946
    m_float = 0.0;
 
3947
    m_double = 0;
 
3948
    m_date = 0;
 
3949
    m_time = 0;
 
3950
    m_dateTime = 0;
 
3951
}
 
3952
 
 
3953
DomProperty::DomProperty()
 
3954
{
 
3955
    m_kind = Unknown;
 
3956
 
 
3957
    m_has_attr_name = false;
 
3958
    m_has_attr_stdset = false;
 
3959
    m_attr_stdset = 0;
 
3960
    m_color = 0;
 
3961
    m_cursor = 0;
 
3962
    m_font = 0;
 
3963
    m_iconSet = 0;
 
3964
    m_pixmap = 0;
 
3965
    m_palette = 0;
 
3966
    m_point = 0;
 
3967
    m_rect = 0;
 
3968
    m_sizePolicy = 0;
 
3969
    m_size = 0;
 
3970
    m_string = 0;
 
3971
    m_stringList = 0;
 
3972
    m_number = 0;
 
3973
    m_float = 0.0;
 
3974
    m_double = 0;
 
3975
    m_date = 0;
 
3976
    m_time = 0;
 
3977
    m_dateTime = 0;
 
3978
}
 
3979
 
 
3980
DomProperty::~DomProperty()
 
3981
{
 
3982
    delete m_color;
 
3983
    delete m_font;
 
3984
    delete m_iconSet;
 
3985
    delete m_pixmap;
 
3986
    delete m_palette;
 
3987
    delete m_point;
 
3988
    delete m_rect;
 
3989
    delete m_sizePolicy;
 
3990
    delete m_size;
 
3991
    delete m_string;
 
3992
    delete m_stringList;
 
3993
    delete m_date;
 
3994
    delete m_time;
 
3995
    delete m_dateTime;
 
3996
}
 
3997
 
 
3998
void DomProperty::read(const QDomElement &node)
 
3999
{
 
4000
    if (node.hasAttribute(QLatin1String("name")))
 
4001
        setAttributeName(node.attribute(QLatin1String("name")));
 
4002
    if (node.hasAttribute(QLatin1String("stdset")))
 
4003
        setAttributeStdset(node.attribute(QLatin1String("stdset")).toInt());
 
4004
 
 
4005
    for (QDomNode n = node.firstChild(); !n.isNull(); n = n.nextSibling()) {
 
4006
        if (!n.isElement())
 
4007
            continue;
 
4008
        QDomElement e = n.toElement();
 
4009
        QString tag = e.tagName().toLower();
 
4010
        if (tag == QLatin1String("bool")) {
 
4011
            setElementBool(e.text());
 
4012
            continue;
 
4013
        }
 
4014
        if (tag == QLatin1String("color")) {
 
4015
            DomColor *v = new DomColor();
 
4016
            v->read(e);
 
4017
            setElementColor(v);
 
4018
            continue;
 
4019
        }
 
4020
        if (tag == QLatin1String("cstring")) {
 
4021
            setElementCstring(e.text());
 
4022
            continue;
 
4023
        }
 
4024
        if (tag == QLatin1String("cursor")) {
 
4025
            setElementCursor(e.text().toInt());
 
4026
            continue;
 
4027
        }
 
4028
        if (tag == QLatin1String("enum")) {
 
4029
            setElementEnum(e.text());
 
4030
            continue;
 
4031
        }
 
4032
        if (tag == QLatin1String("font")) {
 
4033
            DomFont *v = new DomFont();
 
4034
            v->read(e);
 
4035
            setElementFont(v);
 
4036
            continue;
 
4037
        }
 
4038
        if (tag == QLatin1String("iconset")) {
 
4039
            DomResourcePixmap *v = new DomResourcePixmap();
 
4040
            v->read(e);
 
4041
            setElementIconSet(v);
 
4042
            continue;
 
4043
        }
 
4044
        if (tag == QLatin1String("pixmap")) {
 
4045
            DomResourcePixmap *v = new DomResourcePixmap();
 
4046
            v->read(e);
 
4047
            setElementPixmap(v);
 
4048
            continue;
 
4049
        }
 
4050
        if (tag == QLatin1String("palette")) {
 
4051
            DomPalette *v = new DomPalette();
 
4052
            v->read(e);
 
4053
            setElementPalette(v);
 
4054
            continue;
 
4055
        }
 
4056
        if (tag == QLatin1String("point")) {
 
4057
            DomPoint *v = new DomPoint();
 
4058
            v->read(e);
 
4059
            setElementPoint(v);
 
4060
            continue;
 
4061
        }
 
4062
        if (tag == QLatin1String("rect")) {
 
4063
            DomRect *v = new DomRect();
 
4064
            v->read(e);
 
4065
            setElementRect(v);
 
4066
            continue;
 
4067
        }
 
4068
        if (tag == QLatin1String("set")) {
 
4069
            setElementSet(e.text());
 
4070
            continue;
 
4071
        }
 
4072
        if (tag == QLatin1String("sizepolicy")) {
 
4073
            DomSizePolicy *v = new DomSizePolicy();
 
4074
            v->read(e);
 
4075
            setElementSizePolicy(v);
 
4076
            continue;
 
4077
        }
 
4078
        if (tag == QLatin1String("size")) {
 
4079
            DomSize *v = new DomSize();
 
4080
            v->read(e);
 
4081
            setElementSize(v);
 
4082
            continue;
 
4083
        }
 
4084
        if (tag == QLatin1String("string")) {
 
4085
            DomString *v = new DomString();
 
4086
            v->read(e);
 
4087
            setElementString(v);
 
4088
            continue;
 
4089
        }
 
4090
        if (tag == QLatin1String("stringlist")) {
 
4091
            DomStringList *v = new DomStringList();
 
4092
            v->read(e);
 
4093
            setElementStringList(v);
 
4094
            continue;
 
4095
        }
 
4096
        if (tag == QLatin1String("number")) {
 
4097
            setElementNumber(e.text().toInt());
 
4098
            continue;
 
4099
        }
 
4100
        if (tag == QLatin1String("float")) {
 
4101
            setElementFloat(e.text().toFloat());
 
4102
            continue;
 
4103
        }
 
4104
        if (tag == QLatin1String("double")) {
 
4105
            setElementDouble(e.text().toDouble());
 
4106
            continue;
 
4107
        }
 
4108
        if (tag == QLatin1String("date")) {
 
4109
            DomDate *v = new DomDate();
 
4110
            v->read(e);
 
4111
            setElementDate(v);
 
4112
            continue;
 
4113
        }
 
4114
        if (tag == QLatin1String("time")) {
 
4115
            DomTime *v = new DomTime();
 
4116
            v->read(e);
 
4117
            setElementTime(v);
 
4118
            continue;
 
4119
        }
 
4120
        if (tag == QLatin1String("datetime")) {
 
4121
            DomDateTime *v = new DomDateTime();
 
4122
            v->read(e);
 
4123
            setElementDateTime(v);
 
4124
            continue;
 
4125
        }
 
4126
    }
 
4127
 
 
4128
    m_text.clear();
 
4129
    for (QDomNode child = node.firstChild(); !child.isNull(); child = child.nextSibling()) {
 
4130
        if (child.isText())
 
4131
            m_text.append(child.nodeValue());
 
4132
    }
 
4133
}
 
4134
 
 
4135
QDomElement DomProperty::write(QDomDocument &doc, const QString &tagName)
 
4136
{
 
4137
    QDomElement e = doc.createElement(tagName.isEmpty() ? QString::fromLatin1("property") : tagName.toLower());
 
4138
 
 
4139
    QDomElement child;
 
4140
 
 
4141
    if (hasAttributeName())
 
4142
        e.setAttribute(QLatin1String("name"), attributeName());
 
4143
 
 
4144
    if (hasAttributeStdset())
 
4145
        e.setAttribute(QLatin1String("stdset"), attributeStdset());
 
4146
 
 
4147
    switch(kind()) {
 
4148
        case Bool: {
 
4149
            QDomElement child = doc.createElement("bool");
 
4150
            QDomText text = doc.createTextNode(elementBool());
 
4151
            child.appendChild(text);
 
4152
            e.appendChild(child);
 
4153
            break;
 
4154
        }
 
4155
        case Color: {
 
4156
            DomColor* v = elementColor();
 
4157
            if (v != 0) {
 
4158
                QDomElement child = v->write(doc, QLatin1String("color"));
 
4159
                e.appendChild(child);
 
4160
            }
 
4161
            break;
 
4162
        }
 
4163
        case Cstring: {
 
4164
            QDomElement child = doc.createElement("cstring");
 
4165
            QDomText text = doc.createTextNode(elementCstring());
 
4166
            child.appendChild(text);
 
4167
            e.appendChild(child);
 
4168
            break;
 
4169
        }
 
4170
        case Cursor: {
 
4171
            QDomElement child = doc.createElement("cursor");
 
4172
            QDomText text = doc.createTextNode(QString::number(elementCursor()));
 
4173
            child.appendChild(text);
 
4174
            e.appendChild(child);
 
4175
            break;
 
4176
        }
 
4177
        case Enum: {
 
4178
            QDomElement child = doc.createElement("enum");
 
4179
            QDomText text = doc.createTextNode(elementEnum());
 
4180
            child.appendChild(text);
 
4181
            e.appendChild(child);
 
4182
            break;
 
4183
        }
 
4184
        case Font: {
 
4185
            DomFont* v = elementFont();
 
4186
            if (v != 0) {
 
4187
                QDomElement child = v->write(doc, QLatin1String("font"));
 
4188
                e.appendChild(child);
 
4189
            }
 
4190
            break;
 
4191
        }
 
4192
        case IconSet: {
 
4193
            DomResourcePixmap* v = elementIconSet();
 
4194
            if (v != 0) {
 
4195
                QDomElement child = v->write(doc, QLatin1String("iconset"));
 
4196
                e.appendChild(child);
 
4197
            }
 
4198
            break;
 
4199
        }
 
4200
        case Pixmap: {
 
4201
            DomResourcePixmap* v = elementPixmap();
 
4202
            if (v != 0) {
 
4203
                QDomElement child = v->write(doc, QLatin1String("pixmap"));
 
4204
                e.appendChild(child);
 
4205
            }
 
4206
            break;
 
4207
        }
 
4208
        case Palette: {
 
4209
            DomPalette* v = elementPalette();
 
4210
            if (v != 0) {
 
4211
                QDomElement child = v->write(doc, QLatin1String("palette"));
 
4212
                e.appendChild(child);
 
4213
            }
 
4214
            break;
 
4215
        }
 
4216
        case Point: {
 
4217
            DomPoint* v = elementPoint();
 
4218
            if (v != 0) {
 
4219
                QDomElement child = v->write(doc, QLatin1String("point"));
 
4220
                e.appendChild(child);
 
4221
            }
 
4222
            break;
 
4223
        }
 
4224
        case Rect: {
 
4225
            DomRect* v = elementRect();
 
4226
            if (v != 0) {
 
4227
                QDomElement child = v->write(doc, QLatin1String("rect"));
 
4228
                e.appendChild(child);
 
4229
            }
 
4230
            break;
 
4231
        }
 
4232
        case Set: {
 
4233
            QDomElement child = doc.createElement("set");
 
4234
            QDomText text = doc.createTextNode(elementSet());
 
4235
            child.appendChild(text);
 
4236
            e.appendChild(child);
 
4237
            break;
 
4238
        }
 
4239
        case SizePolicy: {
 
4240
            DomSizePolicy* v = elementSizePolicy();
 
4241
            if (v != 0) {
 
4242
                QDomElement child = v->write(doc, QLatin1String("sizepolicy"));
 
4243
                e.appendChild(child);
 
4244
            }
 
4245
            break;
 
4246
        }
 
4247
        case Size: {
 
4248
            DomSize* v = elementSize();
 
4249
            if (v != 0) {
 
4250
                QDomElement child = v->write(doc, QLatin1String("size"));
 
4251
                e.appendChild(child);
 
4252
            }
 
4253
            break;
 
4254
        }
 
4255
        case String: {
 
4256
            DomString* v = elementString();
 
4257
            if (v != 0) {
 
4258
                QDomElement child = v->write(doc, QLatin1String("string"));
 
4259
                e.appendChild(child);
 
4260
            }
 
4261
            break;
 
4262
        }
 
4263
        case StringList: {
 
4264
            DomStringList* v = elementStringList();
 
4265
            if (v != 0) {
 
4266
                QDomElement child = v->write(doc, QLatin1String("stringlist"));
 
4267
                e.appendChild(child);
 
4268
            }
 
4269
            break;
 
4270
        }
 
4271
        case Number: {
 
4272
            QDomElement child = doc.createElement("number");
 
4273
            QDomText text = doc.createTextNode(QString::number(elementNumber()));
 
4274
            child.appendChild(text);
 
4275
            e.appendChild(child);
 
4276
            break;
 
4277
        }
 
4278
        case Float: {
 
4279
            QDomElement child = doc.createElement("float");
 
4280
            QDomText text = doc.createTextNode(QString::number(elementFloat()));
 
4281
            child.appendChild(text);
 
4282
            e.appendChild(child);
 
4283
            break;
 
4284
        }
 
4285
        case Double: {
 
4286
            QDomElement child = doc.createElement("double");
 
4287
            QDomText text = doc.createTextNode(QString::number(elementDouble()));
 
4288
            child.appendChild(text);
 
4289
            e.appendChild(child);
 
4290
            break;
 
4291
        }
 
4292
        case Date: {
 
4293
            DomDate* v = elementDate();
 
4294
            if (v != 0) {
 
4295
                QDomElement child = v->write(doc, QLatin1String("date"));
 
4296
                e.appendChild(child);
 
4297
            }
 
4298
            break;
 
4299
        }
 
4300
        case Time: {
 
4301
            DomTime* v = elementTime();
 
4302
            if (v != 0) {
 
4303
                QDomElement child = v->write(doc, QLatin1String("time"));
 
4304
                e.appendChild(child);
 
4305
            }
 
4306
            break;
 
4307
        }
 
4308
        case DateTime: {
 
4309
            DomDateTime* v = elementDateTime();
 
4310
            if (v != 0) {
 
4311
                QDomElement child = v->write(doc, QLatin1String("datetime"));
 
4312
                e.appendChild(child);
 
4313
            }
 
4314
            break;
 
4315
        }
 
4316
        default:
 
4317
            break;
 
4318
    }
 
4319
    if (!m_text.isEmpty())
 
4320
        e.appendChild(doc.createTextNode(m_text));
 
4321
 
 
4322
    return e;
 
4323
}
 
4324
 
 
4325
void DomProperty::setElementBool(const QString& a)
 
4326
{
 
4327
    clear(false);
 
4328
    m_kind = Bool;
 
4329
    m_bool = a;
 
4330
}
 
4331
 
 
4332
void DomProperty::setElementColor(DomColor* a)
 
4333
{
 
4334
    clear(false);
 
4335
    m_kind = Color;
 
4336
    m_color = a;
 
4337
}
 
4338
 
 
4339
void DomProperty::setElementCstring(const QString& a)
 
4340
{
 
4341
    clear(false);
 
4342
    m_kind = Cstring;
 
4343
    m_cstring = a;
 
4344
}
 
4345
 
 
4346
void DomProperty::setElementCursor(int a)
 
4347
{
 
4348
    clear(false);
 
4349
    m_kind = Cursor;
 
4350
    m_cursor = a;
 
4351
}
 
4352
 
 
4353
void DomProperty::setElementEnum(const QString& a)
 
4354
{
 
4355
    clear(false);
 
4356
    m_kind = Enum;
 
4357
    m_enum = a;
 
4358
}
 
4359
 
 
4360
void DomProperty::setElementFont(DomFont* a)
 
4361
{
 
4362
    clear(false);
 
4363
    m_kind = Font;
 
4364
    m_font = a;
 
4365
}
 
4366
 
 
4367
void DomProperty::setElementIconSet(DomResourcePixmap* a)
 
4368
{
 
4369
    clear(false);
 
4370
    m_kind = IconSet;
 
4371
    m_iconSet = a;
 
4372
}
 
4373
 
 
4374
void DomProperty::setElementPixmap(DomResourcePixmap* a)
 
4375
{
 
4376
    clear(false);
 
4377
    m_kind = Pixmap;
 
4378
    m_pixmap = a;
 
4379
}
 
4380
 
 
4381
void DomProperty::setElementPalette(DomPalette* a)
 
4382
{
 
4383
    clear(false);
 
4384
    m_kind = Palette;
 
4385
    m_palette = a;
 
4386
}
 
4387
 
 
4388
void DomProperty::setElementPoint(DomPoint* a)
 
4389
{
 
4390
    clear(false);
 
4391
    m_kind = Point;
 
4392
    m_point = a;
 
4393
}
 
4394
 
 
4395
void DomProperty::setElementRect(DomRect* a)
 
4396
{
 
4397
    clear(false);
 
4398
    m_kind = Rect;
 
4399
    m_rect = a;
 
4400
}
 
4401
 
 
4402
void DomProperty::setElementSet(const QString& a)
 
4403
{
 
4404
    clear(false);
 
4405
    m_kind = Set;
 
4406
    m_set = a;
 
4407
}
 
4408
 
 
4409
void DomProperty::setElementSizePolicy(DomSizePolicy* a)
 
4410
{
 
4411
    clear(false);
 
4412
    m_kind = SizePolicy;
 
4413
    m_sizePolicy = a;
 
4414
}
 
4415
 
 
4416
void DomProperty::setElementSize(DomSize* a)
 
4417
{
 
4418
    clear(false);
 
4419
    m_kind = Size;
 
4420
    m_size = a;
 
4421
}
 
4422
 
 
4423
void DomProperty::setElementString(DomString* a)
 
4424
{
 
4425
    clear(false);
 
4426
    m_kind = String;
 
4427
    m_string = a;
 
4428
}
 
4429
 
 
4430
void DomProperty::setElementStringList(DomStringList* a)
 
4431
{
 
4432
    clear(false);
 
4433
    m_kind = StringList;
 
4434
    m_stringList = a;
 
4435
}
 
4436
 
 
4437
void DomProperty::setElementNumber(int a)
 
4438
{
 
4439
    clear(false);
 
4440
    m_kind = Number;
 
4441
    m_number = a;
 
4442
}
 
4443
 
 
4444
void DomProperty::setElementFloat(float a)
 
4445
{
 
4446
    clear(false);
 
4447
    m_kind = Float;
 
4448
    m_float = a;
 
4449
}
 
4450
 
 
4451
void DomProperty::setElementDouble(double a)
 
4452
{
 
4453
    clear(false);
 
4454
    m_kind = Double;
 
4455
    m_double = a;
 
4456
}
 
4457
 
 
4458
void DomProperty::setElementDate(DomDate* a)
 
4459
{
 
4460
    clear(false);
 
4461
    m_kind = Date;
 
4462
    m_date = a;
 
4463
}
 
4464
 
 
4465
void DomProperty::setElementTime(DomTime* a)
 
4466
{
 
4467
    clear(false);
 
4468
    m_kind = Time;
 
4469
    m_time = a;
 
4470
}
 
4471
 
 
4472
void DomProperty::setElementDateTime(DomDateTime* a)
 
4473
{
 
4474
    clear(false);
 
4475
    m_kind = DateTime;
 
4476
    m_dateTime = a;
 
4477
}
 
4478
 
 
4479
void DomConnections::clear(bool clear_all)
 
4480
{
 
4481
    for (int i = 0; i < m_connection.size(); ++i)
 
4482
        delete m_connection[i];
 
4483
    m_connection.clear();
 
4484
 
 
4485
    if (clear_all) {
 
4486
    m_text = QString();
 
4487
    }
 
4488
 
 
4489
}
 
4490
 
 
4491
DomConnections::DomConnections()
 
4492
{
 
4493
}
 
4494
 
 
4495
DomConnections::~DomConnections()
 
4496
{
 
4497
    for (int i = 0; i < m_connection.size(); ++i)
 
4498
        delete m_connection[i];
 
4499
    m_connection.clear();
 
4500
}
 
4501
 
 
4502
void DomConnections::read(const QDomElement &node)
 
4503
{
 
4504
 
 
4505
    for (QDomNode n = node.firstChild(); !n.isNull(); n = n.nextSibling()) {
 
4506
        if (!n.isElement())
 
4507
            continue;
 
4508
        QDomElement e = n.toElement();
 
4509
        QString tag = e.tagName().toLower();
 
4510
        if (tag == QLatin1String("connection")) {
 
4511
            DomConnection *v = new DomConnection();
 
4512
            v->read(e);
 
4513
            m_connection.append(v);
 
4514
            continue;
 
4515
        }
 
4516
    }
 
4517
 
 
4518
    m_text.clear();
 
4519
    for (QDomNode child = node.firstChild(); !child.isNull(); child = child.nextSibling()) {
 
4520
        if (child.isText())
 
4521
            m_text.append(child.nodeValue());
 
4522
    }
 
4523
}
 
4524
 
 
4525
QDomElement DomConnections::write(QDomDocument &doc, const QString &tagName)
 
4526
{
 
4527
    QDomElement e = doc.createElement(tagName.isEmpty() ? QString::fromLatin1("connections") : tagName.toLower());
 
4528
 
 
4529
    QDomElement child;
 
4530
 
 
4531
    for (int i = 0; i < m_connection.size(); ++i) {
 
4532
        DomConnection* v = m_connection[i];
 
4533
        QDomNode child = v->write(doc, QLatin1String("connection"));
 
4534
        e.appendChild(child);
 
4535
    }
 
4536
    if (!m_text.isEmpty())
 
4537
        e.appendChild(doc.createTextNode(m_text));
 
4538
 
 
4539
    return e;
 
4540
}
 
4541
 
 
4542
void DomConnections::setElementConnection(const QList<DomConnection*>& a)
 
4543
{
 
4544
    m_connection = a;
 
4545
}
 
4546
 
 
4547
void DomConnection::clear(bool clear_all)
 
4548
{
 
4549
    delete m_hints;
 
4550
 
 
4551
    if (clear_all) {
 
4552
    m_text = QString();
 
4553
    }
 
4554
 
 
4555
    m_hints = 0;
 
4556
}
 
4557
 
 
4558
DomConnection::DomConnection()
 
4559
{
 
4560
    m_hints = 0;
 
4561
}
 
4562
 
 
4563
DomConnection::~DomConnection()
 
4564
{
 
4565
    delete m_hints;
 
4566
}
 
4567
 
 
4568
void DomConnection::read(const QDomElement &node)
 
4569
{
 
4570
 
 
4571
    for (QDomNode n = node.firstChild(); !n.isNull(); n = n.nextSibling()) {
 
4572
        if (!n.isElement())
 
4573
            continue;
 
4574
        QDomElement e = n.toElement();
 
4575
        QString tag = e.tagName().toLower();
 
4576
        if (tag == QLatin1String("sender")) {
 
4577
            setElementSender(e.text());
 
4578
            continue;
 
4579
        }
 
4580
        if (tag == QLatin1String("signal")) {
 
4581
            setElementSignal(e.text());
 
4582
            continue;
 
4583
        }
 
4584
        if (tag == QLatin1String("receiver")) {
 
4585
            setElementReceiver(e.text());
 
4586
            continue;
 
4587
        }
 
4588
        if (tag == QLatin1String("slot")) {
 
4589
            setElementSlot(e.text());
 
4590
            continue;
 
4591
        }
 
4592
        if (tag == QLatin1String("hints")) {
 
4593
            DomConnectionHints *v = new DomConnectionHints();
 
4594
            v->read(e);
 
4595
            setElementHints(v);
 
4596
            continue;
 
4597
        }
 
4598
    }
 
4599
 
 
4600
    m_text.clear();
 
4601
    for (QDomNode child = node.firstChild(); !child.isNull(); child = child.nextSibling()) {
 
4602
        if (child.isText())
 
4603
            m_text.append(child.nodeValue());
 
4604
    }
 
4605
}
 
4606
 
 
4607
QDomElement DomConnection::write(QDomDocument &doc, const QString &tagName)
 
4608
{
 
4609
    QDomElement e = doc.createElement(tagName.isEmpty() ? QString::fromLatin1("connection") : tagName.toLower());
 
4610
 
 
4611
    QDomElement child;
 
4612
 
 
4613
    child = doc.createElement(QLatin1String("sender"));
 
4614
    child.appendChild(doc.createTextNode(m_sender));
 
4615
    e.appendChild(child);
 
4616
 
 
4617
    child = doc.createElement(QLatin1String("signal"));
 
4618
    child.appendChild(doc.createTextNode(m_signal));
 
4619
    e.appendChild(child);
 
4620
 
 
4621
    child = doc.createElement(QLatin1String("receiver"));
 
4622
    child.appendChild(doc.createTextNode(m_receiver));
 
4623
    e.appendChild(child);
 
4624
 
 
4625
    child = doc.createElement(QLatin1String("slot"));
 
4626
    child.appendChild(doc.createTextNode(m_slot));
 
4627
    e.appendChild(child);
 
4628
 
 
4629
    if (m_hints != 0)
 
4630
        e.appendChild(m_hints->write(doc, QLatin1String("hints")));
 
4631
 
 
4632
    if (!m_text.isEmpty())
 
4633
        e.appendChild(doc.createTextNode(m_text));
 
4634
 
 
4635
    return e;
 
4636
}
 
4637
 
 
4638
void DomConnection::setElementSender(const QString& a)
 
4639
{
 
4640
    m_sender = a;
 
4641
}
 
4642
 
 
4643
void DomConnection::setElementSignal(const QString& a)
 
4644
{
 
4645
    m_signal = a;
 
4646
}
 
4647
 
 
4648
void DomConnection::setElementReceiver(const QString& a)
 
4649
{
 
4650
    m_receiver = a;
 
4651
}
 
4652
 
 
4653
void DomConnection::setElementSlot(const QString& a)
 
4654
{
 
4655
    m_slot = a;
 
4656
}
 
4657
 
 
4658
void DomConnection::setElementHints(DomConnectionHints* a)
 
4659
{
 
4660
    delete m_hints;
 
4661
    m_hints = a;
 
4662
}
 
4663
 
 
4664
void DomConnectionHints::clear(bool clear_all)
 
4665
{
 
4666
    for (int i = 0; i < m_hint.size(); ++i)
 
4667
        delete m_hint[i];
 
4668
    m_hint.clear();
 
4669
 
 
4670
    if (clear_all) {
 
4671
    m_text = QString();
 
4672
    }
 
4673
 
 
4674
}
 
4675
 
 
4676
DomConnectionHints::DomConnectionHints()
 
4677
{
 
4678
}
 
4679
 
 
4680
DomConnectionHints::~DomConnectionHints()
 
4681
{
 
4682
    for (int i = 0; i < m_hint.size(); ++i)
 
4683
        delete m_hint[i];
 
4684
    m_hint.clear();
 
4685
}
 
4686
 
 
4687
void DomConnectionHints::read(const QDomElement &node)
 
4688
{
 
4689
 
 
4690
    for (QDomNode n = node.firstChild(); !n.isNull(); n = n.nextSibling()) {
 
4691
        if (!n.isElement())
 
4692
            continue;
 
4693
        QDomElement e = n.toElement();
 
4694
        QString tag = e.tagName().toLower();
 
4695
        if (tag == QLatin1String("hint")) {
 
4696
            DomConnectionHint *v = new DomConnectionHint();
 
4697
            v->read(e);
 
4698
            m_hint.append(v);
 
4699
            continue;
 
4700
        }
 
4701
    }
 
4702
 
 
4703
    m_text.clear();
 
4704
    for (QDomNode child = node.firstChild(); !child.isNull(); child = child.nextSibling()) {
 
4705
        if (child.isText())
 
4706
            m_text.append(child.nodeValue());
 
4707
    }
 
4708
}
 
4709
 
 
4710
QDomElement DomConnectionHints::write(QDomDocument &doc, const QString &tagName)
 
4711
{
 
4712
    QDomElement e = doc.createElement(tagName.isEmpty() ? QString::fromLatin1("connectionhints") : tagName.toLower());
 
4713
 
 
4714
    QDomElement child;
 
4715
 
 
4716
    for (int i = 0; i < m_hint.size(); ++i) {
 
4717
        DomConnectionHint* v = m_hint[i];
 
4718
        QDomNode child = v->write(doc, QLatin1String("hint"));
 
4719
        e.appendChild(child);
 
4720
    }
 
4721
    if (!m_text.isEmpty())
 
4722
        e.appendChild(doc.createTextNode(m_text));
 
4723
 
 
4724
    return e;
 
4725
}
 
4726
 
 
4727
void DomConnectionHints::setElementHint(const QList<DomConnectionHint*>& a)
 
4728
{
 
4729
    m_hint = a;
 
4730
}
 
4731
 
 
4732
void DomConnectionHint::clear(bool clear_all)
 
4733
{
 
4734
 
 
4735
    if (clear_all) {
 
4736
    m_text = QString();
 
4737
    m_has_attr_type = false;
 
4738
    }
 
4739
 
 
4740
    m_x = 0;
 
4741
    m_y = 0;
 
4742
}
 
4743
 
 
4744
DomConnectionHint::DomConnectionHint()
 
4745
{
 
4746
    m_has_attr_type = false;
 
4747
    m_x = 0;
 
4748
    m_y = 0;
 
4749
}
 
4750
 
 
4751
DomConnectionHint::~DomConnectionHint()
 
4752
{
 
4753
}
 
4754
 
 
4755
void DomConnectionHint::read(const QDomElement &node)
 
4756
{
 
4757
    if (node.hasAttribute(QLatin1String("type")))
 
4758
        setAttributeType(node.attribute(QLatin1String("type")));
 
4759
 
 
4760
    for (QDomNode n = node.firstChild(); !n.isNull(); n = n.nextSibling()) {
 
4761
        if (!n.isElement())
 
4762
            continue;
 
4763
        QDomElement e = n.toElement();
 
4764
        QString tag = e.tagName().toLower();
 
4765
        if (tag == QLatin1String("x")) {
 
4766
            setElementX(e.text().toInt());
 
4767
            continue;
 
4768
        }
 
4769
        if (tag == QLatin1String("y")) {
 
4770
            setElementY(e.text().toInt());
 
4771
            continue;
 
4772
        }
 
4773
    }
 
4774
 
 
4775
    m_text.clear();
 
4776
    for (QDomNode child = node.firstChild(); !child.isNull(); child = child.nextSibling()) {
 
4777
        if (child.isText())
 
4778
            m_text.append(child.nodeValue());
 
4779
    }
 
4780
}
 
4781
 
 
4782
QDomElement DomConnectionHint::write(QDomDocument &doc, const QString &tagName)
 
4783
{
 
4784
    QDomElement e = doc.createElement(tagName.isEmpty() ? QString::fromLatin1("connectionhint") : tagName.toLower());
 
4785
 
 
4786
    QDomElement child;
 
4787
 
 
4788
    if (hasAttributeType())
 
4789
        e.setAttribute(QLatin1String("type"), attributeType());
 
4790
 
 
4791
    child = doc.createElement(QLatin1String("x"));
 
4792
    child.appendChild(doc.createTextNode(QString::number(m_x)));
 
4793
    e.appendChild(child);
 
4794
 
 
4795
    child = doc.createElement(QLatin1String("y"));
 
4796
    child.appendChild(doc.createTextNode(QString::number(m_y)));
 
4797
    e.appendChild(child);
 
4798
 
 
4799
    if (!m_text.isEmpty())
 
4800
        e.appendChild(doc.createTextNode(m_text));
 
4801
 
 
4802
    return e;
 
4803
}
 
4804
 
 
4805
void DomConnectionHint::setElementX(int a)
 
4806
{
 
4807
    m_x = a;
 
4808
}
 
4809
 
 
4810
void DomConnectionHint::setElementY(int a)
 
4811
{
 
4812
    m_y = a;
 
4813
}
 
4814
 
 
4815