summaryrefslogtreecommitdiffstats
path: root/src/corelib/tools
diff options
context:
space:
mode:
authorFrederik Gladhorn <frederik.gladhorn@digia.com>2013-11-18 12:27:03 +0100
committerFrederik Gladhorn <frederik.gladhorn@digia.com>2013-11-18 12:27:04 +0100
commit72ea7900858a31c1c6b93e6fed9f2f4dc30291e4 (patch)
tree89c4dd69ad88dde8ec506dbf1a2fae79ef454914 /src/corelib/tools
parentaafbd7392ead765c2038a1ac6b569d083effb81d (diff)
parenteb122a6fe4de5b95acb287f92c6ca5e81864b1c6 (diff)
Merge remote-tracking branch 'origin/release' into stable
Diffstat (limited to 'src/corelib/tools')
-rw-r--r--src/corelib/tools/qcollator.cpp42
-rw-r--r--src/corelib/tools/qcollator.h24
-rw-r--r--src/corelib/tools/qcollator_icu.cpp5
-rw-r--r--src/corelib/tools/qcollator_macx.cpp5
-rw-r--r--src/corelib/tools/qcollator_posix.cpp5
-rw-r--r--src/corelib/tools/qcollator_win.cpp5
-rw-r--r--src/corelib/tools/qmap.cpp6
-rw-r--r--src/corelib/tools/qtimezone.cpp9
-rw-r--r--src/corelib/tools/qtimezone.h10
9 files changed, 76 insertions, 35 deletions
diff --git a/src/corelib/tools/qcollator.cpp b/src/corelib/tools/qcollator.cpp
index a3a9ef940b..9c97d6b158 100644
--- a/src/corelib/tools/qcollator.cpp
+++ b/src/corelib/tools/qcollator.cpp
@@ -99,7 +99,7 @@ QCollator::QCollator(const QCollator &other)
*/
QCollator::~QCollator()
{
- if (!d->ref.deref())
+ if (d && !d->ref.deref())
delete d;
}
@@ -109,14 +109,41 @@ QCollator::~QCollator()
QCollator &QCollator::operator=(const QCollator &other)
{
if (this != &other) {
- if (!d->ref.deref())
+ if (d && !d->ref.deref())
delete d;
d = other.d;
- d->ref.ref();
+ if (d) d->ref.ref();
}
return *this;
}
+/*
+ \fn void QCollator::QCollator(QCollator &&other)
+
+ Move constructor. Moves from \a other into this collator.
+
+ Note that a moved-from QCollator can only be destroyed or assigned
+ to. The effect of calling other functions than the destructor or
+ one of the assignment operators is undefined.
+*/
+
+/*
+ \fn QCollator &QCollator::operator=(QCollator &&other)
+
+ Move-assigns from \a other to this collator.
+
+ Note that a moved-from QCollator can only be destroyed or assigned
+ to. The effect of calling other functions than the destructor or
+ one of the assignment operators is undefined.
+*/
+
+/*!
+ \fn void QCollator::swap(QCollator &other)
+
+ Swaps this collator with \a other. This function is very fast and
+ never fails.
+*/
+
/*!
\internal
*/
@@ -301,12 +328,13 @@ QCollatorSortKey& QCollatorSortKey::operator=(const QCollatorSortKey &other)
}
/*!
- \fn bool QCollatorSortKey::operator<(const QCollatorSortKey &otherKey) const
+ \fn bool operator<(const QCollatorSortKey &lhs, const QCollatorSortKey &rhs)
+ \relates QCollatorSortKey
- According to the QCollator that created the key, returns \c true if the
- key should be sorted before than \a otherKey; otherwise returns \c false.
+ According to the QCollator that created the keys, returns \c true if \a lhs
+ should be sorted before \a rhs; otherwise returns \c false.
- \sa compare()
+ \sa QCollatorSortKey::compare()
*/
/*!
diff --git a/src/corelib/tools/qcollator.h b/src/corelib/tools/qcollator.h
index b99fd1c0cc..781e95b10c 100644
--- a/src/corelib/tools/qcollator.h
+++ b/src/corelib/tools/qcollator.h
@@ -61,10 +61,11 @@ public:
QCollatorSortKey &operator=(const QCollatorSortKey &other);
#ifdef Q_COMPILER_RVALUE_REFS
inline QCollatorSortKey &operator=(QCollatorSortKey &&other)
- { qSwap(d, other.d); return *this; }
+ { swap(other); return *this; }
#endif
+ void swap(QCollatorSortKey &other)
+ { d.swap(other.d); }
- bool operator<(const QCollatorSortKey &key) const;
int compare(const QCollatorSortKey &key) const;
protected:
@@ -76,13 +77,27 @@ private:
QCollatorSortKey();
};
+inline bool operator<(const QCollatorSortKey &lhs, const QCollatorSortKey &rhs)
+{
+ return lhs.compare(rhs) < 0;
+}
+
class Q_CORE_EXPORT QCollator
{
public:
- QCollator(const QLocale &locale = QLocale());
+ explicit QCollator(const QLocale &locale = QLocale());
QCollator(const QCollator &);
~QCollator();
QCollator &operator=(const QCollator &);
+#ifdef Q_COMPILER_RVALUE_REFS
+ QCollator(QCollator &&other)
+ : d(other.d) { other.d = 0; }
+ QCollator &operator=(QCollator &&other)
+ { swap(other); return *this; }
+#endif
+
+ void swap(QCollator &other)
+ { qSwap(d, other.d); }
void setLocale(const QLocale &locale);
QLocale locale() const;
@@ -111,6 +126,9 @@ private:
void detach();
};
+Q_DECLARE_SHARED(QCollatorSortKey)
+Q_DECLARE_SHARED(QCollator)
+
QT_END_NAMESPACE
#endif // QCOLLATOR_P_H
diff --git a/src/corelib/tools/qcollator_icu.cpp b/src/corelib/tools/qcollator_icu.cpp
index 46f830a34c..407a493d25 100644
--- a/src/corelib/tools/qcollator_icu.cpp
+++ b/src/corelib/tools/qcollator_icu.cpp
@@ -151,11 +151,6 @@ QCollatorSortKey QCollator::sortKey(const QString &string) const
return QCollatorSortKey(new QCollatorSortKeyPrivate(result));
}
-bool QCollatorSortKey::operator<(const QCollatorSortKey &otherKey) const
-{
- return d->m_key < otherKey.d->m_key;
-}
-
int QCollatorSortKey::compare(const QCollatorSortKey &otherKey) const
{
return qstrcmp(d->m_key, otherKey.d->m_key);
diff --git a/src/corelib/tools/qcollator_macx.cpp b/src/corelib/tools/qcollator_macx.cpp
index 8edd190fbe..8985cd4eba 100644
--- a/src/corelib/tools/qcollator_macx.cpp
+++ b/src/corelib/tools/qcollator_macx.cpp
@@ -162,11 +162,6 @@ QCollatorSortKey QCollator::sortKey(const QString &string) const
return QCollatorSortKey(new QCollatorSortKeyPrivate(ret));
}
-bool QCollatorSortKey::operator<(const QCollatorSortKey &key) const
-{
- return compare(key) < 0;
-}
-
int QCollatorSortKey::compare(const QCollatorSortKey &key) const
{
SInt32 order;
diff --git a/src/corelib/tools/qcollator_posix.cpp b/src/corelib/tools/qcollator_posix.cpp
index a43618dcf1..b47b546d01 100644
--- a/src/corelib/tools/qcollator_posix.cpp
+++ b/src/corelib/tools/qcollator_posix.cpp
@@ -135,11 +135,6 @@ QCollatorSortKey QCollator::sortKey(const QString &string) const
return QCollatorSortKey(new QCollatorSortKeyPrivate(result));
}
-bool QCollatorSortKey::operator<(const QCollatorSortKey &otherKey) const
-{
- return compare(otherKey) < 0;
-}
-
int QCollatorSortKey::compare(const QCollatorSortKey &otherKey) const
{
return std::wcscmp(d->m_key.constData(),
diff --git a/src/corelib/tools/qcollator_win.cpp b/src/corelib/tools/qcollator_win.cpp
index 282711fbc6..8e59000946 100644
--- a/src/corelib/tools/qcollator_win.cpp
+++ b/src/corelib/tools/qcollator_win.cpp
@@ -155,11 +155,6 @@ QCollatorSortKey QCollator::sortKey(const QString &string) const
return QCollatorSortKey(new QCollatorSortKeyPrivate(ret));
}
-bool QCollatorSortKey::operator<(const QCollatorSortKey &otherKey) const
-{
- return d->m_key < otherKey.d->m_key;
-}
-
int QCollatorSortKey::compare(const QCollatorSortKey &otherKey) const
{
return d->m_key.compare(otherKey.d->m_key);
diff --git a/src/corelib/tools/qmap.cpp b/src/corelib/tools/qmap.cpp
index 9aebbb7b3c..22d744f869 100644
--- a/src/corelib/tools/qmap.cpp
+++ b/src/corelib/tools/qmap.cpp
@@ -897,6 +897,7 @@ void QMapDataBase::freeData(QMapDataBase *d)
*/
/*! \fn const Key &QMap::firstKey() const
+ \since 5.2
Returns a reference to the smallest key in the map.
This function assumes that the map is not empty.
@@ -907,6 +908,7 @@ void QMapDataBase::freeData(QMapDataBase *d)
*/
/*! \fn const Key &QMap::lastKey() const
+ \since 5.2
Returns a reference to the largest key in the map.
This function assumes that the map is not empty.
@@ -917,6 +919,7 @@ void QMapDataBase::freeData(QMapDataBase *d)
*/
/*! \fn T &QMap::first()
+ \since 5.2
Returns a reference to the first value in the map, that is the value mapped
to the smallest key. This function assumes that the map is not empty.
@@ -927,11 +930,13 @@ void QMapDataBase::freeData(QMapDataBase *d)
*/
/*! \fn const T &QMap::first() const
+ \since 5.2
\overload
*/
/*! \fn T &QMap::last()
+ \since 5.2
Returns a reference to the last value in the map, that is the value mapped
to the largest key. This function assumes that the map is not empty.
@@ -942,6 +947,7 @@ void QMapDataBase::freeData(QMapDataBase *d)
*/
/*! \fn const T &QMap::last() const
+ \since 5.2
\overload
*/
diff --git a/src/corelib/tools/qtimezone.cpp b/src/corelib/tools/qtimezone.cpp
index b6196d99e5..9288dc7756 100644
--- a/src/corelib/tools/qtimezone.cpp
+++ b/src/corelib/tools/qtimezone.cpp
@@ -422,13 +422,18 @@ QTimeZone &QTimeZone::operator=(const QTimeZone &other)
return *this;
}
+/*
+ \fn void QTimeZone::swap(QTimeZone &other)
+
+ Swaps this timezone with \a other. This function is very fast and
+ never fails.
+*/
+
/*!
\fn QTimeZone &QTimeZone::operator=(QTimeZone &&other)
Move-assigns \a other to this QTimeZone instance, transferring the
ownership of the managed pointer to this instance.
-
- \since 5.2
*/
/*!
diff --git a/src/corelib/tools/qtimezone.h b/src/corelib/tools/qtimezone.h
index 1a6a923cf4..cbc4f3e4ad 100644
--- a/src/corelib/tools/qtimezone.h
+++ b/src/corelib/tools/qtimezone.h
@@ -78,8 +78,8 @@ public:
QTimeZone();
explicit QTimeZone(const QByteArray &olsenId);
- QTimeZone(int offsetSeconds);
- QTimeZone(const QByteArray &zoneId, int offsetSeconds, const QString &name,
+ explicit QTimeZone(int offsetSeconds);
+ /*implicit*/ QTimeZone(const QByteArray &zoneId, int offsetSeconds, const QString &name,
const QString &abbreviation, QLocale::Country country = QLocale::AnyCountry,
const QString &comment = QString());
QTimeZone(const QTimeZone &other);
@@ -87,9 +87,12 @@ public:
QTimeZone &operator=(const QTimeZone &other);
#ifdef Q_COMPILER_RVALUE_REFS
- QTimeZone &operator=(QTimeZone &&other) { std::swap(d, other.d); return *this; }
+ QTimeZone &operator=(QTimeZone &&other) { swap(other); return *this; }
#endif
+ void swap(QTimeZone &other)
+ { d.swap(other.d); }
+
bool operator==(const QTimeZone &other) const;
bool operator!=(const QTimeZone &other) const;
@@ -149,6 +152,7 @@ private:
};
Q_DECLARE_TYPEINFO(QTimeZone::OffsetData, Q_MOVABLE_TYPE);
+Q_DECLARE_SHARED(QTimeZone)
#ifndef QT_NO_DATASTREAM
Q_CORE_EXPORT QDataStream &operator<<(QDataStream &ds, const QTimeZone &tz);