summaryrefslogtreecommitdiffstats
path: root/src/corelib
diff options
context:
space:
mode:
Diffstat (limited to 'src/corelib')
-rw-r--r--src/corelib/Qt5AndroidSupport.cmake5
-rw-r--r--src/corelib/doc/src/dontdocument.qdoc2
-rw-r--r--src/corelib/doc/src/resource-system.qdoc19
-rw-r--r--src/corelib/global/qfloat16.cpp44
-rw-r--r--src/corelib/io/qloggingregistry.cpp40
-rw-r--r--src/corelib/io/qloggingregistry_p.h8
-rw-r--r--src/corelib/io/qprocess.cpp9
-rw-r--r--src/corelib/io/qresource.cpp2
-rw-r--r--src/corelib/kernel/qmetatype.cpp4
-rw-r--r--src/corelib/mimetypes/mimetypes.pri7
-rw-r--r--src/corelib/text/qbytearray.h8
-rw-r--r--src/corelib/text/qstring.cpp40
-rw-r--r--src/corelib/text/qstring.h15
-rw-r--r--src/corelib/text/qstringview.cpp26
-rw-r--r--src/corelib/text/qstringview.h5
15 files changed, 162 insertions, 72 deletions
diff --git a/src/corelib/Qt5AndroidSupport.cmake b/src/corelib/Qt5AndroidSupport.cmake
index 5f24fb0e8c..4db38f3957 100644
--- a/src/corelib/Qt5AndroidSupport.cmake
+++ b/src/corelib/Qt5AndroidSupport.cmake
@@ -18,6 +18,8 @@ if (NOT ${PROJECT_NAME}-MultiAbiBuild)
option(ANDROID_BUILD_ABI_${abi} "Enable the build for Android ${abi}" ${abi_initial_value})
endif()
endforeach()
+ option(ANDROID_MIN_SDK_VERSION "Android minimum SDK version" "21")
+ option(ANDROID_TARGET_SDK_VERSION "Android target SDK version" "28")
# Make sure to delete the "android-build" directory, which contains all the
# build artefacts, and also the androiddeployqt/gradle artefacts
@@ -101,6 +103,9 @@ if (NOT ${PROJECT_NAME}-MultiAbiBuild)
generate_json_variable(ANDROID_VERSION_NAME "android-version-name")
generate_json_variable_list(ANDROID_EXTRA_LIBS "android-extra-libs")
generate_json_variable_list(QML_IMPORT_PATH "qml-import-paths")
+ generate_json_variable_list(ANDROID_MIN_SDK_VERSION "android-min-sdk-version")
+ generate_json_variable_list(ANDROID_TARGET_SDK_VERSION "android-target-sdk-version")
+
configure_file(
"${CMAKE_BINARY_DIR}/android_deployment_settings.json.in"
diff --git a/src/corelib/doc/src/dontdocument.qdoc b/src/corelib/doc/src/dontdocument.qdoc
index b1af82fbe2..c84b789c46 100644
--- a/src/corelib/doc/src/dontdocument.qdoc
+++ b/src/corelib/doc/src/dontdocument.qdoc
@@ -34,7 +34,7 @@
QMetaTypeId2 QObjectData QObjectUserData QMapNodeBase QMapNode QMapDataBase
QMapData QHashData QHashNode QArrayDataPointer QTextStreamManipulator
QContiguousCacheData QContiguousCacheTypedData QNoDebug QUrlTwoFlags
- QCborValueRef qfloat16 QDeferredDeleteEvent QSpecialInteger QLittleEndianStorageType
+ QCborValueRef QDeferredDeleteEvent QSpecialInteger QLittleEndianStorageType
QBigEndianStorageType QFactoryInterface QFutureWatcherBase QJsonValuePtr
QJsonValueRefPtr QAbstractConcatenable QStringBuilderCommon
QTextCodec::ConverterState QThreadStorageData QTextStreamManipulator)
diff --git a/src/corelib/doc/src/resource-system.qdoc b/src/corelib/doc/src/resource-system.qdoc
index f9ef317799..6ff10804f5 100644
--- a/src/corelib/doc/src/resource-system.qdoc
+++ b/src/corelib/doc/src/resource-system.qdoc
@@ -179,6 +179,17 @@
rcc -compress 2 -compress-algo zlib myresources.qrc
\endcode
+ It is also possible to use \c threshold, \c compress, and \c compress-algo
+ as attributes in a .qrc \c file tag.
+
+ \code
+ <qresource>
+ <file compress="1" compress-algo="zstd">data.txt</file>
+ </qresource>
+ \endcode
+
+ The above will select the \c zstd algorithm with compression level 1.
+
\c rcc supports the following compression algorithms and compression
levels:
@@ -196,10 +207,10 @@
library to choose an implementation-defined default.
\li \c{zlib}: use the \l{https://zlib.net}{zlib} library to compress
- contents. Valid compression levels range from 1 to 9, with 1the least
- compression (least CPU time) and 9 the most compression (most CPU time).
- The special value 0 means "no compression" and should not be used. The
- default is implementation-defined, but usually is level 6.
+ contents. Valid compression levels range from 1 to 9, with 1 applying
+ the least compression (least CPU time) and 9 the most compression (most
+ CPU time). The special value 0 means "no compression" and should not be
+ used. The default is implementation-defined, but usually is level 6.
\li \c{none}: no compression. This is the same as the \c{-no-compress}
option.
diff --git a/src/corelib/global/qfloat16.cpp b/src/corelib/global/qfloat16.cpp
index 3d82bbe95a..1f06b10313 100644
--- a/src/corelib/global/qfloat16.cpp
+++ b/src/corelib/global/qfloat16.cpp
@@ -45,18 +45,20 @@
QT_BEGIN_NAMESPACE
/*!
- \headerfile <QFloat16>
- \title 16-bit Floating Point Support
+ \class qfloat16
+ \keyword 16-bit Floating Point Support
\ingroup funclists
- \brief The <QFloat16> header file provides 16-bit floating point support.
-
- This header file provides support for half-precision (16-bit) floating
- point data with the class \c qfloat16. It is fully compliant with IEEE
- 754 as a storage type. This implies that any arithmetic operation on a
- \c qfloat16 instance results in the value first being converted to a
- \c float. This conversion to and from \c float is performed by hardware
- when possible, but on processors that do not natively support half-precision,
- the conversion is performed through a sequence of lookup table operations.
+ \inmodule QtCore
+ \inheaderfile QFloat16
+ \brief Provides 16-bit floating point support.
+
+ The \c qfloat16 class provides support for half-precision (16-bit) floating
+ point data. It is fully compliant with IEEE 754 as a storage type. This
+ implies that any arithmetic operation on a \c qfloat16 instance results in
+ the value first being converted to a \c float. This conversion to and from
+ \c float is performed by hardware when possible, but on processors that do
+ not natively support half-precision, the conversion is performed through a
+ sequence of lookup table operations.
\c qfloat16 should be treated as if it were a POD (plain old data) type.
Consequently, none of the supported operations need any elaboration beyond
@@ -68,7 +70,7 @@ QT_BEGIN_NAMESPACE
/*!
\macro QT_NO_FLOAT16_OPERATORS
- \relates <QFloat16>
+ \relates qfloat16
\since 5.12.4
Defining this macro disables the arithmetic operators for qfloat16.
@@ -81,7 +83,7 @@ QT_BEGIN_NAMESPACE
/*!
\fn bool qIsInf(qfloat16 f)
- \relates <QFloat16>
+ \relates qfloat16
Returns true if the \c qfloat16 \a {f} is equivalent to infinity.
@@ -90,7 +92,7 @@ QT_BEGIN_NAMESPACE
/*!
\fn bool qIsNaN(qfloat16 f)
- \relates <QFloat16>
+ \relates qfloat16
Returns true if the \c qfloat16 \a {f} is not a number (NaN).
@@ -99,7 +101,7 @@ QT_BEGIN_NAMESPACE
/*!
\fn bool qIsFinite(qfloat16 f)
- \relates <QFloat16>
+ \relates qfloat16
Returns true if the \c qfloat16 \a {f} is a finite number.
@@ -130,7 +132,7 @@ QT_BEGIN_NAMESPACE
\since 5.14
\fn bool qfloat16::isNormal() const noexcept
- Tests whether this \c qfloat16 value is finite and in normal form.
+ Returns \c true if this \c qfloat16 value is finite and in normal form.
\sa qFpClassify()
*/
@@ -167,7 +169,7 @@ int qfloat16::fpClassify() const noexcept
}
/*! \fn int qRound(qfloat16 value)
- \relates <QFloat16>
+ \relates qfloat16
Rounds \a value to the nearest integer.
@@ -175,7 +177,7 @@ int qfloat16::fpClassify() const noexcept
*/
/*! \fn qint64 qRound64(qfloat16 value)
- \relates <QFloat16>
+ \relates qfloat16
Rounds \a value to the nearest 64-bit integer.
@@ -183,7 +185,7 @@ int qfloat16::fpClassify() const noexcept
*/
/*! \fn bool qFuzzyCompare(qfloat16 p1, qfloat16 p2)
- \relates <QFloat16>
+ \relates qfloat16
Compares the floating point value \a p1 and \a p2 and
returns \c true if they are considered equal, otherwise \c false.
@@ -256,7 +258,7 @@ static void qFloatFromFloat16_fast(float *, const quint16 *, qsizetype) noexcept
#endif
/*!
\since 5.11
- \relates <QFloat16>
+ \relates qfloat16
Converts \a len floats from \a in to qfloat16 and stores them in \a out.
Both \a in and \a out must have \a len allocated entries.
@@ -272,7 +274,7 @@ Q_CORE_EXPORT void qFloatToFloat16(qfloat16 *out, const float *in, qsizetype len
/*!
\since 5.11
- \relates <QFloat16>
+ \relates qfloat16
Converts \a len qfloat16 from \a in to floats and stores them in \a out.
Both \a in and \a out must have \a len allocated entries.
diff --git a/src/corelib/io/qloggingregistry.cpp b/src/corelib/io/qloggingregistry.cpp
index e8eb18b4c1..cacebfbda6 100644
--- a/src/corelib/io/qloggingregistry.cpp
+++ b/src/corelib/io/qloggingregistry.cpp
@@ -75,7 +75,7 @@ QLoggingRule::QLoggingRule() :
\internal
Constructs a logging rule.
*/
-QLoggingRule::QLoggingRule(const QStringRef &pattern, bool enabled) :
+QLoggingRule::QLoggingRule(QStringView pattern, bool enabled) :
messageType(-1),
enabled(enabled)
{
@@ -87,7 +87,7 @@ QLoggingRule::QLoggingRule(const QStringRef &pattern, bool enabled) :
Return value 1 means filter passed, 0 means filter doesn't influence this
category, -1 means category doesn't pass this filter.
*/
-int QLoggingRule::pass(const QString &cat, QtMsgType msgType) const
+int QLoggingRule::pass(QLatin1String cat, QtMsgType msgType) const
{
// check message type
if (messageType > -1 && messageType != msgType)
@@ -113,7 +113,7 @@ int QLoggingRule::pass(const QString &cat, QtMsgType msgType) const
return (enabled ? 1 : -1);
} else if (flags == RightFilter) {
// matches right
- if (idx == (cat.count() - category.count()))
+ if (idx == (cat.size() - category.count()))
return (enabled ? 1 : -1);
}
}
@@ -129,26 +129,22 @@ int QLoggingRule::pass(const QString &cat, QtMsgType msgType) const
*.io.warning RightFilter, QtWarningMsg
*.core.* MidFilter
*/
-void QLoggingRule::parse(const QStringRef &pattern)
+void QLoggingRule::parse(QStringView pattern)
{
- QStringRef p;
+ QStringView p;
// strip trailing ".messagetype"
if (pattern.endsWith(QLatin1String(".debug"))) {
- p = QStringRef(pattern.string(), pattern.position(),
- pattern.length() - 6); // strlen(".debug")
+ p = pattern.chopped(6); // strlen(".debug")
messageType = QtDebugMsg;
} else if (pattern.endsWith(QLatin1String(".info"))) {
- p = QStringRef(pattern.string(), pattern.position(),
- pattern.length() - 5); // strlen(".info")
+ p = pattern.chopped(5); // strlen(".info")
messageType = QtInfoMsg;
} else if (pattern.endsWith(QLatin1String(".warning"))) {
- p = QStringRef(pattern.string(), pattern.position(),
- pattern.length() - 8); // strlen(".warning")
+ p = pattern.chopped(8); // strlen(".warning")
messageType = QtWarningMsg;
} else if (pattern.endsWith(QLatin1String(".critical"))) {
- p = QStringRef(pattern.string(), pattern.position(),
- pattern.length() - 9); // strlen(".critical")
+ p = pattern.chopped(9); // strlen(".critical")
messageType = QtCriticalMsg;
} else {
p = pattern;
@@ -159,11 +155,11 @@ void QLoggingRule::parse(const QStringRef &pattern)
} else {
if (p.endsWith(QLatin1Char('*'))) {
flags |= LeftFilter;
- p = QStringRef(p.string(), p.position(), p.length() - 1);
+ p = p.chopped(1);
}
if (p.startsWith(QLatin1Char('*'))) {
flags |= RightFilter;
- p = QStringRef(p.string(), p.position() + 1, p.length() - 1);
+ p = p.mid(1);
}
if (p.contains(QLatin1Char('*'))) // '*' only supported at start/end
flags = PatternFlags();
@@ -208,7 +204,7 @@ void QLoggingSettingsParser::setContent(QTextStream &stream)
_rules.clear();
QString line;
while (stream.readLineInto(&line))
- parseNextLine(QStringRef(&line));
+ parseNextLine(qToStringViewIgnoringNull(line));
}
/*!
@@ -216,7 +212,7 @@ void QLoggingSettingsParser::setContent(QTextStream &stream)
Parses one line of the configuation file
*/
-void QLoggingSettingsParser::parseNextLine(QStringRef line)
+void QLoggingSettingsParser::parseNextLine(QStringView line)
{
// Remove whitespace at start and end of line:
line = line.trimmed();
@@ -227,7 +223,7 @@ void QLoggingSettingsParser::parseNextLine(QStringRef line)
if (line.startsWith(QLatin1Char('[')) && line.endsWith(QLatin1Char(']'))) {
// new section
- auto sectionName = line.mid(1, line.size() - 2).trimmed();
+ auto sectionName = line.mid(1).chopped(1).trimmed();
m_inRulesSection = sectionName.compare(QLatin1String("rules"), Qt::CaseInsensitive) == 0;
return;
}
@@ -240,9 +236,9 @@ void QLoggingSettingsParser::parseNextLine(QStringRef line)
#if QT_CONFIG(settings)
QString tmp;
QSettingsPrivate::iniUnescapedKey(key.toUtf8(), 0, key.length(), tmp);
- QStringRef pattern = QStringRef(&tmp, 0, tmp.length());
+ QStringView pattern = qToStringViewIgnoringNull(tmp);
#else
- QStringRef pattern = key;
+ QStringView pattern = key;
#endif
const auto valueStr = line.mid(equalPos + 1).trimmed();
int value = -1;
@@ -252,7 +248,7 @@ void QLoggingSettingsParser::parseNextLine(QStringRef line)
value = 0;
QLoggingRule rule(pattern, (value == 1));
if (rule.flags != 0 && (value != -1))
- _rules.append(rule);
+ _rules.append(std::move(rule));
else
warnMsg("Ignoring malformed logging rule: '%s'", line.toUtf8().constData());
} else {
@@ -460,7 +456,7 @@ void QLoggingRegistry::defaultCategoryFilter(QLoggingCategory *cat)
debug = false;
}
- QString categoryName = QLatin1String(cat->categoryName());
+ const auto categoryName = QLatin1String(cat->categoryName());
for (const auto &ruleSet : reg->ruleSets) {
for (const auto &rule : ruleSet) {
diff --git a/src/corelib/io/qloggingregistry_p.h b/src/corelib/io/qloggingregistry_p.h
index 12a1f166b3..3ac429b147 100644
--- a/src/corelib/io/qloggingregistry_p.h
+++ b/src/corelib/io/qloggingregistry_p.h
@@ -67,8 +67,8 @@ class Q_AUTOTEST_EXPORT QLoggingRule
{
public:
QLoggingRule();
- QLoggingRule(const QStringRef &pattern, bool enabled);
- int pass(const QString &categoryName, QtMsgType type) const;
+ QLoggingRule(QStringView pattern, bool enabled);
+ int pass(QLatin1String categoryName, QtMsgType type) const;
enum PatternFlag {
FullText = 0x1,
@@ -84,7 +84,7 @@ public:
bool enabled;
private:
- void parse(const QStringRef &pattern);
+ void parse(QStringView pattern);
};
Q_DECLARE_OPERATORS_FOR_FLAGS(QLoggingRule::PatternFlags)
@@ -101,7 +101,7 @@ public:
QVector<QLoggingRule> rules() const { return _rules; }
private:
- void parseNextLine(QStringRef line);
+ void parseNextLine(QStringView line);
private:
bool m_inRulesSection = false;
diff --git a/src/corelib/io/qprocess.cpp b/src/corelib/io/qprocess.cpp
index 3b708d7727..1f4be24913 100644
--- a/src/corelib/io/qprocess.cpp
+++ b/src/corelib/io/qprocess.cpp
@@ -2475,12 +2475,11 @@ int QProcess::execute(const QString &program, const QStringList &arguments)
*/
int QProcess::execute(const QString &command)
{
- QProcess process;
- process.setProcessChannelMode(ForwardedChannels);
- process.start(command);
- if (!process.waitForFinished(-1) || process.error() == FailedToStart)
+ QStringList args = splitCommand(command);
+ if (args.isEmpty())
return -2;
- return process.exitStatus() == QProcess::NormalExit ? process.exitCode() : -1;
+ QString program = args.takeFirst();
+ return execute(program, args);
}
/*!
diff --git a/src/corelib/io/qresource.cpp b/src/corelib/io/qresource.cpp
index e636712e57..9a2fd196a2 100644
--- a/src/corelib/io/qresource.cpp
+++ b/src/corelib/io/qresource.cpp
@@ -732,7 +732,7 @@ const uchar *QResource::data() const
\note If the data was compressed, this function will decompress every time
it is called. The result is not cached between calls.
- \sa uncompressedData(), size(), isCompressed(), isFile()
+ \sa uncompressedSize(), size(), isCompressed(), isFile()
*/
QByteArray QResource::uncompressedData() const
diff --git a/src/corelib/kernel/qmetatype.cpp b/src/corelib/kernel/qmetatype.cpp
index 4d9f3b01de..ea0016c5af 100644
--- a/src/corelib/kernel/qmetatype.cpp
+++ b/src/corelib/kernel/qmetatype.cpp
@@ -337,7 +337,7 @@ Q_GLOBAL_STATIC(QMetaTypeCustomRegistry, customTypeRegistry)
\value QPolygon QPolygon
\value QPolygonF QPolygonF
\value QColor QColor
- \value QColorSpace QColorSpace
+ \value QColorSpace QColorSpace (introduced in Qt 5.15)
\value QSizeF QSizeF
\value QRectF QRectF
\value QLine QLine
@@ -383,7 +383,7 @@ Q_GLOBAL_STATIC(QMetaTypeCustomRegistry, customTypeRegistry)
\value QCborMap QCborMap
\value QCborSimpleType QCborSimpleType
\value QModelIndex QModelIndex
- \value QPersistentModelIndex QPersistentModelIndex (since 5.5)
+ \value QPersistentModelIndex QPersistentModelIndex (introduced in Qt 5.5)
\value QUuid QUuid
\value QByteArrayList QByteArrayList
diff --git a/src/corelib/mimetypes/mimetypes.pri b/src/corelib/mimetypes/mimetypes.pri
index 8cbe7b69ae..288ccf063e 100644
--- a/src/corelib/mimetypes/mimetypes.pri
+++ b/src/corelib/mimetypes/mimetypes.pri
@@ -26,9 +26,12 @@ qtConfig(mimetype) {
qtConfig(mimetype-database) {
outpath = .rcc
+ android {
+ outpath = $$outpath/$${QT_ARCH}
+ }
debug_and_release {
- CONFIG(debug, debug|release): outpath = .rcc/debug
- else: outpath = .rcc/release
+ CONFIG(debug, debug|release): outpath = $$outpath/debug
+ else: outpath = $$outpath/release
}
mimedb.depends = $$PWD/mime/generate.pl
diff --git a/src/corelib/text/qbytearray.h b/src/corelib/text/qbytearray.h
index e3fec1e62c..d260a9d678 100644
--- a/src/corelib/text/qbytearray.h
+++ b/src/corelib/text/qbytearray.h
@@ -219,8 +219,8 @@ public:
int count(const char *a) const;
int count(const QByteArray &a) const;
- inline int compare(const char *c, Qt::CaseSensitivity cs = Qt::CaseSensitive) const;
- inline int compare(const QByteArray &a, Qt::CaseSensitivity cs = Qt::CaseSensitive) const;
+ inline int compare(const char *c, Qt::CaseSensitivity cs = Qt::CaseSensitive) const noexcept;
+ inline int compare(const QByteArray &a, Qt::CaseSensitivity cs = Qt::CaseSensitive) const noexcept;
Q_REQUIRED_RESULT QByteArray left(int len) const;
Q_REQUIRED_RESULT QByteArray right(int len) const;
@@ -555,12 +555,12 @@ inline bool QByteArray::contains(const QByteArray &a) const
{ return indexOf(a) != -1; }
inline bool QByteArray::contains(char c) const
{ return indexOf(c) != -1; }
-inline int QByteArray::compare(const char *c, Qt::CaseSensitivity cs) const
+inline int QByteArray::compare(const char *c, Qt::CaseSensitivity cs) const noexcept
{
return cs == Qt::CaseSensitive ? qstrcmp(*this, c) :
qstrnicmp(data(), size(), c, -1);
}
-inline int QByteArray::compare(const QByteArray &a, Qt::CaseSensitivity cs) const
+inline int QByteArray::compare(const QByteArray &a, Qt::CaseSensitivity cs) const noexcept
{
return cs == Qt::CaseSensitive ? qstrcmp(*this, a) :
qstrnicmp(data(), size(), a.data(), a.size());
diff --git a/src/corelib/text/qstring.cpp b/src/corelib/text/qstring.cpp
index 757f248e8a..745d3d8047 100644
--- a/src/corelib/text/qstring.cpp
+++ b/src/corelib/text/qstring.cpp
@@ -6154,6 +6154,16 @@ QString& QString::fill(QChar ch, int size)
sensitivity setting \a cs.
*/
+/*!
+ \fn int QString::compare(QChar ch, Qt::CaseSensitivity cs = Qt::CaseSensitive) const
+
+ \since 5.14
+ \overload compare()
+
+ Performs a comparison of this with \a ch, using the case
+ sensitivity setting \a cs.
+*/
+
#if QT_STRINGVIEW_LEVEL < 2
/*!
\overload compare()
@@ -9576,6 +9586,23 @@ QString &QString::setRawData(const QChar *unicode, int size)
*/
/*!
+ \fn int QLatin1String::compare(QStringView str, Qt::CaseSensitivity cs) const
+ \fn int QLatin1String::compare(QLatin1String l1, Qt::CaseSensitivity cs) const
+ \fn int QLatin1String::compare(QChar ch) const
+ \fn int QLatin1String::compare(QChar ch, Qt::CaseSensitivity cs) const
+ \since 5.14
+
+ Returns an integer that compares to zero as this Latin-1 string compares to the
+ string-view \a str, Latin-1 string \a l1, or character \a ch, respectively.
+
+ If \a cs is Qt::CaseSensitive (the default), the comparison is case sensitive;
+ otherwise the comparison is case-insensitive.
+
+ \sa operator==(), operator<(), operator>()
+*/
+
+
+/*!
\fn bool QLatin1String::startsWith(QStringView str, Qt::CaseSensitivity cs) const
\since 5.10
\fn bool QLatin1String::startsWith(QLatin1String l1, Qt::CaseSensitivity cs) const
@@ -10943,6 +10970,19 @@ QStringRef QStringRef::appendTo(QString *string) const
/*!
\overload
+ \fn int QStringRef::compare(QChar ch, Qt::CaseSensitivity cs = Qt::CaseSensitive) const
+ \since 5.14
+
+ Compares this string with \a ch and returns an
+ integer less than, equal to, or greater than zero if this string
+ is less than, equal to, or greater than \a ch, interpreted as a string of length one.
+
+ If \a cs is Qt::CaseSensitive, the comparison is case sensitive;
+ otherwise the comparison is case insensitive.
+*/
+
+/*!
+ \overload
\fn int QStringRef::compare(QLatin1String other, Qt::CaseSensitivity cs = Qt::CaseSensitive) const
\since 4.5
diff --git a/src/corelib/text/qstring.h b/src/corelib/text/qstring.h
index f4d6fc24a5..d5101b7ff3 100644
--- a/src/corelib/text/qstring.h
+++ b/src/corelib/text/qstring.h
@@ -110,6 +110,15 @@ public:
Q_REQUIRED_RESULT Q_DECL_CONSTEXPR QLatin1Char front() const { return at(0); }
Q_REQUIRED_RESULT Q_DECL_CONSTEXPR QLatin1Char back() const { return at(size() - 1); }
+ Q_REQUIRED_RESULT int compare(QStringView other, Qt::CaseSensitivity cs = Qt::CaseSensitive) const noexcept
+ { return QtPrivate::compareStrings(*this, other, cs); }
+ Q_REQUIRED_RESULT int compare(QLatin1String other, Qt::CaseSensitivity cs = Qt::CaseSensitive) const noexcept
+ { return QtPrivate::compareStrings(*this, other, cs); }
+ Q_REQUIRED_RESULT Q_DECL_CONSTEXPR int compare(QChar c) const noexcept
+ { return isEmpty() || front() == c ? size() - 1 : uchar(m_data[0]) - c.unicode() ; }
+ Q_REQUIRED_RESULT int compare(QChar c, Qt::CaseSensitivity cs) const noexcept
+ { return QtPrivate::compareStrings(*this, QStringView(&c, 1), cs); }
+
Q_REQUIRED_RESULT bool startsWith(QStringView s, Qt::CaseSensitivity cs = Qt::CaseSensitive) const noexcept
{ return QtPrivate::startsWith(*this, s, cs); }
Q_REQUIRED_RESULT bool startsWith(QLatin1String s, Qt::CaseSensitivity cs = Qt::CaseSensitive) const noexcept
@@ -232,6 +241,8 @@ Q_DECL_CONSTEXPR bool QtPrivate::isLatin1(QLatin1String) noexcept
//
// QStringView members that require QLatin1String:
//
+int QStringView::compare(QLatin1String s, Qt::CaseSensitivity cs) const noexcept
+{ return QtPrivate::compareStrings(*this, s, cs); }
bool QStringView::startsWith(QLatin1String s, Qt::CaseSensitivity cs) const noexcept
{ return QtPrivate::startsWith(*this, s, cs); }
bool QStringView::endsWith(QLatin1String s, Qt::CaseSensitivity cs) const noexcept
@@ -729,6 +740,8 @@ public:
#endif
int compare(QLatin1String other, Qt::CaseSensitivity cs = Qt::CaseSensitive) const noexcept;
inline int compare(QStringView s, Qt::CaseSensitivity cs = Qt::CaseSensitive) const noexcept;
+ int compare(QChar ch, Qt::CaseSensitivity cs = Qt::CaseSensitive) const noexcept
+ { return compare(QStringView{&ch, 1}, cs); }
static inline int compare(const QString &s1, const QString &s2,
Qt::CaseSensitivity cs = Qt::CaseSensitive) noexcept
@@ -1615,6 +1628,8 @@ public:
int compare(const QString &s, Qt::CaseSensitivity cs = Qt::CaseSensitive) const noexcept;
int compare(const QStringRef &s, Qt::CaseSensitivity cs = Qt::CaseSensitive) const noexcept;
+ int compare(QChar c, Qt::CaseSensitivity cs = Qt::CaseSensitive) const noexcept
+ { return QtPrivate::compareStrings(*this, QStringView(&c, 1), cs); }
int compare(QLatin1String s, Qt::CaseSensitivity cs = Qt::CaseSensitive) const noexcept;
#if !defined(QT_NO_CAST_FROM_ASCII) && !defined(QT_RESTRICTED_CAST_FROM_ASCII)
int compare(const QByteArray &s, Qt::CaseSensitivity cs = Qt::CaseSensitive) const
diff --git a/src/corelib/text/qstringview.cpp b/src/corelib/text/qstringview.cpp
index 08dade7e68..9df656dc59 100644
--- a/src/corelib/text/qstringview.cpp
+++ b/src/corelib/text/qstringview.cpp
@@ -692,15 +692,29 @@ QT_BEGIN_NAMESPACE
*/
/*!
- \fn int QStringView::compare(QStringView other, Qt::CaseSensitivity cs) const
+ \fn int QStringView::compare(QStringView str, Qt::CaseSensitivity cs) const
\since 5.12
- Compares this string-view with the \a other string-view and returns an
- integer less than, equal to, or greater than zero if this string-view
- is less than, equal to, or greater than the other string-view.
+ Returns an integer that compares to zero as this string-view compares to the
+ string-view \a str.
- If \a cs is Qt::CaseSensitive, the comparison is case sensitive;
- otherwise the comparison is case insensitive.
+ If \a cs is Qt::CaseSensitive (the default), the comparison is case sensitive;
+ otherwise the comparison is case-insensitive.
+
+ \sa operator==(), operator<(), operator>()
+*/
+
+/*!
+ \fn int QStringView::compare(QLatin1String l1, Qt::CaseSensitivity cs) const
+ \fn int QStringView::compare(QChar ch) const
+ \fn int QStringView::compare(QChar ch, Qt::CaseSensitivity cs) const
+ \since 5.14
+
+ Returns an integer that compares to zero as this string-view compares to the
+ Latin-1 string \a l1, or character \a ch, respectively.
+
+ If \a cs is Qt::CaseSensitive (the default), the comparison is case sensitive;
+ otherwise the comparison is case-insensitive.
\sa operator==(), operator<(), operator>()
*/
diff --git a/src/corelib/text/qstringview.h b/src/corelib/text/qstringview.h
index 06391ffef4..83418970a5 100644
--- a/src/corelib/text/qstringview.h
+++ b/src/corelib/text/qstringview.h
@@ -257,6 +257,11 @@ public:
Q_REQUIRED_RESULT int compare(QStringView other, Qt::CaseSensitivity cs = Qt::CaseSensitive) const noexcept
{ return QtPrivate::compareStrings(*this, other, cs); }
+ Q_REQUIRED_RESULT inline int compare(QLatin1String other, Qt::CaseSensitivity cs = Qt::CaseSensitive) const noexcept;
+ Q_REQUIRED_RESULT Q_DECL_CONSTEXPR int compare(QChar c) const noexcept
+ { return empty() || front() == c ? size() - 1 : *utf16() - c.unicode() ; }
+ Q_REQUIRED_RESULT int compare(QChar c, Qt::CaseSensitivity cs) const noexcept
+ { return QtPrivate::compareStrings(*this, QStringView(&c, 1), cs); }
Q_REQUIRED_RESULT bool startsWith(QStringView s, Qt::CaseSensitivity cs = Qt::CaseSensitive) const noexcept
{ return QtPrivate::startsWith(*this, s, cs); }