From 4c83183e711fb61d10f7c2475cbdbb04c4c36802 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Mon, 16 Sep 2013 21:00:53 +0200 Subject: MetaType: Add assignment operator to the container iterators. Change-Id: Ib4f2197a0ab6bd41c91de667cd3087fb40e44097 Reviewed-by: Olivier Goffart --- src/corelib/kernel/qvariant.cpp | 8 ++++++++ src/corelib/kernel/qvariant.h | 20 ++++++++++++++++++++ 2 files changed, 28 insertions(+) (limited to 'src/corelib/kernel') diff --git a/src/corelib/kernel/qvariant.cpp b/src/corelib/kernel/qvariant.cpp index c3ccc74a20..ec90c4ceef 100644 --- a/src/corelib/kernel/qvariant.cpp +++ b/src/corelib/kernel/qvariant.cpp @@ -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. diff --git a/src/corelib/kernel/qvariant.h b/src/corelib/kernel/qvariant.h index 1f35850043..b6d5c1aebd 100644 --- a/src/corelib/kernel/qvariant.h +++ b/src/corelib/kernel/qvariant.h @@ -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()) @@ -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); -- cgit v1.2.3