summaryrefslogtreecommitdiffstats
path: root/src/tools
diff options
context:
space:
mode:
Diffstat (limited to 'src/tools')
-rw-r--r--src/tools/bootstrap/bootstrap.pri20
-rw-r--r--src/tools/idc/main.cpp78
-rw-r--r--src/tools/moc/generator.cpp41
-rw-r--r--src/tools/moc/moc.cpp60
-rw-r--r--src/tools/moc/moc.h7
-rw-r--r--src/tools/moc/outputrevision.h2
-rw-r--r--src/tools/moc/preprocessor.cpp2
-rw-r--r--src/tools/uic/cpp/cppwriteicondata.cpp4
-rw-r--r--src/tools/uic/cpp/cppwriteinitialization.cpp28
-rw-r--r--src/tools/uic/ui4.cpp245
-rw-r--r--src/tools/uic/ui4.h97
-rw-r--r--src/tools/uic/uic.cpp4
-rw-r--r--src/tools/uic3/converter.cpp17
-rw-r--r--src/tools/uic3/embed.cpp2
-rw-r--r--src/tools/uic3/form.cpp84
-rw-r--r--src/tools/uic3/main.cpp8
-rw-r--r--src/tools/uic3/parser.cpp12
-rw-r--r--src/tools/uic3/qt3to4.cpp2
-rw-r--r--src/tools/uic3/subclassing.cpp36
-rw-r--r--src/tools/uic3/ui3reader.cpp24
-rw-r--r--src/tools/uic3/uic.cpp4
21 files changed, 578 insertions, 199 deletions
diff --git a/src/tools/bootstrap/bootstrap.pri b/src/tools/bootstrap/bootstrap.pri
index 1cf103b..b4f9b2f 100644
--- a/src/tools/bootstrap/bootstrap.pri
+++ b/src/tools/bootstrap/bootstrap.pri
@@ -28,26 +28,26 @@ win32:DEFINES += QT_NODLL
INCLUDEPATH += $$QT_BUILD_TREE/include \
$$QT_BUILD_TREE/include/QtCore \
$$QT_BUILD_TREE/include/QtXml \
- ../../xml
+ $$QT_SOURCE_TREE/src/xml
DEPENDPATH += $$INCLUDEPATH \
- ../../corelib/global \
- ../../corelib/kernel \
- ../../corelib/tools \
- ../../corelib/io \
- ../../corelib/codecs \
- ../../xml
+ $$QT_SOURCE_TREE/src/corelib/global \
+ $$QT_SOURCE_TREE/src/corelib/kernel \
+ $$QT_SOURCE_TREE/src/corelib/tools \
+ $$QT_SOURCE_TREE/src/corelib/io \
+ $$QT_SOURCE_TREE/src/corelib/codecs \
+ $$QT_SOURCE_TREE/src/xml
hpux-acc*|hpuxi-acc* {
LIBS += ../bootstrap/libbootstrap.a
} else {
contains(CONFIG, debug_and_release_target) {
CONFIG(debug, debug|release) {
- LIBS+=-L../bootstrap/debug
+ LIBS+=-L$$QT_BUILD_TREE/src/tools/bootstrap/debug
} else {
- LIBS+=-L../bootstrap/release
+ LIBS+=-L$$QT_BUILD_TREE/src/tools/bootstrap/release
}
} else {
- LIBS += -L../bootstrap
+ LIBS += -L$$QT_BUILD_TREE/src/tools/bootstrap
}
LIBS += -lbootstrap
}
diff --git a/src/tools/idc/main.cpp b/src/tools/idc/main.cpp
index 83d5fec..8fe8a70 100644
--- a/src/tools/idc/main.cpp
+++ b/src/tools/idc/main.cpp
@@ -40,7 +40,6 @@
****************************************************************************/
#include <QFile>
-#include <QSysInfo>
#include <QProcess>
#include <QLibraryInfo>
#include <qt_windows.h>
@@ -50,8 +49,8 @@ QT_BEGIN_NAMESPACE
static QString quotePath(const QString &s)
{
- if (!s.startsWith(QLatin1String("\"")) && s.contains(QLatin1Char(' ')))
- return QLatin1String("\"") + s + QLatin1String("\"");
+ if (!s.startsWith(QLatin1Char('\"')) && s.contains(QLatin1Char(' ')))
+ return QLatin1Char('\"') + s + QLatin1Char('\"');
return s;
}
@@ -87,37 +86,19 @@ static bool runWithQtInEnvironment(const QString &cmd)
static bool attachTypeLibrary(const QString &applicationName, int resource, const QByteArray &data, QString *errorMessage)
{
- HANDLE hExe = 0;
- QT_WA({
- TCHAR *resourceName = MAKEINTRESOURCEW(resource);
- hExe = BeginUpdateResourceW((TCHAR*)applicationName.utf16(), false);
- if (hExe == 0) {
- if (errorMessage)
- *errorMessage = QString::fromLatin1("Failed to attach type library to binary %1 - could not open file.").arg(applicationName);
- return false;
- }
- if (!UpdateResourceW(hExe,L"TYPELIB",resourceName,0,(void*)data.data(),data.count())) {
- EndUpdateResource(hExe, true);
- if (errorMessage)
- *errorMessage = QString::fromLatin1("Failed to attach type library to binary %1 - could not update file.").arg(applicationName);
- return false;
- }
- }, {
- char *resourceName = MAKEINTRESOURCEA(resource);
- hExe = BeginUpdateResourceA(applicationName.toLocal8Bit(), false);
- if (hExe == 0) {
- if (errorMessage)
- *errorMessage = QString::fromLatin1("Failed to attach type library to binary %1 - could not open file.").arg(applicationName);
- return false;
- }
- if (!UpdateResourceA(hExe,"TYPELIB",resourceName,0,(void*)data.data(),data.count())) {
- EndUpdateResource(hExe, true);
- if (errorMessage)
- *errorMessage = QString::fromLatin1("Failed to attach type library to binary %1 - could not update file.").arg(applicationName);
- return false;
- }
- });
-
+ HANDLE hExe = BeginUpdateResource((const wchar_t *)applicationName.utf16(), false);
+ if (hExe == 0) {
+ if (errorMessage)
+ *errorMessage = QString::fromLatin1("Failed to attach type library to binary %1 - could not open file.").arg(applicationName);
+ return false;
+ }
+ if (!UpdateResource(hExe, L"TYPELIB", MAKEINTRESOURCE(resource), 0, (void*)data.data(), data.count())) {
+ EndUpdateResource(hExe, true);
+ if (errorMessage)
+ *errorMessage = QString::fromLatin1("Failed to attach type library to binary %1 - could not update file.").arg(applicationName);
+ return false;
+ }
+
if (!EndUpdateResource(hExe,false)) {
if (errorMessage)
*errorMessage = QString::fromLatin1("Failed to attach type library to binary %1 - could not write file.").arg(applicationName);
@@ -135,12 +116,7 @@ static bool registerServer(const QString &input)
if (input.endsWith(QLatin1String(".exe"))) {
ok = runWithQtInEnvironment(quotePath(input) + QLatin1String(" -regserver"));
} else {
- HMODULE hdll = 0;
- QT_WA({
- hdll = LoadLibraryW((TCHAR*)input.utf16());
- }, {
- hdll = LoadLibraryA(input.toLocal8Bit());
- });
+ HMODULE hdll = LoadLibrary((const wchar_t *)input.utf16());
if (!hdll) {
fprintf(stderr, "Couldn't load library file %s\n", (const char*)input.toLocal8Bit().data());
return false;
@@ -162,12 +138,7 @@ static bool unregisterServer(const QString &input)
if (input.endsWith(QLatin1String(".exe"))) {
ok = runWithQtInEnvironment(quotePath(input) + QLatin1String(" -unregserver"));
} else {
- HMODULE hdll = 0;
- QT_WA({
- hdll = LoadLibraryW((TCHAR*)input.utf16());
- }, {
- hdll = LoadLibraryA(input.toLocal8Bit());
- });
+ HMODULE hdll = LoadLibrary((const wchar_t *)input.utf16());
if (!hdll) {
fprintf(stderr, "Couldn't load library file %s\n", (const char*)input.toLocal8Bit().data());
return false;
@@ -191,12 +162,7 @@ static HRESULT dumpIdl(const QString &input, const QString &idlfile, const QStri
if (runWithQtInEnvironment(quotePath(input) + QLatin1String(" -dumpidl ") + idlfile + QLatin1String(" -version ") + version))
res = S_OK;
} else {
- HMODULE hdll = 0;
- QT_WA({
- hdll = LoadLibraryW((TCHAR*)input.utf16());
- }, {
- hdll = LoadLibraryA(input.toLocal8Bit());
- });
+ HMODULE hdll = LoadLibrary((const wchar_t *)input.utf16());
if (!hdll) {
fprintf(stderr, "Couldn't load library file %s\n", (const char*)input.toLocal8Bit().data());
return 3;
@@ -254,9 +220,6 @@ int runIdc(int argc, char **argv)
else
version = QLatin1String(argv[i]);
} else if (p == QLatin1String("/tlb") || p == QLatin1String("-tlb")) {
- if (QSysInfo::WindowsVersion & QSysInfo::WV_DOS_based)
- fprintf(stderr, "IDC requires Windows NT/2000/XP!\n");
-
++i;
if (i > argc) {
error = QLatin1String("Missing name for type library file!");
@@ -282,7 +245,7 @@ int runIdc(int argc, char **argv)
fprintf(stderr, "Server unregistered successfully!\n");
return 0;
} else if (p[0] == QLatin1Char('/') || p[0] == QLatin1Char('-')) {
- error = QLatin1String("Unknown option \"") + p + QLatin1String("\"");
+ error = QLatin1String("Unknown option \"") + p + QLatin1Char('\"');
break;
} else {
input = QLatin1String(argv[i]);
@@ -331,6 +294,9 @@ int runIdc(int argc, char **argv)
switch(res) {
case S_OK:
break;
+ case E_FAIL:
+ fprintf(stderr, "IDL generation failed trying to run program %s!\n", (const char*)input.toLocal8Bit().data());
+ return res;
case -1:
fprintf(stderr, "Couldn't open %s for writing!\n", (const char*)idlfile.toLocal8Bit().data());
return res;
diff --git a/src/tools/moc/generator.cpp b/src/tools/moc/generator.cpp
index 54305a3..e3ce2ec 100644
--- a/src/tools/moc/generator.cpp
+++ b/src/tools/moc/generator.cpp
@@ -56,6 +56,8 @@ enum PropertyFlags {
EnumOrFlag = 0x00000008,
StdCppSet = 0x00000100,
// Override = 0x00000200,
+ Constant = 0x00000400,
+ Final = 0x00000800,
Designable = 0x00001000,
ResolveDesignable = 0x00002000,
Scriptable = 0x00004000,
@@ -68,6 +70,7 @@ enum PropertyFlags {
ResolveUser = 0x00200000,
Notify = 0x00400000
};
+
enum MethodFlags {
AccessPrivate = 0x00,
AccessProtected = 0x01,
@@ -109,6 +112,14 @@ bool isVariantType(const char* type)
return qvariant_nameToType(type) != 0;
}
+/*!
+ Returns true if the type is qreal.
+*/
+static bool isQRealType(const char *type)
+{
+ return strcmp(type, "qreal") == 0;
+}
+
Generator::Generator(ClassDef *classDef, const QList<QByteArray> &metaTypes, FILE *outfile)
: out(outfile), cdef(classDef), metaTypes(metaTypes)
{
@@ -194,10 +205,10 @@ void Generator::generateCode()
QByteArray qualifiedClassNameIdentifier = cdef->qualified;
qualifiedClassNameIdentifier.replace(':', '_');
- int index = 12;
+ int index = 13;
fprintf(out, "static const uint qt_meta_data_%s[] = {\n", qualifiedClassNameIdentifier.constData());
fprintf(out, "\n // content:\n");
- fprintf(out, " %4d, // revision\n", 2);
+ fprintf(out, " %4d, // revision\n", 3);
fprintf(out, " %4d, // classname\n", strreg(cdef->qualified));
fprintf(out, " %4d, %4d, // classinfo\n", cdef->classInfoList.count(), cdef->classInfoList.count() ? index : 0);
index += cdef->classInfoList.count() * 2;
@@ -217,6 +228,9 @@ void Generator::generateCode()
fprintf(out, " %4d, %4d, // constructors\n", isConstructible ? cdef->constructorList.count() : 0,
isConstructible ? index : 0);
+ fprintf(out, " %4d, // flags\n", 0);
+
+
//
// Build classinfo array
//
@@ -371,7 +385,7 @@ void Generator::generateCode()
if (isQt || !cdef->hasQObject)
return;
- fprintf(out, "\nconst QMetaObject *%s::metaObject() const\n{\n return &staticMetaObject;\n}\n",
+ fprintf(out, "\nconst QMetaObject *%s::metaObject() const\n{\n return QObject::d_ptr->metaObject ? QObject::d_ptr->metaObject : &staticMetaObject;\n}\n",
cdef->qualified.constData());
//
// Generate smart cast function
@@ -545,7 +559,7 @@ void Generator::generateProperties()
uint flags = Invalid;
if (!isVariantType(p.type)) {
flags |= EnumOrFlag;
- } else {
+ } else if (!isQRealType(p.type)) {
flags |= qvariant_nameToType(p.type) << 24;
}
if (!p.read.isEmpty())
@@ -589,10 +603,17 @@ void Generator::generateProperties()
if (p.notifyId != -1)
flags |= Notify;
- fprintf(out, " %4d, %4d, 0x%.8x,\n",
- strreg(p.name),
- strreg(p.type),
- flags);
+ if (p.constant)
+ flags |= Constant;
+ if (p.final)
+ flags |= Final;
+
+ fprintf(out, " %4d, %4d, ",
+ strreg(p.name),
+ strreg(p.type));
+ if (!(flags >> 24) && isQRealType(p.type))
+ fprintf(out, "(QMetaType::QReal << 24) | ");
+ fprintf(out, "0x%.8x,\n", flags);
}
if(cdef->notifyableProperties) {
@@ -1161,8 +1182,8 @@ void Generator::_generateFunctions(QList<FunctionDef> &list, int type)
for (int j = 0; j < f.arguments.count(); ++j) {
const ArgumentDef &a = f.arguments.at(j);
if (j) {
- sig += ",";
- arguments += ",";
+ sig += ',';
+ arguments += ',';
}
sig += a.normalizedType;
arguments += a.name;
diff --git a/src/tools/moc/moc.cpp b/src/tools/moc/moc.cpp
index 61fcee5..74b1a67 100644
--- a/src/tools/moc/moc.cpp
+++ b/src/tools/moc/moc.cpp
@@ -337,11 +337,10 @@ bool Moc::testFunctionAttribute(Token tok, FunctionDef *def)
bool Moc::parseFunction(FunctionDef *def, bool inMacro)
{
def->isVirtual = false;
- while (test(INLINE) || test(STATIC) || test(VIRTUAL)
- || testFunctionAttribute(def)) {
- if (lookup() == VIRTUAL)
- def->isVirtual = true;
- }
+ //skip modifiers and attributes
+ while (test(INLINE) || test(STATIC) ||
+ (test(VIRTUAL) && (def->isVirtual = true)) //mark as virtual
+ || testFunctionAttribute(def)) {}
bool templateFunction = (lookup() == TEMPLATE);
def->type = parseType();
if (def->type.name.isEmpty()) {
@@ -429,11 +428,10 @@ bool Moc::parseFunction(FunctionDef *def, bool inMacro)
bool Moc::parseMaybeFunction(const ClassDef *cdef, FunctionDef *def)
{
def->isVirtual = false;
- while (test(EXPLICIT) || test(INLINE) || test(STATIC) || test(VIRTUAL)
- || testFunctionAttribute(def)) {
- if (lookup() == VIRTUAL)
- def->isVirtual = true;
- }
+ //skip modifiers and attributes
+ while (test(EXPLICIT) || test(INLINE) || test(STATIC) ||
+ (test(VIRTUAL) && (def->isVirtual = true)) //mark as virtual
+ || testFunctionAttribute(def)) {}
bool tilde = test(TILDE);
def->type = parseType();
if (def->type.name.isEmpty())
@@ -752,14 +750,14 @@ void Moc::generate(FILE *out)
if (!noInclude) {
- if (includePath.size() && includePath.right(1) != "/")
- includePath += "/";
+ if (includePath.size() && !includePath.endsWith('/'))
+ includePath += '/';
for (int i = 0; i < includeFiles.size(); ++i) {
QByteArray inc = includeFiles.at(i);
if (inc[0] != '<' && inc[0] != '"') {
if (includePath.size() && includePath != "./")
inc.prepend(includePath);
- inc = "\"" + inc + "\"";
+ inc = '\"' + inc + '\"';
}
fprintf(out, "#include %s\n", inc.constData());
}
@@ -767,6 +765,9 @@ void Moc::generate(FILE *out)
if (classList.size() && classList.first().classname == "Qt")
fprintf(out, "#include <QtCore/qobject.h>\n");
+ if (mustIncludeQMetaTypeH)
+ fprintf(out, "#include <QtCore/qmetatype.h>\n");
+
fprintf(out, "#if !defined(Q_MOC_OUTPUT_REVISION)\n"
"#error \"The header file '%s' doesn't include <QObject>.\"\n", (const char *)fn);
fprintf(out, "#elif Q_MOC_OUTPUT_REVISION != %d\n", mocOutputRevision);
@@ -859,7 +860,7 @@ void Moc::parseSignals(ClassDef *def)
funcDef.access = FunctionDef::Protected;
parseFunction(&funcDef);
if (funcDef.isVirtual)
- error("Signals cannot be declared virtual");
+ warning("Signals cannot be declared virtual");
if (funcDef.inlineCode)
error("Not a signal declaration");
def->signalList += funcDef;
@@ -898,12 +899,24 @@ void Moc::parseProperty(ClassDef *def)
type = "qlonglong";
else if (type == "ULongLong")
type = "qulonglong";
+ else if (type == "qreal")
+ mustIncludeQMetaTypeH = true;
+
propDef.type = type;
next();
propDef.name = lexem();
while (test(IDENTIFIER)) {
QByteArray l = lexem();
+
+ if (l[0] == 'C' && l == "CONSTANT") {
+ propDef.constant = true;
+ continue;
+ } else if(l[0] == 'F' && l == "FINAL") {
+ propDef.final = true;
+ continue;
+ }
+
QByteArray v, v2;
if (test(LPAREN)) {
v = lexemUntil(RPAREN);
@@ -959,7 +972,24 @@ void Moc::parseProperty(ClassDef *def)
msg += " has no READ accessor function. The property will be invalid.";
warning(msg.constData());
}
- if(!propDef.notify.isEmpty())
+ if (propDef.constant && !propDef.write.isNull()) {
+ QByteArray msg;
+ msg += "Property declaration ";
+ msg += propDef.name;
+ msg += " is both WRITEable and CONSTANT. CONSTANT will be ignored.";
+ propDef.constant = false;
+ warning(msg.constData());
+ }
+ if (propDef.constant && !propDef.notify.isNull()) {
+ QByteArray msg;
+ msg += "Property declaration ";
+ msg += propDef.name;
+ msg += " is both NOTIFYable and CONSTANT. CONSTANT will be ignored.";
+ propDef.constant = false;
+ warning(msg.constData());
+ }
+
+ if(!propDef.notify.isEmpty())
def->notifyableProperties++;
def->propertyList += propDef;
diff --git a/src/tools/moc/moc.h b/src/tools/moc/moc.h
index 43866a6..767f84e 100644
--- a/src/tools/moc/moc.h
+++ b/src/tools/moc/moc.h
@@ -115,9 +115,11 @@ struct FunctionDef
struct PropertyDef
{
- PropertyDef():notifyId(-1), gspec(ValueSpec){}
+ PropertyDef():notifyId(-1), constant(false), final(false), gspec(ValueSpec){}
QByteArray name, type, read, write, reset, designable, scriptable, editable, stored, user, notify;
int notifyId;
+ bool constant;
+ bool final;
enum Specification { ValueSpec, ReferenceSpec, PointerSpec };
Specification gspec;
bool stdCppSet() const {
@@ -177,13 +179,14 @@ class Moc : public Parser
{
public:
Moc()
- : noInclude(false), generatedCode(false)
+ : noInclude(false), generatedCode(false), mustIncludeQMetaTypeH(false)
{}
QByteArray filename;
bool noInclude;
bool generatedCode;
+ bool mustIncludeQMetaTypeH;
QByteArray includePath;
QList<QByteArray> includeFiles;
QList<ClassDef> classList;
diff --git a/src/tools/moc/outputrevision.h b/src/tools/moc/outputrevision.h
index 0330a02..ee19885 100644
--- a/src/tools/moc/outputrevision.h
+++ b/src/tools/moc/outputrevision.h
@@ -43,6 +43,6 @@
#define OUTPUTREVISION_H
// if the output revision changes, you MUST change it in qobjectdefs.h too
-enum { mocOutputRevision = 61 }; // moc format output revision
+enum { mocOutputRevision = 62 }; // moc format output revision
#endif // OUTPUTREVISION_H
diff --git a/src/tools/moc/preprocessor.cpp b/src/tools/moc/preprocessor.cpp
index 86cac2f..bc58769 100644
--- a/src/tools/moc/preprocessor.cpp
+++ b/src/tools/moc/preprocessor.cpp
@@ -807,7 +807,7 @@ void Preprocessor::preprocess(const QByteArray &filename, Symbols &preprocessed)
continue;
QByteArray frameworkCandidate = include.left(slashPos);
frameworkCandidate.append(".framework/Headers/");
- fi.setFile(QString::fromLocal8Bit(p.path + "/" + frameworkCandidate), QString::fromLocal8Bit(include.mid(slashPos + 1)));
+ fi.setFile(QString::fromLocal8Bit(p.path + '/' + frameworkCandidate), QString::fromLocal8Bit(include.mid(slashPos + 1)));
} else {
fi.setFile(QString::fromLocal8Bit(p.path), QString::fromLocal8Bit(include));
}
diff --git a/src/tools/uic/cpp/cppwriteicondata.cpp b/src/tools/uic/cpp/cppwriteicondata.cpp
index 51a6b8e..b834460 100644
--- a/src/tools/uic/cpp/cppwriteicondata.cpp
+++ b/src/tools/uic/cpp/cppwriteicondata.cpp
@@ -161,9 +161,9 @@ void WriteIconData::writeImage(QTextStream &output, const QString &indent, DomIm
for (a = 0; a < (int) (data.length()/2)-1; a++) {
output << "0x" << QString(data[2*a]) << QString(data[2*a+1]) << ',';
if (a % 12 == 11)
- output << "\n" << indent;
+ output << '\n' << indent;
else
- output << " ";
+ output << ' ';
}
output << "0x" << QString(data[2*a]) << QString(data[2*a+1]) << '\n';
output << "};\n\n";
diff --git a/src/tools/uic/cpp/cppwriteinitialization.cpp b/src/tools/uic/cpp/cppwriteinitialization.cpp
index 563d588..d43f74e 100644
--- a/src/tools/uic/cpp/cppwriteinitialization.cpp
+++ b/src/tools/uic/cpp/cppwriteinitialization.cpp
@@ -391,6 +391,13 @@ void WriteInitialization::LayoutDefaultHandler::acceptLayoutFunction(DomLayoutFu
}
}
+static inline void writeContentsMargins(const QString &indent, const QString &objectName, int value, QTextStream &str)
+{
+ QString contentsMargins;
+ QTextStream(&contentsMargins) << value << ", " << value << ", " << value << ", " << value;
+ writeSetter(indent, objectName, QLatin1String("setContentsMargins"), contentsMargins, str);
+ }
+
void WriteInitialization::LayoutDefaultHandler::writeProperty(int p, const QString &indent, const QString &objectName,
const DomPropertyMap &properties, const QString &propertyName, const QString &setter,
int defaultStyleValue, bool suppressDefault, QTextStream &str) const
@@ -408,7 +415,11 @@ void WriteInitialization::LayoutDefaultHandler::writeProperty(int p, const QStri
&& value == defaultStyleValue);
if (ifndefMac)
str << "#ifndef Q_OS_MAC\n";
- writeSetter(indent, objectName, setter, value, str);
+ if (p == Margin) { // Use setContentsMargins for numeric values
+ writeContentsMargins(indent, objectName, value, str);
+ } else {
+ writeSetter(indent, objectName, setter, value, str);
+ }
if (ifndefMac)
str << "#endif\n";
return;
@@ -416,13 +427,18 @@ void WriteInitialization::LayoutDefaultHandler::writeProperty(int p, const QStri
}
if (suppressDefault)
return;
- // get default
+ // get default.
if (m_state[p] & HasDefaultFunction) {
+ // Do not use setContentsMargins to avoid repetitive evaluations.
writeSetter(indent, objectName, setter, m_functions[p], str);
return;
}
if (m_state[p] & HasDefaultValue) {
- writeSetter(indent, objectName, setter, m_defaultValues[p], str);
+ if (p == Margin) { // Use setContentsMargins for numeric values
+ writeContentsMargins(indent, objectName, m_defaultValues[p], str);
+ } else {
+ writeSetter(indent, objectName, setter, m_defaultValues[p], str);
+ }
}
return;
}
@@ -2813,7 +2829,7 @@ QString WriteInitialization::Item::writeSetupUi(const QString &parent, Item::Emp
bool generateMultiDirective = false;
if (emptyItemPolicy == Item::ConstructItemOnly && m_children.size() == 0) {
if (m_setupUiData.policy == ItemData::DontGenerate) {
- m_setupUiStream << m_indent << "new " << m_itemClassName << "(" << parent << ");\n";
+ m_setupUiStream << m_indent << "new " << m_itemClassName << '(' << parent << ");\n";
return QString();
} else if (m_setupUiData.policy == ItemData::GenerateWithMultiDirective) {
generateMultiDirective = true;
@@ -2824,11 +2840,11 @@ QString WriteInitialization::Item::writeSetupUi(const QString &parent, Item::Emp
generateMultiDirectiveBegin(m_setupUiStream, m_setupUiData.directives);
const QString uniqueName = m_driver->unique(QLatin1String("__") + m_itemClassName.toLower());
- m_setupUiStream << m_indent << m_itemClassName << " *" << uniqueName << " = new " << m_itemClassName << "(" << parent << ");\n";
+ m_setupUiStream << m_indent << m_itemClassName << " *" << uniqueName << " = new " << m_itemClassName << '(' << parent << ");\n";
if (generateMultiDirective) {
m_setupUiStream << "#else\n";
- m_setupUiStream << m_indent << "new " << m_itemClassName << "(" << parent << ");\n";
+ m_setupUiStream << m_indent << "new " << m_itemClassName << '(' << parent << ");\n";
generateMultiDirectiveEnd(m_setupUiStream, m_setupUiData.directives);
}
diff --git a/src/tools/uic/ui4.cpp b/src/tools/uic/ui4.cpp
index c9793f2..ed75a29 100644
--- a/src/tools/uic/ui4.cpp
+++ b/src/tools/uic/ui4.cpp
@@ -2368,6 +2368,7 @@ void DomCustomWidget::clear(bool clear_all)
delete m_script;
delete m_properties;
delete m_slots;
+ delete m_propertyspecifications;
if (clear_all) {
m_text.clear();
@@ -2381,6 +2382,7 @@ void DomCustomWidget::clear(bool clear_all)
m_script = 0;
m_properties = 0;
m_slots = 0;
+ m_propertyspecifications = 0;
}
DomCustomWidget::DomCustomWidget()
@@ -2393,6 +2395,7 @@ DomCustomWidget::DomCustomWidget()
m_script = 0;
m_properties = 0;
m_slots = 0;
+ m_propertyspecifications = 0;
}
DomCustomWidget::~DomCustomWidget()
@@ -2403,6 +2406,7 @@ DomCustomWidget::~DomCustomWidget()
delete m_script;
delete m_properties;
delete m_slots;
+ delete m_propertyspecifications;
}
void DomCustomWidget::read(QXmlStreamReader &reader)
@@ -2468,6 +2472,12 @@ void DomCustomWidget::read(QXmlStreamReader &reader)
setElementSlots(v);
continue;
}
+ if (tag == QLatin1String("propertyspecifications")) {
+ DomPropertySpecifications *v = new DomPropertySpecifications();
+ v->read(reader);
+ setElementPropertyspecifications(v);
+ continue;
+ }
reader.raiseError(QLatin1String("Unexpected element ") + tag);
}
break;
@@ -2548,6 +2558,12 @@ void DomCustomWidget::read(const QDomElement &node)
setElementSlots(v);
continue;
}
+ if (tag == QLatin1String("propertyspecifications")) {
+ DomPropertySpecifications *v = new DomPropertySpecifications();
+ v->read(e);
+ setElementPropertyspecifications(v);
+ continue;
+ }
}
m_text.clear();
for (QDomNode child = node.firstChild(); !child.isNull(); child = child.nextSibling()) {
@@ -2605,6 +2621,10 @@ void DomCustomWidget::write(QXmlStreamWriter &writer, const QString &tagName) co
m_slots->write(writer, QLatin1String("slots"));
}
+ if (m_children & Propertyspecifications) {
+ m_propertyspecifications->write(writer, QLatin1String("propertyspecifications"));
+ }
+
if (!m_text.isEmpty())
writer.writeCharacters(m_text);
@@ -2731,6 +2751,21 @@ void DomCustomWidget::setElementSlots(DomSlots* a)
m_slots = a;
}
+DomPropertySpecifications* DomCustomWidget::takeElementPropertyspecifications()
+{
+ DomPropertySpecifications* a = m_propertyspecifications;
+ m_propertyspecifications = 0;
+ m_children ^= Propertyspecifications;
+ return a;
+}
+
+void DomCustomWidget::setElementPropertyspecifications(DomPropertySpecifications* a)
+{
+ delete m_propertyspecifications;
+ m_children |= Propertyspecifications;
+ m_propertyspecifications = a;
+}
+
void DomCustomWidget::clearElementClass()
{
m_children &= ~Class;
@@ -2798,6 +2833,13 @@ void DomCustomWidget::clearElementSlots()
m_children &= ~Slots;
}
+void DomCustomWidget::clearElementPropertyspecifications()
+{
+ delete m_propertyspecifications;
+ m_propertyspecifications = 0;
+ m_children &= ~Propertyspecifications;
+}
+
void DomProperties::clear(bool clear_all)
{
qDeleteAll(m_property);
@@ -10883,5 +10925,208 @@ void DomSlots::setElementSlot(const QStringList& a)
m_slot = a;
}
+void DomPropertySpecifications::clear(bool clear_all)
+{
+ qDeleteAll(m_stringpropertyspecification);
+ m_stringpropertyspecification.clear();
+
+ if (clear_all) {
+ m_text.clear();
+ }
+
+ m_children = 0;
+}
+
+DomPropertySpecifications::DomPropertySpecifications()
+{
+ m_children = 0;
+}
+
+DomPropertySpecifications::~DomPropertySpecifications()
+{
+ qDeleteAll(m_stringpropertyspecification);
+ m_stringpropertyspecification.clear();
+}
+
+void DomPropertySpecifications::read(QXmlStreamReader &reader)
+{
+
+ for (bool finished = false; !finished && !reader.hasError();) {
+ switch (reader.readNext()) {
+ case QXmlStreamReader::StartElement : {
+ const QString tag = reader.name().toString().toLower();
+ if (tag == QLatin1String("stringpropertyspecification")) {
+ DomStringPropertySpecification *v = new DomStringPropertySpecification();
+ v->read(reader);
+ m_stringpropertyspecification.append(v);
+ continue;
+ }
+ reader.raiseError(QLatin1String("Unexpected element ") + tag);
+ }
+ break;
+ case QXmlStreamReader::EndElement :
+ finished = true;
+ break;
+ case QXmlStreamReader::Characters :
+ if (!reader.isWhitespace())
+ m_text.append(reader.text().toString());
+ break;
+ default :
+ break;
+ }
+ }
+}
+
+#ifdef QUILOADER_QDOM_READ
+void DomPropertySpecifications::read(const QDomElement &node)
+{
+ for (QDomNode n = node.firstChild(); !n.isNull(); n = n.nextSibling()) {
+ if (!n.isElement())
+ continue;
+ QDomElement e = n.toElement();
+ QString tag = e.tagName().toLower();
+ if (tag == QLatin1String("stringpropertyspecification")) {
+ DomStringPropertySpecification *v = new DomStringPropertySpecification();
+ v->read(e);
+ m_stringpropertyspecification.append(v);
+ continue;
+ }
+ }
+ m_text.clear();
+ for (QDomNode child = node.firstChild(); !child.isNull(); child = child.nextSibling()) {
+ if (child.isText())
+ m_text.append(child.nodeValue());
+ }
+}
+#endif
+
+void DomPropertySpecifications::write(QXmlStreamWriter &writer, const QString &tagName) const
+{
+ writer.writeStartElement(tagName.isEmpty() ? QString::fromUtf8("propertyspecifications") : tagName.toLower());
+
+ for (int i = 0; i < m_stringpropertyspecification.size(); ++i) {
+ DomStringPropertySpecification* v = m_stringpropertyspecification[i];
+ v->write(writer, QLatin1String("stringpropertyspecification"));
+ }
+ if (!m_text.isEmpty())
+ writer.writeCharacters(m_text);
+
+ writer.writeEndElement();
+}
+
+void DomPropertySpecifications::setElementStringpropertyspecification(const QList<DomStringPropertySpecification*>& a)
+{
+ m_children |= Stringpropertyspecification;
+ m_stringpropertyspecification = a;
+}
+
+void DomStringPropertySpecification::clear(bool clear_all)
+{
+
+ if (clear_all) {
+ m_text.clear();
+ m_has_attr_name = false;
+ m_has_attr_type = false;
+ m_has_attr_notr = false;
+ }
+
+ m_children = 0;
+}
+
+DomStringPropertySpecification::DomStringPropertySpecification()
+{
+ m_children = 0;
+ m_has_attr_name = false;
+ m_has_attr_type = false;
+ m_has_attr_notr = false;
+}
+
+DomStringPropertySpecification::~DomStringPropertySpecification()
+{
+}
+
+void DomStringPropertySpecification::read(QXmlStreamReader &reader)
+{
+
+ foreach (const QXmlStreamAttribute &attribute, reader.attributes()) {
+ QStringRef name = attribute.name();
+ if (name == QLatin1String("name")) {
+ setAttributeName(attribute.value().toString());
+ continue;
+ }
+ if (name == QLatin1String("type")) {
+ setAttributeType(attribute.value().toString());
+ continue;
+ }
+ if (name == QLatin1String("notr")) {
+ setAttributeNotr(attribute.value().toString());
+ continue;
+ }
+ reader.raiseError(QLatin1String("Unexpected attribute ") + name.toString());
+ }
+
+ for (bool finished = false; !finished && !reader.hasError();) {
+ switch (reader.readNext()) {
+ case QXmlStreamReader::StartElement : {
+ const QString tag = reader.name().toString().toLower();
+ reader.raiseError(QLatin1String("Unexpected element ") + tag);
+ }
+ break;
+ case QXmlStreamReader::EndElement :
+ finished = true;
+ break;
+ case QXmlStreamReader::Characters :
+ if (!reader.isWhitespace())
+ m_text.append(reader.text().toString());
+ break;
+ default :
+ break;
+ }
+ }
+}
+
+#ifdef QUILOADER_QDOM_READ
+void DomStringPropertySpecification::read(const QDomElement &node)
+{
+ if (node.hasAttribute(QLatin1String("name")))
+ setAttributeName(node.attribute(QLatin1String("name")));
+ if (node.hasAttribute(QLatin1String("type")))
+ setAttributeType(node.attribute(QLatin1String("type")));
+ if (node.hasAttribute(QLatin1String("notr")))
+ setAttributeNotr(node.attribute(QLatin1String("notr")));
+
+ for (QDomNode n = node.firstChild(); !n.isNull(); n = n.nextSibling()) {
+ if (!n.isElement())
+ continue;
+ QDomElement e = n.toElement();
+ QString tag = e.tagName().toLower();
+ }
+ m_text.clear();
+ for (QDomNode child = node.firstChild(); !child.isNull(); child = child.nextSibling()) {
+ if (child.isText())
+ m_text.append(child.nodeValue());
+ }
+}
+#endif
+
+void DomStringPropertySpecification::write(QXmlStreamWriter &writer, const QString &tagName) const
+{
+ writer.writeStartElement(tagName.isEmpty() ? QString::fromUtf8("stringpropertyspecification") : tagName.toLower());
+
+ if (hasAttributeName())
+ writer.writeAttribute(QLatin1String("name"), attributeName());
+
+ if (hasAttributeType())
+ writer.writeAttribute(QLatin1String("type"), attributeType());
+
+ if (hasAttributeNotr())
+ writer.writeAttribute(QLatin1String("notr"), attributeNotr());
+
+ if (!m_text.isEmpty())
+ writer.writeCharacters(m_text);
+
+ writer.writeEndElement();
+}
+
QT_END_NAMESPACE
diff --git a/src/tools/uic/ui4.h b/src/tools/uic/ui4.h
index 505c61b..3c53d13 100644
--- a/src/tools/uic/ui4.h
+++ b/src/tools/uic/ui4.h
@@ -161,6 +161,8 @@ class DomScript;
class DomWidgetData;
class DomDesignerData;
class DomSlots;
+class DomPropertySpecifications;
+class DomStringPropertySpecification;
/*******************************************************************************
** Declarations
@@ -1015,6 +1017,12 @@ public:
inline bool hasElementSlots() const { return m_children & Slots; }
void clearElementSlots();
+ inline DomPropertySpecifications* elementPropertyspecifications() const { return m_propertyspecifications; }
+ DomPropertySpecifications* takeElementPropertyspecifications();
+ void setElementPropertyspecifications(DomPropertySpecifications* a);
+ inline bool hasElementPropertyspecifications() const { return m_children & Propertyspecifications; }
+ void clearElementPropertyspecifications();
+
private:
QString m_text;
void clear(bool clear_all = true);
@@ -1033,6 +1041,7 @@ private:
DomScript* m_script;
DomProperties* m_properties;
DomSlots* m_slots;
+ DomPropertySpecifications* m_propertyspecifications;
enum Child {
Class = 1,
Extends = 2,
@@ -1044,7 +1053,8 @@ private:
Pixmap = 128,
Script = 256,
Properties = 512,
- Slots = 1024
+ Slots = 1024,
+ Propertyspecifications = 2048
};
DomCustomWidget(const DomCustomWidget &other);
@@ -3686,6 +3696,91 @@ private:
void operator = (const DomSlots&other);
};
+class QDESIGNER_UILIB_EXPORT DomPropertySpecifications {
+public:
+ DomPropertySpecifications();
+ ~DomPropertySpecifications();
+
+ void read(QXmlStreamReader &reader);
+#ifdef QUILOADER_QDOM_READ
+ void read(const QDomElement &node);
+#endif
+ void write(QXmlStreamWriter &writer, const QString &tagName = QString()) const;
+ inline QString text() const { return m_text; }
+ inline void setText(const QString &s) { m_text = s; }
+
+ // attribute accessors
+ // child element accessors
+ inline QList<DomStringPropertySpecification*> elementStringpropertyspecification() const { return m_stringpropertyspecification; }
+ void setElementStringpropertyspecification(const QList<DomStringPropertySpecification*>& a);
+
+private:
+ QString m_text;
+ void clear(bool clear_all = true);
+
+ // attribute data
+ // child element data
+ uint m_children;
+ QList<DomStringPropertySpecification*> m_stringpropertyspecification;
+ enum Child {
+ Stringpropertyspecification = 1
+ };
+
+ DomPropertySpecifications(const DomPropertySpecifications &other);
+ void operator = (const DomPropertySpecifications&other);
+};
+
+class QDESIGNER_UILIB_EXPORT DomStringPropertySpecification {
+public:
+ DomStringPropertySpecification();
+ ~DomStringPropertySpecification();
+
+ void read(QXmlStreamReader &reader);
+#ifdef QUILOADER_QDOM_READ
+ void read(const QDomElement &node);
+#endif
+ void write(QXmlStreamWriter &writer, const QString &tagName = QString()) const;
+ inline QString text() const { return m_text; }
+ inline void setText(const QString &s) { m_text = s; }
+
+ // attribute accessors
+ inline bool hasAttributeName() const { return m_has_attr_name; }
+ inline QString attributeName() const { return m_attr_name; }
+ inline void setAttributeName(const QString& a) { m_attr_name = a; m_has_attr_name = true; }
+ inline void clearAttributeName() { m_has_attr_name = false; }
+
+ inline bool hasAttributeType() const { return m_has_attr_type; }
+ inline QString attributeType() const { return m_attr_type; }
+ inline void setAttributeType(const QString& a) { m_attr_type = a; m_has_attr_type = true; }
+ inline void clearAttributeType() { m_has_attr_type = false; }
+
+ inline bool hasAttributeNotr() const { return m_has_attr_notr; }
+ inline QString attributeNotr() const { return m_attr_notr; }
+ inline void setAttributeNotr(const QString& a) { m_attr_notr = a; m_has_attr_notr = true; }
+ inline void clearAttributeNotr() { m_has_attr_notr = false; }
+
+ // child element accessors
+private:
+ QString m_text;
+ void clear(bool clear_all = true);
+
+ // attribute data
+ QString m_attr_name;
+ bool m_has_attr_name;
+
+ QString m_attr_type;
+ bool m_has_attr_type;
+
+ QString m_attr_notr;
+ bool m_has_attr_notr;
+
+ // child element data
+ uint m_children;
+
+ DomStringPropertySpecification(const DomStringPropertySpecification &other);
+ void operator = (const DomStringPropertySpecification&other);
+};
+
#ifdef QFORMINTERNAL_NAMESPACE
}
diff --git a/src/tools/uic/uic.cpp b/src/tools/uic/uic.cpp
index 1c6e3a5..bbb3af7 100644
--- a/src/tools/uic/uic.cpp
+++ b/src/tools/uic/uic.cpp
@@ -137,12 +137,12 @@ void Uic::writeCopyrightHeader(DomUI *ui)
out << "/*\n" << comment << "\n*/\n\n";
out << "/********************************************************************************\n";
- out << "** Form generated from reading ui file '" << QFileInfo(opt.inputFile).fileName() << "'\n";
+ out << "** Form generated from reading UI file '" << QFileInfo(opt.inputFile).fileName() << "'\n";
out << "**\n";
out << "** Created: " << QDateTime::currentDateTime().toString() << "\n";
out << "** " << QString::fromLatin1("by: Qt User Interface Compiler version %1\n").arg(QLatin1String(QT_VERSION_STR));
out << "**\n";
- out << "** WARNING! All changes made in this file will be lost when recompiling ui file!\n";
+ out << "** WARNING! All changes made in this file will be lost when recompiling UI file!\n";
out << "********************************************************************************/\n\n";
}
diff --git a/src/tools/uic3/converter.cpp b/src/tools/uic3/converter.cpp
index 1b0460b..c5a75eb 100644
--- a/src/tools/uic3/converter.cpp
+++ b/src/tools/uic3/converter.cpp
@@ -988,6 +988,7 @@ void Ui3Reader::createProperties(const QDomElement &n, QList<DomProperty*> *prop
QString objectName;
bool wordWrapFound = false;
+ bool wordWrapPropertyFound = false;
for (QDomElement e=n.firstChild().toElement(); !e.isNull(); e = e.nextSibling().toElement()) {
if (e.tagName().toLower() == QLatin1String("property")) {
@@ -1099,14 +1100,16 @@ void Ui3Reader::createProperties(const QDomElement &n, QList<DomProperty*> *prop
name = prop->attributeName(); // sync the name
- if (className == QLatin1String("QLabel") && name == QLatin1String("alignment")) {
- QString v = prop->elementSet();
-
- if (v.contains(QRegExp(QLatin1String("\\bWordBreak\\b"))))
- wordWrapFound = true;
+ if (className == QLatin1String("QLabel")) {
+ if (name == QLatin1String("alignment")) {
+ const QString v = prop->elementSet();
+ if (v.contains(QRegExp(QLatin1String("\\bWordBreak\\b"))))
+ wordWrapFound = true;
+ } else if (name == QLatin1String("wordWrap")) {
+ wordWrapPropertyFound = true;
+ }
}
-
// resolve the flags and enumerator
if (prop->kind() == DomProperty::Set) {
QStringList flags = prop->elementSet().split(QLatin1Char('|'));
@@ -1164,7 +1167,7 @@ void Ui3Reader::createProperties(const QDomElement &n, QList<DomProperty*> *prop
}
}
}
- if (className == QLatin1String("QLabel")) {
+ if (className == QLatin1String("QLabel") && !wordWrapPropertyFound) {
DomProperty *wordWrap = new DomProperty();
wordWrap->setAttributeName(QLatin1String("wordWrap"));
if (wordWrapFound)
diff --git a/src/tools/uic3/embed.cpp b/src/tools/uic3/embed.cpp
index 9716896..645d0ca 100644
--- a/src/tools/uic3/embed.cpp
+++ b/src/tools/uic3/embed.cpp
@@ -238,7 +238,7 @@ void Ui3Reader::embed(const char *project, const QStringList &images)
out << "true, ";
else
out << "false, ";
- out << "\"" << e->name << "\" },\n";
+ out << '\"' << e->name << "\" },\n";
delete e;
}
#ifndef QT_NO_IMAGE_COLLECTION_COMPRESSION
diff --git a/src/tools/uic3/form.cpp b/src/tools/uic3/form.cpp
index f003dcd..f2d0370 100644
--- a/src/tools/uic3/form.cpp
+++ b/src/tools/uic3/form.cpp
@@ -185,14 +185,14 @@ void Ui3Reader::createFormDecl(const QDomElement &e, bool implicitIncludes)
for (it = globalIncludes.constBegin(); it != globalIncludes.constEnd(); ++it) {
if (!(*it).isEmpty()) {
QString header = fixHeaderName(*it);
- out << "#include <" << header << ">" << endl;
+ out << "#include <" << header << '>' << endl;
}
}
localIncludes = unique(localIncludes);
for (it = localIncludes.constBegin(); it != localIncludes.constEnd(); ++it) {
if (!(*it).isEmpty()) {
QString header = fixHeaderName(*it);
- out << "#include \"" << header << "\"" << endl;
+ out << "#include \"" << header << '\"' << endl;
}
}
out << endl;
@@ -216,7 +216,7 @@ void Ui3Reader::createFormDecl(const QDomElement &e, bool implicitIncludes)
typeDefs = unique(typeDefs);
for (it = typeDefs.constBegin(); it != typeDefs.constEnd(); ++it) {
if (!(*it).isEmpty())
- out << "typedef " << *it << ";" << endl;
+ out << "typedef " << *it << ';' << endl;
}
nl = e.parentNode().toElement().elementsByTagName(QLatin1String("forward"));
@@ -236,17 +236,17 @@ void Ui3Reader::createFormDecl(const QDomElement &e, bool implicitIncludes)
out << "namespace " << *ns << " {" << endl;
++ns;
}
- out << "class " << forwardName << ";" << endl;
+ out << "class " << forwardName << ';' << endl;
for (int i = 0; i < (int) forwardNamespaces.count(); i++)
- out << "}" << endl;
+ out << '}' << endl;
}
}
for (it = forwardDecl2.constBegin(); it != forwardDecl2.constEnd(); ++it) {
QString fd = *it;
fd = fd.trimmed();
- if (!fd.endsWith(QLatin1String(";")))
- fd += QLatin1String(";");
+ if (!fd.endsWith(QLatin1Char(';')))
+ fd += QLatin1Char(';');
out << fd << endl;
}
@@ -279,7 +279,7 @@ void Ui3Reader::createWrapperDecl(const QDomElement &e, const QString &converted
out << "#ifndef " << protector << endl;
out << "#define " << protector << endl;
out << endl;
- out << "#include \"" << convertedUiFile << "\"" << endl;
+ out << "#include \"" << convertedUiFile << '\"' << endl;
createWrapperDeclContents(e);
out << endl;
@@ -309,8 +309,8 @@ void Ui3Reader::createWrapperDeclContents(const QDomElement &e)
out << "class ";
if (!exportMacro.isEmpty())
- out << exportMacro << " ";
- out << bareNameOfClass << " : public " << objClass << ", public Ui::" << bareNameOfClass << endl << "{" << endl;
+ out << exportMacro << ' ';
+ out << bareNameOfClass << " : public " << objClass << ", public Ui::" << bareNameOfClass << endl << '{' << endl;
/* qmake ignore Q_OBJECT */
out << " Q_OBJECT" << endl;
@@ -362,8 +362,8 @@ void Ui3Reader::createWrapperDeclContents(const QDomElement &e)
continue;
QString returnType = n.attribute(QLatin1String("returnType"), QLatin1String("void"));
QString functionName = n.firstChild().toText().data().trimmed();
- if (functionName.endsWith(QLatin1String(";")))
- functionName = functionName.left(functionName.length() - 1);
+ if (functionName.endsWith(QLatin1Char(';')))
+ functionName.chop(1);
QString specifier = n.attribute(QLatin1String("specifier"));
QString access = n.attribute(QLatin1String("access"));
if (access == QLatin1String(QLatin1String("protected"))) {
@@ -394,8 +394,8 @@ void Ui3Reader::createWrapperDeclContents(const QDomElement &e)
continue;
QString returnType = n.attribute(QLatin1String("returnType"), QLatin1String("void"));
QString functionName = n.firstChild().toText().data().trimmed();
- if (functionName.endsWith(QLatin1String(";")))
- functionName = functionName.left(functionName.length() - 1);
+ if (functionName.endsWith(QLatin1Char(';')))
+ functionName.chop(1);
QString specifier = n.attribute(QLatin1String("specifier"));
QString access = n.attribute(QLatin1String("access"));
if (access == QLatin1String("protected")) {
@@ -423,8 +423,8 @@ void Ui3Reader::createWrapperDeclContents(const QDomElement &e)
// continue;
QString access = n.attribute(QLatin1String("access"), QLatin1String("protected"));
QString var = fixDeclaration(n.firstChild().toText().data().trimmed());
- if (!var.endsWith(QLatin1String(";")))
- var += QLatin1String(";");
+ if (!var.endsWith(QLatin1Char(';')))
+ var += QLatin1Char(';');
if (access == QLatin1String("public"))
publicVars += var;
else if (access == QLatin1String("private"))
@@ -458,7 +458,7 @@ void Ui3Reader::createWrapperDeclContents(const QDomElement &e)
if (n.attribute(QLatin1String("language"), QLatin1String("C++")) != QLatin1String("C++"))
continue;
QString sigName = n.firstChild().toText().data().trimmed();
- if (sigName.endsWith(QLatin1String(";")))
+ if (sigName.endsWith(QLatin1Char(';')))
sigName = sigName.left(sigName.length() - 1);
extraSignals += fixDeclaration(sigName);
}
@@ -467,7 +467,7 @@ void Ui3Reader::createWrapperDeclContents(const QDomElement &e)
if (!extraSignals.isEmpty()) {
out << "signals:" << endl;
for (it = extraSignals.constBegin(); it != extraSignals.constEnd(); ++it)
- out << " void " << (*it) << ";" << endl;
+ out << " void " << (*it) << ';' << endl;
out << endl;
}
@@ -513,7 +513,7 @@ void Ui3Reader::createWrapperDeclContents(const QDomElement &e)
out << "};" << endl;
for (i = 0; i < (int) namespaces.count(); i++)
- out << "}" << endl;
+ out << '}' << endl;
out << endl;
}
@@ -543,7 +543,7 @@ void Ui3Reader::writeFunctionsDecl(const QStringList &fuLst, const QStringList &
signature = fixDeclaration(signature);
type = fixType(type);
- out << " " << specifier << type << " " << signature << pure << ";" << endl;
+ out << " " << specifier << type << ' ' << signature << pure << ';' << endl;
}
out << endl;
}
@@ -583,8 +583,8 @@ void Ui3Reader::createFormImpl(const QDomElement &e)
if (n.attribute(QLatin1String("language"), QLatin1String("C++")) != QLatin1String("C++"))
continue;
QString functionName = n.firstChild().toText().data().trimmed();
- if (functionName.endsWith(QLatin1String(";")))
- functionName = functionName.left(functionName.length() - 1);
+ if (functionName.endsWith(QLatin1Char(';')))
+ functionName.chop(1);
extraFuncts += functionName;
extraFunctTyp += n.attribute(QLatin1String("returnType"), QLatin1String("void"));
extraFunctSpecifier += n.attribute(QLatin1String("specifier"), QLatin1String("virtual"));
@@ -598,8 +598,8 @@ void Ui3Reader::createFormImpl(const QDomElement &e)
if (n.attribute(QLatin1String("language"), QLatin1String("C++")) != QLatin1String("C++"))
continue;
QString functionName = n.firstChild().toText().data().trimmed();
- if (functionName.endsWith(QLatin1String(";")))
- functionName = functionName.left(functionName.length() - 1);
+ if (functionName.endsWith(QLatin1Char(';')))
+ functionName.chop(1);
extraFuncts += functionName;
extraFunctTyp += n.attribute(QLatin1String("returnType"), QLatin1String("void"));
extraFunctSpecifier += n.attribute(QLatin1String("specifier"), QLatin1String("virtual"));
@@ -663,7 +663,7 @@ void Ui3Reader::createFormImpl(const QDomElement &e)
globalIncludes = unique(globalIncludes);
for (it = globalIncludes.begin(); it != globalIncludes.end(); ++it) {
if (!(*it).isEmpty())
- out << "#include <" << fixHeaderName(*it) << ">" << endl;
+ out << "#include <" << fixHeaderName(*it) << '>' << endl;
}
if (externPixmaps) {
@@ -677,14 +677,14 @@ void Ui3Reader::createFormImpl(const QDomElement &e)
localIncludes = unique(localIncludes);
for (it = localIncludes.begin(); it != localIncludes.end(); ++it) {
if (!(*it).isEmpty() && *it != QFileInfo(fileName + QLatin1String(".h")).fileName())
- out << "#include \"" << fixHeaderName(*it) << "\"" << endl;
+ out << "#include \"" << fixHeaderName(*it) << '\"' << endl;
}
QString uiDotH = fileName + QLatin1String(".h");
if (QFile::exists(uiDotH)) {
if (!outputFileName.isEmpty())
uiDotH = QString::fromUtf8(combinePath(uiDotH.ascii(), outputFileName.ascii()));
- out << "#include \"" << uiDotH << "\"" << endl;
+ out << "#include \"" << uiDotH << '\"' << endl;
writeFunctImpl = false;
}
@@ -702,7 +702,7 @@ void Ui3Reader::createFormImpl(const QDomElement &e)
out << " * name 'name' and widget flags set to 'f'." << endl;
out << " *" << endl;
out << " * The " << objClass.mid(1).toLower() << " will by default be modeless, unless you set 'modal' to" << endl;
- out << " * true to construct a modal " << objClass.mid(1).toLower() << "." << endl;
+ out << " * true to construct a modal " << objClass.mid(1).toLower() << '.' << endl;
out << " */" << endl;
out << nameOfClass << "::" << bareNameOfClass << "(QWidget* parent, const char* name, bool modal, Qt::WindowFlags fl)" << endl;
out << " : " << objClass << "(parent, name, modal, fl)";
@@ -733,7 +733,7 @@ void Ui3Reader::createFormImpl(const QDomElement &e)
out << endl;
- out << "{" << endl;
+ out << '{' << endl;
//
// setup the gui
@@ -775,7 +775,7 @@ void Ui3Reader::createFormImpl(const QDomElement &e)
out << indent << "init();" << endl;
// end of constructor
- out << "}" << endl;
+ out << '}' << endl;
out << endl;
// destructor
@@ -783,11 +783,11 @@ void Ui3Reader::createFormImpl(const QDomElement &e)
out << " * Destroys the object and frees any allocated resources" << endl;
out << " */" << endl;
out << nameOfClass << "::~" << bareNameOfClass << "()" << endl;
- out << "{" << endl;
+ out << '{' << endl;
if (extraFuncts.contains(QLatin1String("destroy()")))
out << indent << "destroy();" << endl;
out << indent << "// no need to delete child widgets, Qt does it all for us" << endl;
- out << "}" << endl;
+ out << '}' << endl;
out << endl;
// handle application events if required
@@ -816,9 +816,9 @@ void Ui3Reader::createFormImpl(const QDomElement &e)
out << " * language." << endl;
out << " */" << endl;
out << "void " << nameOfClass << "::languageChange()" << endl;
- out << "{" << endl;
+ out << '{' << endl;
out << " retranslateUi(this);" << endl;
- out << "}" << endl;
+ out << '}' << endl;
out << endl;
// create stubs for additional slots if necessary
@@ -833,8 +833,8 @@ void Ui3Reader::createFormImpl(const QDomElement &e)
type = type.simplified();
QString fname = fixDeclaration(Parser::cleanArgs(*it));
if (!(*it3).startsWith(QLatin1String("pure"))) { // "pure virtual" or "pureVirtual"
- out << type << " " << nameOfClass << "::" << fname << endl;
- out << "{" << endl;
+ out << type << ' ' << nameOfClass << "::" << fname << endl;
+ out << '{' << endl;
if (*it != QLatin1String("init()") && *it != QLatin1String("destroy()")) {
QRegExp numeric(QLatin1String("^(?:signed|unsigned|u?char|u?short|u?int"
"|u?long|Q_U?INT(?:8|16|32)|Q_U?LONG|float"
@@ -868,14 +868,14 @@ void Ui3Reader::createFormImpl(const QDomElement &e)
if (type == QLatin1String("bool")) {
retVal = QLatin1String("false");
- } else if (isBasicNumericType || type.endsWith(QLatin1String("*"))) {
+ } else if (isBasicNumericType || type.endsWith(QLatin1Char('*'))) {
retVal = QLatin1String("0");
- } else if (type.endsWith(QLatin1String("&"))) {
+ } else if (type.endsWith(QLatin1Char('&'))) {
do {
type.chop(1);
- } while (type.endsWith(QLatin1String(" ")));
+ } while (type.endsWith(QLatin1Char(' ')));
retVal = QLatin1String("uic_temp_var");
- out << indent << "static " << type << " " << retVal << ";" << endl;
+ out << indent << "static " << type << ' ' << retVal << ';' << endl;
} else {
retVal = type + QLatin1String("()");
}
@@ -883,9 +883,9 @@ void Ui3Reader::createFormImpl(const QDomElement &e)
out << indent << "qWarning(\"" << nameOfClass << "::" << fname << ": Not implemented yet\");" << endl;
if (!retVal.isEmpty())
- out << indent << "return " << retVal << ";" << endl;
+ out << indent << "return " << retVal << ';' << endl;
}
- out << "}" << endl;
+ out << '}' << endl;
out << endl;
}
++it;
diff --git a/src/tools/uic3/main.cpp b/src/tools/uic3/main.cpp
index 8ca56e1..f4a9cba 100644
--- a/src/tools/uic3/main.cpp
+++ b/src/tools/uic3/main.cpp
@@ -114,7 +114,7 @@ int runUic3(int argc, char * argv[])
wrap = true;
if (opt == "wrap" || opt[1] == '\0') {
if (!(n < argc-1)) {
- error = "Missing name of converted ui file";
+ error = "Missing name of converted UI file";
break;
}
convertedUiFile = argv[++n];
@@ -230,7 +230,7 @@ int runUic3(int argc, char * argv[])
" %s [options] -decl <uiheaderfile> <uifile>\n"
"\t<uiheaderfile> name of the data file\n"
" %s [options] -wrap <converteduifile> <uifile>\n"
- "\t<converteduifile> name of the converted ui file\n"
+ "\t<converteduifile> name of the converted UI file\n"
"Generate implementation:\n"
" %s [options] -impl <headerfile> <uifile>\n"
"\t<headerfile> name of the declaration file\n"
@@ -254,7 +254,7 @@ int runUic3(int argc, char * argv[])
"\t-pch file Add #include \"file\" as the first statement in implementation\n"
"\t-nofwd Omit forward declarations of custom classes\n"
"\t-no-implicit-includes Do not generate #include-directives for custom classes\n"
- "\t-nounload Don't unload plugins after processing\n"
+ "\t-nounload Do not unload plugins after processing\n"
"\t-tr func Use func() instead of tr() for i18n\n"
"\t-L path Additional plugin search path\n"
"\t-version Display version of uic\n"
@@ -367,7 +367,7 @@ int runUic3(int argc, char * argv[])
}
if (headerFile) {
- out << "#include \"" << headerFile << "\"" << endl << endl;
+ out << "#include \"" << headerFile << '\"' << endl << endl;
}
QString convertedUi;
diff --git a/src/tools/uic3/parser.cpp b/src/tools/uic3/parser.cpp
index a8e5ea4..dddb98c 100644
--- a/src/tools/uic3/parser.cpp
+++ b/src/tools/uic3/parser.cpp
@@ -48,14 +48,14 @@ QT_BEGIN_NAMESPACE
QString Parser::cleanArgs(const QString &func)
{
QString slot(func);
- int begin = slot.indexOf(QLatin1String("(")) + 1;
+ int begin = slot.indexOf(QLatin1Char('(')) + 1;
QString args = slot.mid(begin);
- args = args.left(args.indexOf(QLatin1String(")")));
+ args = args.left(args.indexOf(QLatin1Char(')')));
QStringList lst = args.split(QLatin1Char(','));
QString res = slot.left(begin);
for (QStringList::Iterator it = lst.begin(); it != lst.end(); ++it) {
if (it != lst.begin())
- res += QLatin1String(",");
+ res += QLatin1Char(',');
QString arg = *it;
int pos = 0;
if ((pos = arg.indexOf(QLatin1Char('&'))) != -1) {
@@ -65,7 +65,7 @@ QString Parser::cleanArgs(const QString &func)
} else {
arg = arg.simplified();
if ((pos = arg.indexOf(QLatin1Char(':'))) != -1)
- arg = arg.left(pos).simplified() + QLatin1String(":") + arg.mid(pos + 1).simplified();
+ arg = arg.left(pos).simplified() + QLatin1Char(':') + arg.mid(pos + 1).simplified();
QStringList l = arg.split(QLatin1Char(' '));
if (l.count() == 2) {
if (l[0] != QLatin1String("const")
@@ -73,12 +73,12 @@ QString Parser::cleanArgs(const QString &func)
&& l[0] != QLatin1String("var"))
arg = l[0];
} else if (l.count() == 3) {
- arg = l[0] + QLatin1String(" ") + l[1];
+ arg = l[0] + QLatin1Char(' ') + l[1];
}
}
res += arg;
}
- res += QLatin1String(")");
+ res += QLatin1Char(')');
return res;
}
diff --git a/src/tools/uic3/qt3to4.cpp b/src/tools/uic3/qt3to4.cpp
index 2337153..a0eb865 100644
--- a/src/tools/uic3/qt3to4.cpp
+++ b/src/tools/uic3/qt3to4.cpp
@@ -149,7 +149,7 @@ void Porting::readXML(RuleList *renamedHeaders, RuleList *renamedClasses, RuleLi
QString fileName = QLatin1String("q3porting.xml");
QString filePath;
//check QLibraryInfo::DataPath/filename
- filePath = QDir::cleanPath(QLibraryInfo::location(QLibraryInfo::DataPath) + QLatin1String("/") + fileName) ;
+ filePath = QDir::cleanPath(QLibraryInfo::location(QLibraryInfo::DataPath) + QLatin1Char('/') + fileName) ;
//check QLibraryInfo::PrefixPath/tools/porting/src/filename
if (!QFile::exists(filePath))
diff --git a/src/tools/uic3/subclassing.cpp b/src/tools/uic3/subclassing.cpp
index ee66abb..2e975e3 100644
--- a/src/tools/uic3/subclassing.cpp
+++ b/src/tools/uic3/subclassing.cpp
@@ -69,7 +69,7 @@ void Ui3Reader::createSubDecl( const QDomElement &e, const QString& subClass )
return;
out << "class " << subClass << " : public " << nameOfClass << endl;
- out << "{" << endl;
+ out << '{' << endl;
/* tmake ignore Q_OBJECT */
out << " Q_OBJECT" << endl;
@@ -105,8 +105,8 @@ void Ui3Reader::createSubDecl( const QDomElement &e, const QString& subClass )
continue;
QString returnType = n.attribute(QLatin1String("returnType"), QLatin1String("void"));
QString functionName = n.firstChild().toText().data().trimmed();
- if ( functionName.endsWith(QLatin1String(";")))
- functionName = functionName.left( functionName.length() - 1 );
+ if ( functionName.endsWith(QLatin1Char(';')))
+ functionName.chop(1);
QString specifier = n.attribute(QLatin1String("specifier"));
QString access = n.attribute(QLatin1String("access"));
if ( access == QLatin1String("protected") ) {
@@ -133,8 +133,8 @@ void Ui3Reader::createSubDecl( const QDomElement &e, const QString& subClass )
continue;
QString returnType = n.attribute(QLatin1String("returnType"), QLatin1String("void"));
QString functionName = n.firstChild().toText().data().trimmed();
- if ( functionName.endsWith(QLatin1String(";")) )
- functionName = functionName.left( functionName.length() - 1 );
+ if ( functionName.endsWith(QLatin1Char(';')) )
+ functionName.chop(1);
QString specifier = n.attribute(QLatin1String("specifier"));
QString access = n.attribute(QLatin1String("access"));
if ( access == QLatin1String("protected") ) {
@@ -195,7 +195,7 @@ void Ui3Reader::writeFunctionsSubDecl( const QStringList &fuLst, const QStringLi
type = QLatin1String("void");
if ( *it3 == QLatin1String("non virtual") )
continue;
- out << " " << type << " " << fixDeclaration(*it) << ";" << endl;
+ out << " " << type << ' ' << fixDeclaration(*it) << ';' << endl;
}
out << endl;
}
@@ -223,7 +223,7 @@ void Ui3Reader::createSubImpl( const QDomElement &e, const QString& subClass )
out << " * name 'name' and widget flags set to 'f' " << endl;
out << " *" << endl;
out << " * The " << objClass.mid(1).toLower() << " will by default be modeless, unless you set 'modal' to" << endl;
- out << " * true to construct a modal " << objClass.mid(1).toLower() << "." << endl;
+ out << " * true to construct a modal " << objClass.mid(1).toLower() << '.' << endl;
out << " */" << endl;
out << subClass << "::" << subClass << "( QWidget* parent, const char* name, bool modal, Qt::WindowFlags fl )" << endl;
out << " : " << nameOfClass << "( parent, name, modal, fl )" << endl;
@@ -235,8 +235,8 @@ void Ui3Reader::createSubImpl( const QDomElement &e, const QString& subClass )
out << subClass << "::" << subClass << "( QWidget* parent, const char* name, Qt::WindowFlags fl )" << endl;
out << " : " << nameOfClass << "( parent, name, fl )" << endl;
}
- out << "{" << endl;
- out << "}" << endl;
+ out << '{' << endl;
+ out << '}' << endl;
out << endl;
// destructor
@@ -244,9 +244,9 @@ void Ui3Reader::createSubImpl( const QDomElement &e, const QString& subClass )
out << " * Destroys the object and frees any allocated resources" << endl;
out << " */" << endl;
out << subClass << "::~" << subClass << "()" << endl;
- out << "{" << endl;
+ out << '{' << endl;
out << " // no need to delete child widgets, Qt does it all for us" << endl;
- out << "}" << endl;
+ out << '}' << endl;
out << endl;
@@ -268,8 +268,8 @@ void Ui3Reader::createSubImpl( const QDomElement &e, const QString& subClass )
continue;
QString returnType = n.attribute(QLatin1String("returnType"), QLatin1String("void"));
QString functionName = n.firstChild().toText().data().trimmed();
- if ( functionName.endsWith(QLatin1String(";")) )
- functionName = functionName.left( functionName.length() - 1 );
+ if ( functionName.endsWith(QLatin1Char(';')) )
+ functionName.chop(1);
QString specifier = n.attribute(QLatin1String("specifier"));
QString access = n.attribute(QLatin1String("access"));
if ( access == QLatin1String("protected") ) {
@@ -296,8 +296,8 @@ void Ui3Reader::createSubImpl( const QDomElement &e, const QString& subClass )
continue;
QString returnType = n.attribute(QLatin1String("returnType"), QLatin1String("void"));
QString functionName = n.firstChild().toText().data().trimmed();
- if ( functionName.endsWith(QLatin1String(";")) )
- functionName = functionName.left( functionName.length() - 1 );
+ if ( functionName.endsWith(QLatin1Char(';')) )
+ functionName.chop(1);
QString specifier = n.attribute(QLatin1String("specifier"));
QString access = n.attribute(QLatin1String("access"));
if ( access == QLatin1String("protected") ) {
@@ -351,10 +351,10 @@ void Ui3Reader::writeFunctionsSubImpl( const QStringList &fuLst, const QStringLi
out << "/*" << endl;
out << " * " << descr << endl;
out << " */" << endl;
- out << type << " " << subClass << "::" << fixDeclaration(*it) << endl;
- out << "{" << endl;
+ out << type << ' ' << subClass << "::" << fixDeclaration(*it) << endl;
+ out << '{' << endl;
out << " qWarning( \"" << subClass << "::" << fixDeclaration(*it) << " not yet implemented!\" );" << endl;
- out << "}" << endl << endl;
+ out << '}' << endl << endl;
}
out << endl;
}
diff --git a/src/tools/uic3/ui3reader.cpp b/src/tools/uic3/ui3reader.cpp
index abbce55..4aaaa2d 100644
--- a/src/tools/uic3/ui3reader.cpp
+++ b/src/tools/uic3/ui3reader.cpp
@@ -125,10 +125,10 @@ QString Ui3Reader::fixString(const QString &str, bool encode)
QString s;
if (!encode) {
s = str;
- s.replace(QLatin1String("\\"), QLatin1String("\\\\"));
- s.replace(QLatin1String("\""), QLatin1String("\\\""));
- s.replace(QLatin1String("\r"), QLatin1String(""));
- s.replace(QLatin1String("\n"), QLatin1String("\\n\"\n\""));
+ s.replace(QLatin1Char('\\'), QLatin1String("\\\\"));
+ s.replace(QLatin1Char('\"'), QLatin1String("\\\""));
+ s.remove(QLatin1Char('\r'));
+ s.replace(QLatin1Char('\n'), QLatin1String("\\n\"\n\""));
} else {
QByteArray utf8 = str.utf8();
const int l = utf8.length();
@@ -136,7 +136,7 @@ QString Ui3Reader::fixString(const QString &str, bool encode)
s += QLatin1String("\\x") + QString::number((uchar)utf8[i], 16);
}
- return QLatin1String("\"") + s + QLatin1String("\"");
+ return QLatin1Char('\"') + s + QLatin1Char('\"');
}
QString Ui3Reader::trcall(const QString& sourceText, const QString& comment)
@@ -158,12 +158,12 @@ QString Ui3Reader::trcall(const QString& sourceText, const QString& comment)
}
if (comment.isEmpty()) {
- return t + QLatin1String("(") + fixString(sourceText, encode) + QLatin1String(")");
+ return t + QLatin1Char('(') + fixString(sourceText, encode) + QLatin1Char(')');
} else {
- return t + QLatin1String("(")
+ return t + QLatin1Char('(')
+ fixString(sourceText, encode)
+ QLatin1String(", ")
- + fixString(comment, encode) + QLatin1String(")");
+ + fixString(comment, encode) + QLatin1Char(')');
}
}
@@ -480,10 +480,10 @@ void Ui3Reader::createColorGroupImpl(const QString& name, const QDomElement& e)
QString pixmap = n.firstChild().toText().data();
if (!pixmapLoaderFunction.isEmpty()) {
pixmap.prepend(pixmapLoaderFunction
- + QLatin1String("(")
+ + QLatin1Char('(')
+ QLatin1String(externPixmaps ? "\"" : ""));
- pixmap.append(QLatin1String(externPixmaps ? "\"" : "") + QLatin1String(")"));
+ pixmap.append(QLatin1String(externPixmaps ? "\"" : "") + QLatin1Char(')'));
}
out << indent << name << ".setBrush(QColorGroup::"
<< ColorRole[r] << ", QBrush(" << color << ", " << pixmap << "));" << endl;
@@ -578,9 +578,9 @@ QString Ui3Reader::registerObject(const QString& name)
if (objectNames.contains(result)) {
int i = 2;
- while (objectNames.contains(result + QLatin1String("_") + QString::number(i)))
+ while (objectNames.contains(result + QLatin1Char('_') + QString::number(i)))
i++;
- result += QLatin1String("_");
+ result += QLatin1Char('_');
result += QString::number(i);
}
objectNames += result;
diff --git a/src/tools/uic3/uic.cpp b/src/tools/uic3/uic.cpp
index e911844..16b2754 100644
--- a/src/tools/uic3/uic.cpp
+++ b/src/tools/uic3/uic.cpp
@@ -144,12 +144,12 @@ void Uic::writeCopyrightHeader(DomUI *ui)
out << "/*\n" << comment << "\n*/\n\n";
out << "/********************************************************************************\n";
- out << "** Form generated from reading ui file '" << QFileInfo(opt.inputFile).fileName() << "'\n";
+ out << "** Form generated from reading UI file '" << QFileInfo(opt.inputFile).fileName() << "'\n";
out << "**\n";
out << "** Created: " << QDateTime::currentDateTime().toString() << "\n";
out << "** " << QString::fromLatin1("by: Qt User Interface Compiler version %1\n").arg(QLatin1String(QT_VERSION_STR));
out << "**\n";
- out << "** WARNING! All changes made in this file will be lost when recompiling ui file!\n";
+ out << "** WARNING! All changes made in this file will be lost when recompiling UI file!\n";
out << "********************************************************************************/\n\n";
}