diff options
Diffstat (limited to 'tools')
-rw-r--r-- | tools/configure/configure.pro | 5 | ||||
-rw-r--r-- | tools/configure/configureapp.cpp | 204 | ||||
-rw-r--r-- | tools/designer/src/lib/uilib/abstractformbuilder.cpp | 189 |
3 files changed, 361 insertions, 37 deletions
diff --git a/tools/configure/configure.pro b/tools/configure/configure.pro index 1ce9a1b..b82104e 100644 --- a/tools/configure/configure.pro +++ b/tools/configure/configure.pro @@ -6,7 +6,10 @@ CONFIG -= moc qt DEFINES = QT_NODLL QT_NO_CODECS QT_NO_TEXTCODEC QT_NO_UNICODETABLES QT_LITE_COMPONENT QT_NO_STL QT_NO_COMPRESS QT_BUILD_QMAKE QT_NO_THREAD QT_NO_QOBJECT _CRT_SECURE_NO_DEPRECATE -win32 : LIBS += -lole32 -ladvapi32 +win32 : !win32-mwc : LIBS += -lole32 -ladvapi32 +win32-mwc { + LIBS += -ladvapi32.lib -luuid.lib +} win32-msvc.net | win32-msvc2* : QMAKE_CXXFLAGS += /EHsc win32-g++ : LIBS += -luuid diff --git a/tools/configure/configureapp.cpp b/tools/configure/configureapp.cpp index bcbf557..43201df 100644 --- a/tools/configure/configureapp.cpp +++ b/tools/configure/configureapp.cpp @@ -310,6 +310,7 @@ Configure::Configure( int& argc, char** argv ) dictionary[ "LIBJPEG" ] = "auto"; dictionary[ "LIBPNG" ] = "auto"; dictionary[ "LIBMNG" ] = "auto"; + dictionary[ "FREETYPE" ] = "no"; dictionary[ "QT3SUPPORT" ] = "yes"; dictionary[ "ACCESSIBILITY" ] = "yes"; @@ -328,6 +329,7 @@ Configure::Configure( int& argc, char** argv ) dictionary[ "STYLE_WINDOWSMOBILE" ] = "no"; dictionary[ "STYLE_MOTIF" ] = "yes"; dictionary[ "STYLE_CDE" ] = "yes"; + dictionary[ "STYLE_S60" ] = "no"; dictionary[ "STYLE_GTK" ] = "no"; dictionary[ "SQL_MYSQL" ] = "no"; @@ -580,6 +582,13 @@ void Configure::parseCmdLine() dictionary[ "MNG" ] = "qt"; dictionary[ "LIBMNG" ] = "system"; } + + // Text Rendering -------------------------------------------- + else if( configCmdLine.at(i) == "-no-freetype" ) + dictionary[ "FREETYPE" ] = "no"; + else if( configCmdLine.at(i) == "-qt-freetype" ) + dictionary[ "FREETYPE" ] = "yes"; + // CE- C runtime -------------------------------------------- else if( configCmdLine.at(i) == "-crt" ) { ++i; @@ -659,6 +668,11 @@ void Configure::parseCmdLine() else if( configCmdLine.at(i) == "-no-style-cde" ) dictionary[ "STYLE_CDE" ] = "no"; + else if( configCmdLine.at(i) == "-qt-style-s60" ) + dictionary[ "STYLE_S60" ] = "yes"; + else if( configCmdLine.at(i) == "-no-style-s60" ) + dictionary[ "STYLE_S60" ] = "no"; + // Qt 3 Support --------------------------------------------- else if( configCmdLine.at(i) == "-no-qt3support" ) dictionary[ "QT3SUPPORT" ] = "no"; @@ -769,6 +783,13 @@ void Configure::parseCmdLine() dictionary[ "INCREDIBUILD_XGE" ] = "yes"; #if !defined(EVAL) // Others --------------------------------------------------- + else if (configCmdLine.at(i) == "-fpu" ) + { + ++i; + if(i==argCount) + break; + dictionary[ "ARM_FPU_TYPE" ] = configCmdLine.at(i); + } else if (configCmdLine.at(i) == "-fast" ) dictionary[ "FAST" ] = "yes"; else if (configCmdLine.at(i) == "-no-fast" ) @@ -1095,12 +1116,29 @@ void Configure::parseCmdLine() } else { dictionary[ "QMAKEMAKEFILE" ] = "Makefile.win32-g++"; } + } else if ( dictionary[ "QMAKESPEC" ] == QString( "win32-mwc" ) ) { + dictionary[ "QMAKEMAKEFILE" ] = "Makefile.win32-mwc"; + dictionary[ "MAKE" ] = "make"; } else { if ( dictionary[ "MAKE" ].isEmpty() ) dictionary[ "MAKE" ] = "make"; dictionary[ "QMAKEMAKEFILE" ] = "Makefile.win32"; } } + // Tell the user how to proceed building Qt after configure finished its job + dictionary["QTBUILDINSTRUCTION"] = dictionary["MAKE"]; + if (dictionary.contains("XQMAKESPEC")) { + if (dictionary["XQMAKESPEC"].startsWith("symbian")) { + dictionary["QTBUILDINSTRUCTION"] = dictionary["MAKE"] + QString(" debug-winscw|debug-armv5|release-armv5"); + } else if (dictionary["XQMAKESPEC"].startsWith("wince")) { + dictionary["QTBUILDINSTRUCTION"] = + QString("setcepaths.bat ") + dictionary["XQMAKESPEC"] + QString(" && ") + dictionary["MAKE"]; + } + } + + // Tell the user how to confclean before the next configure + dictionary["CONFCLEANINSTRUCTION"] = dictionary["MAKE"] + QString(" confclean"); + // Ensure that -spec (XQMAKESPEC) exists in the mkspecs folder as well if (dictionary.contains("XQMAKESPEC") && !mkspecs.contains(dictionary["XQMAKESPEC"], Qt::CaseInsensitive)) { @@ -1154,9 +1192,9 @@ void Configure::parseCmdLine() #if !defined(EVAL) void Configure::validateArgs() { - QStringList configs; // Validate the specified config + // Get all possible configurations from the file system. QDir dir; QStringList filters; filters << "qconfig-*.h"; @@ -1170,9 +1208,24 @@ void Configure::validateArgs() allConfigs << it->remove("qconfig-").remove(".h"); allConfigs << "full"; + // Try internal configurations first. + QStringList possible_configs = QStringList() + << "minimal" + << "small" + << "medium" + << "large" + << "full"; + int index = possible_configs.indexOf(dictionary["QCONFIG"]); + if (index >= 0) { + for (int c = 0; c <= index; c++) { + qmakeConfig += possible_configs[c] + "-config"; + } + return; + } + + // If the internal configurations failed, try others. QStringList::Iterator config; for( config = allConfigs.begin(); config != allConfigs.end(); ++config ) { - configs += (*config) + "-config"; if( (*config) == dictionary[ "QCONFIG" ] ) break; } @@ -1181,7 +1234,7 @@ void Configure::validateArgs() cout << "No such configuration \"" << qPrintable(dictionary[ "QCONFIG" ]) << "\"" << endl ; } else - qmakeConfig += configs; + qmakeConfig += (*config) + "-config"; } #endif @@ -1302,6 +1355,8 @@ void Configure::applySpecSpecifics() dictionary[ "STYLE_WINDOWSMOBILE" ] = "yes"; dictionary[ "STYLE_MOTIF" ] = "no"; dictionary[ "STYLE_CDE" ] = "no"; + dictionary[ "STYLE_S60" ] = "no"; + dictionary[ "FREETYPE" ] = "no"; dictionary[ "QT3SUPPORT" ] = "no"; dictionary[ "OPENGL" ] = "no"; dictionary[ "OPENSSL" ] = "no"; @@ -1328,6 +1383,46 @@ void Configure::applySpecSpecifics() dictionary[ "QT_HOST_PREFIX" ] = dictionary[ "QT_INSTALL_PREFIX" ]; dictionary[ "QT_INSTALL_PREFIX" ] = ""; + } else if(dictionary[ "XQMAKESPEC" ].startsWith("symbian")) { + dictionary[ "ACCESSIBILITY" ] = "no"; + dictionary[ "STYLE_WINDOWSXP" ] = "no"; + dictionary[ "STYLE_WINDOWSVISTA" ] = "no"; + dictionary[ "STYLE_PLASTIQUE" ] = "no"; + dictionary[ "STYLE_CLEANLOOKS" ] = "no"; + dictionary[ "STYLE_WINDOWSCE" ] = "no"; + dictionary[ "STYLE_WINDOWSMOBILE" ] = "no"; + dictionary[ "STYLE_MOTIF" ] = "no"; + dictionary[ "STYLE_CDE" ] = "no"; + dictionary[ "STYLE_S60" ] = "yes"; + dictionary[ "FREETYPE" ] = "no"; + dictionary[ "QT3SUPPORT" ] = "no"; + dictionary[ "OPENGL" ] = "no"; + dictionary[ "OPENSSL" ] = "no"; + dictionary[ "STL" ] = "no"; + dictionary[ "EXCEPTIONS" ] = "no"; + dictionary[ "RTTI" ] = "no"; + dictionary[ "ARCHITECTURE" ] = "symbian"; + dictionary[ "3DNOW" ] = "no"; + dictionary[ "SSE" ] = "no"; + dictionary[ "SSE2" ] = "no"; + dictionary[ "MMX" ] = "no"; + dictionary[ "IWMMXT" ] = "no"; + dictionary[ "CE_CRT" ] = "no"; + dictionary[ "DIRECT3D" ] = "no"; + dictionary[ "WEBKIT" ] = "no"; + dictionary[ "ASSISTANT_WEBKIT" ] = "no"; + dictionary[ "PHONON" ] = "no"; + dictionary[ "XMLPATTERNS" ] = "no"; + dictionary[ "QT_GLIB" ] = "no"; + // iconv makes makes apps start and run ridiculously slowly in symbian emulator (HW not tested) + // iconv_open seems to return -1 always, so something is probably missing from the platform. + dictionary[ "QT_ICONV" ] = "no"; + dictionary[ "SCRIPTTOOLS" ] = "no"; + dictionary[ "QT_HOST_PREFIX" ] = dictionary[ "QT_INSTALL_PREFIX" ]; + dictionary[ "QT_INSTALL_PREFIX" ] = ""; + dictionary[ "QT_INSTALL_PLUGINS" ] = "\\resource\\qt\\plugins"; + dictionary[ "ARM_FPU_TYPE" ] = "softvfp"; + } else if(dictionary[ "XQMAKESPEC" ].startsWith("linux")) { //TODO actually wrong. //TODO dictionary[ "STYLE_WINDOWSXP" ] = "no"; @@ -1598,6 +1693,7 @@ bool Configure::displayHelp() "Available values for <arch>:"); desc("ARCHITECTURE","windows", "", " windows", ' '); desc("ARCHITECTURE","windowsce", "", " windowsce", ' '); + desc("ARCHITECTURE","symbian", "", " symbian", ' '); desc("ARCHITECTURE","boundschecker", "", " boundschecker", ' '); desc("ARCHITECTURE","generic", "", " generic\n", ' '); @@ -1612,7 +1708,8 @@ bool Configure::displayHelp() desc("STYLE_MOTIF", "yes", "", " motif", ' '); desc("STYLE_CDE", "yes", "", " cde", ' '); desc("STYLE_WINDOWSCE", "yes", "", " windowsce", ' '); - desc("STYLE_WINDOWSMOBILE" , "yes", "", " windowsmobile\n", ' '); + desc("STYLE_WINDOWSMOBILE" , "yes", "", " windowsmobile", ' '); + desc("STYLE_S60" , "yes", "", " s60\n", ' '); /* We do not support -qconfig on Windows yet @@ -1641,6 +1738,11 @@ bool Configure::displayHelp() desc("OPENGL_ES_2", "no", "-opengl-es-2", "Enable support for OpenGL ES 2.0"); desc("DIRECTSHOW", "no", "-phonon-wince-ds9", "Enable Phonon Direct Show 9 backend for Windows CE"); + // Qt\Symbian only options go below here ----------------------------------------------------------------------------- + desc("Qt for S60 only:\n\n"); + desc("FREETYPE", "no", "-no-freetype", "Do not compile in Freetype2 support."); + desc("FREETYPE", "yes", "-qt-freetype", "Use the libfreetype bundled with Qt.\n"); + desc( "-fpu <flags>", "VFP type on ARM, supported options: softvfp(default) | vfpv2 | softvfp+vfpv2\n"); return true; } return false; @@ -1774,12 +1876,21 @@ bool Configure::checkAvailability(const QString &part) else if (part == "SQL_DB2") available = findFile("sqlcli.h") && findFile("sqlcli1.h") && findFile("db2cli.lib"); else if (part == "SQL_SQLITE") + if (dictionary["XQMAKESPEC"].startsWith("symbian")) + available = false; // In Symbian we only support system sqlite option + else available = true; // Built in, we have a fork else if (part == "SQL_SQLITE_LIB") { if (dictionary[ "SQL_SQLITE_LIB" ] == "system") { - available = findFile("sqlite3.h") && findFile("sqlite3.lib"); - if (available) - dictionary[ "QT_LFLAGS_SQLITE" ] += "sqlite3.lib"; + // Symbian has multiple .lib/.dll files we need to find + if (dictionary["XQMAKESPEC"].startsWith("symbian")) { + available = true; // There is sqlite_symbian plugin which exports the necessary stuff + dictionary[ "QT_LFLAGS_SQLITE" ] += "-lsqlite3"; + } else { + available = findFile("sqlite3.h") && findFile("sqlite3.lib"); + if (available) + dictionary[ "QT_LFLAGS_SQLITE" ] += "sqlite3.lib"; + } } else available = true; } else if (part == "SQL_SQLITE2") @@ -2007,6 +2118,15 @@ bool Configure::verifyConfiguration() if(_getch() == 3) // _Any_ keypress w/no echo(eat <Enter> for stdout) exit(0); // Exit cleanly for Ctrl+C } + if (0 != dictionary["ARM_FPU_TYPE"].size()) + { + QStringList l= QStringList() + << "softvfp" + << "softvfp+vfpv2" + << "vfpv2"; + if (!(l.contains(dictionary["ARM_FPU_TYPE"]))) + cout << QString("WARNING: Using unsupported fpu flag: %1").arg(dictionary["ARM_FPU_TYPE"]) << endl; + } return true; } @@ -2156,6 +2276,10 @@ void Configure::generateOutputVars() if( dictionary[ "LIBMNG" ] == "system" ) qtConfig += "system-mng"; + // Text rendering -------------------------------------------------- + if( dictionary[ "FREETYPE" ] == "yes" ) + qtConfig += "freetype"; + // Styles ------------------------------------------------------- if ( dictionary[ "STYLE_WINDOWS" ] == "yes" ) qmakeStyles += "windows"; @@ -2187,6 +2311,9 @@ void Configure::generateOutputVars() if ( dictionary[ "STYLE_CDE" ] == "yes" ) qmakeStyles += "cde"; + if ( dictionary[ "STYLE_S60" ] == "yes" ) + qmakeStyles += "s60"; + // Databases ---------------------------------------------------- if ( dictionary[ "SQL_MYSQL" ] == "yes" ) qmakeSql += "mysql"; @@ -2340,6 +2467,9 @@ void Configure::generateOutputVars() } } + if (dictionary.contains("XQMAKESPEC") && ( dictionary["QMAKESPEC"] != dictionary["XQMAKESPEC"] ) ) + qmakeConfig += "cross_compile"; + // Directories and settings for .qmake.cache -------------------- // if QT_INSTALL_* have not been specified on commandline, define them now from QT_INSTALL_PREFIX @@ -2380,8 +2510,12 @@ void Configure::generateOutputVars() qmakeVars += QString("INCLUDEPATH += ") + qmakeIncludes.join( " " ); if (!opensslLibs.isEmpty()) qmakeVars += opensslLibs; - else if (dictionary[ "OPENSSL" ] == "linked") - qmakeVars += QString("OPENSSL_LIBS = -lssleay32 -llibeay32"); + else if (dictionary[ "OPENSSL" ] == "linked") { + if(dictionary[ "XQMAKESPEC" ].startsWith("symbian") ) + qmakeVars += QString("OPENSSL_LIBS = -llibssl -llibcrypto"); + else + qmakeVars += QString("OPENSSL_LIBS = -lssleay32 -llibeay32"); + } if (!qmakeSql.isEmpty()) qmakeVars += QString("sql-drivers += ") + qmakeSql.join( " " ); if (!qmakeSqlPlugins.isEmpty()) @@ -2538,7 +2672,12 @@ void Configure::generateCachefile() configStream << "DEFAULT_SIGNATURE=" << dictionary["CE_SIGNATURE"] << endl; if(!dictionary["QMAKE_RPATHDIR"].isEmpty()) - configStream<<"QMAKE_RPATHDIR += "<<dictionary["QMAKE_RPATHDIR"]; + configStream<<"QMAKE_RPATHDIR += "<<dictionary["QMAKE_RPATHDIR"] <<endl; + + if(!dictionary["ARM_FPU_TYPE"].isEmpty()) + { + configStream<<"QMAKE_CXXFLAGS.ARMCC += --fpu "<< dictionary["ARM_FPU_TYPE"]; + } configStream.flush(); configFile.close(); @@ -2579,6 +2718,18 @@ QString Configure::addDefine(QString def) } #if !defined(EVAL) +// ### This should be removed once Qt for S60 is out. +static void applyTemporarySymbianFlags(QStringList &qconfigList) +{ + qconfigList += "QT_NO_CONCURRENT"; + qconfigList += "QT_NO_QFUTURE"; + // This is removed because it uses UNIX signals which are not implemented yet + qconfigList += "QT_NO_CRASHHANDLER"; + qconfigList += "QT_NO_PRINTER"; + qconfigList += "QT_NO_CURSOR"; + qconfigList += "QT_NO_SYSTEMTRAYICON"; +} + void Configure::generateConfigfiles() { QDir(buildPath).mkpath("src/corelib/global"); @@ -2648,6 +2799,7 @@ void Configure::generateConfigfiles() if(dictionary["STYLE_WINDOWSVISTA"] != "yes") qconfigList += "QT_NO_STYLE_WINDOWSVISTA"; if(dictionary["STYLE_MOTIF"] != "yes") qconfigList += "QT_NO_STYLE_MOTIF"; if(dictionary["STYLE_CDE"] != "yes") qconfigList += "QT_NO_STYLE_CDE"; + if(dictionary["STYLE_S60"] != "yes") qconfigList += "QT_NO_STYLE_S60"; if(dictionary["STYLE_WINDOWSCE"] != "yes") qconfigList += "QT_NO_STYLE_WINDOWSCE"; if(dictionary["STYLE_WINDOWSMOBILE"] != "yes") qconfigList += "QT_NO_STYLE_WINDOWSMOBILE"; if(dictionary["STYLE_GTK"] != "yes") qconfigList += "QT_NO_STYLE_GTK"; @@ -2662,7 +2814,6 @@ void Configure::generateConfigfiles() qconfigList += "QT_NO_COMPRESS"; } - if(dictionary["QT3SUPPORT"] == "no") qconfigList += "QT_NO_QT3SUPPORT"; if(dictionary["ACCESSIBILITY"] == "no") qconfigList += "QT_NO_ACCESSIBILITY"; if(dictionary["EXCEPTIONS"] == "no") qconfigList += "QT_NO_EXCEPTIONS"; if(dictionary["OPENGL"] == "no") qconfigList += "QT_NO_OPENGL"; @@ -2696,6 +2847,10 @@ void Configure::generateConfigfiles() if (dictionary["GRAPHICS_SYSTEM"] == "opengl") qconfigList += "QT_GRAPHICSSYSTEM_OPENGL"; if (dictionary["GRAPHICS_SYSTEM"] == "raster") qconfigList += "QT_GRAPHICSSYSTEM_RASTER"; + // ### This block should be removed once Qt for S60 is out. + if (dictionary.contains("XQMAKESPEC") && dictionary["XQMAKESPEC"].startsWith("symbian")) { + applyTemporarySymbianFlags(qconfigList); + } qconfigList.sort(); for (int i = 0; i < qconfigList.count(); ++i) @@ -2942,7 +3097,8 @@ void Configure::displayConfig() cout << " TIFF support............" << dictionary[ "TIFF" ] << endl; cout << " JPEG support............" << dictionary[ "JPEG" ] << endl; cout << " PNG support............." << dictionary[ "PNG" ] << endl; - cout << " MNG support............." << dictionary[ "MNG" ] << endl << endl; + cout << " MNG support............." << dictionary[ "MNG" ] << endl; + cout << " FreeType support........" << dictionary[ "FREETYPE" ] << endl << endl; cout << "Styles:" << endl; cout << " Windows................." << dictionary[ "STYLE_WINDOWS" ] << endl; @@ -2953,7 +3109,8 @@ void Configure::displayConfig() cout << " Motif..................." << dictionary[ "STYLE_MOTIF" ] << endl; cout << " CDE....................." << dictionary[ "STYLE_CDE" ] << endl; cout << " Windows CE.............." << dictionary[ "STYLE_WINDOWSCE" ] << endl; - cout << " Windows Mobile.........." << dictionary[ "STYLE_WINDOWSMOBILE" ] << endl << endl; + cout << " Windows Mobile.........." << dictionary[ "STYLE_WINDOWSMOBILE" ] << endl; + cout << " S60....................." << dictionary[ "STYLE_S60" ] << endl << endl; cout << "Sql Drivers:" << endl; cout << " ODBC...................." << dictionary[ "SQL_ODBC" ] << endl; @@ -3127,8 +3284,10 @@ void Configure::buildHostTools() << "src/tools/bootstrap" << "src/tools/moc" << "src/tools/rcc" - << "src/tools/uic" - << "tools/checksdk"; + << "src/tools/uic"; + + if(dictionary["XQMAKESPEC"].startsWith("wince")) + hostToolsDirs << "tools/checksdk"; if (dictionary[ "CETEST" ] == "yes") hostToolsDirs << "tools/qtestlib/wince/cetest"; @@ -3348,9 +3507,8 @@ void Configure::generateMakefiles() void Configure::showSummary() { - QString make = dictionary[ "MAKE" ]; - cout << endl << endl << "Qt is now configured for building. Just run " << qPrintable(make) << "." << endl; - cout << "To reconfigure, run " << qPrintable(make) << " confclean and configure." << endl << endl; + cout << endl << endl << "Qt is now configured for building. Just run '" << qPrintable(dictionary["QTBUILDINSTRUCTION"]) << "'." << endl + << "To reconfigure, run '" << qPrintable(dictionary["CONFCLEANINSTRUCTION"]) << "' and configure." << endl; } Configure::ProjectType Configure::projectType( const QString& proFileName ) @@ -3466,9 +3624,13 @@ bool Configure::showLicense(QString orgLicenseFile) void Configure::readLicense() { - dictionary[ "PLATFORM NAME" ] = (QFile::exists(dictionary["QT_SOURCE_TREE"] + "/src/corelib/kernel/qfunctions_wince.h") - && (dictionary.value("QMAKESPEC").startsWith("wince") || dictionary.value("XQMAKESPEC").startsWith("wince"))) - ? "Qt for Windows CE" : "Qt for Windows"; + if (QFile::exists(dictionary["QT_SOURCE_TREE"] + "/src/corelib/kernel/qfunctions_wince.h") && + (dictionary.value("QMAKESPEC").startsWith("wince") || dictionary.value("XQMAKESPEC").startsWith("wince"))) + dictionary["PLATFORM NAME"] = "Qt for Windows CE"; + else if (dictionary.value("XQMAKESPEC").startsWith("symbian")) + dictionary["PLATFORM NAME"] = "Qt for S60"; + else + dictionary["PLATFORM NAME"] = "Qt for Windows"; bool openSource = false; if (dictionary["BUILDNOKIA"] == "yes" || dictionary["BUILDTYPE"] == "commercial") { openSource = false; diff --git a/tools/designer/src/lib/uilib/abstractformbuilder.cpp b/tools/designer/src/lib/uilib/abstractformbuilder.cpp index 4dae28e..f819f05 100644 --- a/tools/designer/src/lib/uilib/abstractformbuilder.cpp +++ b/tools/designer/src/lib/uilib/abstractformbuilder.cpp @@ -1701,6 +1701,24 @@ public: }; template<class T> +static void storeItemFlags(const T *item, QList<DomProperty*> *properties) +{ + static const QFormBuilderStrings &strings = QFormBuilderStrings::instance(); + static const Qt::ItemFlags defaultFlags = T().flags(); + static const QMetaEnum itemFlags_enum = metaEnum<QAbstractFormBuilderGadget>("itemFlags"); + + if (item->flags() != defaultFlags) { + DomProperty *p = new DomProperty; + p->setAttributeName(strings.flagsAttribute); + p->setElementSet(QString::fromAscii(itemFlags_enum.valueToKeys(item->flags()))); + properties->append(p); + } +} + +#ifndef Q_CC_RVCT +// RVCT does not accept static inline functions if one argument is templated type +// For this reason all necessary function variants are explicityly written for it. +template<class T> static void storeItemProps(QAbstractFormBuilder *abstractFormBuilder, const T *item, QList<DomProperty*> *properties) { @@ -1726,21 +1744,6 @@ static void storeItemProps(QAbstractFormBuilder *abstractFormBuilder, const T *i } template<class T> -static void storeItemFlags(const T *item, QList<DomProperty*> *properties) -{ - static const QFormBuilderStrings &strings = QFormBuilderStrings::instance(); - static const Qt::ItemFlags defaultFlags = T().flags(); - static const QMetaEnum itemFlags_enum = metaEnum<QAbstractFormBuilderGadget>("itemFlags"); - - if (item->flags() != defaultFlags) { - DomProperty *p = new DomProperty; - p->setAttributeName(strings.flagsAttribute); - p->setElementSet(QString::fromAscii(itemFlags_enum.valueToKeys(item->flags()))); - properties->append(p); - } -} - -template<class T> static void storeItemPropsNFlags(QAbstractFormBuilder *abstractFormBuilder, const T *item, QList<DomProperty*> *properties) { @@ -1793,6 +1796,158 @@ static void loadItemPropsNFlags(QAbstractFormBuilder *abstractFormBuilder, T *it item->setFlags(enumKeysToValue<Qt::ItemFlags>(itemFlags_enum, p->elementSet().toAscii())); } +#else + +static void storeItemProps(QAbstractFormBuilder *abstractFormBuilder, const QTableWidgetItem *item, + QList<DomProperty*> *properties) +{ + static const QFormBuilderStrings &strings = QFormBuilderStrings::instance(); + FriendlyFB * const formBuilder = static_cast<FriendlyFB *>(abstractFormBuilder); + + DomProperty *p; + QVariant v; + + foreach (const QFormBuilderStrings::TextRoleNName &it, strings.itemTextRoles) + if ((p = formBuilder->saveText(it.second, item->data(it.first.second)))) + properties->append(p); + + foreach (const QFormBuilderStrings::RoleNName &it, strings.itemRoles) + if ((v = item->data(it.first)).isValid() && + (p = variantToDomProperty(abstractFormBuilder, + static_cast<const QMetaObject *>(&QAbstractFormBuilderGadget::staticMetaObject), + it.second, v))) + properties->append(p); + + if ((p = formBuilder->saveResource(item->data(Qt::DecorationPropertyRole)))) + properties->append(p); +} + +static void storeItemProps(QAbstractFormBuilder *abstractFormBuilder, const QListWidgetItem *item, + QList<DomProperty*> *properties) +{ + static const QFormBuilderStrings &strings = QFormBuilderStrings::instance(); + FriendlyFB * const formBuilder = static_cast<FriendlyFB *>(abstractFormBuilder); + + DomProperty *p; + QVariant v; + + foreach (const QFormBuilderStrings::TextRoleNName &it, strings.itemTextRoles) + if ((p = formBuilder->saveText(it.second, item->data(it.first.second)))) + properties->append(p); + + foreach (const QFormBuilderStrings::RoleNName &it, strings.itemRoles) + if ((v = item->data(it.first)).isValid() && + (p = variantToDomProperty(abstractFormBuilder, + static_cast<const QMetaObject *>(&QAbstractFormBuilderGadget::staticMetaObject), + it.second, v))) + properties->append(p); + + if ((p = formBuilder->saveResource(item->data(Qt::DecorationPropertyRole)))) + properties->append(p); +} + +static void storeItemPropsNFlags(QAbstractFormBuilder *abstractFormBuilder, const QTableWidgetItem *item, + QList<DomProperty*> *properties) +{ + storeItemProps(abstractFormBuilder, item, properties); + storeItemFlags(item, properties); +} + +static void storeItemPropsNFlags(QAbstractFormBuilder *abstractFormBuilder, const QListWidgetItem *item, + QList<DomProperty*> *properties) +{ + storeItemProps(abstractFormBuilder, item, properties); + storeItemFlags(item, properties); +} + +static void loadItemProps(QAbstractFormBuilder *abstractFormBuilder, QTableWidgetItem *item, + const QHash<QString, DomProperty*> &properties) +{ + static const QFormBuilderStrings &strings = QFormBuilderStrings::instance(); + FriendlyFB * const formBuilder = static_cast<FriendlyFB *>(abstractFormBuilder); + + DomProperty *p; + QVariant v; + + foreach (const QFormBuilderStrings::TextRoleNName &it, strings.itemTextRoles) + if ((p = properties.value(it.second))) { + v = formBuilder->textBuilder()->loadText(p); + QVariant nativeValue = formBuilder->textBuilder()->toNativeValue(v); + item->setData(it.first.first, qVariantValue<QString>(nativeValue)); + item->setData(it.first.second, v); + } + + foreach (const QFormBuilderStrings::RoleNName &it, strings.itemRoles) + if ((p = properties.value(it.second)) && + (v = formBuilder->toVariant(&QAbstractFormBuilderGadget::staticMetaObject, p)).isValid()) + item->setData(it.first, v); + + if ((p = properties.value(strings.iconAttribute))) { + v = formBuilder->resourceBuilder()->loadResource(formBuilder->workingDirectory(), p); + QVariant nativeValue = formBuilder->resourceBuilder()->toNativeValue(v); + item->setIcon(qVariantValue<QIcon>(nativeValue)); + item->setData(Qt::DecorationPropertyRole, v); + } +} + +static void loadItemProps(QAbstractFormBuilder *abstractFormBuilder, QListWidgetItem *item, + const QHash<QString, DomProperty*> &properties) +{ + static const QFormBuilderStrings &strings = QFormBuilderStrings::instance(); + FriendlyFB * const formBuilder = static_cast<FriendlyFB *>(abstractFormBuilder); + + DomProperty *p; + QVariant v; + + foreach (const QFormBuilderStrings::TextRoleNName &it, strings.itemTextRoles) + if ((p = properties.value(it.second))) { + v = formBuilder->textBuilder()->loadText(p); + QVariant nativeValue = formBuilder->textBuilder()->toNativeValue(v); + item->setData(it.first.first, qVariantValue<QString>(nativeValue)); + item->setData(it.first.second, v); + } + + foreach (const QFormBuilderStrings::RoleNName &it, strings.itemRoles) + if ((p = properties.value(it.second)) && + (v = formBuilder->toVariant(&QAbstractFormBuilderGadget::staticMetaObject, p)).isValid()) + item->setData(it.first, v); + + if ((p = properties.value(strings.iconAttribute))) { + v = formBuilder->resourceBuilder()->loadResource(formBuilder->workingDirectory(), p); + QVariant nativeValue = formBuilder->resourceBuilder()->toNativeValue(v); + item->setIcon(qVariantValue<QIcon>(nativeValue)); + item->setData(Qt::DecorationPropertyRole, v); + } +} + +static void loadItemPropsNFlags(QAbstractFormBuilder *abstractFormBuilder, QTableWidgetItem *item, + const QHash<QString, DomProperty*> &properties) +{ + static const QFormBuilderStrings &strings = QFormBuilderStrings::instance(); + static const QMetaEnum itemFlags_enum = metaEnum<QAbstractFormBuilderGadget>("itemFlags"); + + loadItemProps(abstractFormBuilder, item, properties); + + DomProperty *p; + if ((p = properties.value(strings.flagsAttribute)) && p->kind() == DomProperty::Set) + item->setFlags(enumKeysToValue<Qt::ItemFlags>(itemFlags_enum, p->elementSet().toAscii())); +} + +static void loadItemPropsNFlags(QAbstractFormBuilder *abstractFormBuilder, QListWidgetItem *item, + const QHash<QString, DomProperty*> &properties) +{ + static const QFormBuilderStrings &strings = QFormBuilderStrings::instance(); + static const QMetaEnum itemFlags_enum = metaEnum<QAbstractFormBuilderGadget>("itemFlags"); + + loadItemProps(abstractFormBuilder, item, properties); + + DomProperty *p; + if ((p = properties.value(strings.flagsAttribute)) && p->kind() == DomProperty::Set) + item->setFlags(enumKeysToValue<Qt::ItemFlags>(itemFlags_enum, p->elementSet().toAscii())); +} + +#endif + /*! \internal */ @@ -2145,7 +2300,11 @@ void QAbstractFormBuilder::loadListWidgetExtraInfo(DomWidget *ui_widget, QListWi foreach (DomItem *ui_item, ui_widget->elementItem()) { const DomPropertyHash properties = propertyMap(ui_item->elementProperty()); QListWidgetItem *item = new QListWidgetItem(listWidget); +#ifndef Q_CC_RVCT loadItemPropsNFlags<QListWidgetItem>(this, item, properties); +#else + loadItemPropsNFlags(this, item, properties); +#endif } DomProperty *currentRow = propertyMap(ui_widget->elementProperty()).value(strings.currentRowProperty); |