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

📄 ui4.cpp

📁 奇趣公司比较新的qt/emd版本
💻 CPP
📖 第 1 页 / 共 5 页
字号:
/******************************************************************************** Copyright (C) 1992-2007 Trolltech ASA. All rights reserved.**** This file is part of the tools applications 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://trolltech.com/products/qt/licenses/licensing/opensource/**** If you are unsure which license is appropriate for your use, please** review the following information:** http://trolltech.com/products/qt/licenses/licensing/licensingoverview** or contact the sales department at sales@trolltech.com.**** In addition, as a special exception, Trolltech gives you certain** additional rights. These rights are described in the Trolltech GPL** Exception version 1.0, which can be found at** http://www.trolltech.com/products/qt/gplexception/ and in the file** GPL_EXCEPTION.txt in this package.**** In addition, as a special exception, Trolltech, as the sole copyright** holder for Qt Designer, grants users of the Qt/Eclipse Integration** plug-in the right for the Qt/Eclipse Integration to link to** functionality provided by Qt Designer and its related libraries.**** Trolltech reserves all rights not expressly granted herein.**** 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;    delete m_designerdata;    if (clear_all) {    m_text = QString();    m_has_attr_version = false;    m_has_attr_language = false;    m_has_attr_stdSetDef = false;    m_attr_stdSetDef = 0;    }    m_children = 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;    m_designerdata = 0;}DomUI::DomUI(){    m_children = 0;    m_has_attr_version = false;    m_has_attr_language = 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;    m_designerdata = 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;    delete m_designerdata;}void DomUI::read(const QDomElement &node){    if (node.hasAttribute(QLatin1String("version")))        setAttributeVersion(node.attribute(QLatin1String("version")));    if (node.hasAttribute(QLatin1String("language")))        setAttributeLanguage(node.attribute(QLatin1String("language")));    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;        }        if (tag == QLatin1String("designerdata")) {            DomDesignerData *v = new DomDesignerData();            v->read(e);            setElementDesignerdata(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) const{    QDomElement e = doc.createElement(tagName.isEmpty() ? QString::fromUtf8("ui") : tagName.toLower());    QDomElement child;    if (hasAttributeVersion())        e.setAttribute(QLatin1String("version"), attributeVersion());    if (hasAttributeLanguage())        e.setAttribute(QLatin1String("language"), attributeLanguage());    if (hasAttributeStdSetDef())        e.setAttribute(QLatin1String("stdsetdef"), attributeStdSetDef());    if (m_children & Author) {        child = doc.createElement(QLatin1String("author"));        child.appendChild(doc.createTextNode(m_author));        e.appendChild(child);    }    if (m_children & Comment) {        child = doc.createElement(QLatin1String("comment"));        child.appendChild(doc.createTextNode(m_comment));        e.appendChild(child);    }    if (m_children & ExportMacro) {        child = doc.createElement(QLatin1String("exportmacro"));        child.appendChild(doc.createTextNode(m_exportMacro));        e.appendChild(child);    }    if (m_children & Class) {        child = doc.createElement(QLatin1String("class"));        child.appendChild(doc.createTextNode(m_class));        e.appendChild(child);    }    if (m_children & Widget) {        e.appendChild(m_widget->write(doc, QLatin1String("widget")));    }    if (m_children & LayoutDefault) {        e.appendChild(m_layoutDefault->write(doc, QLatin1String("layoutdefault")));    }    if (m_children & LayoutFunction) {        e.appendChild(m_layoutFunction->write(doc, QLatin1String("layoutfunction")));    }    if (m_children & PixmapFunction) {        child = doc.createElement(QLatin1String("pixmapfunction"));        child.appendChild(doc.createTextNode(m_pixmapFunction));        e.appendChild(child);    }    if (m_children & CustomWidgets) {        e.appendChild(m_customWidgets->write(doc, QLatin1String("customwidgets")));    }    if (m_children & TabStops) {        e.appendChild(m_tabStops->write(doc, QLatin1String("tabstops")));    }    if (m_children & Images) {        e.appendChild(m_images->write(doc, QLatin1String("images")));    }    if (m_children & Includes) {        e.appendChild(m_includes->write(doc, QLatin1String("includes")));    }    if (m_children & Resources) {        e.appendChild(m_resources->write(doc, QLatin1String("resources")));    }    if (m_children & Connections) {        e.appendChild(m_connections->write(doc, QLatin1String("connections")));    }    if (m_children & Designerdata) {        e.appendChild(m_designerdata->write(doc, QLatin1String("designerdata")));    }    if (!m_text.isEmpty())        e.appendChild(doc.createTextNode(m_text));    return e;}void DomUI::setElementAuthor(const QString& a){    m_children |= Author;    m_author = a;}void DomUI::setElementComment(const QString& a){    m_children |= Comment;    m_comment = a;}void DomUI::setElementExportMacro(const QString& a){    m_children |= ExportMacro;    m_exportMacro = a;}void DomUI::setElementClass(const QString& a){    m_children |= Class;    m_class = a;}void DomUI::setElementWidget(DomWidget* a){    delete m_widget;    m_children |= Widget;    m_widget = a;}void DomUI::setElementLayoutDefault(DomLayoutDefault* a){    delete m_layoutDefault;    m_children |= LayoutDefault;    m_layoutDefault = a;}void DomUI::setElementLayoutFunction(DomLayoutFunction* a){    delete m_layoutFunction;    m_children |= LayoutFunction;    m_layoutFunction = a;}void DomUI::setElementPixmapFunction(const QString& a){    m_children |= PixmapFunction;    m_pixmapFunction = a;}void DomUI::setElementCustomWidgets(DomCustomWidgets* a){    delete m_customWidgets;    m_children |= CustomWidgets;    m_customWidgets = a;}void DomUI::setElementTabStops(DomTabStops* a){    delete m_tabStops;    m_children |= TabStops;    m_tabStops = a;}void DomUI::setElementImages(DomImages* a){    delete m_images;    m_children |= Images;    m_images = a;}void DomUI::setElementIncludes(DomIncludes* a){    delete m_includes;    m_children |= Includes;    m_includes = a;}void DomUI::setElementResources(DomResources* a){    delete m_resources;    m_children |= Resources;    m_resources = a;}void DomUI::setElementConnections(DomConnections* a){    delete m_connections;    m_children |= Connections;    m_connections = a;}void DomUI::setElementDesignerdata(DomDesignerData* a){    delete m_designerdata;    m_children |= Designerdata;    m_designerdata = a;}void DomUI::clearElementAuthor(){    m_children &= ~Author;}void DomUI::clearElementComment(){    m_children &= ~Comment;}void DomUI::clearElementExportMacro(){    m_children &= ~ExportMacro;}void DomUI::clearElementClass(){    m_children &= ~Class;}void DomUI::clearElementWidget(){    delete m_widget;    m_widget = 0;    m_children &= ~Widget;}void DomUI::clearElementLayoutDefault(){    delete m_layoutDefault;    m_layoutDefault = 0;    m_children &= ~LayoutDefault;}void DomUI::clearElementLayoutFunction(){    delete m_layoutFunction;    m_layoutFunction = 0;    m_children &= ~LayoutFunction;}void DomUI::clearElementPixmapFunction(){    m_children &= ~PixmapFunction;}void DomUI::clearElementCustomWidgets(){    delete m_customWidgets;    m_customWidgets = 0;    m_children &= ~CustomWidgets;}void DomUI::clearElementTabStops(){    delete m_tabStops;    m_tabStops = 0;    m_children &= ~TabStops;}void DomUI::clearElementImages(){    delete m_images;    m_images = 0;    m_children &= ~Images;}void DomUI::clearElementIncludes(){    delete m_includes;    m_includes = 0;    m_children &= ~Includes;}void DomUI::clearElementResources(){    delete m_resources;    m_resources = 0;    m_children &= ~Resources;}void DomUI::clearElementConnections(){    delete m_connections;    m_connections = 0;    m_children &= ~Connections;}void DomUI::clearElementDesignerdata(){    delete m_designerdata;    m_designerdata = 0;    m_children &= ~Designerdata;}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){

⌨️ 快捷键说明

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