Example #1
0
void Ui3Reader::generate(const QString &fn, const QString &outputFn,
                         QDomDocument doc, bool decl, bool subcl, const QString &trm,
                         const QString& subClass, const QString &convertedUiFile)
{
    init();

    fileName = fn;
    outputFileName = outputFn;
    trmacro = trm;

    QDomElement e = parse(doc);

    if (nameOfClass.isEmpty())
        nameOfClass = getObjectName(e);
    namespaces = nameOfClass.split(QLatin1String("::"));
    bareNameOfClass = namespaces.last();
    namespaces.removeLast();

    if (!convertedUiFile.isEmpty()) {
        createWrapperDecl(e, convertedUiFile);
    } else if (subcl) {
        if (decl)
            createSubDecl(e, subClass);
        else
            createSubImpl(e, subClass);
    } else {
        if (decl)
            createFormDecl(e);
        else
            createFormImpl(e);
    }

}
Example #2
0
/*!
  \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 );
    }

}