src/tools/uic3/ui3reader.cpp
changeset 7 f7bc934e204c
parent 0 1918ee327afb
equal deleted inserted replaced
3:41300fa6a67c 7:f7bc934e204c
     1 /****************************************************************************
     1 /****************************************************************************
     2 **
     2 **
     3 ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
     3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     4 ** All rights reserved.
     4 ** All rights reserved.
     5 ** Contact: Nokia Corporation (qt-info@nokia.com)
     5 ** Contact: Nokia Corporation (qt-info@nokia.com)
     6 **
     6 **
     7 ** This file is part of the tools applications of the Qt Toolkit.
     7 ** This file is part of the tools applications of the Qt Toolkit.
     8 **
     8 **
   174 
   174 
   175 void Ui3Reader::init()
   175 void Ui3Reader::init()
   176 {
   176 {
   177     outputFileName.clear();
   177     outputFileName.clear();
   178     trmacro.clear();
   178     trmacro.clear();
   179     nofwd = false;
       
   180 
   179 
   181     fileName.clear();
   180     fileName.clear();
   182     writeFunctImpl = true;
   181     writeFunctImpl = true;
   183     defMargin = BOXLAYOUT_DEFAULT_MARGIN;
   182     defMargin = BOXLAYOUT_DEFAULT_MARGIN;
   184     defSpacing = BOXLAYOUT_DEFAULT_SPACING;
   183     defSpacing = BOXLAYOUT_DEFAULT_SPACING;
   239     }
   238     }
   240 
   239 
   241     return widget;
   240     return widget;
   242 }
   241 }
   243 
   242 
   244 Ui3Reader::Ui3Reader(QTextStream &outStream)
   243 Ui3Reader::Ui3Reader(QTextStream &outStream, unsigned options) :
   245    : out(outStream), trout(&languageChangeBody)
   244     m_options(options), out(outStream), trout(&languageChangeBody),
   246 {
   245     m_porting(new Porting), m_extractImages(false)
   247     m_porting = new Porting();
   246 {
   248     m_extractImages = false;
       
   249 }
   247 }
   250 
   248 
   251 Ui3Reader::~Ui3Reader()
   249 Ui3Reader::~Ui3Reader()
   252 {
   250 {
   253     delete m_porting;
   251     delete m_porting;
   254 }
   252 }
   255 
   253 
   256 void Ui3Reader::generate(const QString &fn, const QString &outputFn,
   254 void Ui3Reader::generate(const QString &fn, const QString &outputFn,
   257           QDomDocument doc, bool decl, bool subcl, const QString &trm,
   255           QDomDocument doc, bool decl, bool subcl, const QString &trm,
   258           const QString& subClass, bool omitForwardDecls, bool implicitIncludes, const QString &convertedUiFile)
   256           const QString& subClass, const QString &convertedUiFile)
   259 {
   257 {
   260     init();
   258     init();
   261 
   259 
   262     fileName = fn;
   260     fileName = fn;
   263     outputFileName = outputFn;
   261     outputFileName = outputFn;
   264     trmacro = trm;
   262     trmacro = trm;
   265     nofwd = omitForwardDecls;
       
   266 
   263 
   267     QDomElement e = parse(doc);
   264     QDomElement e = parse(doc);
   268 
   265 
   269     if (nameOfClass.isEmpty())
   266     if (nameOfClass.isEmpty())
   270         nameOfClass = getObjectName(e);
   267         nameOfClass = getObjectName(e);
   279             createSubDecl(e, subClass);
   276             createSubDecl(e, subClass);
   280         else
   277         else
   281             createSubImpl(e, subClass);
   278             createSubImpl(e, subClass);
   282     } else {
   279     } else {
   283         if (decl)
   280         if (decl)
   284             createFormDecl(e, implicitIncludes);
   281             createFormDecl(e);
   285         else
   282         else
   286             createFormImpl(e);
   283             createFormImpl(e);
   287     }
   284     }
   288 
   285 
   289 }
   286 }
   290 
   287 
   291 void Ui3Reader::generateUi4(const QString &fn, const QString &outputFn, QDomDocument doc, bool implicitIncludes)
   288 void Ui3Reader::generateUi4(const QString &fn, const QString &outputFn, QDomDocument doc)
   292 {
   289 {
   293     init();
   290     init();
   294 
   291 
   295     fileName = fn;
   292     fileName = fn;
   296     outputFileName = outputFn;
   293     outputFileName = outputFn;
   297 
   294 
   298     DomUI *ui = generateUi4(parse(doc), implicitIncludes);
   295     DomUI *ui = generateUi4(parse(doc));
   299     if (!ui)
   296     if (!ui)
   300         return;
   297         return;
   301 
   298 
   302     if (pixmapLoaderFunction.size())
   299     if (pixmapLoaderFunction.size())
   303         ui->setElementPixmapFunction(pixmapLoaderFunction);
   300         ui->setElementPixmapFunction(pixmapLoaderFunction);
   313 }
   310 }
   314 
   311 
   315 void Ui3Reader::setTrMacro(const QString &trmacro)
   312 void Ui3Reader::setTrMacro(const QString &trmacro)
   316 {
   313 {
   317     this->trmacro = trmacro;
   314     this->trmacro = trmacro;
   318 }
       
   319 
       
   320 void Ui3Reader::setForwardDeclarationsEnabled(bool b)
       
   321 {
       
   322     nofwd = !b;
       
   323 }
   315 }
   324 
   316 
   325 void Ui3Reader::setOutputFileName(const QString &fileName)
   317 void Ui3Reader::setOutputFileName(const QString &fileName)
   326 {
   318 {
   327     outputFileName = fileName;
   319     outputFileName = fileName;