⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ui4.cpp

📁 qt-x11-opensource-src-4.1.4.tar.gz源码
💻 CPP
📖 第 1 页 / 共 5 页
字号:
/******************************************************************************** Copyright (C) 1992-2006 Trolltech ASA. All rights reserved.**** This file is part of the Qt Designer of the Qt Toolkit.**** This file may be used under the terms of the GNU General Public** License version 2.0 as published by the Free Software Foundation** and appearing in the file LICENSE.GPL included in the packaging of** this file.  Please review the following information to ensure GNU** General Public Licensing requirements will be met:** http://www.trolltech.com/products/qt/opensource.html**** If you are unsure which license is appropriate for your use, please** review the following information:** http://www.trolltech.com/products/qt/licensing.html or contact the** sales department at sales@trolltech.com.**** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.******************************************************************************/#include "ui4.h"#include <QDomDocument>#ifdef QFORMINTERNAL_NAMESPACEusing namespace QFormInternal;#endif/********************************************************************************* Implementations*/void DomUI::clear(bool clear_all){    delete m_widget;    delete m_layoutDefault;    delete m_layoutFunction;    delete m_customWidgets;    delete m_tabStops;    delete m_images;    delete m_includes;    delete m_resources;    delete m_connections;    if (clear_all) {    m_text = QString();    m_has_attr_version = false;    m_has_attr_stdSetDef = false;    m_attr_stdSetDef = 0;    }    m_widget = 0;    m_layoutDefault = 0;    m_layoutFunction = 0;    m_customWidgets = 0;    m_tabStops = 0;    m_images = 0;    m_includes = 0;    m_resources = 0;    m_connections = 0;}DomUI::DomUI(){    m_has_attr_version = false;    m_has_attr_stdSetDef = false;    m_attr_stdSetDef = 0;    m_widget = 0;    m_layoutDefault = 0;    m_layoutFunction = 0;    m_customWidgets = 0;    m_tabStops = 0;    m_images = 0;    m_includes = 0;    m_resources = 0;    m_connections = 0;}DomUI::~DomUI(){    delete m_widget;    delete m_layoutDefault;    delete m_layoutFunction;    delete m_customWidgets;    delete m_tabStops;    delete m_images;    delete m_includes;    delete m_resources;    delete m_connections;}void DomUI::read(const QDomElement &node){    if (node.hasAttribute(QLatin1String("version")))        setAttributeVersion(node.attribute(QLatin1String("version")));    if (node.hasAttribute(QLatin1String("stdsetdef")))        setAttributeStdSetDef(node.attribute(QLatin1String("stdsetdef")).toInt());    for (QDomNode n = node.firstChild(); !n.isNull(); n = n.nextSibling()) {        if (!n.isElement())            continue;        QDomElement e = n.toElement();        QString tag = e.tagName().toLower();        if (tag == QLatin1String("author")) {            setElementAuthor(e.text());            continue;        }        if (tag == QLatin1String("comment")) {            setElementComment(e.text());            continue;        }        if (tag == QLatin1String("exportmacro")) {            setElementExportMacro(e.text());            continue;        }        if (tag == QLatin1String("class")) {            setElementClass(e.text());            continue;        }        if (tag == QLatin1String("widget")) {            DomWidget *v = new DomWidget();            v->read(e);            setElementWidget(v);            continue;        }        if (tag == QLatin1String("layoutdefault")) {            DomLayoutDefault *v = new DomLayoutDefault();            v->read(e);            setElementLayoutDefault(v);            continue;        }        if (tag == QLatin1String("layoutfunction")) {            DomLayoutFunction *v = new DomLayoutFunction();            v->read(e);            setElementLayoutFunction(v);            continue;        }        if (tag == QLatin1String("pixmapfunction")) {            setElementPixmapFunction(e.text());            continue;        }        if (tag == QLatin1String("customwidgets")) {            DomCustomWidgets *v = new DomCustomWidgets();            v->read(e);            setElementCustomWidgets(v);            continue;        }        if (tag == QLatin1String("tabstops")) {            DomTabStops *v = new DomTabStops();            v->read(e);            setElementTabStops(v);            continue;        }        if (tag == QLatin1String("images")) {            DomImages *v = new DomImages();            v->read(e);            setElementImages(v);            continue;        }        if (tag == QLatin1String("includes")) {            DomIncludes *v = new DomIncludes();            v->read(e);            setElementIncludes(v);            continue;        }        if (tag == QLatin1String("resources")) {            DomResources *v = new DomResources();            v->read(e);            setElementResources(v);            continue;        }        if (tag == QLatin1String("connections")) {            DomConnections *v = new DomConnections();            v->read(e);            setElementConnections(v);            continue;        }    }    m_text.clear();    for (QDomNode child = node.firstChild(); !child.isNull(); child = child.nextSibling()) {        if (child.isText())            m_text.append(child.nodeValue());    }}QDomElement DomUI::write(QDomDocument &doc, const QString &tagName){    QDomElement e = doc.createElement(tagName.isEmpty() ? QString::fromUtf8("ui") : tagName.toLower());    QDomElement child;    if (hasAttributeVersion())        e.setAttribute(QLatin1String("version"), attributeVersion());    if (hasAttributeStdSetDef())        e.setAttribute(QLatin1String("stdsetdef"), attributeStdSetDef());    child = doc.createElement(QLatin1String("author"));    child.appendChild(doc.createTextNode(m_author));    e.appendChild(child);    child = doc.createElement(QLatin1String("comment"));    child.appendChild(doc.createTextNode(m_comment));    e.appendChild(child);    child = doc.createElement(QLatin1String("exportmacro"));    child.appendChild(doc.createTextNode(m_exportMacro));    e.appendChild(child);    child = doc.createElement(QLatin1String("class"));    child.appendChild(doc.createTextNode(m_class));    e.appendChild(child);    if (m_widget != 0)        e.appendChild(m_widget->write(doc, QLatin1String("widget")));    if (m_layoutDefault != 0)        e.appendChild(m_layoutDefault->write(doc, QLatin1String("layoutdefault")));    if (m_layoutFunction != 0)        e.appendChild(m_layoutFunction->write(doc, QLatin1String("layoutfunction")));    child = doc.createElement(QLatin1String("pixmapfunction"));    child.appendChild(doc.createTextNode(m_pixmapFunction));    e.appendChild(child);    if (m_customWidgets != 0)        e.appendChild(m_customWidgets->write(doc, QLatin1String("customwidgets")));    if (m_tabStops != 0)        e.appendChild(m_tabStops->write(doc, QLatin1String("tabstops")));    if (m_images != 0)        e.appendChild(m_images->write(doc, QLatin1String("images")));    if (m_includes != 0)        e.appendChild(m_includes->write(doc, QLatin1String("includes")));    if (m_resources != 0)        e.appendChild(m_resources->write(doc, QLatin1String("resources")));    if (m_connections != 0)        e.appendChild(m_connections->write(doc, QLatin1String("connections")));    if (!m_text.isEmpty())        e.appendChild(doc.createTextNode(m_text));    return e;}void DomUI::setElementAuthor(const QString& a){    m_author = a;}void DomUI::setElementComment(const QString& a){    m_comment = a;}void DomUI::setElementExportMacro(const QString& a){    m_exportMacro = a;}void DomUI::setElementClass(const QString& a){    m_class = a;}void DomUI::setElementWidget(DomWidget* a){    delete m_widget;    m_widget = a;}void DomUI::setElementLayoutDefault(DomLayoutDefault* a){    delete m_layoutDefault;    m_layoutDefault = a;}void DomUI::setElementLayoutFunction(DomLayoutFunction* a){    delete m_layoutFunction;    m_layoutFunction = a;}void DomUI::setElementPixmapFunction(const QString& a){    m_pixmapFunction = a;}void DomUI::setElementCustomWidgets(DomCustomWidgets* a){    delete m_customWidgets;    m_customWidgets = a;}void DomUI::setElementTabStops(DomTabStops* a){    delete m_tabStops;    m_tabStops = a;}void DomUI::setElementImages(DomImages* a){    delete m_images;    m_images = a;}void DomUI::setElementIncludes(DomIncludes* a){    delete m_includes;    m_includes = a;}void DomUI::setElementResources(DomResources* a){    delete m_resources;    m_resources = a;}void DomUI::setElementConnections(DomConnections* a){    delete m_connections;    m_connections = a;}void DomIncludes::clear(bool clear_all){    for (int i = 0; i < m_include.size(); ++i)        delete m_include[i];    m_include.clear();    if (clear_all) {    m_text = QString();    }}DomIncludes::DomIncludes(){}DomIncludes::~DomIncludes(){    for (int i = 0; i < m_include.size(); ++i)        delete m_include[i];    m_include.clear();}void DomIncludes::read(const QDomElement &node){    for (QDomNode n = node.firstChild(); !n.isNull(); n = n.nextSibling()) {        if (!n.isElement())            continue;        QDomElement e = n.toElement();        QString tag = e.tagName().toLower();        if (tag == QLatin1String("include")) {            DomInclude *v = new DomInclude();            v->read(e);            m_include.append(v);            continue;        }    }    m_text.clear();    for (QDomNode child = node.firstChild(); !child.isNull(); child = child.nextSibling()) {        if (child.isText())            m_text.append(child.nodeValue());    }}QDomElement DomIncludes::write(QDomDocument &doc, const QString &tagName){    QDomElement e = doc.createElement(tagName.isEmpty() ? QString::fromUtf8("includes") : tagName.toLower());    QDomElement child;    for (int i = 0; i < m_include.size(); ++i) {        DomInclude* v = m_include[i];        QDomNode child = v->write(doc, QLatin1String("include"));        e.appendChild(child);    }    if (!m_text.isEmpty())        e.appendChild(doc.createTextNode(m_text));    return e;}void DomIncludes::setElementInclude(const QList<DomInclude*>& a){    m_include = a;}void DomInclude::clear(bool clear_all){    if (clear_all) {    m_text = QString();    m_has_attr_location = false;    m_has_attr_impldecl = false;    }}DomInclude::DomInclude(){    m_has_attr_location = false;    m_has_attr_impldecl = false;}DomInclude::~DomInclude(){}void DomInclude::read(const QDomElement &node){    if (node.hasAttribute(QLatin1String("location")))        setAttributeLocation(node.attribute(QLatin1String("location")));    if (node.hasAttribute(QLatin1String("impldecl")))        setAttributeImpldecl(node.attribute(QLatin1String("impldecl")));    for (QDomNode n = node.firstChild(); !n.isNull(); n = n.nextSibling()) {        if (!n.isElement())            continue;        QDomElement e = n.toElement();        QString tag = e.tagName().toLower();    }    m_text.clear();    for (QDomNode child = node.firstChild(); !child.isNull(); child = child.nextSibling()) {        if (child.isText())            m_text.append(child.nodeValue());    }}QDomElement DomInclude::write(QDomDocument &doc, const QString &tagName){    QDomElement e = doc.createElement(tagName.isEmpty() ? QString::fromUtf8("include") : tagName.toLower());    QDomElement child;    if (hasAttributeLocation())        e.setAttribute(QLatin1String("location"), attributeLocation());    if (hasAttributeImpldecl())        e.setAttribute(QLatin1String("impldecl"), attributeImpldecl());    if (!m_text.isEmpty())        e.appendChild(doc.createTextNode(m_text));    return e;}void DomResources::clear(bool clear_all){    for (int i = 0; i < m_include.size(); ++i)        delete m_include[i];    m_include.clear();    if (clear_all) {    m_text = QString();    m_has_attr_name = false;    }}DomResources::DomResources(){    m_has_attr_name = false;}DomResources::~DomResources(){    for (int i = 0; i < m_include.size(); ++i)        delete m_include[i];    m_include.clear();}void DomResources::read(const QDomElement &node){    if (node.hasAttribute(QLatin1String("name")))        setAttributeName(node.attribute(QLatin1String("name")));    for (QDomNode n = node.firstChild(); !n.isNull(); n = n.nextSibling()) {        if (!n.isElement())            continue;        QDomElement e = n.toElement();        QString tag = e.tagName().toLower();        if (tag == QLatin1String("include")) {            DomResource *v = new DomResource();            v->read(e);            m_include.append(v);            continue;        }    }    m_text.clear();    for (QDomNode child = node.firstChild(); !child.isNull(); child = child.nextSibling()) {        if (child.isText())            m_text.append(child.nodeValue());    }}QDomElement DomResources::write(QDomDocument &doc, const QString &tagName){    QDomElement e = doc.createElement(tagName.isEmpty() ? QString::fromUtf8("resources") : tagName.toLower());

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -