MetaType: Add assignment operator to the container iterators.
Change-Id: Ib4f2197a0ab6bd41c91de667cd3087fb40e44097 Reviewed-by: Olivier Goffart <ogoffart@woboq.com>bb10
parent
09f9c6e1b9
commit
4c83183e71
|
|
@ -3508,6 +3508,10 @@ QDebug operator<<(QDebug dbg, const QVariant::Type p)
|
|||
Creates a copy of \a other.
|
||||
*/
|
||||
|
||||
/*! \fn QSequentialIterable::const_iterator::const_iterator& QSequentialIterable::const_iterator::operator=(const const_iterator &other)
|
||||
Assigns \a other to this.
|
||||
*/
|
||||
|
||||
/*! \fn QVariant QSequentialIterable::const_iterator::operator*() const
|
||||
|
||||
Returns the current item, converted to a QVariant.
|
||||
|
|
@ -3684,6 +3688,10 @@ QDebug operator<<(QDebug dbg, const QVariant::Type p)
|
|||
Creates a copy of \a other.
|
||||
*/
|
||||
|
||||
/*! \fn QAssociativeIterable::const_iterator::const_iterator& QAssociativeIterable::const_iterator::operator=(const const_iterator &other)
|
||||
Assigns \a other to this.
|
||||
*/
|
||||
|
||||
/*! \fn QVariant QAssociativeIterable::const_iterator::operator*() const
|
||||
|
||||
Returns the current value, converted to a QVariant.
|
||||
|
|
|
|||
|
|
@ -602,6 +602,16 @@ public:
|
|||
ref->ref();
|
||||
}
|
||||
|
||||
inline const_iterator& operator=(const const_iterator &other)
|
||||
{
|
||||
if (!m_impl.equal(other.m_impl)) {
|
||||
m_impl = other.m_impl;
|
||||
ref = other.ref;
|
||||
}
|
||||
ref->ref();
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline const QVariant operator*() const {
|
||||
const QtMetaTypePrivate::VariantData d = m_impl.getCurrent();
|
||||
if (d.metaTypeId == qMetaTypeId<QVariant>())
|
||||
|
|
@ -671,6 +681,16 @@ public:
|
|||
ref->ref();
|
||||
}
|
||||
|
||||
inline const_iterator& operator=(const const_iterator &other)
|
||||
{
|
||||
if (!m_impl.equal(other.m_impl)) {
|
||||
m_impl = other.m_impl;
|
||||
ref = other.ref;
|
||||
}
|
||||
ref->ref();
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline const QVariant key() const {
|
||||
const QtMetaTypePrivate::VariantData d = m_impl.getCurrentKey();
|
||||
QVariant v(d.metaTypeId, d.data, d.flags);
|
||||
|
|
|
|||
|
|
@ -3830,13 +3830,8 @@ void tst_QVariant::iterateContainerElements()
|
|||
for ( ; it != end; ++it, ++i) {
|
||||
QCOMPARE(ints.at(i), *it);
|
||||
}
|
||||
}
|
||||
{
|
||||
QVariantList ints;
|
||||
ints << 1 << 2 << 3;
|
||||
QVariant var = QVariant::fromValue(ints);
|
||||
QSequentialIterable iter = var.value<QSequentialIterable>();
|
||||
QSequentialIterable::const_iterator it = iter.begin();
|
||||
|
||||
it = iter.begin();
|
||||
|
||||
QVariantList intsCopy;
|
||||
intsCopy << *(it++);
|
||||
|
|
@ -3894,17 +3889,11 @@ void tst_QVariant::iterateContainerElements()
|
|||
for ( ; it != end; ++it, ++i) {
|
||||
QCOMPARE(*(mapping.begin() + i), (*it).toString());
|
||||
}
|
||||
}
|
||||
{
|
||||
|
||||
QVariantList nums;
|
||||
nums << "one" << "two" << "three";
|
||||
QMap<int, QString> mapping;
|
||||
mapping.insert(1, "one");
|
||||
mapping.insert(2, "two");
|
||||
mapping.insert(3, "three");
|
||||
QVariant var = QVariant::fromValue(mapping);
|
||||
QAssociativeIterable iter = var.value<QAssociativeIterable>();
|
||||
QAssociativeIterable::const_iterator it = iter.begin();
|
||||
|
||||
it = iter.begin();
|
||||
|
||||
QVariantList numsCopy;
|
||||
numsCopy << *(it++);
|
||||
|
|
|
|||
Loading…
Reference in New Issue