diff options
author | Sona Kurazyan <sona.kurazyan@qt.io> | 2022-03-09 16:34:49 +0100 |
---|---|---|
committer | Sona Kurazyan <sona.kurazyan@qt.io> | 2022-03-25 19:16:29 +0100 |
commit | 753a08ae0e1204b148cf3935f87349eefe75d338 (patch) | |
tree | 193ff5b6a131bba519336c31727d708ddab43032 /src/corelib/kernel/qcoreapplication.cpp | |
parent | 1fefff6d1f99dbcf1a453424753ad5562fb675ef (diff) |
QtCore: replace QLatin1String/QLatin1Char with _L1/u'' where applicable
As a drive-by, did also minor refactorings/improvements.
Task-number: QTBUG-98434
Change-Id: I81964176ae2f07ea63674c96f47f9c6aa046854f
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Anton Kudryavtsev <antkudr@mail.ru>
Diffstat (limited to 'src/corelib/kernel/qcoreapplication.cpp')
-rw-r--r-- | src/corelib/kernel/qcoreapplication.cpp | 20 |
1 files changed, 11 insertions, 9 deletions
diff --git a/src/corelib/kernel/qcoreapplication.cpp b/src/corelib/kernel/qcoreapplication.cpp index fa0c2486cc..e41c1b6df7 100644 --- a/src/corelib/kernel/qcoreapplication.cpp +++ b/src/corelib/kernel/qcoreapplication.cpp @@ -138,6 +138,8 @@ QT_BEGIN_NAMESPACE +using namespace Qt::StringLiterals; + #if defined(Q_OS_WIN) || defined(Q_OS_MAC) extern QString qAppFileName(); #endif @@ -573,7 +575,7 @@ void QCoreApplicationPrivate::appendApplicationPathToLibraryPaths() if (!app_libpaths) coreappdata()->app_libpaths.reset(app_libpaths = new QStringList); QString app_location = QCoreApplication::applicationFilePath(); - app_location.truncate(app_location.lastIndexOf(QLatin1Char('/'))); + app_location.truncate(app_location.lastIndexOf(u'/')); app_location = QDir(app_location).canonicalPath(); if (QFile::exists(app_location) && !app_libpaths->contains(app_location)) app_libpaths->append(app_location); @@ -2181,20 +2183,20 @@ static void replacePercentN(QString *result, int n) if (n >= 0) { int percentPos = 0; int len = 0; - while ((percentPos = result->indexOf(QLatin1Char('%'), percentPos + len)) != -1) { + while ((percentPos = result->indexOf(u'%', percentPos + len)) != -1) { len = 1; if (percentPos + len == result->length()) break; QString fmt; - if (result->at(percentPos + len) == QLatin1Char('L')) { + if (result->at(percentPos + len) == u'L') { ++len; if (percentPos + len == result->length()) break; - fmt = QLatin1String("%L1"); + fmt = "%L1"_L1; } else { - fmt = QLatin1String("%1"); + fmt = "%1"_L1; } - if (result->at(percentPos + len) == QLatin1Char('n')) { + if (result->at(percentPos + len) == u'n') { fmt = fmt.arg(n); ++len; result->replace(percentPos, len, fmt); @@ -2290,7 +2292,7 @@ QString QCoreApplication::translate(const char *context, const char *sourceText, Q_UNUSED(disambiguation); QString ret = QString::fromUtf8(sourceText); if (n >= 0) - ret.replace(QLatin1String("%n"), QString::number(n)); + ret.replace("%n"_L1, QString::number(n)); return ret; } @@ -2406,13 +2408,13 @@ QString QCoreApplication::applicationFilePath() if (absPath.isEmpty() && !arguments().isEmpty()) { QString argv0 = QFile::decodeName(arguments().at(0).toLocal8Bit()); - if (!argv0.isEmpty() && argv0.at(0) == QLatin1Char('/')) { + if (!argv0.isEmpty() && argv0.at(0) == u'/') { /* If argv0 starts with a slash, it is already an absolute file path. */ absPath = argv0; - } else if (argv0.contains(QLatin1Char('/'))) { + } else if (argv0.contains(u'/')) { /* If argv0 contains one or more slashes, it is a file path relative to the current directory. |