~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): Alessandro Ghersi
  • Date: 2009-11-02 18:30:08 UTC
  • mfrom: (1.2.2 upstream)
  • mto: (15.2.5 experimental)
  • mto: This revision was merged to the branch mainline in revision 88.
  • Revision ID: james.westby@ubuntu.com-20091102183008-b6a4gcs128mvfb3m
Tags: upstream-4.6.0~beta1
ImportĀ upstreamĀ versionĀ 4.6.0~beta1

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/****************************************************************************
2
2
**
3
3
** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
 
4
** All rights reserved.
4
5
** Contact: Nokia Corporation (qt-info@nokia.com)
5
6
**
6
7
** This file is part of the tools applications of the Qt Toolkit.
7
8
**
8
9
** $QT_BEGIN_LICENSE:LGPL$
9
 
** Commercial Usage
10
 
** Licensees holding valid Qt Commercial licenses may use this file in
11
 
** accordance with the Qt Commercial License Agreement provided with the
12
 
** Software or, alternatively, in accordance with the terms contained in
13
 
** a written agreement between you and Nokia.
 
10
** No Commercial Usage
 
11
** This file contains pre-release code and may not be distributed.
 
12
** You may use this file in accordance with the terms and conditions
 
13
** contained in the Technology Preview License Agreement accompanying
 
14
** this package.
14
15
**
15
16
** GNU Lesser General Public License Usage
16
17
** Alternatively, this file may be used under the terms of the GNU Lesser
20
21
** ensure the GNU Lesser General Public License version 2.1 requirements
21
22
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
22
23
**
23
 
** In addition, as a special exception, Nokia gives you certain
24
 
** additional rights. These rights are described in the Nokia Qt LGPL
25
 
** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
26
 
** package.
27
 
**
28
 
** GNU General Public License Usage
29
 
** Alternatively, this file may be used under the terms of the GNU
30
 
** General Public License version 3.0 as published by the Free Software
31
 
** Foundation and appearing in the file LICENSE.GPL included in the
32
 
** packaging of this file.  Please review the following information to
33
 
** ensure the GNU General Public License version 3.0 requirements will be
34
 
** met: http://www.gnu.org/copyleft/gpl.html.
35
 
**
36
 
** If you are unsure which license is appropriate for your use, please
37
 
** contact the sales department at http://www.qtsoftware.com/contact.
 
24
** In addition, as a special exception, Nokia gives you certain additional
 
25
** rights.  These rights are described in the Nokia Qt LGPL Exception
 
26
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
 
27
**
 
28
** If you have questions regarding the use of this file, please contact
 
29
** Nokia at qt-info@nokia.com.
 
30
**
 
31
**
 
32
**
 
33
**
 
34
**
 
35
**
 
36
**
 
37
**
38
38
** $QT_END_LICENSE$
39
39
**
40
40
****************************************************************************/
2368
2368
    delete m_script;
2369
2369
    delete m_properties;
2370
2370
    delete m_slots;
 
2371
    delete m_propertyspecifications;
2371
2372
 
2372
2373
    if (clear_all) {
2373
2374
    m_text.clear();
2381
2382
    m_script = 0;
2382
2383
    m_properties = 0;
2383
2384
    m_slots = 0;
 
2385
    m_propertyspecifications = 0;
2384
2386
}
2385
2387
 
2386
2388
DomCustomWidget::DomCustomWidget()
2393
2395
    m_script = 0;
2394
2396
    m_properties = 0;
2395
2397
    m_slots = 0;
 
2398
    m_propertyspecifications = 0;
2396
2399
}
2397
2400
 
2398
2401
DomCustomWidget::~DomCustomWidget()
2403
2406
    delete m_script;
2404
2407
    delete m_properties;
2405
2408
    delete m_slots;
 
2409
    delete m_propertyspecifications;
2406
2410
}
2407
2411
 
2408
2412
void DomCustomWidget::read(QXmlStreamReader &reader)
2468
2472
                setElementSlots(v);
