summaryrefslogtreecommitdiffstats
path: root/src/corelib/tools
diff options
context:
space:
mode:
Diffstat (limited to 'src/corelib/tools')
-rw-r--r--src/corelib/tools/qarraydata.h4
-rw-r--r--src/corelib/tools/qbytearray.h20
-rw-r--r--src/corelib/tools/qbytearraylist.h2
-rw-r--r--src/corelib/tools/qcollator.h2
-rw-r--r--src/corelib/tools/qcollator_win.cpp8
-rw-r--r--src/corelib/tools/qdatetime.h2
-rw-r--r--src/corelib/tools/qeasingcurve.cpp20
-rw-r--r--src/corelib/tools/qeasingcurve.h2
-rw-r--r--src/corelib/tools/qhash.h8
-rw-r--r--src/corelib/tools/qlinkedlist.h4
-rw-r--r--src/corelib/tools/qlist.h4
-rw-r--r--src/corelib/tools/qlocale.cpp14
-rw-r--r--src/corelib/tools/qlocale.h32
-rw-r--r--src/corelib/tools/qlocale_tools.cpp5
-rw-r--r--src/corelib/tools/qlocale_tools_p.h1
-rw-r--r--src/corelib/tools/qlocale_win.cpp12
-rw-r--r--src/corelib/tools/qmap.cpp280
-rw-r--r--src/corelib/tools/qmap.h46
-rw-r--r--src/corelib/tools/qringbuffer_p.h2
-rw-r--r--src/corelib/tools/qscopedpointer.cpp7
-rw-r--r--src/corelib/tools/qscopedpointer.h17
-rw-r--r--src/corelib/tools/qshareddata.h12
-rw-r--r--src/corelib/tools/qsharedpointer.cpp9
-rw-r--r--src/corelib/tools/qsharedpointer.h1
-rw-r--r--src/corelib/tools/qsharedpointer_impl.h39
-rw-r--r--src/corelib/tools/qsimd_p.h11
-rw-r--r--src/corelib/tools/qstring.cpp6
-rw-r--r--src/corelib/tools/qstring.h48
-rw-r--r--src/corelib/tools/qtextboundaryfinder.h2
-rw-r--r--src/corelib/tools/qtimeline.h4
-rw-r--r--src/corelib/tools/qtimezoneprivate_p.h183
-rw-r--r--src/corelib/tools/qtimezoneprivate_win.cpp227
-rw-r--r--src/corelib/tools/qversionnumber.h2
33 files changed, 562 insertions, 474 deletions
diff --git a/src/corelib/tools/qarraydata.h b/src/corelib/tools/qarraydata.h
index 88f0cfb0ea..f0cc56e899 100644
--- a/src/corelib/tools/qarraydata.h
+++ b/src/corelib/tools/qarraydata.h
@@ -139,7 +139,7 @@ struct QTypedArrayData
typedef T *pointer;
typedef T &reference;
- inline iterator() : i(Q_NULLPTR) {}
+ inline iterator() : i(nullptr) {}
inline iterator(T *n) : i(n) {}
inline iterator(const iterator &o): i(o.i){} // #### Qt 6: remove, the implicit version is fine
inline T &operator*() const { return *i; }
@@ -173,7 +173,7 @@ struct QTypedArrayData
typedef const T *pointer;
typedef const T &reference;
- inline const_iterator() : i(Q_NULLPTR) {}
+ inline const_iterator() : i(nullptr) {}
inline const_iterator(const T *n) : i(n) {}
inline const_iterator(const const_iterator &o): i(o.i) {} // #### Qt 6: remove, the default version is fine
inline explicit const_iterator(const iterator &o): i(o.i) {}
diff --git a/src/corelib/tools/qbytearray.h b/src/corelib/tools/qbytearray.h
index 732d3afc17..300f795469 100644
--- a/src/corelib/tools/qbytearray.h
+++ b/src/corelib/tools/qbytearray.h
@@ -340,16 +340,16 @@ public:
inline QT_ASCII_CAST_WARN bool operator>=(const QString &s2) const;
#endif
- short toShort(bool *ok = Q_NULLPTR, int base = 10) const;
- ushort toUShort(bool *ok = Q_NULLPTR, int base = 10) const;
- int toInt(bool *ok = Q_NULLPTR, int base = 10) const;
- uint toUInt(bool *ok = Q_NULLPTR, int base = 10) const;
- long toLong(bool *ok = Q_NULLPTR, int base = 10) const;
- ulong toULong(bool *ok = Q_NULLPTR, int base = 10) const;
- qlonglong toLongLong(bool *ok = Q_NULLPTR, int base = 10) const;
- qulonglong toULongLong(bool *ok = Q_NULLPTR, int base = 10) const;
- float toFloat(bool *ok = Q_NULLPTR) const;
- double toDouble(bool *ok = Q_NULLPTR) const;
+ short toShort(bool *ok = nullptr, int base = 10) const;
+ ushort toUShort(bool *ok = nullptr, int base = 10) const;
+ int toInt(bool *ok = nullptr, int base = 10) const;
+ uint toUInt(bool *ok = nullptr, int base = 10) const;
+ long toLong(bool *ok = nullptr, int base = 10) const;
+ ulong toULong(bool *ok = nullptr, int base = 10) const;
+ qlonglong toLongLong(bool *ok = nullptr, int base = 10) const;
+ qulonglong toULongLong(bool *ok = nullptr, int base = 10) const;
+ float toFloat(bool *ok = nullptr) const;
+ double toDouble(bool *ok = nullptr) const;
QByteArray toBase64(Base64Options options) const;
QByteArray toBase64() const; // ### Qt6 merge with previous
QByteArray toHex() const;
diff --git a/src/corelib/tools/qbytearraylist.h b/src/corelib/tools/qbytearraylist.h
index 501bb2e0d5..ed014dd157 100644
--- a/src/corelib/tools/qbytearraylist.h
+++ b/src/corelib/tools/qbytearraylist.h
@@ -70,7 +70,7 @@ protected:
#endif
public:
inline QByteArray join() const
- { return QtPrivate::QByteArrayList_join(self(), Q_NULLPTR, 0); }
+ { return QtPrivate::QByteArrayList_join(self(), nullptr, 0); }
inline QByteArray join(const QByteArray &sep) const
{ return QtPrivate::QByteArrayList_join(self(), sep.constData(), sep.size()); }
inline QByteArray join(char sep) const
diff --git a/src/corelib/tools/qcollator.h b/src/corelib/tools/qcollator.h
index d81c7c85e3..6fa199cb0f 100644
--- a/src/corelib/tools/qcollator.h
+++ b/src/corelib/tools/qcollator.h
@@ -89,7 +89,7 @@ public:
QCollator &operator=(const QCollator &);
#ifdef Q_COMPILER_RVALUE_REFS
QCollator(QCollator &&other) Q_DECL_NOTHROW
- : d(other.d) { other.d = Q_NULLPTR; }
+ : d(other.d) { other.d = nullptr; }
QCollator &operator=(QCollator &&other) Q_DECL_NOTHROW
{ swap(other); return *this; }
#endif
diff --git a/src/corelib/tools/qcollator_win.cpp b/src/corelib/tools/qcollator_win.cpp
index bce896278e..5a838c1b50 100644
--- a/src/corelib/tools/qcollator_win.cpp
+++ b/src/corelib/tools/qcollator_win.cpp
@@ -70,12 +70,8 @@ void QCollatorPrivate::init()
if (caseSensitivity == Qt::CaseInsensitive)
collator |= NORM_IGNORECASE;
- if (numericMode) {
- if (QSysInfo::windowsVersion() >= QSysInfo::WV_WINDOWS7)
- collator |= SORT_DIGITSASNUMBERS;
- else
- qWarning("Numeric sorting unsupported on Windows versions older than Windows 7.");
- }
+ if (numericMode)
+ collator |= SORT_DIGITSASNUMBERS;
if (ignorePunctuation)
collator |= NORM_IGNORESYMBOLS;
diff --git a/src/corelib/tools/qdatetime.h b/src/corelib/tools/qdatetime.h
index adab47fc1f..a390bce95f 100644
--- a/src/corelib/tools/qdatetime.h
+++ b/src/corelib/tools/qdatetime.h
@@ -79,7 +79,7 @@ public:
int dayOfYear() const;
int daysInMonth() const;
int daysInYear() const;
- int weekNumber(int *yearNum = Q_NULLPTR) const;
+ int weekNumber(int *yearNum = nullptr) const;
#if QT_DEPRECATED_SINCE(5, 11) && !defined QT_NO_TEXTDATE
QT_DEPRECATED_X("Use QLocale::monthName or QLocale::standaloneMonthName")
diff --git a/src/corelib/tools/qeasingcurve.cpp b/src/corelib/tools/qeasingcurve.cpp
index 03bb1a1411..0b8fa4ca74 100644
--- a/src/corelib/tools/qeasingcurve.cpp
+++ b/src/corelib/tools/qeasingcurve.cpp
@@ -496,7 +496,7 @@ struct BezierEase : public QEasingCurveFunction
}
}
- QEasingCurveFunction *copy() const Q_DECL_OVERRIDE
+ QEasingCurveFunction *copy() const override
{
BezierEase *rv = new BezierEase();
rv->_t = _t;
@@ -532,7 +532,7 @@ struct BezierEase : public QEasingCurveFunction
return newT;
}
- qreal value(qreal x) Q_DECL_OVERRIDE
+ qreal value(qreal x) override
{
Q_ASSERT(_bezierCurves.count() % 3 == 0);
@@ -826,7 +826,7 @@ struct TCBEase : public BezierEase
: BezierEase(QEasingCurve::TCBSpline)
{ }
- qreal value(qreal x) Q_DECL_OVERRIDE
+ qreal value(qreal x) override
{
Q_ASSERT(_bezierCurves.count() % 3 == 0);
@@ -846,7 +846,7 @@ struct ElasticEase : public QEasingCurveFunction
: QEasingCurveFunction(type, qreal(0.3), qreal(1.0))
{ }
- QEasingCurveFunction *copy() const Q_DECL_OVERRIDE
+ QEasingCurveFunction *copy() const override
{
ElasticEase *rv = new ElasticEase(_t);
rv->_p = _p;
@@ -856,7 +856,7 @@ struct ElasticEase : public QEasingCurveFunction
return rv;
}
- qreal value(qreal t) Q_DECL_OVERRIDE
+ qreal value(qreal t) override
{
qreal p = (_p < 0) ? qreal(0.3) : _p;
qreal a = (_a < 0) ? qreal(1.0) : _a;
@@ -881,7 +881,7 @@ struct BounceEase : public QEasingCurveFunction
: QEasingCurveFunction(type, qreal(0.3), qreal(1.0))
{ }
- QEasingCurveFunction *copy() const Q_DECL_OVERRIDE
+ QEasingCurveFunction *copy() const override
{
BounceEase *rv = new BounceEase(_t);
rv->_a = _a;
@@ -890,7 +890,7 @@ struct BounceEase : public QEasingCurveFunction
return rv;
}
- qreal value(qreal t) Q_DECL_OVERRIDE
+ qreal value(qreal t) override
{
qreal a = (_a < 0) ? qreal(1.0) : _a;
switch(_t) {
@@ -914,7 +914,7 @@ struct BackEase : public QEasingCurveFunction
: QEasingCurveFunction(type, qreal(0.3), qreal(1.0), qreal(1.70158))
{ }
- QEasingCurveFunction *copy() const Q_DECL_OVERRIDE
+ QEasingCurveFunction *copy() const override
{
BackEase *rv = new BackEase(_t);
rv->_o = _o;
@@ -923,7 +923,7 @@ struct BackEase : public QEasingCurveFunction
return rv;
}
- qreal value(qreal t) Q_DECL_OVERRIDE
+ qreal value(qreal t) override
{
qreal o = (_o < 0) ? qreal(1.70158) : _o;
switch(_t) {
@@ -1488,7 +1488,7 @@ QDataStream &operator>>(QDataStream &stream, QEasingCurve &easing)
bool hasConfig;
stream >> hasConfig;
delete easing.d_ptr->config;
- easing.d_ptr->config = Q_NULLPTR;
+ easing.d_ptr->config = nullptr;
if (hasConfig) {
QEasingCurveFunction *config = curveToFunctionObject(type);
stream >> config->_p;
diff --git a/src/corelib/tools/qeasingcurve.h b/src/corelib/tools/qeasingcurve.h
index ba06de8f9e..74bde5825a 100644
--- a/src/corelib/tools/qeasingcurve.h
+++ b/src/corelib/tools/qeasingcurve.h
@@ -81,7 +81,7 @@ public:
QEasingCurve &operator=(const QEasingCurve &other)
{ if ( this != &other ) { QEasingCurve copy(other); swap(copy); } return *this; }
#ifdef Q_COMPILER_RVALUE_REFS
- QEasingCurve(QEasingCurve &&other) Q_DECL_NOTHROW : d_ptr(other.d_ptr) { other.d_ptr = Q_NULLPTR; }
+ QEasingCurve(QEasingCurve &&other) Q_DECL_NOTHROW : d_ptr(other.d_ptr) { other.d_ptr = nullptr; }
QEasingCurve &operator=(QEasingCurve &&other) Q_DECL_NOTHROW
{ qSwap(d_ptr, other.d_ptr); return *this; }
#endif
diff --git a/src/corelib/tools/qhash.h b/src/corelib/tools/qhash.h
index 715acc77ce..e7ce4b658f 100644
--- a/src/corelib/tools/qhash.h
+++ b/src/corelib/tools/qhash.h
@@ -315,7 +315,7 @@ public:
typedef T *pointer;
typedef T &reference;
- inline iterator() : i(Q_NULLPTR) { }
+ inline iterator() : i(nullptr) { }
explicit inline iterator(void *node) : i(reinterpret_cast<QHashData::Node *>(node)) { }
inline const Key &key() const { return concrete(i)->key; }
@@ -373,7 +373,7 @@ public:
typedef const T *pointer;
typedef const T &reference;
- Q_DECL_CONSTEXPR inline const_iterator() : i(Q_NULLPTR) { }
+ Q_DECL_CONSTEXPR inline const_iterator() : i(nullptr) { }
explicit inline const_iterator(void *node)
: i(reinterpret_cast<QHashData::Node *>(node)) { }
#ifdef QT_STRICT_ITERATORS
@@ -502,7 +502,7 @@ public:
private:
void detach_helper();
void freeData(QHashData *d);
- Node **findNode(const Key &key, uint *hp = Q_NULLPTR) const;
+ Node **findNode(const Key &key, uint *hp = nullptr) const;
Node **findNode(const Key &key, uint h) const;
Node *createNode(uint h, const Key &key, const T &value, Node **nextNode);
void deleteNode(Node *node);
@@ -550,7 +550,7 @@ template <class Key, class T>
Q_INLINE_TEMPLATE void QHash<Key, T>::duplicateNode(QHashData::Node *node, void *newNode)
{
Node *concreteNode = concrete(node);
- new (newNode) Node(concreteNode->key, concreteNode->value, concreteNode->h, Q_NULLPTR);
+ new (newNode) Node(concreteNode->key, concreteNode->value, concreteNode->h, nullptr);
}
template <class Key, class T>
diff --git a/src/corelib/tools/qlinkedlist.h b/src/corelib/tools/qlinkedlist.h
index 9f54ba7825..c8f3f4c8c3 100644
--- a/src/corelib/tools/qlinkedlist.h
+++ b/src/corelib/tools/qlinkedlist.h
@@ -134,7 +134,7 @@ public:
typedef T *pointer;
typedef T &reference;
Node *i;
- inline iterator() : i(Q_NULLPTR) {}
+ inline iterator() : i(nullptr) {}
inline iterator(Node *n) : i(n) {}
#if QT_VERSION < QT_VERSION_CHECK(6,0,0)
iterator(const iterator &other) Q_DECL_NOTHROW : i(other.i) {}
@@ -171,7 +171,7 @@ public:
typedef const T *pointer;
typedef const T &reference;
Node *i;
- inline const_iterator() : i(Q_NULLPTR) {}
+ inline const_iterator() : i(nullptr) {}
inline const_iterator(Node *n) : i(n) {}
inline const_iterator(iterator ci) : i(ci.i){}
#if QT_VERSION < QT_VERSION_CHECK(6,0,0)
diff --git a/src/corelib/tools/qlist.h b/src/corelib/tools/qlist.h
index 1042c29460..af7659e995 100644
--- a/src/corelib/tools/qlist.h
+++ b/src/corelib/tools/qlist.h
@@ -231,7 +231,7 @@ public:
typedef T *pointer;
typedef T &reference;
- inline iterator() Q_DECL_NOTHROW : i(Q_NULLPTR) {}
+ inline iterator() Q_DECL_NOTHROW : i(nullptr) {}
inline iterator(Node *n) Q_DECL_NOTHROW : i(n) {}
#if QT_VERSION < QT_VERSION_CHECK(6,0,0)
// can't remove it in Qt 5, since doing so would make the type trivial,
@@ -283,7 +283,7 @@ public:
typedef const T *pointer;
typedef const T &reference;
- inline const_iterator() Q_DECL_NOTHROW : i(Q_NULLPTR) {}
+ inline const_iterator() Q_DECL_NOTHROW : i(nullptr) {}
inline const_iterator(Node *n) Q_DECL_NOTHROW : i(n) {}
#if QT_VERSION < QT_VERSION_CHECK(6,0,0)
// can't remove it in Qt 5, since doing so would make the type trivial,
diff --git a/src/corelib/tools/qlocale.cpp b/src/corelib/tools/qlocale.cpp
index 723e63114d..c85dcb4358 100644
--- a/src/corelib/tools/qlocale.cpp
+++ b/src/corelib/tools/qlocale.cpp
@@ -3151,11 +3151,15 @@ QString QLocaleData::longLongToString(const QChar zero, const QChar group,
negative = false; // neither are negative numbers
}
- QString num_str;
- if (base == 10)
- num_str = qlltoa(l, base, zero);
- else
- num_str = qulltoa(l, base, zero);
+QT_WARNING_PUSH
+ /* "unary minus operator applied to unsigned type, result still unsigned" */
+QT_WARNING_DISABLE_MSVC(4146)
+ /*
+ Negating std::numeric_limits<qlonglong>::min() hits undefined behavior, so
+ taking an absolute value has to cast to unsigned to change sign.
+ */
+ QString num_str = qulltoa(negative ? -qulonglong(l) : qulonglong(l), base, zero);
+QT_WARNING_POP
uint cnt_thousand_sep = 0;
if (flags & ThousandsGroup && base == 10) {
diff --git a/src/corelib/tools/qlocale.h b/src/corelib/tools/qlocale.h
index 54b1a32946..ef7a26ea79 100644
--- a/src/corelib/tools/qlocale.h
+++ b/src/corelib/tools/qlocale.h
@@ -949,23 +949,23 @@ public:
QString nativeCountryName() const;
#if QT_STRINGVIEW_LEVEL < 2
- short toShort(const QString &s, bool *ok = Q_NULLPTR) const;
- ushort toUShort(const QString &s, bool *ok = Q_NULLPTR) const;
- int toInt(const QString &s, bool *ok = Q_NULLPTR) const;
- uint toUInt(const QString &s, bool *ok = Q_NULLPTR) const;
- qlonglong toLongLong(const QString &s, bool *ok = Q_NULLPTR) const;
- qulonglong toULongLong(const QString &s, bool *ok = Q_NULLPTR) const;
- float toFloat(const QString &s, bool *ok = Q_NULLPTR) const;
- double toDouble(const QString &s, bool *ok = Q_NULLPTR) const;
+ short toShort(const QString &s, bool *ok = nullptr) const;
+ ushort toUShort(const QString &s, bool *ok = nullptr) const;
+ int toInt(const QString &s, bool *ok = nullptr) const;
+ uint toUInt(const QString &s, bool *ok = nullptr) const;
+ qlonglong toLongLong(const QString &s, bool *ok = nullptr) const;
+ qulonglong toULongLong(const QString &s, bool *ok = nullptr) const;
+ float toFloat(const QString &s, bool *ok = nullptr) const;
+ double toDouble(const QString &s, bool *ok = nullptr) const;
- short toShort(const QStringRef &s, bool *ok = Q_NULLPTR) const;
- ushort toUShort(const QStringRef &s, bool *ok = Q_NULLPTR) const;
- int toInt(const QStringRef &s, bool *ok = Q_NULLPTR) const;
- uint toUInt(const QStringRef &s, bool *ok = Q_NULLPTR) const;
- qlonglong toLongLong(const QStringRef &s, bool *ok = Q_NULLPTR) const;
- qulonglong toULongLong(const QStringRef &s, bool *ok = Q_NULLPTR) const;
- float toFloat(const QStringRef &s, bool *ok = Q_NULLPTR) const;
- double toDouble(const QStringRef &s, bool *ok = Q_NULLPTR) const;
+ short toShort(const QStringRef &s, bool *ok = nullptr) const;
+ ushort toUShort(const QStringRef &s, bool *ok = nullptr) const;
+ int toInt(const QStringRef &s, bool *ok = nullptr) const;
+ uint toUInt(const QStringRef &s, bool *ok = nullptr) const;
+ qlonglong toLongLong(const QStringRef &s, bool *ok = nullptr) const;
+ qulonglong toULongLong(const QStringRef &s, bool *ok = nullptr) const;
+ float toFloat(const QStringRef &s, bool *ok = nullptr) const;
+ double toDouble(const QStringRef &s, bool *ok = nullptr) const;
#endif
short toShort(QStringView s, bool *ok = nullptr) const;
diff --git a/src/corelib/tools/qlocale_tools.cpp b/src/corelib/tools/qlocale_tools.cpp
index 3e4f37501e..4d969a4723 100644
--- a/src/corelib/tools/qlocale_tools.cpp
+++ b/src/corelib/tools/qlocale_tools.cpp
@@ -456,11 +456,6 @@ QString qulltoa(qulonglong l, int base, const QChar _zero)
return QString(reinterpret_cast<QChar *>(p), 65 - (p - buff));
}
-QString qlltoa(qlonglong l, int base, const QChar zero)
-{
- return qulltoa(l < 0 ? -l : l, base, zero);
-}
-
QString &decimalForm(QChar zero, QChar decimal, QChar group,
QString &digits, int decpt, int precision,
PrecisionMode pm,
diff --git a/src/corelib/tools/qlocale_tools_p.h b/src/corelib/tools/qlocale_tools_p.h
index 6133f67add..742abb4957 100644
--- a/src/corelib/tools/qlocale_tools_p.h
+++ b/src/corelib/tools/qlocale_tools_p.h
@@ -83,7 +83,6 @@ void doubleToAscii(double d, QLocaleData::DoubleForm form, int precision, char *
bool &sign, int &length, int &decpt);
QString qulltoa(qulonglong l, int base, const QChar _zero);
-QString qlltoa(qlonglong l, int base, const QChar zero);
Q_CORE_EXPORT QString qdtoa(qreal d, int *decpt, int *sign);
enum PrecisionMode {
diff --git a/src/corelib/tools/qlocale_win.cpp b/src/corelib/tools/qlocale_win.cpp
index 1d80320d8e..30aefb71c1 100644
--- a/src/corelib/tools/qlocale_win.cpp
+++ b/src/corelib/tools/qlocale_win.cpp
@@ -326,9 +326,7 @@ QVariant QSystemLocalePrivate::timeFormat(QLocale::FormatType type)
{
switch (type) {
case QLocale::ShortFormat:
- if (QSysInfo::windowsVersion() >= QSysInfo::WV_WINDOWS7)
- return winToQtFormat(getLocaleInfo(LOCALE_SSHORTTIME));
- // fall through
+ return winToQtFormat(getLocaleInfo(LOCALE_SSHORTTIME));
case QLocale::LongFormat:
return winToQtFormat(getLocaleInfo(LOCALE_STIMEFORMAT));
case QLocale::NarrowFormat:
@@ -367,7 +365,7 @@ QVariant QSystemLocalePrivate::dayName(int day, QLocale::FormatType type)
if (type == QLocale::LongFormat)
return getLocaleInfo(long_day_map[day]);
- else if (type == QLocale::NarrowFormat && QSysInfo::windowsVersion() >= QSysInfo::WV_VISTA)
+ else if (type == QLocale::NarrowFormat)
return getLocaleInfo(narrow_day_map[day]);
return getLocaleInfo(short_day_map[day]);
}
@@ -425,7 +423,7 @@ QVariant QSystemLocalePrivate::toString(const QTime &time, QLocale::FormatType t
DWORD flags = 0;
// keep the same conditional as timeFormat() above
- if (type == QLocale::ShortFormat && QSysInfo::windowsVersion() >= QSysInfo::WV_WINDOWS7)
+ if (type == QLocale::ShortFormat)
flags = TIME_NOSECONDS;
wchar_t buf[255];
@@ -656,15 +654,11 @@ QVariant QSystemLocalePrivate::uiLanguages()
QVariant QSystemLocalePrivate::nativeLanguageName()
{
- if (QSysInfo::windowsVersion() < QSysInfo::WV_WINDOWS7)
- return getLocaleInfo(LOCALE_SNATIVELANGNAME);
return getLocaleInfo(LOCALE_SNATIVELANGUAGENAME);
}
QVariant QSystemLocalePrivate::nativeCountryName()
{
- if (QSysInfo::windowsVersion() < QSysInfo::WV_WINDOWS7)
- return getLocaleInfo(LOCALE_SNATIVECTRYNAME);
return getLocaleInfo(LOCALE_SNATIVECOUNTRYNAME);
}
diff --git a/src/corelib/tools/qmap.cpp b/src/corelib/tools/qmap.cpp
index afdd30e5c8..5a20c581e9 100644
--- a/src/corelib/tools/qmap.cpp
+++ b/src/corelib/tools/qmap.cpp
@@ -509,7 +509,7 @@ void QMapDataBase::freeData(QMapDataBase *d)
\sa QMapIterator, QMutableMapIterator, QHash, QSet
*/
-/*! \fn QMap::QMap()
+/*! \fn template <class Key, class T> QMap<Key, T>::QMap()
Constructs an empty map.
@@ -517,7 +517,7 @@ void QMapDataBase::freeData(QMapDataBase *d)
*/
/*!
- \fn QMap::QMap(QMap<Key, T> &&other)
+ \fn template <class Key, class T> QMap<Key, T>::QMap(QMap<Key, T> &&other)
Move-constructs a QMap instance, making it point at the same
object that \a other was pointing to.
@@ -525,7 +525,7 @@ void QMapDataBase::freeData(QMapDataBase *d)
\since 5.2
*/
-/*! \fn QMap::QMap(const QMap<Key, T> &other)
+/*! \fn template <class Key, class T> QMap<Key, T>::QMap(const QMap<Key, T> &other)
Constructs a copy of \a other.
@@ -537,14 +537,14 @@ void QMapDataBase::freeData(QMapDataBase *d)
\sa operator=()
*/
-/*! \fn QMap::QMap(const std::map<Key, T> & other)
+/*! \fn template <class Key, class T> QMap<Key, T>::QMap(const std::map<Key, T> & other)
Constructs a copy of \a other.
\sa toStdMap()
*/
-/*! \fn QMap::QMap(std::initializer_list<std::pair<Key,T> > list)
+/*! \fn template <class Key, class T> QMap<Key, T>::QMap(std::initializer_list<std::pair<Key,T> > list)
\since 5.1
Constructs a map with a copy of each of the elements in the
@@ -554,45 +554,45 @@ void QMapDataBase::freeData(QMapDataBase *d)
compiled in C++11 mode.
*/
-/*! \fn std::map<Key, T> QMap::toStdMap() const
+/*! \fn template <class Key, class T> std::map<Key, T> QMap<Key, T>::toStdMap() const
Returns an STL map equivalent to this QMap.
*/
-/*! \fn QMap::~QMap()
+/*! \fn template <class Key, class T> QMap<Key, T>::~QMap()
Destroys the map. References to the values in the map, and all
iterators over this map, become invalid.
*/
-/*! \fn QMap<Key, T> &QMap::operator=(const QMap<Key, T> &other)
+/*! \fn template <class Key, class T> QMap<Key, T> &QMap<Key, T>::operator=(const QMap<Key, T> &other)
Assigns \a other to this map and returns a reference to this map.
*/
/*!
- \fn QMap<Key, T> &QMap::operator=(QMap<Key, T> &&other)
+ \fn template <class Key, class T> QMap<Key, T> &QMap<Key, T>::operator=(QMap<Key, T> &&other)
Move-assigns \a other to this QMap instance.
\since 5.2
*/
-/*! \fn void QMap::swap(QMap<Key, T> &other)
+/*! \fn template <class Key, class T> void QMap<Key, T>::swap(QMap<Key, T> &other)
\since 4.8
Swaps map \a other with this map. This operation is very
fast and never fails.
*/
-/*! \fn void QMultiMap::swap(QMultiMap<Key, T> &other)
+/*! \fn template <class Key, class T> void QMultiMap<Key, T>::swap(QMultiMap<Key, T> &other)
\since 4.8
Swaps map \a other with this map. This operation is very
fast and never fails.
*/
-/*! \fn bool QMap::operator==(const QMap<Key, T> &other) const
+/*! \fn template <class Key, class T> bool QMap<Key, T>::operator==(const QMap<Key, T> &other) const
Returns \c true if \a other is equal to this map; otherwise returns
false.
@@ -606,7 +606,7 @@ void QMapDataBase::freeData(QMapDataBase *d)
\sa operator!=()
*/
-/*! \fn bool QMap::operator!=(const QMap<Key, T> &other) const
+/*! \fn template <class Key, class T> bool QMap<Key, T>::operator!=(const QMap<Key, T> &other) const
Returns \c true if \a other is not equal to this map; otherwise
returns \c false.
@@ -620,7 +620,7 @@ void QMapDataBase::freeData(QMapDataBase *d)
\sa operator==()
*/
-/*! \fn int QMap::size() const
+/*! \fn template <class Key, class T> int QMap<Key, T>::size() const
Returns the number of (key, value) pairs in the map.
@@ -628,7 +628,7 @@ void QMapDataBase::freeData(QMapDataBase *d)
*/
/*!
- \fn bool QMap::isEmpty() const
+ \fn template <class Key, class T> bool QMap<Key, T>::isEmpty() const
Returns \c true if the map contains no items; otherwise returns
false.
@@ -636,7 +636,7 @@ void QMapDataBase::freeData(QMapDataBase *d)
\sa size()
*/
-/*! \fn void QMap::detach()
+/*! \fn template <class Key, class T> void QMap<Key, T>::detach()
\internal
@@ -646,7 +646,7 @@ void QMapDataBase::freeData(QMapDataBase *d)
\sa isDetached()
*/
-/*! \fn bool QMap::isDetached() const
+/*! \fn template <class Key, class T> bool QMap<Key, T>::isDetached() const
\internal
@@ -656,24 +656,24 @@ void QMapDataBase::freeData(QMapDataBase *d)
\sa detach()
*/
-/*! \fn void QMap::setSharable(bool sharable)
+/*! \fn template <class Key, class T> void QMap<Key, T>::setSharable(bool sharable)
\internal
*/
-/*! \fn bool QMap::isSharedWith(const QMap<Key, T> &other) const
+/*! \fn template <class Key, class T> bool QMap<Key, T>::isSharedWith(const QMap<Key, T> &other) const
\internal
*/
-/*! \fn void QMap::clear()
+/*! \fn template <class Key, class T> void QMap<Key, T>::clear()
Removes all items from the map.
\sa remove()
*/
-/*! \fn int QMap::remove(const Key &key)
+/*! \fn template <class Key, class T> int QMap<Key, T>::remove(const Key &key)
Removes all the items that have the key \a key from the map.
Returns the number of items removed which is usually 1 but will be
@@ -683,7 +683,7 @@ void QMapDataBase::freeData(QMapDataBase *d)
\sa clear(), take(), QMultiMap::remove()
*/
-/*! \fn T QMap::take(const Key &key)
+/*! \fn template <class Key, class T> T QMap<Key, T>::take(const Key &key)
Removes the item with the key \a key from the map and returns
the value associated with it.
@@ -698,7 +698,7 @@ void QMapDataBase::freeData(QMapDataBase *d)
\sa remove()
*/
-/*! \fn bool QMap::contains(const Key &key) const
+/*! \fn template <class Key, class T> bool QMap<Key, T>::contains(const Key &key) const
Returns \c true if the map contains an item with key \a key;
otherwise returns \c false.
@@ -706,7 +706,7 @@ void QMapDataBase::freeData(QMapDataBase *d)
\sa count(), QMultiMap::contains()
*/
-/*! \fn const T QMap::value(const Key &key, const T &defaultValue) const
+/*! \fn template <class Key, class T> const T QMap<Key, T>::value(const Key &key, const T &defaultValue) const
Returns the value associated with the key \a key.
@@ -719,7 +719,7 @@ void QMapDataBase::freeData(QMapDataBase *d)
\sa key(), values(), contains(), operator[]()
*/
-/*! \fn T &QMap::operator[](const Key &key)
+/*! \fn template <class Key, class T> T &QMap<Key, T>::operator[](const Key &key)
Returns the value associated with the key \a key as a modifiable
reference.
@@ -733,14 +733,14 @@ void QMapDataBase::freeData(QMapDataBase *d)
\sa insert(), value()
*/
-/*! \fn const T QMap::operator[](const Key &key) const
+/*! \fn template <class Key, class T> const T QMap<Key, T>::operator[](const Key &key) const
\overload
Same as value().
*/
-/*! \fn QList<Key> QMap::uniqueKeys() const
+/*! \fn template <class Key, class T> QList<Key> QMap<Key, T>::uniqueKeys() const
\since 4.2
Returns a list containing all the keys in the map in ascending
@@ -751,7 +751,7 @@ void QMapDataBase::freeData(QMapDataBase *d)
\sa keys(), values()
*/
-/*! \fn QList<Key> QMap::keys() const
+/*! \fn template <class Key, class T> QList<Key> QMap<Key, T>::keys() const
Returns a list containing all the keys in the map in ascending
order. Keys that occur multiple times in the map (because items
@@ -766,7 +766,7 @@ void QMapDataBase::freeData(QMapDataBase *d)
\sa uniqueKeys(), values(), key()
*/
-/*! \fn QList<Key> QMap::keys(const T &value) const
+/*! \fn template <class Key, class T> QList<Key> QMap<Key, T>::keys(const T &value) const
\overload
@@ -779,7 +779,7 @@ void QMapDataBase::freeData(QMapDataBase *d)
*/
/*!
- \fn Key QMap::key(const T &value, const Key &defaultKey) const
+ \fn template <class Key, class T> Key QMap<Key, T>::key(const T &value, const Key &defaultKey) const
\since 4.3
\overload
@@ -795,7 +795,7 @@ void QMapDataBase::freeData(QMapDataBase *d)
\sa value(), keys()
*/
-/*! \fn QList<T> QMap::values() const
+/*! \fn template <class Key, class T> QList<T> QMap<Key, T>::values() const
Returns a list containing all the values in the map, in ascending
order of their keys. If a key is associated with multiple values,
@@ -805,7 +805,7 @@ void QMapDataBase::freeData(QMapDataBase *d)
\sa keys(), value()
*/
-/*! \fn QList<T> QMap::values(const Key &key) const
+/*! \fn template <class Key, class T> QList<T> QMap<Key, T>::values(const Key &key) const
\overload
@@ -816,21 +816,21 @@ void QMapDataBase::freeData(QMapDataBase *d)
\sa count(), insertMulti()
*/
-/*! \fn int QMap::count(const Key &key) const
+/*! \fn template <class Key, class T> int QMap<Key, T>::count(const Key &key) const
Returns the number of items associated with key \a key.
\sa contains(), insertMulti(), QMultiMap::count()
*/
-/*! \fn int QMap::count() const
+/*! \fn template <class Key, class T> int QMap<Key, T>::count() const
\overload
Same as size().
*/
-/*! \fn QMap::iterator QMap::begin()
+/*! \fn template <class Key, class T> QMap<Key, T>::iterator QMap<Key, T>::begin()
Returns an \l{STL-style iterators}{STL-style iterator} pointing to the first item in
the map.
@@ -838,12 +838,12 @@ void QMapDataBase::freeData(QMapDataBase *d)
\sa constBegin(), end()
*/
-/*! \fn QMap::const_iterator QMap::begin() const
+/*! \fn template <class Key, class T> QMap<Key, T>::const_iterator QMap<Key, T>::begin() const
\overload
*/
-/*! \fn QMap::const_iterator QMap::cbegin() const
+/*! \fn template <class Key, class T> QMap<Key, T>::const_iterator QMap<Key, T>::cbegin() const
\since 5.0
Returns a const \l{STL-style iterators}{STL-style iterator} pointing to the first item
@@ -852,7 +852,7 @@ void QMapDataBase::freeData(QMapDataBase *d)
\sa begin(), cend()
*/
-/*! \fn QMap::const_iterator QMap::constBegin() const
+/*! \fn template <class Key, class T> QMap<Key, T>::const_iterator QMap<Key, T>::constBegin() const
Returns a const \l{STL-style iterators}{STL-style iterator} pointing to the first item
in the map.
@@ -860,7 +860,7 @@ void QMapDataBase::freeData(QMapDataBase *d)
\sa begin(), constEnd()
*/
-/*! \fn QMap::key_iterator QMap::keyBegin() const
+/*! \fn template <class Key, class T> QMap<Key, T>::key_iterator QMap<Key, T>::keyBegin() const
\since 5.6
Returns a const \l{STL-style iterators}{STL-style iterator} pointing to the first key
@@ -869,7 +869,7 @@ void QMapDataBase::freeData(QMapDataBase *d)
\sa keyEnd(), firstKey()
*/
-/*! \fn QMap::iterator QMap::end()
+/*! \fn template <class Key, class T> QMap<Key, T>::iterator QMap<Key, T>::end()
Returns an \l{STL-style iterators}{STL-style iterator} pointing to the imaginary item
after the last item in the map.
@@ -877,12 +877,12 @@ void QMapDataBase::freeData(QMapDataBase *d)
\sa begin(), constEnd()
*/
-/*! \fn QMap::const_iterator QMap::end() const
+/*! \fn template <class Key, class T> QMap<Key, T>::const_iterator QMap<Key, T>::end() const
\overload
*/
-/*! \fn QMap::const_iterator QMap::cend() const
+/*! \fn template <class Key, class T> QMap<Key, T>::const_iterator QMap<Key, T>::cend() const
\since 5.0
Returns a const \l{STL-style iterators}{STL-style iterator} pointing to the imaginary
@@ -891,7 +891,7 @@ void QMapDataBase::freeData(QMapDataBase *d)
\sa cbegin(), end()
*/
-/*! \fn QMap::const_iterator QMap::constEnd() const
+/*! \fn template <class Key, class T> QMap<Key, T>::const_iterator QMap<Key, T>::constEnd() const
Returns a const \l{STL-style iterators}{STL-style iterator} pointing to the imaginary
item after the last item in the map.
@@ -899,7 +899,7 @@ void QMapDataBase::freeData(QMapDataBase *d)
\sa constBegin(), end()
*/
-/*! \fn QMap::key_iterator QMap::keyEnd() const
+/*! \fn template <class Key, class T> QMap<Key, T>::key_iterator QMap<Key, T>::keyEnd() const
\since 5.6
Returns a const \l{STL-style iterators}{STL-style iterator} pointing to the imaginary
@@ -909,7 +909,7 @@ void QMapDataBase::freeData(QMapDataBase *d)
*/
-/*! \fn QMap::key_value_iterator QMap::keyValueBegin()
+/*! \fn template <class Key, class T> QMap<Key, T>::key_value_iterator QMap<Key, T>::keyValueBegin()
\since 5.10
Returns an \l{STL-style iterators}{STL-style iterator} pointing to the first entry
@@ -918,7 +918,7 @@ void QMapDataBase::freeData(QMapDataBase *d)
\sa keyValueEnd()
*/
-/*! \fn QMap::key_value_iterator QMap::keyValueEnd()
+/*! \fn template <class Key, class T> QMap<Key, T>::key_value_iterator QMap<Key, T>::keyValueEnd()
\since 5.10
Returns an \l{STL-style iterators}{STL-style iterator} pointing to the imaginary
@@ -927,7 +927,7 @@ void QMapDataBase::freeData(QMapDataBase *d)
\sa keyValueBegin()
*/
-/*! \fn QMap::const_key_value_iterator QMap::keyValueBegin() const
+/*! \fn template <class Key, class T> QMap<Key, T>::const_key_value_iterator QMap<Key, T>::keyValueBegin() const
\since 5.10
Returns a const \l{STL-style iterators}{STL-style iterator} pointing to the first entry
@@ -936,7 +936,7 @@ void QMapDataBase::freeData(QMapDataBase *d)
\sa keyValueEnd()
*/
-/*! \fn QMap::const_key_value_iterator QMap::constKeyValueBegin() const
+/*! \fn template <class Key, class T> QMap<Key, T>::const_key_value_iterator QMap<Key, T>::constKeyValueBegin() const
\since 5.10
Returns a const \l{STL-style iterators}{STL-style iterator} pointing to the first entry
@@ -945,7 +945,7 @@ void QMapDataBase::freeData(QMapDataBase *d)
\sa keyValueBegin()
*/
-/*! \fn QMap::const_key_value_iterator QMap::keyValueEnd() const
+/*! \fn template <class Key, class T> QMap<Key, T>::const_key_value_iterator QMap<Key, T>::keyValueEnd() const
\since 5.10
Returns a const \l{STL-style iterators}{STL-style iterator} pointing to the imaginary
@@ -954,7 +954,7 @@ void QMapDataBase::freeData(QMapDataBase *d)
\sa keyValueBegin()
*/
-/*! \fn QMap::const_key_value_iterator QMap::constKeyValueEnd() const
+/*! \fn template <class Key, class T> QMap<Key, T>::const_key_value_iterator QMap<Key, T>::constKeyValueEnd() const
\since 5.10
Returns a const \l{STL-style iterators}{STL-style iterator} pointing to the imaginary
@@ -963,7 +963,7 @@ void QMapDataBase::freeData(QMapDataBase *d)
\sa constKeyValueBegin()
*/
-/*! \fn const Key &QMap::firstKey() const
+/*! \fn template <class Key, class T> const Key &QMap<Key, T>::firstKey() const
\since 5.2
Returns a reference to the smallest key in the map.
@@ -974,7 +974,7 @@ void QMapDataBase::freeData(QMapDataBase *d)
\sa lastKey(), first(), keyBegin(), isEmpty()
*/
-/*! \fn const Key &QMap::lastKey() const
+/*! \fn template <class Key, class T> const Key &QMap<Key, T>::lastKey() const
\since 5.2
Returns a reference to the largest key in the map.
@@ -985,7 +985,7 @@ void QMapDataBase::freeData(QMapDataBase *d)
\sa firstKey(), last(), keyEnd(), isEmpty()
*/
-/*! \fn T &QMap::first()
+/*! \fn template <class Key, class T> T &QMap<Key, T>::first()
\since 5.2
Returns a reference to the first value in the map, that is the value mapped
@@ -996,13 +996,13 @@ void QMapDataBase::freeData(QMapDataBase *d)
\sa last(), firstKey(), isEmpty()
*/
-/*! \fn const T &QMap::first() const
+/*! \fn template <class Key, class T> const T &QMap<Key, T>::first() const
\since 5.2
\overload
*/
-/*! \fn T &QMap::last()
+/*! \fn template <class Key, class T> T &QMap<Key, T>::last()
\since 5.2
Returns a reference to the last value in the map, that is the value mapped
@@ -1013,13 +1013,13 @@ void QMapDataBase::freeData(QMapDataBase *d)
\sa first(), lastKey(), isEmpty()
*/
-/*! \fn const T &QMap::last() const
+/*! \fn template <class Key, class T> const T &QMap<Key, T>::last() const
\since 5.2
\overload
*/
-/*! \fn QMap::iterator QMap::erase(iterator pos)
+/*! \fn template <class Key, class T> QMap<Key, T>::iterator QMap<Key, T>::erase(iterator pos)
Removes the (key, value) pair pointed to by the iterator \a pos
from the map, and returns an iterator to the next item in the
@@ -1028,7 +1028,7 @@ void QMapDataBase::freeData(QMapDataBase *d)
\sa remove()
*/
-/*! \fn QMap::iterator QMap::find(const Key &key)
+/*! \fn template <class Key, class T> QMap<Key, T>::iterator QMap<Key, T>::find(const Key &key)
Returns an iterator pointing to the item with key \a key in the
map.
@@ -1047,12 +1047,12 @@ void QMapDataBase::freeData(QMapDataBase *d)
\sa constFind(), value(), values(), lowerBound(), upperBound(), QMultiMap::find()
*/
-/*! \fn QMap::const_iterator QMap::find(const Key &key) const
+/*! \fn template <class Key, class T> QMap<Key, T>::const_iterator QMap<Key, T>::find(const Key &key) const
\overload
*/
-/*! \fn QMap::const_iterator QMap::constFind(const Key &key) const
+/*! \fn template <class Key, class T> QMap<Key, T>::const_iterator QMap<Key, T>::constFind(const Key &key) const
\since 4.1
Returns an const iterator pointing to the item with key \a key in the
@@ -1064,7 +1064,7 @@ void QMapDataBase::freeData(QMapDataBase *d)
\sa find(), QMultiMap::constFind()
*/
-/*! \fn QMap::iterator QMap::lowerBound(const Key &key)
+/*! \fn template <class Key, class T> QMap<Key, T>::iterator QMap<Key, T>::lowerBound(const Key &key)
Returns an iterator pointing to the first item with key \a key in
the map. If the map contains no item with key \a key, the
@@ -1085,12 +1085,12 @@ void QMapDataBase::freeData(QMapDataBase *d)
\sa upperBound(), find()
*/
-/*! \fn QMap::const_iterator QMap::lowerBound(const Key &key) const
+/*! \fn template <class Key, class T> QMap<Key, T>::const_iterator QMap<Key, T>::lowerBound(const Key &key) const
\overload
*/
-/*! \fn QMap::iterator QMap::upperBound(const Key &key)
+/*! \fn template <class Key, class T> QMap<Key, T>::iterator QMap<Key, T>::upperBound(const Key &key)
Returns an iterator pointing to the item that immediately follows
the last item with key \a key in the map. If the map contains no
@@ -1103,12 +1103,12 @@ void QMapDataBase::freeData(QMapDataBase *d)
\sa lowerBound(), find()
*/
-/*! \fn QMap::const_iterator QMap::upperBound(const Key &key) const
+/*! \fn template <class Key, class T> QMap<Key, T>::const_iterator QMap<Key, T>::upperBound(const Key &key) const
\overload
*/
-/*! \fn QMap::iterator QMap::insert(const Key &key, const T &value)
+/*! \fn template <class Key, class T> QMap<Key, T>::iterator QMap<Key, T>::insert(const Key &key, const T &value)
Inserts a new item with the key \a key and a value of \a value.
@@ -1121,7 +1121,7 @@ void QMapDataBase::freeData(QMapDataBase *d)
\sa insertMulti()
*/
-/*! \fn QMap::iterator QMap::insert(const_iterator pos, const Key &key, const T &value)
+/*! \fn template <class Key, class T> QMap<Key, T>::iterator QMap<Key, T>::insert(const_iterator pos, const Key &key, const T &value)
\overload
\since 5.1
Inserts a new item with the key \a key and value \a value and with hint \a pos
@@ -1150,7 +1150,7 @@ void QMapDataBase::freeData(QMapDataBase *d)
\sa insertMulti()
*/
-/*! \fn QMap::iterator QMap::insertMulti(const Key &key, const T &value)
+/*! \fn template <class Key, class T> QMap<Key, T>::iterator QMap<Key, T>::insertMulti(const Key &key, const T &value)
Inserts a new item with the key \a key and a value of \a value.
@@ -1162,7 +1162,7 @@ void QMapDataBase::freeData(QMapDataBase *d)
\sa insert(), values()
*/
-/*! \fn QMap::iterator QMap::insertMulti(const_iterator pos, const Key &key, const T &value)
+/*! \fn template <class Key, class T> QMap<Key, T>::iterator QMap<Key, T>::insertMulti(const_iterator pos, const Key &key, const T &value)
\overload
\since 5.1
Inserts a new item with the key \a key and value \a value and with hint \a pos
@@ -1182,7 +1182,7 @@ void QMapDataBase::freeData(QMapDataBase *d)
*/
-/*! \fn QMap<Key, T> &QMap::unite(const QMap<Key, T> &other)
+/*! \fn template <class Key, class T> QMap<Key, T> &QMap<Key, T>::unite(const QMap<Key, T> &other)
Inserts all the items in the \a other map into this map. If a
key is common to both maps, the resulting map will contain the
@@ -1193,12 +1193,12 @@ void QMapDataBase::freeData(QMapDataBase *d)
/*! \typedef QMap::Iterator
- Qt-style synonym for QMap::iterator.
+ Qt-style synonym for QMap<Key, T>::iterator.
*/
/*! \typedef QMap::ConstIterator
- Qt-style synonym for QMap::const_iterator.
+ Qt-style synonym for QMap<Key, T>::const_iterator.
*/
/*! \typedef QMap::difference_type
@@ -1222,7 +1222,7 @@ void QMapDataBase::freeData(QMapDataBase *d)
*/
/*!
- \fn bool QMap::empty() const
+ \fn template <class Key, class T> bool QMap<Key, T>::empty() const
This function is provided for STL compatibility. It is equivalent
to isEmpty(), returning true if the map is empty; otherwise
@@ -1230,14 +1230,14 @@ void QMapDataBase::freeData(QMapDataBase *d)
*/
/*!
- \fn QPair<iterator, iterator> QMap::equal_range(const Key &key)
+ \fn template <class Key, class T> QPair<iterator, iterator> QMap<Key, T>::equal_range(const Key &key)
Returns a pair of iterators delimiting the range of values \c{[first, second)}, that
are stored under \a key.
*/
/*!
- \fn QPair<const_iterator, const_iterator> QMap::equal_range(const Key &key) const
+ \fn template <class Key, class T> QPair<const_iterator, const_iterator> QMap<Key, T>::equal_range(const Key &key) const
\overload
\since 5.6
*/
@@ -1339,7 +1339,7 @@ void QMapDataBase::freeData(QMapDataBase *d)
\internal
*/
-/*! \fn QMap::iterator::iterator()
+/*! \fn template <class Key, class T> QMap<Key, T>::iterator::iterator()
Constructs an uninitialized iterator.
@@ -1350,12 +1350,12 @@ void QMapDataBase::freeData(QMapDataBase *d)
\sa QMap::begin(), QMap::end()
*/
-/*! \fn QMap::iterator::iterator(Node *)
+/*! \fn template <class Key, class T> QMap<Key, T>::iterator::iterator(Node *)
\internal
*/
-/*! \fn const Key &QMap::iterator::key() const
+/*! \fn template <class Key, class T> const Key &QMap<Key, T>::iterator::key() const
Returns the current item's key as a const reference.
@@ -1366,7 +1366,7 @@ void QMapDataBase::freeData(QMapDataBase *d)
\sa value()
*/
-/*! \fn T &QMap::iterator::value() const
+/*! \fn template <class Key, class T> T &QMap<Key, T>::iterator::value() const
Returns a modifiable reference to the current item's value.
@@ -1378,7 +1378,7 @@ void QMapDataBase::freeData(QMapDataBase *d)
\sa key(), operator*()
*/
-/*! \fn T &QMap::iterator::operator*() const
+/*! \fn template <class Key, class T> T &QMap<Key, T>::iterator::operator*() const
Returns a modifiable reference to the current item's value.
@@ -1387,7 +1387,7 @@ void QMapDataBase::freeData(QMapDataBase *d)
\sa key()
*/
-/*! \fn T *QMap::iterator::operator->() const
+/*! \fn template <class Key, class T> T *QMap<Key, T>::iterator::operator->() const
Returns a pointer to the current item's value.
@@ -1395,8 +1395,8 @@ void QMapDataBase::freeData(QMapDataBase *d)
*/
/*!
- \fn bool QMap::iterator::operator==(const iterator &other) const
- \fn bool QMap::iterator::operator==(const const_iterator &other) const
+ \fn template <class Key, class T> bool QMap<Key, T>::iterator::operator==(const iterator &other) const
+ \fn template <class Key, class T> bool QMap<Key, T>::iterator::operator==(const const_iterator &other) const
Returns \c true if \a other points to the same item as this
iterator; otherwise returns \c false.
@@ -1405,8 +1405,8 @@ void QMapDataBase::freeData(QMapDataBase *d)
*/
/*!
- \fn bool QMap::iterator::operator!=(const iterator &other) const
- \fn bool QMap::iterator::operator!=(const const_iterator &other) const
+ \fn template <class Key, class T> bool QMap<Key, T>::iterator::operator!=(const iterator &other) const
+ \fn template <class Key, class T> bool QMap<Key, T>::iterator::operator!=(const const_iterator &other) const
Returns \c true if \a other points to a different item than this
iterator; otherwise returns \c false.
@@ -1414,7 +1414,7 @@ void QMapDataBase::freeData(QMapDataBase *d)
\sa operator==()
*/
-/*! \fn QMap::iterator QMap::iterator::operator++()
+/*! \fn template <class Key, class T> QMap<Key, T>::iterator QMap<Key, T>::iterator::operator++()
The prefix ++ operator (\c{++i}) advances the iterator to the
next item in the map and returns an iterator to the new current
@@ -1425,7 +1425,7 @@ void QMapDataBase::freeData(QMapDataBase *d)
\sa operator--()
*/
-/*! \fn QMap::iterator QMap::iterator::operator++(int)
+/*! \fn template <class Key, class T> QMap<Key, T>::iterator QMap<Key, T>::iterator::operator++(int)
\overload
@@ -1434,7 +1434,7 @@ void QMapDataBase::freeData(QMapDataBase *d)
current item.
*/
-/*! \fn QMap::iterator QMap::iterator::operator--()
+/*! \fn template <class Key, class T> QMap<Key, T>::iterator QMap<Key, T>::iterator::operator--()
The prefix -- operator (\c{--i}) makes the preceding item
current and returns an iterator pointing to the new current item.
@@ -1445,7 +1445,7 @@ void QMapDataBase::freeData(QMapDataBase *d)
\sa operator++()
*/
-/*! \fn QMap::iterator QMap::iterator::operator--(int)
+/*! \fn template <class Key, class T> QMap<Key, T>::iterator QMap<Key, T>::iterator::operator--(int)
\overload
@@ -1454,7 +1454,7 @@ void QMapDataBase::freeData(QMapDataBase *d)
current item.
*/
-/*! \fn QMap::iterator QMap::iterator::operator+(int j) const
+/*! \fn template <class Key, class T> QMap<Key, T>::iterator QMap<Key, T>::iterator::operator+(int j) const
Returns an iterator to the item at \a j positions forward from
this iterator. (If \a j is negative, the iterator goes backward.)
@@ -1465,7 +1465,7 @@ void QMapDataBase::freeData(QMapDataBase *d)
*/
-/*! \fn QMap::iterator QMap::iterator::operator-(int j) const
+/*! \fn template <class Key, class T> QMap<Key, T>::iterator QMap<Key, T>::iterator::operator-(int j) const
Returns an iterator to the item at \a j positions backward from
this iterator. (If \a j is negative, the iterator goes forward.)
@@ -1475,7 +1475,7 @@ void QMapDataBase::freeData(QMapDataBase *d)
\sa operator+()
*/
-/*! \fn QMap::iterator &QMap::iterator::operator+=(int j)
+/*! \fn template <class Key, class T> QMap<Key, T>::iterator &QMap<Key, T>::iterator::operator+=(int j)
Advances the iterator by \a j items. (If \a j is negative, the
iterator goes backward.)
@@ -1483,7 +1483,7 @@ void QMapDataBase::freeData(QMapDataBase *d)
\sa operator-=(), operator+()
*/
-/*! \fn QMap::iterator &QMap::iterator::operator-=(int j)
+/*! \fn template <class Key, class T> QMap<Key, T>::iterator &QMap<Key, T>::iterator::operator-=(int j)
Makes the iterator go back by \a j items. (If \a j is negative,
the iterator goes forward.)
@@ -1562,7 +1562,7 @@ void QMapDataBase::freeData(QMapDataBase *d)
\internal
*/
-/*! \fn QMap::const_iterator::const_iterator()
+/*! \fn template <class Key, class T> QMap<Key, T>::const_iterator::const_iterator()
Constructs an uninitialized iterator.
@@ -1573,31 +1573,31 @@ void QMapDataBase::freeData(QMapDataBase *d)
\sa QMap::constBegin(), QMap::constEnd()
*/
-/*! \fn QMap::const_iterator::const_iterator(const Node *)
+/*! \fn template <class Key, class T> QMap<Key, T>::const_iterator::const_iterator(const Node *)
\internal
*/
-/*! \fn QMap::const_iterator::const_iterator(const iterator &other)
+/*! \fn template <class Key, class T> QMap<Key, T>::const_iterator::const_iterator(const iterator &other)
Constructs a copy of \a other.
*/
-/*! \fn const Key &QMap::const_iterator::key() const
+/*! \fn template <class Key, class T> const Key &QMap<Key, T>::const_iterator::key() const
Returns the current item's key.
\sa value()
*/
-/*! \fn const T &QMap::const_iterator::value() const
+/*! \fn template <class Key, class T> const T &QMap<Key, T>::const_iterator::value() const
Returns the current item's value.
\sa key(), operator*()
*/
-/*! \fn const T &QMap::const_iterator::operator*() const
+/*! \fn template <class Key, class T> const T &QMap<Key, T>::const_iterator::operator*() const
Returns the current item's value.
@@ -1606,14 +1606,14 @@ void QMapDataBase::freeData(QMapDataBase *d)
\sa key()
*/
-/*! \fn const T *QMap::const_iterator::operator->() const
+/*! \fn template <class Key, class T> const T *QMap<Key, T>::const_iterator::operator->() const
Returns a pointer to the current item's value.
\sa value()
*/
-/*! \fn bool QMap::const_iterator::operator==(const const_iterator &other) const
+/*! \fn template <class Key, class T> bool QMap<Key, T>::const_iterator::operator==(const const_iterator &other) const
Returns \c true if \a other points to the same item as this
iterator; otherwise returns \c false.
@@ -1621,7 +1621,7 @@ void QMapDataBase::freeData(QMapDataBase *d)
\sa operator!=()
*/
-/*! \fn bool QMap::const_iterator::operator!=(const const_iterator &other) const
+/*! \fn template <class Key, class T> bool QMap<Key, T>::const_iterator::operator!=(const const_iterator &other) const
Returns \c true if \a other points to a different item than this
iterator; otherwise returns \c false.
@@ -1629,7 +1629,7 @@ void QMapDataBase::freeData(QMapDataBase *d)
\sa operator==()
*/
-/*! \fn QMap::const_iterator QMap::const_iterator::operator++()
+/*! \fn template <class Key, class T> QMap<Key, T>::const_iterator QMap<Key, T>::const_iterator::operator++()
The prefix ++ operator (\c{++i}) advances the iterator to the
next item in the map and returns an iterator to the new current
@@ -1640,7 +1640,7 @@ void QMapDataBase::freeData(QMapDataBase *d)
\sa operator--()
*/
-/*! \fn QMap::const_iterator QMap::const_iterator::operator++(int)
+/*! \fn template <class Key, class T> QMap<Key, T>::const_iterator QMap<Key, T>::const_iterator::operator++(int)
\overload
@@ -1649,7 +1649,7 @@ void QMapDataBase::freeData(QMapDataBase *d)
current item.
*/
-/*! \fn QMap::const_iterator &QMap::const_iterator::operator--()
+/*! \fn template <class Key, class T> QMap<Key, T>::const_iterator &QMap<Key, T>::const_iterator::operator--()
The prefix -- operator (\c{--i}) makes the preceding item
current and returns an iterator pointing to the new current item.
@@ -1660,7 +1660,7 @@ void QMapDataBase::freeData(QMapDataBase *d)
\sa operator++()
*/
-/*! \fn QMap::const_iterator QMap::const_iterator::operator--(int)
+/*! \fn template <class Key, class T> QMap<Key, T>::const_iterator QMap<Key, T>::const_iterator::operator--(int)
\overload
@@ -1669,7 +1669,7 @@ void QMapDataBase::freeData(QMapDataBase *d)
current item.
*/
-/*! \fn QMap::const_iterator QMap::const_iterator::operator+(int j) const
+/*! \fn template <class Key, class T> QMap<Key, T>::const_iterator QMap<Key, T>::const_iterator::operator+(int j) const
Returns an iterator to the item at \a j positions forward from
this iterator. (If \a j is negative, the iterator goes backward.)
@@ -1679,7 +1679,7 @@ void QMapDataBase::freeData(QMapDataBase *d)
\sa operator-()
*/
-/*! \fn QMap::const_iterator QMap::const_iterator::operator-(int j) const
+/*! \fn template <class Key, class T> QMap<Key, T>::const_iterator QMap<Key, T>::const_iterator::operator-(int j) const
Returns an iterator to the item at \a j positions backward from
this iterator. (If \a j is negative, the iterator goes forward.)
@@ -1689,7 +1689,7 @@ void QMapDataBase::freeData(QMapDataBase *d)
\sa operator+()
*/
-/*! \fn QMap::const_iterator &QMap::const_iterator::operator+=(int j)
+/*! \fn template <class Key, class T> QMap<Key, T>::const_iterator &QMap<Key, T>::const_iterator::operator+=(int j)
Advances the iterator by \a j items. (If \a j is negative, the
iterator goes backward.)
@@ -1699,7 +1699,7 @@ void QMapDataBase::freeData(QMapDataBase *d)
\sa operator-=(), operator+()
*/
-/*! \fn QMap::const_iterator &QMap::const_iterator::operator-=(int j)
+/*! \fn template <class Key, class T> QMap<Key, T>::const_iterator &QMap<Key, T>::const_iterator::operator-=(int j)
Makes the iterator go back by \a j items. (If \a j is negative,
the iterator goes forward.)
@@ -1766,17 +1766,17 @@ void QMapDataBase::freeData(QMapDataBase *d)
\internal
*/
-/*! \fn const T &QMap::key_iterator::operator*() const
+/*! \fn template <class Key, class T> const T &QMap<Key, T>::key_iterator::operator*() const
Returns the current item's key.
*/
-/*! \fn const T *QMap::key_iterator::operator->() const
+/*! \fn template <class Key, class T> const T *QMap<Key, T>::key_iterator::operator->() const
Returns a pointer to the current item's key.
*/
-/*! \fn bool QMap::key_iterator::operator==(key_iterator other) const
+/*! \fn template <class Key, class T> bool QMap<Key, T>::key_iterator::operator==(key_iterator other) const
Returns \c true if \a other points to the same item as this
iterator; otherwise returns \c false.
@@ -1784,7 +1784,7 @@ void QMapDataBase::freeData(QMapDataBase *d)
\sa operator!=()
*/
-/*! \fn bool QMap::key_iterator::operator!=(key_iterator other) const
+/*! \fn template <class Key, class T> bool QMap<Key, T>::key_iterator::operator!=(key_iterator other) const
Returns \c true if \a other points to a different item than this
iterator; otherwise returns \c false.
@@ -1793,7 +1793,7 @@ void QMapDataBase::freeData(QMapDataBase *d)
*/
/*!
- \fn QMap::key_iterator &QMap::key_iterator::operator++()
+ \fn template <class Key, class T> QMap<Key, T>::key_iterator &QMap<Key, T>::key_iterator::operator++()
The prefix ++ operator (\c{++i}) advances the iterator to the
next item in the hash and returns an iterator to the new current
@@ -1804,7 +1804,7 @@ void QMapDataBase::freeData(QMapDataBase *d)
\sa operator--()
*/
-/*! \fn QMap::key_iterator QMap::key_iterator::operator++(int)
+/*! \fn template <class Key, class T> QMap<Key, T>::key_iterator QMap<Key, T>::key_iterator::operator++(int)
\overload
@@ -1813,7 +1813,7 @@ void QMapDataBase::freeData(QMapDataBase *d)
item.
*/
-/*! \fn QMap::key_iterator &QMap::key_iterator::operator--()
+/*! \fn template <class Key, class T> QMap<Key, T>::key_iterator &QMap<Key, T>::key_iterator::operator--()
The prefix -- operator (\c{--i}) makes the preceding item
current and returns an iterator pointing to the new current item.
@@ -1824,7 +1824,7 @@ void QMapDataBase::freeData(QMapDataBase *d)
\sa operator++()
*/
-/*! \fn QMap::key_iterator QMap::key_iterator::operator--(int)
+/*! \fn template <class Key, class T> QMap<Key, T>::key_iterator QMap<Key, T>::key_iterator::operator--(int)
\overload
@@ -1833,10 +1833,22 @@ void QMapDataBase::freeData(QMapDataBase *d)
item.
*/
-/*! \fn const_iterator QMap::key_iterator::base() const
+/*! \fn template <class Key, class T> const_iterator QMap<Key, T>::key_iterator::base() const
Returns the underlying const_iterator this key_iterator is based on.
*/
+/*! \typedef QMap::const_key_value_iterator
+ \inmodule QtCore
+ \since 5.10
+ \brief The QMap::const_key_value_iterator typedef provides an STL-style iterator for QMap and QMultiMap.
+
+ QMap::const_key_value_iterator is essentially the same as QMap::const_iterator
+ with the difference that operator*() returns a key/value pair instead of a
+ value.
+
+ \sa QKeyValueIterator
+*/
+
/*! \typedef QMap::key_value_iterator
\inmodule QtCore
\since 5.10
@@ -1849,7 +1861,7 @@ void QMapDataBase::freeData(QMapDataBase *d)
\sa QKeyValueIterator
*/
-/*! \fn QDataStream &operator<<(QDataStream &out, const QMap<Key, T> &map)
+/*! \fn template <class Key, class T> QDataStream &operator<<(QDataStream &out, const QMap<Key, T> &map)
\relates QMap
Writes the map \a map to stream \a out.
@@ -1860,7 +1872,7 @@ void QMapDataBase::freeData(QMapDataBase *d)
\sa{Serializing Qt Data Types}{Format of the QDataStream operators}
*/
-/*! \fn QDataStream &operator>>(QDataStream &in, QMap<Key, T> &map)
+/*! \fn template <class Key, class T> QDataStream &operator>>(QDataStream &in, QMap<Key, T> &map)
\relates QMap
Reads a map from stream \a in into \a map.
@@ -1926,12 +1938,12 @@ void QMapDataBase::freeData(QMapDataBase *d)
\sa QMap, QMapIterator, QMutableMapIterator, QMultiHash
*/
-/*! \fn QMultiMap::QMultiMap()
+/*! \fn template <class Key, class T> QMultiMap<Key, T>::QMultiMap()
Constructs an empty map.
*/
-/*! \fn QMultiMap::QMultiMap(std::initializer_list<std::pair<Key,T> > list)
+/*! \fn template <class Key, class T> QMultiMap<Key, T>::QMultiMap(std::initializer_list<std::pair<Key,T> > list)
\since 5.1
Constructs a multi-map with a copy of each of the elements in the
@@ -1941,7 +1953,7 @@ void QMapDataBase::freeData(QMapDataBase *d)
compiled in C++11 mode.
*/
-/*! \fn QMultiMap::QMultiMap(const QMap<Key, T> &other)
+/*! \fn template <class Key, class T> QMultiMap<Key, T>::QMultiMap(const QMap<Key, T> &other)
Constructs a copy of \a other (which can be a QMap or a
QMultiMap).
@@ -1949,7 +1961,7 @@ void QMapDataBase::freeData(QMapDataBase *d)
\sa operator=()
*/
-/*! \fn QMultiMap::iterator QMultiMap::replace(const Key &key, const T &value)
+/*! \fn template <class Key, class T> QMultiMap<Key, T>::iterator QMultiMap<Key, T>::replace(const Key &key, const T &value)
Inserts a new item with the key \a key and a value of \a value.
@@ -1962,7 +1974,7 @@ void QMapDataBase::freeData(QMapDataBase *d)
\sa insert()
*/
-/*! \fn QMultiMap::iterator QMultiMap::insert(const Key &key, const T &value)
+/*! \fn template <class Key, class T> QMultiMap<Key, T>::iterator QMultiMap<Key, T>::insert(const Key &key, const T &value)
Inserts a new item with the key \a key and a value of \a value.
@@ -1974,7 +1986,7 @@ void QMapDataBase::freeData(QMapDataBase *d)
\sa replace()
*/
-/*! \fn QMultiMap::iterator QMultiMap::insert(QMap<Key, T>::const_iterator pos, const Key &key, const T &value)
+/*! \fn template <class Key, class T> typename QMap<Key, T>::iterator QMultiMap<Key, T>::insert(typename QMap<Key, T>::const_iterator pos, const Key &key, const T &value)
\since 5.1
Inserts a new item with the key \a key and value \a value and with hint \a pos
@@ -1991,7 +2003,7 @@ void QMapDataBase::freeData(QMapDataBase *d)
crash but there is also a risk that it will silently corrupt both the map and the \a pos map.
*/
-/*! \fn QMultiMap &QMultiMap::operator+=(const QMultiMap &other)
+/*! \fn template <class Key, class T> QMultiMap &QMultiMap<Key, T>::operator+=(const QMultiMap &other)
Inserts all the items in the \a other map into this map and
returns a reference to this map.
@@ -1999,7 +2011,7 @@ void QMapDataBase::freeData(QMapDataBase *d)
\sa insert(), operator+()
*/
-/*! \fn QMultiMap QMultiMap::operator+(const QMultiMap &other) const
+/*! \fn template <class Key, class T> QMultiMap QMultiMap<Key, T>::operator+(const QMultiMap &other) const
Returns a map that contains all the items in this map in
addition to all the items in \a other. If a key is common to both
@@ -2009,7 +2021,7 @@ void QMapDataBase::freeData(QMapDataBase *d)
*/
/*!
- \fn bool QMultiMap::contains(const Key &key, const T &value) const
+ \fn template <class Key, class T> bool QMultiMap<Key, T>::contains(const Key &key, const T &value) const
\since 4.3
Returns \c true if the map contains an item with key \a key and
@@ -2019,7 +2031,7 @@ void QMapDataBase::freeData(QMapDataBase *d)
*/
/*!
- \fn int QMultiMap::remove(const Key &key, const T &value)
+ \fn template <class Key, class T> int QMultiMap<Key, T>::remove(const Key &key, const T &value)
\since 4.3
Removes all the items that have the key \a key and the value \a
@@ -2029,7 +2041,7 @@ void QMapDataBase::freeData(QMapDataBase *d)
*/
/*!
- \fn int QMultiMap::count(const Key &key, const T &value) const
+ \fn template <class Key, class T> int QMultiMap<Key, T>::count(const Key &key, const T &value) const
\since 4.3
Returns the number of items with key \a key and value \a value.
@@ -2038,7 +2050,7 @@ void QMapDataBase::freeData(QMapDataBase *d)
*/
/*!
- \fn typename QMap<Key, T>::iterator QMultiMap::find(const Key &key, const T &value)
+ \fn template <class Key, class T> typename QMap<Key, T>::iterator QMultiMap<Key, T>::find(const Key &key, const T &value)
\since 4.3
Returns an iterator pointing to the item with key \a key and
@@ -2054,7 +2066,7 @@ void QMapDataBase::freeData(QMapDataBase *d)
*/
/*!
- \fn typename QMap<Key, T>::const_iterator QMultiMap::find(const Key &key, const T &value) const
+ \fn template <class Key, class T> typename QMap<Key, T>::const_iterator QMultiMap<Key, T>::find(const Key &key, const T &value) const
\since 4.3
\overload
@@ -2071,7 +2083,7 @@ void QMapDataBase::freeData(QMapDataBase *d)
*/
/*!
- \fn typename QMap<Key, T>::const_iterator QMultiMap::constFind(const Key &key, const T &value) const
+ \fn template <class Key, class T> typename QMap<Key, T>::const_iterator QMultiMap<Key, T>::constFind(const Key &key, const T &value) const
\since 4.3
Returns an iterator pointing to the item with key \a key and the
diff --git a/src/corelib/tools/qmap.h b/src/corelib/tools/qmap.h
index 16442014ff..fc72c6e32c 100644
--- a/src/corelib/tools/qmap.h
+++ b/src/corelib/tools/qmap.h
@@ -150,7 +150,7 @@ template <class Key, class T>
inline QMapNode<Key, T> *QMapNode<Key, T>::lowerBound(const Key &akey)
{
QMapNode<Key, T> *n = this;
- QMapNode<Key, T> *lastNode = Q_NULLPTR;
+ QMapNode<Key, T> *lastNode = nullptr;
while (n) {
if (!qMapLessThanKey(n->key, akey)) {
lastNode = n;
@@ -166,7 +166,7 @@ template <class Key, class T>
inline QMapNode<Key, T> *QMapNode<Key, T>::upperBound(const Key &akey)
{
QMapNode<Key, T> *n = this;
- QMapNode<Key, T> *lastNode = Q_NULLPTR;
+ QMapNode<Key, T> *lastNode = nullptr;
while (n) {
if (qMapLessThanKey(akey, n->key)) {
lastNode = n;
@@ -220,7 +220,7 @@ struct QMapData : public QMapDataBase
Node *findNode(const Key &akey) const;
void nodeRange(const Key &akey, Node **firstNode, Node **lastNode);
- Node *createNode(const Key &k, const T &v, Node *parent = Q_NULLPTR, bool left = false)
+ Node *createNode(const Key &k, const T &v, Node *parent = nullptr, bool left = false)
{
Node *n = static_cast<Node *>(QMapDataBase::createNode(sizeof(Node), Q_ALIGNOF(Node),
parent, left));
@@ -261,13 +261,13 @@ QMapNode<Key, T> *QMapNode<Key, T>::copy(QMapData<Key, T> *d) const
n->left = leftNode()->copy(d);
n->left->setParent(n);
} else {
- n->left = Q_NULLPTR;
+ n->left = nullptr;
}
if (right) {
n->right = rightNode()->copy(d);
n->right->setParent(n);
} else {
- n->right = Q_NULLPTR;
+ n->right = nullptr;
}
return n;
}
@@ -288,7 +288,7 @@ QMapNode<Key, T> *QMapData<Key, T>::findNode(const Key &akey) const
if (lb && !qMapLessThanKey(akey, lb->key))
return lb;
}
- return Q_NULLPTR;
+ return nullptr;
}
@@ -304,10 +304,10 @@ void QMapData<Key, T>::nodeRange(const Key &akey, QMapNode<Key, T> **firstNode,
} else if (qMapLessThanKey(n->key, akey)) {
n = n->rightNode();
} else {
- *firstNode = n->leftNode() ? n->leftNode()->lowerBound(akey) : Q_NULLPTR;
+ *firstNode = n->leftNode() ? n->leftNode()->lowerBound(akey) : nullptr;
if (!*firstNode)
*firstNode = n;
- *lastNode = n->rightNode() ? n->rightNode()->upperBound(akey) : Q_NULLPTR;
+ *lastNode = n->rightNode() ? n->rightNode()->upperBound(akey) : nullptr;
if (!*lastNode)
*lastNode = l;
return;
@@ -416,7 +416,7 @@ public:
typedef T *pointer;
typedef T &reference;
- inline iterator() : i(Q_NULLPTR) { }
+ inline iterator() : i(nullptr) { }
inline iterator(Node *node) : i(node) { }
inline const Key &key() const { return i->key; }
@@ -473,7 +473,7 @@ public:
typedef const T *pointer;
typedef const T &reference;
- Q_DECL_CONSTEXPR inline const_iterator() : i(Q_NULLPTR) { }
+ Q_DECL_CONSTEXPR inline const_iterator() : i(nullptr) { }
inline const_iterator(const Node *node) : i(node) { }
#ifdef QT_STRICT_ITERATORS
explicit inline const_iterator(const iterator &o)
@@ -695,7 +695,7 @@ Q_INLINE_TEMPLATE int QMap<Key, T>::count(const Key &akey) const
template <class Key, class T>
Q_INLINE_TEMPLATE bool QMap<Key, T>::contains(const Key &akey) const
{
- return d->findNode(akey) != Q_NULLPTR;
+ return d->findNode(akey) != nullptr;
}
template <class Key, class T>
@@ -704,7 +704,7 @@ Q_INLINE_TEMPLATE typename QMap<Key, T>::iterator QMap<Key, T>::insert(const Key
detach();
Node *n = d->root();
Node *y = d->end();
- Node *lastNode = Q_NULLPTR;
+ Node *lastNode = nullptr;
bool left = true;
while (n) {
y = n;
@@ -779,15 +779,15 @@ typename QMap<Key, T>::iterator QMap<Key, T>::insert(const_iterator pos, const K
}
// we need to insert (not overwrite)
- if (prev->right == Q_NULLPTR) {
+ if (prev->right == nullptr) {
Node *z = d->createNode(akey, avalue, prev, false);
return iterator(z);
}
- if (next->left == Q_NULLPTR) {
+ if (next->left == nullptr) {
Node *z = d->createNode(akey, avalue, next, true);
return iterator(z);
}
- Q_ASSERT(false); // We should have prev->right == Q_NULLPTR or next->left == Q_NULLPTR.
+ Q_ASSERT(false); // We should have prev->right == nullptr or next->left == nullptr.
return this->insert(akey, avalue);
}
}
@@ -801,7 +801,7 @@ Q_INLINE_TEMPLATE typename QMap<Key, T>::iterator QMap<Key, T>::insertMulti(cons
Node* y = d->end();
Node* x = static_cast<Node *>(d->root());
bool left = true;
- while (x != Q_NULLPTR) {
+ while (x != nullptr) {
left = !qMapLessThanKey(x->key, akey);
y = x;
x = left ? x->leftNode() : x->rightNode();
@@ -848,15 +848,15 @@ typename QMap<Key, T>::iterator QMap<Key, T>::insertMulti(const_iterator pos, co
return this->insertMulti(akey, avalue); // ignore hint
// Hint is ok - do insert
- if (prev->right == Q_NULLPTR) {
+ if (prev->right == nullptr) {
Node *z = d->createNode(akey, avalue, prev, false);
return iterator(z);
}
- if (next->left == Q_NULLPTR) {
+ if (next->left == nullptr) {
Node *z = d->createNode(akey, avalue, next, true);
return iterator(z);
}
- Q_ASSERT(false); // We should have prev->right == Q_NULLPTR or next->left == Q_NULLPTR.
+ Q_ASSERT(false); // We should have prev->right == nullptr or next->left == nullptr.
return this->insertMulti(akey, avalue);
}
}
@@ -1102,7 +1102,7 @@ Q_OUTOFLINE_TEMPLATE QList<T> QMap<Key, T>::values(const Key &akey) const
template <class Key, class T>
Q_INLINE_TEMPLATE typename QMap<Key, T>::const_iterator QMap<Key, T>::lowerBound(const Key &akey) const
{
- Node *lb = d->root() ? d->root()->lowerBound(akey) : Q_NULLPTR;
+ Node *lb = d->root() ? d->root()->lowerBound(akey) : nullptr;
if (!lb)
lb = d->end();
return const_iterator(lb);
@@ -1112,7 +1112,7 @@ template <class Key, class T>
Q_INLINE_TEMPLATE typename QMap<Key, T>::iterator QMap<Key, T>::lowerBound(const Key &akey)
{
detach();
- Node *lb = d->root() ? d->root()->lowerBound(akey) : Q_NULLPTR;
+ Node *lb = d->root() ? d->root()->lowerBound(akey) : nullptr;
if (!lb)
lb = d->end();
return iterator(lb);
@@ -1122,7 +1122,7 @@ template <class Key, class T>
Q_INLINE_TEMPLATE typename QMap<Key, T>::const_iterator
QMap<Key, T>::upperBound(const Key &akey) const
{
- Node *ub = d->root() ? d->root()->upperBound(akey) : Q_NULLPTR;
+ Node *ub = d->root() ? d->root()->upperBound(akey) : nullptr;
if (!ub)
ub = d->end();
return const_iterator(ub);
@@ -1132,7 +1132,7 @@ template <class Key, class T>
Q_INLINE_TEMPLATE typename QMap<Key, T>::iterator QMap<Key, T>::upperBound(const Key &akey)
{
detach();
- Node *ub = d->root() ? d->root()->upperBound(akey) : Q_NULLPTR;
+ Node *ub = d->root() ? d->root()->upperBound(akey) : nullptr;
if (!ub)
ub = d->end();
return iterator(ub);
diff --git a/src/corelib/tools/qringbuffer_p.h b/src/corelib/tools/qringbuffer_p.h
index 558a456515..1f3f2d3fb0 100644
--- a/src/corelib/tools/qringbuffer_p.h
+++ b/src/corelib/tools/qringbuffer_p.h
@@ -80,7 +80,7 @@ public:
}
inline const char *readPointer() const {
- return bufferSize == 0 ? Q_NULLPTR : (buffers.first().constData() + head);
+ return bufferSize == 0 ? nullptr : (buffers.first().constData() + head);
}
Q_CORE_EXPORT const char *readPointerAtPosition(qint64 pos, qint64 &length) const;
diff --git a/src/corelib/tools/qscopedpointer.cpp b/src/corelib/tools/qscopedpointer.cpp
index 8d84b3beca..f3a4f0ca1f 100644
--- a/src/corelib/tools/qscopedpointer.cpp
+++ b/src/corelib/tools/qscopedpointer.cpp
@@ -146,6 +146,13 @@ QT_BEGIN_NAMESPACE
*/
/*!
+ \fn T *QScopedPointer::get() const
+ \since 5.11
+
+ Same as data().
+*/
+
+/*!
\fn T &QScopedPointer::operator*() const
Provides access to the scoped pointer's object.
diff --git a/src/corelib/tools/qscopedpointer.h b/src/corelib/tools/qscopedpointer.h
index 141a3f8c70..2a4083466b 100644
--- a/src/corelib/tools/qscopedpointer.h
+++ b/src/corelib/tools/qscopedpointer.h
@@ -97,7 +97,7 @@ class QScopedPointer
{
typedef T *QScopedPointer:: *RestrictedBool;
public:
- explicit QScopedPointer(T *p = Q_NULLPTR) Q_DECL_NOTHROW : d(p)
+ explicit QScopedPointer(T *p = nullptr) Q_DECL_NOTHROW : d(p)
{
}
@@ -126,12 +126,12 @@ public:
#if defined(Q_QDOC)
inline operator bool() const
{
- return isNull() ? Q_NULLPTR : &QScopedPointer::d;
+ return isNull() ? nullptr : &QScopedPointer::d;
}
#else
operator RestrictedBool() const Q_DECL_NOTHROW
{
- return isNull() ? Q_NULLPTR : &QScopedPointer::d;
+ return isNull() ? nullptr : &QScopedPointer::d;
}
#endif
@@ -140,12 +140,17 @@ public:
return d;
}
+ T *get() const Q_DECL_NOTHROW
+ {
+ return d;
+ }
+
bool isNull() const Q_DECL_NOTHROW
{
return !d;
}
- void reset(T *other = Q_NULLPTR) Q_DECL_NOEXCEPT_EXPR(noexcept(Cleanup::cleanup(std::declval<T *>())))
+ void reset(T *other = nullptr) Q_DECL_NOEXCEPT_EXPR(noexcept(Cleanup::cleanup(std::declval<T *>())))
{
if (d == other)
return;
@@ -157,7 +162,7 @@ public:
T *take() Q_DECL_NOTHROW
{
T *oldD = d;
- d = Q_NULLPTR;
+ d = nullptr;
return oldD;
}
@@ -221,7 +226,7 @@ class QScopedArrayPointer : public QScopedPointer<T, Cleanup>
template <typename Ptr>
using if_same_type = typename std::enable_if<std::is_same<typename std::remove_cv<T>::type, Ptr>::value, bool>::type;
public:
- inline QScopedArrayPointer() : QScopedPointer<T, Cleanup>(Q_NULLPTR) {}
+ inline QScopedArrayPointer() : QScopedPointer<T, Cleanup>(nullptr) {}
template <typename D, if_same_type<D> = true>
explicit QScopedArrayPointer(D *p)
diff --git a/src/corelib/tools/qshareddata.h b/src/corelib/tools/qshareddata.h
index 13b0032605..dbf0907a0f 100644
--- a/src/corelib/tools/qshareddata.h
+++ b/src/corelib/tools/qshareddata.h
@@ -85,7 +85,7 @@ public:
inline bool operator==(const QSharedDataPointer<T> &other) const { return d == other.d; }
inline bool operator!=(const QSharedDataPointer<T> &other) const { return d != other.d; }
- inline QSharedDataPointer() { d = Q_NULLPTR; }
+ inline QSharedDataPointer() { d = nullptr; }
inline ~QSharedDataPointer() { if (d && !d->ref.deref()) delete d; }
explicit QSharedDataPointer(T *data) Q_DECL_NOTHROW;
@@ -113,7 +113,7 @@ public:
return *this;
}
#ifdef Q_COMPILER_RVALUE_REFS
- QSharedDataPointer(QSharedDataPointer &&o) Q_DECL_NOTHROW : d(o.d) { o.d = Q_NULLPTR; }
+ QSharedDataPointer(QSharedDataPointer &&o) Q_DECL_NOTHROW : d(o.d) { o.d = nullptr; }
inline QSharedDataPointer<T> &operator=(QSharedDataPointer<T> &&other) Q_DECL_NOTHROW
{ qSwap(d, other.d); return *this; }
#endif
@@ -151,17 +151,17 @@ public:
if(d && !d->ref.deref())
delete d;
- d = Q_NULLPTR;
+ d = nullptr;
}
- inline operator bool () const { return d != Q_NULLPTR; }
+ inline operator bool () const { return d != nullptr; }
inline bool operator==(const QExplicitlySharedDataPointer<T> &other) const { return d == other.d; }
inline bool operator!=(const QExplicitlySharedDataPointer<T> &other) const { return d != other.d; }
inline bool operator==(const T *ptr) const { return d == ptr; }
inline bool operator!=(const T *ptr) const { return d != ptr; }
- inline QExplicitlySharedDataPointer() { d = Q_NULLPTR; }
+ inline QExplicitlySharedDataPointer() { d = nullptr; }
inline ~QExplicitlySharedDataPointer() { if (d && !d->ref.deref()) delete d; }
explicit QExplicitlySharedDataPointer(T *data) Q_DECL_NOTHROW;
@@ -202,7 +202,7 @@ public:
return *this;
}
#ifdef Q_COMPILER_RVALUE_REFS
- inline QExplicitlySharedDataPointer(QExplicitlySharedDataPointer &&o) Q_DECL_NOTHROW : d(o.d) { o.d = Q_NULLPTR; }
+ inline QExplicitlySharedDataPointer(QExplicitlySharedDataPointer &&o) Q_DECL_NOTHROW : d(o.d) { o.d = nullptr; }
inline QExplicitlySharedDataPointer<T> &operator=(QExplicitlySharedDataPointer<T> &&other) Q_DECL_NOTHROW
{ qSwap(d, other.d); return *this; }
#endif
diff --git a/src/corelib/tools/qsharedpointer.cpp b/src/corelib/tools/qsharedpointer.cpp
index af09ef6f40..7f1e9ed798 100644
--- a/src/corelib/tools/qsharedpointer.cpp
+++ b/src/corelib/tools/qsharedpointer.cpp
@@ -577,6 +577,15 @@
*/
/*!
+ \fn T *QSharedPointer::get() const
+ \since 5.11
+
+ Same as data().
+
+ This function is provided for API compatibility with \c{std::shared_ptr}.
+*/
+
+/*!
\fn T &QSharedPointer::operator *() const
Provides access to the shared pointer's members.
diff --git a/src/corelib/tools/qsharedpointer.h b/src/corelib/tools/qsharedpointer.h
index 3b86eb238b..98b38b97d3 100644
--- a/src/corelib/tools/qsharedpointer.h
+++ b/src/corelib/tools/qsharedpointer.h
@@ -59,6 +59,7 @@ class QSharedPointer
public:
// basic accessor functions
T *data() const;
+ T *get() const;
bool isNull() const;
operator bool() const;
bool operator!() const;
diff --git a/src/corelib/tools/qsharedpointer_impl.h b/src/corelib/tools/qsharedpointer_impl.h
index ede54c155d..a0e408b94a 100644
--- a/src/corelib/tools/qsharedpointer_impl.h
+++ b/src/corelib/tools/qsharedpointer_impl.h
@@ -303,8 +303,9 @@ public:
typedef qptrdiff difference_type;
T *data() const Q_DECL_NOTHROW { return value; }
+ T *get() const Q_DECL_NOTHROW { return value; }
bool isNull() const Q_DECL_NOTHROW { return !data(); }
- operator RestrictedBool() const Q_DECL_NOTHROW { return isNull() ? Q_NULLPTR : &QSharedPointer::value; }
+ operator RestrictedBool() const Q_DECL_NOTHROW { return isNull() ? nullptr : &QSharedPointer::value; }
bool operator !() const Q_DECL_NOTHROW { return isNull(); }
T &operator*() const { return *data(); }
T *operator->() const Q_DECL_NOTHROW { return data(); }
@@ -337,8 +338,8 @@ public:
QSharedPointer(QSharedPointer &&other) Q_DECL_NOTHROW
: value(other.value), d(other.d)
{
- other.d = Q_NULLPTR;
- other.value = Q_NULLPTR;
+ other.d = nullptr;
+ other.value = nullptr;
}
QSharedPointer &operator=(QSharedPointer &&other) Q_DECL_NOTHROW
{
@@ -351,8 +352,8 @@ public:
QSharedPointer(QSharedPointer<X> &&other) Q_DECL_NOTHROW
: value(other.value), d(other.d)
{
- other.d = Q_NULLPTR;
- other.value = Q_NULLPTR;
+ other.d = nullptr;
+ other.value = nullptr;
}
template <class X>
@@ -378,7 +379,7 @@ public:
}
template <class X>
- inline QSharedPointer(const QWeakPointer<X> &other) : value(Q_NULLPTR), d(Q_NULLPTR)
+ inline QSharedPointer(const QWeakPointer<X> &other) : value(nullptr), d(nullptr)
{ *this = other; }
template <class X>
@@ -476,7 +477,7 @@ private:
inline void internalConstruct(X *ptr, Deleter deleter)
{
if (!ptr) {
- d = Q_NULLPTR;
+ d = nullptr;
return;
}
@@ -527,14 +528,14 @@ public:
o->weakref.ref();
} else {
o->checkQObjectShared(actual);
- o = Q_NULLPTR;
+ o = nullptr;
}
}
qSwap(d, o);
qSwap(this->value, actual);
if (!d || d->strongref.load() == 0)
- this->value = Q_NULLPTR;
+ this->value = nullptr;
// dereference saved data
deref(o);
@@ -559,19 +560,19 @@ public:
typedef const value_type &const_reference;
typedef qptrdiff difference_type;
- bool isNull() const Q_DECL_NOTHROW { return d == Q_NULLPTR || d->strongref.load() == 0 || value == Q_NULLPTR; }
- operator RestrictedBool() const Q_DECL_NOTHROW { return isNull() ? Q_NULLPTR : &QWeakPointer::value; }
+ bool isNull() const Q_DECL_NOTHROW { return d == nullptr || d->strongref.load() == 0 || value == nullptr; }
+ operator RestrictedBool() const Q_DECL_NOTHROW { return isNull() ? nullptr : &QWeakPointer::value; }
bool operator !() const Q_DECL_NOTHROW { return isNull(); }
- T *data() const Q_DECL_NOTHROW { return d == Q_NULLPTR || d->strongref.load() == 0 ? Q_NULLPTR : value; }
+ T *data() const Q_DECL_NOTHROW { return d == nullptr || d->strongref.load() == 0 ? nullptr : value; }
- inline QWeakPointer() Q_DECL_NOTHROW : d(Q_NULLPTR), value(Q_NULLPTR) { }
+ inline QWeakPointer() Q_DECL_NOTHROW : d(nullptr), value(nullptr) { }
inline ~QWeakPointer() { if (d && !d->weakref.deref()) delete d; }
#ifndef QT_NO_QOBJECT
// special constructor that is enabled only if X derives from QObject
#if QT_DEPRECATED_SINCE(5, 0)
template <class X>
- QT_DEPRECATED inline QWeakPointer(X *ptr) : d(ptr ? Data::getAndRef(ptr) : Q_NULLPTR), value(ptr)
+ QT_DEPRECATED inline QWeakPointer(X *ptr) : d(ptr ? Data::getAndRef(ptr) : nullptr), value(ptr)
{ }
#endif
#endif
@@ -588,8 +589,8 @@ public:
QWeakPointer(QWeakPointer &&other) Q_DECL_NOTHROW
: d(other.d), value(other.value)
{
- other.d = Q_NULLPTR;
- other.value = Q_NULLPTR;
+ other.d = nullptr;
+ other.value = nullptr;
}
QWeakPointer &operator=(QWeakPointer &&other) Q_DECL_NOTHROW
{ QWeakPointer moved(std::move(other)); swap(moved); return *this; }
@@ -616,7 +617,7 @@ public:
}
template <class X>
- inline QWeakPointer(const QWeakPointer<X> &o) : d(Q_NULLPTR), value(Q_NULLPTR)
+ inline QWeakPointer(const QWeakPointer<X> &o) : d(nullptr), value(nullptr)
{ *this = o; }
template <class X>
@@ -637,7 +638,7 @@ public:
{ return !(*this == o); }
template <class X>
- inline QWeakPointer(const QSharedPointer<X> &o) : d(Q_NULLPTR), value(Q_NULLPTR)
+ inline QWeakPointer(const QSharedPointer<X> &o) : d(nullptr), value(nullptr)
{ *this = o; }
template <class X>
@@ -681,7 +682,7 @@ public:
#ifndef QT_NO_QOBJECT
template <class X>
- inline QWeakPointer(X *ptr, bool) : d(ptr ? Data::getAndRef(ptr) : Q_NULLPTR), value(ptr)
+ inline QWeakPointer(X *ptr, bool) : d(ptr ? Data::getAndRef(ptr) : nullptr), value(ptr)
{ }
#endif
diff --git a/src/corelib/tools/qsimd_p.h b/src/corelib/tools/qsimd_p.h
index 181da4f7de..a462d7bb58 100644
--- a/src/corelib/tools/qsimd_p.h
+++ b/src/corelib/tools/qsimd_p.h
@@ -53,7 +53,6 @@
//
#include <QtCore/private/qglobal_p.h>
-#include <qatomic.h>
/*
* qt_module_config.prf defines the QT_COMPILER_SUPPORTS_XXX macros.
@@ -333,8 +332,10 @@
# include <arm_acle.h>
#endif
-QT_BEGIN_NAMESPACE
+#ifdef __cplusplus
+#include <qatomic.h>
+QT_BEGIN_NAMESPACE
enum CPUFeatures {
#if defined(Q_PROCESSOR_ARM)
@@ -512,9 +513,11 @@ static inline quint64 qCpuFeatures()
#define ALIGNMENT_PROLOGUE_32BYTES(ptr, i, length) \
for (; i < static_cast<int>(qMin(static_cast<quintptr>(length), ((8 - ((reinterpret_cast<quintptr>(ptr) >> 2) & 0x7)) & 0x7))); ++i)
+QT_END_NAMESPACE
+
+#endif // __cplusplus
+
#define SIMD_EPILOGUE(i, length, max) \
for (int _i = 0; _i < max && i < length; ++i, ++_i)
-QT_END_NAMESPACE
-
#endif // QSIMD_P_H
diff --git a/src/corelib/tools/qstring.cpp b/src/corelib/tools/qstring.cpp
index c10987a5fe..78b7e69d9c 100644
--- a/src/corelib/tools/qstring.cpp
+++ b/src/corelib/tools/qstring.cpp
@@ -4058,7 +4058,7 @@ int QString::count(const QRegExp& rx) const
*/
int QString::indexOf(const QRegularExpression& re, int from) const
{
- return indexOf(re, from, Q_NULLPTR);
+ return indexOf(re, from, nullptr);
}
/*!
@@ -4109,7 +4109,7 @@ int QString::indexOf(const QRegularExpression &re, int from, QRegularExpressionM
*/
int QString::lastIndexOf(const QRegularExpression &re, int from) const
{
- return lastIndexOf(re, from, Q_NULLPTR);
+ return lastIndexOf(re, from, nullptr);
}
/*!
@@ -4161,7 +4161,7 @@ int QString::lastIndexOf(const QRegularExpression &re, int from, QRegularExpress
*/
bool QString::contains(const QRegularExpression &re) const
{
- return contains(re, Q_NULLPTR);
+ return contains(re, nullptr);
}
/*!
diff --git a/src/corelib/tools/qstring.h b/src/corelib/tools/qstring.h
index fe7e9b050b..b411bdac5a 100644
--- a/src/corelib/tools/qstring.h
+++ b/src/corelib/tools/qstring.h
@@ -91,7 +91,7 @@ template <typename T> class QVector;
class QLatin1String
{
public:
- Q_DECL_CONSTEXPR inline QLatin1String() Q_DECL_NOTHROW : m_size(0), m_data(Q_NULLPTR) {}
+ Q_DECL_CONSTEXPR inline QLatin1String() Q_DECL_NOTHROW : m_size(0), m_data(nullptr) {}
Q_DECL_CONSTEXPR inline explicit QLatin1String(const char *s) Q_DECL_NOTHROW : m_size(s ? int(strlen(s)) : 0), m_data(s) {}
Q_DECL_CONSTEXPR explicit QLatin1String(const char *f, const char *l)
: QLatin1String(f, int(l - f)) {}
@@ -624,16 +624,16 @@ public:
static int localeAwareCompare(const QString& s1, const QStringRef& s2);
// ### Qt6: make inline except for the long long versions
- short toShort(bool *ok=Q_NULLPTR, int base=10) const;
- ushort toUShort(bool *ok=Q_NULLPTR, int base=10) const;
- int toInt(bool *ok=Q_NULLPTR, int base=10) const;
- uint toUInt(bool *ok=Q_NULLPTR, int base=10) const;
- long toLong(bool *ok=Q_NULLPTR, int base=10) const;
- ulong toULong(bool *ok=Q_NULLPTR, int base=10) const;
- qlonglong toLongLong(bool *ok=Q_NULLPTR, int base=10) const;
- qulonglong toULongLong(bool *ok=Q_NULLPTR, int base=10) const;
- float toFloat(bool *ok=Q_NULLPTR) const;
- double toDouble(bool *ok=Q_NULLPTR) const;
+ short toShort(bool *ok=nullptr, int base=10) const;
+ ushort toUShort(bool *ok=nullptr, int base=10) const;
+ int toInt(bool *ok=nullptr, int base=10) const;
+ uint toUInt(bool *ok=nullptr, int base=10) const;
+ long toLong(bool *ok=nullptr, int base=10) const;
+ ulong toULong(bool *ok=nullptr, int base=10) const;
+ qlonglong toLongLong(bool *ok=nullptr, int base=10) const;
+ qulonglong toULongLong(bool *ok=nullptr, int base=10) const;
+ float toFloat(bool *ok=nullptr) const;
+ double toDouble(bool *ok=nullptr) const;
QString &setNum(short, int base=10);
QString &setNum(ushort, int base=10);
@@ -1417,7 +1417,7 @@ public:
typedef QString::const_reference const_reference;
// ### Qt 6: make this constructor constexpr, after the destructor is made trivial
- inline QStringRef() : m_string(Q_NULLPTR), m_position(0), m_size(0) {}
+ inline QStringRef() : m_string(nullptr), m_position(0), m_size(0) {}
inline QStringRef(const QString *string, int position, int size);
inline QStringRef(const QString *string);
@@ -1533,10 +1533,10 @@ public:
Q_REQUIRED_RESULT QByteArray toLocal8Bit() const;
Q_REQUIRED_RESULT QVector<uint> toUcs4() const;
- inline void clear() { m_string = Q_NULLPTR; m_position = m_size = 0; }
+ inline void clear() { m_string = nullptr; m_position = m_size = 0; }
QString toString() const;
inline bool isEmpty() const { return m_size == 0; }
- inline bool isNull() const { return m_string == Q_NULLPTR || m_string->isNull(); }
+ inline bool isNull() const { return m_string == nullptr || m_string->isNull(); }
QStringRef appendTo(QString *string) const;
@@ -1576,16 +1576,16 @@ public:
static int localeAwareCompare(const QStringRef &s1, const QStringRef &s2);
Q_REQUIRED_RESULT QStringRef trimmed() const;
- short toShort(bool *ok = Q_NULLPTR, int base = 10) const;
- ushort toUShort(bool *ok = Q_NULLPTR, int base = 10) const;
- int toInt(bool *ok = Q_NULLPTR, int base = 10) const;
- uint toUInt(bool *ok = Q_NULLPTR, int base = 10) const;
- long toLong(bool *ok = Q_NULLPTR, int base = 10) const;
- ulong toULong(bool *ok = Q_NULLPTR, int base = 10) const;
- qlonglong toLongLong(bool *ok = Q_NULLPTR, int base = 10) const;
- qulonglong toULongLong(bool *ok = Q_NULLPTR, int base = 10) const;
- float toFloat(bool *ok = Q_NULLPTR) const;
- double toDouble(bool *ok = Q_NULLPTR) const;
+ short toShort(bool *ok = nullptr, int base = 10) const;
+ ushort toUShort(bool *ok = nullptr, int base = 10) const;
+ int toInt(bool *ok = nullptr, int base = 10) const;
+ uint toUInt(bool *ok = nullptr, int base = 10) const;
+ long toLong(bool *ok = nullptr, int base = 10) const;
+ ulong toULong(bool *ok = nullptr, int base = 10) const;
+ qlonglong toLongLong(bool *ok = nullptr, int base = 10) const;
+ qulonglong toULongLong(bool *ok = nullptr, int base = 10) const;
+ float toFloat(bool *ok = nullptr) const;
+ double toDouble(bool *ok = nullptr) const;
};
Q_DECLARE_TYPEINFO(QStringRef, Q_PRIMITIVE_TYPE);
diff --git a/src/corelib/tools/qtextboundaryfinder.h b/src/corelib/tools/qtextboundaryfinder.h
index d021df3f2c..b1e5008f54 100644
--- a/src/corelib/tools/qtextboundaryfinder.h
+++ b/src/corelib/tools/qtextboundaryfinder.h
@@ -74,7 +74,7 @@ public:
Q_DECLARE_FLAGS( BoundaryReasons, BoundaryReason )
QTextBoundaryFinder(BoundaryType type, const QString &string);
- QTextBoundaryFinder(BoundaryType type, const QChar *chars, int length, unsigned char *buffer = Q_NULLPTR, int bufferSize = 0);
+ QTextBoundaryFinder(BoundaryType type, const QChar *chars, int length, unsigned char *buffer = nullptr, int bufferSize = 0);
inline bool isValid() const { return d; }
diff --git a/src/corelib/tools/qtimeline.h b/src/corelib/tools/qtimeline.h
index f0e9a32e4d..d9982bdb58 100644
--- a/src/corelib/tools/qtimeline.h
+++ b/src/corelib/tools/qtimeline.h
@@ -76,7 +76,7 @@ public:
CosineCurve
};
- explicit QTimeLine(int duration = 1000, QObject *parent = Q_NULLPTR);
+ explicit QTimeLine(int duration = 1000, QObject *parent = nullptr);
virtual ~QTimeLine();
State state() const;
@@ -127,7 +127,7 @@ Q_SIGNALS:
void finished(QPrivateSignal);
protected:
- void timerEvent(QTimerEvent *event) Q_DECL_OVERRIDE;
+ void timerEvent(QTimerEvent *event) override;
private:
Q_DISABLE_COPY(QTimeLine)
diff --git a/src/corelib/tools/qtimezoneprivate_p.h b/src/corelib/tools/qtimezoneprivate_p.h
index 74b79dce16..9b7adbbbbe 100644
--- a/src/corelib/tools/qtimezoneprivate_p.h
+++ b/src/corelib/tools/qtimezoneprivate_p.h
@@ -171,7 +171,7 @@ Q_DECLARE_TYPEINFO(QTimeZonePrivate::Data, Q_MOVABLE_TYPE);
template<> QTimeZonePrivate *QSharedDataPointer<QTimeZonePrivate>::clone();
-class Q_AUTOTEST_EXPORT QUtcTimeZonePrivate Q_DECL_FINAL : public QTimeZonePrivate
+class Q_AUTOTEST_EXPORT QUtcTimeZonePrivate final : public QTimeZonePrivate
{
public:
// Create default UTC time zone
@@ -189,26 +189,26 @@ public:
QUtcTimeZonePrivate *clone() const override;
- Data data(qint64 forMSecsSinceEpoch) const Q_DECL_OVERRIDE;
+ Data data(qint64 forMSecsSinceEpoch) const override;
- QLocale::Country country() const Q_DECL_OVERRIDE;
- QString comment() const Q_DECL_OVERRIDE;
+ QLocale::Country country() const override;
+ QString comment() const override;
QString displayName(QTimeZone::TimeType timeType,
QTimeZone::NameType nameType,
- const QLocale &locale) const Q_DECL_OVERRIDE;
- QString abbreviation(qint64 atMSecsSinceEpoch) const Q_DECL_OVERRIDE;
+ const QLocale &locale) const override;
+ QString abbreviation(qint64 atMSecsSinceEpoch) const override;
- int standardTimeOffset(qint64 atMSecsSinceEpoch) const Q_DECL_OVERRIDE;
- int daylightTimeOffset(qint64 atMSecsSinceEpoch) const Q_DECL_OVERRIDE;
+ int standardTimeOffset(qint64 atMSecsSinceEpoch) const override;
+ int daylightTimeOffset(qint64 atMSecsSinceEpoch) const override;
- QByteArray systemTimeZoneId() const Q_DECL_OVERRIDE;
+ QByteArray systemTimeZoneId() const override;
- QList<QByteArray> availableTimeZoneIds() const Q_DECL_OVERRIDE;
- QList<QByteArray> availableTimeZoneIds(QLocale::Country country) const Q_DECL_OVERRIDE;
- QList<QByteArray> availableTimeZoneIds(int utcOffset) const Q_DECL_OVERRIDE;
+ QList<QByteArray> availableTimeZoneIds() const override;
+ QList<QByteArray> availableTimeZoneIds(QLocale::Country country) const override;
+ QList<QByteArray> availableTimeZoneIds(int utcOffset) const override;
- void serialize(QDataStream &ds) const Q_DECL_OVERRIDE;
+ void serialize(QDataStream &ds) const override;
private:
void init(const QByteArray &zoneId);
@@ -224,7 +224,7 @@ private:
};
#if QT_CONFIG(icu)
-class Q_AUTOTEST_EXPORT QIcuTimeZonePrivate Q_DECL_FINAL : public QTimeZonePrivate
+class Q_AUTOTEST_EXPORT QIcuTimeZonePrivate final : public QTimeZonePrivate
{
public:
// Create default time zone
@@ -237,27 +237,27 @@ public:
QIcuTimeZonePrivate *clone() const override;
QString displayName(QTimeZone::TimeType timeType, QTimeZone::NameType nameType,
- const QLocale &locale) const Q_DECL_OVERRIDE;
- QString abbreviation(qint64 atMSecsSinceEpoch) const Q_DECL_OVERRIDE;
+ const QLocale &locale) const override;
+ QString abbreviation(qint64 atMSecsSinceEpoch) const override;
- int offsetFromUtc(qint64 atMSecsSinceEpoch) const Q_DECL_OVERRIDE;
- int standardTimeOffset(qint64 atMSecsSinceEpoch) const Q_DECL_OVERRIDE;
- int daylightTimeOffset(qint64 atMSecsSinceEpoch) const Q_DECL_OVERRIDE;
+ int offsetFromUtc(qint64 atMSecsSinceEpoch) const override;
+ int standardTimeOffset(qint64 atMSecsSinceEpoch) const override;
+ int daylightTimeOffset(qint64 atMSecsSinceEpoch) const override;
- bool hasDaylightTime() const Q_DECL_OVERRIDE;
- bool isDaylightTime(qint64 atMSecsSinceEpoch) const Q_DECL_OVERRIDE;
+ bool hasDaylightTime() const override;
+ bool isDaylightTime(qint64 atMSecsSinceEpoch) const override;
- Data data(qint64 forMSecsSinceEpoch) const Q_DECL_OVERRIDE;
+ Data data(qint64 forMSecsSinceEpoch) const override;
- bool hasTransitions() const Q_DECL_OVERRIDE;
- Data nextTransition(qint64 afterMSecsSinceEpoch) const Q_DECL_OVERRIDE;
- Data previousTransition(qint64 beforeMSecsSinceEpoch) const Q_DECL_OVERRIDE;
+ bool hasTransitions() const override;
+ Data nextTransition(qint64 afterMSecsSinceEpoch) const override;
+ Data previousTransition(qint64 beforeMSecsSinceEpoch) const override;
- QByteArray systemTimeZoneId() const Q_DECL_OVERRIDE;
+ QByteArray systemTimeZoneId() const override;
- QList<QByteArray> availableTimeZoneIds() const Q_DECL_OVERRIDE;
- QList<QByteArray> availableTimeZoneIds(QLocale::Country country) const Q_DECL_OVERRIDE;
- QList<QByteArray> availableTimeZoneIds(int offsetFromUtc) const Q_DECL_OVERRIDE;
+ QList<QByteArray> availableTimeZoneIds() const override;
+ QList<QByteArray> availableTimeZoneIds(QLocale::Country country) const override;
+ QList<QByteArray> availableTimeZoneIds(int offsetFromUtc) const override;
private:
void init(const QByteArray &ianaId);
@@ -285,7 +285,7 @@ Q_DECL_CONSTEXPR inline bool operator==(const QTzTransitionRule &lhs, const QTzT
Q_DECL_CONSTEXPR inline bool operator!=(const QTzTransitionRule &lhs, const QTzTransitionRule &rhs) Q_DECL_NOTHROW
{ return !operator==(lhs, rhs); }
-class Q_AUTOTEST_EXPORT QTzTimeZonePrivate Q_DECL_FINAL : public QTimeZonePrivate
+class Q_AUTOTEST_EXPORT QTzTimeZonePrivate final : public QTimeZonePrivate
{
QTzTimeZonePrivate(const QTzTimeZonePrivate &) = default;
public:
@@ -297,34 +297,34 @@ public:
QTzTimeZonePrivate *clone() const override;
- QLocale::Country country() const Q_DECL_OVERRIDE;
- QString comment() const Q_DECL_OVERRIDE;
+ QLocale::Country country() const override;
+ QString comment() const override;
QString displayName(qint64 atMSecsSinceEpoch,
QTimeZone::NameType nameType,
- const QLocale &locale) const Q_DECL_OVERRIDE;
+ const QLocale &locale) const override;
QString displayName(QTimeZone::TimeType timeType,
QTimeZone::NameType nameType,
- const QLocale &locale) const Q_DECL_OVERRIDE;
- QString abbreviation(qint64 atMSecsSinceEpoch) const Q_DECL_OVERRIDE;
+ const QLocale &locale) const override;
+ QString abbreviation(qint64 atMSecsSinceEpoch) const override;
- int offsetFromUtc(qint64 atMSecsSinceEpoch) const Q_DECL_OVERRIDE;
- int standardTimeOffset(qint64 atMSecsSinceEpoch) const Q_DECL_OVERRIDE;
- int daylightTimeOffset(qint64 atMSecsSinceEpoch) const Q_DECL_OVERRIDE;
+ int offsetFromUtc(qint64 atMSecsSinceEpoch) const override;
+ int standardTimeOffset(qint64 atMSecsSinceEpoch) const override;
+ int daylightTimeOffset(qint64 atMSecsSinceEpoch) const override;
- bool hasDaylightTime() const Q_DECL_OVERRIDE;
- bool isDaylightTime(qint64 atMSecsSinceEpoch) const Q_DECL_OVERRIDE;
+ bool hasDaylightTime() const override;
+ bool isDaylightTime(qint64 atMSecsSinceEpoch) const override;
- Data data(qint64 forMSecsSinceEpoch) const Q_DECL_OVERRIDE;
+ Data data(qint64 forMSecsSinceEpoch) const override;
- bool hasTransitions() const Q_DECL_OVERRIDE;
- Data nextTransition(qint64 afterMSecsSinceEpoch) const Q_DECL_OVERRIDE;
- Data previousTransition(qint64 beforeMSecsSinceEpoch) const Q_DECL_OVERRIDE;
+ bool hasTransitions() const override;
+ Data nextTransition(qint64 afterMSecsSinceEpoch) const override;
+ Data previousTransition(qint64 beforeMSecsSinceEpoch) const override;
- QByteArray systemTimeZoneId() const Q_DECL_OVERRIDE;
+ QByteArray systemTimeZoneId() const override;
- QList<QByteArray> availableTimeZoneIds() const Q_DECL_OVERRIDE;
- QList<QByteArray> availableTimeZoneIds(QLocale::Country country) const Q_DECL_OVERRIDE;
+ QList<QByteArray> availableTimeZoneIds() const override;
+ QList<QByteArray> availableTimeZoneIds(QLocale::Country country) const override;
private:
void init(const QByteArray &ianaId);
@@ -341,7 +341,7 @@ private:
#endif // Q_OS_UNIX
#ifdef Q_OS_MAC
-class Q_AUTOTEST_EXPORT QMacTimeZonePrivate Q_DECL_FINAL : public QTimeZonePrivate
+class Q_AUTOTEST_EXPORT QMacTimeZonePrivate final : public QTimeZonePrivate
{
public:
// Create default time zone
@@ -353,28 +353,28 @@ public:
QMacTimeZonePrivate *clone() const override;
- QString comment() const Q_DECL_OVERRIDE;
+ QString comment() const override;
QString displayName(QTimeZone::TimeType timeType, QTimeZone::NameType nameType,
- const QLocale &locale) const Q_DECL_OVERRIDE;
- QString abbreviation(qint64 atMSecsSinceEpoch) const Q_DECL_OVERRIDE;
+ const QLocale &locale) const override;
+ QString abbreviation(qint64 atMSecsSinceEpoch) const override;
- int offsetFromUtc(qint64 atMSecsSinceEpoch) const Q_DECL_OVERRIDE;
- int standardTimeOffset(qint64 atMSecsSinceEpoch) const Q_DECL_OVERRIDE;
- int daylightTimeOffset(qint64 atMSecsSinceEpoch) const Q_DECL_OVERRIDE;
+ int offsetFromUtc(qint64 atMSecsSinceEpoch) const override;
+ int standardTimeOffset(qint64 atMSecsSinceEpoch) const override;
+ int daylightTimeOffset(qint64 atMSecsSinceEpoch) const override;
- bool hasDaylightTime() const Q_DECL_OVERRIDE;
- bool isDaylightTime(qint64 atMSecsSinceEpoch) const Q_DECL_OVERRIDE;
+ bool hasDaylightTime() const override;
+ bool isDaylightTime(qint64 atMSecsSinceEpoch) const override;
- Data data(qint64 forMSecsSinceEpoch) const Q_DECL_OVERRIDE;
+ Data data(qint64 forMSecsSinceEpoch) const override;
- bool hasTransitions() const Q_DECL_OVERRIDE;
- Data nextTransition(qint64 afterMSecsSinceEpoch) const Q_DECL_OVERRIDE;
- Data previousTransition(qint64 beforeMSecsSinceEpoch) const Q_DECL_OVERRIDE;
+ bool hasTransitions() const override;
+ Data nextTransition(qint64 afterMSecsSinceEpoch) const override;
+ Data previousTransition(qint64 beforeMSecsSinceEpoch) const override;
- QByteArray systemTimeZoneId() const Q_DECL_OVERRIDE;
+ QByteArray systemTimeZoneId() const override;
- QList<QByteArray> availableTimeZoneIds() const Q_DECL_OVERRIDE;
+ QList<QByteArray> availableTimeZoneIds() const override;
NSTimeZone *nsTimeZone() const;
@@ -386,7 +386,7 @@ private:
#endif // Q_OS_MAC
#ifdef Q_OS_WIN
-class Q_AUTOTEST_EXPORT QWinTimeZonePrivate Q_DECL_FINAL : public QTimeZonePrivate
+class Q_AUTOTEST_EXPORT QWinTimeZonePrivate final : public QTimeZonePrivate
{
public:
struct QWinTransitionRule {
@@ -406,32 +406,31 @@ public:
QWinTimeZonePrivate *clone() const override;
- QString comment() const Q_DECL_OVERRIDE;
+ QString comment() const override;
QString displayName(QTimeZone::TimeType timeType, QTimeZone::NameType nameType,
- const QLocale &locale) const Q_DECL_OVERRIDE;
- QString abbreviation(qint64 atMSecsSinceEpoch) const Q_DECL_OVERRIDE;
+ const QLocale &locale) const override;
+ QString abbreviation(qint64 atMSecsSinceEpoch) const override;
- int offsetFromUtc(qint64 atMSecsSinceEpoch) const Q_DECL_OVERRIDE;
- int standardTimeOffset(qint64 atMSecsSinceEpoch) const Q_DECL_OVERRIDE;
- int daylightTimeOffset(qint64 atMSecsSinceEpoch) const Q_DECL_OVERRIDE;
+ int offsetFromUtc(qint64 atMSecsSinceEpoch) const override;
+ int standardTimeOffset(qint64 atMSecsSinceEpoch) const override;
+ int daylightTimeOffset(qint64 atMSecsSinceEpoch) const override;
- bool hasDaylightTime() const Q_DECL_OVERRIDE;
- bool isDaylightTime(qint64 atMSecsSinceEpoch) const Q_DECL_OVERRIDE;
+ bool hasDaylightTime() const override;
+ bool isDaylightTime(qint64 atMSecsSinceEpoch) const override;
- Data data(qint64 forMSecsSinceEpoch) const Q_DECL_OVERRIDE;
+ Data data(qint64 forMSecsSinceEpoch) const override;
- bool hasTransitions() const Q_DECL_OVERRIDE;
- Data nextTransition(qint64 afterMSecsSinceEpoch) const Q_DECL_OVERRIDE;
- Data previousTransition(qint64 beforeMSecsSinceEpoch) const Q_DECL_OVERRIDE;
+ bool hasTransitions() const override;
+ Data nextTransition(qint64 afterMSecsSinceEpoch) const override;
+ Data previousTransition(qint64 beforeMSecsSinceEpoch) const override;
- QByteArray systemTimeZoneId() const Q_DECL_OVERRIDE;
+ QByteArray systemTimeZoneId() const override;
- QList<QByteArray> availableTimeZoneIds() const Q_DECL_OVERRIDE;
+ QList<QByteArray> availableTimeZoneIds() const override;
private:
void init(const QByteArray &ianaId);
- QWinTransitionRule ruleForYear(int year) const;
QTimeZonePrivate::Data ruleToData(const QWinTransitionRule &rule, qint64 atMSecsSinceEpoch,
QTimeZone::TimeType type) const;
@@ -444,7 +443,7 @@ private:
#endif // Q_OS_WIN
#ifdef Q_OS_ANDROID
-class QAndroidTimeZonePrivate Q_DECL_FINAL : public QTimeZonePrivate
+class QAndroidTimeZonePrivate final : public QTimeZonePrivate
{
public:
// Create default time zone
@@ -457,25 +456,25 @@ public:
QAndroidTimeZonePrivate *clone() const override;
QString displayName(QTimeZone::TimeType timeType, QTimeZone::NameType nameType,
- const QLocale &locale) const Q_DECL_OVERRIDE;
- QString abbreviation(qint64 atMSecsSinceEpoch) const Q_DECL_OVERRIDE;
+ const QLocale &locale) const override;
+ QString abbreviation(qint64 atMSecsSinceEpoch) const override;
- int offsetFromUtc(qint64 atMSecsSinceEpoch) const Q_DECL_OVERRIDE;
- int standardTimeOffset(qint64 atMSecsSinceEpoch) const Q_DECL_OVERRIDE;
- int daylightTimeOffset(qint64 atMSecsSinceEpoch) const Q_DECL_OVERRIDE;
+ int offsetFromUtc(qint64 atMSecsSinceEpoch) const override;
+ int standardTimeOffset(qint64 atMSecsSinceEpoch) const override;
+ int daylightTimeOffset(qint64 atMSecsSinceEpoch) const override;
- bool hasDaylightTime() const Q_DECL_OVERRIDE;
- bool isDaylightTime(qint64 atMSecsSinceEpoch) const Q_DECL_OVERRIDE;
+ bool hasDaylightTime() const override;
+ bool isDaylightTime(qint64 atMSecsSinceEpoch) const override;
- Data data(qint64 forMSecsSinceEpoch) const Q_DECL_OVERRIDE;
+ Data data(qint64 forMSecsSinceEpoch) const override;
- bool hasTransitions() const Q_DECL_OVERRIDE;
- Data nextTransition(qint64 afterMSecsSinceEpoch) const Q_DECL_OVERRIDE;
- Data previousTransition(qint64 beforeMSecsSinceEpoch) const Q_DECL_OVERRIDE;
+ bool hasTransitions() const override;
+ Data nextTransition(qint64 afterMSecsSinceEpoch) const override;
+ Data previousTransition(qint64 beforeMSecsSinceEpoch) const override;
- QByteArray systemTimeZoneId() const Q_DECL_OVERRIDE;
+ QByteArray systemTimeZoneId() const override;
- QList<QByteArray> availableTimeZoneIds() const Q_DECL_OVERRIDE;
+ QList<QByteArray> availableTimeZoneIds() const override;
private:
void init(const QByteArray &zoneId);
diff --git a/src/corelib/tools/qtimezoneprivate_win.cpp b/src/corelib/tools/qtimezoneprivate_win.cpp
index a50227d3cc..3bce55925f 100644
--- a/src/corelib/tools/qtimezoneprivate_win.cpp
+++ b/src/corelib/tools/qtimezoneprivate_win.cpp
@@ -259,8 +259,38 @@ static DYNAMIC_TIME_ZONE_INFORMATION dynamicInfoForId(const QByteArray &windowsI
}
return dtzInfo;
}
+
+static QWinTimeZonePrivate::QWinTransitionRule
+readDynamicRule(DYNAMIC_TIME_ZONE_INFORMATION &dtzi, int year, bool *ok)
+{
+ TIME_ZONE_INFORMATION tzi;
+ QWinTimeZonePrivate::QWinTransitionRule rule;
+ *ok = GetTimeZoneInformationForYear(year, &dtzi, &tzi);
+ if (*ok) {
+ rule.startYear = 0;
+ rule.standardTimeBias = tzi.Bias + tzi.StandardBias;
+ rule.daylightTimeBias = tzi.Bias + tzi.DaylightBias - rule.standardTimeBias;
+ rule.standardTimeRule = tzi.StandardDate;
+ rule.daylightTimeRule = tzi.DaylightDate;
+ }
+ return rule;
+}
#endif // QT_USE_REGISTRY_TIMEZONE
+static bool isSameRule(const QWinTimeZonePrivate::QWinTransitionRule &last,
+ const QWinTimeZonePrivate::QWinTransitionRule &rule)
+{
+ // In particular, when this is true and either wYear is 0, so is the other;
+ // so if one rule is recurrent and they're equal, so is the other. If
+ // either rule *isn't* recurrent, it has non-0 wYear which shall be
+ // different from the other's. Note that we don't compare .startYear, since
+ // that will always be different.
+ return equalSystemtime(last.standardTimeRule, rule.standardTimeRule)
+ && equalSystemtime(last.daylightTimeRule, rule.daylightTimeRule)
+ && last.standardTimeBias == rule.standardTimeBias
+ && last.daylightTimeBias == rule.daylightTimeBias;
+}
+
static QList<QByteArray> availableWindowsIds()
{
#ifdef QT_USE_REGISTRY_TIMEZONE
@@ -356,30 +386,33 @@ static inline qint64 timeToMSecs(const QDate &date, const QTime &time)
+ time.msecsSinceStartOfDay();
}
-static void calculateTransitionsForYear(const QWinTimeZonePrivate::QWinTransitionRule &rule, int year,
- qint64 *stdMSecs, qint64 *dstMSecs)
+static qint64 calculateTransitionForYear(const SYSTEMTIME &rule, int year, int bias)
{
// TODO Consider caching the calculated values
- // The local time in Daylight Time when switches to Standard Time
- QDate standardDate = calculateTransitionLocalDate(rule.standardTimeRule, year);
- QTime standardTime = QTime(rule.standardTimeRule.wHour, rule.standardTimeRule.wMinute,
- rule.standardTimeRule.wSecond);
- if (standardDate.isValid() && standardTime.isValid()) {
- *stdMSecs = timeToMSecs(standardDate, standardTime)
- + ((rule.standardTimeBias + rule.daylightTimeBias) * 60000);
- } else {
- *stdMSecs = QTimeZonePrivate::invalidMSecs();
- }
-
- // The local time in Standard Time when switches to Daylight Time
- QDate daylightDate = calculateTransitionLocalDate(rule.daylightTimeRule, year);
- QTime daylightTime = QTime(rule.daylightTimeRule.wHour, rule.daylightTimeRule.wMinute,
- rule.daylightTimeRule.wSecond);
- if (daylightDate.isValid() && daylightTime.isValid())
- *dstMSecs = timeToMSecs(daylightDate, daylightTime) + (rule.standardTimeBias * 60000);
- else
- *dstMSecs = QTimeZonePrivate::invalidMSecs();
-}
+ const QDate date = calculateTransitionLocalDate(rule, year);
+ const QTime time = QTime(rule.wHour, rule.wMinute, rule.wSecond);
+ if (date.isValid() && time.isValid())
+ return timeToMSecs(date, time) + bias * 60000;
+ return QTimeZonePrivate::invalidMSecs();
+}
+
+namespace {
+struct TransitionTimePair
+{
+ // Transition times after the epoch, in ms:
+ qint64 std, dst;
+ TransitionTimePair()
+ : std(QTimeZonePrivate::invalidMSecs()), dst(QTimeZonePrivate::invalidMSecs())
+ {}
+ TransitionTimePair(const QWinTimeZonePrivate::QWinTransitionRule &rule, int year)
+ // The local time in Daylight Time of the switch to Standard Time
+ : std(calculateTransitionForYear(rule.standardTimeRule, year,
+ rule.standardTimeBias + rule.daylightTimeBias)),
+ // The local time in Standard Time of the switch to Daylight Time
+ dst(calculateTransitionForYear(rule.daylightTimeRule, year, rule.standardTimeBias))
+ {}
+};
+} // anonymous namespace
static QLocale::Country userCountry()
{
@@ -390,6 +423,34 @@ static QLocale::Country userCountry()
: QLocale::AnyCountry;
}
+// Index of last rule in rules with .startYear <= year:
+static int ruleIndexForYear(const QList<QWinTimeZonePrivate::QWinTransitionRule> &rules, int year)
+{
+ if (rules.last().startYear <= year)
+ return rules.count() - 1;
+ // We don't have a rule for before the first, but the first is the best we can offer:
+ if (rules.first().startYear > year)
+ return 0;
+
+ // Otherwise, use binary chop:
+ int lo = 0, hi = rules.count();
+ // invariant: rules[i].startYear <= year < rules[hi].startYear
+ // subject to treating rules[rules.count()] as "off the end of time"
+ while (lo + 1 < hi) {
+ const int mid = (lo + hi) / 2;
+ // lo + 2 <= hi, so lo + 1 <= mid <= hi - 1, so lo < mid < hi
+ // In particular, mid < rules.count()
+ const int midYear = rules.at(mid).startYear;
+ if (midYear > year)
+ hi = mid;
+ else if (midYear < year)
+ lo = mid;
+ else // No two rules have the same startYear:
+ return mid;
+ }
+ return lo;
+}
+
// Create the system default time zone
QWinTimeZonePrivate::QWinTimeZonePrivate()
: QTimeZonePrivate()
@@ -453,16 +514,20 @@ void QWinTimeZonePrivate::init(const QByteArray &ianaId)
QWinTransitionRule rule = readRegistryRule(dynamicKey,
(LPCWSTR)QString::number(year).utf16(),
&ruleOk);
- rule.startYear = year;
- if (ruleOk)
+ if (ruleOk
+ // Don't repeat a recurrent rule:
+ && (m_tranRules.isEmpty()
+ || !isSameRule(m_tranRules.last(), rule))) {
+ rule.startYear = m_tranRules.isEmpty() ? MIN_YEAR : year;
m_tranRules.append(rule);
+ }
}
RegCloseKey(dynamicKey);
} else {
// No dynamic data so use the base data
bool ruleOk;
QWinTransitionRule rule = readRegistryRule(baseKey, L"TZI", &ruleOk);
- rule.startYear = 1970;
+ rule.startYear = MIN_YEAR;
if (ruleOk)
m_tranRules.append(rule);
}
@@ -479,20 +544,28 @@ void QWinTimeZonePrivate::init(const QByteArray &ianaId)
DWORD firstYear = 0;
DWORD lastYear = 0;
DYNAMIC_TIME_ZONE_INFORMATION dtzi = dynamicInfoForId(m_windowsId);
- GetDynamicTimeZoneInformationEffectiveYears(&dtzi, &firstYear, &lastYear);
- // If there is no dynamic information, you can still query for
- // year 0, which helps simplifying following part
- for (DWORD year = firstYear; year <= lastYear; ++year) {
- TIME_ZONE_INFORMATION tzi;
- if (!GetTimeZoneInformationForYear(year, &dtzi, &tzi))
- continue;
- QWinTransitionRule rule;
- rule.standardTimeBias = tzi.Bias + tzi.StandardBias;
- rule.daylightTimeBias = tzi.Bias + tzi.DaylightBias - rule.standardTimeBias;
- rule.standardTimeRule = tzi.StandardDate;
- rule.daylightTimeRule = tzi.DaylightDate;
- rule.startYear = year;
- m_tranRules.append(rule);
+ if (GetDynamicTimeZoneInformationEffectiveYears(&dtzi, &firstYear, &lastYear)
+ == ERROR_SUCCESS && firstYear < lastYear) {
+ for (DWORD year = firstYear; year <= lastYear; ++year) {
+ bool ok = false;
+ QWinTransitionRule rule = readDynamicRule(dtzi, year, &ok);
+ if (ok
+ // Don't repeat a recurrent rule
+ && (m_tranRules.isEmpty()
+ || !isSameRule(m_tranRules.last(), rule))) {
+ rule.startYear = m_tranRules.isEmpty() ? MIN_YEAR : year;
+ m_tranRules.append(rule);
+ }
+ }
+ } else {
+ // At least try to get the non-dynamic data:
+ dtzi.DynamicDaylightTimeDisabled = false;
+ bool ok = false;
+ QWinTransitionRule rule = readDynamicRule(dtzi, 1970, &ok);
+ if (ok) {
+ rule.startYear = MIN_YEAR;
+ m_tranRules.append(rule);
+ }
}
}
#endif // QT_USE_REGISTRY_TIMEZONE
@@ -519,7 +592,8 @@ QString QWinTimeZonePrivate::displayName(QTimeZone::TimeType timeType,
Q_UNUSED(locale);
if (nameType == QTimeZone::OffsetName) {
- QWinTransitionRule rule = ruleForYear(QDate::currentDate().year());
+ const QWinTransitionRule &rule =
+ m_tranRules.at(ruleIndexForYear(m_tranRules, QDate::currentDate().year()));
if (timeType == QTimeZone::DaylightTime)
return isoOffsetFormat((rule.standardTimeBias + rule.daylightTimeBias) * -60);
else
@@ -575,22 +649,22 @@ QTimeZonePrivate::Data QWinTimeZonePrivate::data(qint64 forMSecsSinceEpoch) cons
qint64 first;
qint64 second;
qint64 next = maxMSecs();
- qint64 stdMSecs;
- qint64 dstMSecs;
+ TransitionTimePair pair;
QWinTransitionRule rule;
do {
// Convert the transition rules into msecs for the year we want to try
- rule = ruleForYear(year);
+ rule = m_tranRules.at(ruleIndexForYear(m_tranRules, year));
// If no transition rules to calculate then no DST, so just use rule for std
if (rule.standardTimeRule.wMonth == 0 && rule.daylightTimeRule.wMonth == 0)
break;
- calculateTransitionsForYear(rule, year, &stdMSecs, &dstMSecs);
- if (stdMSecs < dstMSecs) {
- first = stdMSecs;
- second = dstMSecs;
+
+ pair = TransitionTimePair(rule, year);
+ if (pair.std < pair.dst) {
+ first = pair.std;
+ second = pair.dst;
} else {
- first = dstMSecs;
- second = stdMSecs;
+ first = pair.dst;
+ second = pair.std;
}
if (forMSecsSinceEpoch >= second && second != invalidMSecs())
next = second;
@@ -600,7 +674,7 @@ QTimeZonePrivate::Data QWinTimeZonePrivate::data(qint64 forMSecsSinceEpoch) cons
--year;
} while (next == maxMSecs() && year >= MIN_YEAR);
- return ruleToData(rule, forMSecsSinceEpoch, (next == dstMSecs) ? QTimeZone::DaylightTime : QTimeZone::StandardTime);
+ return ruleToData(rule, forMSecsSinceEpoch, (next == pair.dst) ? QTimeZone::DaylightTime : QTimeZone::StandardTime);
}
bool QWinTimeZonePrivate::hasTransitions() const
@@ -621,7 +695,7 @@ QTimeZonePrivate::Data QWinTimeZonePrivate::nextTransition(qint64 afterMSecsSinc
// If the required year falls after the last rule start year and the last rule has no
// valid future transition calculations then there is no next transition
if (year > m_tranRules.last().startYear) {
- rule = ruleForYear(year);
+ rule = m_tranRules.at(ruleIndexForYear(m_tranRules, year));
// If the rules have either a fixed year, or no month, then no future trans
if (rule.standardTimeRule.wYear != 0 || rule.daylightTimeRule.wYear != 0
|| rule.standardTimeRule.wMonth == 0 || rule.daylightTimeRule.wMonth == 0) {
@@ -634,22 +708,21 @@ QTimeZonePrivate::Data QWinTimeZonePrivate::nextTransition(qint64 afterMSecsSinc
qint64 first;
qint64 second;
qint64 next = minMSecs();
- qint64 stdMSecs;
- qint64 dstMSecs;
+ TransitionTimePair pair;
do {
// Convert the transition rules into msecs for the year we want to try
- rule = ruleForYear(year);
+ rule = m_tranRules.at(ruleIndexForYear(m_tranRules, year));
// If no transition rules to calculate then no next transition
if (rule.standardTimeRule.wMonth == 0 && rule.daylightTimeRule.wMonth == 0)
return invalidData();
- calculateTransitionsForYear(rule, year, &stdMSecs, &dstMSecs);
+ pair = TransitionTimePair(rule, year);
// Find the first and second transition for the year
- if (stdMSecs < dstMSecs) {
- first = stdMSecs;
- second = dstMSecs;
+ if (pair.std < pair.dst) {
+ first = pair.std;
+ second = pair.dst;
} else {
- first = dstMSecs;
- second = stdMSecs;
+ first = pair.dst;
+ second = pair.std;
}
if (afterMSecsSinceEpoch < first)
next = first;
@@ -662,7 +735,7 @@ QTimeZonePrivate::Data QWinTimeZonePrivate::nextTransition(qint64 afterMSecsSinc
if (next == minMSecs() || next == invalidMSecs())
return invalidData();
- return ruleToData(rule, next, (next == dstMSecs) ? QTimeZone::DaylightTime : QTimeZone::StandardTime);
+ return ruleToData(rule, next, (next == pair.dst) ? QTimeZone::DaylightTime : QTimeZone::StandardTime);
}
QTimeZonePrivate::Data QWinTimeZonePrivate::previousTransition(qint64 beforeMSecsSinceEpoch) const
@@ -674,7 +747,7 @@ QTimeZonePrivate::Data QWinTimeZonePrivate::previousTransition(qint64 beforeMSec
// If the required year falls before the first rule start year and the first rule has no
// valid transition calculations then there is no previous transition
if (year < m_tranRules.first().startYear) {
- rule = ruleForYear(year);
+ rule = m_tranRules.at(ruleIndexForYear(m_tranRules, year));
// If the rules have either a fixed year, or no month, then no previous trans
if (rule.standardTimeRule.wYear != 0 || rule.daylightTimeRule.wYear != 0
|| rule.standardTimeRule.wMonth == 0 || rule.daylightTimeRule.wMonth == 0) {
@@ -685,21 +758,20 @@ QTimeZonePrivate::Data QWinTimeZonePrivate::previousTransition(qint64 beforeMSec
qint64 first;
qint64 second;
qint64 next = maxMSecs();
- qint64 stdMSecs;
- qint64 dstMSecs;
+ TransitionTimePair pair;
do {
// Convert the transition rules into msecs for the year we want to try
- rule = ruleForYear(year);
+ rule = m_tranRules.at(ruleIndexForYear(m_tranRules, year));
// If no transition rules to calculate then no previous transition
if (rule.standardTimeRule.wMonth == 0 && rule.daylightTimeRule.wMonth == 0)
return invalidData();
- calculateTransitionsForYear(rule, year, &stdMSecs, &dstMSecs);
- if (stdMSecs < dstMSecs) {
- first = stdMSecs;
- second = dstMSecs;
+ pair = TransitionTimePair(rule, year);
+ if (pair.std < pair.dst) {
+ first = pair.std;
+ second = pair.dst;
} else {
- first = dstMSecs;
- second = stdMSecs;
+ first = pair.dst;
+ second = pair.std;
}
if (beforeMSecsSinceEpoch > second && second != invalidMSecs())
next = second;
@@ -712,7 +784,7 @@ QTimeZonePrivate::Data QWinTimeZonePrivate::previousTransition(qint64 beforeMSec
if (next == maxMSecs())
return invalidData();
- return ruleToData(rule, next, (next == dstMSecs) ? QTimeZone::DaylightTime : QTimeZone::StandardTime);
+ return ruleToData(rule, next, (next == pair.dst) ? QTimeZone::DaylightTime : QTimeZone::StandardTime);
}
QByteArray QWinTimeZonePrivate::systemTimeZoneId() const
@@ -744,20 +816,11 @@ QList<QByteArray> QWinTimeZonePrivate::availableTimeZoneIds() const
return result;
}
-QWinTimeZonePrivate::QWinTransitionRule QWinTimeZonePrivate::ruleForYear(int year) const
-{
- for (int i = m_tranRules.size() - 1; i >= 0; --i) {
- if (m_tranRules.at(i).startYear <= year)
- return m_tranRules.at(i);
- }
- return m_tranRules.at(0);
-}
-
QTimeZonePrivate::Data QWinTimeZonePrivate::ruleToData(const QWinTransitionRule &rule,
qint64 atMSecsSinceEpoch,
QTimeZone::TimeType type) const
{
- QTimeZonePrivate::Data tran = QTimeZonePrivate::invalidData();
+ Data tran = invalidData();
tran.atMSecsSinceEpoch = atMSecsSinceEpoch;
tran.standardTimeOffset = rule.standardTimeBias * -60;
if (type == QTimeZone::DaylightTime) {
diff --git a/src/corelib/tools/qversionnumber.h b/src/corelib/tools/qversionnumber.h
index 3836bc2119..1bfb4aab39 100644
--- a/src/corelib/tools/qversionnumber.h
+++ b/src/corelib/tools/qversionnumber.h
@@ -281,7 +281,7 @@ public:
Q_REQUIRED_RESULT Q_CORE_EXPORT QString toString() const;
#if QT_STRINGVIEW_LEVEL < 2
- Q_REQUIRED_RESULT Q_CORE_EXPORT static Q_DECL_PURE_FUNCTION QVersionNumber fromString(const QString &string, int *suffixIndex = Q_NULLPTR);
+ Q_REQUIRED_RESULT Q_CORE_EXPORT static Q_DECL_PURE_FUNCTION QVersionNumber fromString(const QString &string, int *suffixIndex = nullptr);
#endif
Q_REQUIRED_RESULT Q_CORE_EXPORT static Q_DECL_PURE_FUNCTION QVersionNumber fromString(QLatin1String string, int *suffixIndex = nullptr);
Q_REQUIRED_RESULT Q_CORE_EXPORT static Q_DECL_PURE_FUNCTION QVersionNumber fromString(QStringView string, int *suffixIndex = nullptr);