diff options
Diffstat (limited to 'src/tools')
-rw-r--r-- | src/tools/androiddeployqt/main.cpp | 43 | ||||
-rw-r--r-- | src/tools/bootstrap/bootstrap.pro | 4 | ||||
-rw-r--r-- | src/tools/moc/generator.cpp | 38 | ||||
-rw-r--r-- | src/tools/moc/moc.h | 1 | ||||
-rw-r--r-- | src/tools/rcc/main.cpp | 18 | ||||
-rw-r--r-- | src/tools/rcc/rcc.cpp | 18 | ||||
-rw-r--r-- | src/tools/rcc/rcc.h | 4 | ||||
-rw-r--r-- | src/tools/tracegen/lttng.cpp | 4 | ||||
-rw-r--r-- | src/tools/tracegen/provider.cpp | 39 | ||||
-rw-r--r-- | src/tools/tracegen/provider.h | 2 | ||||
-rw-r--r-- | src/tools/uic/cpp/cppwritedeclaration.cpp | 19 | ||||
-rw-r--r-- | src/tools/uic/cpp/cppwriteinitialization.cpp | 195 | ||||
-rw-r--r-- | src/tools/uic/cpp/cppwriteinitialization.h | 10 | ||||
-rw-r--r-- | src/tools/uic/customwidgetsinfo.cpp | 4 | ||||
-rw-r--r-- | src/tools/uic/driver.cpp | 4 | ||||
-rw-r--r-- | src/tools/uic/driver.h | 1 | ||||
-rw-r--r-- | src/tools/uic/main.cpp | 6 | ||||
-rw-r--r-- | src/tools/uic/option.h | 2 | ||||
-rw-r--r-- | src/tools/uic/treewalker.h | 2 | ||||
-rw-r--r-- | src/tools/uic/ui4.cpp | 755 | ||||
-rw-r--r-- | src/tools/uic/uic.cpp | 4 | ||||
-rw-r--r-- | src/tools/uic/uic.h | 1 | ||||
-rw-r--r-- | src/tools/uic/utils.h | 26 |
23 files changed, 576 insertions, 624 deletions
diff --git a/src/tools/androiddeployqt/main.cpp b/src/tools/androiddeployqt/main.cpp index 57714fc687..29681bf5ce 100644 --- a/src/tools/androiddeployqt/main.cpp +++ b/src/tools/androiddeployqt/main.cpp @@ -137,6 +137,7 @@ struct Options // Build paths QString qtInstallDirectory; + std::vector<QString> extraPrefixDirs; QString androidSourceDirectory; QString outputDirectory; QString inputFileName; @@ -730,6 +731,14 @@ bool readInputFile(Options *options) } { + const auto extraPrefixDirs = jsonObject.value(QLatin1String("extraPrefixDirs")).toArray(); + options->extraPrefixDirs.reserve(extraPrefixDirs.size()); + for (const auto &prefix : extraPrefixDirs) { + options->extraPrefixDirs.push_back(prefix.toString()); + } + } + + { const QJsonValue androidSourcesDirectory = jsonObject.value(QStringLiteral("android-package-source-directory")); if (!androidSourcesDirectory.isUndefined()) options->androidSourceDirectory = androidSourcesDirectory.toString(); @@ -1287,6 +1296,9 @@ bool updateAndroidManifest(Options &options) } } + options.localJars.removeDuplicates(); + options.initClasses.removeDuplicates(); + QHash<QString, QString> replacements; replacements[QLatin1String("-- %%INSERT_APP_NAME%% --")] = QFileInfo(options.applicationBinary).baseName().mid(sizeof("lib") - 1); replacements[QLatin1String("-- %%INSERT_APP_LIB_NAME%% --")] = QFileInfo(options.applicationBinary).baseName().mid(sizeof("lib") - 1); @@ -1380,6 +1392,16 @@ bool updateAndroidFiles(Options &options) return true; } +static QString absoluteFilePath(const Options *options, const QString &relativeFileName) +{ + for (const auto &prefix : options->extraPrefixDirs) { + const QString path = prefix + QLatin1Char('/') + relativeFileName; + if (QFile::exists(path)) + return path; + } + return options->qtInstallDirectory + QLatin1Char('/') + relativeFileName; +} + QList<QtDependency> findFilesRecursively(const Options &options, const QFileInfo &info, const QString &rootPath) { if (!info.exists()) @@ -1404,6 +1426,11 @@ QList<QtDependency> findFilesRecursively(const Options &options, const QFileInfo QList<QtDependency> findFilesRecursively(const Options &options, const QString &fileName) { + for (const auto &prefix : options.extraPrefixDirs) { + QFileInfo info(prefix + QLatin1Char('/') + fileName); + if (info.exists()) + return findFilesRecursively(options, info, prefix + QLatin1Char('/')); + } QFileInfo info(options.qtInstallDirectory + QLatin1Char('/') + fileName); return findFilesRecursively(options, info, options.qtInstallDirectory + QLatin1Char('/')); } @@ -1413,7 +1440,7 @@ bool readAndroidDependencyXml(Options *options, QSet<QString> *usedDependencies, QSet<QString> *remainingDependencies) { - QString androidDependencyName = options->qtInstallDirectory + QString::fromLatin1("/lib/%1-android-dependencies.xml").arg(moduleName); + QString androidDependencyName = absoluteFilePath(options, QString::fromLatin1("/lib/%1-android-dependencies.xml").arg(moduleName)); QFile androidDependencyFile(androidDependencyName); if (androidDependencyFile.exists()) { @@ -1458,7 +1485,7 @@ bool readAndroidDependencyXml(Options *options, int bundling = reader.attributes().value(QLatin1String("bundling")).toInt(); QString fileName = reader.attributes().value(QLatin1String("file")).toString(); if (bundling == (options->deploymentMechanism == Options::Bundled)) { - QtDependency dependency(fileName, options->qtInstallDirectory + QLatin1Char('/') + fileName); + QtDependency dependency(fileName, absoluteFilePath(options, fileName)); if (!usedDependencies->contains(dependency.absolutePath)) { options->qtDependencies.append(dependency); usedDependencies->insert(dependency.absolutePath); @@ -1545,7 +1572,7 @@ QStringList getQtLibsFromElf(const Options &options, const QString &fileName) if (line.contains("(NEEDED)") && line.contains("Shared library:") ) { const int pos = line.lastIndexOf('[') + 1; QString libraryName = QLatin1String("lib/") + QString::fromLatin1(line.mid(pos, line.length() - pos - 2)); - if (QFile::exists(options.qtInstallDirectory + QLatin1Char('/') + libraryName)) { + if (QFile::exists(absoluteFilePath(&options, libraryName))) { ret += libraryName; } @@ -1576,7 +1603,7 @@ bool readDependenciesFromElf(Options *options, if (usedDependencies->contains(dependency)) continue; - QString absoluteDependencyPath(options->qtInstallDirectory + QLatin1Char('/') + dependency); + QString absoluteDependencyPath = absoluteFilePath(options, dependency); usedDependencies->insert(dependency); if (!readDependenciesFromElf(options, absoluteDependencyPath, @@ -1763,11 +1790,9 @@ bool readDependencies(Options *options) if (!readDependenciesFromElf(options, options->qtInstallDirectory + QLatin1String("/plugins/platforms/android/libqtforandroid.so"), &usedDependencies, &remainingDependencies)) return false; - QString qtDir = options->qtInstallDirectory + QLatin1Char('/'); - while (!remainingDependencies.isEmpty()) { QSet<QString>::iterator start = remainingDependencies.begin(); - QString fileName = qtDir + *start; + QString fileName = absoluteFilePath(options, *start); remainingDependencies.erase(start); QStringList unmetDependencies; @@ -1785,7 +1810,7 @@ bool readDependencies(Options *options) QStringList::iterator it = options->localLibs.begin(); while (it != options->localLibs.end()) { QStringList unmetDependencies; - if (!goodToCopy(options, qtDir + *it, &unmetDependencies)) { + if (!goodToCopy(options, absoluteFilePath(options, *it), &unmetDependencies)) { fprintf(stdout, "Skipping %s due to unmet dependencies: %s\n", qPrintable(*it), qPrintable(unmetDependencies.join(QLatin1Char(',')))); @@ -1922,7 +1947,7 @@ bool goodToCopy(const Options *options, const QString &file, QStringList *unmetD bool ret = true; const auto libs = getQtLibsFromElf(*options, file); for (const QString &lib : libs) { - if (!options->qtDependencies.contains(QtDependency(lib, options->qtInstallDirectory + QLatin1Char('/') + lib))) { + if (!options->qtDependencies.contains(QtDependency(lib, absoluteFilePath(options, lib)))) { ret = false; unmetDependencies->append(lib); } diff --git a/src/tools/bootstrap/bootstrap.pro b/src/tools/bootstrap/bootstrap.pro index a45382106a..83e44ff9a4 100644 --- a/src/tools/bootstrap/bootstrap.pro +++ b/src/tools/bootstrap/bootstrap.pro @@ -2,7 +2,7 @@ option(host_build) TARGET = QtBootstrap QT = -CONFIG += minimal_syncqt internal_module force_bootstrap +CONFIG += minimal_syncqt internal_module force_bootstrap gc_binaries MODULE_INCNAME = QtCore QtXml MODULE_DEFINES = \ @@ -12,6 +12,7 @@ MODULE_DEFINES = \ QT_VERSION_PATCH=$$QT_PATCH_VERSION \ QT_BOOTSTRAPPED \ QT_NO_CAST_TO_ASCII +MODULE_CONFIG = gc_binaries DEFINES += \ $$MODULE_DEFINES \ @@ -24,6 +25,7 @@ SOURCES += \ ../../corelib/codecs/qlatincodec.cpp \ ../../corelib/codecs/qtextcodec.cpp \ ../../corelib/codecs/qutfcodec.cpp \ + ../../corelib/global/qendian.cpp \ ../../corelib/global/qglobal.cpp \ ../../corelib/global/qlogging.cpp \ ../../corelib/global/qmalloc.cpp \ diff --git a/src/tools/moc/generator.cpp b/src/tools/moc/generator.cpp index d299cdad51..a3ef1147d6 100644 --- a/src/tools/moc/generator.cpp +++ b/src/tools/moc/generator.cpp @@ -200,6 +200,7 @@ void Generator::generateCode() if (cdef->enumDeclarations.contains(def.name)) { enumList += def; } + def.enumName = def.name; QByteArray alias = cdef->flagAliases.value(def.name); if (cdef->enumDeclarations.contains(alias)) { def.name = alias; @@ -369,7 +370,7 @@ void Generator::generateCode() int enumsIndex = index; for (int i = 0; i < cdef->enumList.count(); ++i) - index += 4 + (cdef->enumList.at(i).values.count() * 2); + index += 5 + (cdef->enumList.at(i).values.count() * 2); fprintf(out, " %4d, %4d, // constructors\n", isConstructible ? cdef->constructorList.count() : 0, isConstructible ? index : 0); @@ -523,29 +524,29 @@ void Generator::generateCode() // Finally create and initialize the static meta object // if (isQt) - fprintf(out, "QT_INIT_METAOBJECT const QMetaObject QObject::staticQtMetaObject = {\n"); + fprintf(out, "QT_INIT_METAOBJECT const QMetaObject QObject::staticQtMetaObject = { {\n"); else - fprintf(out, "QT_INIT_METAOBJECT const QMetaObject %s::staticMetaObject = {\n", cdef->qualified.constData()); + fprintf(out, "QT_INIT_METAOBJECT const QMetaObject %s::staticMetaObject = { {\n", cdef->qualified.constData()); if (isQObject) - fprintf(out, " { nullptr, "); + fprintf(out, " nullptr,\n"); else if (cdef->superclassList.size() && (!cdef->hasQGadget || knownGadgets.contains(purestSuperClass))) - fprintf(out, " { &%s::staticMetaObject, ", purestSuperClass.constData()); + fprintf(out, " &%s::staticMetaObject,\n", purestSuperClass.constData()); else - fprintf(out, " { nullptr, "); - fprintf(out, "qt_meta_stringdata_%s.data,\n" - " qt_meta_data_%s, ", qualifiedClassNameIdentifier.constData(), + fprintf(out, " nullptr,\n"); + fprintf(out, " qt_meta_stringdata_%s.data,\n" + " qt_meta_data_%s,\n", qualifiedClassNameIdentifier.constData(), qualifiedClassNameIdentifier.constData()); if (hasStaticMetaCall) - fprintf(out, " qt_static_metacall, "); + fprintf(out, " qt_static_metacall,\n"); else - fprintf(out, " nullptr, "); + fprintf(out, " nullptr,\n"); if (extraList.isEmpty()) - fprintf(out, "nullptr, "); + fprintf(out, " nullptr,\n"); else - fprintf(out, "qt_meta_extradata_%s, ", qualifiedClassNameIdentifier.constData()); - fprintf(out, "nullptr}\n};\n\n"); + fprintf(out, " qt_meta_extradata_%s,\n", qualifiedClassNameIdentifier.constData()); + fprintf(out, " nullptr\n} };\n\n"); if(isQt) return; @@ -887,6 +888,8 @@ void Generator::registerEnumStrings() for (int i = 0; i < cdef->enumList.count(); ++i) { const EnumDef &e = cdef->enumList.at(i); strreg(e.name); + if (!e.enumName.isNull()) + strreg(e.enumName); for (int j = 0; j < e.values.count(); ++j) strreg(e.values.at(j)); } @@ -897,8 +900,8 @@ void Generator::generateEnums(int index) if (cdef->enumDeclarations.isEmpty()) return; - fprintf(out, "\n // enums: name, flags, count, data\n"); - index += 4 * cdef->enumList.count(); + fprintf(out, "\n // enums: name, alias, flags, count, data\n"); + index += 5 * cdef->enumList.count(); int i; for (i = 0; i < cdef->enumList.count(); ++i) { const EnumDef &e = cdef->enumList.at(i); @@ -907,8 +910,9 @@ void Generator::generateEnums(int index) flags |= EnumIsFlag; if (e.isEnumClass) flags |= EnumIsScoped; - fprintf(out, " %4d, 0x%.1x, %4d, %4d,\n", + fprintf(out, " %4d, %4d, 0x%.1x, %4d, %4d,\n", stridx(e.name), + e.enumName.isNull() ? stridx(e.name) : stridx(e.enumName), flags, e.values.count(), index); @@ -922,7 +926,7 @@ void Generator::generateEnums(int index) const QByteArray &val = e.values.at(j); QByteArray code = cdef->qualified.constData(); if (e.isEnumClass) - code += "::" + e.name; + code += "::" + (e.enumName.isNull() ? e.name : e.enumName); code += "::" + val; fprintf(out, " %4d, uint(%s),\n", stridx(val), code.constData()); diff --git a/src/tools/moc/moc.h b/src/tools/moc/moc.h index 5f8cdfcf2c..56763c5e59 100644 --- a/src/tools/moc/moc.h +++ b/src/tools/moc/moc.h @@ -64,6 +64,7 @@ Q_DECLARE_TYPEINFO(Type, Q_MOVABLE_TYPE); struct EnumDef { QByteArray name; + QByteArray enumName; QList<QByteArray> values; bool isEnumClass; // c++11 enum class EnumDef() : isEnumClass(false) {} diff --git a/src/tools/rcc/main.cpp b/src/tools/rcc/main.cpp index fba47b74c3..12f986b1e2 100644 --- a/src/tools/rcc/main.cpp +++ b/src/tools/rcc/main.cpp @@ -151,6 +151,10 @@ int runRcc(int argc, char *argv[]) QCommandLineOption listOption(QStringLiteral("list"), QStringLiteral("Only list .qrc file entries, do not generate code.")); parser.addOption(listOption); + QCommandLineOption mapOption(QStringLiteral("list-mapping"), + QStringLiteral("Only output a mapping of resource paths to file system paths defined in the .qrc file, do not generate code.")); + parser.addOption(mapOption); + QCommandLineOption projectOption(QStringLiteral("project"), QStringLiteral("Output a resource file containing all files from the current directory.")); parser.addOption(projectOption); @@ -207,6 +211,7 @@ int runRcc(int argc, char *argv[]) library.setVerbose(true); const bool list = parser.isSet(listOption); + const bool map = parser.isSet(mapOption); const bool projectRequested = parser.isSet(projectOption); const QStringList filenamesIn = parser.positionalArguments(); @@ -242,7 +247,7 @@ int runRcc(int argc, char *argv[]) library.setInputFiles(filenamesIn); - if (!library.readFiles(list, errorDevice)) + if (!library.readFiles(list || map, errorDevice)) return 1; QFile out; @@ -294,6 +299,17 @@ int runRcc(int argc, char *argv[]) return 0; } + if (map) { + const RCCResourceLibrary::ResourceDataFileMap data = library.resourceDataFileMap(); + for (auto it = data.begin(), end = data.end(); it != end; ++it) { + out.write(qPrintable(it.key())); + out.write("\t"); + out.write(qPrintable(QDir::cleanPath(it.value()))); + out.write("\n"); + } + return 0; + } + QFile temp; if (!tempFilename.isEmpty()) { temp.setFileName(tempFilename); diff --git a/src/tools/rcc/rcc.cpp b/src/tools/rcc/rcc.cpp index 4c7d095ca3..1a7cab01df 100644 --- a/src/tools/rcc/rcc.cpp +++ b/src/tools/rcc/rcc.cpp @@ -377,7 +377,7 @@ enum RCCXmlTag { Q_DECLARE_TYPEINFO(RCCXmlTag, Q_PRIMITIVE_TYPE); bool RCCResourceLibrary::interpretResourceFile(QIODevice *inputDevice, - const QString &fname, QString currentPath, bool ignoreErrors) + const QString &fname, QString currentPath, bool listMode) { Q_ASSERT(m_errorDevice); const QChar slash = QLatin1Char('/'); @@ -527,7 +527,7 @@ bool RCCResourceLibrary::interpretResourceFile(QIODevice *inputDevice, m_failedResources.push_back(child.fileName()); } } - } else if (file.isFile()) { + } else if (listMode || file.isFile()) { const bool arc = addFile(alias, RCCFileInfo(alias.section(slash, -1), @@ -551,8 +551,6 @@ bool RCCResourceLibrary::interpretResourceFile(QIODevice *inputDevice, const QString msg = QString::fromLatin1("RCC: Error in '%1': Cannot find file '%2'\n") .arg(fname, fileName); m_errorDevice->write(msg.toUtf8()); - if (ignoreErrors) - continue; return false; } } @@ -564,8 +562,6 @@ bool RCCResourceLibrary::interpretResourceFile(QIODevice *inputDevice, } if (reader.hasError()) { - if (ignoreErrors) - return true; int errorLine = reader.lineNumber(); int errorColumn = reader.columnNumber(); QString errorMessage = reader.errorString(); @@ -577,7 +573,7 @@ bool RCCResourceLibrary::interpretResourceFile(QIODevice *inputDevice, if (m_root == 0) { const QString msg = QString::fromLatin1("RCC: Warning: No resources in '%1'.\n").arg(fname); m_errorDevice->write(msg.toUtf8()); - if (!ignoreErrors && m_format == Binary) { + if (!listMode && m_format == Binary) { // create dummy entry, otherwise loading with QResource will crash m_root = new RCCFileInfo(QString(), QFileInfo(), QLocale::C, QLocale::AnyCountry, RCCFileInfo::Directory); @@ -645,14 +641,14 @@ void RCCResourceLibrary::reset() } -bool RCCResourceLibrary::readFiles(bool ignoreErrors, QIODevice &errorDevice) +bool RCCResourceLibrary::readFiles(bool listMode, QIODevice &errorDevice) { reset(); m_errorDevice = &errorDevice; //read in data if (m_verbose) { - const QString msg = QString::fromLatin1("Processing %1 files [%2]\n") - .arg(m_fileNames.size()).arg(static_cast<int>(ignoreErrors)); + const QString msg = QString::fromLatin1("Processing %1 files [listMode=%2]\n") + .arg(m_fileNames.size()).arg(static_cast<int>(listMode)); m_errorDevice->write(msg.toUtf8()); } for (int i = 0; i < m_fileNames.size(); ++i) { @@ -680,7 +676,7 @@ bool RCCResourceLibrary::readFiles(bool ignoreErrors, QIODevice &errorDevice) m_errorDevice->write(msg.toUtf8()); } - if (!interpretResourceFile(&fileIn, fname, pwd, ignoreErrors)) + if (!interpretResourceFile(&fileIn, fname, pwd, listMode)) return false; } return true; diff --git a/src/tools/rcc/rcc.h b/src/tools/rcc/rcc.h index 19e04e401d..36984cf38a 100644 --- a/src/tools/rcc/rcc.h +++ b/src/tools/rcc/rcc.h @@ -53,7 +53,7 @@ public: bool output(QIODevice &outDevice, QIODevice &tempDevice, QIODevice &errorDevice); - bool readFiles(bool ignoreErrors, QIODevice &errorDevice); + bool readFiles(bool listMode, QIODevice &errorDevice); enum Format { Binary, C_Code, Pass1, Pass2 }; void setFormat(Format f) { m_format = f; } @@ -109,7 +109,7 @@ private: void reset(); bool addFile(const QString &alias, const RCCFileInfo &file); bool interpretResourceFile(QIODevice *inputDevice, const QString &file, - QString currentPath = QString(), bool ignoreErrors = false); + QString currentPath = QString(), bool listMode = false); bool writeHeader(); bool writeDataBlobs(); bool writeDataNames(); diff --git a/src/tools/tracegen/lttng.cpp b/src/tools/tracegen/lttng.cpp index 6c0d8cc88b..5d41bf5f1f 100644 --- a/src/tools/tracegen/lttng.cpp +++ b/src/tools/tracegen/lttng.cpp @@ -69,6 +69,10 @@ static void writeCtfMacro(QTextStream &stream, const Tracepoint::Field &field) case Tracepoint::Field::Integer: stream << "ctf_integer(" << paramType << ", " << name << ", " << name << ")"; return; + case Tracepoint::Field::IntegerHex: + case Tracepoint::Field::Pointer: + stream << "ctf_integer_hex(" << paramType << ", " << name << ", " << name << ")"; + return; case Tracepoint::Field::Float: stream << "ctf_float(" << paramType << ", " << name << ", " << name << ")"; return; diff --git a/src/tools/tracegen/provider.cpp b/src/tools/tracegen/provider.cpp index 00e105377e..a6523a2e3d 100644 --- a/src/tools/tracegen/provider.cpp +++ b/src/tools/tracegen/provider.cpp @@ -157,10 +157,13 @@ static Tracepoint::Field::BackendType backendType(QString rawType) { "signed_long_long_int", Tracepoint::Field::Integer }, { "unsigned_long_long", Tracepoint::Field::Integer }, { "char", Tracepoint::Field::Integer }, + { "intptr_t", Tracepoint::Field::IntegerHex }, + { "uintptr_t", Tracepoint::Field::IntegerHex }, + { "std::intptr_t", Tracepoint::Field::IntegerHex }, + { "std::uintptr_t", Tracepoint::Field::IntegerHex }, { "float", Tracepoint::Field::Float }, { "double", Tracepoint::Field::Float }, { "long_double", Tracepoint::Field::Float }, - { "char_ptr", Tracepoint::Field::String }, { "QString", Tracepoint::Field::QtString }, { "QByteArray", Tracepoint::Field::QtByteArray }, { "QUrl", Tracepoint::Field::QtUrl }, @@ -168,7 +171,6 @@ static Tracepoint::Field::BackendType backendType(QString rawType) }; auto backendType = [](const QString &rawType) { - static const size_t tableSize = sizeof (typeTable) / sizeof (typeTable[0]); for (size_t i = 0; i < tableSize; ++i) { @@ -194,7 +196,13 @@ static Tracepoint::Field::BackendType backendType(QString rawType) rawType = rawType.trimmed(); rawType.replace(QStringLiteral(" "), QStringLiteral("_")); - return backendType(rawType.trimmed()); + if (rawType == QLatin1String("char_ptr")) + return Tracepoint::Field::String; + + if (rawType.endsWith(QLatin1String("_ptr"))) + return Tracepoint::Field::Pointer; + + return backendType(rawType); } static Tracepoint parseTracepoint(const QString &name, const QStringList &args, @@ -264,35 +272,28 @@ Provider parseProvider(const QString &filename) static const QRegExp tracedef(QStringLiteral("([A-Za-z][A-Za-z0-9_]*)\\((.*)\\)")); - int lineNumber = 0; - Provider provider; provider.name = QFileInfo(filename).baseName(); - for (;;) { + for (int lineNumber = 1; !s.atEnd(); ++lineNumber) { QString line = s.readLine().trimmed(); - if (line.isNull()) - break; - - if (line.isEmpty() || line.startsWith(QStringLiteral("#"))) { - ++lineNumber; + if (line.isEmpty() || line.startsWith(QLatin1Char('#'))) continue; - } if (tracedef.exactMatch(line)) { const QString name = tracedef.cap(1); - QStringList args = tracedef.cap(2).split(QStringLiteral(","), QString::SkipEmptyParts); - - if (args.at(0).isNull()) - args.clear(); + const QString argsString = tracedef.cap(2); + const QStringList args = argsString.split(QLatin1Char(','), + QString::SkipEmptyParts); provider.tracepoints << parseTracepoint(name, args, filename, lineNumber); } else { - panic("Syntax error whilre processing %s on line %d", qPrintable(filename), lineNumber); + panic("Syntax error while processing '%s' line %d:\n" + " '%s' does not look like a tracepoint definition", + qPrintable(filename), lineNumber, + qPrintable(line)); } - - ++lineNumber; } #ifdef TRACEGEN_DEBUG diff --git a/src/tools/tracegen/provider.h b/src/tools/tracegen/provider.h index d8cbd2662d..9771e62f4d 100644 --- a/src/tools/tracegen/provider.h +++ b/src/tools/tracegen/provider.h @@ -59,8 +59,10 @@ struct Tracepoint Array, Sequence, Integer, + IntegerHex, Float, String, + Pointer, QtString, QtByteArray, QtUrl, diff --git a/src/tools/uic/cpp/cppwritedeclaration.cpp b/src/tools/uic/cpp/cppwritedeclaration.cpp index 9e774ad07b..995b99b692 100644 --- a/src/tools/uic/cpp/cppwritedeclaration.cpp +++ b/src/tools/uic/cpp/cppwritedeclaration.cpp @@ -40,10 +40,11 @@ QT_BEGIN_NAMESPACE namespace { - void openNameSpaces(const QStringList &namespaceList, QTextStream &output) { - for (auto it = namespaceList.begin(), end = namespaceList.end(); it != end; ++it) { - if (!it->isEmpty()) - output << "namespace " << *it << " {\n"; + void openNameSpaces(const QStringList &namespaceList, QTextStream &output) + { + for (const QString &n : namespaceList) { + if (!n.isEmpty()) + output << "namespace " << n << " {\n"; } } @@ -103,13 +104,9 @@ void WriteDeclaration::acceptUI(DomUI *node) << "public:\n"; const QStringList connections = m_uic->databaseInfo()->connections(); - for (int i=0; i<connections.size(); ++i) { - const QString connection = connections.at(i); - - if (connection == QLatin1String("(default)")) - continue; - - m_output << m_option.indent << "QSqlDatabase " << connection << "Connection;\n"; + for (const QString &connection : connections) { + if (connection != QLatin1String("(default)")) + m_output << m_option.indent << "QSqlDatabase " << connection << "Connection;\n"; } TreeWalker::acceptWidget(node->elementWidget()); diff --git a/src/tools/uic/cpp/cppwriteinitialization.cpp b/src/tools/uic/cpp/cppwriteinitialization.cpp index 9ab5fd4eb0..e6d90540b3 100644 --- a/src/tools/uic/cpp/cppwriteinitialization.cpp +++ b/src/tools/uic/cpp/cppwriteinitialization.cpp @@ -475,21 +475,6 @@ WriteInitialization::WriteInitialization(Uic *uic) : { } -QString WriteInitialization::writeString(const QString &s, const QString &indent) const -{ - unsigned flags = 0; - const QString ret = fixString(s, indent, &flags); - if (flags & Utf8String) - return QLatin1String("QString::fromUtf8(") + ret + QLatin1Char(')'); - // MSVC cannot concat L"foo" "bar" (C2308: concatenating mismatched strings), - // use QLatin1String instead (all platforms to avoid cross-compiling issues). - if (flags & MultiLineString) - return QLatin1String("QLatin1String(") + ret + QLatin1Char(')'); - const QLatin1String stringWrapper = m_uic->option().stringLiteral ? - QLatin1String("QStringLiteral(") : QLatin1String("QLatin1String("); - return stringWrapper + ret + QLatin1Char(')'); -} - void WriteInitialization::acceptUI(DomUI *node) { m_actionGroupChain.push(0); @@ -529,16 +514,14 @@ void WriteInitialization::acceptUI(DomUI *node) continue; const QString varConn = connection + QLatin1String("Connection"); - m_output << m_indent << varConn << " = QSqlDatabase::database(" << writeString(connection, m_dindent) << ");\n"; + m_output << m_indent << varConn << " = QSqlDatabase::database(" << fixString(connection, m_dindent) << ");\n"; } acceptWidget(node->elementWidget()); - if (m_buddies.size() > 0) + if (!m_buddies.empty()) openIfndef(m_output, QLatin1String(shortcutDefineC)); - for (int i=0; i<m_buddies.size(); ++i) { - const Buddy &b = m_buddies.at(i); - + for (const Buddy &b : qAsConst(m_buddies)) { if (!m_registeredWidgets.contains(b.objName)) { fprintf(stderr, "%s: Warning: Buddy assignment: '%s' is not a valid widget.\n", qPrintable(m_option.messagePrefix()), @@ -553,7 +536,7 @@ void WriteInitialization::acceptUI(DomUI *node) m_output << m_indent << b.objName << "->setBuddy(" << b.buddy << ");\n"; } - if (m_buddies.size() > 0) + if (!m_buddies.empty()) closeIfndef(m_output, QLatin1String(shortcutDefineC)); if (node->elementTabStops()) @@ -832,9 +815,7 @@ void WriteInitialization::acceptWidget(DomWidget *node) m_layoutChain.pop(); const QStringList zOrder = node->elementZOrder(); - for (int i = 0; i < zOrder.size(); ++i) { - const QString name = zOrder.at(i); - + for (const QString &name : zOrder) { if (!m_registeredWidgets.contains(name)) { fprintf(stderr, "%s: Warning: Z-order assignment: '%s' is not a valid widget.\n", qPrintable(m_option.messagePrefix()), @@ -842,11 +823,8 @@ void WriteInitialization::acceptWidget(DomWidget *node) continue; } - if (name.isEmpty()) { - continue; - } - - m_output << m_indent << name << "->raise();\n"; + if (!name.isEmpty()) + m_output << m_indent << name << "->raise();\n"; } } @@ -1141,7 +1119,7 @@ QString WriteInitialization::writeStringListProperty(const DomStringList *list) str << '\n' << m_indent << " << " << trCall(values.at(i), comment); } else { for (int i = 0; i < values.size(); ++i) - str << " << " << writeString(values.at(i), m_dindent); + str << " << QString::fromUtf8(" << fixString(values.at(i), m_dindent) << ')'; } return propertyValue; } @@ -1156,8 +1134,8 @@ void WriteInitialization::writeProperties(const QString &varName, if (m_uic->customWidgetsInfo()->extends(className, QLatin1String("QAxWidget"))) { DomPropertyMap properties = propertyMap(lst); if (DomProperty *p = properties.value(QLatin1String("control"))) { - m_output << m_indent << varName << "->setControl(" - << writeString(toString(p->elementString()), m_dindent) << ");\n"; + m_output << m_indent << varName << "->setControl(QString::fromUtf8(" + << fixString(toString(p->elementString()), m_dindent) << "));\n"; } } @@ -1168,14 +1146,13 @@ void WriteInitialization::writeProperties(const QString &varName, } if (!(flags & WritePropertyIgnoreObjectName)) m_output << m_indent << indent << varName - << "->setObjectName(" << writeString(varName, m_dindent) << ");\n"; + << "->setObjectName(QString::fromUtf8(" << fixString(varName, m_dindent) << "));\n"; int leftMargin, topMargin, rightMargin, bottomMargin; leftMargin = topMargin = rightMargin = bottomMargin = -1; bool frameShadowEncountered = false; - for (int i=0; i<lst.size(); ++i) { - const DomProperty *p = lst.at(i); + for (const DomProperty *p : lst) { if (!checkProperty(m_option.inputFile, p)) continue; QString propertyName = p->attributeName(); @@ -1187,30 +1164,35 @@ void WriteInitialization::writeProperties(const QString &varName, const DomRect *r = p->elementRect(); m_output << m_indent << varName << "->resize(" << r->elementWidth() << ", " << r->elementHeight() << ");\n"; continue; - } else if (propertyName == QLatin1String("currentRow") // QListWidget::currentRow - && m_uic->customWidgetsInfo()->extends(className, QLatin1String("QListWidget"))) { + } + if (propertyName == QLatin1String("currentRow") // QListWidget::currentRow + && m_uic->customWidgetsInfo()->extends(className, QLatin1String("QListWidget"))) { m_delayedOut << m_indent << varName << "->setCurrentRow(" << p->elementNumber() << ");\n"; continue; - } else if (propertyName == QLatin1String("currentIndex") // set currentIndex later - && (m_uic->customWidgetsInfo()->extends(className, QLatin1String("QComboBox")) - || m_uic->customWidgetsInfo()->extends(className, QLatin1String("QStackedWidget")) - || m_uic->customWidgetsInfo()->extends(className, QLatin1String("QTabWidget")) - || m_uic->customWidgetsInfo()->extends(className, QLatin1String("QToolBox")))) { + } + if (propertyName == QLatin1String("currentIndex") // set currentIndex later + && (m_uic->customWidgetsInfo()->extends(className, QLatin1String("QComboBox")) + || m_uic->customWidgetsInfo()->extends(className, QLatin1String("QStackedWidget")) + || m_uic->customWidgetsInfo()->extends(className, QLatin1String("QTabWidget")) + || m_uic->customWidgetsInfo()->extends(className, QLatin1String("QToolBox")))) { m_delayedOut << m_indent << varName << "->setCurrentIndex(" << p->elementNumber() << ");\n"; continue; - } else if (propertyName == QLatin1String("tabSpacing") - && m_uic->customWidgetsInfo()->extends(className, QLatin1String("QToolBox"))) { + } + if (propertyName == QLatin1String("tabSpacing") + && m_uic->customWidgetsInfo()->extends(className, QLatin1String("QToolBox"))) { m_delayedOut << m_indent << varName << "->layout()->setSpacing(" << p->elementNumber() << ");\n"; continue; - } else if (propertyName == QLatin1String("control") // ActiveQt support - && m_uic->customWidgetsInfo()->extends(className, QLatin1String("QAxWidget"))) { + } + if (propertyName == QLatin1String("control") // ActiveQt support + && m_uic->customWidgetsInfo()->extends(className, QLatin1String("QAxWidget"))) { // already done ;) continue; - } else if (propertyName == QLatin1String("default") - && m_uic->customWidgetsInfo()->extends(className, QLatin1String("QPushButton"))) { + } + if (propertyName == QLatin1String("default") + && m_uic->customWidgetsInfo()->extends(className, QLatin1String("QPushButton"))) { // QTBUG-44406: Setting of QPushButton::default needs to be delayed until the parent is set delayProperty = true; } else if (propertyName == QLatin1String("database") @@ -1467,8 +1449,8 @@ void WriteInitialization::writeProperties(const QString &varName, case DomProperty::Url: { const DomUrl* u = p->elementUrl(); - propertyValue = QString::fromLatin1("QUrl(%1)") - .arg(writeString(u->elementString()->text(), m_dindent)); + propertyValue = QString::fromLatin1("QUrl(QString::fromUtf8(%1))") + .arg(fixString(u->elementString()->text(), m_dindent)); break; } case DomProperty::Brush: @@ -1572,8 +1554,8 @@ QString WriteInitialization::writeFontProperties(const DomFont *f) m_output << m_indent << "QFont " << fontName << ";\n"; if (f->hasElementFamily() && !f->elementFamily().isEmpty()) { - m_output << m_indent << fontName << ".setFamily(" << writeString(f->elementFamily(), m_dindent) - << ");\n"; + m_output << m_indent << fontName << ".setFamily(QString::fromUtf8(" + << fixString(f->elementFamily(), m_dindent) << "));\n"; } if (f->hasElementPointSize() && f->elementPointSize() > 0) { m_output << m_indent << fontName << ".setPointSize(" << f->elementPointSize() @@ -1616,27 +1598,51 @@ QString WriteInitialization::writeFontProperties(const DomFont *f) } // Post 4.4 write resource icon -void WriteInitialization::writeResourceIcon(QTextStream &output, - const QString &iconName, - const QString &indent, - const DomResourceIcon *i) const -{ - if (i->hasElementNormalOff()) - output << indent << iconName << ".addFile(" << writeString(i->elementNormalOff()->text(), indent) << ", QSize(), QIcon::Normal, QIcon::Off);\n"; - if (i->hasElementNormalOn()) - output << indent << iconName << ".addFile(" << writeString(i->elementNormalOn()->text(), indent) << ", QSize(), QIcon::Normal, QIcon::On);\n"; - if (i->hasElementDisabledOff()) - output << indent << iconName << ".addFile(" << writeString(i->elementDisabledOff()->text(), indent) << ", QSize(), QIcon::Disabled, QIcon::Off);\n"; - if (i->hasElementDisabledOn()) - output << indent << iconName << ".addFile(" << writeString(i->elementDisabledOn()->text(), indent) << ", QSize(), QIcon::Disabled, QIcon::On);\n"; - if (i->hasElementActiveOff()) - output << indent << iconName << ".addFile(" << writeString(i->elementActiveOff()->text(), indent) << ", QSize(), QIcon::Active, QIcon::Off);\n"; - if (i->hasElementActiveOn()) - output << indent << iconName << ".addFile(" << writeString(i->elementActiveOn()->text(), indent) << ", QSize(), QIcon::Active, QIcon::On);\n"; - if (i->hasElementSelectedOff()) - output << indent << iconName << ".addFile(" << writeString(i->elementSelectedOff()->text(), indent) << ", QSize(), QIcon::Selected, QIcon::Off);\n"; - if (i->hasElementSelectedOn()) - output << indent << iconName << ".addFile(" << writeString(i->elementSelectedOn()->text(), indent) << ", QSize(), QIcon::Selected, QIcon::On);\n"; +static void writeResourceIcon(QTextStream &output, + const QString &iconName, + const QString &indent, + const DomResourceIcon *i) +{ + if (i->hasElementNormalOff()) { + output << indent << iconName << ".addFile(QString::fromUtf8(" + << fixString(i->elementNormalOff()->text(), indent) + << "), QSize(), QIcon::Normal, QIcon::Off);\n"; + } + if (i->hasElementNormalOn()) { + output << indent << iconName << ".addFile(QString::fromUtf8(" + << fixString(i->elementNormalOn()->text(), indent) + << "), QSize(), QIcon::Normal, QIcon::On);\n"; + } + if (i->hasElementDisabledOff()) { + output << indent << iconName << ".addFile(QString::fromUtf8(" + << fixString(i->elementDisabledOff()->text(), indent) + << "), QSize(), QIcon::Disabled, QIcon::Off);\n"; + } + if (i->hasElementDisabledOn()) { + output << indent << iconName << ".addFile(QString::fromUtf8(" + << fixString(i->elementDisabledOn()->text(), indent) + << "), QSize(), QIcon::Disabled, QIcon::On);\n"; + } + if (i->hasElementActiveOff()) { + output << indent << iconName << ".addFile(QString::fromUtf8(" + << fixString(i->elementActiveOff()->text(), indent) + << "), QSize(), QIcon::Active, QIcon::Off);\n"; + } + if (i->hasElementActiveOn()) { + output << indent << iconName << ".addFile(QString::fromUtf8(" + << fixString(i->elementActiveOn()->text(), indent) + << "), QSize(), QIcon::Active, QIcon::On);\n"; + } + if (i->hasElementSelectedOff()) { + output << indent << iconName << ".addFile(QString::fromUtf8(" + << fixString(i->elementSelectedOff()->text(), indent) + << "), QSize(), QIcon::Selected, QIcon::Off);\n"; + } + if (i->hasElementSelectedOn()) { + output << indent << iconName << ".addFile(QString::fromUtf8(" + << fixString(i->elementSelectedOn()->text(), indent) + << "), QSize(), QIcon::Selected, QIcon::On);\n"; + } } QString WriteInitialization::writeIconProperties(const DomResourceIcon *i) @@ -1658,7 +1664,7 @@ QString WriteInitialization::writeIconProperties(const DomResourceIcon *i) writeResourceIcon(m_output, iconName, m_indent, i); } else { // Theme: Generate code to check the theme and default to resource - const QString themeIconName = writeString(i->attributeTheme(), QString()); + const QString themeIconName = fixString(i->attributeTheme(), QString()); if (iconHasStatePixmaps(i)) { // Theme + default state pixmaps: // Generate code to check the theme and default to state pixmaps @@ -1670,8 +1676,8 @@ QString WriteInitialization::writeIconProperties(const DomResourceIcon *i) m_output << "QString "; m_firstThemeIcon = false; } - m_output << themeNameStringVariableC << " = " - << themeIconName << ";\n"; + m_output << themeNameStringVariableC << " = QString::fromUtf8(" + << themeIconName << ");\n"; m_output << m_indent << "if (QIcon::hasThemeIcon(" << themeNameStringVariableC << ")) {\n" @@ -1682,8 +1688,8 @@ QString WriteInitialization::writeIconProperties(const DomResourceIcon *i) } else { // Theme, but no state pixmaps: Construct from theme directly. m_output << m_indent << "QIcon " << iconName - << "(QIcon::fromTheme(" - << themeIconName << "));\n"; + << "(QIcon::fromTheme(QString::fromUtf8(" + << themeIconName << ")));\n"; } // Theme, but not state } // >= 4.4 } else { // pre-4.4 legacy @@ -1841,7 +1847,7 @@ void WriteInitialization::acceptTabStops(DomTabStops *tabStops) const QStringList l = tabStops->elementTabStop(); for (int i=0; i<l.size(); ++i) { - const QString name = l.at(i); + const QString &name = l.at(i); if (!m_registeredWidgets.contains(name)) { fprintf(stderr, "%s: Warning: Tab-stop assignment: '%s' is not a valid widget.\n", @@ -1853,9 +1859,9 @@ void WriteInitialization::acceptTabStops(DomTabStops *tabStops) if (i == 0) { lastName = name; continue; - } else if (name.isEmpty() || lastName.isEmpty()) { - continue; } + if (name.isEmpty() || lastName.isEmpty()) + continue; m_output << m_indent << "QWidget::setTabOrder(" << lastName << ", " << name << ");\n"; @@ -2125,7 +2131,7 @@ void WriteInitialization::initializeTreeWidget(DomWidget *w) if (!itemName.isNull()) m_output << m_indent << varName << "->setHeaderItem(" << itemName << ");\n"; - if (w->elementItem().size() == 0) + if (w->elementItem().empty()) return; QString tempName = disableSorting(w, varName); @@ -2167,9 +2173,8 @@ QList<WriteInitialization::Item *> WriteInitialization::initializeTreeWidgetItem int col = -1; const DomPropertyList properties = domItem->elementProperty(); - for (int j = 0; j < properties.size(); ++j) { - DomProperty *p = properties.at(j); - if (p->attributeName() == QLatin1String("text")) { + for (DomProperty *p : properties) { + if (p->attributeName() == QLatin1String("text")) { if (!map.isEmpty()) { addCommonInitializers(item, map, col); map.clear(); @@ -2196,7 +2201,7 @@ void WriteInitialization::initializeTableWidget(DomWidget *w) // columns const auto &columns = w->elementColumn(); - if (columns.size() != 0) { + if (!columns.empty()) { m_output << m_indent << "if (" << varName << "->columnCount() < " << columns.size() << ")\n" << m_dindent << varName << "->setColumnCount(" << columns.size() << ");\n"; } @@ -2218,7 +2223,7 @@ void WriteInitialization::initializeTableWidget(DomWidget *w) // rows const auto &rows = w->elementRow(); - if (rows.size() != 0) { + if (!rows.isEmpty()) { m_output << m_indent << "if (" << varName << "->rowCount() < " << rows.size() << ")\n" << m_dindent << varName << "->setRowCount(" << rows.size() << ");\n"; } @@ -2242,8 +2247,7 @@ void WriteInitialization::initializeTableWidget(DomWidget *w) const auto &items = w->elementItem(); - for (int i = 0; i < items.size(); ++i) { - const DomItem *cell = items.at(i); + for (const DomItem *cell : items) { if (cell->hasAttributeRow() && cell->hasAttributeColumn() && !cell->elementProperty().isEmpty()) { const int r = cell->attributeRow(); const int c = cell->attributeColumn(); @@ -2323,7 +2327,10 @@ QString WriteInitialization::noTrCall(DomString *str, const QString &defaultStri return QString(); if (str) value = str->text(); - return writeString(value, m_dindent); + QString ret = QLatin1String("QString::fromUtf8("); + ret += fixString(value, m_dindent); + ret += QLatin1Char(')'); + return ret; } QString WriteInitialization::autoTrCall(DomString *str, const QString &defaultString) const @@ -2448,13 +2455,13 @@ QString WriteInitialization::Item::writeSetupUi(const QString &parent, Item::Emp return QString(); bool generateMultiDirective = false; - if (emptyItemPolicy == Item::ConstructItemOnly && m_children.size() == 0) { + if (emptyItemPolicy == Item::ConstructItemOnly && m_children.isEmpty()) { if (m_setupUiData.policy == ItemData::DontGenerate) { m_setupUiStream << m_indent << "new " << m_itemClassName << '(' << parent << ");\n"; - return QString(); - } else if (m_setupUiData.policy == ItemData::GenerateWithMultiDirective) { - generateMultiDirective = true; + return QString(); } + if (m_setupUiData.policy == ItemData::GenerateWithMultiDirective) + generateMultiDirective = true; } if (generateMultiDirective) diff --git a/src/tools/uic/cpp/cppwriteinitialization.h b/src/tools/uic/cpp/cppwriteinitialization.h index 21116057d4..e6950a00ea 100644 --- a/src/tools/uic/cpp/cppwriteinitialization.h +++ b/src/tools/uic/cpp/cppwriteinitialization.h @@ -139,8 +139,6 @@ struct WriteInitialization : public TreeWalker private: static QString domColor2QString(const DomColor *c); - QString writeString(const QString &s, const QString &indent) const; - QString iconCall(const DomProperty *prop); QString pixCall(const DomProperty *prop) const; QString pixCall(const QString &type, const QString &text) const; @@ -163,6 +161,7 @@ private: // special initialization // class Item { + Q_DISABLE_COPY(Item) public: Item(const QString &itemClassName, const QString &indent, QTextStream &setupUiStream, QTextStream &retranslateUiStream, Driver *driver); ~Item(); @@ -178,15 +177,15 @@ private: int setupUiCount() const { return m_setupUiData.setters.count(); } int retranslateUiCount() const { return m_retranslateUiData.setters.count(); } private: - struct ItemData { - ItemData() : policy(DontGenerate) {} + struct ItemData + { QMultiMap<QString, QString> setters; // directive to setter QSet<QString> directives; enum TemporaryVariableGeneratorPolicy { // policies with priority, number describes the priority DontGenerate = 1, GenerateWithMultiDirective = 2, Generate = 3 - } policy; + } policy = DontGenerate; }; ItemData m_setupUiData; ItemData m_retranslateUiData; @@ -230,7 +229,6 @@ private: private: QString writeFontProperties(const DomFont *f); - void writeResourceIcon(QTextStream &output, const QString &iconName, const QString &indent, const DomResourceIcon *i) const; QString writeIconProperties(const DomResourceIcon *i); QString writeSizePolicy(const DomSizePolicy *sp); QString writeBrushInitialization(const DomBrush *brush); diff --git a/src/tools/uic/customwidgetsinfo.cpp b/src/tools/uic/customwidgetsinfo.cpp index 6883b715ae..0ac0c2b6a3 100644 --- a/src/tools/uic/customwidgetsinfo.cpp +++ b/src/tools/uic/customwidgetsinfo.cpp @@ -33,9 +33,7 @@ QT_BEGIN_NAMESPACE -CustomWidgetsInfo::CustomWidgetsInfo() -{ -} +CustomWidgetsInfo::CustomWidgetsInfo() = default; void CustomWidgetsInfo::acceptUI(DomUI *node) { diff --git a/src/tools/uic/driver.cpp b/src/tools/uic/driver.cpp index 72be667468..6b3a6f8f69 100644 --- a/src/tools/uic/driver.cpp +++ b/src/tools/uic/driver.cpp @@ -41,9 +41,7 @@ Driver::Driver() m_output = &m_stdout; } -Driver::~Driver() -{ -} +Driver::~Driver() = default; QString Driver::findOrInsertWidget(DomWidget *ui_widget) { diff --git a/src/tools/uic/driver.h b/src/tools/uic/driver.h index 41c1572860..1563bdbd83 100644 --- a/src/tools/uic/driver.h +++ b/src/tools/uic/driver.h @@ -49,6 +49,7 @@ class DomButtonGroup; class Driver { + Q_DISABLE_COPY(Driver) public: Driver(); virtual ~Driver(); diff --git a/src/tools/uic/main.cpp b/src/tools/uic/main.cpp index 46a1e66bcc..0e30bac28e 100644 --- a/src/tools/uic/main.cpp +++ b/src/tools/uic/main.cpp @@ -76,7 +76,7 @@ int runUic(int argc, char *argv[]) parser.addOption(noImplicitIncludesOption); QCommandLineOption noStringLiteralOption(QStringList() << QStringLiteral("s") << QStringLiteral("no-stringliteral")); - noStringLiteralOption.setDescription(QStringLiteral("Use QLatin1String instead of QStringLiteral in generated code.")); + noStringLiteralOption.setDescription(QStringLiteral("Deprecated. The use of this option won't take any effect.")); parser.addOption(noStringLiteralOption); QCommandLineOption postfixOption(QStringLiteral("postfix")); @@ -111,13 +111,15 @@ int runUic(int argc, char *argv[]) driver.option().outputFile = parser.value(outputOption); driver.option().headerProtection = !parser.isSet(noProtOption); driver.option().implicitIncludes = !parser.isSet(noImplicitIncludesOption); - driver.option().stringLiteral = !parser.isSet(noStringLiteralOption); driver.option().idBased = parser.isSet(idBasedOption); driver.option().postfix = parser.value(postfixOption); driver.option().translateFunction = parser.value(translateOption); driver.option().includeFile = parser.value(includeOption); driver.option().generator = (parser.value(generatorOption).toLower() == QLatin1String("java")) ? Option::JavaGenerator : Option::CppGenerator; + if (parser.isSet(noStringLiteralOption)) + fprintf(stderr, "The -s, --no-stringliteral option is deprecated and it won't take any effect.\n"); + QString inputFile; if (!parser.positionalArguments().isEmpty()) inputFile = parser.positionalArguments().at(0); diff --git a/src/tools/uic/option.h b/src/tools/uic/option.h index c7278393fb..a5b14abc5f 100644 --- a/src/tools/uic/option.h +++ b/src/tools/uic/option.h @@ -51,7 +51,6 @@ struct Option unsigned int limitXPM_LineLength : 1; unsigned int implicitIncludes: 1; unsigned int idBased: 1; - unsigned int stringLiteral: 1; Generator generator; QString inputFile; @@ -77,7 +76,6 @@ struct Option limitXPM_LineLength(0), implicitIncludes(1), idBased(0), - stringLiteral(1), generator(CppGenerator), prefix(QLatin1String("Ui_")) { indent.fill(QLatin1Char(' '), 4); } diff --git a/src/tools/uic/treewalker.h b/src/tools/uic/treewalker.h index 78da17d628..43d4633d83 100644 --- a/src/tools/uic/treewalker.h +++ b/src/tools/uic/treewalker.h @@ -77,7 +77,7 @@ class DomButtonGroup; struct TreeWalker { - inline virtual ~TreeWalker() {} + inline virtual ~TreeWalker() = default; virtual void acceptUI(DomUI *ui); virtual void acceptLayoutDefault(DomLayoutDefault *layoutDefault); diff --git a/src/tools/uic/ui4.cpp b/src/tools/uic/ui4.cpp index 7a1d755bb4..984ef36274 100644 --- a/src/tools/uic/ui4.cpp +++ b/src/tools/uic/ui4.cpp @@ -108,19 +108,19 @@ void DomUI::read(QXmlStreamReader &reader) continue; } if (!tag.compare(QLatin1String("widget"), Qt::CaseInsensitive)) { - DomWidget *v = new DomWidget(); + auto *v = new DomWidget(); v->read(reader); setElementWidget(v); continue; } if (!tag.compare(QLatin1String("layoutdefault"), Qt::CaseInsensitive)) { - DomLayoutDefault *v = new DomLayoutDefault(); + auto *v = new DomLayoutDefault(); v->read(reader); setElementLayoutDefault(v); continue; } if (!tag.compare(QLatin1String("layoutfunction"), Qt::CaseInsensitive)) { - DomLayoutFunction *v = new DomLayoutFunction(); + auto *v = new DomLayoutFunction(); v->read(reader); setElementLayoutFunction(v); continue; @@ -130,13 +130,13 @@ void DomUI::read(QXmlStreamReader &reader) continue; } if (!tag.compare(QLatin1String("customwidgets"), Qt::CaseInsensitive)) { - DomCustomWidgets *v = new DomCustomWidgets(); + auto *v = new DomCustomWidgets(); v->read(reader); setElementCustomWidgets(v); continue; } if (!tag.compare(QLatin1String("tabstops"), Qt::CaseInsensitive)) { - DomTabStops *v = new DomTabStops(); + auto *v = new DomTabStops(); v->read(reader); setElementTabStops(v); continue; @@ -147,37 +147,37 @@ void DomUI::read(QXmlStreamReader &reader) continue; } if (!tag.compare(QLatin1String("includes"), Qt::CaseInsensitive)) { - DomIncludes *v = new DomIncludes(); + auto *v = new DomIncludes(); v->read(reader); setElementIncludes(v); continue; } if (!tag.compare(QLatin1String("resources"), Qt::CaseInsensitive)) { - DomResources *v = new DomResources(); + auto *v = new DomResources(); v->read(reader); setElementResources(v); continue; } if (!tag.compare(QLatin1String("connections"), Qt::CaseInsensitive)) { - DomConnections *v = new DomConnections(); + auto *v = new DomConnections(); v->read(reader); setElementConnections(v); continue; } if (!tag.compare(QLatin1String("designerdata"), Qt::CaseInsensitive)) { - DomDesignerData *v = new DomDesignerData(); + auto *v = new DomDesignerData(); v->read(reader); setElementDesignerdata(v); continue; } if (!tag.compare(QLatin1String("slots"), Qt::CaseInsensitive)) { - DomSlots *v = new DomSlots(); + auto *v = new DomSlots(); v->read(reader); setElementSlots(v); continue; } if (!tag.compare(QLatin1String("buttongroups"), Qt::CaseInsensitive)) { - DomButtonGroups *v = new DomButtonGroups(); + auto *v = new DomButtonGroups(); v->read(reader); setElementButtonGroups(v); continue; @@ -293,7 +293,7 @@ void DomUI::setElementClass(const QString &a) DomWidget *DomUI::takeElementWidget() { DomWidget *a = m_widget; - m_widget = 0; + m_widget = nullptr; m_children ^= Widget; return a; } @@ -308,7 +308,7 @@ void DomUI::setElementWidget(DomWidget *a) DomLayoutDefault *DomUI::takeElementLayoutDefault() { DomLayoutDefault *a = m_layoutDefault; - m_layoutDefault = 0; + m_layoutDefault = nullptr; m_children ^= LayoutDefault; return a; } @@ -323,7 +323,7 @@ void DomUI::setElementLayoutDefault(DomLayoutDefault *a) DomLayoutFunction *DomUI::takeElementLayoutFunction() { DomLayoutFunction *a = m_layoutFunction; - m_layoutFunction = 0; + m_layoutFunction = nullptr; m_children ^= LayoutFunction; return a; } @@ -344,7 +344,7 @@ void DomUI::setElementPixmapFunction(const QString &a) DomCustomWidgets *DomUI::takeElementCustomWidgets() { DomCustomWidgets *a = m_customWidgets; - m_customWidgets = 0; + m_customWidgets = nullptr; m_children ^= CustomWidgets; return a; } @@ -359,7 +359,7 @@ void DomUI::setElementCustomWidgets(DomCustomWidgets *a) DomTabStops *DomUI::takeElementTabStops() { DomTabStops *a = m_tabStops; - m_tabStops = 0; + m_tabStops = nullptr; m_children ^= TabStops; return a; } @@ -374,7 +374,7 @@ void DomUI::setElementTabStops(DomTabStops *a) DomIncludes *DomUI::takeElementIncludes() { DomIncludes *a = m_includes; - m_includes = 0; + m_includes = nullptr; m_children ^= Includes; return a; } @@ -389,7 +389,7 @@ void DomUI::setElementIncludes(DomIncludes *a) DomResources *DomUI::takeElementResources() { DomResources *a = m_resources; - m_resources = 0; + m_resources = nullptr; m_children ^= Resources; return a; } @@ -404,7 +404,7 @@ void DomUI::setElementResources(DomResources *a) DomConnections *DomUI::takeElementConnections() { DomConnections *a = m_connections; - m_connections = 0; + m_connections = nullptr; m_children ^= Connections; return a; } @@ -419,7 +419,7 @@ void DomUI::setElementConnections(DomConnections *a) DomDesignerData *DomUI::takeElementDesignerdata() { DomDesignerData *a = m_designerdata; - m_designerdata = 0; + m_designerdata = nullptr; m_children ^= Designerdata; return a; } @@ -434,7 +434,7 @@ void DomUI::setElementDesignerdata(DomDesignerData *a) DomSlots *DomUI::takeElementSlots() { DomSlots *a = m_slots; - m_slots = 0; + m_slots = nullptr; m_children ^= Slots; return a; } @@ -449,7 +449,7 @@ void DomUI::setElementSlots(DomSlots *a) DomButtonGroups *DomUI::takeElementButtonGroups() { DomButtonGroups *a = m_buttonGroups; - m_buttonGroups = 0; + m_buttonGroups = nullptr; m_children ^= ButtonGroups; return a; } @@ -484,21 +484,21 @@ void DomUI::clearElementClass() void DomUI::clearElementWidget() { delete m_widget; - m_widget = 0; + m_widget = nullptr; m_children &= ~Widget; } void DomUI::clearElementLayoutDefault() { delete m_layoutDefault; - m_layoutDefault = 0; + m_layoutDefault = nullptr; m_children &= ~LayoutDefault; } void DomUI::clearElementLayoutFunction() { delete m_layoutFunction; - m_layoutFunction = 0; + m_layoutFunction = nullptr; m_children &= ~LayoutFunction; } @@ -510,56 +510,56 @@ void DomUI::clearElementPixmapFunction() void DomUI::clearElementCustomWidgets() { delete m_customWidgets; - m_customWidgets = 0; + m_customWidgets = nullptr; m_children &= ~CustomWidgets; } void DomUI::clearElementTabStops() { delete m_tabStops; - m_tabStops = 0; + m_tabStops = nullptr; m_children &= ~TabStops; } void DomUI::clearElementIncludes() { delete m_includes; - m_includes = 0; + m_includes = nullptr; m_children &= ~Includes; } void DomUI::clearElementResources() { delete m_resources; - m_resources = 0; + m_resources = nullptr; m_children &= ~Resources; } void DomUI::clearElementConnections() { delete m_connections; - m_connections = 0; + m_connections = nullptr; m_children &= ~Connections; } void DomUI::clearElementDesignerdata() { delete m_designerdata; - m_designerdata = 0; + m_designerdata = nullptr; m_children &= ~Designerdata; } void DomUI::clearElementSlots() { delete m_slots; - m_slots = 0; + m_slots = nullptr; m_children &= ~Slots; } void DomUI::clearElementButtonGroups() { delete m_buttonGroups; - m_buttonGroups = 0; + m_buttonGroups = nullptr; m_children &= ~ButtonGroups; } @@ -576,7 +576,7 @@ void DomIncludes::read(QXmlStreamReader &reader) case QXmlStreamReader::StartElement : { const QStringRef tag = reader.name(); if (!tag.compare(QLatin1String("include"), Qt::CaseInsensitive)) { - DomInclude *v = new DomInclude(); + auto *v = new DomInclude(); v->read(reader); m_include.append(v); continue; @@ -608,9 +608,7 @@ void DomIncludes::setElementInclude(const QVector<DomInclude *> &a) m_include = a; } -DomInclude::~DomInclude() -{ -} +DomInclude::~DomInclude() = default; void DomInclude::read(QXmlStreamReader &reader) { @@ -686,7 +684,7 @@ void DomResources::read(QXmlStreamReader &reader) case QXmlStreamReader::StartElement : { const QStringRef tag = reader.name(); if (!tag.compare(QLatin1String("include"), Qt::CaseInsensitive)) { - DomResource *v = new DomResource(); + auto *v = new DomResource(); v->read(reader); m_include.append(v); continue; @@ -721,9 +719,7 @@ void DomResources::setElementInclude(const QVector<DomResource *> &a) m_include = a; } -DomResource::~DomResource() -{ -} +DomResource::~DomResource() = default; void DomResource::read(QXmlStreamReader &reader) { @@ -791,25 +787,25 @@ void DomActionGroup::read(QXmlStreamReader &reader) case QXmlStreamReader::StartElement : { const QStringRef tag = reader.name(); if (!tag.compare(QLatin1String("action"), Qt::CaseInsensitive)) { - DomAction *v = new DomAction(); + auto *v = new DomAction(); v->read(reader); m_action.append(v); continue; } if (!tag.compare(QLatin1String("actiongroup"), Qt::CaseInsensitive)) { - DomActionGroup *v = new DomActionGroup(); + auto *v = new DomActionGroup(); v->read(reader); m_actionGroup.append(v); continue; } if (!tag.compare(QLatin1String("property"), Qt::CaseInsensitive)) { - DomProperty *v = new DomProperty(); + auto *v = new DomProperty(); v->read(reader); m_property.append(v); continue; } if (!tag.compare(QLatin1String("attribute"), Qt::CaseInsensitive)) { - DomProperty *v = new DomProperty(); + auto *v = new DomProperty(); v->read(reader); m_attribute.append(v); continue; @@ -900,13 +896,13 @@ void DomAction::read(QXmlStreamReader &reader) case QXmlStreamReader::StartElement : { const QStringRef tag = reader.name(); if (!tag.compare(QLatin1String("property"), Qt::CaseInsensitive)) { - DomProperty *v = new DomProperty(); + auto *v = new DomProperty(); v->read(reader); m_property.append(v); continue; } if (!tag.compare(QLatin1String("attribute"), Qt::CaseInsensitive)) { - DomProperty *v = new DomProperty(); + auto *v = new DomProperty(); v->read(reader); m_attribute.append(v); continue; @@ -953,9 +949,7 @@ void DomAction::setElementAttribute(const QList<DomProperty *> &a) m_attribute = a; } -DomActionRef::~DomActionRef() -{ -} +DomActionRef::~DomActionRef() = default; void DomActionRef::read(QXmlStreamReader &reader) { @@ -1019,13 +1013,13 @@ void DomButtonGroup::read(QXmlStreamReader &reader) case QXmlStreamReader::StartElement : { const QStringRef tag = reader.name(); if (!tag.compare(QLatin1String("property"), Qt::CaseInsensitive)) { - DomProperty *v = new DomProperty(); + auto *v = new DomProperty(); v->read(reader); m_property.append(v); continue; } if (!tag.compare(QLatin1String("attribute"), Qt::CaseInsensitive)) { - DomProperty *v = new DomProperty(); + auto *v = new DomProperty(); v->read(reader); m_attribute.append(v); continue; @@ -1082,7 +1076,7 @@ void DomButtonGroups::read(QXmlStreamReader &reader) case QXmlStreamReader::StartElement : { const QStringRef tag = reader.name(); if (!tag.compare(QLatin1String("buttongroup"), Qt::CaseInsensitive)) { - DomButtonGroup *v = new DomButtonGroup(); + auto *v = new DomButtonGroup(); v->read(reader); m_buttonGroup.append(v); continue; @@ -1127,7 +1121,7 @@ void DomCustomWidgets::read(QXmlStreamReader &reader) case QXmlStreamReader::StartElement : { const QStringRef tag = reader.name(); if (!tag.compare(QLatin1String("customwidget"), Qt::CaseInsensitive)) { - DomCustomWidget *v = new DomCustomWidget(); + auto *v = new DomCustomWidget(); v->read(reader); m_customWidget.append(v); continue; @@ -1159,9 +1153,7 @@ void DomCustomWidgets::setElementCustomWidget(const QVector<DomCustomWidget *> & m_customWidget = a; } -DomHeader::~DomHeader() -{ -} +DomHeader::~DomHeader() = default; void DomHeader::read(QXmlStreamReader &reader) { @@ -1230,13 +1222,13 @@ void DomCustomWidget::read(QXmlStreamReader &reader) continue; } if (!tag.compare(QLatin1String("header"), Qt::CaseInsensitive)) { - DomHeader *v = new DomHeader(); + auto *v = new DomHeader(); v->read(reader); setElementHeader(v); continue; } if (!tag.compare(QLatin1String("sizehint"), Qt::CaseInsensitive)) { - DomSize *v = new DomSize(); + auto *v = new DomSize(); v->read(reader); setElementSizeHint(v); continue; @@ -1269,13 +1261,13 @@ void DomCustomWidget::read(QXmlStreamReader &reader) continue; } if (!tag.compare(QLatin1String("slots"), Qt::CaseInsensitive)) { - DomSlots *v = new DomSlots(); + auto *v = new DomSlots(); v->read(reader); setElementSlots(v); continue; } if (!tag.compare(QLatin1String("propertyspecifications"), Qt::CaseInsensitive)) { - DomPropertySpecifications *v = new DomPropertySpecifications(); + auto *v = new DomPropertySpecifications(); v->read(reader); setElementPropertyspecifications(v); continue; @@ -1340,7 +1332,7 @@ void DomCustomWidget::setElementExtends(const QString &a) DomHeader *DomCustomWidget::takeElementHeader() { DomHeader *a = m_header; - m_header = 0; + m_header = nullptr; m_children ^= Header; return a; } @@ -1355,7 +1347,7 @@ void DomCustomWidget::setElementHeader(DomHeader *a) DomSize *DomCustomWidget::takeElementSizeHint() { DomSize *a = m_sizeHint; - m_sizeHint = 0; + m_sizeHint = nullptr; m_children ^= SizeHint; return a; } @@ -1388,7 +1380,7 @@ void DomCustomWidget::setElementPixmap(const QString &a) DomSlots *DomCustomWidget::takeElementSlots() { DomSlots *a = m_slots; - m_slots = 0; + m_slots = nullptr; m_children ^= Slots; return a; } @@ -1403,7 +1395,7 @@ void DomCustomWidget::setElementSlots(DomSlots *a) DomPropertySpecifications *DomCustomWidget::takeElementPropertyspecifications() { DomPropertySpecifications *a = m_propertyspecifications; - m_propertyspecifications = 0; + m_propertyspecifications = nullptr; m_children ^= Propertyspecifications; return a; } @@ -1428,14 +1420,14 @@ void DomCustomWidget::clearElementExtends() void DomCustomWidget::clearElementHeader() { delete m_header; - m_header = 0; + m_header = nullptr; m_children &= ~Header; } void DomCustomWidget::clearElementSizeHint() { delete m_sizeHint; - m_sizeHint = 0; + m_sizeHint = nullptr; m_children &= ~SizeHint; } @@ -1457,20 +1449,18 @@ void DomCustomWidget::clearElementPixmap() void DomCustomWidget::clearElementSlots() { delete m_slots; - m_slots = 0; + m_slots = nullptr; m_children &= ~Slots; } void DomCustomWidget::clearElementPropertyspecifications() { delete m_propertyspecifications; - m_propertyspecifications = 0; + m_propertyspecifications = nullptr; m_children &= ~Propertyspecifications; } -DomLayoutDefault::~DomLayoutDefault() -{ -} +DomLayoutDefault::~DomLayoutDefault() = default; void DomLayoutDefault::read(QXmlStreamReader &reader) { @@ -1516,9 +1506,7 @@ void DomLayoutDefault::write(QXmlStreamWriter &writer, const QString &tagName) c writer.writeEndElement(); } -DomLayoutFunction::~DomLayoutFunction() -{ -} +DomLayoutFunction::~DomLayoutFunction() = default; void DomLayoutFunction::read(QXmlStreamReader &reader) { @@ -1657,19 +1645,19 @@ void DomLayout::read(QXmlStreamReader &reader) case QXmlStreamReader::StartElement : { const QStringRef tag = reader.name(); if (!tag.compare(QLatin1String("property"), Qt::CaseInsensitive)) { - DomProperty *v = new DomProperty(); + auto *v = new DomProperty(); v->read(reader); m_property.append(v); continue; } if (!tag.compare(QLatin1String("attribute"), Qt::CaseInsensitive)) { - DomProperty *v = new DomProperty(); + auto *v = new DomProperty(); v->read(reader); m_attribute.append(v); continue; } if (!tag.compare(QLatin1String("item"), Qt::CaseInsensitive)) { - DomLayoutItem *v = new DomLayoutItem(); + auto *v = new DomLayoutItem(); v->read(reader); m_item.append(v); continue; @@ -1793,19 +1781,19 @@ void DomLayoutItem::read(QXmlStreamReader &reader) case QXmlStreamReader::StartElement : { const QStringRef tag = reader.name(); if (!tag.compare(QLatin1String("widget"), Qt::CaseInsensitive)) { - DomWidget *v = new DomWidget(); + auto *v = new DomWidget(); v->read(reader); setElementWidget(v); continue; } if (!tag.compare(QLatin1String("layout"), Qt::CaseInsensitive)) { - DomLayout *v = new DomLayout(); + auto *v = new DomLayout(); v->read(reader); setElementLayout(v); continue; } if (!tag.compare(QLatin1String("spacer"), Qt::CaseInsensitive)) { - DomSpacer *v = new DomSpacer(); + auto *v = new DomSpacer(); v->read(reader); setElementSpacer(v); continue; @@ -1841,24 +1829,21 @@ void DomLayoutItem::write(QXmlStreamWriter &writer, const QString &tagName) cons writer.writeAttribute(QStringLiteral("alignment"), attributeAlignment()); switch (kind()) { - case Widget: { - DomWidget *v = elementWidget(); - if (v != 0) - v->write(writer, QStringLiteral("widget")); + case Widget: + if (m_widget != nullptr) + m_widget->write(writer, QStringLiteral("widget")); break; - } - case Layout: { - DomLayout *v = elementLayout(); - if (v != 0) - v->write(writer, QStringLiteral("layout")); + + case Layout: + if (m_layout != nullptr) + m_layout->write(writer, QStringLiteral("layout")); break; - } - case Spacer: { - DomSpacer *v = elementSpacer(); - if (v != 0) - v->write(writer, QStringLiteral("spacer")); + + case Spacer: + if (m_spacer != nullptr) + m_spacer->write(writer, QStringLiteral("spacer")); break; - } + default: break; } @@ -1868,7 +1853,7 @@ void DomLayoutItem::write(QXmlStreamWriter &writer, const QString &tagName) cons DomWidget *DomLayoutItem::takeElementWidget() { DomWidget *a = m_widget; - m_widget = 0; + m_widget = nullptr; return a; } @@ -1882,7 +1867,7 @@ void DomLayoutItem::setElementWidget(DomWidget *a) DomLayout *DomLayoutItem::takeElementLayout() { DomLayout *a = m_layout; - m_layout = 0; + m_layout = nullptr; return a; } @@ -1896,7 +1881,7 @@ void DomLayoutItem::setElementLayout(DomLayout *a) DomSpacer *DomLayoutItem::takeElementSpacer() { DomSpacer *a = m_spacer; - m_spacer = 0; + m_spacer = nullptr; return a; } @@ -1920,7 +1905,7 @@ void DomRow::read(QXmlStreamReader &reader) case QXmlStreamReader::StartElement : { const QStringRef tag = reader.name(); if (!tag.compare(QLatin1String("property"), Qt::CaseInsensitive)) { - DomProperty *v = new DomProperty(); + auto *v = new DomProperty(); v->read(reader); m_property.append(v); continue; @@ -1965,7 +1950,7 @@ void DomColumn::read(QXmlStreamReader &reader) case QXmlStreamReader::StartElement : { const QStringRef tag = reader.name(); if (!tag.compare(QLatin1String("property"), Qt::CaseInsensitive)) { - DomProperty *v = new DomProperty(); + auto *v = new DomProperty(); v->read(reader); m_property.append(v); continue; @@ -2026,13 +2011,13 @@ void DomItem::read(QXmlStreamReader &reader) case QXmlStreamReader::StartElement : { const QStringRef tag = reader.name(); if (!tag.compare(QLatin1String("property"), Qt::CaseInsensitive)) { - DomProperty *v = new DomProperty(); + auto *v = new DomProperty(); v->read(reader); m_property.append(v); continue; } if (!tag.compare(QLatin1String("item"), Qt::CaseInsensitive)) { - DomItem *v = new DomItem(); + auto *v = new DomItem(); v->read(reader); m_item.append(v); continue; @@ -2134,7 +2119,7 @@ void DomWidget::read(QXmlStreamReader &reader) continue; } if (!tag.compare(QLatin1String("property"), Qt::CaseInsensitive)) { - DomProperty *v = new DomProperty(); + auto *v = new DomProperty(); v->read(reader); m_property.append(v); continue; @@ -2150,55 +2135,55 @@ void DomWidget::read(QXmlStreamReader &reader) continue; } if (!tag.compare(QLatin1String("attribute"), Qt::CaseInsensitive)) { - DomProperty *v = new DomProperty(); + auto *v = new DomProperty(); v->read(reader); m_attribute.append(v); continue; } if (!tag.compare(QLatin1String("row"), Qt::CaseInsensitive)) { - DomRow *v = new DomRow(); + auto *v = new DomRow(); v->read(reader); m_row.append(v); continue; } if (!tag.compare(QLatin1String("column"), Qt::CaseInsensitive)) { - DomColumn *v = new DomColumn(); + auto *v = new DomColumn(); v->read(reader); m_column.append(v); continue; } if (!tag.compare(QLatin1String("item"), Qt::CaseInsensitive)) { - DomItem *v = new DomItem(); + auto *v = new DomItem(); v->read(reader); m_item.append(v); continue; } if (!tag.compare(QLatin1String("layout"), Qt::CaseInsensitive)) { - DomLayout *v = new DomLayout(); + auto *v = new DomLayout(); v->read(reader); m_layout.append(v); continue; } if (!tag.compare(QLatin1String("widget"), Qt::CaseInsensitive)) { - DomWidget *v = new DomWidget(); + auto *v = new DomWidget(); v->read(reader); m_widget.append(v); continue; } if (!tag.compare(QLatin1String("action"), Qt::CaseInsensitive)) { - DomAction *v = new DomAction(); + auto *v = new DomAction(); v->read(reader); m_action.append(v); continue; } if (!tag.compare(QLatin1String("actiongroup"), Qt::CaseInsensitive)) { - DomActionGroup *v = new DomActionGroup(); + auto *v = new DomActionGroup(); v->read(reader); m_actionGroup.append(v); continue; } if (!tag.compare(QLatin1String("addaction"), Qt::CaseInsensitive)) { - DomActionRef *v = new DomActionRef(); + auto *v = new DomActionRef(); v->read(reader); m_addAction.append(v); continue; @@ -2365,7 +2350,7 @@ void DomSpacer::read(QXmlStreamReader &reader) case QXmlStreamReader::StartElement : { const QStringRef tag = reader.name(); if (!tag.compare(QLatin1String("property"), Qt::CaseInsensitive)) { - DomProperty *v = new DomProperty(); + auto *v = new DomProperty(); v->read(reader); m_property.append(v); continue; @@ -2400,9 +2385,7 @@ void DomSpacer::setElementProperty(const QList<DomProperty *> &a) m_property = a; } -DomColor::~DomColor() -{ -} +DomColor::~DomColor() = default; void DomColor::read(QXmlStreamReader &reader) { @@ -2517,7 +2500,7 @@ void DomGradientStop::read(QXmlStreamReader &reader) case QXmlStreamReader::StartElement : { const QStringRef tag = reader.name(); if (!tag.compare(QLatin1String("color"), Qt::CaseInsensitive)) { - DomColor *v = new DomColor(); + auto *v = new DomColor(); v->read(reader); setElementColor(v); continue; @@ -2549,7 +2532,7 @@ void DomGradientStop::write(QXmlStreamWriter &writer, const QString &tagName) co DomColor *DomGradientStop::takeElementColor() { DomColor *a = m_color; - m_color = 0; + m_color = nullptr; m_children ^= Color; return a; } @@ -2564,7 +2547,7 @@ void DomGradientStop::setElementColor(DomColor *a) void DomGradientStop::clearElementColor() { delete m_color; - m_color = 0; + m_color = nullptr; m_children &= ~Color; } @@ -2639,7 +2622,7 @@ void DomGradient::read(QXmlStreamReader &reader) case QXmlStreamReader::StartElement : { const QStringRef tag = reader.name(); if (!tag.compare(QLatin1String("gradientstop"), Qt::CaseInsensitive)) { - DomGradientStop *v = new DomGradientStop(); + auto *v = new DomGradientStop(); v->read(reader); m_gradientStop.append(v); continue; @@ -2747,19 +2730,19 @@ void DomBrush::read(QXmlStreamReader &reader) case QXmlStreamReader::StartElement : { const QStringRef tag = reader.name(); if (!tag.compare(QLatin1String("color"), Qt::CaseInsensitive)) { - DomColor *v = new DomColor(); + auto *v = new DomColor(); v->read(reader); setElementColor(v); continue; } if (!tag.compare(QLatin1String("texture"), Qt::CaseInsensitive)) { - DomProperty *v = new DomProperty(); + auto *v = new DomProperty(); v->read(reader); setElementTexture(v); continue; } if (!tag.compare(QLatin1String("gradient"), Qt::CaseInsensitive)) { - DomGradient *v = new DomGradient(); + auto *v = new DomGradient(); v->read(reader); setElementGradient(v); continue; @@ -2783,24 +2766,21 @@ void DomBrush::write(QXmlStreamWriter &writer, const QString &tagName) const writer.writeAttribute(QStringLiteral("brushstyle"), attributeBrushStyle()); switch (kind()) { - case Color: { - DomColor *v = elementColor(); - if (v != 0) - v->write(writer, QStringLiteral("color")); + case Color: + if (m_color != nullptr) + m_color->write(writer, QStringLiteral("color")); break; - } - case Texture: { - DomProperty *v = elementTexture(); - if (v != 0) - v->write(writer, QStringLiteral("texture")); + + case Texture: + if (m_texture != nullptr) + m_texture->write(writer, QStringLiteral("texture")); break; - } - case Gradient: { - DomGradient *v = elementGradient(); - if (v != 0) - v->write(writer, QStringLiteral("gradient")); + + case Gradient: + if (m_gradient != nullptr) + m_gradient->write(writer, QStringLiteral("gradient")); break; - } + default: break; } @@ -2810,7 +2790,7 @@ void DomBrush::write(QXmlStreamWriter &writer, const QString &tagName) const DomColor *DomBrush::takeElementColor() { DomColor *a = m_color; - m_color = 0; + m_color = nullptr; return a; } @@ -2824,7 +2804,7 @@ void DomBrush::setElementColor(DomColor *a) DomProperty *DomBrush::takeElementTexture() { DomProperty *a = m_texture; - m_texture = 0; + m_texture = nullptr; return a; } @@ -2838,7 +2818,7 @@ void DomBrush::setElementTexture(DomProperty *a) DomGradient *DomBrush::takeElementGradient() { DomGradient *a = m_gradient; - m_gradient = 0; + m_gradient = nullptr; return a; } @@ -2871,7 +2851,7 @@ void DomColorRole::read(QXmlStreamReader &reader) case QXmlStreamReader::StartElement : { const QStringRef tag = reader.name(); if (!tag.compare(QLatin1String("brush"), Qt::CaseInsensitive)) { - DomBrush *v = new DomBrush(); + auto *v = new DomBrush(); v->read(reader); setElementBrush(v); continue; @@ -2903,7 +2883,7 @@ void DomColorRole::write(QXmlStreamWriter &writer, const QString &tagName) const DomBrush *DomColorRole::takeElementBrush() { DomBrush *a = m_brush; - m_brush = 0; + m_brush = nullptr; m_children ^= Brush; return a; } @@ -2918,7 +2898,7 @@ void DomColorRole::setElementBrush(DomBrush *a) void DomColorRole::clearElementBrush() { delete m_brush; - m_brush = 0; + m_brush = nullptr; m_children &= ~Brush; } @@ -2937,13 +2917,13 @@ void DomColorGroup::read(QXmlStreamReader &reader) case QXmlStreamReader::StartElement : { const QStringRef tag = reader.name(); if (!tag.compare(QLatin1String("colorrole"), Qt::CaseInsensitive)) { - DomColorRole *v = new DomColorRole(); + auto *v = new DomColorRole(); v->read(reader); m_colorRole.append(v); continue; } if (!tag.compare(QLatin1String("color"), Qt::CaseInsensitive)) { - DomColor *v = new DomColor(); + auto *v = new DomColor(); v->read(reader); m_color.append(v); continue; @@ -2998,19 +2978,19 @@ void DomPalette::read(QXmlStreamReader &reader) case QXmlStreamReader::StartElement : { const QStringRef tag = reader.name(); if (!tag.compare(QLatin1String("active"), Qt::CaseInsensitive)) { - DomColorGroup *v = new DomColorGroup(); + auto *v = new DomColorGroup(); v->read(reader); setElementActive(v); continue; } if (!tag.compare(QLatin1String("inactive"), Qt::CaseInsensitive)) { - DomColorGroup *v = new DomColorGroup(); + auto *v = new DomColorGroup(); v->read(reader); setElementInactive(v); continue; } if (!tag.compare(QLatin1String("disabled"), Qt::CaseInsensitive)) { - DomColorGroup *v = new DomColorGroup(); + auto *v = new DomColorGroup(); v->read(reader); setElementDisabled(v); continue; @@ -3045,7 +3025,7 @@ void DomPalette::write(QXmlStreamWriter &writer, const QString &tagName) const DomColorGroup *DomPalette::takeElementActive() { DomColorGroup *a = m_active; - m_active = 0; + m_active = nullptr; m_children ^= Active; return a; } @@ -3060,7 +3040,7 @@ void DomPalette::setElementActive(DomColorGroup *a) DomColorGroup *DomPalette::takeElementInactive() { DomColorGroup *a = m_inactive; - m_inactive = 0; + m_inactive = nullptr; m_children ^= Inactive; return a; } @@ -3075,7 +3055,7 @@ void DomPalette::setElementInactive(DomColorGroup *a) DomColorGroup *DomPalette::takeElementDisabled() { DomColorGroup *a = m_disabled; - m_disabled = 0; + m_disabled = nullptr; m_children ^= Disabled; return a; } @@ -3090,27 +3070,25 @@ void DomPalette::setElementDisabled(DomColorGroup *a) void DomPalette::clearElementActive() { delete m_active; - m_active = 0; + m_active = nullptr; m_children &= ~Active; } void DomPalette::clearElementInactive() { delete m_inactive; - m_inactive = 0; + m_inactive = nullptr; m_children &= ~Inactive; } void DomPalette::clearElementDisabled() { delete m_disabled; - m_disabled = 0; + m_disabled = nullptr; m_children &= ~Disabled; } -DomFont::~DomFont() -{ -} +DomFont::~DomFont() = default; void DomFont::read(QXmlStreamReader &reader) { @@ -3316,9 +3294,7 @@ void DomFont::clearElementKerning() m_children &= ~Kerning; } -DomPoint::~DomPoint() -{ -} +DomPoint::~DomPoint() = default; void DomPoint::read(QXmlStreamReader &reader) { @@ -3380,9 +3356,7 @@ void DomPoint::clearElementY() m_children &= ~Y; } -DomRect::~DomRect() -{ -} +DomRect::~DomRect() = default; void DomRect::read(QXmlStreamReader &reader) { @@ -3480,9 +3454,7 @@ void DomRect::clearElementHeight() m_children &= ~Height; } -DomLocale::~DomLocale() -{ -} +DomLocale::~DomLocale() = default; void DomLocale::read(QXmlStreamReader &reader) { @@ -3528,9 +3500,7 @@ void DomLocale::write(QXmlStreamWriter &writer, const QString &tagName) const writer.writeEndElement(); } -DomSizePolicy::~DomSizePolicy() -{ -} +DomSizePolicy::~DomSizePolicy() = default; void DomSizePolicy::read(QXmlStreamReader &reader) { @@ -3648,9 +3618,7 @@ void DomSizePolicy::clearElementVerStretch() m_children &= ~VerStretch; } -DomSize::~DomSize() -{ -} +DomSize::~DomSize() = default; void DomSize::read(QXmlStreamReader &reader) { @@ -3712,9 +3680,7 @@ void DomSize::clearElementHeight() m_children &= ~Height; } -DomDate::~DomDate() -{ -} +DomDate::~DomDate() = default; void DomDate::read(QXmlStreamReader &reader) { @@ -3794,9 +3760,7 @@ void DomDate::clearElementDay() m_children &= ~Day; } -DomTime::~DomTime() -{ -} +DomTime::~DomTime() = default; void DomTime::read(QXmlStreamReader &reader) { @@ -3876,9 +3840,7 @@ void DomTime::clearElementSecond() m_children &= ~Second; } -DomDateTime::~DomDateTime() -{ -} +DomDateTime::~DomDateTime() = default; void DomDateTime::read(QXmlStreamReader &reader) { @@ -4088,9 +4050,7 @@ void DomStringList::setElementString(const QStringList &a) m_string = a; } -DomResourcePixmap::~DomResourcePixmap() -{ -} +DomResourcePixmap::~DomResourcePixmap() = default; void DomResourcePixmap::read(QXmlStreamReader &reader) { @@ -4176,49 +4136,49 @@ void DomResourceIcon::read(QXmlStreamReader &reader) case QXmlStreamReader::StartElement : { const QStringRef tag = reader.name(); if (!tag.compare(QLatin1String("normaloff"), Qt::CaseInsensitive)) { - DomResourcePixmap *v = new DomResourcePixmap(); + auto *v = new DomResourcePixmap(); v->read(reader); setElementNormalOff(v); continue; } if (!tag.compare(QLatin1String("normalon"), Qt::CaseInsensitive)) { - DomResourcePixmap *v = new DomResourcePixmap(); + auto *v = new DomResourcePixmap(); v->read(reader); setElementNormalOn(v); continue; } if (!tag.compare(QLatin1String("disabledoff"), Qt::CaseInsensitive)) { - DomResourcePixmap *v = new DomResourcePixmap(); + auto *v = new DomResourcePixmap(); v->read(reader); setElementDisabledOff(v); continue; } if (!tag.compare(QLatin1String("disabledon"), Qt::CaseInsensitive)) { - DomResourcePixmap *v = new DomResourcePixmap(); + auto *v = new DomResourcePixmap(); v->read(reader); setElementDisabledOn(v); continue; } if (!tag.compare(QLatin1String("activeoff"), Qt::CaseInsensitive)) { - DomResourcePixmap *v = new DomResourcePixmap(); + auto *v = new DomResourcePixmap(); v->read(reader); setElementActiveOff(v); continue; } if (!tag.compare(QLatin1String("activeon"), Qt::CaseInsensitive)) { - DomResourcePixmap *v = new DomResourcePixmap(); + auto *v = new DomResourcePixmap(); v->read(reader); setElementActiveOn(v); continue; } if (!tag.compare(QLatin1String("selectedoff"), Qt::CaseInsensitive)) { - DomResourcePixmap *v = new DomResourcePixmap(); + auto *v = new DomResourcePixmap(); v->read(reader); setElementSelectedOff(v); continue; } if (!tag.compare(QLatin1String("selectedon"), Qt::CaseInsensitive)) { - DomResourcePixmap *v = new DomResourcePixmap(); + auto *v = new DomResourcePixmap(); v->read(reader); setElementSelectedOn(v); continue; @@ -4281,7 +4241,7 @@ void DomResourceIcon::write(QXmlStreamWriter &writer, const QString &tagName) co DomResourcePixmap *DomResourceIcon::takeElementNormalOff() { DomResourcePixmap *a = m_normalOff; - m_normalOff = 0; + m_normalOff = nullptr; m_children ^= NormalOff; return a; } @@ -4296,7 +4256,7 @@ void DomResourceIcon::setElementNormalOff(DomResourcePixmap *a) DomResourcePixmap *DomResourceIcon::takeElementNormalOn() { DomResourcePixmap *a = m_normalOn; - m_normalOn = 0; + m_normalOn = nullptr; m_children ^= NormalOn; return a; } @@ -4311,7 +4271,7 @@ void DomResourceIcon::setElementNormalOn(DomResourcePixmap *a) DomResourcePixmap *DomResourceIcon::takeElementDisabledOff() { DomResourcePixmap *a = m_disabledOff; - m_disabledOff = 0; + m_disabledOff = nullptr; m_children ^= DisabledOff; return a; } @@ -4326,7 +4286,7 @@ void DomResourceIcon::setElementDisabledOff(DomResourcePixmap *a) DomResourcePixmap *DomResourceIcon::takeElementDisabledOn() { DomResourcePixmap *a = m_disabledOn; - m_disabledOn = 0; + m_disabledOn = nullptr; m_children ^= DisabledOn; return a; } @@ -4341,7 +4301,7 @@ void DomResourceIcon::setElementDisabledOn(DomResourcePixmap *a) DomResourcePixmap *DomResourceIcon::takeElementActiveOff() { DomResourcePixmap *a = m_activeOff; - m_activeOff = 0; + m_activeOff = nullptr; m_children ^= ActiveOff; return a; } @@ -4356,7 +4316,7 @@ void DomResourceIcon::setElementActiveOff(DomResourcePixmap *a) DomResourcePixmap *DomResourceIcon::takeElementActiveOn() { DomResourcePixmap *a = m_activeOn; - m_activeOn = 0; + m_activeOn = nullptr; m_children ^= ActiveOn; return a; } @@ -4371,7 +4331,7 @@ void DomResourceIcon::setElementActiveOn(DomResourcePixmap *a) DomResourcePixmap *DomResourceIcon::takeElementSelectedOff() { DomResourcePixmap *a = m_selectedOff; - m_selectedOff = 0; + m_selectedOff = nullptr; m_children ^= SelectedOff; return a; } @@ -4386,7 +4346,7 @@ void DomResourceIcon::setElementSelectedOff(DomResourcePixmap *a) DomResourcePixmap *DomResourceIcon::takeElementSelectedOn() { DomResourcePixmap *a = m_selectedOn; - m_selectedOn = 0; + m_selectedOn = nullptr; m_children ^= SelectedOn; return a; } @@ -4401,62 +4361,60 @@ void DomResourceIcon::setElementSelectedOn(DomResourcePixmap *a) void DomResourceIcon::clearElementNormalOff() { delete m_normalOff; - m_normalOff = 0; + m_normalOff = nullptr; m_children &= ~NormalOff; } void DomResourceIcon::clearElementNormalOn() { delete m_normalOn; - m_normalOn = 0; + m_normalOn = nullptr; m_children &= ~NormalOn; } void DomResourceIcon::clearElementDisabledOff() { delete m_disabledOff; - m_disabledOff = 0; + m_disabledOff = nullptr; m_children &= ~DisabledOff; } void DomResourceIcon::clearElementDisabledOn() { delete m_disabledOn; - m_disabledOn = 0; + m_disabledOn = nullptr; m_children &= ~DisabledOn; } void DomResourceIcon::clearElementActiveOff() { delete m_activeOff; - m_activeOff = 0; + m_activeOff = nullptr; m_children &= ~ActiveOff; } void DomResourceIcon::clearElementActiveOn() { delete m_activeOn; - m_activeOn = 0; + m_activeOn = nullptr; m_children &= ~ActiveOn; } void DomResourceIcon::clearElementSelectedOff() { delete m_selectedOff; - m_selectedOff = 0; + m_selectedOff = nullptr; m_children &= ~SelectedOff; } void DomResourceIcon::clearElementSelectedOn() { delete m_selectedOn; - m_selectedOn = 0; + m_selectedOn = nullptr; m_children &= ~SelectedOn; } -DomString::~DomString() -{ -} +DomString::~DomString() = default; void DomString::read(QXmlStreamReader &reader) { @@ -4523,9 +4481,7 @@ void DomString::write(QXmlStreamWriter &writer, const QString &tagName) const writer.writeEndElement(); } -DomPointF::~DomPointF() -{ -} +DomPointF::~DomPointF() = default; void DomPointF::read(QXmlStreamReader &reader) { @@ -4587,9 +4543,7 @@ void DomPointF::clearElementY() m_children &= ~Y; } -DomRectF::~DomRectF() -{ -} +DomRectF::~DomRectF() = default; void DomRectF::read(QXmlStreamReader &reader) { @@ -4687,9 +4641,7 @@ void DomRectF::clearElementHeight() m_children &= ~Height; } -DomSizeF::~DomSizeF() -{ -} +DomSizeF::~DomSizeF() = default; void DomSizeF::read(QXmlStreamReader &reader) { @@ -4751,9 +4703,7 @@ void DomSizeF::clearElementHeight() m_children &= ~Height; } -DomChar::~DomChar() -{ -} +DomChar::~DomChar() = default; void DomChar::read(QXmlStreamReader &reader) { @@ -4809,7 +4759,7 @@ void DomUrl::read(QXmlStreamReader &reader) case QXmlStreamReader::StartElement : { const QStringRef tag = reader.name(); if (!tag.compare(QLatin1String("string"), Qt::CaseInsensitive)) { - DomString *v = new DomString(); + auto *v = new DomString(); v->read(reader); setElementString(v); continue; @@ -4838,7 +4788,7 @@ void DomUrl::write(QXmlStreamWriter &writer, const QString &tagName) const DomString *DomUrl::takeElementString() { DomString *a = m_string; - m_string = 0; + m_string = nullptr; m_children ^= String; return a; } @@ -4853,7 +4803,7 @@ void DomUrl::setElementString(DomString *a) void DomUrl::clearElementString() { delete m_string; - m_string = 0; + m_string = nullptr; m_children &= ~String; } @@ -4963,7 +4913,7 @@ void DomProperty::read(QXmlStreamReader &reader) continue; } if (!tag.compare(QLatin1String("color"), Qt::CaseInsensitive)) { - DomColor *v = new DomColor(); + auto *v = new DomColor(); v->read(reader); setElementColor(v); continue; @@ -4985,37 +4935,37 @@ void DomProperty::read(QXmlStreamReader &reader) continue; } if (!tag.compare(QLatin1String("font"), Qt::CaseInsensitive)) { - DomFont *v = new DomFont(); + auto *v = new DomFont(); v->read(reader); setElementFont(v); continue; } if (!tag.compare(QLatin1String("iconset"), Qt::CaseInsensitive)) { - DomResourceIcon *v = new DomResourceIcon(); + auto *v = new DomResourceIcon(); v->read(reader); setElementIconSet(v); continue; } if (!tag.compare(QLatin1String("pixmap"), Qt::CaseInsensitive)) { - DomResourcePixmap *v = new DomResourcePixmap(); + auto *v = new DomResourcePixmap(); v->read(reader); setElementPixmap(v); continue; } if (!tag.compare(QLatin1String("palette"), Qt::CaseInsensitive)) { - DomPalette *v = new DomPalette(); + auto *v = new DomPalette(); v->read(reader); setElementPalette(v); continue; } if (!tag.compare(QLatin1String("point"), Qt::CaseInsensitive)) { - DomPoint *v = new DomPoint(); + auto *v = new DomPoint(); v->read(reader); setElementPoint(v); continue; } if (!tag.compare(QLatin1String("rect"), Qt::CaseInsensitive)) { - DomRect *v = new DomRect(); + auto *v = new DomRect(); v->read(reader); setElementRect(v); continue; @@ -5025,31 +4975,31 @@ void DomProperty::read(QXmlStreamReader &reader) continue; } if (!tag.compare(QLatin1String("locale"), Qt::CaseInsensitive)) { - DomLocale *v = new DomLocale(); + auto *v = new DomLocale(); v->read(reader); setElementLocale(v); continue; } if (!tag.compare(QLatin1String("sizepolicy"), Qt::CaseInsensitive)) { - DomSizePolicy *v = new DomSizePolicy(); + auto *v = new DomSizePolicy(); v->read(reader); setElementSizePolicy(v); continue; } if (!tag.compare(QLatin1String("size"), Qt::CaseInsensitive)) { - DomSize *v = new DomSize(); + auto *v = new DomSize(); v->read(reader); setElementSize(v); continue; } if (!tag.compare(QLatin1String("string"), Qt::CaseInsensitive)) { - DomString *v = new DomString(); + auto *v = new DomString(); v->read(reader); setElementString(v); continue; } if (!tag.compare(QLatin1String("stringlist"), Qt::CaseInsensitive)) { - DomStringList *v = new DomStringList(); + auto *v = new DomStringList(); v->read(reader); setElementStringList(v); continue; @@ -5067,37 +5017,37 @@ void DomProperty::read(QXmlStreamReader &reader) continue; } if (!tag.compare(QLatin1String("date"), Qt::CaseInsensitive)) { - DomDate *v = new DomDate(); + auto *v = new DomDate(); v->read(reader); setElementDate(v); continue; } if (!tag.compare(QLatin1String("time"), Qt::CaseInsensitive)) { - DomTime *v = new DomTime(); + auto *v = new DomTime(); v->read(reader); setElementTime(v); continue; } if (!tag.compare(QLatin1String("datetime"), Qt::CaseInsensitive)) { - DomDateTime *v = new DomDateTime(); + auto *v = new DomDateTime(); v->read(reader); setElementDateTime(v); continue; } if (!tag.compare(QLatin1String("pointf"), Qt::CaseInsensitive)) { - DomPointF *v = new DomPointF(); + auto *v = new DomPointF(); v->read(reader); setElementPointF(v); continue; } if (!tag.compare(QLatin1String("rectf"), Qt::CaseInsensitive)) { - DomRectF *v = new DomRectF(); + auto *v = new DomRectF(); v->read(reader); setElementRectF(v); continue; } if (!tag.compare(QLatin1String("sizef"), Qt::CaseInsensitive)) { - DomSizeF *v = new DomSizeF(); + auto *v = new DomSizeF(); v->read(reader); setElementSizeF(v); continue; @@ -5107,13 +5057,13 @@ void DomProperty::read(QXmlStreamReader &reader) continue; } if (!tag.compare(QLatin1String("char"), Qt::CaseInsensitive)) { - DomChar *v = new DomChar(); + auto *v = new DomChar(); v->read(reader); setElementChar(v); continue; } if (!tag.compare(QLatin1String("url"), Qt::CaseInsensitive)) { - DomUrl *v = new DomUrl(); + auto *v = new DomUrl(); v->read(reader); setElementUrl(v); continue; @@ -5127,7 +5077,7 @@ void DomProperty::read(QXmlStreamReader &reader) continue; } if (!tag.compare(QLatin1String("brush"), Qt::CaseInsensitive)) { - DomBrush *v = new DomBrush(); + auto *v = new DomBrush(); v->read(reader); setElementBrush(v); continue; @@ -5154,180 +5104,159 @@ void DomProperty::write(QXmlStreamWriter &writer, const QString &tagName) const writer.writeAttribute(QStringLiteral("stdset"), QString::number(attributeStdset())); switch (kind()) { - case Bool: { + case Bool: writer.writeTextElement(QStringLiteral("bool"), elementBool()); break; - } - case Color: { - DomColor *v = elementColor(); - if (v != 0) - v->write(writer, QStringLiteral("color")); + + case Color: + if (m_color != nullptr) + m_color->write(writer, QStringLiteral("color")); break; - } - case Cstring: { + + case Cstring: writer.writeTextElement(QStringLiteral("cstring"), elementCstring()); break; - } - case Cursor: { + + case Cursor: writer.writeTextElement(QStringLiteral("cursor"), QString::number(elementCursor())); break; - } - case CursorShape: { + + case CursorShape: writer.writeTextElement(QStringLiteral("cursorShape"), elementCursorShape()); break; - } - case Enum: { + + case Enum: writer.writeTextElement(QStringLiteral("enum"), elementEnum()); break; - } - case Font: { - DomFont *v = elementFont(); - if (v != 0) - v->write(writer, QStringLiteral("font")); + + case Font: + if (m_font != nullptr) + m_font->write(writer, QStringLiteral("font")); break; - } - case IconSet: { - DomResourceIcon *v = elementIconSet(); - if (v != 0) - v->write(writer, QStringLiteral("iconset")); + + case IconSet: + if (m_iconSet != nullptr) + m_iconSet->write(writer, QStringLiteral("iconset")); break; - } - case Pixmap: { - DomResourcePixmap *v = elementPixmap(); - if (v != 0) - v->write(writer, QStringLiteral("pixmap")); + + case Pixmap: + if (m_pixmap != nullptr) + m_pixmap->write(writer, QStringLiteral("pixmap")); break; - } - case Palette: { - DomPalette *v = elementPalette(); - if (v != 0) - v->write(writer, QStringLiteral("palette")); + + case Palette: + if (m_palette != nullptr) + m_palette->write(writer, QStringLiteral("palette")); break; - } - case Point: { - DomPoint *v = elementPoint(); - if (v != 0) - v->write(writer, QStringLiteral("point")); + + case Point: + if (m_point != nullptr) + m_point->write(writer, QStringLiteral("point")); break; - } - case Rect: { - DomRect *v = elementRect(); - if (v != 0) - v->write(writer, QStringLiteral("rect")); + + case Rect: + if (m_rect != nullptr) + m_rect->write(writer, QStringLiteral("rect")); break; - } - case Set: { + + case Set: writer.writeTextElement(QStringLiteral("set"), elementSet()); break; - } - case Locale: { - DomLocale *v = elementLocale(); - if (v != 0) - v->write(writer, QStringLiteral("locale")); + + case Locale: + if (m_locale != nullptr) + m_locale->write(writer, QStringLiteral("locale")); break; - } - case SizePolicy: { - DomSizePolicy *v = elementSizePolicy(); - if (v != 0) - v->write(writer, QStringLiteral("sizepolicy")); + + case SizePolicy: + if (m_sizePolicy != nullptr) + m_sizePolicy->write(writer, QStringLiteral("sizepolicy")); break; - } - case Size: { - DomSize *v = elementSize(); - if (v != 0) - v->write(writer, QStringLiteral("size")); + + case Size: + if (m_size != nullptr) + m_size->write(writer, QStringLiteral("size")); break; - } - case String: { - DomString *v = elementString(); - if (v != 0) - v->write(writer, QStringLiteral("string")); + + case String: + if (m_string != nullptr) + m_string->write(writer, QStringLiteral("string")); break; - } - case StringList: { - DomStringList *v = elementStringList(); - if (v != 0) - v->write(writer, QStringLiteral("stringlist")); + + case StringList: + if (m_stringList != nullptr) + m_stringList->write(writer, QStringLiteral("stringlist")); break; - } - case Number: { + + case Number: writer.writeTextElement(QStringLiteral("number"), QString::number(elementNumber())); break; - } - case Float: { + + case Float: writer.writeTextElement(QStringLiteral("float"), QString::number(elementFloat(), 'f', 8)); break; - } - case Double: { + + case Double: writer.writeTextElement(QStringLiteral("double"), QString::number(elementDouble(), 'f', 15)); break; - } - case Date: { - DomDate *v = elementDate(); - if (v != 0) - v->write(writer, QStringLiteral("date")); + + case Date: + if (m_date != nullptr) + m_date->write(writer, QStringLiteral("date")); break; - } - case Time: { - DomTime *v = elementTime(); - if (v != 0) - v->write(writer, QStringLiteral("time")); + + case Time: + if (m_time != nullptr) + m_time->write(writer, QStringLiteral("time")); break; - } - case DateTime: { - DomDateTime *v = elementDateTime(); - if (v != 0) - v->write(writer, QStringLiteral("datetime")); + + case DateTime: + if (m_dateTime != nullptr) + m_dateTime->write(writer, QStringLiteral("datetime")); break; - } - case PointF: { - DomPointF *v = elementPointF(); - if (v != 0) - v->write(writer, QStringLiteral("pointf")); + + case PointF: + if (m_pointF != nullptr) + m_pointF->write(writer, QStringLiteral("pointf")); break; - } - case RectF: { - DomRectF *v = elementRectF(); - if (v != 0) - v->write(writer, QStringLiteral("rectf")); + + case RectF: + if (m_rectF != nullptr) + m_rectF->write(writer, QStringLiteral("rectf")); break; - } - case SizeF: { - DomSizeF *v = elementSizeF(); - if (v != 0) - v->write(writer, QStringLiteral("sizef")); + + case SizeF: + if (m_sizeF != nullptr) + m_sizeF->write(writer, QStringLiteral("sizef")); break; - } - case LongLong: { + + case LongLong: writer.writeTextElement(QStringLiteral("longLong"), QString::number(elementLongLong())); break; - } - case Char: { - DomChar *v = elementChar(); - if (v != 0) - v->write(writer, QStringLiteral("char")); + + case Char: + if (m_char != nullptr) + m_char->write(writer, QStringLiteral("char")); break; - } - case Url: { - DomUrl *v = elementUrl(); - if (v != 0) - v->write(writer, QStringLiteral("url")); + + case Url: + if (m_url != nullptr) + m_url->write(writer, QStringLiteral("url")); break; - } - case UInt: { + + case UInt: writer.writeTextElement(QStringLiteral("UInt"), QString::number(elementUInt())); break; - } - case ULongLong: { + + case ULongLong: writer.writeTextElement(QStringLiteral("uLongLong"), QString::number(elementULongLong())); break; - } - case Brush: { - DomBrush *v = elementBrush(); - if (v != 0) - v->write(writer, QStringLiteral("brush")); + + case Brush: + if (m_brush != nullptr) + m_brush->write(writer, QStringLiteral("brush")); break; - } + default: break; } @@ -5344,7 +5273,7 @@ void DomProperty::setElementBool(const QString &a) DomColor *DomProperty::takeElementColor() { DomColor *a = m_color; - m_color = 0; + m_color = nullptr; return a; } @@ -5386,7 +5315,7 @@ void DomProperty::setElementEnum(const QString &a) DomFont *DomProperty::takeElementFont() { DomFont *a = m_font; - m_font = 0; + m_font = nullptr; return a; } @@ -5400,7 +5329,7 @@ void DomProperty::setElementFont(DomFont *a) DomResourceIcon *DomProperty::takeElementIconSet() { DomResourceIcon *a = m_iconSet; - m_iconSet = 0; + m_iconSet = nullptr; return a; } @@ -5414,7 +5343,7 @@ void DomProperty::setElementIconSet(DomResourceIcon *a) DomResourcePixmap *DomProperty::takeElementPixmap() { DomResourcePixmap *a = m_pixmap; - m_pixmap = 0; + m_pixmap = nullptr; return a; } @@ -5428,7 +5357,7 @@ void DomProperty::setElementPixmap(DomResourcePixmap *a) DomPalette *DomProperty::takeElementPalette() { DomPalette *a = m_palette; - m_palette = 0; + m_palette = nullptr; return a; } @@ -5442,7 +5371,7 @@ void DomProperty::setElementPalette(DomPalette *a) DomPoint *DomProperty::takeElementPoint() { DomPoint *a = m_point; - m_point = 0; + m_point = nullptr; return a; } @@ -5456,7 +5385,7 @@ void DomProperty::setElementPoint(DomPoint *a) DomRect *DomProperty::takeElementRect() { DomRect *a = m_rect; - m_rect = 0; + m_rect = nullptr; return a; } @@ -5477,7 +5406,7 @@ void DomProperty::setElementSet(const QString &a) DomLocale *DomProperty::takeElementLocale() { DomLocale *a = m_locale; - m_locale = 0; + m_locale = nullptr; return a; } @@ -5491,7 +5420,7 @@ void DomProperty::setElementLocale(DomLocale *a) DomSizePolicy *DomProperty::takeElementSizePolicy() { DomSizePolicy *a = m_sizePolicy; - m_sizePolicy = 0; + m_sizePolicy = nullptr; return a; } @@ -5505,7 +5434,7 @@ void DomProperty::setElementSizePolicy(DomSizePolicy *a) DomSize *DomProperty::takeElementSize() { DomSize *a = m_size; - m_size = 0; + m_size = nullptr; return a; } @@ -5519,7 +5448,7 @@ void DomProperty::setElementSize(DomSize *a) DomString *DomProperty::takeElementString() { DomString *a = m_string; - m_string = 0; + m_string = nullptr; return a; } @@ -5533,7 +5462,7 @@ void DomProperty::setElementString(DomString *a) DomStringList *DomProperty::takeElementStringList() { DomStringList *a = m_stringList; - m_stringList = 0; + m_stringList = nullptr; return a; } @@ -5568,7 +5497,7 @@ void DomProperty::setElementDouble(double a) DomDate *DomProperty::takeElementDate() { DomDate *a = m_date; - m_date = 0; + m_date = nullptr; return a; } @@ -5582,7 +5511,7 @@ void DomProperty::setElementDate(DomDate *a) DomTime *DomProperty::takeElementTime() { DomTime *a = m_time; - m_time = 0; + m_time = nullptr; return a; } @@ -5596,7 +5525,7 @@ void DomProperty::setElementTime(DomTime *a) DomDateTime *DomProperty::takeElementDateTime() { DomDateTime *a = m_dateTime; - m_dateTime = 0; + m_dateTime = nullptr; return a; } @@ -5610,7 +5539,7 @@ void DomProperty::setElementDateTime(DomDateTime *a) DomPointF *DomProperty::takeElementPointF() { DomPointF *a = m_pointF; - m_pointF = 0; + m_pointF = nullptr; return a; } @@ -5624,7 +5553,7 @@ void DomProperty::setElementPointF(DomPointF *a) DomRectF *DomProperty::takeElementRectF() { DomRectF *a = m_rectF; - m_rectF = 0; + m_rectF = nullptr; return a; } @@ -5638,7 +5567,7 @@ void DomProperty::setElementRectF(DomRectF *a) DomSizeF *DomProperty::takeElementSizeF() { DomSizeF *a = m_sizeF; - m_sizeF = 0; + m_sizeF = nullptr; return a; } @@ -5659,7 +5588,7 @@ void DomProperty::setElementLongLong(qlonglong a) DomChar *DomProperty::takeElementChar() { DomChar *a = m_char; - m_char = 0; + m_char = nullptr; return a; } @@ -5673,7 +5602,7 @@ void DomProperty::setElementChar(DomChar *a) DomUrl *DomProperty::takeElementUrl() { DomUrl *a = m_url; - m_url = 0; + m_url = nullptr; return a; } @@ -5701,7 +5630,7 @@ void DomProperty::setElementULongLong(qulonglong a) DomBrush *DomProperty::takeElementBrush() { DomBrush *a = m_brush; - m_brush = 0; + m_brush = nullptr; return a; } @@ -5725,7 +5654,7 @@ void DomConnections::read(QXmlStreamReader &reader) case QXmlStreamReader::StartElement : { const QStringRef tag = reader.name(); if (!tag.compare(QLatin1String("connection"), Qt::CaseInsensitive)) { - DomConnection *v = new DomConnection(); + auto *v = new DomConnection(); v->read(reader); m_connection.append(v); continue; @@ -5785,7 +5714,7 @@ void DomConnection::read(QXmlStreamReader &reader) continue; } if (!tag.compare(QLatin1String("hints"), Qt::CaseInsensitive)) { - DomConnectionHints *v = new DomConnectionHints(); + auto *v = new DomConnectionHints(); v->read(reader); setElementHints(v); continue; @@ -5850,7 +5779,7 @@ void DomConnection::setElementSlot(const QString &a) DomConnectionHints *DomConnection::takeElementHints() { DomConnectionHints *a = m_hints; - m_hints = 0; + m_hints = nullptr; m_children ^= Hints; return a; } @@ -5885,7 +5814,7 @@ void DomConnection::clearElementSlot() void DomConnection::clearElementHints() { delete m_hints; - m_hints = 0; + m_hints = nullptr; m_children &= ~Hints; } @@ -5902,7 +5831,7 @@ void DomConnectionHints::read(QXmlStreamReader &reader) case QXmlStreamReader::StartElement : { const QStringRef tag = reader.name(); if (!tag.compare(QLatin1String("hint"), Qt::CaseInsensitive)) { - DomConnectionHint *v = new DomConnectionHint(); + auto *v = new DomConnectionHint(); v->read(reader); m_hint.append(v); continue; @@ -5934,9 +5863,7 @@ void DomConnectionHints::setElementHint(const QVector<DomConnectionHint *> &a) m_hint = a; } -DomConnectionHint::~DomConnectionHint() -{ -} +DomConnectionHint::~DomConnectionHint() = default; void DomConnectionHint::read(QXmlStreamReader &reader) { @@ -6024,7 +5951,7 @@ void DomDesignerData::read(QXmlStreamReader &reader) case QXmlStreamReader::StartElement : { const QStringRef tag = reader.name(); if (!tag.compare(QLatin1String("property"), Qt::CaseInsensitive)) { - DomProperty *v = new DomProperty(); + auto *v = new DomProperty(); v->read(reader); m_property.append(v); continue; @@ -6127,13 +6054,13 @@ void DomPropertySpecifications::read(QXmlStreamReader &reader) case QXmlStreamReader::StartElement : { const QStringRef tag = reader.name(); if (!tag.compare(QLatin1String("tooltip"), Qt::CaseInsensitive)) { - DomPropertyToolTip *v = new DomPropertyToolTip(); + auto *v = new DomPropertyToolTip(); v->read(reader); m_tooltip.append(v); continue; } if (!tag.compare(QLatin1String("stringpropertyspecification"), Qt::CaseInsensitive)) { - DomStringPropertySpecification *v = new DomStringPropertySpecification(); + auto *v = new DomStringPropertySpecification(); v->read(reader); m_stringpropertyspecification.append(v); continue; @@ -6174,9 +6101,7 @@ void DomPropertySpecifications::setElementStringpropertyspecification(const QVec m_stringpropertyspecification = a; } -DomPropertyToolTip::~DomPropertyToolTip() -{ -} +DomPropertyToolTip::~DomPropertyToolTip() = default; void DomPropertyToolTip::read(QXmlStreamReader &reader) { @@ -6215,9 +6140,7 @@ void DomPropertyToolTip::write(QXmlStreamWriter &writer, const QString &tagName) writer.writeEndElement(); } -DomStringPropertySpecification::~DomStringPropertySpecification() -{ -} +DomStringPropertySpecification::~DomStringPropertySpecification() = default; void DomStringPropertySpecification::read(QXmlStreamReader &reader) { diff --git a/src/tools/uic/uic.cpp b/src/tools/uic/uic.cpp index 8e4709c831..957a50b1d5 100644 --- a/src/tools/uic/uic.cpp +++ b/src/tools/uic/uic.cpp @@ -56,9 +56,7 @@ Uic::Uic(Driver *d) { } -Uic::~Uic() -{ -} +Uic::~Uic() = default; bool Uic::printDependencies() { diff --git a/src/tools/uic/uic.h b/src/tools/uic/uic.h index e00dc595bc..1c229bc516 100644 --- a/src/tools/uic/uic.h +++ b/src/tools/uic/uic.h @@ -53,6 +53,7 @@ struct Option; class Uic { + Q_DISABLE_COPY(Uic) public: Uic(Driver *driver); ~Uic(); diff --git a/src/tools/uic/utils.h b/src/tools/uic/utils.h index 18b361fb81..3f32a532ca 100644 --- a/src/tools/uic/utils.h +++ b/src/tools/uic/utils.h @@ -42,27 +42,18 @@ inline bool toBool(const QString &str) inline QString toString(const DomString *str) { return str ? str->text() : QString(); } -enum StringFlags { - Utf8String = 0x1, - MultiLineString = 0x2 -}; - -inline QString fixString(const QString &str, const QString &indent, - unsigned *stringFlags = 0) +inline QString fixString(const QString &str, const QString &indent) { QString cursegment; QStringList result; const QByteArray utf8 = str.toUtf8(); const int utf8Length = utf8.length(); - unsigned flags = 0; - for (int i = 0; i < utf8Length; ++i) { const uchar cbyte = utf8.at(i); if (cbyte >= 0x80) { cursegment += QLatin1Char('\\'); cursegment += QString::number(cbyte, 8); - flags |= Utf8String; } else { switch(cbyte) { case '\\': @@ -72,7 +63,6 @@ inline QString fixString(const QString &str, const QString &indent, case '\r': break; case '\n': - flags |= MultiLineString; cursegment += QLatin1String("\\n\"\n\""); break; default: cursegment += QLatin1Char(cbyte); @@ -98,24 +88,14 @@ inline QString fixString(const QString &str, const QString &indent, rc += result.join(joinstr); rc += QLatin1Char('"'); - if (result.size() > 1) - flags |= MultiLineString; - - if (stringFlags) - *stringFlags = flags; - return rc; } inline QHash<QString, DomProperty *> propertyMap(const QList<DomProperty *> &properties) { QHash<QString, DomProperty *> map; - - for (int i=0; i<properties.size(); ++i) { - DomProperty *p = properties.at(i); - map.insert(p->attributeName(), p); - } - + for (DomProperty *p : properties) + map.insert(p->attributeName(), p); return map; } |