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

📄 form.cpp

📁 Linux下的基于X11的图形开发环境。
💻 CPP
📖 第 1 页 / 共 4 页
字号:
    /* qmake ignore Q_OBJECT */    out << "    Q_OBJECT" << endl;    out << endl;    out << "public:" << endl;    // constructor    if ( objClass == "QDialog" || objClass == "QWizard" ) {	out << "    " << bareNameOfClass << "( QWidget* parent = 0, const char* name = 0, bool modal = FALSE, WFlags fl = 0 );" << endl;    } else if ( objClass == "QWidget" ) {	out << "    " << bareNameOfClass << "( QWidget* parent = 0, const char* name = 0, WFlags fl = 0 );" << endl;    } else if ( objClass == "QMainWindow" ) {	out << "    " << bareNameOfClass << "( QWidget* parent = 0, const char* name = 0, WFlags fl = WType_TopLevel );" << endl;	isMainWindow = TRUE;    } else {	out << "    " << bareNameOfClass << "( QWidget* parent = 0, const char* name = 0 );" << endl;    }    // destructor    out << "    ~" << bareNameOfClass << "();" << endl;    out << endl;    // children    bool needPolish = FALSE;    nl = e.parentNode().toElement().elementsByTagName( "widget" );    for ( i = 1; i < (int) nl.length(); i++ ) { // start at 1, 0 is the toplevel widget	n = nl.item(i).toElement();	createObjectDecl( n );	QString s = getClassName( n );	if ( s == "QDataTable" || s == "QDataBrowser" ) {	    if ( isFrameworkCodeGenerated( n ) )		 needPolish = TRUE;	}    }    // actions, toolbars, menus    for ( n = e; !n.isNull(); n = n.nextSibling().toElement() ) {	if ( n.tagName()  == "actions" ) {	    for ( QDomElement a = n.firstChild().toElement(); !a.isNull(); a = a.nextSibling().toElement() )		createActionDecl( a );	} else if ( n.tagName() == "toolbars" ) {	    for ( QDomElement a = n.firstChild().toElement(); !a.isNull(); a = a.nextSibling().toElement() )		createToolbarDecl( a );	} else if ( n.tagName() == "menubar" ) {	    out << "    " << "QMenuBar *" << getObjectName( n ) << ";" << endl;	    for ( QDomElement a = n.firstChild().toElement(); !a.isNull(); a = a.nextSibling().toElement() )		createMenuBarDecl( a );	}    }    out << endl;    // database connections    dbConnections = unique( dbConnections );    bool hadOutput = FALSE;    for ( it = dbConnections.begin(); it != dbConnections.end(); ++it ) {	if ( !(*it).isEmpty() ) {	    // only need pointers to non-default connections	    if ( (*it) != "(default)" && !(*it).isEmpty() ) {		out << indent << "QSqlDatabase* " << *it << "Connection;" << endl;		hadOutput = TRUE;	    }	}    }    if ( hadOutput )	out << endl;    QStringList publicSlots, protectedSlots, privateSlots;    QStringList publicSlotTypes, protectedSlotTypes, privateSlotTypes;    QStringList publicSlotSpecifier, protectedSlotSpecifier, privateSlotSpecifier;    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;	}    }    QStringList publicFuncts, protectedFuncts, privateFuncts;    QStringList publicFunctRetTyp, protectedFunctRetTyp, privateFunctRetTyp;    QStringList publicFunctSpec, protectedFunctSpec, privateFunctSpec;    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;	}    }    QStringList publicVars, protectedVars, privateVars;    nl = e.parentNode().toElement().elementsByTagName( "variable" );    for ( i = 0; i < (int)nl.length(); i++ ) {	n = nl.item( i ).toElement();	// Because of compatibility the next lines have to be commented out.	// Someday it should be uncommented.	//if ( n.parentNode().toElement().tagName() != "variables" )	//    continue;	QString access = n.attribute( "access", "protected" );	QString var = n.firstChild().toText().data().stripWhiteSpace();	if ( !var.endsWith( ";" ) )	    var += ";";	if ( access == "public" )	    publicVars += var;	else if ( access == "private" )	    privateVars += var;	else	    protectedVars += var;    }    if ( !publicVars.isEmpty() ) {	for ( it = publicVars.begin(); it != publicVars.end(); ++it )	    out << indent << *it << endl;	out << endl;    }    if ( !publicFuncts.isEmpty() )	writeFunctionsDecl( publicFuncts, publicFunctRetTyp, publicFunctSpec );    if ( needPolish || !publicSlots.isEmpty() ) {	out << "public slots:" << endl;	if ( needPolish ) {	    out << indent << "virtual void polish();" << endl;	    out << endl;	}	if ( !publicSlots.isEmpty() )	    writeFunctionsDecl( publicSlots, publicSlotTypes, publicSlotSpecifier );    }    // find signals    QStringList extraSignals;    nl = e.parentNode().toElement().elementsByTagName( "signal" );    for ( i = 0; i < (int) nl.length(); i++ ) {	n = nl.item( i ).toElement();	if ( n.parentNode().toElement().tagName() != "signals"	     && n.parentNode().toElement().tagName() != "connections" )	    continue;	if ( n.attribute( "language", "C++" ) != "C++" )	    continue;	QString sigName = n.firstChild().toText().data().stripWhiteSpace();	if ( sigName.endsWith( ";" ) )	    sigName = sigName.left( sigName.length() - 1 );	extraSignals += sigName;    }    // create signals    if ( !extraSignals.isEmpty() ) {	out << "signals:" << endl;	for ( it = extraSignals.begin(); it != extraSignals.end(); ++it )	    out << "    void " << (*it) << ";" << endl;	out << endl;    }    out << "protected:" << endl;    if ( !protectedVars.isEmpty() ) {	for ( it = protectedVars.begin(); it != protectedVars.end(); ++it )	    out << indent << *it << endl;	out << endl;    }    if ( !protectedFuncts.isEmpty() )	writeFunctionsDecl( protectedFuncts, protectedFunctRetTyp, protectedFunctSpec );    // child layouts    registerLayouts( e );    out << endl;#if QT_VERSION >= 0x030900#error Make languageChange() a virtual protected non-slot member of QWidget#endif    out << "protected slots:" << endl;    out << "    virtual void languageChange();" << endl;    if ( !protectedSlots.isEmpty() ) {	out << endl;	writeFunctionsDecl( protectedSlots, protectedSlotTypes, protectedSlotSpecifier );    }    // create all private stuff    if ( !privateFuncts.isEmpty() || !privateVars.isEmpty() || !imageMembers.isEmpty() ) {	out << "private:" << endl;	if ( !privateVars.isEmpty() ) {	    for ( it = privateVars.begin(); it != privateVars.end(); ++it )		out << indent << *it << endl;	    out << endl;	}	if ( !imageMembers.isEmpty() ) {	    out << imageMembers;	    out << endl;	}	if ( !privateFuncts.isEmpty() )	    writeFunctionsDecl( privateFuncts, privateFunctRetTyp, privateFunctSpec );    }    if ( !privateSlots.isEmpty() ) {	out << "private slots:" << endl;	writeFunctionsDecl( privateSlots, privateSlotTypes, privateSlotSpecifier );    }    out << "};" << endl;    for ( i = 0; i < (int) namespaces.count(); i++ )	out << "}" << endl;    out << endl;    out << "#endif // " << protector << endl;}void Uic::writeFunctionsDecl( const QStringList &fuLst, const QStringList &typLst, const QStringList &specLst ){    QValueListConstIterator<QString> it, it2, it3;    for ( it = fuLst.begin(), it2 = typLst.begin(), it3 = specLst.begin();	  it != fuLst.end(); ++it, ++it2, ++it3 ) {	QString specifier;	QString pure;	QString type = *it2;	if ( type.isEmpty() )	    type = "void";	if ( *it3 != "non virtual" && *it3 != "nonVirtual" )	    specifier = "virtual ";	if ( *it3 == "pure virtual" || *it3 == "pureVirtual" )	    pure = " = 0";	type.replace( ">>", "> >" );	out << "    " << specifier << type << " " << *it << pure << ";" << endl;    }    out << endl;}/*!  Creates an implementation (cpp-file) for the form given in \a e.  \sa createFormDecl(), createObjectImpl() */void Uic::createFormImpl( const QDomElement &e ){    QDomElement n;    QDomNodeList nl;    int i;    QString objClass = getClassName( e );    if ( objClass.isEmpty() )	return;    QString objName = getObjectName( e );    // generate local and local includes required    QStringList globalIncludes, localIncludes;    QStringList::Iterator it;    QMap<QString, CustomInclude> customWidgetIncludes;    // find additional slots and functions    QStringList extraFuncts;    QStringList extraFunctTyp;    QStringList extraFunctSpecifier;    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 functionName = n.firstChild().toText().data().stripWhiteSpace();	if ( functionName.endsWith( ";" ) )	    functionName = functionName.left( functionName.length() - 1 );	extraFuncts += functionName;	extraFunctTyp += n.attribute( "returnType", "void" );	extraFunctSpecifier += n.attribute( "specifier", "virtual" );    }    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 functionName = n.firstChild().toText().data().stripWhiteSpace();	if ( functionName.endsWith( ";" ) )	    functionName = functionName.left( functionName.length() - 1 );	extraFuncts += functionName;	extraFunctTyp += n.attribute( "returnType", "void" );	extraFunctSpecifier += n.attribute( "specifier", "virtual" );    }    for ( n = e; !n.isNull(); n = n.nextSibling().toElement() ) {	if ( n.tagName() == "customwidgets" ) {	    QDomElement n2 = n.firstChild().toElement();	    while ( !n2.isNull() ) {		if ( n2.tagName() == "customwidget" ) {		    QDomElement n3 = n2.firstChild().toElement();		    QString cl;		    WidgetDatabaseRecord *r = new WidgetDatabaseRecord;		    while ( !n3.isNull() ) {			if ( n3.tagName() == "class" ) {			    cl = n3.firstChild().toText().data();			    r->name = cl;			} else if ( n3.tagName() == "header" ) {			    CustomInclude ci;			    ci.header = n3.firstChild().toText().data();			    ci.location = n3.attribute( "location", "global" );			    r->includeFile = ci.header;			    customWidgetIncludes.insert( cl, ci );			}			WidgetDatabase::append( r );			n3 = n3.nextSibling().toElement();		    }		}		n2 = n2.nextSibling().toElement();	    }	}    }

⌨️ 快捷键说明

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