QT_BEGIN_NAMESPACE /*! 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(QLatin1Char(';'))) functionName.chop(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(QLatin1Char(';')) ) functionName.chop(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 ); } out << "};" << endl; }
/*! Creates a declaration ( headerfile ) for a subclass \a subClass of the form given in \a e \sa createSubImpl() */ void Uic::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 == "QDialog" || objClass == "QWizard" ) { out << " " << subClass << "( QWidget* parent = 0, const char* name = 0, bool modal = FALSE, WFlags fl = 0 );" << endl; } else { // standard QWidget out << " " << subClass << "( QWidget* parent = 0, const char* name = 0, WFlags 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( "slot" ); for ( i = 0; i < ( int ) nl.length(); i++ ) { n = nl.item( i ).toElement(); if ( n.parentNode().toElement().tagName() != "slots" && n.parentNode().toElement().tagName() != "connections" ) continue; if ( n.attribute( "language", "C++" ) != "C++" ) continue; QString returnType = n.attribute( "returnType", "void" ); QString functionName = n.firstChild().toText().data().stripWhiteSpace(); if ( functionName.endsWith( ";" ) ) functionName = functionName.left( functionName.length() - 1 ); QString specifier = n.attribute( "specifier" ); QString access = n.attribute( "access" ); if ( access == "protected" ) { protectedSlots += functionName; protectedSlotTypes += returnType; protectedSlotSpecifier += specifier; } else if ( access == "private" ) { privateSlots += functionName; privateSlotTypes += returnType; privateSlotSpecifier += specifier; } else { publicSlots += functionName; publicSlotTypes += returnType; publicSlotSpecifier += specifier; } } nl = e.parentNode().toElement().elementsByTagName( "function" ); for ( i = 0; i < ( int ) nl.length(); i++ ) { n = nl.item( i ).toElement(); if ( n.parentNode().toElement().tagName() != "functions" ) continue; if ( n.attribute( "language", "C++" ) != "C++" ) continue; QString returnType = n.attribute( "returnType", "void" ); QString functionName = n.firstChild().toText().data().stripWhiteSpace(); if ( functionName.endsWith( ";" ) ) functionName = functionName.left( functionName.length() - 1 ); QString specifier = n.attribute( "specifier" ); QString access = n.attribute( "access" ); if ( access == "protected" ) { protectedFuncts += functionName; protectedFunctRetTyp += returnType; protectedFunctSpec += specifier; } else if ( access == "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 ); } out << "};" << endl; }