summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSona Kurazyan <[email protected]>2022-04-13 17:21:47 +0200
committerSona Kurazyan <[email protected]>2022-04-23 09:47:03 +0200
commitfedba8eaab464e9218afb4d11c7a77ddb5f09c40 (patch)
treeaeb9d0d978dd59bab4fb8c87ac7472a977479cf7
parent3aef84d6002016e6f764a0c2924bb5a802e9cb64 (diff)
uic: stop using QLatin1Char constructor for creating char literals
Required for porting away from QLatin1Char/QLatin1String in scope of QTBUG-98434. As a drive-by, fix qsizetype -> int narrowing conversion warnings for the touched lines. Change-Id: I0d3c232a9fa95aea854445922f100b89c6d6f5a1 Reviewed-by: Friedemann Kleint <[email protected]>
-rw-r--r--src/tools/uic/cpp/cppwritedeclaration.cpp2
-rw-r--r--src/tools/uic/cpp/cppwriteincludes.cpp6
-rw-r--r--src/tools/uic/cpp/cppwriteinitialization.cpp16
-rw-r--r--src/tools/uic/driver.cpp11
-rw-r--r--src/tools/uic/option.h2
-rw-r--r--src/tools/uic/python/pythonwriteimports.cpp4
-rw-r--r--src/tools/uic/shared/language.cpp6
-rw-r--r--src/tools/uic/uic.cpp6
8 files changed, 26 insertions, 27 deletions
diff --git a/src/tools/uic/cpp/cppwritedeclaration.cpp b/src/tools/uic/cpp/cppwritedeclaration.cpp
index 995b99b6923..9bdfc8ca5c6 100644
--- a/src/tools/uic/cpp/cppwritedeclaration.cpp
+++ b/src/tools/uic/cpp/cppwritedeclaration.cpp
@@ -75,7 +75,7 @@ void WriteDeclaration::acceptUI(DomUI *node)
QString exportMacro = node->elementExportMacro();
if (!exportMacro.isEmpty())
- exportMacro.append(QLatin1Char(' '));
+ exportMacro.append(u' ');
QStringList namespaceList = qualifiedClassName.split(QLatin1String("::"));
if (namespaceList.count()) {
diff --git a/src/tools/uic/cpp/cppwriteincludes.cpp b/src/tools/uic/cpp/cppwriteincludes.cpp
index 809c78f7004..9ead840c4d0 100644
--- a/src/tools/uic/cpp/cppwriteincludes.cpp
+++ b/src/tools/uic/cpp/cppwriteincludes.cpp
@@ -47,7 +47,7 @@ enum { warnHeaderGeneration = 0 };
static inline QString moduleHeader(const QString &module, const QString &header)
{
QString rc = module;
- rc += QLatin1Char('/');
+ rc += u'/';
rc += header;
return rc;
}
@@ -190,8 +190,8 @@ void WriteIncludes::insertInclude(const QString &header, bool global)
void WriteIncludes::writeHeaders(const OrderedSet &headers, bool global)
{
- const QChar openingQuote = global ? QLatin1Char('<') : QLatin1Char('"');
- const QChar closingQuote = global ? QLatin1Char('>') : QLatin1Char('"');
+ const QChar openingQuote = global ? u'<' : u'"';
+ const QChar closingQuote = global ? u'>' : u'"';
// Check for the old headers 'qslider.h' and replace by 'QtGui/QSlider'
for (const QString &header : headers) {
diff --git a/src/tools/uic/cpp/cppwriteinitialization.cpp b/src/tools/uic/cpp/cppwriteinitialization.cpp
index 33aa48d3087..89acd4b4c52 100644
--- a/src/tools/uic/cpp/cppwriteinitialization.cpp
+++ b/src/tools/uic/cpp/cppwriteinitialization.cpp
@@ -983,7 +983,7 @@ void WriteInitialization::acceptLayout(DomLayout *node)
m_layoutChain.pop();
// Stretch? (Unless we are compiling for UIC3)
- const QString numberNull = QString(QLatin1Char('0'));
+ const QString numberNull(u'0');
writePropertyList(varName, QLatin1String("setStretch"), node->attributeStretch(), numberNull);
writePropertyList(varName, QLatin1String("setRowStretch"), node->attributeRowStretch(), numberNull);
writePropertyList(varName, QLatin1String("setColumnStretch"), node->attributeColumnStretch(), numberNull);
@@ -999,7 +999,7 @@ void WriteInitialization::writePropertyList(const QString &varName,
{
if (value.isEmpty())
return;
- const QStringList list = value.split(QLatin1Char(','));
+ const QStringList list = value.split(u',');
const int count = list.count();
for (int i = 0; i < count; i++) {
if (list.at(i) != defaultValue) {
@@ -1375,7 +1375,7 @@ void WriteInitialization::writeProperties(const QString &varName,
if (p->hasAttributeStdset() && !p->attributeStdset())
varNewName += language::derefPointer + QLatin1String("viewport()");
propertyValue = QLatin1String("QCursor(Qt") + language::qualifier
- + p->elementCursorShape() + QLatin1Char(')');
+ + p->elementCursorShape() + u')';
break;
case DomProperty::Enum:
propertyValue = p->elementEnum();
@@ -1479,17 +1479,17 @@ void WriteInitialization::writeProperties(const QString &varName,
break;
case DomProperty::UInt:
propertyValue = QString::number(p->elementUInt());
- propertyValue += QLatin1Char('u');
+ propertyValue += u'u';
break;
case DomProperty::LongLong:
propertyValue = QLatin1String("Q_INT64_C(");
propertyValue += QString::number(p->elementLongLong());
- propertyValue += QLatin1Char(')');;
+ propertyValue += u')';
break;
case DomProperty::ULongLong:
propertyValue = QLatin1String("Q_UINT64_C(");
propertyValue += QString::number(p->elementULongLong());
- propertyValue += QLatin1Char(')');
+ propertyValue += u')';
break;
case DomProperty::Float:
propertyValue = QString::number(p->elementFloat(), 'f', 8);
@@ -2227,10 +2227,10 @@ void WriteInitialization::addQtFlagsInitializer(Item *item,
const DomPropertyMap &properties, const QString &name, int column) const
{
if (const DomProperty *p = properties.value(name)) {
- const QString orOperator = QLatin1Char('|') + language::qtQualifier;
+ const QString orOperator = u'|' + language::qtQualifier;
QString v = p->elementSet();
if (!v.isEmpty()) {
- v.replace(QLatin1Char('|'), orOperator);
+ v.replace(u'|', orOperator);
addInitializer(item, name, column, language::qtQualifier + v);
}
}
diff --git a/src/tools/uic/driver.cpp b/src/tools/uic/driver.cpp
index 8b9b4806e69..7acc8f9c614 100644
--- a/src/tools/uic/driver.cpp
+++ b/src/tools/uic/driver.cpp
@@ -152,7 +152,7 @@ QString Driver::normalizedName(const QString &name)
QString result = name;
std::replace_if(result.begin(), result.end(),
[] (QChar c) { return !c.isLetterOrNumber(); },
- QLatin1Char('_'));
+ u'_');
return result;
}
@@ -190,7 +190,7 @@ QString Driver::qtify(const QString &name)
{
QString qname = name;
- if (qname.at(0) == QLatin1Char('Q') || qname.at(0) == QLatin1Char('K'))
+ if (qname.at(0) == u'Q' || qname.at(0) == u'K')
qname.remove(0, 1);
for (int i = 0, size = qname.size(); i < size && qname.at(i).isUpper(); ++i)
@@ -201,8 +201,7 @@ QString Driver::qtify(const QString &name)
static bool isAnsiCCharacter(QChar c)
{
- return (c.toUpper() >= QLatin1Char('A') && c.toUpper() <= QLatin1Char('Z'))
- || c.isDigit() || c == QLatin1Char('_');
+ return (c.toUpper() >= u'A' && c.toUpper() <= u'Z') || c.isDigit() || c == u'_';
}
QString Driver::headerFileName() const
@@ -226,13 +225,13 @@ QString Driver::headerFileName(const QString &fileName)
QString baseName = info.baseName();
// Transform into a valid C++ identifier
if (!baseName.isEmpty() && baseName.at(0).isDigit())
- baseName.prepend(QLatin1Char('_'));
+ baseName.prepend(u'_');
for (int i = 0; i < baseName.size(); ++i) {
QChar c = baseName.at(i);
if (!isAnsiCCharacter(c)) {
// Replace character by its unicode value
QString hex = QString::number(c.unicode(), 16);
- baseName.replace(i, 1, QLatin1Char('_') + hex + QLatin1Char('_'));
+ baseName.replace(i, 1, u'_' + hex + u'_');
i += hex.size() + 1;
}
}
diff --git a/src/tools/uic/option.h b/src/tools/uic/option.h
index b08aab2d3ee..c4703ab6265 100644
--- a/src/tools/uic/option.h
+++ b/src/tools/uic/option.h
@@ -74,7 +74,7 @@ struct Option
forceStringConnectionSyntax(0),
useStarImports(0),
prefix(QLatin1String("Ui_"))
- { indent.fill(QLatin1Char(' '), 4); }
+ { indent.fill(u' ', 4); }
QString messagePrefix() const
{
diff --git a/src/tools/uic/python/pythonwriteimports.cpp b/src/tools/uic/python/pythonwriteimports.cpp
index 0d295b483d5..cceb0693143 100644
--- a/src/tools/uic/python/pythonwriteimports.cpp
+++ b/src/tools/uic/python/pythonwriteimports.cpp
@@ -81,7 +81,7 @@ static WriteImports::ClassesPerModule defaultClasses()
// module name "foo_rc" according to project conventions.
static QString pythonResource(QString resource)
{
- const int lastSlash = resource.lastIndexOf(QLatin1Char('/'));
+ const qsizetype lastSlash = resource.lastIndexOf(u'/');
if (lastSlash != -1)
resource.remove(0, lastSlash + 1);
if (resource.endsWith(QLatin1String(".qrc"))) {
@@ -223,7 +223,7 @@ void WriteImports::addPythonCustomWidget(const QString &className, const DomCust
} else { // When we do have elementHeader, we know it's a relative import.
QString modulePath = node->elementHeader()->text();
// Replace the '/' by '.'
- modulePath.replace(QLatin1Char('/'), QLatin1Char('.'));
+ modulePath.replace(u'/', u'.');
// '.h' is added by default on headers for <customwidget>
if (modulePath.endsWith(QLatin1String(".h")))
modulePath.chop(2);
diff --git a/src/tools/uic/shared/language.cpp b/src/tools/uic/shared/language.cpp
index fc1395d403d..b3583c2038f 100644
--- a/src/tools/uic/shared/language.cpp
+++ b/src/tools/uic/shared/language.cpp
@@ -217,7 +217,7 @@ static int formatEscapedNumber(QTextStream &str, ushort value, int base, int wid
const auto oldFieldWidth = str.fieldWidth();
const auto oldFieldAlignment = str.fieldAlignment();
const auto oldIntegerBase = str.integerBase();
- str.setPadChar(QLatin1Char('0'));
+ str.setPadChar(u'0');
str.setFieldWidth(width);
str.setFieldAlignment(QTextStream::AlignRight);
str.setIntegerBase(base);
@@ -405,7 +405,7 @@ enum OverloadUse {
static void formatMemberFnPtr(QTextStream &str, const SignalSlot &s,
OverloadUse useQOverload = DontUseOverload)
{
- const int parenPos = s.signature.indexOf(QLatin1Char('('));
+ const qsizetype parenPos = s.signature.indexOf(u'(');
Q_ASSERT(parenPos >= 0);
const auto functionName = QStringView{s.signature}.left(parenPos);
@@ -469,7 +469,7 @@ void formatConnection(QTextStream &str, const SignalSlot &sender, const SignalSl
str << "[\"" << parameters << "\"]";
}
str << ".connect(" << receiver.name << '.'
- << QStringView{receiver.signature}.left(receiver.signature.indexOf(QLatin1Char('(')))
+ << QStringView{receiver.signature}.left(receiver.signature.indexOf(u'('))
<< ')';
}
break;
diff --git a/src/tools/uic/uic.cpp b/src/tools/uic/uic.cpp
index 36012801445..5fa5661f873 100644
--- a/src/tools/uic/uic.cpp
+++ b/src/tools/uic/uic.cpp
@@ -127,7 +127,7 @@ void Uic::writeCopyrightHeaderCpp(const DomUI *ui) const
static inline bool isCppCommentChar(QChar c)
{
- return c == QLatin1Char('/') || c == QLatin1Char('*');
+ return c == u'/' || c == u'*';
}
static int leadingCppCommentCharCount(QStringView s)
@@ -142,13 +142,13 @@ void Uic::writeCopyrightHeaderPython(const DomUI *ui) const
{
QString comment = ui->elementComment();
if (!comment.isEmpty()) {
- const auto lines = QStringView{comment}.split(QLatin1Char('\n'));
+ const auto lines = QStringView{comment}.split(u'\n');
for (const auto &line : lines) {
if (const int leadingCommentChars = leadingCppCommentCharCount(line)) {
out << language::repeat(leadingCommentChars, '#')
<< line.right(line.size() - leadingCommentChars);
} else {
- if (!line.startsWith(QLatin1Char('#')))
+ if (!line.startsWith(u'#'))
out << "# ";
out << line;
}