QDomElement Ui3Reader::parse(const QDomDocument &doc) { root = doc.firstChild().toElement(); widget = QDomElement(); pixmapLoaderFunction = getPixmapLoaderFunction(doc.firstChild().toElement()); nameOfClass = getFormClassName(doc.firstChild().toElement()); uiFileVersion = doc.firstChild().toElement().attribute(QLatin1String("version")); stdsetdef = toBool(doc.firstChild().toElement().attribute(QLatin1String("stdsetdef"))); if (doc.firstChild().isNull() || doc.firstChild().firstChild().isNull()) return widget; QDomElement e = doc.firstChild().firstChild().toElement(); while (!e.isNull()) { if (e.tagName() == QLatin1String("widget")) { widget = e; } else if (e.tagName() == QLatin1String("pixmapinproject")) { externPixmaps = true; } else if (e.tagName() == QLatin1String("layoutdefaults")) { defSpacing = e.attribute(QLatin1String("spacing"), defSpacing.toString()); defMargin = e.attribute(QLatin1String("margin"), defMargin.toString()); } else if (e.tagName() == QLatin1String("layoutfunctions")) { defSpacing = e.attribute(QLatin1String("spacing"), defSpacing.toString()); bool ok; defSpacing.toInt(&ok); if (!ok) { QString buf = defSpacing.toString(); defSpacing = buf.append(QLatin1String("()")); } defMargin = e.attribute(QLatin1String("margin"), defMargin.toString()); defMargin.toInt(&ok); if (!ok) { QString buf = defMargin.toString(); defMargin = buf.append(QLatin1String("()")); } } e = e.nextSibling().toElement(); } return widget; }
/*! \class Uic uic.h \brief User Interface Compiler The class Uic encapsulates the user interface compiler (uic). */ Uic::Uic( const QString &fn, const char *outputFn, QTextStream &outStream, QDomDocument doc, bool decl, bool subcl, const QString &trm, const QString& subClass, bool omitForwardDecls ) : out( outStream ), trout( &languageChangeBody ), outputFileName( outputFn ), trmacro( trm ), nofwd( omitForwardDecls ) { fileName = fn; writeFunctImpl = TRUE; defMargin = BOXLAYOUT_DEFAULT_MARGIN; defSpacing = BOXLAYOUT_DEFAULT_SPACING; externPixmaps = FALSE; indent = " "; // default indent item_used = cg_used = pal_used = 0; layouts << "hbox" << "vbox" << "grid"; tags = layouts; tags << "widget"; pixmapLoaderFunction = getPixmapLoaderFunction( doc.firstChild().toElement() ); nameOfClass = getFormClassName( doc.firstChild().toElement() ); uiFileVersion = doc.firstChild().toElement().attribute("version"); stdsetdef = toBool( doc.firstChild().toElement().attribute("stdsetdef") ); if ( doc.firstChild().isNull() || doc.firstChild().firstChild().isNull() ) return; QDomElement e = doc.firstChild().firstChild().toElement(); QDomElement widget; while ( !e.isNull() ) { if ( e.tagName() == "widget" ) { widget = e; } else if ( e.tagName() == "pixmapinproject" ) { externPixmaps = TRUE; } else if ( e.tagName() == "layoutdefaults" ) { defSpacing = e.attribute( "spacing", defSpacing.toString() ); defMargin = e.attribute( "margin", defMargin.toString() ); } else if ( e.tagName() == "layoutfunctions" ) { defSpacing = e.attribute( "spacing", defSpacing.toString() ); bool ok; defSpacing.toInt( &ok ); if ( !ok ) { QString buf = defSpacing.toString(); defSpacing = buf.append( "()" ); } defMargin = e.attribute( "margin", defMargin.toString() ); defMargin.toInt( &ok ); if ( !ok ) { QString buf = defMargin.toString(); defMargin = buf.append( "()" ); } } e = e.nextSibling().toElement(); } e = widget; if ( nameOfClass.isEmpty() ) nameOfClass = getObjectName( e ); namespaces = QStringList::split( "::", nameOfClass ); bareNameOfClass = namespaces.last(); namespaces.remove( namespaces.fromLast() ); if ( subcl ) { if ( decl ) createSubDecl( e, subClass ); else createSubImpl( e, subClass ); } else { if ( decl ) createFormDecl( e ); else createFormImpl( e ); } }