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

📄 subclassing.cpp

📁 奇趣公司比较新的qt/emd版本
💻 CPP
📖 第 1 页 / 共 2 页
字号:
/******************************************************************************** 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 "ui3reader.h"#include "parser.h"#include "domtool.h"#include "globaldefs.h"#include <QFile>#include <QStringList>#include <QDateTime>#include <QRegExp>#include <stdio.h>#include <stdlib.h>/*!  Creates a declaration ( headerfile ) for a subclass \a subClass  of the form given in \a e  \sa createSubImpl() */void Ui3Reader::createSubDecl( const QDomElement &e, const QString& subClass ){    QDomElement n;    QDomNodeList nl;    int i;    QString objClass = getClassName( e );    if ( objClass.isEmpty() )        return;    out << "class " << subClass << " : public " << nameOfClass << endl;    out << "{" << endl;/* tmake ignore Q_OBJECT */    out << "    Q_OBJECT" << endl;    out << endl;    out << "public:" << endl;    // constructor    if ( objClass == QLatin1String("QDialog") || objClass == QLatin1String("QWizard") ) {        out << "    " << subClass << "( QWidget* parent = 0, const char* name = 0, bool modal = false, Qt::WindowFlags fl = 0 );" << endl;    } else { // standard QWidget        out << "    " << subClass << "( QWidget* parent = 0, const char* name = 0, Qt::WindowFlags fl = 0 );" << endl;    }    // destructor    out << "    ~" << subClass << "();" << endl;    out << endl;    // find additional functions    QStringList publicSlots, protectedSlots, privateSlots;    QStringList publicSlotTypes, protectedSlotTypes, privateSlotTypes;    QStringList publicSlotSpecifier, protectedSlotSpecifier, privateSlotSpecifier;    QStringList publicFuncts, protectedFuncts, privateFuncts;    QStringList publicFunctRetTyp, protectedFunctRetTyp, privateFunctRetTyp;    QStringList publicFunctSpec, protectedFunctSpec, privateFunctSpec;    nl = e.parentNode().toElement().elementsByTagName(QLatin1String("slot"));    for ( i = 0; i < (int) nl.length(); i++ ) {        n = nl.item(i).toElement();        if ( n.parentNode().toElement().tagName() != QLatin1String("slots")             && n.parentNode().toElement().tagName() != QLatin1String("connections") )            continue;        if ( n.attribute(QLatin1String("language"), QLatin1String("C++")) != QLatin1String("C++") )            continue;        QString returnType = n.attribute(QLatin1String("returnType"), QLatin1String("void"));        QString functionName = n.firstChild().toText().data().trimmed();        if ( functionName.endsWith(QLatin1String(";")))            functionName = functionName.left( functionName.length() - 1 );        QString specifier = n.attribute(QLatin1String("specifier"));        QString access = n.attribute(QLatin1String("access"));        if ( access == QLatin1String("protected") ) {            protectedSlots += functionName;            protectedSlotTypes += returnType;            protectedSlotSpecifier += specifier;        } else if ( access == QLatin1String("private") ) {            privateSlots += functionName;            privateSlotTypes += returnType;            privateSlotSpecifier += specifier;        } else {            publicSlots += functionName;            publicSlotTypes += returnType;            publicSlotSpecifier += specifier;        }    }    nl = e.parentNode().toElement().elementsByTagName(QLatin1String("function"));    for ( i = 0; i < (int) nl.length(); i++ ) {        n = nl.item(i).toElement();        if ( n.parentNode().toElement().tagName() != QLatin1String("functions") )            continue;        if ( n.attribute(QLatin1String("language"), QLatin1String("C++")) != QLatin1String("C++") )            continue;        QString returnType = n.attribute(QLatin1String("returnType"), QLatin1String("void"));        QString functionName = n.firstChild().toText().data().trimmed();        if ( functionName.endsWith(QLatin1String(";")) )            functionName = functionName.left( functionName.length() - 1 );        QString specifier = n.attribute(QLatin1String("specifier"));        QString access = n.attribute(QLatin1String("access"));        if ( access == QLatin1String("protected") ) {            protectedFuncts += functionName;            protectedFunctRetTyp += returnType;            protectedFunctSpec += specifier;        } else if ( access == QLatin1String("private") ) {            privateFuncts += functionName;            privateFunctRetTyp += returnType;            privateFunctSpec += specifier;        } else {            publicFuncts += functionName;            publicFunctRetTyp += returnType;            publicFunctSpec += specifier;        }    }    if ( !publicFuncts.isEmpty() )        writeFunctionsSubDecl( publicFuncts, publicFunctRetTyp, publicFunctSpec );    // create public additional slots    if ( !publicSlots.isEmpty() ) {        out << "public slots:" << endl;        writeFunctionsSubDecl( publicSlots, publicSlotTypes, publicSlotSpecifier );    }    if ( !protectedFuncts.isEmpty() ) {        out << "protected:" << endl;        writeFunctionsSubDecl( protectedFuncts, protectedFunctRetTyp, protectedFunctSpec );    }    // create protected additional slots    if ( !protectedSlots.isEmpty() ) {        out << "protected slots:" << endl;        writeFunctionsSubDecl( protectedSlots, protectedSlotTypes, protectedSlotSpecifier );    }    if ( !privateFuncts.isEmpty() ) {        out << "private:" << endl;        writeFunctionsSubDecl( privateFuncts, privateFunctRetTyp, privateFunctSpec );    }    // create private additional slots    if ( !privateSlots.isEmpty() ) {        out << "private slots:" << endl;        writeFunctionsSubDecl( privateSlots, privateSlotTypes, privateSlotSpecifier );    }

⌨️ 快捷键说明

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