summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarc Mutz <marc.mutz@kdab.com>2020-04-27 11:16:52 +0200
committerMarc Mutz <marc.mutz@kdab.com>2020-04-30 07:49:43 +0200
commit915e756a426ccb0ad4d4322182d1468a995b4c18 (patch)
treeb75f92d9289bd8516760cdc5cae4196b7cb87cdb
parent2e41a466903852facc3f3f0100d04149b72b2409 (diff)
QtCore: fix a few more char/int/uint -> QChar conversions
They were masked by all QChar ctors being made explicit, except the char16_t one, which was left as the only viable choice. Change-Id: I5632795f3c7dd1de3830285d5446d9b994613466 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
-rw-r--r--src/corelib/mimetypes/qmimeprovider.cpp2
-rw-r--r--src/corelib/serialization/qcbordiagnostic.cpp15
-rw-r--r--src/corelib/time/qdatetimeparser.cpp4
-rw-r--r--src/corelib/time/qtimezoneprivate_tz.cpp2
4 files changed, 13 insertions, 10 deletions
diff --git a/src/corelib/mimetypes/qmimeprovider.cpp b/src/corelib/mimetypes/qmimeprovider.cpp
index 9dba72923a..04d6d6220b 100644
--- a/src/corelib/mimetypes/qmimeprovider.cpp
+++ b/src/corelib/mimetypes/qmimeprovider.cpp
@@ -281,7 +281,7 @@ bool QMimeBinaryProvider::matchSuffixTree(QMimeGlobMatchResult &result, QMimeBin
while (min <= max) {
const int mid = (min + max) / 2;
const int off = firstOffset + 12 * mid;
- const QChar ch = cacheFile->getUint32(off);
+ const QChar ch = char16_t(cacheFile->getUint32(off));
if (ch < fileChar)
min = mid + 1;
else if (ch > fileChar)
diff --git a/src/corelib/serialization/qcbordiagnostic.cpp b/src/corelib/serialization/qcbordiagnostic.cpp
index 75feaded17..2e92dab0a4 100644
--- a/src/corelib/serialization/qcbordiagnostic.cpp
+++ b/src/corelib/serialization/qcbordiagnostic.cpp
@@ -112,7 +112,7 @@ static QString makeFpString(double d)
s.prepend(QLatin1Char('-'));
} else {
s = QString::number(d, 'g', QLocale::FloatingPointShortest);
- if (!s.contains(QLatin1Char('.')) && !s.contains('e'))
+ if (!s.contains(u'.') && !s.contains(u'e'))
s += QLatin1Char('.');
}
return s;
@@ -171,14 +171,17 @@ void DiagnosticNotation::appendString(const QString &s)
buf[1] = QChar(uc);
if (buf[1] == QChar::Null) {
- using QtMiscUtils::toHexUpper;
+ const auto toHexUpper = [](char32_t value) -> QChar {
+ // QtMiscUtils::toHexUpper() returns char, we need QChar, so wrap
+ return char16_t(QtMiscUtils::toHexUpper(value));
+ };
if (ptr->isHighSurrogate() && (ptr + 1) != end && ptr[1].isLowSurrogate()) {
// properly-paired surrogates
++ptr;
char32_t ucs4 = QChar::surrogateToUcs4(uc, ptr->unicode());
- buf[1] = 'U';
- buf[2] = '0'; // toHexUpper(ucs4 >> 28);
- buf[3] = '0'; // toHexUpper(ucs4 >> 24);
+ buf[1] = u'U';
+ buf[2] = u'0'; // toHexUpper(ucs4 >> 28);
+ buf[3] = u'0'; // toHexUpper(ucs4 >> 24);
buf[4] = toHexUpper(ucs4 >> 20);
buf[5] = toHexUpper(ucs4 >> 16);
buf[6] = toHexUpper(ucs4 >> 12);
@@ -187,7 +190,7 @@ void DiagnosticNotation::appendString(const QString &s)
buf[9] = toHexUpper(ucs4);
buflen = 10;
} else {
- buf[1] = 'u';
+ buf[1] = u'u';
buf[2] = toHexUpper(uc >> 12);
buf[3] = toHexUpper(uc >> 8);
buf[4] = toHexUpper(uc >> 4);
diff --git a/src/corelib/time/qdatetimeparser.cpp b/src/corelib/time/qdatetimeparser.cpp
index bc3d9b992e..860f975b4f 100644
--- a/src/corelib/time/qdatetimeparser.cpp
+++ b/src/corelib/time/qdatetimeparser.cpp
@@ -1663,9 +1663,9 @@ QDateTimeParser::findTimeZone(QStringRef str, const QDateTime &when,
// Collect up plausibly-valid characters; let QTimeZone work out what's truly valid.
while (index < size) {
- QChar here = str[index];
+ const auto here = str[index].unicode();
if (here < 127
- && (here.isLetterOrNumber()
+ && (QChar::isLetterOrNumber(here)
|| here == '/' || here == '-'
|| here == '_' || here == '.'
|| here == '+' || here == ':'))
diff --git a/src/corelib/time/qtimezoneprivate_tz.cpp b/src/corelib/time/qtimezoneprivate_tz.cpp
index 01f9a6cce0..d40f4612d5 100644
--- a/src/corelib/time/qtimezoneprivate_tz.cpp
+++ b/src/corelib/time/qtimezoneprivate_tz.cpp
@@ -91,7 +91,7 @@ static QTzTimeZoneHash loadTzTimeZones()
while (!ts.atEnd()) {
const QString line = ts.readLine();
// Comment lines are prefixed with a #
- if (!line.isEmpty() && line.at(0) != '#') {
+ if (!line.isEmpty() && line.at(0) != u'#') {
// Data rows are tab-separated columns Region, Coordinates, ID, Optional Comments
const auto parts = line.splitRef(QLatin1Char('\t'));
QTzTimeZone zone;