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

📄 form.cpp

📁 这个是Linux的qt源代码
💻 CPP
📖 第 1 页 / 共 4 页
字号:
	    }	}    }    // additional includes (local or global) and forward declaractions    nl = e.parentNode().toElement().elementsByTagName( "include" );    for ( i = 0; i < (int) nl.length(); i++ ) {	QDomElement n2 = nl.item(i).toElement();	QString s = n2.firstChild().toText().data();	if ( n2.attribute( "location" ) != "local" ) {	    if ( s.right( 5 ) == ".ui.h" && !QFile::exists( s ) )		continue;	    if ( n2.attribute( "impldecl", "in implementation" ) != "in implementation" )		continue;	    globalIncludes += s;	}    }    registerDatabases( e );    dbConnections = unique( dbConnections );    if ( dbConnections.count() )	globalIncludes += "qsqldatabase.h";    if ( dbCursors.count() )	globalIncludes += "qsqlcursor.h";    bool dbForm = FALSE;    if ( dbForms[ "(default)" ].count() )	dbForm = TRUE;    bool subDbForms = FALSE;    for ( it = dbConnections.begin(); it != dbConnections.end(); ++it ) {	if ( !(*it).isEmpty()  && (*it) != "(default)" ) {	    if ( dbForms[ (*it) ].count() ) {		subDbForms = TRUE;		break;	    }	}    }    if ( dbForm || subDbForms ) {	globalIncludes += "qsqlform.h";	globalIncludes += "qsqlrecord.h";    }    // do the local includes afterwards, since global includes have priority on clashes    for ( i = 0; i < (int) nl.length(); i++ ) {	QDomElement n2 = nl.item(i).toElement();	QString s = n2.firstChild().toText().data();	if ( n2.attribute( "location" ) == "local" &&!globalIncludes.contains( s ) ) {	    if ( s.right( 5 ) == ".ui.h" && !QFile::exists( s ) )		continue;	    if ( n2.attribute( "impldecl", "in implementation" ) != "in implementation" )		continue;	    localIncludes += s;	}    }    // additional custom widget headers    nl = e.parentNode().toElement().elementsByTagName( "header" );    for ( i = 0; i < (int) nl.length(); i++ ) {	QDomElement n2 = nl.item(i).toElement();	QString s = n2.firstChild().toText().data();	if ( n2.attribute( "location" ) != "local" )	    globalIncludes += s;	else	    localIncludes += s;    }    // includes for child widgets    for ( it = tags.begin(); it != tags.end(); ++it ) {	nl = e.parentNode().toElement().elementsByTagName( *it );	for ( i = 1; i < (int) nl.length(); i++ ) { // start at 1, 0 is the toplevel widget	    QString name = getClassName( nl.item(i).toElement() );	    if ( name == "Spacer" ) {		globalIncludes += "qlayout.h";		globalIncludes += "qapplication.h";		continue;	    }	    if ( name.mid( 1 ) == "ListView" )		globalIncludes += "qheader.h";	    if ( name != objClass ) {		int wid = WidgetDatabase::idFromClassName( name );		QMap<QString, CustomInclude>::Iterator it = customWidgetIncludes.find( name );		if ( it == customWidgetIncludes.end() )		    globalIncludes += WidgetDatabase::includeFile( wid );	    }	}    }    out << "#include <qvariant.h>" << endl; // first for gcc 2.7.2    globalIncludes = unique( globalIncludes );    for ( it = globalIncludes.begin(); it != globalIncludes.end(); ++it ) {	if ( !(*it).isEmpty() )	    out << "#include <" << *it << ">" << endl;    }    out << "#include <qlayout.h>" << endl;    out << "#include <qtooltip.h>" << endl;    out << "#include <qwhatsthis.h>" << endl;    if ( objClass == "QMainWindow" ) {	out << "#include <qaction.h>" << endl;	out << "#include <qmenubar.h>" << endl;	out << "#include <qpopupmenu.h>" << endl;	out << "#include <qtoolbar.h>" << endl;    }    // find out what images are required    QStringList requiredImages;    static const char *imgTags[] = { "pixmap", "iconset", 0 };    for ( i = 0; imgTags[i] != 0; i++ ) {	nl = e.parentNode().toElement().elementsByTagName( imgTags[i] );	for ( int j = 0; j < (int) nl.length(); j++ ) {	    QDomNode nn = nl.item(j);	    while ( nn.parentNode() != e.parentNode() )		nn = nn.parentNode();	    if ( nn.nodeName() != "customwidgets" )		requiredImages += nl.item(j).firstChild().toText().data();	}    }    if ( !requiredImages.isEmpty() || externPixmaps ) {	out << "#include <qimage.h>" << endl;	out << "#include <qpixmap.h>" << endl << endl;    }    /*      Put local includes after all global includes    */    localIncludes = unique( localIncludes );    for ( it = localIncludes.begin(); it != localIncludes.end(); ++it ) {	if ( !(*it).isEmpty() && *it != QFileInfo( fileName + ".h" ).fileName() )	    out << "#include \"" << *it << "\"" << endl;    }    QString uiDotH = fileName + ".h";    if ( QFile::exists( uiDotH ) ) {	if ( !outputFileName.isEmpty() )	    uiDotH = combinePath( uiDotH, outputFileName );	out << "#include \"" << uiDotH << "\"" << endl;	writeFunctImpl = FALSE;    }    // register the object and unify its name    objName = registerObject( objName );    QStringList images;    QStringList xpmImages;    if ( pixmapLoaderFunction.isEmpty() && !externPixmaps ) {	// create images	for ( n = e; !n.isNull(); n = n.nextSibling().toElement() ) {	    if ( n.tagName()  == "images" ) {		nl = n.elementsByTagName( "image" );		for ( i = 0; i < (int) nl.length(); i++ ) {		    QString img = registerObject( nl.item(i).toElement().attribute("name") );		    if ( !requiredImages.contains( img ) )			continue;		    QDomElement tmp = nl.item(i).firstChild().toElement();		    if ( tmp.tagName() != "data" )			continue;		    QString format = tmp.attribute("format", "PNG" );		    QString data = tmp.firstChild().toText().data();		    if ( format == "XPM.GZ" ) {			xpmImages += img;			ulong length = tmp.attribute("length").toULong();			QByteArray baunzip = unzipXPM( data, length );			length = baunzip.size();			// shouldn't we test the initial 'length' against the			// resulting 'length' to catch corrupt UIC files?			int a = 0;			int column = 0;			bool inQuote = FALSE;			out << "static const char* const " << img << "_data[] = { " << endl;			while ( baunzip[a] != '\"' )			    a++;			for ( ; a < (int) length; a++ ) {			    out << baunzip[a];			    if ( baunzip[a] == '\n' ) {				column = 0;			    } else if ( baunzip[a] == '"' ) {				inQuote = !inQuote;			    }			    if ( column++ >= 511 && inQuote ) {				out << "\"\n\""; // be nice with MSVC & Co.				column = 1;			    }			}			out << endl;		    } else {			images += img;			out << "static const unsigned char const " << img << "_data[] = { " << endl;			out << "    ";			int a ;			for ( a = 0; a < (int) (data.length()/2)-1; a++ ) {			    out << "0x" << QString(data[2*a]) << QString(data[2*a+1]) << ",";			    if ( a % 12 == 11 )				out << endl << "    ";			    else				out << " ";			}			out << "0x" << QString(data[2*a]) << QString(data[2*a+1]) << endl;			out << "};" << endl << endl;		    }		}	    }	}	out << endl;    } else if ( externPixmaps ) {	pixmapLoaderFunction = "QPixmap::fromMimeSource";    }    // constructor    if ( objClass == "QDialog" || objClass == "QWizard" ) {	out << "/*" << endl;	out << " *  Constructs a " << nameOfClass << " as a child of 'parent', with the" << endl;	out << " *  name 'name' and widget flags set to 'f'." << endl;	out << " *" << endl;	out << " *  The " << objClass.mid(1).lower() << " will by default be modeless, unless you set 'modal' to" << endl;	out << " *  TRUE to construct a modal " << objClass.mid(1).lower() << "." << endl;	out << " */" << endl;	out << nameOfClass << "::" << bareNameOfClass << "( QWidget* parent, const char* name, bool modal, WFlags fl )" << endl;	out << "    : " << objClass << "( parent, name, modal, fl )";    } else if ( objClass == "QWidget" )  {	out << "/*" << endl;	out << " *  Constructs a " << nameOfClass << " as a child of 'parent', with the" << endl;	out << " *  name 'name' and widget flags set to 'f'." << endl;	out << " */" << endl;	out << nameOfClass << "::" << bareNameOfClass << "( QWidget* parent, const char* name, WFlags fl )" << endl;	out << "    : " << objClass << "( parent, name, fl )";    } else if ( objClass == "QMainWindow" ) {	out << "/*" << endl;	out << " *  Constructs a " << nameOfClass << " as a child of 'parent', with the" << endl;	out << " *  name 'name' and widget flags set to 'f'." << endl;	out << " *" << endl;	out << " */" << endl;	out << nameOfClass << "::" << bareNameOfClass << "( QWidget* parent, const char* name, WFlags fl )" << endl;	out << "    : " << objClass << "( parent, name, fl )";	isMainWindow = TRUE;    } else {	out << "/*" << endl;	out << " *  Constructs a " << nameOfClass << " which is a child of 'parent', with the" << endl;	out << " *  name 'name'.' " << endl;	out << " */" << endl;	out << nameOfClass << "::" << bareNameOfClass << "( QWidget* parent,  const char* name )" << endl;	out << "    : " << objClass << "( parent, name )";    }    // create pixmaps for all images    if ( !xpmImages.isEmpty() ) {	for ( it = xpmImages.begin(); it != xpmImages.end(); ++it ) {	    out << "," << endl;	    out << indent << "  " << *it << "( (const char **) " << (*it) << "_data )";	}    }    out << endl;    out << "{" << endl;    if ( isMainWindow )	out << indent << "(void)statusBar();" << endl;    if ( !images.isEmpty() ) {	out << indent << "QImage img;" << endl;	for ( it = images.begin(); it != images.end(); ++it ) {	    out << indent << "img.loadFromData( " << (*it) << "_data, sizeof( " << (*it) << "_data ), \"PNG\" );" << endl;	    out << indent << (*it) << " = img;" << endl;	}    }    // set the properties    QSize geometry( 0, 0 );    for ( n = e.firstChild().toElement(); !n.isNull(); n = n.nextSibling().toElement() ) {	if ( n.tagName() == "property" ) {	    bool stdset = stdsetdef;	    if ( n.hasAttribute( "stdset" ) )		stdset = toBool( n.attribute( "stdset" ) );	    QString prop = n.attribute("name");	    QDomElement n2 = n.firstChild().toElement();	    QString value = setObjectProperty( objClass, QString::null, prop, n2, stdset );	    if ( value.isEmpty() )		continue;	    if ( prop == "geometry" && n2.tagName() == "rect" ) {		QDomElement n3 = n2.firstChild().toElement();		while ( !n3.isNull() ) {		    if ( n3.tagName() == "width" )			geometry.setWidth( n3.firstChild().toText().data().toInt() );		    else if ( n3.tagName() == "height" )			geometry.setHeight( n3.firstChild().toText().data().toInt() );		    n3 = n3.nextSibling().toElement();		}	    } else {		QString call;		if ( stdset ) {		    call = mkStdSet( prop ) + "( ";		} else {		    call = "setProperty( \"" + prop + "\", ";		}		call += value + " );";		if ( n2.tagName() == "string" ) {		    trout << indent << call << endl;		} else if ( prop == "name" ) {		    out << indent << "if ( !name )" << endl;		    out << "\t" << call << endl;		} else {		    out << indent << call << endl;		}	    }	}    }    // create all children, some forms have special requirements    if ( objClass == "QWizard" ) {	for ( n = e.firstChild().toElement(); !n.isNull(); n = n.nextSibling().toElement() ) {	    if ( tags.contains( n.tagName()  ) ) {		QString page = createObjectImpl( n, objClass, "this" );		QString comment;		QString label = DomTool::readAttribute( n, "title", "", comment ).toString();		out << indent << "addPage( " << page << ", QString(\"\") );" << endl;		trout << indent << "setTitle( " << page << ", " << trcall( label, comment ) << " );" << endl;		QVariant def( FALSE, 0 );		if ( DomTool::hasAttribute( n, "backEnabled" ) )		    out << indent << "setBackEnabled( " << page << ", " << mkBool( DomTool::readAttribute( n, "backEnabled", def).toBool() ) << endl;		if ( DomTool::hasAttribute( n, "nextEnabled" ) )		    out << indent << "setNextEnabled( " << page << ", " << mkBool( DomTool::readAttribute( n, "nextEnabled", def).toBool() ) << endl;		if ( DomTool::hasAttribute( n, "finishEnabled" ) )		    out << indent << "setFinishEnabled( " << page << ", " << mkBool( DomTool::readAttribute( n, "finishEnabled", def).toBool() ) << " );" << endl;		if ( DomTool::hasAttribute( n, "helpEnabled" ) )		    out << indent << "setHelpEnabled( " << page << ", " << mkBool( DomTool::readAttribute( n, "helpEnabled", def).toBool() ) << endl;		if ( DomTool::hasAttribute( n, "finish" ) )		    out << indent << "setFinish( " << page << ", " << mkBool( DomTool::readAttribute( n, "finish", def).toBool() ) << endl;	    }	}    } else { // standard widgets	for ( n = e.firstChild().toElement(); !n.isNull(); n = n.nextSibling().toElement() ) {	    if ( tags.contains( n.tagName()  ) )		createObjectImpl( n, objName, "this" );	}    }    // database support    dbConnections = unique( dbConnections );    if ( dbConnections.count() )	out << endl;    for ( it = dbConnections.begin(); it != dbConnections.end(); ++it ) {	if ( !(*it).isEmpty() && (*it) != "(default)") {	    out << indent << (*it) << "Connection = QSqlDatabase::database( \"" <<(*it) << "\" );" << endl;	}    }    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();	QString s = getClassName( n );	if ( (dbForm || subDbForms) && (s == "QDataBrowser" || s == "QDataView") ) {	    QString objName = getObjectName( n );	    QString tab = getDatabaseInfo( n, "table" );	    QString con = getDatabaseInfo( n, "connection" );	    out << indent << "QSqlForm* " << objName << "Form =  new QSqlForm( this, \"" << objName << "Form\" );" << endl;	    QDomElement n2;	    for ( n2 = n.firstChild().toElement(); !n2.isNull(); n2 = n2.nextSibling().toElement() )

⌨️ 快捷键说明

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