2469
2473
                continue;
2470
2474
            }
 
2475
            if (tag == QLatin1String("propertyspecifications")) {
 
2476
                DomPropertySpecifications *v = new DomPropertySpecifications();
 
2477
                v->read(reader);
 
2478
                setElementPropertyspecifications(v);
 
2479
                continue;
 
2480
            }
2471
2481
            reader.raiseError(QLatin1String("Unexpected element ") + tag);
2472
2482
        }
2473
2483
            break;
2548
2558
                setElementSlots(v);
2549
2559
                continue;
2550
2560
            }
 
2561
            if (tag == QLatin1String("propertyspecifications")) {
 
2562
                DomPropertySpecifications *v = new DomPropertySpecifications();
 
2563
                v->read(e);
 
2564
                setElementPropertyspecifications(v);
 
2565
                continue;
 
2566
            }
2551
2567
    }
2552
2568
    m_text.clear();
2553
2569
    for (QDomNode child = node.firstChild(); !child.isNull(); child = child.nextSibling()) {
2605
2621
        m_slots->write(writer, QLatin1String("slots"));
2606
2622
    }
2607
2623
 
 
2624
    if (m_children & Propertyspecifications) {
 
2625
        m_propertyspecifications->write(writer, QLatin1String("propertyspecifications"));
 
2626
    }
 
2627
 
2608
2628
    if (!m_text.isEmpty())
2609
2629
        writer.writeCharacters(m_text);
2610
2630
 
2731
2751
    m_slots = a;
2732
2752
}
2733
2753
 
 
2754
DomPropertySpecifications* DomCustomWidget::takeElementPropertyspecifications() 
 
2755
{
 
2756
    DomPropertySpecifications* a = m_propertyspecifications;
 
2757
    m_propertyspecifications = 0;
 
2758
    m_children ^= Propertyspecifications;
 
2759
    return a;
 
2760
}
 
2761
 
 
2762
void DomCustomWidget::setElementPropertyspecifications(DomPropertySpecifications* a)
 
2763
{
 
2764
    delete m_propertyspecifications;
 
2765
    m_children |= Propertyspecifications;
 
2766
    m_propertyspecifications = a;
 
2767
}
 
2768
 
2734
2769
void DomCustomWidget::clearElementClass()
2735
2770
{
2736
2771
    m_children &= ~Class;
2798
2833
    m_children &= ~Slots;
2799
2834
}
2800
2835
 
 
2836
void DomCustomWidget::clearElementPropertyspecifications()
 
2837
{
 
2838
    delete m_propertyspecifications;
 
2839
    m_propertyspecifications = 0;
 
2840
    m_children &= ~Propertyspecifications;
 
2841
}
 
2842
 
2801
2843
void DomProperties::clear(bool clear_all)
2802
2844
{
2803
2845
    qDeleteAll(m_property);
10883
10925
    m_slot = a;
10884
10926
}
10885
10927
 
 
10928
void DomPropertySpecifications::clear(bool clear_all)
 
10929
{
 
10930
    qDeleteAll(m_stringpropertyspecification);
 
10931
    m_stringpropertyspecification.clear();
 
10932
 
 
10933
    if (clear_all) {
 
10934
    m_text.clear();
 
10935
    }
 
10936
 
 
10937
    m_children = 0;
 
10938
}
 
10939
 
 
10940
DomPropertySpecifications::DomPropertySpecifications()
 
10941
{
 
10942
    m_children = 0;
 
10943
}
 
10944
 
 
10945
DomPropertySpecifications::~DomPropertySpecifications()
 
10946
{
 
10947
    qDeleteAll(m_stringpropertyspecification);
 
10948
    m_stringpropertyspecification.clear();
 
10949
}
 
10950
 
 
10951
void DomPropertySpecifications::read(QXmlStreamReader &reader)
 
