diff options
Diffstat (limited to 'src/corelib/io')
45 files changed, 641 insertions, 577 deletions
diff --git a/src/corelib/io/qabstractfileengine.cpp b/src/corelib/io/qabstractfileengine.cpp index d6b2b6a10e..d077e68161 100644 --- a/src/corelib/io/qabstractfileengine.cpp +++ b/src/corelib/io/qabstractfileengine.cpp @@ -1017,8 +1017,8 @@ QString QAbstractFileEngineIterator::currentFilePath() const if (!name.isNull()) { QString tmp = path(); if (!tmp.isEmpty()) { - if (!tmp.endsWith(QLatin1Char('/'))) - tmp.append(QLatin1Char('/')); + if (!tmp.endsWith(u'/')) + tmp.append(u'/'); name.prepend(tmp); } } diff --git a/src/corelib/io/qdataurl.cpp b/src/corelib/io/qdataurl.cpp index 1d91933e75..f58c04cef2 100644 --- a/src/corelib/io/qdataurl.cpp +++ b/src/corelib/io/qdataurl.cpp @@ -53,7 +53,7 @@ using namespace Qt::Literals; */ Q_CORE_EXPORT bool qDecodeDataUrl(const QUrl &uri, QString &mimeType, QByteArray &payload) { - if (uri.scheme() != QLatin1String("data") || !uri.host().isEmpty()) + if (uri.scheme() != "data"_L1 || !uri.host().isEmpty()) return false; mimeType = QStringLiteral("text/plain;charset=US-ASCII"); diff --git a/src/corelib/io/qdebug.cpp b/src/corelib/io/qdebug.cpp index 4956b2a59c..525f032368 100644 --- a/src/corelib/io/qdebug.cpp +++ b/src/corelib/io/qdebug.cpp @@ -196,7 +196,7 @@ QByteArray QtDebugUtils::toPrintable(const char *data, int len, int maxSize) QDebug::~QDebug() { if (stream && !--stream->ref) { - if (stream->space && stream->buffer.endsWith(QLatin1Char(' '))) + if (stream->space && stream->buffer.endsWith(u' ')) stream->buffer.chop(1); if (stream->message_output) { qt_message_output(stream->type, @@ -222,7 +222,7 @@ void QDebug::putUcs4(uint ucs4) stream->ts << "\\u" << qSetFieldWidth(4); else stream->ts << "\\U" << qSetFieldWidth(8); - stream->ts << Qt::hex << qSetPadChar(QLatin1Char('0')) << ucs4 << Qt::reset; + stream->ts << Qt::hex << qSetPadChar(u'0') << ucs4 << Qt::reset; } maybeQuote('\''); } @@ -240,7 +240,7 @@ static inline bool isPrintable(uchar c) template <typename Char> static inline void putEscapedString(QTextStreamPrivate *d, const Char *begin, int length, bool isUnicode = true) { - QChar quote(QLatin1Char('"')); + QChar quote(u'"'); d->write("e, 1); bool lastWasHexEscape = false; @@ -250,7 +250,7 @@ static inline void putEscapedString(QTextStreamPrivate *d, const Char *begin, in if (Q_UNLIKELY(lastWasHexEscape)) { if (fromHex(*p) != -1) { // yes, insert it - QChar quotes[] = { QLatin1Char('"'), QLatin1Char('"') }; + QChar quotes[] = { quote, quote }; d->write(quotes, 2); } lastWasHexEscape = false; @@ -983,7 +983,7 @@ public: { const bool currentSpaces = m_stream->space; if (currentSpaces && !m_spaces) - if (m_stream->buffer.endsWith(QLatin1Char(' '))) + if (m_stream->buffer.endsWith(u' ')) m_stream->buffer.chop(1); m_stream->space = m_spaces; diff --git a/src/corelib/io/qdir.cpp b/src/corelib/io/qdir.cpp index 5fba6619e6..a88ddc837c 100644 --- a/src/corelib/io/qdir.cpp +++ b/src/corelib/io/qdir.cpp @@ -68,6 +68,8 @@ QT_BEGIN_NAMESPACE +using namespace Qt::StringLiterals; + #if defined(Q_OS_WIN) static QString driveSpec(const QString &path) { @@ -95,18 +97,18 @@ static int rootLength(const QString &name, bool allowUncPaths) { const int len = name.length(); // starts with double slash - if (allowUncPaths && name.startsWith(QLatin1String("//"))) { + if (allowUncPaths && name.startsWith("//"_L1)) { // Server name '//server/path' is part of the prefix. - const int nextSlash = name.indexOf(QLatin1Char('/'), 2); + const int nextSlash = name.indexOf(u'/', 2); return nextSlash >= 0 ? nextSlash + 1 : len; } #if defined(Q_OS_WIN) - if (len >= 2 && name.at(1) == QLatin1Char(':')) { + if (len >= 2 && name.at(1) == u':') { // Handle a possible drive letter - return len > 2 && name.at(2) == QLatin1Char('/') ? 3 : 2; + return len > 2 && name.at(2) == u'/' ? 3 : 2; } #endif - if (name.at(0) == QLatin1Char('/')) + if (name.at(0) == u'/') return 1; return 0; } @@ -165,10 +167,10 @@ bool QDirPrivate::exists() const // static inline QChar QDirPrivate::getFilterSepChar(const QString &nameFilter) { - QChar sep(QLatin1Char(';')); + QChar sep(u';'); int i = nameFilter.indexOf(sep, 0); - if (i == -1 && nameFilter.indexOf(QLatin1Char(' '), 0) != -1) - sep = QChar(QLatin1Char(' ')); + if (i == -1 && nameFilter.indexOf(u' ', 0) != -1) + sep = QChar(u' '); return sep; } @@ -186,7 +188,7 @@ inline QStringList QDirPrivate::splitFilters(const QString &nameFilter, QChar se inline void QDirPrivate::setPath(const QString &path) { QString p = QDir::fromNativeSeparators(path); - if (p.endsWith(QLatin1Char('/')) + if (p.endsWith(u'/') && p.length() > 1 #if defined(Q_OS_WIN) && (!(p.length() == 3 && p.at(1).unicode() == ':' && p.at(0).isLetter())) @@ -717,7 +719,7 @@ static int drivePrefixLength(const QString &path) if (size > 1 && path.at(1).unicode() == ':') { if (Q_UNLIKELY(!path.at(0).isLetter())) return 0; - } else if (path.startsWith(QLatin1String("//"))) { + } else if (path.startsWith("//"_L1)) { // UNC path; use its //server/share part as "drive" - it's as sane a // thing as we can do. for (int i = 2; i-- > 0; ) { // Scan two "path fragments": @@ -749,7 +751,7 @@ static bool treatAsAbsolute(const QString &path) // a colon in the path. // FIXME: relies on virtual file-systems having colons in their prefixes. // The case of an MS-absolute C:/... path happens to work either way. - return (path.contains(QLatin1Char(':')) && QFileInfo(path).isAbsolute()) + return (path.contains(u':') && QFileInfo(path).isAbsolute()) || QFileSystemEntry(path).isAbsolute(); } @@ -773,16 +775,16 @@ QString QDir::filePath(const QString &fileName) const return ret; #ifdef Q_OS_WIN - if (fileName.startsWith(QLatin1Char('/')) || fileName.startsWith(QLatin1Char('\\'))) { + if (fileName.startsWith(u'/') || fileName.startsWith(u'\\')) { // Handle the "absolute except for drive" case (i.e. \blah not c:\blah): const int drive = drivePrefixLength(ret); return drive > 0 ? QStringView{ret}.left(drive) % fileName : fileName; } #endif // Q_OS_WIN - if (ret.isEmpty() || ret.endsWith(QLatin1Char('/'))) + if (ret.isEmpty() || ret.endsWith(u'/')) return ret % fileName; - return ret % QLatin1Char('/') % fileName; + return ret % u'/' % fileName; } /*! @@ -805,7 +807,7 @@ QString QDir::absoluteFilePath(const QString &fileName) const return absoluteDirPath; #ifdef Q_OS_WIN // Handle the "absolute except for drive" case (i.e. \blah not c:\blah): - if (fileName.startsWith(QLatin1Char('/')) || fileName.startsWith(QLatin1Char('\\'))) { + if (fileName.startsWith(u'/') || fileName.startsWith(u'\\')) { // Combine absoluteDirPath's drive with fileName const int drive = drivePrefixLength(absoluteDirPath); if (Q_LIKELY(drive)) @@ -816,8 +818,8 @@ QString QDir::absoluteFilePath(const QString &fileName) const return QString(); } #endif // Q_OS_WIN - if (!absoluteDirPath.endsWith(QLatin1Char('/'))) - return absoluteDirPath % QLatin1Char('/') % fileName; + if (!absoluteDirPath.endsWith(u'/')) + return absoluteDirPath % u'/' % fileName; return absoluteDirPath % fileName; } @@ -847,9 +849,10 @@ QString QDir::relativeFilePath(const QString &fileName) const } if (fileDrive.toLower() != dirDrive.toLower() - || (file.startsWith(QLatin1String("//")) - && !dir.startsWith(QLatin1String("//")))) + || (file.startsWith("//"_L1) + && !dir.startsWith("//"_L1))) { return file; + } dir.remove(0, dirDrive.size()); if (!fileDriveMissing) @@ -857,8 +860,8 @@ QString QDir::relativeFilePath(const QString &fileName) const #endif QString result; - const auto dirElts = dir.tokenize(QLatin1Char('/'), Qt::SkipEmptyParts); - const auto fileElts = file.tokenize(QLatin1Char('/'), Qt::SkipEmptyParts); + const auto dirElts = dir.tokenize(u'/', Qt::SkipEmptyParts); + const auto fileElts = file.tokenize(u'/', Qt::SkipEmptyParts); const auto dend = dirElts.end(); const auto fend = fileElts.end(); @@ -881,20 +884,20 @@ QString QDir::relativeFilePath(const QString &fileName) const } while (dit != dend) { - result += QLatin1String("../"); + result += "../"_L1; ++dit; } if (fit != fend) { while (fit != fend) { result += *fit++; - result += QLatin1Char('/'); + result += u'/'; } result.chop(1); } if (result.isEmpty()) - result = QLatin1String("."); + result = "."_L1; return result; } @@ -916,16 +919,16 @@ QString QDir::relativeFilePath(const QString &fileName) const QString QDir::toNativeSeparators(const QString &pathName) { #if defined(Q_OS_WIN) - int i = pathName.indexOf(QLatin1Char('/')); + int i = pathName.indexOf(u'/'); if (i != -1) { QString n(pathName); QChar * const data = n.data(); - data[i++] = QLatin1Char('\\'); + data[i++] = u'\\'; for (; i < n.length(); ++i) { - if (data[i] == QLatin1Char('/')) - data[i] = QLatin1Char('\\'); + if (data[i] == u'/') + data[i] = u'\\'; } return n; @@ -973,19 +976,19 @@ bool QDir::cd(const QString &dirName) // Don't detach just yet. const QDirPrivate * const d = d_ptr.constData(); - if (dirName.isEmpty() || dirName == QLatin1String(".")) + if (dirName.isEmpty() || dirName == u'.') return true; QString newPath; if (isAbsolutePath(dirName)) { newPath = qt_cleanPath(dirName); } else { newPath = d->dirEntry.filePath(); - if (!newPath.endsWith(QLatin1Char('/'))) - newPath += QLatin1Char('/'); + if (!newPath.endsWith(u'/')) + newPath += u'/'; newPath += dirName; - if (dirName.indexOf(QLatin1Char('/')) >= 0 - || dirName == QLatin1String("..") - || d->dirEntry.filePath() == QLatin1String(".")) { + if (dirName.indexOf(u'/') >= 0 + || dirName == ".."_L1 + || d->dirEntry.filePath() == u'.') { bool ok; newPath = qt_cleanPath(newPath, &ok); if (!ok) @@ -998,7 +1001,7 @@ bool QDir::cd(const QString &dirName) while (dir.cdUp()) ; */ - if (newPath.startsWith(QLatin1String(".."))) { + if (newPath.startsWith(".."_L1)) { newPath = QFileInfo(newPath).absoluteFilePath(); } } @@ -2325,9 +2328,9 @@ static QString qt_cleanPath(const QString &path, bool *ok) QString ret = qt_normalizePathSegments(name, OSSupportsUncPaths ? QDirPrivate::AllowUncPaths : QDirPrivate::DefaultNormalization, ok); // Strip away last slash except for root directories - if (ret.length() > 1 && ret.endsWith(QLatin1Char('/'))) { + if (ret.length() > 1 && ret.endsWith(u'/')) { #if defined (Q_OS_WIN) - if (!(ret.length() == 3 && ret.at(1) == QLatin1Char(':'))) + if (!(ret.length() == 3 && ret.at(1) == u':')) #endif ret.chop(1); } @@ -2457,25 +2460,25 @@ QDebug operator<<(QDebug debug, QDir::Filters filters) debug.resetFormat(); QStringList flags; if (filters == QDir::NoFilter) { - flags << QLatin1String("NoFilter"); + flags << "NoFilter"_L1; } else { - if (filters & QDir::Dirs) flags << QLatin1String("Dirs"); - if (filters & QDir::AllDirs) flags << QLatin1String("AllDirs"); - if (filters & QDir::Files) flags << QLatin1String("Files"); - if (filters & QDir::Drives) flags << QLatin1String("Drives"); - if (filters & QDir::NoSymLinks) flags << QLatin1String("NoSymLinks"); - if (filters & QDir::NoDot) flags << QLatin1String("NoDot"); - if (filters & QDir::NoDotDot) flags << QLatin1String("NoDotDot"); - if ((filters & QDir::AllEntries) == QDir::AllEntries) flags << QLatin1String("AllEntries"); - if (filters & QDir::Readable) flags << QLatin1String("Readable"); - if (filters & QDir::Writable) flags << QLatin1String("Writable"); - if (filters & QDir::Executable) flags << QLatin1String("Executable"); - if (filters & QDir::Modified) flags << QLatin1String("Modified"); - if (filters & QDir::Hidden) flags << QLatin1String("Hidden"); - if (filters & QDir::System) flags << QLatin1String("System"); - if (filters & QDir::CaseSensitive) flags << QLatin1String("CaseSensitive"); + if (filters & QDir::Dirs) flags << "Dirs"_L1; + if (filters & QDir::AllDirs) flags << "AllDirs"_L1; + if (filters & QDir::Files) flags << "Files"_L1; + if (filters & QDir::Drives) flags << "Drives"_L1; + if (filters & QDir::NoSymLinks) flags << "NoSymLinks"_L1; + if (filters & QDir::NoDot) flags << "NoDot"_L1; + if (filters & QDir::NoDotDot) flags << "NoDotDot"_L1; + if ((filters & QDir::AllEntries) == QDir::AllEntries) flags << "AllEntries"_L1; + if (filters & QDir::Readable) flags << "Readable"_L1; + if (filters & QDir::Writable) flags << "Writable"_L1; + if (filters & QDir::Executable) flags << "Executable"_L1; + if (filters & QDir::Modified) flags << "Modified"_L1; + if (filters & QDir::Hidden) flags << "Hidden"_L1; + if (filters & QDir::System) flags << "System"_L1; + if (filters & QDir::CaseSensitive) flags << "CaseSensitive"_L1; } - debug.noquote() << "QDir::Filters(" << flags.join(QLatin1Char('|')) << ')'; + debug.noquote() << "QDir::Filters(" << flags.join(u'|') << ')'; return debug; } @@ -2487,18 +2490,18 @@ static QDebug operator<<(QDebug debug, QDir::SortFlags sorting) debug << "QDir::SortFlags(NoSort)"; } else { QString type; - if ((sorting & QDir::SortByMask) == QDir::Name) type = QLatin1String("Name"); - if ((sorting & QDir::SortByMask) == QDir::Time) type = QLatin1String("Time"); - if ((sorting & QDir::SortByMask) == QDir::Size) type = QLatin1String("Size"); - if ((sorting & QDir::SortByMask) == QDir::Unsorted) type = QLatin1String("Unsorted"); + if ((sorting & QDir::SortByMask) == QDir::Name) type = "Name"_L1; + if ((sorting & QDir::SortByMask) == QDir::Time) type = "Time"_L1; + if ((sorting & QDir::SortByMask) == QDir::Size) type = "Size"_L1; + if ((sorting & QDir::SortByMask) == QDir::Unsorted) type = "Unsorted"_L1; QStringList flags; - if (sorting & QDir::DirsFirst) flags << QLatin1String("DirsFirst"); - if (sorting & QDir::DirsLast) flags << QLatin1String("DirsLast"); - if (sorting & QDir::IgnoreCase) flags << QLatin1String("IgnoreCase"); - if (sorting & QDir::LocaleAware) flags << QLatin1String("LocaleAware"); - if (sorting & QDir::Type) flags << QLatin1String("Type"); - debug.noquote() << "QDir::SortFlags(" << type << '|' << flags.join(QLatin1Char('|')) << ')'; + if (sorting & QDir::DirsFirst) flags << "DirsFirst"_L1; + if (sorting & QDir::DirsLast) flags << "DirsLast"_L1; + if (sorting & QDir::IgnoreCase) flags << "IgnoreCase"_L1; + if (sorting & QDir::LocaleAware) flags << "LocaleAware"_L1; + if (sorting & QDir::Type) flags << "Type"_L1; + debug.noquote() << "QDir::SortFlags(" << type << '|' << flags.join(u'|') << ')'; } return debug; } @@ -2508,7 +2511,7 @@ QDebug operator<<(QDebug debug, const QDir &dir) QDebugStateSaver save(debug); debug.resetFormat(); debug << "QDir(" << dir.path() << ", nameFilters = {" - << dir.nameFilters().join(QLatin1Char(',')) + << dir.nameFilters().join(u',') << "}, " << dir.sorting() << ',' diff --git a/src/corelib/io/qdiriterator.cpp b/src/corelib/io/qdiriterator.cpp index 7e86aacdb1..74278092f9 100644 --- a/src/corelib/io/qdiriterator.cpp +++ b/src/corelib/io/qdiriterator.cpp @@ -111,6 +111,8 @@ QT_BEGIN_NAMESPACE +using namespace Qt::StringLiterals; + template <class Iterator> class QDirIteratorPrivateIteratorStack : public QStack<Iterator *> { @@ -163,7 +165,7 @@ public: QDirIteratorPrivate::QDirIteratorPrivate(const QFileSystemEntry &entry, const QStringList &nameFilters, QDir::Filters _filters, QDirIterator::IteratorFlags flags, bool resolveEngine) : dirEntry(entry) - , nameFilters(nameFilters.contains(QLatin1String("*")) ? QStringList() : nameFilters) + , nameFilters(nameFilters.contains("*"_L1) ? QStringList() : nameFilters) , filters(QDir::NoFilter == _filters ? QDir::AllEntries : _filters) , iteratorFlags(flags) { @@ -301,7 +303,7 @@ void QDirIteratorPrivate::checkAndPushDirectory(const QFileInfo &fileInfo) // Never follow . and .. QString fileName = fileInfo.fileName(); - if (QLatin1String(".") == fileName || QLatin1String("..") == fileName) + if ("."_L1 == fileName || ".."_L1 == fileName) return; // No hidden directories unless requested @@ -329,9 +331,9 @@ bool QDirIteratorPrivate::matchesFilters(const QString &fileName, const QFileInf // filter . and ..? const int fileNameSize = fileName.size(); - const bool dotOrDotDot = fileName[0] == QLatin1Char('.') + const bool dotOrDotDot = fileName[0] == u'.' && ((fileNameSize == 1) - ||(fileNameSize == 2 && fileName[1] == QLatin1Char('.'))); + ||(fileNameSize == 2 && fileName[1] == u'.')); if ((filters & QDir::NoDot) && dotOrDotDot && fileNameSize == 1) return false; if ((filters & QDir::NoDotDot) && dotOrDotDot && fileNameSize == 2) diff --git a/src/corelib/io/qfile.cpp b/src/corelib/io/qfile.cpp index 8d8b579bfc..cecc0b5c4c 100644 --- a/src/corelib/io/qfile.cpp +++ b/src/corelib/io/qfile.cpp @@ -61,6 +61,8 @@ QT_BEGIN_NAMESPACE +using namespace Qt::StringLiterals; + Q_DECL_COLD_FUNCTION static bool file_already_open(QFile &file, const char *where = nullptr) { @@ -616,7 +618,7 @@ QFile::rename(const QString &newName) // report both errors d->setError(QFile::RenameError, tr("Error while renaming: %1").arg(error.toString()) - + QLatin1Char('\n') + + u'\n' + tr("Unable to restore from %1: %2"). arg(QDir::toNativeSeparators(tmp.filePath()), error2.toString())); return false; @@ -789,7 +791,7 @@ QFile::copy(const QString &newName) error = true; d->setError(QFile::CopyError, tr("Cannot open %1 for input").arg(d->fileName)); } else { - const auto fileTemplate = QLatin1String("%1/qt_temp.XXXXXX"); + const auto fileTemplate = "%1/qt_temp.XXXXXX"_L1; #ifdef QT_NO_TEMPORARYFILE QFile out(fileTemplate.arg(QFileInfo(newName).path())); if (!out.open(QIODevice::ReadWrite)) diff --git a/src/corelib/io/qfileinfo.cpp b/src/corelib/io/qfileinfo.cpp index 5e2b5eb4ad..d1587dcb35 100644 --- a/src/corelib/io/qfileinfo.cpp +++ b/src/corelib/io/qfileinfo.cpp @@ -46,6 +46,8 @@ QT_BEGIN_NAMESPACE +using namespace Qt::StringLiterals; + QT_IMPL_METATYPE_EXTERN(QFileInfo) QString QFileInfoPrivate::getFileName(QAbstractFileEngine::FileName name) const @@ -97,7 +99,7 @@ QString QFileInfoPrivate::getFileName(QAbstractFileEngine::FileName name) const ret = fileEngine->fileName(name); } if (ret.isNull()) - ret = QLatin1String(""); + ret = ""_L1; if (cache_enabled) fileNames[(int)name] = ret; return ret; @@ -121,7 +123,7 @@ QString QFileInfoPrivate::getFileOwner(QAbstractFileEngine::FileOwner own) const ret = fileEngine->owner(own); } if (ret.isNull()) - ret = QLatin1String(""); + ret = ""_L1; if (cache_enabled) fileOwners[(int)own] = ret; return ret; @@ -557,7 +559,7 @@ QString QFileInfo::absoluteFilePath() const { Q_D(const QFileInfo); if (d->isDefaultConstructed) - return QLatin1String(""); + return ""_L1; return d->getFileName(QAbstractFileEngine::AbsoluteName); } @@ -574,7 +576,7 @@ QString QFileInfo::canonicalFilePath() const { Q_D(const QFileInfo); if (d->isDefaultConstructed) - return QLatin1String(""); + return ""_L1; return d->getFileName(QAbstractFileEngine::CanonicalName); } @@ -600,9 +602,8 @@ QString QFileInfo::absolutePath() const { Q_D(const QFileInfo); - if (d->isDefaultConstructed) { - return QLatin1String(""); - } + if (d->isDefaultConstructed) + return ""_L1; return d->getFileName(QAbstractFileEngine::AbsolutePathName); } @@ -618,7 +619,7 @@ QString QFileInfo::canonicalPath() const { Q_D(const QFileInfo); if (d->isDefaultConstructed) - return QLatin1String(""); + return ""_L1; return d->getFileName(QAbstractFileEngine::CanonicalPathName); } @@ -635,7 +636,7 @@ QString QFileInfo::path() const { Q_D(const QFileInfo); if (d->isDefaultConstructed) - return QLatin1String(""); + return ""_L1; return d->fileEntry.path(); } @@ -754,7 +755,7 @@ QString QFileInfo::filePath() const { Q_D(const QFileInfo); if (d->isDefaultConstructed) - return QLatin1String(""); + return ""_L1; return d->fileEntry.filePath(); } @@ -773,7 +774,7 @@ QString QFileInfo::fileName() const { Q_D(const QFileInfo); if (d->isDefaultConstructed) - return QLatin1String(""); + return ""_L1; return d->fileEntry.fileName(); } @@ -793,7 +794,7 @@ QString QFileInfo::bundleName() const { Q_D(const QFileInfo); if (d->isDefaultConstructed) - return QLatin1String(""); + return ""_L1; return d->getFileName(QAbstractFileEngine::BundleName); } @@ -817,7 +818,7 @@ QString QFileInfo::baseName() const { Q_D(const QFileInfo); if (d->isDefaultConstructed) - return QLatin1String(""); + return ""_L1; return d->fileEntry.baseName(); } @@ -836,7 +837,7 @@ QString QFileInfo::completeBaseName() const { Q_D(const QFileInfo); if (d->isDefaultConstructed) - return QLatin1String(""); + return ""_L1; return d->fileEntry.completeBaseName(); } @@ -855,7 +856,7 @@ QString QFileInfo::completeSuffix() const { Q_D(const QFileInfo); if (d->isDefaultConstructed) - return QLatin1String(""); + return ""_L1; return d->fileEntry.completeSuffix(); } @@ -878,7 +879,7 @@ QString QFileInfo::suffix() const { Q_D(const QFileInfo); if (d->isDefaultConstructed) - return QLatin1String(""); + return ""_L1; return d->fileEntry.suffix(); } @@ -1250,7 +1251,7 @@ QString QFileInfo::symLinkTarget() const { Q_D(const QFileInfo); if (d->isDefaultConstructed) - return QLatin1String(""); + return ""_L1; return d->getFileName(QAbstractFileEngine::AbsoluteLinkTarget); } @@ -1272,7 +1273,7 @@ QString QFileInfo::junctionTarget() const { Q_D(const QFileInfo); if (d->isDefaultConstructed) - return QLatin1String(""); + return ""_L1; return d->getFileName(QAbstractFileEngine::JunctionName); } @@ -1294,7 +1295,7 @@ QString QFileInfo::owner() const { Q_D(const QFileInfo); if (d->isDefaultConstructed) - return QLatin1String(""); + return ""_L1; return d->getFileOwner(QAbstractFileEngine::OwnerUser); } @@ -1335,7 +1336,7 @@ QString QFileInfo::group() const { Q_D(const QFileInfo); if (d->isDefaultConstructed) - return QLatin1String(""); + return ""_L1; return d->getFileOwner(QAbstractFileEngine::OwnerGroup); } diff --git a/src/corelib/io/qfileselector.cpp b/src/corelib/io/qfileselector.cpp index dd6257a885..77362c2073 100644 --- a/src/corelib/io/qfileselector.cpp +++ b/src/corelib/io/qfileselector.cpp @@ -52,6 +52,8 @@ QT_BEGIN_NAMESPACE +using namespace Qt::StringLiterals; + //Environment variable to allow tooling full control of file selectors static const char env_override[] = "QT_NO_BUILTIN_SELECTORS"; @@ -196,9 +198,9 @@ QString QFileSelector::select(const QString &filePath) const static bool isLocalScheme(const QString &file) { - bool local = file == QLatin1String("qrc"); + bool local = file == "qrc"_L1; #ifdef Q_OS_ANDROID - local |= file == QLatin1String("assets"); + local |= file == "assets"_L1; #endif return local; } @@ -217,11 +219,11 @@ QUrl QFileSelector::select(const QUrl &filePath) const return filePath; QUrl ret(filePath); if (isLocalScheme(filePath.scheme())) { - QLatin1String scheme(":"); + auto scheme = ":"_L1; #ifdef Q_OS_ANDROID // use other scheme because ":" means "qrc" here - if (filePath.scheme() == QLatin1String("assets")) - scheme = QLatin1String("assets:"); + if (filePath.scheme() == "assets"_L1) + scheme = "assets:"_L1; #endif QString equivalentPath = scheme + filePath.path(); @@ -250,13 +252,13 @@ QString QFileSelectorPrivate::selectionHelper(const QString &path, const QString selector ordering in the API, we can stop checking as soon as we find the file in a directory which does not contain any other valid selector directories. */ - Q_ASSERT(path.isEmpty() || path.endsWith(QLatin1Char('/'))); + Q_ASSERT(path.isEmpty() || path.endsWith(u'/')); for (const QString &s : selectors) { QString prospectiveBase = path; if (!indicator.isNull()) prospectiveBase += indicator; - prospectiveBase += s + QLatin1Char('/'); + prospectiveBase += s + u'/'; QStringList remainingSelectors = selectors; remainingSelectors.removeAll(s); if (!QDir(prospectiveBase).exists()) @@ -356,7 +358,7 @@ QStringList QFileSelectorPrivate::platformSelectors() ret << QSysInfo::kernelType(); # endif QString productName = QSysInfo::productType(); - if (productName != QLatin1String("unknown")) + if (productName != "unknown"_L1) ret << productName; // "opensuse", "fedora", "osx", "ios", "android" #endif return ret; diff --git a/src/corelib/io/qfilesystemengine.cpp b/src/corelib/io/qfilesystemengine.cpp index f00aba78c3..0b127cfbea 100644 --- a/src/corelib/io/qfilesystemengine.cpp +++ b/src/corelib/io/qfilesystemengine.cpp @@ -61,7 +61,7 @@ QString QFileSystemEngine::slowCanonicalized(const QString &path) return path; QFileInfo fi; - const QChar slash(QLatin1Char('/')); + const QChar slash(u'/'); QString tmpPath = path; int separatorPos = 0; QSet<QString> nonSymlinks; @@ -74,7 +74,7 @@ QString QFileSystemEngine::slowCanonicalized(const QString &path) if (tmpPath.size() >= 2 && tmpPath.at(0) == slash && tmpPath.at(1) == slash) { // UNC, skip past the first two elements separatorPos = tmpPath.indexOf(slash, 2); - } else if (tmpPath.size() >= 3 && tmpPath.at(1) == QLatin1Char(':') && tmpPath.at(2) == slash) { + } else if (tmpPath.size() >= 3 && tmpPath.at(1) == u':' && tmpPath.at(2) == slash) { // volume root, skip since it can not be a symlink separatorPos = 2; } @@ -142,10 +142,10 @@ static bool _q_resolveEntryAndCreateLegacyEngine_recursive(QFileSystemEntry &ent #if defined(QT_BUILD_CORE_LIB) for (int prefixSeparator = 0; prefixSeparator < filePath.size(); ++prefixSeparator) { QChar const ch = filePath[prefixSeparator]; - if (ch == QLatin1Char('/')) + if (ch == u'/') break; - if (ch == QLatin1Char(':')) { + if (ch == u':') { if (prefixSeparator == 0) { engine = new QResourceFileEngine(filePath); return _q_checkEntry(engine, resolvingEntry); @@ -156,7 +156,8 @@ static bool _q_resolveEntryAndCreateLegacyEngine_recursive(QFileSystemEntry &ent const QStringList &paths = QDir::searchPaths(filePath.left(prefixSeparator)); for (int i = 0; i < paths.count(); i++) { - entry = QFileSystemEntry(QDir::cleanPath(paths.at(i) % QLatin1Char('/') % QStringView{filePath}.mid(prefixSeparator + 1))); + entry = QFileSystemEntry(QDir::cleanPath( + paths.at(i) % u'/' % QStringView{filePath}.mid(prefixSeparator + 1))); // Recurse! if (_q_resolveEntryAndCreateLegacyEngine_recursive(entry, data, engine, true)) return true; diff --git a/src/corelib/io/qfilesystemengine_unix.cpp b/src/corelib/io/qfilesystemengine_unix.cpp index ea903fa990..9b34ab6596 100644 --- a/src/corelib/io/qfilesystemengine_unix.cpp +++ b/src/corelib/io/qfilesystemengine_unix.cpp @@ -113,6 +113,8 @@ struct statx { mode_t stx_mode; }; // dummy QT_BEGIN_NAMESPACE +using namespace Qt::StringLiterals; + enum { #ifdef Q_OS_ANDROID // On Android, the link(2) system call has been observed to always fail @@ -180,7 +182,7 @@ static bool isPackage(const QFileSystemMetaData &data, const QFileSystemEntry &e QCFType<CFBundleRef> bundle = CFBundleCreate(kCFAllocatorDefault, application); CFStringRef identifier = CFBundleGetIdentifier(bundle); QString applicationId = QString::fromCFString(identifier); - if (applicationId != QLatin1String("com.apple.finder")) + if (applicationId != "com.apple.finder"_L1) return true; } #endif @@ -633,15 +635,15 @@ QFileSystemEntry QFileSystemEngine::getLinkTarget(const QFileSystemEntry &link, QDir parent(link.filePath()); parent.cdUp(); ret = parent.path(); - if (!ret.isEmpty() && !ret.endsWith(QLatin1Char('/'))) - ret += QLatin1Char('/'); + if (!ret.isEmpty() && !ret.endsWith(u'/')) + ret += u'/'; } ret += QFile::decodeName(s); - if (!ret.startsWith(QLatin1Char('/'))) - ret.prepend(absoluteName(link).path() + QLatin1Char('/')); + if (!ret.startsWith(u'/')) + ret.prepend(absoluteName(link).path() + u'/'); ret = QDir::cleanPath(ret); - if (ret.size() > 1 && ret.endsWith(QLatin1Char('/'))) + if (ret.size() > 1 && ret.endsWith(u'/')) ret.chop(1); return QFileSystemEntry(ret); } @@ -764,7 +766,7 @@ QFileSystemEntry QFileSystemEngine::absoluteName(const QFileSystemEntry &entry) QFileSystemEntry resultingEntry(result, QFileSystemEntry::FromNativePath()); QString stringVersion = QDir::cleanPath(resultingEntry.filePath()); if (isDir) - stringVersion.append(QLatin1Char('/')); + stringVersion.append(u'/'); return QFileSystemEntry(stringVersion); } @@ -1047,7 +1049,7 @@ bool QFileSystemEngine::fillMetaData(const QFileSystemEntry &entry, QFileSystemM if (what & QFileSystemMetaData::HiddenAttribute && !data.isHidden()) { QString fileName = entry.fileName(); - if ((fileName.size() > 0 && fileName.at(0) == QLatin1Char('.')) + if (fileName.startsWith(u'.') #if defined(Q_OS_DARWIN) || (entryErrno == 0 && hasResourcePropertyFlag(data, entry, kCFURLIsHiddenKey)) #endif @@ -1165,7 +1167,7 @@ bool QFileSystemEngine::createDirectory(const QFileSystemEntry &entry, bool crea Q_CHECK_FILE_NAME(dirName, false); // Darwin doesn't support trailing /'s, so remove for everyone - while (dirName.size() > 1 && dirName.endsWith(QLatin1Char('/'))) + while (dirName.size() > 1 && dirName.endsWith(u'/')) dirName.chop(1); // try to mkdir this directory @@ -1250,7 +1252,7 @@ static QString freeDesktopTrashLocation(const QString &sourcePath) const QStorageInfo homeStorage(QDir::home()); // We support trashing of files outside the users home partition if (sourceStorage != homeStorage) { - const QLatin1String dotTrash(".Trash"); + const auto dotTrash = ".Trash"_L1; QDir topDir(sourceStorage.rootPath()); /* Method 1: @@ -1298,7 +1300,7 @@ static QString freeDesktopTrashLocation(const QString &sourcePath) */ if (trash.isEmpty()) { topDir = QDir(sourceStorage.rootPath()); - const QString userTrashDir = dotTrash + QLatin1Char('-') + userID; + const QString userTrashDir = dotTrash + u'-' + userID; trash = makeTrashDir(topDir, userTrashDir); } } @@ -1314,7 +1316,7 @@ static QString freeDesktopTrashLocation(const QString &sourcePath) */ if (trash.isEmpty()) { QDir topDir = QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation); - trash = makeTrashDir(topDir, QLatin1String("Trash")); + trash = makeTrashDir(topDir, "Trash"_L1); if (!QFileInfo(trash).isDir()) { qWarning("Unable to establish trash directory in %s", topDir.path().toLocal8Bit().constData()); @@ -1348,8 +1350,8 @@ bool QFileSystemEngine::moveFileToTrash(const QFileSystemEntry &source, /* "A trash directory contains two subdirectories, named info and files." */ - const QLatin1String filesDir("files"); - const QLatin1String infoDir("info"); + const auto filesDir = "files"_L1; + const auto infoDir = "info"_L1; trashDir.mkdir(filesDir); int savedErrno = errno; trashDir.mkdir(infoDir); @@ -1369,7 +1371,7 @@ bool QFileSystemEngine::moveFileToTrash(const QFileSystemEntry &source, const QString trashedName = sourceInfo.isDir() ? QDir(sourcePath).dirName() : sourceInfo.fileName(); - QString uniqueTrashedName = QLatin1Char('/') + trashedName; + QString uniqueTrashedName = u'/' + trashedName; QString infoFileName; int counter = 0; QFile infoFile; @@ -1392,7 +1394,7 @@ bool QFileSystemEngine::moveFileToTrash(const QFileSystemEntry &source, (at least on the same machine), if it fails you need to pick another filename." */ infoFileName = trashDir.filePath(infoDir) - + uniqueTrashedName + QLatin1String(".trashinfo"); + + uniqueTrashedName + ".trashinfo"_L1; infoFile.setFileName(infoFileName); if (!infoFile.open(QIODevice::NewOnly | QIODevice::WriteOnly | QIODevice::Text)) uniqueTrashedName = makeUniqueTrashedName(); @@ -1415,7 +1417,7 @@ bool QFileSystemEngine::moveFileToTrash(const QFileSystemEntry &source, QByteArray info = "[Trash Info]\n" "Path=" + sourcePath.toUtf8() + "\n" - "DeletionDate=" + QDateTime::currentDateTime().toString(QLatin1String("yyyy-MM-ddThh:mm:ss")).toUtf8() + "DeletionDate=" + QDateTime::currentDateTime().toString("yyyy-MM-ddThh:mm:ss"_L1).toUtf8() + "\n"; infoFile.write(info); infoFile.close(); @@ -1646,7 +1648,7 @@ QString QFileSystemEngine::homePath() QString QFileSystemEngine::rootPath() { - return QLatin1String("/"); + return u"/"_qs; } QString QFileSystemEngine::tempPath() diff --git a/src/corelib/io/qfilesystemengine_win.cpp b/src/corelib/io/qfilesystemengine_win.cpp index 3da6c06a8d..5d3681e58a 100644 --- a/src/corelib/io/qfilesystemengine_win.cpp +++ b/src/corelib/io/qfilesystemengine_win.cpp @@ -72,6 +72,8 @@ #define SECURITY_WIN32 #include <security.h> +using namespace Qt::StringLiterals; + #ifndef SPI_GETPLATFORMTYPE #define SPI_GETPLATFORMTYPE 257 #endif @@ -684,14 +686,14 @@ static QString readSymLink(const QFileSystemEntry &link) #if QT_CONFIG(fslibs) && QT_CONFIG(regularexpression) initGlobalSid(); - QRegularExpression matchVolumeRe(QLatin1String("^Volume\\{([a-z]|[0-9]|-)+\\}\\\\"), + QRegularExpression matchVolumeRe("^Volume\\{([a-z]|[0-9]|-)+\\}\\\\"_L1, QRegularExpression::CaseInsensitiveOption); auto matchVolume = matchVolumeRe.match(result); if (matchVolume.hasMatch()) { Q_ASSERT(matchVolume.capturedStart() == 0); DWORD len; wchar_t buffer[MAX_PATH]; - const QString volumeName = QLatin1String("\\\\?\\") + matchVolume.captured(); + const QString volumeName = "\\\\?\\"_L1 + matchVolume.captured(); if (GetVolumePathNamesForVolumeName(reinterpret_cast<LPCWSTR>(volumeName.utf16()), buffer, MAX_PATH, &len) != 0) { @@ -751,10 +753,10 @@ static QString readLink(const QFileSystemEntry &link) static bool uncShareExists(const QString &server) { // This code assumes the UNC path is always like \\?\UNC\server... - const auto parts = QStringView{server}.split(QLatin1Char('\\'), Qt::SkipEmptyParts); + const auto parts = QStringView{server}.split(u'\\', Qt::SkipEmptyParts); if (parts.count() >= 3) { QStringList shares; - if (QFileSystemEngine::uncListSharesOnServer(QLatin1String("\\\\") + parts.at(2), &shares)) + if (QFileSystemEngine::uncListSharesOnServer("\\\\"_L1 + parts.at(2), &shares)) return parts.count() < 4 || shares.contains(parts.at(3).toString(), Qt::CaseInsensitive); } @@ -764,11 +766,11 @@ static bool uncShareExists(const QString &server) static inline bool getFindData(QString path, WIN32_FIND_DATA &findData) { // path should not end with a trailing slash - while (path.endsWith(QLatin1Char('\\'))) + while (path.endsWith(u'\\')) path.chop(1); // can't handle drives - if (!path.endsWith(QLatin1Char(':'))) { + if (!path.endsWith(u':')) { HANDLE hFind = ::FindFirstFile((wchar_t*)path.utf16(), &findData); if (hFind != INVALID_HANDLE_VALUE) { ::FindClose(hFind); @@ -913,7 +915,7 @@ QFileSystemEntry QFileSystemEngine::getLinkTarget(const QFileSystemEntry &link, target = readSymLink(link); QFileSystemEntry ret(target); if (!target.isEmpty() && ret.isRelative()) { - target.prepend(absoluteName(link).path() + QLatin1Char('/')); + target.prepend(absoluteName(link).path() + u'/'); ret = QFileSystemEntry(QDir::cleanPath(target)); } return ret; @@ -933,7 +935,7 @@ QFileSystemEntry QFileSystemEngine::junctionTarget(const QFileSystemEntry &link, target = readSymLink(link); QFileSystemEntry ret(target); if (!target.isEmpty() && ret.isRelative()) { - target.prepend(absoluteName(link).path() + QLatin1Char('/')); + target.prepend(absoluteName(link).path() + u'/'); ret = QFileSystemEntry(QDir::cleanPath(target)); } return ret; @@ -976,8 +978,8 @@ QString QFileSystemEngine::nativeAbsoluteFilePath(const QString &path) // (which is an invalid filename) this function will strip the space off and viola, // the file is later reported as existing. Therefore, we re-add the whitespace that // was at the end of path in order to keep the filename invalid. - if (!path.isEmpty() && path.at(path.size() - 1) == QLatin1Char(' ')) - absPath.append(QLatin1Char(' ')); + if (!path.isEmpty() && path.at(path.size() - 1) == u' ') + absPath.append(u' '); return absPath; } @@ -994,17 +996,17 @@ QFileSystemEntry QFileSystemEngine::absoluteName(const QFileSystemEntry &entry) else ret = QDir::fromNativeSeparators(nativeAbsoluteFilePath(entry.filePath())); } else { - ret = QDir::cleanPath(QDir::currentPath() + QLatin1Char('/') + entry.filePath()); + ret = QDir::cleanPath(QDir::currentPath() + u'/' + entry.filePath()); } // The path should be absolute at this point. // From the docs : // Absolute paths begin with the directory separator "/" // (optionally preceded by a drive specification under Windows). - if (ret.at(0) != QLatin1Char('/')) { + if (ret.at(0) != u'/') { Q_ASSERT(ret.length() >= 2); Q_ASSERT(ret.at(0).isLetter()); - Q_ASSERT(ret.at(1) == QLatin1Char(':')); + Q_ASSERT(ret.at(1) == u':'); // Force uppercase drive letters. ret[0] = ret.at(0).toUpper(); @@ -1264,9 +1266,8 @@ bool QFileSystemEngine::fillPermissions(const QFileSystemEntry &entry, QFileSyst QString fname = entry.filePath(); QString ext = fname.right(4).toLower(); - if (data.isDirectory() || ext == QLatin1String(".exe") || ext == QLatin1String(".com") - || ext == QLatin1String(".bat") || ext == QLatin1String(".pif") - || ext == QLatin1String(".cmd")) { + if (data.isDirectory() || ext == ".exe"_L1 || ext == ".com"_L1 + || ext == ".bat"_L1 || ext == ".pif"_L1 || ext == ".cmd"_L1) { data.entryFlags |= QFileSystemMetaData::OwnerExecutePermission | QFileSystemMetaData::GroupExecutePermission | QFileSystemMetaData::OtherExecutePermission @@ -1301,7 +1302,7 @@ static bool tryDriveUNCFallback(const QFileSystemEntry &fname, QFileSystemMetaDa DWORD drivesBitmask = ::GetLogicalDrives(); ::SetErrorMode(oldErrorMode); int drivebit = - 1 << (fname.filePath().at(0).toUpper().unicode() - QLatin1Char('A').unicode()); + 1 << (fname.filePath().at(0).toUpper().unicode() - u'A'); if (drivesBitmask & drivebit) { fileAttrib = FILE_ATTRIBUTE_DIRECTORY | FILE_ATTRIBUTE_SYSTEM; entryExists = true; @@ -1309,7 +1310,7 @@ static bool tryDriveUNCFallback(const QFileSystemEntry &fname, QFileSystemMetaDa } else { const QString &path = fname.nativeFilePath(); bool is_dir = false; - if (path.startsWith(QLatin1String("\\\\?\\UNC"))) { + if (path.startsWith("\\\\?\\UNC"_L1)) { // UNC - stat doesn't work for all cases (Windows bug) int s = path.indexOf(path.at(0),7); if (s > 0) { @@ -1398,7 +1399,7 @@ bool QFileSystemEngine::fillMetaData(const QFileSystemEntry &entry, QFileSystemM // Check for ".lnk": Directories named ".lnk" should be skipped, corrupted // link files should still be detected as links. const QString origFilePath = entry.filePath(); - if (origFilePath.endsWith(QLatin1String(".lnk")) && !isDirPath(origFilePath, nullptr)) { + if (origFilePath.endsWith(".lnk"_L1) && !isDirPath(origFilePath, nullptr)) { data.entryFlags |= QFileSystemMetaData::WinLnkType; fname = QFileSystemEntry(readLink(entry)); } else { @@ -1471,8 +1472,8 @@ static inline bool rmDir(const QString &path) bool QFileSystemEngine::isDirPath(const QString &dirPath, bool *existed) { QString path = dirPath; - if (path.length() == 2 && path.at(1) == QLatin1Char(':')) - path += QLatin1Char('\\'); + if (path.length() == 2 && path.at(1) == u':') + path += u'\\'; const QString longPath = QFSFileEnginePrivate::longFileName(path); DWORD fileAttrib = ::GetFileAttributes(reinterpret_cast<const wchar_t*>(longPath.utf16())); @@ -1501,11 +1502,11 @@ static bool createDirectoryWithParents(const QString &nativeName, bool shouldMkdirFirst = true) { const auto isUNCRoot = [](const QString &nativeName) { - return nativeName.startsWith(QLatin1String("\\\\")) + return nativeName.startsWith("\\\\"_L1) && nativeName.count(QDir::separator()) <= 3; }; const auto isDriveName = [](const QString &nativeName) { - return nativeName.size() == 2 && nativeName.at(1) == QLatin1Char(':'); + return nativeName.size() == 2 && nativeName.at(1) == u':'; }; const auto isDir = [](const QString &nativeName) { bool exists = false; @@ -1573,7 +1574,7 @@ bool QFileSystemEngine::removeDirectory(const QFileSystemEntry &entry, bool remo for (int oldslash = 0, slash=dirName.length(); slash > 0; oldslash = slash) { const auto chunkRef = QStringView{dirName}.left(slash); if (chunkRef.length() == 2 && chunkRef.at(0).isLetter() - && chunkRef.at(1) == QLatin1Char(':')) { + && chunkRef.at(1) == u':') { break; } const QString chunk = chunkRef.toString(); @@ -1593,8 +1594,8 @@ QString QFileSystemEngine::rootPath() { QString ret = QString::fromLatin1(qgetenv("SystemDrive")); if (ret.isEmpty()) - ret = QLatin1String("c:"); - ret.append(QLatin1Char('/')); + ret = "c:"_L1; + ret.append(u'/'); return ret; } @@ -1652,13 +1653,13 @@ QString QFileSystemEngine::tempPath() QString::fromWCharArray(tempPath, len); } if (!ret.isEmpty()) { - while (ret.endsWith(QLatin1Char('\\'))) + while (ret.endsWith(u'\\')) ret.chop(1); ret = QDir::fromNativeSeparators(ret); } if (ret.isEmpty()) { - ret = QLatin1String("C:/tmp"); - } else if (ret.length() >= 2 && ret[1] == QLatin1Char(':')) + ret = "C:/tmp"_L1; + } else if (ret.length() >= 2 && ret[1] == u':') ret[0] = ret.at(0).toUpper(); // Force uppercase drive letters. return ret; } @@ -1695,7 +1696,7 @@ QFileSystemEntry QFileSystemEngine::currentPath() ret = QString::fromWCharArray(currentName, size); } } - if (ret.length() >= 2 && ret[1] == QLatin1Char(':')) + if (ret.length() >= 2 && ret[1] == u':') ret[0] = ret.at(0).toUpper(); // Force uppercase drive letters. return QFileSystemEntry(ret, QFileSystemEntry::FromNativePath()); } diff --git a/src/corelib/io/qfilesystementry.cpp b/src/corelib/io/qfilesystementry.cpp index bb39a46642..0c2458c862 100644 --- a/src/corelib/io/qfilesystementry.cpp +++ b/src/corelib/io/qfilesystementry.cpp @@ -48,14 +48,16 @@ QT_BEGIN_NAMESPACE +using namespace Qt::StringLiterals; + #ifdef Q_OS_WIN static bool isUncRoot(const QString &server) { QString localPath = QDir::toNativeSeparators(server); - if (!localPath.startsWith(QLatin1String("\\\\"))) + if (!localPath.startsWith("\\\\"_L1)) return false; - int idx = localPath.indexOf(QLatin1Char('\\'), 2); + int idx = localPath.indexOf(u'\\', 2); if (idx == -1 || idx + 1 == localPath.length()) return true; @@ -65,8 +67,8 @@ static bool isUncRoot(const QString &server) static inline QString fixIfRelativeUncPath(const QString &path) { QString currentPath = QDir::currentPath(); - if (currentPath.startsWith(QLatin1String("//"))) - return currentPath % QChar(QLatin1Char('/')) % path; + if (currentPath.startsWith("//"_L1)) + return currentPath % QChar(u'/') % path; return path; } #endif @@ -166,7 +168,7 @@ QString QFileSystemEntry::fileName() const { findLastSeparator(); #if defined(Q_OS_WIN) - if (m_lastSeparator == -1 && m_filePath.length() >= 2 && m_filePath.at(1) == QLatin1Char(':')) + if (m_lastSeparator == -1 && m_filePath.length() >= 2 && m_filePath.at(1) == u':') return m_filePath.mid(2); #endif return m_filePath.mid(m_lastSeparator + 1); @@ -177,15 +179,15 @@ QString QFileSystemEntry::path() const findLastSeparator(); if (m_lastSeparator == -1) { #if defined(Q_OS_WIN) - if (m_filePath.length() >= 2 && m_filePath.at(1) == QLatin1Char(':')) + if (m_filePath.length() >= 2 && m_filePath.at(1) == u':') return m_filePath.left(2); #endif - return QString(QLatin1Char('.')); + return QString(u'.'); } if (m_lastSeparator == 0) - return QString(QLatin1Char('/')); + return QString(u'/'); #if defined(Q_OS_WIN) - if (m_lastSeparator == 2 && m_filePath.at(1) == QLatin1Char(':')) + if (m_lastSeparator == 2 && m_filePath.at(1) == u':') return m_filePath.left(m_lastSeparator + 1); #endif return m_filePath.left(m_lastSeparator); @@ -201,7 +203,7 @@ QString QFileSystemEntry::baseName() const length--; } #if defined(Q_OS_WIN) - if (m_lastSeparator == -1 && m_filePath.length() >= 2 && m_filePath.at(1) == QLatin1Char(':')) + if (m_lastSeparator == -1 && m_filePath.length() >= 2 && m_filePath.at(1) == u':') return m_filePath.mid(2, length - 2); #endif return m_filePath.mid(m_lastSeparator + 1, length); @@ -217,7 +219,7 @@ QString QFileSystemEntry::completeBaseName() const length--; } #if defined(Q_OS_WIN) - if (m_lastSeparator == -1 && m_filePath.length() >= 2 && m_filePath.at(1) == QLatin1Char(':')) + if (m_lastSeparator == -1 && m_filePath.length() >= 2 && m_filePath.at(1) == u':') return m_filePath.mid(2, length - 2); #endif return m_filePath.mid(m_lastSeparator + 1, length); @@ -259,8 +261,8 @@ bool QFileSystemEntry::isAbsolute() const && m_filePath.at(1).unicode() == ':' && m_filePath.at(2).unicode() == '/') || (m_filePath.length() >= 2 - && m_filePath.at(0) == QLatin1Char('/') - && m_filePath.at(1) == QLatin1Char('/'))); + && m_filePath.at(0) == u'/' + && m_filePath.at(1) == u'/')); } #else bool QFileSystemEntry::isRelative() const @@ -285,8 +287,8 @@ bool QFileSystemEntry::isDriveRoot() const bool QFileSystemEntry::isDriveRootPath(const QString &path) { return (path.length() == 3 - && path.at(0).isLetter() && path.at(1) == QLatin1Char(':') - && path.at(2) == QLatin1Char('/')); + && path.at(0).isLetter() && path.at(1) == u':' + && path.at(2) == u'/'); } QString QFileSystemEntry::removeUncOrLongPathPrefix(QString path) @@ -320,7 +322,7 @@ QString QFileSystemEntry::removeUncOrLongPathPrefix(QString path) bool QFileSystemEntry::isRootPath(const QString &path) { - if (path == QLatin1String("/") + if (path == "/"_L1 #if defined(Q_OS_WIN) || isDriveRootPath(path) || isUncRoot(path) @@ -343,7 +345,7 @@ void QFileSystemEntry::findLastSeparator() const { if (m_lastSeparator == -2) { resolveFilePath(); - m_lastSeparator = m_filePath.lastIndexOf(QLatin1Char('/')); + m_lastSeparator = m_filePath.lastIndexOf(u'/'); } } @@ -402,7 +404,7 @@ bool QFileSystemEntry::isClean() const bool dotok = true; // checking for ".." or "." starts to relative paths bool slashok = true; for (QString::const_iterator iter = m_filePath.constBegin(); iter != m_filePath.constEnd(); ++iter) { - if (*iter == QLatin1Char('/')) { + if (*iter == u'/') { if (dots == 1 || dots == 2) return false; // path contains "./" or "../" if (!slashok) @@ -412,7 +414,7 @@ bool QFileSystemEntry::isClean() const slashok = false; } else if (dotok) { slashok = true; - if (*iter == QLatin1Char('.')) { + if (*iter == u'.') { dots++; if (dots > 2) dotok = false; diff --git a/src/corelib/io/qfilesystemiterator_win.cpp b/src/corelib/io/qfilesystemiterator_win.cpp index ac52dacdce..91cfef644c 100644 --- a/src/corelib/io/qfilesystemiterator_win.cpp +++ b/src/corelib/io/qfilesystemiterator_win.cpp @@ -46,6 +46,8 @@ QT_BEGIN_NAMESPACE +using namespace Qt::StringLiterals; + bool done = true; QFileSystemIterator::QFileSystemIterator(const QFileSystemEntry &entry, QDir::Filters filters, @@ -64,12 +66,12 @@ QFileSystemIterator::QFileSystemIterator(const QFileSystemEntry &entry, QDir::Fi QFileSystemEntry link = QFileSystemEngine::getLinkTarget(entry, metaData); nativePath = link.nativeFilePath(); } - if (!nativePath.endsWith(QLatin1Char('\\'))) - nativePath.append(QLatin1Char('\\')); - nativePath.append(QLatin1Char('*')); + if (!nativePath.endsWith(u'\\')) + nativePath.append(u'\\'); + nativePath.append(u'*'); // In MSVC2015+ case we prepend //?/ for longer file-name support - if (!dirPath.endsWith(QLatin1Char('/'))) - dirPath.append(QLatin1Char('/')); + if (!dirPath.endsWith(u'/')) + dirPath.append(u'/'); if ((filters & (QDir::Dirs|QDir::Drives)) && (!(filters & (QDir::Files)))) onlyDirs = true; } @@ -97,10 +99,10 @@ bool QFileSystemIterator::advance(QFileSystemEntry &fileEntry, QFileSystemMetaDa findFileHandle = FindFirstFileEx((const wchar_t *)nativePath.utf16(), FINDEX_INFO_LEVELS(infoLevel), &findData, FINDEX_SEARCH_OPS(searchOps), 0, dwAdditionalFlags); if (findFileHandle == INVALID_HANDLE_VALUE) { - if (nativePath.startsWith(QLatin1String("\\\\?\\UNC\\"))) { - const auto parts = QStringView{nativePath}.split(QLatin1Char('\\'), Qt::SkipEmptyParts); + if (nativePath.startsWith("\\\\?\\UNC\\"_L1)) { + const auto parts = QStringView{nativePath}.split(u'\\', Qt::SkipEmptyParts); if (parts.count() == 4 && QFileSystemEngine::uncListSharesOnServer( - QLatin1String("\\\\") + parts.at(2), &uncShares)) { + "\\\\"_L1 + parts.at(2), &uncShares)) { if (uncShares.isEmpty()) return false; // No shares found in the server uncFallback = true; @@ -129,7 +131,7 @@ bool QFileSystemIterator::advance(QFileSystemEntry &fileEntry, QFileSystemMetaDa QString fileName = QString::fromWCharArray(findData.cFileName); fileEntry = QFileSystemEntry(dirPath + fileName); metaData = QFileSystemMetaData(); - if (!fileName.endsWith(QLatin1String(".lnk"))) { + if (!fileName.endsWith(".lnk"_L1)) { metaData.fillFromFindData(findData, true); } return true; diff --git a/src/corelib/io/qfilesystemwatcher.cpp b/src/corelib/io/qfilesystemwatcher.cpp index bd5a73da84..4fceb5c1ca 100644 --- a/src/corelib/io/qfilesystemwatcher.cpp +++ b/src/corelib/io/qfilesystemwatcher.cpp @@ -67,6 +67,8 @@ QT_BEGIN_NAMESPACE +using namespace Qt::StringLiterals; + Q_LOGGING_CATEGORY(lcWatcher, "qt.core.filesystemwatcher") QFileSystemWatcherEngine *QFileSystemWatcherPrivate::createNativeEngine(QObject *parent) @@ -364,14 +366,14 @@ QStringList QFileSystemWatcher::addPaths(const QStringList &paths) #ifdef QT_BUILD_INTERNAL const QString on = objectName(); - if (Q_UNLIKELY(on.startsWith(QLatin1String("_qt_autotest_force_engine_")))) { + if (Q_UNLIKELY(on.startsWith("_qt_autotest_force_engine_"_L1))) { // Autotest override case - use the explicitly selected engine only const auto forceName = QStringView{on}.mid(26); - if (forceName == QLatin1String("poller")) { + if (forceName == "poller"_L1) { qCDebug(lcWatcher, "QFileSystemWatcher: skipping native engine, using only polling engine"); d_func()->initPollerEngine(); return d->poller; - } else if (forceName == QLatin1String("native")) { + } else if (forceName == "native"_L1) { qCDebug(lcWatcher, "QFileSystemWatcher: skipping polling engine, using only native engine"); return d->native; } diff --git a/src/corelib/io/qfilesystemwatcher_polling.cpp b/src/corelib/io/qfilesystemwatcher_polling.cpp index 6920eab258..330df998b5 100644 --- a/src/corelib/io/qfilesystemwatcher_polling.cpp +++ b/src/corelib/io/qfilesystemwatcher_polling.cpp @@ -64,8 +64,8 @@ QStringList QPollingFileSystemWatcherEngine::addPaths(const QStringList &paths, if (directories->contains(path)) continue; directories->append(path); - if (!path.endsWith(QLatin1Char('/'))) - fi = QFileInfo(path + QLatin1Char('/')); + if (!path.endsWith(u'/')) + fi = QFileInfo(path + u'/'); this->directories.insert(path, fi); } else { if (files->contains(path)) @@ -127,8 +127,8 @@ void QPollingFileSystemWatcherEngine::timeout() for (auto it = directories.begin(), end = directories.end(); it != end; /*erasing*/) { QString path = it.key(); QFileInfo fi(path); - if (!path.endsWith(QLatin1Char('/'))) - fi = QFileInfo(path + QLatin1Char('/')); + if (!path.endsWith(u'/')) + fi = QFileInfo(path + u'/'); if (!fi.exists()) { it = directories.erase(it); emit directoryChanged(path, true); diff --git a/src/corelib/io/qfilesystemwatcher_win.cpp b/src/corelib/io/qfilesystemwatcher_win.cpp index 5d8a5b3682..a836c56473 100644 --- a/src/corelib/io/qfilesystemwatcher_win.cpp +++ b/src/corelib/io/qfilesystemwatcher_win.cpp @@ -63,6 +63,8 @@ QT_BEGIN_NAMESPACE +using namespace Qt::StringLiterals; + // #define WINQFSW_DEBUG #ifdef WINQFSW_DEBUG # define DEBUG qDebug @@ -75,8 +77,8 @@ static Qt::HANDLE createChangeNotification(const QString &path, uint flags) // Volume and folder paths need a trailing slash for proper notification // (e.g. "c:" -> "c:/"). QString nativePath = QDir::toNativeSeparators(path); - if ((flags & FILE_NOTIFY_CHANGE_ATTRIBUTES) == 0 && !nativePath.endsWith(QLatin1Char('\\'))) - nativePath.append(QLatin1Char('\\')); + if ((flags & FILE_NOTIFY_CHANGE_ATTRIBUTES) == 0 && !nativePath.endsWith(u'\\')) + nativePath.append(u'\\'); const HANDLE result = FindFirstChangeNotification(reinterpret_cast<const wchar_t *>(nativePath.utf16()), FALSE, flags); DEBUG() << __FUNCTION__ << nativePath << Qt::hex << Qt::showbase << flags << "returns" << result; @@ -274,7 +276,7 @@ bool QWindowsRemovableDriveListener::nativeEventFilter(const QByteArray &, void // Set up listening for WM_DEVICECHANGE+DBT_CUSTOMEVENT for a removable drive path, void QWindowsRemovableDriveListener::addPath(const QString &p) { - const wchar_t drive = p.size() >= 2 && p.at(0).isLetter() && p.at(1) == QLatin1Char(':') + const wchar_t drive = p.size() >= 2 && p.at(0).isLetter() && p.at(1) == u':' ? wchar_t(p.at(0).toUpper().unicode()) : L'\0'; if (!drive) return; @@ -367,8 +369,8 @@ QStringList QWindowsFileSystemWatcherEngine::addPaths(const QStringList &paths, for (const QString &path : paths) { auto sg = qScopeGuard([&] { unhandled.push_back(path); }); QString normalPath = path; - if ((normalPath.endsWith(QLatin1Char('/')) && !normalPath.endsWith(QLatin1String(":/"))) - || (normalPath.endsWith(QLatin1Char('\\')) && !normalPath.endsWith(QLatin1String(":\\")))) { + if ((normalPath.endsWith(u'/') && !normalPath.endsWith(":/"_L1)) + || (normalPath.endsWith(u'\\') && !normalPath.endsWith(":\\"_L1))) { normalPath.chop(1); } QFileInfo fileInfo(normalPath); @@ -530,7 +532,7 @@ QStringList QWindowsFileSystemWatcherEngine::removePaths(const QStringList &path for (const QString &path : paths) { auto sg = qScopeGuard([&] { unhandled.push_back(path); }); QString normalPath = path; - if (normalPath.endsWith(QLatin1Char('/')) || normalPath.endsWith(QLatin1Char('\\'))) + if (normalPath.endsWith(u'/') || normalPath.endsWith(u'\\')) normalPath.chop(1); QFileInfo fileInfo(normalPath); DEBUG() << "removing" << normalPath; @@ -631,10 +633,10 @@ Q_DECL_COLD_FUNCTION static QString msgFindNextFailed(const QWindowsFileSystemWatcherEngineThread::PathInfoHash &pathInfos) { QString str; - str += QLatin1String("QFileSystemWatcher: FindNextChangeNotification failed for"); + str += "QFileSystemWatcher: FindNextChangeNotification failed for"_L1; for (const QWindowsFileSystemWatcherEngine::PathInfo &pathInfo : pathInfos) - str += QLatin1String(" \"") + QDir::toNativeSeparators(pathInfo.absolutePath) + QLatin1Char('"'); - str += QLatin1Char(' '); + str += " \""_L1 + QDir::toNativeSeparators(pathInfo.absolutePath) + u'"'; + str += u' '; return str; } diff --git a/src/corelib/io/qfsfileengine.cpp b/src/corelib/io/qfsfileengine.cpp index 4ba35abacb..a28cc823d5 100644 --- a/src/corelib/io/qfsfileengine.cpp +++ b/src/corelib/io/qfsfileengine.cpp @@ -60,6 +60,8 @@ QT_BEGIN_NAMESPACE +using namespace Qt::StringLiterals; + #ifdef Q_OS_WIN # ifndef S_ISREG # define S_ISREG(x) (((x) & S_IFMT) == S_IFREG) @@ -173,14 +175,14 @@ ProcessOpenModeResult processOpenModeFlags(QIODevice::OpenMode openMode) result.ok = false; if ((openMode & QFile::NewOnly) && (openMode & QFile::ExistingOnly)) { qWarning("NewOnly and ExistingOnly are mutually exclusive"); - result.error = QLatin1String("NewOnly and ExistingOnly are mutually exclusive"); + result.error = "NewOnly and ExistingOnly are mutually exclusive"_L1; return result; } if ((openMode & QFile::ExistingOnly) && !(openMode & (QFile::ReadOnly | QFile::WriteOnly))) { qWarning("ExistingOnly must be specified alongside ReadOnly, WriteOnly, or ReadWrite"); - result.error = QLatin1String( - "ExistingOnly must be specified alongside ReadOnly, WriteOnly, or ReadWrite"); + result.error = + "ExistingOnly must be specified alongside ReadOnly, WriteOnly, or ReadWrite"_L1; return result; } @@ -235,7 +237,7 @@ bool QFSFileEngine::open(QIODevice::OpenMode openMode, Q_D(QFSFileEngine); if (d->fileEntry.isEmpty()) { qWarning("QFSFileEngine::open: No file name specified"); - setError(QFile::OpenError, QLatin1String("No file name specified")); + setError(QFile::OpenError, "No file name specified"_L1); return false; } diff --git a/src/corelib/io/qfsfileengine_win.cpp b/src/corelib/io/qfsfileengine_win.cpp index 60e25d34f1..840c0d9f37 100644 --- a/src/corelib/io/qfsfileengine_win.cpp +++ b/src/corelib/io/qfsfileengine_win.cpp @@ -69,11 +69,13 @@ QT_BEGIN_NAMESPACE +using namespace Qt::StringLiterals; + static inline bool isUncPath(const QString &path) { // Starts with \\, but not \\. - return (path.startsWith(QLatin1String("\\\\")) - && path.size() > 2 && path.at(2) != QLatin1Char('.')); + return (path.startsWith("\\\\"_L1) + && path.size() > 2 && path.at(2) != u'.'); } /*! @@ -81,13 +83,13 @@ static inline bool isUncPath(const QString &path) */ QString QFSFileEnginePrivate::longFileName(const QString &path) { - if (path.startsWith(QLatin1String("\\\\.\\"))) + if (path.startsWith("\\\\.\\"_L1)) return path; QString absPath = QFileSystemEngine::nativeAbsoluteFilePath(path); - QString prefix = QLatin1String("\\\\?\\"); + QString prefix = "\\\\?\\"_L1; if (isUncPath(absPath)) { - prefix.append(QLatin1String("UNC\\")); // "\\\\?\\UNC\\" + prefix.append("UNC\\"_L1); // "\\\\?\\UNC\\" absPath.remove(0, 2); } return prefix + absPath; @@ -438,7 +440,7 @@ QString QFSFileEngine::currentPath(const QString &fileName) QString ret; //if filename is a drive: then get the pwd of that drive if (fileName.length() >= 2 && - fileName.at(0).isLetter() && fileName.at(1) == QLatin1Char(':')) { + fileName.at(0).isLetter() && fileName.at(1) == u':') { int drv = fileName.toUpper().at(0).toLatin1() - 'A' + 1; if (_getdrive() != drv) { wchar_t buf[PATH_MAX]; @@ -450,7 +452,7 @@ QString QFSFileEngine::currentPath(const QString &fileName) //just the pwd ret = QFileSystemEngine::currentPath().filePath(); } - if (ret.length() >= 2 && ret[1] == QLatin1Char(':')) + if (ret.length() >= 2 && ret[1] == u':') ret[0] = ret.at(0).toUpper(); // Force uppercase drive letters. return ret; } diff --git a/src/corelib/io/qiodevice.cpp b/src/corelib/io/qiodevice.cpp index 978c6f2486..fdeed890f4 100644 --- a/src/corelib/io/qiodevice.cpp +++ b/src/corelib/io/qiodevice.cpp @@ -55,6 +55,8 @@ QT_BEGIN_NAMESPACE +using namespace Qt::StringLiterals; + #ifdef QIODEVICE_DEBUG void debugBinaryString(const QByteArray &input) { @@ -2246,23 +2248,23 @@ QDebug operator<<(QDebug debug, QIODevice::OpenMode modes) debug << "OpenMode("; QStringList modeList; if (modes == QIODevice::NotOpen) { - modeList << QLatin1String("NotOpen"); + modeList << "NotOpen"_L1; } else { if (modes & QIODevice::ReadOnly) - modeList << QLatin1String("ReadOnly"); + modeList << "ReadOnly"_L1; if (modes & QIODevice::WriteOnly) - modeList << QLatin1String("WriteOnly"); + modeList << "WriteOnly"_L1; if (modes & QIODevice::Append) - modeList << QLatin1String("Append"); + modeList << "Append"_L1; if (modes & QIODevice::Truncate) - modeList << QLatin1String("Truncate"); + modeList << "Truncate"_L1; if (modes & QIODevice::Text) - modeList << QLatin1String("Text"); + modeList << "Text"_L1; if (modes & QIODevice::Unbuffered) - modeList << QLatin1String("Unbuffered"); + modeList << "Unbuffered"_L1; } std::sort(modeList.begin(), modeList.end()); - debug << modeList.join(QLatin1Char('|')); + debug << modeList.join(u'|'); debug << ')'; return debug; } diff --git a/src/corelib/io/qipaddress.cpp b/src/corelib/io/qipaddress.cpp index 911d1a54b9..cf77ac2977 100644 --- a/src/corelib/io/qipaddress.cpp +++ b/src/corelib/io/qipaddress.cpp @@ -44,6 +44,9 @@ #include "qvarlengtharray.h" QT_BEGIN_NAMESPACE + +using namespace Qt::StringLiterals; + namespace QIPAddressUtils { static QString number(quint8 val, int base = 10) @@ -130,12 +133,9 @@ void toString(QString &appendTo, IPv4Address address) { // reconstructing is easy // use the fast operator% that pre-calculates the size - appendTo += number(address >> 24) - % QLatin1Char('.') - % number(address >> 16) - % QLatin1Char('.') - % number(address >> 8) - % QLatin1Char('.') + appendTo += number(address >> 24) % u'.' + % number(address >> 16) % u'.' + % number(address >> 8) % u'.' % number(address); } @@ -283,7 +283,7 @@ void toString(QString &appendTo, const IPv6Address address) if (address[12] != 0 || address[13] != 0 || address[14] != 0) { embeddedIp4 = true; } else if (address[15] == 0) { - appendTo.append(QLatin1String("::")); + appendTo.append("::"_L1); return; } } diff --git a/src/corelib/io/qlockfile.cpp b/src/corelib/io/qlockfile.cpp index e6812cedde..7ff8e16abb 100644 --- a/src/corelib/io/qlockfile.cpp +++ b/src/corelib/io/qlockfile.cpp @@ -50,6 +50,8 @@ QT_BEGIN_NAMESPACE +using namespace Qt::StringLiterals; + namespace { struct LockFileInfo { @@ -293,7 +295,7 @@ bool QLockFile::tryLock(int timeout) qInfo("QLockFile: Lock file '%ls' has a modification time in the future", qUtf16Printable(d->fileName)); // Stale lock from another thread/process // Ensure two processes don't remove it at the same time - QLockFile rmlock(d->fileName + QLatin1String(".rmlock")); + QLockFile rmlock(d->fileName + ".rmlock"_L1); if (rmlock.tryLock()) { if (d->isApparentlyStale() && d->removeStaleLock()) continue; diff --git a/src/corelib/io/qlockfile_win.cpp b/src/corelib/io/qlockfile_win.cpp index 6c0d2c1f8d..cd52c86866 100644 --- a/src/corelib/io/qlockfile_win.cpp +++ b/src/corelib/io/qlockfile_win.cpp @@ -142,10 +142,10 @@ QString QLockFilePrivate::processNameByPid(qint64 pid) if (!length) return QString(); QString name = QString::fromWCharArray(buf, length); - int i = name.lastIndexOf(QLatin1Char('\\')); + int i = name.lastIndexOf(u'\\'); if (i >= 0) name.remove(0, i + 1); - i = name.lastIndexOf(QLatin1Char('.')); + i = name.lastIndexOf(u'.'); if (i >= 0) name.truncate(i); return name; diff --git a/src/corelib/io/qloggingregistry.cpp b/src/corelib/io/qloggingregistry.cpp index 52d76d689a..a5c6a3cfed 100644 --- a/src/corelib/io/qloggingregistry.cpp +++ b/src/corelib/io/qloggingregistry.cpp @@ -60,6 +60,8 @@ QT_BEGIN_NAMESPACE +using namespace Qt::StringLiterals; + Q_GLOBAL_STATIC(QLoggingRegistry, qtLoggingRegistry) /*! @@ -133,34 +135,35 @@ void QLoggingRule::parse(QStringView pattern) QStringView p; // strip trailing ".messagetype" - if (pattern.endsWith(QLatin1String(".debug"))) { + if (pattern.endsWith(".debug"_L1)) { p = pattern.chopped(6); // strlen(".debug") messageType = QtDebugMsg; - } else if (pattern.endsWith(QLatin1String(".info"))) { + } else if (pattern.endsWith(".info"_L1)) { p = pattern.chopped(5); // strlen(".info") messageType = QtInfoMsg; - } else if (pattern.endsWith(QLatin1String(".warning"))) { + } else if (pattern.endsWith(".warning"_L1)) { p = pattern.chopped(8); // strlen(".warning") messageType = QtWarningMsg; - } else if (pattern.endsWith(QLatin1String(".critical"))) { + } else if (pattern.endsWith(".critical"_L1)) { p = pattern.chopped(9); // strlen(".critical") messageType = QtCriticalMsg; } else { p = pattern; } - if (!p.contains(QLatin1Char('*'))) { + const QChar asterisk = u'*'; + if (!p.contains(asterisk)) { flags = FullText; } else { - if (p.endsWith(QLatin1Char('*'))) { + if (p.endsWith(asterisk)) { flags |= LeftFilter; p = p.chopped(1); } - if (p.startsWith(QLatin1Char('*'))) { + if (p.startsWith(asterisk)) { flags |= RightFilter; p = p.mid(1); } - if (p.contains(QLatin1Char('*'))) // '*' only supported at start/end + if (p.contains(asterisk)) // '*' only supported at start/end flags = PatternFlags(); } @@ -216,20 +219,20 @@ void QLoggingSettingsParser::parseNextLine(QStringView line) line = line.trimmed(); // comment - if (line.startsWith(QLatin1Char(';'))) + if (line.startsWith(u';')) return; - if (line.startsWith(QLatin1Char('[')) && line.endsWith(QLatin1Char(']'))) { + if (line.startsWith(u'[') && line.endsWith(u']')) { // new section auto sectionName = line.mid(1).chopped(1).trimmed(); - m_inRulesSection = sectionName.compare(QLatin1String("rules"), Qt::CaseInsensitive) == 0; + m_inRulesSection = sectionName.compare("rules"_L1, Qt::CaseInsensitive) == 0; return; } if (m_inRulesSection) { - int equalPos = line.indexOf(QLatin1Char('=')); + int equalPos = line.indexOf(u'='); if (equalPos != -1) { - if (line.lastIndexOf(QLatin1Char('=')) == equalPos) { + if (line.lastIndexOf(u'=') == equalPos) { const auto key = line.left(equalPos).trimmed(); #if QT_CONFIG(settings) QString tmp; @@ -240,9 +243,9 @@ void QLoggingSettingsParser::parseNextLine(QStringView line) #endif const auto valueStr = line.mid(equalPos + 1).trimmed(); int value = -1; - if (valueStr == QLatin1String("true")) + if (valueStr == "true"_L1) value = 1; - else if (valueStr == QLatin1String("false")) + else if (valueStr == "false"_L1) value = 0; QLoggingRule rule(pattern, (value == 1)); if (rule.flags != 0 && (value != -1)) diff --git a/src/corelib/io/qprocess.cpp b/src/corelib/io/qprocess.cpp index 3378412502..e21827e64e 100644 --- a/src/corelib/io/qprocess.cpp +++ b/src/corelib/io/qprocess.cpp @@ -98,7 +98,7 @@ QStringList QProcessEnvironmentPrivate::toList() const QStringList result; result.reserve(vars.size()); for (auto it = vars.cbegin(), end = vars.cend(); it != end; ++it) - result << nameToString(it.key()) + QLatin1Char('=') + valueToString(it.value()); + result << nameToString(it.key()) + u'=' + valueToString(it.value()); return result; } @@ -108,7 +108,7 @@ QProcessEnvironment QProcessEnvironmentPrivate::fromList(const QStringList &list QStringList::ConstIterator it = list.constBegin(), end = list.constEnd(); for ( ; it != end; ++it) { - int pos = it->indexOf(QLatin1Char('='), 1); + int pos = it->indexOf(u'=', 1); if (pos < 1) continue; @@ -2213,7 +2213,7 @@ QStringList QProcess::splitCommand(QStringView command) // "hello world". three consecutive double quotes represent // the quote character itself. for (int i = 0; i < command.size(); ++i) { - if (command.at(i) == QLatin1Char('"')) { + if (command.at(i) == u'"') { ++quoteCount; if (quoteCount == 3) { // third consecutive quote diff --git a/src/corelib/io/qprocess_unix.cpp b/src/corelib/io/qprocess_unix.cpp index 9f97bb7af9..9973ab76cd 100644 --- a/src/corelib/io/qprocess_unix.cpp +++ b/src/corelib/io/qprocess_unix.cpp @@ -79,6 +79,8 @@ QT_BEGIN_NAMESPACE +using namespace Qt::StringLiterals; + #if !defined(Q_OS_DARWIN) QT_BEGIN_INCLUDE_NAMESPACE @@ -415,7 +417,7 @@ static QString resolveExecutable(const QString &program) #ifdef Q_OS_DARWIN // allow invoking of .app bundles on the Mac. QFileInfo fileInfo(program); - if (program.endsWith(QLatin1String(".app")) && fileInfo.isDir()) { + if (program.endsWith(".app"_L1) && fileInfo.isDir()) { QCFType<CFURLRef> url = CFURLCreateWithFileSystemPath(0, QCFString(fileInfo.absoluteFilePath()), kCFURLPOSIXPathStyle, true); @@ -437,7 +439,7 @@ static QString resolveExecutable(const QString &program) } #endif - if (!program.contains(QLatin1Char('/'))) { + if (!program.contains(u'/')) { // findExecutable() returns its argument if it's an absolute path, // otherwise it searches $PATH; returns empty if not found (we handle // that case much later) @@ -625,7 +627,7 @@ bool QProcessPrivate::processStarted(QString *errorMessage) // did we read an error message? if (errorMessage) - *errorMessage = QLatin1String(buf.function) + QLatin1String(": ") + qt_error_string(buf.code); + *errorMessage = QLatin1String(buf.function) + ": "_L1 + qt_error_string(buf.code); return false; } @@ -946,7 +948,7 @@ bool QProcessPrivate::startDetached(qint64 *pid) AutoPipe startedPipe, pidPipe; if (!startedPipe || !pidPipe) { - setErrorAndEmit(QProcess::FailedToStart, QLatin1String("pipe: ") + qt_error_string(errno)); + setErrorAndEmit(QProcess::FailedToStart, "pipe: "_L1 + qt_error_string(errno)); return false; } @@ -1003,7 +1005,7 @@ bool QProcessPrivate::startDetached(qint64 *pid) closeChannels(); if (childPid == -1) { - setErrorAndEmit(QProcess::FailedToStart, QLatin1String("fork: ") + qt_error_string(savedErrno)); + setErrorAndEmit(QProcess::FailedToStart, "fork: "_L1 + qt_error_string(savedErrno)); return false; } diff --git a/src/corelib/io/qprocess_win.cpp b/src/corelib/io/qprocess_win.cpp index 3e2257109d..6b29710c84 100644 --- a/src/corelib/io/qprocess_win.cpp +++ b/src/corelib/io/qprocess_win.cpp @@ -64,6 +64,8 @@ QT_BEGIN_NAMESPACE +using namespace Qt::StringLiterals; + QProcessEnvironment QProcessEnvironment::systemEnvironment() { QProcessEnvironment env; @@ -391,44 +393,44 @@ static QString qt_create_commandline(const QString &program, const QStringList & QString args; if (!program.isEmpty()) { QString programName = program; - if (!programName.startsWith(QLatin1Char('\"')) && !programName.endsWith(QLatin1Char('\"')) && programName.contains(QLatin1Char(' '))) - programName = QLatin1Char('\"') + programName + QLatin1Char('\"'); - programName.replace(QLatin1Char('/'), QLatin1Char('\\')); + if (!programName.startsWith(u'\"') && !programName.endsWith(u'\"') && programName.contains(u' ')) + programName = u'\"' + programName + u'\"'; + programName.replace(u'/', u'\\'); // add the program as the first arg ... it works better - args = programName + QLatin1Char(' '); + args = programName + u' '; } for (qsizetype i = 0; i < arguments.size(); ++i) { QString tmp = arguments.at(i); // Quotes are escaped and their preceding backslashes are doubled. - qsizetype index = tmp.indexOf(QLatin1Char('"')); + qsizetype index = tmp.indexOf(u'"'); while (index >= 0) { // Escape quote - tmp.insert(index++, QLatin1Char('\\')); + tmp.insert(index++, u'\\'); // Double preceding backslashes (ignoring the one we just inserted) - for (qsizetype i = index - 2 ; i >= 0 && tmp.at(i) == QLatin1Char('\\') ; --i) { - tmp.insert(i, QLatin1Char('\\')); + for (qsizetype i = index - 2 ; i >= 0 && tmp.at(i) == u'\\' ; --i) { + tmp.insert(i, u'\\'); index++; } - index = tmp.indexOf(QLatin1Char('"'), index + 1); + index = tmp.indexOf(u'"', index + 1); } - if (tmp.isEmpty() || tmp.contains(QLatin1Char(' ')) || tmp.contains(QLatin1Char('\t'))) { + if (tmp.isEmpty() || tmp.contains(u' ') || tmp.contains(u'\t')) { // The argument must not end with a \ since this would be interpreted // as escaping the quote -- rather put the \ behind the quote: e.g. // rather use "foo"\ than "foo\" qsizetype i = tmp.length(); - while (i > 0 && tmp.at(i - 1) == QLatin1Char('\\')) + while (i > 0 && tmp.at(i - 1) == u'\\') --i; - tmp.insert(i, QLatin1Char('"')); - tmp.prepend(QLatin1Char('"')); + tmp.insert(i, u'"'); + tmp.prepend(u'"'); } - args += QLatin1Char(' ') + tmp; + args += u' ' + tmp; } if (!nativeArguments.isEmpty()) { if (!args.isEmpty()) - args += QLatin1Char(' '); + args += u' '; args += nativeArguments; } @@ -441,7 +443,7 @@ static QByteArray qt_create_environment(const QProcessEnvironmentPrivate::Map &e QProcessEnvironmentPrivate::Map copy = environment; // add PATH if necessary (for DLL loading) - QProcessEnvironmentPrivate::Key pathKey(QLatin1String("PATH")); + QProcessEnvironmentPrivate::Key pathKey("PATH"_L1); if (!copy.contains(pathKey)) { QByteArray path = qgetenv("PATH"); if (!path.isEmpty()) @@ -449,7 +451,7 @@ static QByteArray qt_create_environment(const QProcessEnvironmentPrivate::Map &e } // add systemroot if needed - QProcessEnvironmentPrivate::Key rootKey(QLatin1String("SystemRoot")); + QProcessEnvironmentPrivate::Key rootKey("SystemRoot"_L1); if (!copy.contains(rootKey)) { QByteArray systemRoot = qgetenv("SystemRoot"); if (!systemRoot.isEmpty()) diff --git a/src/corelib/io/qresource.cpp b/src/corelib/io/qresource.cpp index af0b9429af..fe19a8f4f4 100644 --- a/src/corelib/io/qresource.cpp +++ b/src/corelib/io/qresource.cpp @@ -78,6 +78,8 @@ QT_BEGIN_NAMESPACE +using namespace Qt::StringLiterals; + // Symbols used by code generated by RCC. // They cause compilation errors if the RCC content couldn't // be interpreted by this QtCore version. @@ -125,7 +127,7 @@ public: const QChar *m_data; qsizetype m_len; qsizetype m_pos = 0; - QChar m_splitChar = QLatin1Char('/'); + QChar m_splitChar = u'/'; }; // resource glue @@ -189,7 +191,7 @@ static QString cleanPath(const QString &_path) QString path = QDir::cleanPath(_path); // QDir::cleanPath does not remove two trailing slashes under _Windows_ // due to support for UNC paths. Remove those manually. - if (path.startsWith(QLatin1String("//"))) + if (path.startsWith("//"_L1)) path.remove(0, 1); return path; } @@ -381,26 +383,26 @@ void QResourcePrivate::ensureInitialized() const if (!related.isEmpty()) return; QResourcePrivate *that = const_cast<QResourcePrivate *>(this); - if (fileName == QLatin1String(":")) - that->fileName += QLatin1Char('/'); + if (fileName == ":"_L1) + that->fileName += u'/'; that->absoluteFilePath = fileName; - if (!that->absoluteFilePath.startsWith(QLatin1Char(':'))) - that->absoluteFilePath.prepend(QLatin1Char(':')); + if (!that->absoluteFilePath.startsWith(u':')) + that->absoluteFilePath.prepend(u':'); QStringView path(fileName); - if (path.startsWith(QLatin1Char(':'))) + if (path.startsWith(u':')) path = path.mid(1); - if (path.startsWith(QLatin1Char('/'))) { + if (path.startsWith(u'/')) { that->load(path.toString()); } else { const auto locker = qt_scoped_lock(resourceMutex()); QStringList searchPaths = *resourceSearchPaths(); - searchPaths << QLatin1String(""); + searchPaths << ""_L1; for (int i = 0; i < searchPaths.size(); ++i) { - const QString searchPath(searchPaths.at(i) + QLatin1Char('/') + path); + const QString searchPath(searchPaths.at(i) + u'/' + path); if (that->load(searchPath)) { - that->absoluteFilePath = QLatin1Char(':') + searchPath; + that->absoluteFilePath = u':' + searchPath; break; } } @@ -414,7 +416,7 @@ void QResourcePrivate::ensureChildren() const return; QString path = absoluteFilePath, k; - if (path.startsWith(QLatin1Char(':'))) + if (path.startsWith(u':')) path = path.mid(1); QDuplicateTracker<QString> kids(related.size()); QString cleaned = cleanPath(path); @@ -808,14 +810,14 @@ int QResourceRoot::findNode(const QString &_path, const QLocale &locale) const QString root = mappingRoot(); if (!root.isEmpty()) { if (root == path) { - path = QLatin1Char('/'); + path = u'/'; } else { - if (!root.endsWith(QLatin1Char('/'))) - root += QLatin1Char('/'); + if (!root.endsWith(u'/')) + root += u'/'; if (path.size() >= root.size() && path.startsWith(root)) path = path.mid(root.length() - 1); if (path.isEmpty()) - path = QLatin1Char('/'); + path = u'/'; } } } @@ -823,7 +825,7 @@ int QResourceRoot::findNode(const QString &_path, const QLocale &locale) const qDebug() << "!!!!" << "START" << path << locale.territory() << locale.language(); #endif - if (path == QLatin1String("/")) + if (path == "/"_L1) return 0; // the root node is always first @@ -1228,7 +1230,7 @@ bool QDynamicFileResourceRoot::registerSelf(const QString &f) static QString qt_resource_fixResourceRoot(QString r) { if (!r.isEmpty()) { - if (r.startsWith(QLatin1Char(':'))) + if (r.startsWith(u':')) r = r.mid(1); if (!r.isEmpty()) r = QDir::cleanPath(r); @@ -1249,7 +1251,7 @@ static QString qt_resource_fixResourceRoot(QString r) bool QResource::registerResource(const QString &rccFilename, const QString &resourceRoot) { QString r = qt_resource_fixResourceRoot(resourceRoot); - if (!r.isEmpty() && r[0] != QLatin1Char('/')) { + if (!r.isEmpty() && r[0] != u'/') { qWarning("QDir::registerResource: Registering a resource [%ls] must be rooted in an " "absolute path (start with /) [%ls]", qUtf16Printable(rccFilename), qUtf16Printable(resourceRoot)); @@ -1318,7 +1320,7 @@ bool QResource::unregisterResource(const QString &rccFilename, const QString &re bool QResource::registerResource(const uchar *rccData, const QString &resourceRoot) { QString r = qt_resource_fixResourceRoot(resourceRoot); - if (!r.isEmpty() && r[0] != QLatin1Char('/')) { + if (!r.isEmpty() && r[0] != u'/') { qWarning("QDir::registerResource: Registering a resource [%p] must be rooted in an " "absolute path (start with /) [%ls]", rccData, qUtf16Printable(resourceRoot)); @@ -1512,7 +1514,7 @@ QAbstractFileEngine::FileFlags QResourceFileEngine::fileFlags(QAbstractFileEngin } if (type & FlagsMask) { ret |= ExistsFlag; - if (d->resource.absoluteFilePath() == QLatin1String(":/")) + if (d->resource.absoluteFilePath() == ":/"_L1) ret |= RootFlag; } return ret; @@ -1522,24 +1524,24 @@ QString QResourceFileEngine::fileName(FileName file) const { Q_D(const QResourceFileEngine); if (file == BaseName) { - int slash = d->resource.fileName().lastIndexOf(QLatin1Char('/')); + int slash = d->resource.fileName().lastIndexOf(u'/'); if (slash == -1) return d->resource.fileName(); return d->resource.fileName().mid(slash + 1); } else if (file == PathName || file == AbsolutePathName) { const QString path = (file == AbsolutePathName) ? d->resource.absoluteFilePath() : d->resource.fileName(); - const int slash = path.lastIndexOf(QLatin1Char('/')); + const int slash = path.lastIndexOf(u'/'); if (slash == -1) - return QLatin1String(":"); + return ":"_L1; else if (slash <= 1) - return QLatin1String(":/"); + return ":/"_L1; return path.left(slash); } else if (file == CanonicalName || file == CanonicalPathName) { const QString absoluteFilePath = d->resource.absoluteFilePath(); if (file == CanonicalPathName) { - const int slash = absoluteFilePath.lastIndexOf(QLatin1Char('/')); + const int slash = absoluteFilePath.lastIndexOf(u'/'); if (slash != -1) return absoluteFilePath.left(slash); } diff --git a/src/corelib/io/qsavefile.cpp b/src/corelib/io/qsavefile.cpp index afe39287bd..a1518fa83a 100644 --- a/src/corelib/io/qsavefile.cpp +++ b/src/corelib/io/qsavefile.cpp @@ -55,6 +55,8 @@ QT_BEGIN_NAMESPACE +using namespace Qt::StringLiterals; + QSaveFilePrivate::QSaveFilePrivate() : writeError(QFileDevice::NoError), useTemporaryFile(true), @@ -246,10 +248,10 @@ bool QSaveFile::open(OpenMode mode) bool requiresDirectWrite = false; #ifdef Q_OS_WIN // check if it is an Alternate Data Stream - requiresDirectWrite = d->finalFileName == d->fileName && d->fileName.indexOf(QLatin1Char(':'), 2) > 1; + requiresDirectWrite = d->finalFileName == d->fileName && d->fileName.indexOf(u':', 2) > 1; #elif defined(Q_OS_ANDROID) // check if it is a content:// URL - requiresDirectWrite = d->fileName.startsWith(QLatin1String("content://")); + requiresDirectWrite = d->fileName.startsWith("content://"_L1); #endif if (requiresDirectWrite) { // yes, we can't rename onto it... diff --git a/src/corelib/io/qsettings.cpp b/src/corelib/io/qsettings.cpp index d3868a92a5..e90ada20db 100644 --- a/src/corelib/io/qsettings.cpp +++ b/src/corelib/io/qsettings.cpp @@ -100,6 +100,8 @@ QT_BEGIN_NAMESPACE +using namespace Qt::StringLiterals; + struct QConfFileCustomFormat { QString extension; @@ -323,7 +325,7 @@ QSettingsPrivate *QSettingsPrivate::create(const QString &fileName, QSettings::F void QSettingsPrivate::processChild(QStringView key, ChildSpec spec, QStringList &result) { if (spec != AllKeys) { - int slashPos = key.indexOf(QLatin1Char('/')); + int slashPos = key.indexOf(u'/'); if (slashPos == -1) { if (spec != ChildKeys) return; @@ -341,7 +343,7 @@ void QSettingsPrivate::beginGroupOrArray(const QSettingsGroup &group) groupStack.push(group); const QString name = group.name(); if (!name.isEmpty()) - groupPrefix += name + QLatin1Char('/'); + groupPrefix += name + u'/'; } /* @@ -390,8 +392,8 @@ QVariant QSettingsPrivate::stringListToVariantList(const QStringList &l) for (int i = 0; i < outStringList.count(); ++i) { const QString &str = outStringList.at(i); - if (str.startsWith(QLatin1Char('@'))) { - if (str.length() >= 2 && str.at(1) == QLatin1Char('@')) { + if (str.startsWith(u'@')) { + if (str.length() >= 2 && str.at(1) == u'@') { outStringList[i].remove(0, 1); } else { QVariantList variantList; @@ -412,14 +414,14 @@ QString QSettingsPrivate::variantToString(const QVariant &v) switch (v.metaType().id()) { case QMetaType::UnknownType: - result = QLatin1String("@Invalid()"); + result = "@Invalid()"_L1; break; case QMetaType::QByteArray: { QByteArray a = v.toByteArray(); - result = QLatin1String("@ByteArray(") + result = "@ByteArray("_L1 + QLatin1String(a.constData(), a.size()) - + QLatin1Char(')'); + + u')'; break; } @@ -436,9 +438,9 @@ QString QSettingsPrivate::variantToString(const QVariant &v) case QMetaType::Double: { result = v.toString(); if (result.contains(QChar::Null)) - result = QLatin1String("@String(") + result + QLatin1Char(')'); - else if (result.startsWith(QLatin1Char('@'))) - result.prepend(QLatin1Char('@')); + result = "@String("_L1 + result + u')'; + else if (result.startsWith(u'@')) + result.prepend(u'@'); break; } #ifndef QT_NO_GEOM_VARIANT @@ -479,7 +481,7 @@ QString QSettingsPrivate::variantToString(const QVariant &v) result = QLatin1String(typeSpec) + QLatin1String(a.constData(), a.size()) - + QLatin1Char(')'); + + u')'; #else Q_ASSERT(!"QSettings: Cannot save custom types without QDataStream support"); #endif @@ -493,18 +495,18 @@ QString QSettingsPrivate::variantToString(const QVariant &v) QVariant QSettingsPrivate::stringToVariant(const QString &s) { - if (s.startsWith(QLatin1Char('@'))) { - if (s.endsWith(QLatin1Char(')'))) { - if (s.startsWith(QLatin1String("@ByteArray("))) { + if (s.startsWith(u'@')) { + if (s.endsWith(u')')) { + if (s.startsWith("@ByteArray("_L1)) { return QVariant(QStringView{s}.mid(11, s.size() - 12).toLatin1()); - } else if (s.startsWith(QLatin1String("@String("))) { + } else if (s.startsWith("@String("_L1)) { return QVariant(QStringView{s}.mid(8, s.size() - 9).toString()); - } else if (s.startsWith(QLatin1String("@Variant(")) - || s.startsWith(QLatin1String("@DateTime("))) { + } else if (s.startsWith("@Variant("_L1) + || s.startsWith("@DateTime("_L1)) { #ifndef QT_NO_DATASTREAM QDataStream::Version version; int offset; - if (s.at(1) == QLatin1Char('D')) { + if (s.at(1) == u'D') { version = QDataStream::Qt_5_6; offset = 10; } else { @@ -521,25 +523,25 @@ QVariant QSettingsPrivate::stringToVariant(const QString &s) Q_ASSERT(!"QSettings: Cannot load custom types without QDataStream support"); #endif #ifndef QT_NO_GEOM_VARIANT - } else if (s.startsWith(QLatin1String("@Rect("))) { + } else if (s.startsWith("@Rect("_L1)) { QStringList args = QSettingsPrivate::splitArgs(s, 5); if (args.size() == 4) return QVariant(QRect(args[0].toInt(), args[1].toInt(), args[2].toInt(), args[3].toInt())); - } else if (s.startsWith(QLatin1String("@Size("))) { + } else if (s.startsWith("@Size("_L1)) { QStringList args = QSettingsPrivate::splitArgs(s, 5); if (args.size() == 2) return QVariant(QSize(args[0].toInt(), args[1].toInt())); - } else if (s.startsWith(QLatin1String("@Point("))) { + } else if (s.startsWith("@Point("_L1)) { QStringList args = QSettingsPrivate::splitArgs(s, 6); if (args.size() == 2) return QVariant(QPoint(args[0].toInt(), args[1].toInt())); #endif - } else if (s == QLatin1String("@Invalid()")) { + } else if (s == "@Invalid()"_L1) { return QVariant(); } } - if (s.startsWith(QLatin1String("@@"))) + if (s.startsWith("@@"_L1)) return QVariant(s.mid(1)); } @@ -584,7 +586,7 @@ bool QSettingsPrivate::iniUnescapedKey(const QByteArray &key, int from, int to, char16_t ch = decoded.at(i).unicode(); if (ch == '\\') { - result += QLatin1Char('/'); + result += u'/'; ++i; continue; } @@ -608,7 +610,7 @@ bool QSettingsPrivate::iniUnescapedKey(const QByteArray &key, int from, int to, } if (firstDigitPos + numDigits > size) { - result += QLatin1Char('%'); + result += u'%'; ++i; continue; } @@ -616,7 +618,7 @@ bool QSettingsPrivate::iniUnescapedKey(const QByteArray &key, int from, int to, bool ok; ch = QStringView(decoded).sliced(firstDigitPos, numDigits).toUShort(&ok, 16); if (!ok) { - result += QLatin1Char('%'); + result += u'%'; ++i; continue; } @@ -634,8 +636,8 @@ void QSettingsPrivate::iniEscapedString(const QString &str, QByteArray &result) { bool needsQuotes = false; bool escapeNextIfDigit = false; - bool useCodec = !str.startsWith(QLatin1String("@ByteArray(")) - && !str.startsWith(QLatin1String("@Variant(")); + bool useCodec = !str.startsWith("@ByteArray("_L1) + && !str.startsWith("@Variant("_L1); int i; int startPos = result.size(); @@ -715,7 +717,7 @@ inline static void iniChopTrailingSpaces(QString &str, int limit) { int n = str.size() - 1; QChar ch; - while (n >= limit && ((ch = str.at(n)) == QLatin1Char(' ') || ch == QLatin1Char('\t'))) + while (n >= limit && ((ch = str.at(n)) == u' ' || ch == u'\t')) str.truncate(n--); } @@ -899,18 +901,18 @@ QStringList QSettingsPrivate::splitArgs(const QString &s, int idx) { int l = s.length(); Q_ASSERT(l > 0); - Q_ASSERT(s.at(idx) == QLatin1Char('(')); - Q_ASSERT(s.at(l - 1) == QLatin1Char(')')); + Q_ASSERT(s.at(idx) == u'('); + Q_ASSERT(s.at(l - 1) == u')'); QStringList result; QString item; for (++idx; idx < l; ++idx) { QChar c = s.at(idx); - if (c == QLatin1Char(')')) { + if (c == u')') { Q_ASSERT(idx == l - 1); result.append(item); - } else if (c == QLatin1Char(' ')) { + } else if (c == u' ') { result.append(item); item.clear(); } else { @@ -926,7 +928,7 @@ QStringList QSettingsPrivate::splitArgs(const QString &s, int idx) void QConfFileSettingsPrivate::initFormat() { - extension = (format == QSettings::NativeFormat) ? QLatin1String(".conf") : QLatin1String(".ini"); + extension = (format == QSettings::NativeFormat) ? ".conf"_L1 : ".ini"_L1; readFunc = nullptr; writeFunc = nullptr; #if defined(Q_OS_MAC) @@ -975,9 +977,9 @@ static QString windowsConfigPath(const KNOWNFOLDERID &type) if (result.isEmpty()) { if (type == FOLDERID_ProgramData) { - result = QLatin1String("C:\\temp\\qt-common"); + result = "C:\\temp\\qt-common"_L1; } else if (type == FOLDERID_RoamingAppData) { - result = QLatin1String("C:\\temp\\qt-user"); + result = "C:\\temp\\qt-user"_L1; } } @@ -993,13 +995,13 @@ static inline int pathHashKey(QSettings::Format format, QSettings::Scope scope) #ifndef Q_OS_WIN static QString make_user_path() { - static constexpr QChar sep = QLatin1Char('/'); + static constexpr QChar sep = u'/'; #ifndef QSETTINGS_USE_QSTANDARDPATHS // Non XDG platforms (OS X, iOS, Android...) have used this code path erroneously // for some time now. Moving away from that would require migrating existing settings. QByteArray env = qgetenv("XDG_CONFIG_HOME"); if (env.isEmpty()) { - return QDir::homePath() + QLatin1String("/.config/"); + return QDir::homePath() + "/.config/"_L1; } else if (env.startsWith('/')) { return QFile::decodeName(env) + sep; } else { @@ -1025,7 +1027,7 @@ static std::unique_lock<QBasicMutex> initDefaultPaths(std::unique_lock<QBasicMut avoid a dead-lock, we can't hold the global mutex while calling it. */ - QString systemPath = QLibraryInfo::path(QLibraryInfo::SettingsPath) + QLatin1Char('/'); + QString systemPath = QLibraryInfo::path(QLibraryInfo::SettingsPath) + u'/'; locker.lock(); if (pathHash->isEmpty()) { @@ -1095,7 +1097,7 @@ QConfFileSettingsPrivate::QConfFileSettingsPrivate(QSettings::Format format, QString org = organization; if (org.isEmpty()) { setStatus(QSettings::AccessError); - org = QLatin1String("Unknown Organization"); + org = "Unknown Organization"_L1; } QString appFile = org + QDir::separator() + application + extension; @@ -1123,12 +1125,12 @@ QConfFileSettingsPrivate::QConfFileSettingsPrivate(QSettings::Format format, if (!application.isEmpty()) { paths.reserve(dirs.size() * 2); for (const auto &dir : qAsConst(dirs)) - paths.append(dir + QLatin1Char('/') + appFile); + paths.append(dir + u'/' + appFile); } else { paths.reserve(dirs.size()); } for (const auto &dir : qAsConst(dirs)) - paths.append(dir + QLatin1Char('/') + orgFile); + paths.append(dir + u'/' + orgFile); // Note: No check for existence of files is done intentionally. for (const auto &path : qAsConst(paths)) @@ -1198,7 +1200,7 @@ void QConfFileSettingsPrivate::remove(const QString &key) QConfFile *confFile = confFiles.at(0); QSettingsKey theKey(key, caseSensitivity); - QSettingsKey prefix(key + QLatin1Char('/'), caseSensitivity); + QSettingsKey prefix(key + u'/', caseSensitivity); const auto locker = qt_scoped_lock(confFile->mutex); ensureSectionParsed(confFile, theKey); @@ -1377,7 +1379,7 @@ void QConfFileSettingsPrivate::syncConfFile(QConfFile *confFile) We only need to lock if we are actually writing as only concurrent writes are a problem. Concurrent read and write are not a problem because the writing operation is atomic. */ - QLockFile lockFile(confFile->name + QLatin1String(".lock")); + QLockFile lockFile(confFile->name + ".lock"_L1); if (!readOnly && !lockFile.lock() && atomicSyncOnly) { setStatus(QSettings::AccessError); return; @@ -1661,7 +1663,7 @@ bool QConfFileSettingsPrivate::readIniFile(const QByteArray &data, currentSection.clear(); iniUnescapedKey(iniSection, 0, iniSection.size(), currentSection); } - currentSection += QLatin1Char('/'); + currentSection += u'/'; } currentSectionStart = dataPos; } @@ -1784,7 +1786,7 @@ bool QConfFileSettingsPrivate::writeIniFile(QIODevice &device, const ParsedSetti QSettingsIniKey key(j.key().originalCaseKey(), j.key().originalKeyPosition()); int slashPos; - if ((slashPos = key.indexOf(QLatin1Char('/'))) != -1) { + if ((slashPos = key.indexOf(u'/')) != -1) { section = key.left(slashPos); key.remove(0, slashPos + 1); } @@ -1877,7 +1879,7 @@ void QConfFileSettingsPrivate::ensureSectionParsed(QConfFile *confFile, UnparsedSettingsMap::iterator i; - int indexOfSlash = key.indexOf(QLatin1Char('/')); + int indexOfSlash = key.indexOf(u'/'); if (indexOfSlash != -1) { i = confFile->unparsedIniSections.upperBound(key); if (i == confFile->unparsedIniSections.begin()) @@ -2982,7 +2984,7 @@ int QSettings::beginReadArray(QAnyStringView prefix) { Q_D(QSettings); d->beginGroupOrArray(QSettingsGroup(d->normalizedKey(prefix), false)); - return value(QLatin1String("size")).toInt(); + return value("size"_L1).toInt(); } /*! @@ -3023,9 +3025,9 @@ void QSettings::beginWriteArray(QAnyStringView prefix, int size) d->beginGroupOrArray(QSettingsGroup(d->normalizedKey(prefix), size < 0)); if (size < 0) - remove(QLatin1String("size")); + remove("size"_L1); else - setValue(QLatin1String("size"), size); + setValue("size"_L1, size); } /*! @@ -3049,7 +3051,7 @@ void QSettings::endArray() d->groupPrefix.truncate(d->groupPrefix.size() - (len + 1)); if (group.arraySizeGuess() != -1) - setValue(group.name() + QLatin1String("/size"), group.arraySizeGuess()); + setValue(group.name() + "/size"_L1, group.arraySizeGuess()); if (!group.isArray()) qWarning("QSettings::endArray: Expected endGroup() instead"); @@ -3510,7 +3512,7 @@ QSettings::Format QSettings::registerFormat(const QString &extension, ReadFunc r return QSettings::InvalidFormat; QConfFileCustomFormat info; - info.extension = QLatin1Char('.') + extension; + info.extension = u'.' + extension; info.readFunc = readFunc; info.writeFunc = writeFunc; info.caseSensitivity = caseSensitivity; diff --git a/src/corelib/io/qsettings_mac.cpp b/src/corelib/io/qsettings_mac.cpp index 59f0015b63..fa4d95b1fe 100644 --- a/src/corelib/io/qsettings_mac.cpp +++ b/src/corelib/io/qsettings_mac.cpp @@ -50,6 +50,8 @@ QT_BEGIN_NAMESPACE +using namespace Qt::StringLiterals; + static const CFStringRef hostNames[2] = { kCFPreferencesCurrentHost, kCFPreferencesAnyHost }; static const int numHostNames = 2; @@ -291,18 +293,16 @@ static QString comify(const QString &organization) { for (int i = organization.size() - 1; i >= 0; --i) { QChar ch = organization.at(i); - if (ch == QLatin1Char('.') || ch == QChar(0x3002) || ch == QChar(0xff0e) + if (ch == u'.' || ch == QChar(0x3002) || ch == QChar(0xff0e) || ch == QChar(0xff61)) { QString suffix = organization.mid(i + 1).toLower(); - if (suffix.size() == 2 || suffix == QLatin1String("com") - || suffix == QLatin1String("org") || suffix == QLatin1String("net") - || suffix == QLatin1String("edu") || suffix == QLatin1String("gov") - || suffix == QLatin1String("mil") || suffix == QLatin1String("biz") - || suffix == QLatin1String("info") || suffix == QLatin1String("name") - || suffix == QLatin1String("pro") || suffix == QLatin1String("aero") - || suffix == QLatin1String("coop") || suffix == QLatin1String("museum")) { + if (suffix.size() == 2 || suffix == "com"_L1 || suffix == "org"_L1 + || suffix == "net"_L1 || suffix == "edu"_L1 || suffix == "gov"_L1 + || suffix == "mil"_L1 || suffix == "biz"_L1 || suffix == "info"_L1 + || suffix == "name"_L1 || suffix == "pro"_L1 || suffix == "aero"_L1 + || suffix == "coop"_L1 || suffix == "museum"_L1) { QString result = organization; - result.replace(QLatin1Char('/'), QLatin1Char(' ')); + result.replace(u'/', u' '); return result; } break; @@ -321,13 +321,13 @@ static QString comify(const QString &organization) } else if (uc >= 'A' && uc <= 'Z') { domain += ch.toLower(); } else { - domain += QLatin1Char(' '); + domain += u' '; } } domain = domain.simplified(); - domain.replace(QLatin1Char(' '), QLatin1Char('-')); + domain.replace(u' ', u'-'); if (!domain.isEmpty()) - domain.append(QLatin1String(".com")); + domain.append(".com"_L1); return domain; } @@ -380,35 +380,34 @@ QMacSettingsPrivate::QMacSettingsPrivate(QSettings::Scope scope, const QString & if (main_bundle_identifier != NULL) { QString bundle_identifier(qtKey(main_bundle_identifier)); // CFBundleGetIdentifier returns identifier separated by slashes rather than periods. - QStringList bundle_identifier_components = bundle_identifier.split(QLatin1Char('/')); + QStringList bundle_identifier_components = bundle_identifier.split(u'/'); // pre-reverse them so that when they get reversed again below, they are in the com.company.product format. QStringList bundle_identifier_components_reversed; for (int i=0; i<bundle_identifier_components.size(); ++i) { const QString &bundle_identifier_component = bundle_identifier_components.at(i); bundle_identifier_components_reversed.push_front(bundle_identifier_component); } - domainName = bundle_identifier_components_reversed.join(QLatin1Char('.')); + domainName = bundle_identifier_components_reversed.join(u'.'); } } } // if no bundle identifier yet. use a hard coded string. - if (domainName.isEmpty()) { - domainName = QLatin1String("unknown-organization.trolltech.com"); - } + if (domainName.isEmpty()) + domainName = "unknown-organization.trolltech.com"_L1; - while ((nextDot = domainName.indexOf(QLatin1Char('.'), curPos)) != -1) { + while ((nextDot = domainName.indexOf(u'.', curPos)) != -1) { javaPackageName.prepend(QStringView{domainName}.mid(curPos, nextDot - curPos)); - javaPackageName.prepend(QLatin1Char('.')); + javaPackageName.prepend(u'.'); curPos = nextDot + 1; } javaPackageName.prepend(QStringView{domainName}.mid(curPos)); javaPackageName = std::move(javaPackageName).toLower(); if (curPos == 0) - javaPackageName.prepend(QLatin1String("com.")); + javaPackageName.prepend("com."_L1); suiteId = javaPackageName; if (!application.isEmpty()) { - javaPackageName += QLatin1Char('.') + application; + javaPackageName += u'.' + application; applicationId = javaPackageName; } @@ -436,13 +435,13 @@ QMacSettingsPrivate::~QMacSettingsPrivate() void QMacSettingsPrivate::remove(const QString &key) { - QStringList keys = children(key + QLatin1Char('/'), AllKeys); + QStringList keys = children(key + u'/', AllKeys); // If i == -1, then delete "key" itself. for (int i = -1; i < keys.size(); ++i) { QString subKey = key; if (i >= 0) { - subKey += QLatin1Char('/'); + subKey += u'/'; subKey += keys.at(i); } CFPreferencesSetValue(macKey(subKey), 0, domains[0].applicationOrSuiteId, @@ -534,7 +533,7 @@ void QMacSettingsPrivate::flush() bool QMacSettingsPrivate::isWritable() const { QMacSettingsPrivate *that = const_cast<QMacSettingsPrivate *>(this); - QString impossibleKey(QLatin1String("qt_internal/")); + QString impossibleKey("qt_internal/"_L1); QSettings::Status oldStatus = that->status; that->status = QSettings::NoError; @@ -554,9 +553,9 @@ QString QMacSettingsPrivate::fileName() const QString result; if (scope == QSettings::UserScope) result = QDir::homePath(); - result += QLatin1String("/Library/Preferences/"); + result += "/Library/Preferences/"_L1; result += QString::fromCFString(domains[0].applicationOrSuiteId); - result += QLatin1String(".plist"); + result += ".plist"_L1; return result; } @@ -566,7 +565,7 @@ QSettingsPrivate *QSettingsPrivate::create(QSettings::Format format, const QString &application) { #ifndef QT_BOOTSTRAPPED - if (organization == QLatin1String("Qt")) + if (organization == "Qt"_L1) { QString organizationDomain = QCoreApplication::organizationDomain(); QString applicationName = QCoreApplication::applicationName(); diff --git a/src/corelib/io/qsettings_wasm.cpp b/src/corelib/io/qsettings_wasm.cpp index 9e016aa4f4..d264515a7c 100644 --- a/src/corelib/io/qsettings_wasm.cpp +++ b/src/corelib/io/qsettings_wasm.cpp @@ -53,6 +53,8 @@ QT_BEGIN_NAMESPACE +using namespace Qt::StringLiterals; + static bool isReadReady = false; class QWasmSettingsPrivate : public QConfFileSettingsPrivate @@ -127,7 +129,7 @@ QSettingsPrivate *QSettingsPrivate::create(QSettings::Format format, const QString &application) { Q_UNUSED(format); - if (organization == QLatin1String("Qt")) + if (organization == "Qt"_L1) { QString organizationDomain = QCoreApplication::organizationDomain(); QString applicationName = QCoreApplication::applicationName(); diff --git a/src/corelib/io/qsettings_win.cpp b/src/corelib/io/qsettings_win.cpp index 5146009c71..9059f2af01 100644 --- a/src/corelib/io/qsettings_win.cpp +++ b/src/corelib/io/qsettings_win.cpp @@ -60,6 +60,8 @@ QT_BEGIN_NAMESPACE +using namespace Qt::StringLiterals; + /* Keys are stored in QStrings. If the variable name starts with 'u', this is a "user" key, ie. "foo/bar/alpha/beta". If the variable name starts with 'r', this is a "registry" key, ie. "\foo\bar\alpha\beta". */ @@ -76,7 +78,7 @@ static const REGSAM registryPermissions = KEY_READ | KEY_WRITE; static QString keyPath(const QString &rKey) { - int idx = rKey.lastIndexOf(QLatin1Char('\\')); + int idx = rKey.lastIndexOf(u'\\'); if (idx == -1) return QString(); return rKey.left(idx + 1); @@ -84,7 +86,7 @@ static QString keyPath(const QString &rKey) static QString keyName(const QString &rKey) { - int idx = rKey.lastIndexOf(QLatin1Char('\\')); + int idx = rKey.lastIndexOf(u'\\'); QString res; if (idx == -1) @@ -92,8 +94,8 @@ static QString keyName(const QString &rKey) else res = rKey.mid(idx + 1); - if (res == QLatin1String("Default") || res == QLatin1String(".")) - res = QLatin1String(""); + if (res == "Default"_L1 || res == "."_L1) + res = ""_L1; return res; } @@ -248,7 +250,7 @@ static QStringList childKeysOrGroups(HKEY parentHandle, QSettingsPrivate::ChildS continue; } if (item.isEmpty()) - item = QLatin1String("."); + item = "."_L1; result.append(item); } return result; @@ -267,7 +269,7 @@ static void allKeys(HKEY parentHandle, const QString &rSubKey, NameSet *result, for (int i = 0; i < childKeys.size(); ++i) { QString s = rSubKey; if (!s.isEmpty()) - s += QLatin1Char('\\'); + s += u'\\'; s += childKeys.at(i); result->insert(s, QString()); } @@ -275,7 +277,7 @@ static void allKeys(HKEY parentHandle, const QString &rSubKey, NameSet *result, for (int i = 0; i < childGroups.size(); ++i) { QString s = rSubKey; if (!s.isEmpty()) - s += QLatin1Char('\\'); + s += u'\\'; s += childGroups.at(i); allKeys(parentHandle, s, result, access); } @@ -411,9 +413,9 @@ QWinSettingsPrivate::QWinSettingsPrivate(QSettings::Scope scope, const QString & deleteWriteHandleOnExit = false; if (!organization.isEmpty()) { - QString prefix = QLatin1String("Software\\") + organization; - QString orgPrefix = prefix + QLatin1String("\\OrganizationDefaults"); - QString appPrefix = prefix + QLatin1Char('\\') + application; + QString prefix = "Software\\"_L1 + organization; + QString orgPrefix = prefix + "\\OrganizationDefaults"_L1; + QString appPrefix = prefix + u'\\' + application; if (scope == QSettings::UserScope) { if (!application.isEmpty()) @@ -438,34 +440,34 @@ QWinSettingsPrivate::QWinSettingsPrivate(QString rPath, REGSAM access) { deleteWriteHandleOnExit = false; - if (rPath.startsWith(QLatin1Char('\\'))) + if (rPath.startsWith(u'\\')) rPath.remove(0, 1); int keyLength; HKEY keyName; - if (rPath.startsWith(QLatin1String("HKEY_CURRENT_USER"))) { + if (rPath.startsWith("HKEY_CURRENT_USER"_L1)) { keyLength = 17; keyName = HKEY_CURRENT_USER; - } else if (rPath.startsWith(QLatin1String("HKCU"))) { + } else if (rPath.startsWith("HKCU"_L1)) { keyLength = 4; keyName = HKEY_CURRENT_USER; - } else if (rPath.startsWith(QLatin1String("HKEY_LOCAL_MACHINE"))) { + } else if (rPath.startsWith("HKEY_LOCAL_MACHINE"_L1)) { keyLength = 18; keyName = HKEY_LOCAL_MACHINE; - } else if (rPath.startsWith(QLatin1String("HKLM"))) { + } else if (rPath.startsWith("HKLM"_L1)) { keyLength = 4; keyName = HKEY_LOCAL_MACHINE; - } else if (rPath.startsWith(QLatin1String("HKEY_CLASSES_ROOT"))) { + } else if (rPath.startsWith("HKEY_CLASSES_ROOT"_L1)) { keyLength = 17; keyName = HKEY_CLASSES_ROOT; - } else if (rPath.startsWith(QLatin1String("HKCR"))) { + } else if (rPath.startsWith("HKCR"_L1)) { keyLength = 4; keyName = HKEY_CLASSES_ROOT; - } else if (rPath.startsWith(QLatin1String("HKEY_USERS"))) { + } else if (rPath.startsWith("HKEY_USERS"_L1)) { keyLength = 10; keyName = HKEY_USERS; - } else if (rPath.startsWith(QLatin1String("HKU"))) { + } else if (rPath.startsWith("HKU"_L1)) { keyLength = 3; keyName = HKEY_USERS; } else { @@ -474,7 +476,7 @@ QWinSettingsPrivate::QWinSettingsPrivate(QString rPath, REGSAM access) if (rPath.length() == keyLength) regList.append(RegistryKey(keyName, QString(), false, access)); - else if (rPath[keyLength] == QLatin1Char('\\')) + else if (rPath[keyLength] == u'\\') regList.append(RegistryKey(keyName, rPath.mid(keyLength+1), false, access)); } @@ -773,7 +775,7 @@ QStringList QWinSettingsPrivate::children(const QString &uKey, ChildSpec spec) c if (spec == AllKeys) { NameSet keys; - allKeys(handle, QLatin1String(""), &keys, access); + allKeys(handle, ""_L1, &keys, access); mergeKeySets(&result, keys); } else { // ChildGroups or ChildKeys QStringList names = childKeysOrGroups(handle, spec); @@ -813,9 +815,9 @@ QString QWinSettingsPrivate::fileName() const const RegistryKey &key = regList.at(0); QString result; if (key.parentHandle() == HKEY_CURRENT_USER) - result = QLatin1String("\\HKEY_CURRENT_USER\\"); + result = "\\HKEY_CURRENT_USER\\"_L1; else - result = QLatin1String("\\HKEY_LOCAL_MACHINE\\"); + result = "\\HKEY_LOCAL_MACHINE\\"_L1; return result + regList.at(0).key(); } diff --git a/src/corelib/io/qstandardpaths.cpp b/src/corelib/io/qstandardpaths.cpp index 65cbfe70e7..2f73cf27bb 100644 --- a/src/corelib/io/qstandardpaths.cpp +++ b/src/corelib/io/qstandardpaths.cpp @@ -60,6 +60,7 @@ QT_BEGIN_NAMESPACE +using namespace Qt::StringLiterals; /*! \class QStandardPaths \inmodule QtCore @@ -412,7 +413,7 @@ QString QStandardPaths::locate(StandardLocation type, const QString &fileName, L { const QStringList &dirs = standardLocations(type); for (QStringList::const_iterator dir = dirs.constBegin(); dir != dirs.constEnd(); ++dir) { - const QString path = *dir + QLatin1Char('/') + fileName; + const QString path = *dir + u'/' + fileName; if (existsAsSpecified(path, options)) return path; } @@ -427,7 +428,7 @@ QStringList QStandardPaths::locateAll(StandardLocation type, const QString &file const QStringList &dirs = standardLocations(type); QStringList result; for (QStringList::const_iterator dir = dirs.constBegin(); dir != dirs.constEnd(); ++dir) { - const QString path = *dir + QLatin1Char('/') + fileName; + const QString path = *dir + u'/' + fileName; if (existsAsSpecified(path, options)) result.append(path); } @@ -438,11 +439,9 @@ QStringList QStandardPaths::locateAll(StandardLocation type, const QString &file static QStringList executableExtensions() { // If %PATHEXT% does not contain .exe, it is either empty, malformed, or distorted in ways that we cannot support, anyway. - const QStringList pathExt = QString::fromLocal8Bit(qgetenv("PATHEXT")).toLower().split(QLatin1Char(';')); - return pathExt.contains(QLatin1String(".exe"), Qt::CaseInsensitive) ? - pathExt : - QStringList() << QLatin1String(".exe") << QLatin1String(".com") - << QLatin1String(".bat") << QLatin1String(".cmd"); + const QStringList pathExt = QString::fromLocal8Bit(qgetenv("PATHEXT")).toLower().split(u';'); + return pathExt.contains(".exe"_L1, Qt::CaseInsensitive) ? + pathExt : QStringList{".exe"_L1, ".com"_L1, ".bat"_L1, ".cmd"_L1}; } #endif @@ -461,7 +460,7 @@ static inline QString searchExecutable(const QStringList &searchPaths, { const QDir currentDir = QDir::current(); for (const QString &searchPath : searchPaths) { - const QString candidate = currentDir.absoluteFilePath(searchPath + QLatin1Char('/') + executableName); + const QString candidate = currentDir.absoluteFilePath(searchPath + u'/' + executableName); const QString absPath = checkExecutable(candidate); if (!absPath.isEmpty()) return absPath; @@ -480,7 +479,7 @@ static inline QString { const QDir currentDir = QDir::current(); for (const QString &searchPath : searchPaths) { - const QString candidateRoot = currentDir.absoluteFilePath(searchPath + QLatin1Char('/') + executableName); + const QString candidateRoot = currentDir.absoluteFilePath(searchPath + u'/' + executableName); for (const QString &suffix : suffixes) { const QString absPath = checkExecutable(candidateRoot + suffix); if (!absPath.isEmpty()) @@ -530,7 +529,7 @@ QString QStandardPaths::findExecutable(const QString &executableName, const QStr searchPaths.reserve(rawPaths.size()); for (const QString &rawPath : rawPaths) { QString cleanPath = QDir::cleanPath(rawPath); - if (cleanPath.size() > 1 && cleanPath.endsWith(QLatin1Char('/'))) + if (cleanPath.size() > 1 && cleanPath.endsWith(u'/')) cleanPath.truncate(cleanPath.size() - 1); searchPaths.push_back(cleanPath); } @@ -540,9 +539,9 @@ QString QStandardPaths::findExecutable(const QString &executableName, const QStr // On Windows, if the name does not have a suffix or a suffix not // in PATHEXT ("xx.foo"), append suffixes from PATHEXT. static const QStringList executable_extensions = executableExtensions(); - if (executableName.contains(QLatin1Char('.'))) { + if (executableName.contains(u'.')) { const QString suffix = QFileInfo(executableName).suffix(); - if (suffix.isEmpty() || !executable_extensions.contains(QLatin1Char('.') + suffix, Qt::CaseInsensitive)) + if (suffix.isEmpty() || !executable_extensions.contains(u'.' + suffix, Qt::CaseInsensitive)) return searchExecutableAppendSuffix(searchPaths, executableName, executable_extensions); } else { return searchExecutableAppendSuffix(searchPaths, executableName, executable_extensions); diff --git a/src/corelib/io/qstandardpaths_android.cpp b/src/corelib/io/qstandardpaths_android.cpp index 28993a16dc..9deab7754b 100644 --- a/src/corelib/io/qstandardpaths_android.cpp +++ b/src/corelib/io/qstandardpaths_android.cpp @@ -49,14 +49,14 @@ QT_BEGIN_NAMESPACE using namespace QNativeInterface; +using namespace Qt::StringLiterals; typedef QMap<QString, QString> AndroidDirCache; Q_GLOBAL_STATIC(AndroidDirCache, androidDirCache) static QString testDir() { - return QStandardPaths::isTestModeEnabled() ? QLatin1String("/qttest") - : QLatin1String(""); + return QStandardPaths::isTestModeEnabled() ? "/qttest"_L1 : ""_L1; } static inline QString getAbsolutePath(const QJniObject &file) @@ -75,7 +75,7 @@ static inline QString getAbsolutePath(const QJniObject &file) */ static QString getExternalFilesDir(const char *directoryField = nullptr) { - QString &path = (*androidDirCache)[QLatin1String("APPNAME_%1").arg(QLatin1String(directoryField))]; + QString &path = (*androidDirCache)["APPNAME_%1"_L1.arg(QLatin1String(directoryField))]; if (!path.isEmpty()) return path; @@ -83,7 +83,7 @@ static QString getExternalFilesDir(const char *directoryField = nullptr) if (!appCtx.isValid()) return QString(); - QJniObject dirField = QJniObject::fromString(QLatin1String("")); + QJniObject dirField = QJniObject::fromString(""_L1); if (directoryField && strlen(directoryField) > 0) { dirField = QJniObject::getStaticObjectField("android/os/Environment", directoryField, @@ -184,7 +184,7 @@ QString QStandardPaths::writableLocation(StandardLocation type) case QStandardPaths::GenericConfigLocation: case QStandardPaths::ConfigLocation: case QStandardPaths::AppConfigLocation: - return getFilesDir() + testDir() + QLatin1String("/settings"); + return getFilesDir() + testDir() + "/settings"_L1; case QStandardPaths::GenericDataLocation: return getExternalFilesDir() + testDir(); case QStandardPaths::AppDataLocation: @@ -260,7 +260,7 @@ QStringList QStandardPaths::standardLocations(StandardLocation type) // Don't cache the fallback, as we might just have been called before // QT_ANDROID_FONT_LOCATION has been set. - return QStringList(QLatin1String("/system/fonts")); + return QStringList("/system/fonts"_L1); } return QStringList(writableLocation(type)); diff --git a/src/corelib/io/qstandardpaths_haiku.cpp b/src/corelib/io/qstandardpaths_haiku.cpp index cac7767e6b..0709e2a57f 100644 --- a/src/corelib/io/qstandardpaths_haiku.cpp +++ b/src/corelib/io/qstandardpaths_haiku.cpp @@ -61,10 +61,10 @@ void appendOrganizationAndApp(QString &path) #ifndef QT_BOOTSTRAPPED const QString org = QCoreApplication::organizationName(); if (!org.isEmpty()) - path += QLatin1Char('/') + org; + path += u'/' + org; const QString appName = QCoreApplication::applicationName(); if (!appName.isEmpty()) - path += QLatin1Char('/') + appName; + path += u'/' + appName; #else Q_UNUSED(path); #endif diff --git a/src/corelib/io/qstandardpaths_mac.mm b/src/corelib/io/qstandardpaths_mac.mm index 8c102d6928..f0963daf04 100644 --- a/src/corelib/io/qstandardpaths_mac.mm +++ b/src/corelib/io/qstandardpaths_mac.mm @@ -53,6 +53,8 @@ QT_BEGIN_NAMESPACE +using namespace Qt::StringLiterals; + static QString pathForDirectory(NSSearchPathDirectory directory, NSSearchPathDomainMask mask) { @@ -98,10 +100,10 @@ static void appendOrganizationAndApp(QString &path) #ifndef QT_BOOTSTRAPPED const QString org = QCoreApplication::organizationName(); if (!org.isEmpty()) - path += QLatin1Char('/') + org; + path += u'/' + org; const QString appName = QCoreApplication::applicationName(); if (!appName.isEmpty()) - path += QLatin1Char('/') + appName; + path += u'/' + appName; #else Q_UNUSED(path); #endif @@ -123,36 +125,36 @@ static QString baseWritableLocation(QStandardPaths::StandardLocation type, #if defined(QT_PLATFORM_UIKIT) // These locations point to non-existing write-protected paths. Use sensible fallbacks. case QStandardPaths::MusicLocation: - path = pathForDirectory(NSDocumentDirectory, mask) + QLatin1String("/Music"); + path = pathForDirectory(NSDocumentDirectory, mask) + "/Music"_L1; break; case QStandardPaths::MoviesLocation: - path = pathForDirectory(NSDocumentDirectory, mask) + QLatin1String("/Movies"); + path = pathForDirectory(NSDocumentDirectory, mask) + "/Movies"_L1; break; case QStandardPaths::PicturesLocation: - path = pathForDirectory(NSDocumentDirectory, mask) + QLatin1String("/Pictures"); + path = pathForDirectory(NSDocumentDirectory, mask) + "/Pictures"_L1; break; case QStandardPaths::DownloadLocation: - path = pathForDirectory(NSDocumentDirectory, mask) + QLatin1String("/Downloads"); + path = pathForDirectory(NSDocumentDirectory, mask) + "/Downloads"_L1; break; case QStandardPaths::DesktopLocation: - path = pathForDirectory(NSDocumentDirectory, mask) + QLatin1String("/Desktop"); + path = pathForDirectory(NSDocumentDirectory, mask) + "/Desktop"_L1; break; case QStandardPaths::ApplicationsLocation: break; case QStandardPaths::PublicShareLocation: - path = pathForDirectory(NSDocumentDirectory, mask) + QLatin1String("/Public"); + path = pathForDirectory(NSDocumentDirectory, mask) + "/Public"_L1; break; case QStandardPaths::TemplatesLocation: - path = pathForDirectory(NSDocumentDirectory, mask) + QLatin1String("/Templates"); + path = pathForDirectory(NSDocumentDirectory, mask) + "/Templates"_L1; break; #endif case QStandardPaths::FontsLocation: - path = pathForDirectory(NSLibraryDirectory, mask) + QLatin1String("/Fonts"); + path = pathForDirectory(NSLibraryDirectory, mask) + "/Fonts"_L1; break; case QStandardPaths::ConfigLocation: case QStandardPaths::GenericConfigLocation: case QStandardPaths::AppConfigLocation: - path = pathForDirectory(NSLibraryDirectory, mask) + QLatin1String("/Preferences"); + path = pathForDirectory(NSLibraryDirectory, mask) + "/Preferences"_L1; break; default: path = pathForDirectory(dir, mask); @@ -179,7 +181,7 @@ QString QStandardPaths::writableLocation(StandardLocation type) { QString location = baseWritableLocation(type, NSUserDomainMask, true); if (isTestModeEnabled()) - location = location.replace(QDir::homePath(), QDir::homePath() + QLatin1String("/.qttest")); + location = location.replace(QDir::homePath(), QDir::homePath() + "/.qttest"_L1); return location; } @@ -190,7 +192,7 @@ QStringList QStandardPaths::standardLocations(StandardLocation type) #if defined(QT_PLATFORM_UIKIT) if (type == PicturesLocation) - dirs << writableLocation(PicturesLocation) << QLatin1String("assets-library://"); + dirs << writableLocation(PicturesLocation) << "assets-library://"_L1; #endif if (type == GenericDataLocation || type == FontsLocation || type == ApplicationsLocation diff --git a/src/corelib/io/qstandardpaths_unix.cpp b/src/corelib/io/qstandardpaths_unix.cpp index 6acec9c034..2750feda5d 100644 --- a/src/corelib/io/qstandardpaths_unix.cpp +++ b/src/corelib/io/qstandardpaths_unix.cpp @@ -58,15 +58,17 @@ QT_BEGIN_NAMESPACE +using namespace Qt::StringLiterals; + static void appendOrganizationAndApp(QString &path) { #ifndef QT_BOOTSTRAPPED const QString org = QCoreApplication::organizationName(); if (!org.isEmpty()) - path += QLatin1Char('/') + org; + path += u'/' + org; const QString appName = QCoreApplication::applicationName(); if (!appName.isEmpty()) - path += QLatin1Char('/') + appName; + path += u'/' + appName; #else Q_UNUSED(path); #endif @@ -77,23 +79,23 @@ static QLatin1String xdg_key_name(QStandardPaths::StandardLocation type) { switch (type) { case QStandardPaths::DesktopLocation: - return QLatin1String("DESKTOP"); + return "DESKTOP"_L1; case QStandardPaths::DocumentsLocation: - return QLatin1String("DOCUMENTS"); + return "DOCUMENTS"_L1; case QStandardPaths::PicturesLocation: - return QLatin1String("PICTURES"); + return "PICTURES"_L1; case QStandardPaths::MusicLocation: - return QLatin1String("MUSIC"); + return "MUSIC"_L1; case QStandardPaths::MoviesLocation: - return QLatin1String("VIDEOS"); + return "VIDEOS"_L1; case QStandardPaths::DownloadLocation: - return QLatin1String("DOWNLOAD"); + return "DOWNLOAD"_L1; case QStandardPaths::PublicShareLocation: - return QLatin1String("PUBLICSHARE"); + return "PUBLICSHARE"_L1; case QStandardPaths::TemplatesLocation: - return QLatin1String("TEMPLATES"); + return "TEMPLATES"_L1; default: - return QLatin1String(); + return {}; } } #endif @@ -217,9 +219,9 @@ QString QStandardPaths::writableLocation(StandardLocation type) // http://standards.freedesktop.org/basedir-spec/basedir-spec-0.6.html QString xdgCacheHome = QFile::decodeName(qgetenv("XDG_CACHE_HOME")); if (isTestModeEnabled()) - xdgCacheHome = QDir::homePath() + QLatin1String("/.qttest/cache"); + xdgCacheHome = QDir::homePath() + "/.qttest/cache"_L1; if (xdgCacheHome.isEmpty()) - xdgCacheHome = QDir::homePath() + QLatin1String("/.cache"); + xdgCacheHome = QDir::homePath() + "/.cache"_L1; if (type == QStandardPaths::CacheLocation) appendOrganizationAndApp(xdgCacheHome); return xdgCacheHome; @@ -230,9 +232,9 @@ QString QStandardPaths::writableLocation(StandardLocation type) { QString xdgDataHome = QFile::decodeName(qgetenv("XDG_DATA_HOME")); if (isTestModeEnabled()) - xdgDataHome = QDir::homePath() + QLatin1String("/.qttest/share"); + xdgDataHome = QDir::homePath() + "/.qttest/share"_L1; if (xdgDataHome.isEmpty()) - xdgDataHome = QDir::homePath() + QLatin1String("/.local/share"); + xdgDataHome = QDir::homePath() + "/.local/share"_L1; if (type == AppDataLocation || type == AppLocalDataLocation) appendOrganizationAndApp(xdgDataHome); return xdgDataHome; @@ -244,9 +246,9 @@ QString QStandardPaths::writableLocation(StandardLocation type) // http://standards.freedesktop.org/basedir-spec/latest/ QString xdgConfigHome = QFile::decodeName(qgetenv("XDG_CONFIG_HOME")); if (isTestModeEnabled()) - xdgConfigHome = QDir::homePath() + QLatin1String("/.qttest/config"); + xdgConfigHome = QDir::homePath() + "/.qttest/config"_L1; if (xdgConfigHome.isEmpty()) - xdgConfigHome = QDir::homePath() + QLatin1String("/.config"); + xdgConfigHome = QDir::homePath() + "/.config"_L1; if (type == AppConfigLocation) appendOrganizationAndApp(xdgConfigHome); return xdgConfigHome; @@ -259,7 +261,7 @@ QString QStandardPaths::writableLocation(StandardLocation type) // environment variable not set or is set to something unsuitable const uint myUid = uint(geteuid()); const QString userName = QFileSystemEngine::resolveUserName(myUid); - xdgRuntimeDir = QDir::tempPath() + QLatin1String("/runtime-") + userName; + xdgRuntimeDir = QDir::tempPath() + "/runtime-"_L1 + userName; if (!fromEnv) { #ifndef Q_OS_WASM @@ -281,13 +283,13 @@ QString QStandardPaths::writableLocation(StandardLocation type) // http://www.freedesktop.org/wiki/Software/xdg-user-dirs QString xdgConfigHome = QFile::decodeName(qgetenv("XDG_CONFIG_HOME")); if (xdgConfigHome.isEmpty()) - xdgConfigHome = QDir::homePath() + QLatin1String("/.config"); - QFile file(xdgConfigHome + QLatin1String("/user-dirs.dirs")); + xdgConfigHome = QDir::homePath() + "/.config"_L1; + QFile file(xdgConfigHome + "/user-dirs.dirs"_L1); const QLatin1String key = xdg_key_name(type); if (!key.isEmpty() && !isTestModeEnabled() && file.open(QIODevice::ReadOnly)) { QTextStream stream(&file); // Only look for lines like: XDG_DESKTOP_DIR="$HOME/Desktop" - QRegularExpression exp(QLatin1String("^XDG_(.*)_DIR=(.*)$")); + QRegularExpression exp("^XDG_(.*)_DIR=(.*)$"_L1); QString result; while (!stream.atEnd()) { const QString &line = stream.readLine(); @@ -295,15 +297,15 @@ QString QStandardPaths::writableLocation(StandardLocation type) if (match.hasMatch() && match.capturedView(1) == key) { QStringView value = match.capturedView(2); if (value.length() > 2 - && value.startsWith(QLatin1Char('\"')) - && value.endsWith(QLatin1Char('\"'))) + && value.startsWith(u'\"') + && value.endsWith(u'\"')) value = value.mid(1, value.length() - 2); // value can start with $HOME - if (value.startsWith(QLatin1String("$HOME"))) + if (value.startsWith("$HOME"_L1)) result = QDir::homePath() + value.mid(5); else result = value.toString(); - if (result.length() > 1 && result.endsWith(QLatin1Char('/'))) + if (result.length() > 1 && result.endsWith(u'/')) result.chop(1); } } @@ -315,39 +317,39 @@ QString QStandardPaths::writableLocation(StandardLocation type) QString path; switch (type) { case DesktopLocation: - path = QDir::homePath() + QLatin1String("/Desktop"); + path = QDir::homePath() + "/Desktop"_L1; break; case DocumentsLocation: - path = QDir::homePath() + QLatin1String("/Documents"); + path = QDir::homePath() + "/Documents"_L1; break; case PicturesLocation: - path = QDir::homePath() + QLatin1String("/Pictures"); + path = QDir::homePath() + "/Pictures"_L1; break; case FontsLocation: - path = writableLocation(GenericDataLocation) + QLatin1String("/fonts"); + path = writableLocation(GenericDataLocation) + "/fonts"_L1; break; case MusicLocation: - path = QDir::homePath() + QLatin1String("/Music"); + path = QDir::homePath() + "/Music"_L1; break; case MoviesLocation: - path = QDir::homePath() + QLatin1String("/Videos"); + path = QDir::homePath() + "/Videos"_L1; break; case DownloadLocation: - path = QDir::homePath() + QLatin1String("/Downloads"); + path = QDir::homePath() + "/Downloads"_L1; break; case ApplicationsLocation: - path = writableLocation(GenericDataLocation) + QLatin1String("/applications"); + path = writableLocation(GenericDataLocation) + "/applications"_L1; break; case PublicShareLocation: - path = QDir::homePath() + QLatin1String("/Public"); + path = QDir::homePath() + "/Public"_L1; break; case TemplatesLocation: - path = QDir::homePath() + QLatin1String("/Templates"); + path = QDir::homePath() + "/Templates"_L1; break; default: @@ -368,7 +370,7 @@ static QStringList xdgDataDirs() } else { // Normalize paths, skip relative paths for (const auto dir : qTokenize(xdgDataDirsEnv, u':')) { - if (dir.startsWith(QLatin1Char('/'))) + if (dir.startsWith(u'/')) dirs.push_back(QDir::cleanPath(dir.toString())); } @@ -391,7 +393,7 @@ static QStringList xdgConfigDirs() if (xdgConfigDirs.isEmpty()) dirs.append(QString::fromLatin1("/etc/xdg")); else - dirs = xdgConfigDirs.split(QLatin1Char(':')); + dirs = xdgConfigDirs.split(u':'); return dirs; } @@ -414,7 +416,7 @@ QStringList QStandardPaths::standardLocations(StandardLocation type) case ApplicationsLocation: dirs = xdgDataDirs(); for (int i = 0; i < dirs.count(); ++i) - dirs[i].append(QLatin1String("/applications")); + dirs[i].append("/applications"_L1); break; case AppDataLocation: case AppLocalDataLocation: @@ -423,10 +425,10 @@ QStringList QStandardPaths::standardLocations(StandardLocation type) appendOrganizationAndApp(dirs[i]); break; case FontsLocation: - dirs += QDir::homePath() + QLatin1String("/.fonts"); + dirs += QDir::homePath() + "/.fonts"_L1; dirs += xdgDataDirs(); for (int i = 1; i < dirs.count(); ++i) - dirs[i].append(QLatin1String("/fonts")); + dirs[i].append("/fonts"_L1); break; default: break; diff --git a/src/corelib/io/qstandardpaths_win.cpp b/src/corelib/io/qstandardpaths_win.cpp index d191ed33b4..1c404a06b3 100644 --- a/src/corelib/io/qstandardpaths_win.cpp +++ b/src/corelib/io/qstandardpaths_win.cpp @@ -55,6 +55,8 @@ QT_BEGIN_NAMESPACE +using namespace Qt::StringLiterals; + static QString convertCharArray(const wchar_t *path) { return QDir::fromNativeSeparators(QString::fromWCharArray(path)); @@ -77,10 +79,10 @@ static void appendOrganizationAndApp(QString &path) // Courtesy qstandardpaths_u #ifndef QT_BOOTSTRAPPED const QString &org = QCoreApplication::organizationName(); if (!org.isEmpty()) - path += QLatin1Char('/') + org; + path += u'/' + org; const QString &appName = QCoreApplication::applicationName(); if (!appName.isEmpty()) - path += QLatin1Char('/') + appName; + path += u'/' + appName; #else // !QT_BOOTSTRAPPED Q_UNUSED(path); #endif @@ -89,7 +91,7 @@ static void appendOrganizationAndApp(QString &path) // Courtesy qstandardpaths_u static inline void appendTestMode(QString &path) { if (QStandardPaths::isTestModeEnabled()) - path += QLatin1String("/qttest"); + path += "/qttest"_L1; } static bool isProcessLowIntegrity() @@ -197,7 +199,7 @@ QString QStandardPaths::writableLocation(StandardLocation type) if (!result.isEmpty()) { appendTestMode(result); appendOrganizationAndApp(result); - result += QLatin1String("/cache"); + result += "/cache"_L1; } break; @@ -205,7 +207,7 @@ QString QStandardPaths::writableLocation(StandardLocation type) result = sHGetKnownFolderPath(writableSpecialFolderId(GenericDataLocation)); if (!result.isEmpty()) { appendTestMode(result); - result += QLatin1String("/cache"); + result += "/cache"_L1; } break; @@ -256,7 +258,7 @@ QStringList QStandardPaths::standardLocations(StandardLocation type) QString applicationDirPath = qApp ? QCoreApplication::applicationDirPath() : QFileInfo(qAppFileName()).path(); dirs.append(applicationDirPath); - const QString dataDir = applicationDirPath + QLatin1String("/data"); + const QString dataDir = applicationDirPath + "/data"_L1; dirs.append(dataDir); if (!isGenericConfigLocation(type)) { diff --git a/src/corelib/io/qstorageinfo_unix.cpp b/src/corelib/io/qstorageinfo_unix.cpp index 2b635f63bb..380f3e3f4c 100644 --- a/src/corelib/io/qstorageinfo_unix.cpp +++ b/src/corelib/io/qstorageinfo_unix.cpp @@ -119,6 +119,8 @@ QT_BEGIN_NAMESPACE +using namespace Qt::StringLiterals; + class QStorageIterator { public: @@ -190,7 +192,7 @@ template <typename String> static bool isParentOf(const String &parent, const QString &dirName) { return dirName.startsWith(parent) && - (dirName.size() == parent.size() || dirName.at(parent.size()) == QLatin1Char('/') || + (dirName.size() == parent.size() || dirName.at(parent.size()) == u'/' || parent.size() == 1); } @@ -214,11 +216,11 @@ static bool shouldIncludeFs(const QStorageIterator &it) */ QString mountDir = it.rootPath(); - if (isParentOf(QLatin1String("/dev"), mountDir) - || isParentOf(QLatin1String("/proc"), mountDir) - || isParentOf(QLatin1String("/sys"), mountDir) - || isParentOf(QLatin1String("/var/run"), mountDir) - || isParentOf(QLatin1String("/var/lock"), mountDir)) { + if (isParentOf("/dev"_L1, mountDir) + || isParentOf("/proc"_L1, mountDir) + || isParentOf("/sys"_L1, mountDir) + || isParentOf("/var/run"_L1, mountDir) + || isParentOf("/var/lock"_L1, mountDir)) { return false; } @@ -767,8 +769,7 @@ static QString decodeFsEncString(const QString &str) int i = 0; while (i < str.size()) { if (i <= str.size() - 4) { // we need at least four characters \xAB - if (str.at(i) == QLatin1Char('\\') && - str.at(i+1) == QLatin1Char('x')) { + if (QStringView{str}.sliced(i).startsWith("\\x"_L1)) { bool bOk; const int code = QStringView{str}.mid(i+2, 2).toInt(&bOk, 16); // only decode characters between 0x20 and 0x7f but not diff --git a/src/corelib/io/qstorageinfo_win.cpp b/src/corelib/io/qstorageinfo_win.cpp index d594551425..e9929c9921 100644 --- a/src/corelib/io/qstorageinfo_win.cpp +++ b/src/corelib/io/qstorageinfo_win.cpp @@ -51,6 +51,8 @@ QT_BEGIN_NAMESPACE +using namespace Qt::StringLiterals; + static const int defaultBufferSize = MAX_PATH + 1; static QString canonicalPath(const QString &rootPath) @@ -59,16 +61,16 @@ static QString canonicalPath(const QString &rootPath) if (path.isEmpty()) return path; - if (path.startsWith(QLatin1String("\\\\?\\"))) + if (path.startsWith("\\\\?\\"_L1)) path.remove(0, 4); - if (path.length() < 2 || path.at(1) != QLatin1Char(':')) + if (path.length() < 2 || path.at(1) != u':') return QString(); path[0] = path[0].toUpper(); if (!(path.at(0).unicode() >= 'A' && path.at(0).unicode() <= 'Z')) return QString(); - if (!path.endsWith(QLatin1Char('\\'))) - path.append(QLatin1Char('\\')); + if (!path.endsWith(u'\\')) + path.append(u'\\'); return path; } diff --git a/src/corelib/io/qtemporarydir.cpp b/src/corelib/io/qtemporarydir.cpp index c9573182c4..d19896563d 100644 --- a/src/corelib/io/qtemporarydir.cpp +++ b/src/corelib/io/qtemporarydir.cpp @@ -61,6 +61,8 @@ QT_BEGIN_NAMESPACE +using namespace Qt::StringLiterals; + static_assert(std::is_nothrow_move_constructible_v<QTemporaryDir>); static_assert(std::is_nothrow_move_assignable_v<QTemporaryDir>); @@ -95,9 +97,9 @@ static QString defaultTemplateName() baseName = QCoreApplication::applicationName(); if (baseName.isEmpty()) #endif - baseName = QLatin1String("qt_temp"); + baseName = "qt_temp"_L1; - return QDir::tempPath() + QLatin1Char('/') + baseName + QLatin1String("-XXXXXX"); + return QDir::tempPath() + u'/' + baseName + "-XXXXXX"_L1; } void QTemporaryDirPrivate::create(const QString &templateName) @@ -302,7 +304,7 @@ QString QTemporaryDir::filePath(const QString &fileName) const QString ret = d_ptr->pathOrError; if (!fileName.isEmpty()) { - ret += QLatin1Char('/'); + ret += u'/'; ret += fileName; } return ret; @@ -347,7 +349,7 @@ bool QTemporaryDir::remove() if (!d_ptr->success) return false; Q_ASSERT(!path().isEmpty()); - Q_ASSERT(path() != QLatin1String(".")); + Q_ASSERT(path() != "."_L1); const bool result = QDir(path()).removeRecursively(); if (!result) { diff --git a/src/corelib/io/qtemporaryfile.cpp b/src/corelib/io/qtemporaryfile.cpp index 4b587857a8..21dd468c5f 100644 --- a/src/corelib/io/qtemporaryfile.cpp +++ b/src/corelib/io/qtemporaryfile.cpp @@ -59,6 +59,8 @@ QT_BEGIN_NAMESPACE +using namespace Qt::StringLiterals; + #if defined(Q_OS_WIN) typedef ushort Char; @@ -85,13 +87,13 @@ QTemporaryFileName::QTemporaryFileName(const QString &templateName) while (phPos != 0) { --phPos; - if (qfilename[phPos] == QLatin1Char('X')) { + if (qfilename[phPos] == u'X') { ++phLength; continue; } if (phLength >= 6 - || qfilename[phPos] == QLatin1Char('/')) { + || qfilename[phPos] == u'/') { ++phPos; break; } @@ -101,7 +103,7 @@ QTemporaryFileName::QTemporaryFileName(const QString &templateName) } if (phLength < 6) - qfilename.append(QLatin1String(".XXXXXX")); + qfilename.append(".XXXXXX"_L1); // "Nativify" :-) QFileSystemEntry::NativePath filename = QFileSystemEngine::absoluteName( @@ -576,9 +578,9 @@ QString QTemporaryFilePrivate::defaultTemplateName() baseName = QCoreApplication::applicationName(); if (baseName.isEmpty()) #endif - baseName = QLatin1String("qt_temp"); + baseName = "qt_temp"_L1; - return QDir::tempPath() + QLatin1Char('/') + baseName + QLatin1String(".XXXXXX"); + return QDir::tempPath() + u'/' + baseName + ".XXXXXX"_L1; } //************* QTemporaryFile diff --git a/src/corelib/io/qurl.cpp b/src/corelib/io/qurl.cpp index 08385c9629..9dc84094ce 100644 --- a/src/corelib/io/qurl.cpp +++ b/src/corelib/io/qurl.cpp @@ -439,6 +439,8 @@ QT_BEGIN_NAMESPACE +using namespace Qt::StringLiterals; + // in qstring.cpp: void qt_from_latin1(char16_t *dst, const char *str, size_t size) noexcept; @@ -833,7 +835,7 @@ static const ushort * const fragmentInUrl = userNameInUrl + 6; static inline void parseDecodedComponent(QString &data) { - data.replace(QLatin1Char('%'), QLatin1String("%25")); + data.replace(u'%', "%25"_L1); } static inline QString @@ -870,11 +872,11 @@ inline void QUrlPrivate::appendAuthority(QString &appendTo, QUrl::FormattingOpti // add '@' only if we added anything if (hasUserName() || (hasPassword() && (options & QUrl::RemovePassword) == 0)) - appendTo += QLatin1Char('@'); + appendTo += u'@'; } appendHost(appendTo, options); if (!(options & QUrl::RemovePort) && port != -1) - appendTo += QLatin1Char(':') + QString::number(port); + appendTo += u':' + QString::number(port); } inline void QUrlPrivate::appendUserInfo(QString &appendTo, QUrl::FormattingOptions options, Section appendingTo) const @@ -916,7 +918,7 @@ inline void QUrlPrivate::appendUserInfo(QString &appendTo, QUrl::FormattingOptio if (options & QUrl::RemovePassword || !hasPassword()) { return; } else { - appendTo += QLatin1Char(':'); + appendTo += u':'; if (!qt_urlRecode(appendTo, password, options, passwordActions)) appendTo += password; } @@ -945,14 +947,14 @@ inline void QUrlPrivate::appendPath(QString &appendTo, QUrl::FormattingOptions o QStringView thePathView(thePath); if (options & QUrl::RemoveFilename) { - const qsizetype slash = path.lastIndexOf(QLatin1Char('/')); + const qsizetype slash = path.lastIndexOf(u'/'); if (slash == -1) return; thePathView = QStringView{path}.left(slash + 1); } // check if we need to remove trailing slashes if (options & QUrl::StripTrailingSlash) { - while (thePathView.length() > 1 && thePathView.endsWith(QLatin1Char('/'))) + while (thePathView.length() > 1 && thePathView.endsWith(u'/')) thePathView.chop(1); } @@ -1048,7 +1050,7 @@ inline void QUrlPrivate::setAuthority(const QString &auth, qsizetype from, qsize // we never actually _loop_ while (from != end) { - qsizetype userInfoIndex = auth.indexOf(QLatin1Char('@'), from); + qsizetype userInfoIndex = auth.indexOf(u'@', from); if (size_t(userInfoIndex) < size_t(end)) { setUserInfo(auth, from, userInfoIndex); if (mode == QUrl::StrictMode && !validateComponent(UserInfo, auth, from, userInfoIndex)) @@ -1056,14 +1058,14 @@ inline void QUrlPrivate::setAuthority(const QString &auth, qsizetype from, qsize from = userInfoIndex + 1; } - qsizetype colonIndex = auth.lastIndexOf(QLatin1Char(':'), end - 1); + qsizetype colonIndex = auth.lastIndexOf(u':', end - 1); if (colonIndex < from) colonIndex = -1; if (size_t(colonIndex) < size_t(end)) { if (auth.at(from).unicode() == '[') { // check if colonIndex isn't inside the "[...]" part - qsizetype closingBracket = auth.indexOf(QLatin1Char(']'), from); + qsizetype closingBracket = auth.indexOf(u']', from); if (size_t(closingBracket) > size_t(colonIndex)) colonIndex = -1; } @@ -1111,7 +1113,7 @@ inline void QUrlPrivate::setAuthority(const QString &auth, qsizetype from, qsize inline void QUrlPrivate::setUserInfo(const QString &userInfo, qsizetype from, qsizetype end) { - qsizetype delimIndex = userInfo.indexOf(QLatin1Char(':'), from); + qsizetype delimIndex = userInfo.indexOf(u':', from); setUserName(userInfo, from, qMin<size_t>(delimIndex, end)); if (size_t(delimIndex) >= size_t(end)) { @@ -1248,7 +1250,7 @@ static const QChar *parseIpFuture(QString &host, const QChar *begin, const QChar else return decoded.isEmpty() ? begin : &origBegin[2]; } - host += QLatin1Char(']'); + host += u']'; return nullptr; } return &origBegin[2]; @@ -1290,14 +1292,14 @@ static const QChar *parseIp6(QString &host, const QChar *begin, const QChar *end return begin + (ret - decoded.constBegin()); host.reserve(host.size() + (end - begin) + 2); // +2 for the brackets - host += QLatin1Char('['); + host += u'['; QIPAddressUtils::toString(host, address); if (!zoneId.isEmpty()) { host += zoneIdIdentifier; host += zoneId; } - host += QLatin1Char(']'); + host += u']'; return nullptr; } @@ -1504,19 +1506,19 @@ QString QUrlPrivate::toLocalFile(QUrl::FormattingOptions options) const // magic for shared drive on windows if (!host.isEmpty()) { - tmp = QLatin1String("//") + host; + tmp = "//"_L1 + host; #ifdef Q_OS_WIN // QTBUG-42346, WebDAV is visible as local file on Windows only. if (scheme == webDavScheme()) tmp += webDavSslTag(); #endif - if (!ourPath.isEmpty() && !ourPath.startsWith(QLatin1Char('/'))) - tmp += QLatin1Char('/'); + if (!ourPath.isEmpty() && !ourPath.startsWith(u'/')) + tmp += u'/'; tmp += ourPath; } else { tmp = ourPath; #ifdef Q_OS_WIN // magic for drives on windows - if (ourPath.length() > 2 && ourPath.at(0) == QLatin1Char('/') && ourPath.at(2) == QLatin1Char(':')) + if (ourPath.length() > 2 && ourPath.at(0) == u'/' && ourPath.at(2) == u':') tmp.remove(0, 1); #endif } @@ -1537,7 +1539,7 @@ inline QString QUrlPrivate::mergePaths(const QString &relativePath) const // path, then return a string consisting of "/" concatenated with // the reference's path; otherwise, if (!host.isEmpty() && path.isEmpty()) - return QLatin1Char('/') + relativePath; + return u'/' + relativePath; // Return a string consisting of the reference's path component // appended to all but the last segment of the base URI's path @@ -1545,10 +1547,10 @@ inline QString QUrlPrivate::mergePaths(const QString &relativePath) const // base URI path, or excluding the entire base URI path if it does // not contain any "/" characters). QString newPath; - if (!path.contains(QLatin1Char('/'))) + if (!path.contains(u'/')) newPath = relativePath; else - newPath = QStringView{path}.left(path.lastIndexOf(QLatin1Char('/')) + 1) + relativePath; + newPath = QStringView{path}.left(path.lastIndexOf(u'/') + 1) + relativePath; return newPath; } @@ -1594,7 +1596,7 @@ static void removeDotsFromPath(QString *path) in += 2; continue; } else if (in == end - 2 && in[0].unicode() == '/' && in[1].unicode() == '.') { - *out++ = QLatin1Char('/'); + *out++ = u'/'; in += 2; break; } @@ -1661,8 +1663,8 @@ inline QUrlPrivate::ErrorCode QUrlPrivate::validityError(QString *source, qsizet if (path.isEmpty()) return NoError; - if (path.at(0) == QLatin1Char('/')) { - if (hasAuthority() || path.length() == 1 || path.at(1) != QLatin1Char('/')) + if (path.at(0) == u'/') { + if (hasAuthority() || path.length() == 1 || path.at(1) != u'/') return NoError; if (source) { *source = path; @@ -1779,7 +1781,7 @@ inline void QUrlPrivate::validate() const if (!isHostValid) return; - if (scheme == QLatin1String("mailto")) { + if (scheme == "mailto"_L1) { if (!host.isEmpty() || port != -1 || !userName.isEmpty() || !password.isEmpty()) { that->isValid = false; that->errorInfo.setParams(0, QT_TRANSLATE_NOOP(QUrl, "expected empty host, username," @@ -2321,15 +2323,15 @@ void QUrl::setHost(const QString &host, ParsingMode mode) if (d->setHost(data, 0, data.length(), mode)) { if (host.isNull()) d->sectionIsPresent &= ~QUrlPrivate::Host; - } else if (!data.startsWith(QLatin1Char('['))) { + } else if (!data.startsWith(u'[')) { // setHost failed, it might be IPv6 or IPvFuture in need of bracketing Q_ASSERT(d->error); - data.prepend(QLatin1Char('[')); - data.append(QLatin1Char(']')); + data.prepend(u'['); + data.append(u']'); if (!d->setHost(data, 0, data.length(), mode)) { // failed again - if (data.contains(QLatin1Char(':'))) { + if (data.contains(u':')) { // source data contains ':', so it's an IPv6 error d->error->code = QUrlPrivate::InvalidIPv6AddressError; } @@ -2363,7 +2365,7 @@ QString QUrl::host(ComponentFormattingOptions options) const QString result; if (d) { d->appendHost(result, options); - if (result.startsWith(QLatin1Char('['))) + if (result.startsWith(u'[')) result = result.mid(1, result.length() - 2); } return result; @@ -2518,7 +2520,7 @@ QString QUrl::path(ComponentFormattingOptions options) const QString QUrl::fileName(ComponentFormattingOptions options) const { const QString ourPath = path(options); - const qsizetype slash = ourPath.lastIndexOf(QLatin1Char('/')); + const qsizetype slash = ourPath.lastIndexOf(u'/'); if (slash == -1) return ourPath; return ourPath.mid(slash + 1); @@ -2776,7 +2778,7 @@ QUrl QUrl::resolved(const QUrl &relative) const t.d->sectionIsPresent |= QUrlPrivate::Query; } } else { - t.d->path = relative.d->path.startsWith(QLatin1Char('/')) + t.d->path = relative.d->path.startsWith(u'/') ? relative.d->path : d->mergePaths(relative.d->path); if (relative.d->hasQuery()) { @@ -2883,26 +2885,26 @@ QString QUrl::toString(FormattingOptions options) const options |= EncodeReserved; if (!(options & QUrl::RemoveScheme) && d->hasScheme()) - url += d->scheme + QLatin1Char(':'); + url += d->scheme + u':'; - bool pathIsAbsolute = d->path.startsWith(QLatin1Char('/')); + bool pathIsAbsolute = d->path.startsWith(u'/'); if (!((options & QUrl::RemoveAuthority) == QUrl::RemoveAuthority) && d->hasAuthority()) { - url += QLatin1String("//"); + url += "//"_L1; d->appendAuthority(url, options, QUrlPrivate::FullUrl); } else if (isLocalFile() && pathIsAbsolute) { // Comply with the XDG file URI spec, which requires triple slashes. - url += QLatin1String("//"); + url += "//"_L1; } if (!(options & QUrl::RemovePath)) d->appendPath(url, options, QUrlPrivate::FullUrl); if (!(options & QUrl::RemoveQuery) && d->hasQuery()) { - url += QLatin1Char('?'); + url += u'?'; d->appendQuery(url, options, QUrlPrivate::FullUrl); } if (!(options & QUrl::RemoveFragment) && d->hasFragment()) { - url += QLatin1Char('#'); + url += u'#'; d->appendFragment(url, options, QUrlPrivate::FullUrl); } @@ -3380,11 +3382,11 @@ QUrl QUrl::fromLocalFile(const QString &localFile) QString deslashified = fromNativeSeparators(localFile); // magic for drives on windows - if (deslashified.length() > 1 && deslashified.at(1) == QLatin1Char(':') && deslashified.at(0) != QLatin1Char('/')) { - deslashified.prepend(QLatin1Char('/')); - } else if (deslashified.startsWith(QLatin1String("//"))) { + if (deslashified.length() > 1 && deslashified.at(1) == u':' && deslashified.at(0) != u'/') { + deslashified.prepend(u'/'); + } else if (deslashified.startsWith("//"_L1)) { // magic for shared drive on windows - qsizetype indexOfPath = deslashified.indexOf(QLatin1Char('/'), 2); + qsizetype indexOfPath = deslashified.indexOf(u'/', 2); QStringView hostSpec = QStringView{deslashified}.mid(2, indexOfPath - 2); // Check for Windows-specific WebDAV specification: "//host@SSL/path". if (hostSpec.endsWith(webDavSslTag(), Qt::CaseInsensitive)) { @@ -3465,16 +3467,16 @@ bool QUrl::isParentOf(const QUrl &childUrl) const if (!d) return ((childUrl.scheme().isEmpty()) && (childUrl.authority().isEmpty()) - && childPath.length() > 0 && childPath.at(0) == QLatin1Char('/')); + && childPath.length() > 0 && childPath.at(0) == u'/'); QString ourPath = path(); return ((childUrl.scheme().isEmpty() || d->scheme == childUrl.scheme()) && (childUrl.authority().isEmpty() || authority() == childUrl.authority()) && childPath.startsWith(ourPath) - && ((ourPath.endsWith(QLatin1Char('/')) && childPath.length() > ourPath.length()) - || (!ourPath.endsWith(QLatin1Char('/')) - && childPath.length() > ourPath.length() && childPath.at(ourPath.length()) == QLatin1Char('/')))); + && ((ourPath.endsWith(u'/') && childPath.length() > ourPath.length()) + || (!ourPath.endsWith(u'/') && childPath.length() > ourPath.length() + && childPath.at(ourPath.length()) == u'/'))); } @@ -3533,21 +3535,21 @@ static QString errorMessage(QUrlPrivate::ErrorCode errorCode, const QString &err return QString(); case QUrlPrivate::InvalidSchemeError: { - auto msg = QLatin1String("Invalid scheme (character '%1' not permitted)"); + auto msg = "Invalid scheme (character '%1' not permitted)"_L1; return msg.arg(c); } case QUrlPrivate::InvalidUserNameError: - return QLatin1String("Invalid user name (character '%1' not permitted)") + return "Invalid user name (character '%1' not permitted)"_L1 .arg(c); case QUrlPrivate::InvalidPasswordError: - return QLatin1String("Invalid password (character '%1' not permitted)") + return "Invalid password (character '%1' not permitted)"_L1 .arg(c); case QUrlPrivate::InvalidRegNameError: if (errorPosition >= 0) - return QLatin1String("Invalid hostname (character '%1' not permitted)") + return "Invalid hostname (character '%1' not permitted)"_L1 .arg(c); else return QStringLiteral("Invalid hostname (contains invalid characters)"); @@ -3556,9 +3558,9 @@ static QString errorMessage(QUrlPrivate::ErrorCode errorCode, const QString &err case QUrlPrivate::InvalidIPv6AddressError: return QStringLiteral("Invalid IPv6 address"); case QUrlPrivate::InvalidCharacterInIPv6Error: - return QLatin1String("Invalid IPv6 address (character '%1' not permitted)").arg(c); + return "Invalid IPv6 address (character '%1' not permitted)"_L1.arg(c); case QUrlPrivate::InvalidIPvFutureError: - return QLatin1String("Invalid IPvFuture address (character '%1' not permitted)").arg(c); + return "Invalid IPvFuture address (character '%1' not permitted)"_L1.arg(c); case QUrlPrivate::HostMissingEndBracket: return QStringLiteral("Expected ']' to match '[' in hostname"); @@ -3568,15 +3570,15 @@ static QString errorMessage(QUrlPrivate::ErrorCode errorCode, const QString &err return QStringLiteral("Port field was empty"); case QUrlPrivate::InvalidPathError: - return QLatin1String("Invalid path (character '%1' not permitted)") + return "Invalid path (character '%1' not permitted)"_L1 .arg(c); case QUrlPrivate::InvalidQueryError: - return QLatin1String("Invalid query (character '%1' not permitted)") + return "Invalid query (character '%1' not permitted)"_L1 .arg(c); case QUrlPrivate::InvalidFragmentError: - return QLatin1String("Invalid fragment (character '%1' not permitted)") + return "Invalid fragment (character '%1' not permitted)"_L1 .arg(c); case QUrlPrivate::AuthorityPresentAndPathIsRelative: @@ -3597,9 +3599,9 @@ static inline void appendComponentIfPresent(QString &msg, bool present, const ch { if (present) { msg += QLatin1String(componentName); - msg += QLatin1Char('"'); + msg += u'"'; msg += component; - msg += QLatin1String("\","); + msg += "\","_L1; } } @@ -3629,9 +3631,9 @@ QString QUrl::errorString() const return msg; msg += errorMessage(errorCode, errorSource, errorPosition); - msg += QLatin1String("; source was \""); + msg += "; source was \""_L1; msg += errorSource; - msg += QLatin1String("\";"); + msg += "\";"_L1; appendComponentIfPresent(msg, d->sectionIsPresent & QUrlPrivate::Scheme, " scheme = ", d->scheme); appendComponentIfPresent(msg, d->sectionIsPresent & QUrlPrivate::UserInfo, @@ -3646,7 +3648,7 @@ QString QUrl::errorString() const " query = ", d->query); appendComponentIfPresent(msg, d->sectionIsPresent & QUrlPrivate::Fragment, " fragment = ", d->fragment); - if (msg.endsWith(QLatin1Char(','))) + if (msg.endsWith(u',')) msg.chop(1); return msg; } @@ -3717,8 +3719,8 @@ static QUrl adjustFtpPath(QUrl url) { if (url.scheme() == ftpScheme()) { QString path = url.path(QUrl::PrettyDecoded); - if (path.startsWith(QLatin1String("//"))) - url.setPath(QLatin1String("/%2F") + QStringView{path}.mid(2), QUrl::TolerantMode); + if (path.startsWith("//"_L1)) + url.setPath("/%2F"_L1 + QStringView{path}.mid(2), QUrl::TolerantMode); } return url; } @@ -3803,7 +3805,7 @@ QUrl QUrl::fromUserInput(const QString &userInput, const QString &workingDirecto if (QDir::isAbsolutePath(trimmedString)) return QUrl::fromLocalFile(trimmedString); - QUrl urlPrepended = QUrl(QLatin1String("http://") + trimmedString, QUrl::TolerantMode); + QUrl urlPrepended = QUrl("http://"_L1 + trimmedString, QUrl::TolerantMode); // Check the most common case of a valid url with a scheme // We check if the port would be valid by adding the scheme to handle the case host:port @@ -3815,7 +3817,7 @@ QUrl QUrl::fromUserInput(const QString &userInput, const QString &workingDirecto // Else, try the prepended one and adjust the scheme from the host name if (urlPrepended.isValid() && (!urlPrepended.host().isEmpty() || !urlPrepended.path().isEmpty())) { - qsizetype dotIndex = trimmedString.indexOf(QLatin1Char('.')); + qsizetype dotIndex = trimmedString.indexOf(u'.'); const QStringView hostscheme = QStringView{trimmedString}.left(dotIndex); if (hostscheme.compare(ftpScheme(), Qt::CaseInsensitive) == 0) urlPrepended.setScheme(ftpScheme()); diff --git a/src/corelib/io/qurlidna.cpp b/src/corelib/io/qurlidna.cpp index 14208f98ee..170475ce61 100644 --- a/src/corelib/io/qurlidna.cpp +++ b/src/corelib/io/qurlidna.cpp @@ -50,6 +50,8 @@ QT_BEGIN_NAMESPACE +using namespace Qt::StringLiterals; + // needed by the punycode encoder/decoder static const uint base = 36; static const uint tmin = 1; @@ -137,7 +139,7 @@ Q_AUTOTEST_EXPORT void qt_punycodeEncoder(QStringView in, QString *output) // if basic code points were copied, add the delimiter character. if (h > 0) - *output += QLatin1Char{'-'}; + *output += u'-'; // compute the input length in Unicode code points. uint inputLength = 0; @@ -198,7 +200,7 @@ Q_AUTOTEST_EXPORT void qt_punycodeEncoder(QStringView in, QString *output) } // prepend ACE prefix - output->insert(outLen, QLatin1String("xn--")); + output->insert(outLen, "xn--"_L1); return; } @@ -215,13 +217,13 @@ Q_AUTOTEST_EXPORT QString qt_punycodeDecoder(const QString &pc) return QString(); // strip any ACE prefix - int start = pc.startsWith(QLatin1String("xn--")) ? 4 : 0; + int start = pc.startsWith("xn--"_L1) ? 4 : 0; if (!start) return pc; // find the last delimiter character '-' in the input array. copy // all data before this delimiter directly to the output array. - int delimiterPos = pc.lastIndexOf(QLatin1Char{'-'}); + int delimiterPos = pc.lastIndexOf(u'-'); auto output = delimiterPos < 4 ? std::u32string() : pc.mid(start, delimiterPos - start).toStdU32String(); @@ -383,7 +385,7 @@ static bool equal(const QChar *a, int l, const char *b) static bool qt_is_idn_enabled(QStringView aceDomain) { - auto idx = aceDomain.lastIndexOf(QLatin1Char('.')); + auto idx = aceDomain.lastIndexOf(u'.'); if (idx == -1) return false; @@ -747,14 +749,14 @@ bool DomainValidityChecker::checkLabel(const QString &label, QUrl::AceProcessing // This assumes that the first two characters are in BMP, but that's ok // because non-BMP characters are unlikely to be used for specifying // future extensions. - if (label[2] == QLatin1Char('-') && label[3] == QLatin1Char('-')) + if (label[2] == u'-' && label[3] == u'-') return false; } - if (label.startsWith(QLatin1Char('-')) || label.endsWith(QLatin1Char('-'))) + if (label.startsWith(u'-') || label.endsWith(u'-')) return false; - if (label.contains(QLatin1Char('.'))) + if (label.contains(u'.')) return false; QStringIterator iter(label); @@ -871,7 +873,7 @@ static bool checkAsciiDomainName(const QString &normalizedDomain, AceLeadingDot if (!validateAsciiLabel(label)) return false; - hasPunycode = hasPunycode || label.startsWith(QLatin1String("xn--")); + hasPunycode = hasPunycode || label.startsWith("xn--"_L1); } lastIdx = idx + 1; diff --git a/src/corelib/io/qwindowspipereader.cpp b/src/corelib/io/qwindowspipereader.cpp index 4435a47cab..8411697a87 100644 --- a/src/corelib/io/qwindowspipereader.cpp +++ b/src/corelib/io/qwindowspipereader.cpp @@ -45,6 +45,8 @@ QT_BEGIN_NAMESPACE +using namespace Qt::StringLiterals; + static const DWORD minReadBufferSize = 4096; QWindowsPipeReader::QWindowsPipeReader(QObject *parent) @@ -493,7 +495,7 @@ bool QWindowsPipeReader::consumePendingAndEmit(bool allowWinActPosting) if (emitReadyRead) emit readyRead(); if (alive && dwError != ERROR_BROKEN_PIPE && dwError != ERROR_PIPE_NOT_CONNECTED) - emit winError(dwError, QLatin1String("QWindowsPipeReader::consumePendingAndEmit")); + emit winError(dwError, "QWindowsPipeReader::consumePendingAndEmit"_L1); if (alive) emit pipeClosed(); } |