src/tools/uic3/main.cpp
changeset 7 f7bc934e204c
parent 0 1918ee327afb
child 30 5dc02b23752f
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 **
    76     QByteArray outputFile;
    76     QByteArray outputFile;
    77     QString  qrcOutputFile;
    77     QString  qrcOutputFile;
    78     QByteArray image_tmpfile;
    78     QByteArray image_tmpfile;
    79     const char* projectName = 0;
    79     const char* projectName = 0;
    80     const char* trmacro = 0;
    80     const char* trmacro = 0;
    81     bool nofwd = false;
       
    82     bool fix = false;
    81     bool fix = false;
    83     bool deps = false;
    82     bool deps = false;
    84     bool implicitIncludes = true;
    83     unsigned readerOptions = Ui3Reader::ImplicitIncludes|Ui3Reader::CustomWidgetForwardDeclarations;
    85     QByteArray pchFile;
    84     QByteArray pchFile;
    86 
       
    87 
    85 
    88     QApplication app(argc, argv, false);
    86     QApplication app(argc, argv, false);
    89 
    87 
    90     for (int n = 1; n < argc && error == 0; n++) {
    88     for (int n = 1; n < argc && error == 0; n++) {
    91         QByteArray arg = argv[n];
    89         QByteArray arg = argv[n];
   144                     n += 2;
   142                     n += 2;
   145                 }
   143                 }
   146             } else if (opt == "d") {
   144             } else if (opt == "d") {
   147                 deps = true;
   145                 deps = true;
   148             } else if (opt == "no-implicit-includes") {
   146             } else if (opt == "no-implicit-includes") {
   149                 implicitIncludes = false;
   147                 readerOptions &= ~Ui3Reader::ImplicitIncludes;
   150             } else if (opt == "nofwd") {
   148             } else if (opt == "nofwd") {
   151                 nofwd = true;
   149                 readerOptions &= ~Ui3Reader::CustomWidgetForwardDeclarations;
       
   150             } else if (opt == "layout-names") {
       
   151                 readerOptions |= Ui3Reader::PreserveLayoutNames;
   152             } else if (opt == "nounload") {
   152             } else if (opt == "nounload") {
   153                 // skip
   153                 // skip
   154             } else if (opt == "convert") {
   154             } else if (opt == "convert") {
   155                 convert = true;
   155                 convert = true;
   156             } else if (opt == "subdecl") {
   156             } else if (opt == "subdecl") {
   251                  "Options:\n"
   251                  "Options:\n"
   252                  "\t-o file            Write output to file rather than stdout\n"
   252                  "\t-o file            Write output to file rather than stdout\n"
   253                  "\t-extract qrcFile   Create resource file and extract embedded images into \"image\" dir\n"
   253                  "\t-extract qrcFile   Create resource file and extract embedded images into \"image\" dir\n"
   254                  "\t-pch file          Add #include \"file\" as the first statement in implementation\n"
   254                  "\t-pch file          Add #include \"file\" as the first statement in implementation\n"
   255                  "\t-nofwd             Omit forward declarations of custom classes\n"
   255                  "\t-nofwd             Omit forward declarations of custom classes\n"
       
   256                  "\t-layout-names      Preserve layout names of Qt Designer 3\n"
   256                  "\t-no-implicit-includes Do not generate #include-directives for custom classes\n"
   257                  "\t-no-implicit-includes Do not generate #include-directives for custom classes\n"
   257                  "\t-nounload          Do not unload plugins after processing\n"
   258                  "\t-nounload          Do not unload plugins after processing\n"
   258                  "\t-tr func           Use func() instead of tr() for i18n\n"
   259                  "\t-tr func           Use func() instead of tr() for i18n\n"
   259                  "\t-L path            Additional plugin search path\n"
   260                  "\t-L path            Additional plugin search path\n"
   260                  "\t-version           Display version of uic\n"
   261                  "\t-version           Display version of uic\n"
   287         fileOut.open(QIODevice::WriteOnly, stdout);
   288         fileOut.open(QIODevice::WriteOnly, stdout);
   288     }
   289     }
   289 
   290 
   290     QTextStream out(&fileOut);
   291     QTextStream out(&fileOut);
   291 
   292 
   292     Ui3Reader ui3(out);
   293     Ui3Reader ui3(out, readerOptions);
   293     ui3.setExtractImages(extract, qrcOutputFile);
   294     ui3.setExtractImages(extract, qrcOutputFile);
   294 
       
   295     if (projectName && imagecollection) {
   295     if (projectName && imagecollection) {
   296         out.setEncoding(QTextStream::Latin1);
   296         out.setEncoding(QTextStream::Latin1);
   297         ui3.embed(projectName, images);
   297         ui3.embed(projectName, images);
   298         return 0;
   298         return 0;
   299     }
   299     }
   336         return 0;
   336         return 0;
   337     } else if (deps) {
   337     } else if (deps) {
   338         QStringList globalIncludes, localIncludes;
   338         QStringList globalIncludes, localIncludes;
   339         ui3.computeDeps(e, globalIncludes, localIncludes, impl);
   339         ui3.computeDeps(e, globalIncludes, localIncludes, impl);
   340 
   340 
   341         foreach (QString i, globalIncludes)
   341         foreach (const QString &i, globalIncludes)
   342             printf("%s\n", i.toLatin1().constData());
   342             printf("%s\n", i.toLatin1().constData());
   343 
   343 
   344         foreach (QString i, localIncludes)
   344         foreach (const QString &i, localIncludes)
   345             printf("%s\n", i.toLatin1().constData());
   345             printf("%s\n", i.toLatin1().constData());
   346 
   346 
   347         if (impl)
   347         if (impl)
   348             printf("%s\n", headerFile);
   348             printf("%s\n", headerFile);
   349 
   349 
   350         return 0;
   350         return 0;
   351     } else if (convert) {
   351     } else if (convert) {
   352         ui3.generateUi4(QFile::decodeName(fileName), QFile::decodeName(outputFile), doc, implicitIncludes);
   352         ui3.generateUi4(QFile::decodeName(fileName), QFile::decodeName(outputFile), doc);
   353         return 0;
   353         return 0;
   354     }
   354     }
   355 
   355 
   356     QString protector;
   356     QString protector;
   357     if (subcl && className && !impl)
   357     if (subcl && className && !impl)
   386         doc,
   386         doc,
   387         !impl,
   387         !impl,
   388         subcl,
   388         subcl,
   389         QString::fromUtf8(trmacro),
   389         QString::fromUtf8(trmacro),
   390         QString::fromUtf8(className),
   390         QString::fromUtf8(className),
   391         nofwd,
       
   392         implicitIncludes, 
       
   393         convertedUi);
   391         convertedUi);
   394 
   392 
   395     if (!protector.isEmpty()) {
   393     if (!protector.isEmpty()) {
   396         out << endl;
   394         out << endl;
   397         out << "#endif // " << protector << endl;
   395         out << "#endif // " << protector << endl;