10952
{
 
10953
 
 
10954
    for (bool finished = false; !finished && !reader.hasError();) {
 
10955
        switch (reader.readNext()) {
 
10956
        case QXmlStreamReader::StartElement : {
 
10957
            const QString tag = reader.name().toString().toLower();
 
10958
            if (tag == QLatin1String("stringpropertyspecification")) {
 
10959
                DomStringPropertySpecification *v = new DomStringPropertySpecification();
 
10960
                v->read(reader);
 
10961
                m_stringpropertyspecification.append(v);
 
10962
                continue;
 
10963
            }
 
10964
            reader.raiseError(QLatin1String("Unexpected element ") + tag);
 
10965
        }
 
10966
            break;
 
10967
        case QXmlStreamReader::EndElement :
 
10968
            finished = true;
 
10969
            break;
 
10970
        case QXmlStreamReader::Characters :
 
10971
            if (!reader.isWhitespace())
 
10972
                m_text.append(reader.text().toString());
 
10973
            break;
 
10974
        default :
 
10975
            break;
 
10976
        }
 
10977
    }
 
10978
}
 
10979
 
 
10980
#ifdef QUILOADER_QDOM_READ
 
10981
void DomPropertySpecifications::read(const QDomElement &node)
 
10982
{
 
10983
    for (QDomNode n = node.firstChild(); !n.isNull(); n = n.nextSibling()) {
 
10984
        if (!n.isElement())
 
10985
            continue;
 
10986
        QDomElement e = n.toElement();
 
10987
        QString tag = e.tagName().toLower();
 
10988
            if (tag == QLatin1String("stringpropertyspecification")) {
 
10989
                DomStringPropertySpecification *v = new DomStringPropertySpecification();
 
10990
                v->read(e);
 
10991
                m_stringpropertyspecification.append(v);
 
10992
                continue;
 
10993
            }
 
10994
    }
 
10995
    m_text.clear();
 
10996
    for (QDomNode child = node.firstChild(); !child.isNull(); child = child.nextSibling()) {
 
10997
        if (child.isText())
 
10998
            m_text.append(child.nodeValue());
 
10999
     }
 
11000
}
 
11001
#endif
 
11002
 
 
11003
void DomPropertySpecifications::write(QXmlStreamWriter &writer, const QString &tagName) const
 
11004
{
 
11005
    writer.writeStartElement(tagName.isEmpty() ? QString::fromUtf8("propertyspecifications") : tagName.toLower());
 
11006
 
 
11007
    for (int i = 0; i < m_stringpropertyspecification.size(); ++i) {
 
11008
        DomStringPropertySpecification* v = m_stringpropertyspecification[i];
 
11009
        v->write(writer, QLatin1String("stringpropertyspecification"));
 
11010
    }
 
11011
    if (!m_text.isEmpty())
 
11012
        writer.writeCharacters(m_text);
 
11013
 
 
11014
    writer.writeEndElement();
 
11015
}
 
11016
 
 
11017
void DomPropertySpecifications::setElementStringpropertyspecification(const QList<DomStringPropertySpecification*>& a)
 
11018
{
 
11019
    m_children |= Stringpropertyspecification;
 
11020
    m_stringpropertyspecification = a;
 
11021
}
 
11022
 
 
11023
void DomStringPropertySpecification::clear(bool clear_all)
 
11024
{
 
11025
 
 
11026
    if (clear_all) {
 
11027
    m_text.clear();
 
11028
    m_has_attr_name = false;
 
11029
    m_has_attr_type = false;
 
11030
    m_has_attr_notr = false;
 
11031
    }
 
11032
 
 
11033
    m_children = 0;
 
11034
}
 
11035
 
 
11036
DomStringPropertySpecification::DomStringPropertySpecification()
 
11037
{
 
11038
    m_children = 0;
 
11039
    m_has_attr_name = false;
 
11040
    m_has_attr_type = false;
 
11041
    m_has_attr_notr = false;
 
11042
}
 
11043
 
 
11044
DomStringPropertySpecification::~DomStringPropertySpecification()
 
11045
{
 
11046
}
 
11047
 
 
11048
void DomStringPropertySpecification::read(QXmlStreamReader &reader)
 
11049
{
 
11050
 
 
11051
    foreach (const QXmlStreamAttribute &attribute, reader.attributes()) {
 
11052
        QStringRef name = attribute.name();
 
11053
        if (name == QLatin1String("name")) {
 
11054
            setAttributeName(attribute.value().toString());
 
11055
            continue;
 
11056
        }
 
11057
        if (name == QLatin1String("type")) {
 
11058
            setAttributeType(attribute.value().toString());
 
11059
            continue;
 
11060
        }
 
11061
        if (name == QLatin1String("notr")) {
 
11062
            setAttributeNotr(attribute.value().toString());
 
11063
            continue;
 
11064
        }
 
11065
        reader.raiseError(QLatin1String("Unexpected attribute ") + name.toString());
 
11066
    }
 
11067
 
 
11068
    for (bool finished = false; !finished && !reader.hasError();) {
 
11069
        switch (reader.readNext()) {
 
11070
        case QXmlStreamReader::StartElement : {
 
11071
            const QString tag = reader.name().toString().toLower();
 
11072
            reader.raiseError(QLatin1String("Unexpected element ") + tag);
 
11073
        }
 
11074
            break;
 
11075
        case QXmlStreamReader::EndElement :
 
11076
            finished = true;
 
11077
            break;
 
11078
        case QXmlStreamReader::Characters :
 
11079
            if (!reader.isWhitespace())
 
11080
                m_text.append(reader.text().toString());
 
11081
            break;
 
11082
        default :
 
11083
            break;
 
11084
        }
 
11085
    }
 
11086
}
 
11087
 
 
11088
#ifdef QUILOADER_QDOM_READ
 
11089
void DomStringPropertySpecification::read(const QDomElement &node)
 
11090
{
 
11091
    if (node.hasAttribute(QLatin1String("name")))
 
11092
        setAttributeName(node.attribute(QLatin1String("name")));
 
11093
    if (node.hasAttribute(QLatin1String("type")))
 
11094
        setAttributeType(node.attribute(QLatin1String("type")));
 
11095
    if (node.hasAttribute(QLatin1String("notr")))
 
11096
        setAttributeNotr(node.attribute(QLatin1String("notr")));
 
11097
 
 
11098
    for (QDomNode n = node.firstChild(); !n.isNull(); n = n.nextSibling()) {
 
11099
        if (!n.isElement())
 
11100
            continue;
 
11101
        QDomElement e = n.toElement();
 
11102
        QString tag = e.tagName().toLower();
 
11103
    }
 
11104
    m_text.clear();
 
11105
    for (QDomNode child = node.firstChild(); !child.isNull(); child = child.nextSibling()) {
 
11106
        if (child.isText())
 
11107
            m_text.append(child.nodeValue());
 
11108
     }
 
11109
}
 
11110
#endif
 
11111
 
 
11112
void DomStringPropertySpecification::write(QXmlStreamWriter &writer, const QString &tagName) const
 
11113
{
 
11114
    writer.writeStartElement(tagName.isEmpty() ? QString::fromUtf8("stringpropertyspecification") : tagName.toLower());
 
11115
 
 
11116
    if (hasAttributeName())
 
11117
        writer.writeAttribute(QLatin1String("name"), attributeName());
 
11118
 
 
11119
    if (hasAttributeType())
 
11120
        writer.writeAttribute(QLatin1String("type"), attributeType());
 
11121
 
 
11122
    if (hasAttributeNotr())
 
11123
        writer.writeAttribute(QLatin1String("notr"), attributeNotr());
 
11124
 
 
11125
    if (!m_text.isEmpty())
 
11126
        writer.writeCharacters(m_text);
 
11127
 
 
11128
    writer.writeEndElement();
 
11129
}
 
11130
 
10886
11131
QT_END_NAMESPACE
10887
11132