aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFabian Kosmale <fabian.kosmale@qt.io>2020-07-13 09:37:44 +0200
committerFabian Kosmale <fabian.kosmale@qt.io>2020-07-13 11:04:24 +0200
commit47bf186e0c5c14c47c0b090f52fd8c915b5ea85c (patch)
tree5d3ac70222b2f595c42880173e800285cbd7a5ba
parent80dc47641cad6dd4006d704139c3a3dfe4ae679f (diff)
QQmlListReference: add operator==
This is needed after the QVariant equality change in order for QQuickTableView to work correctly. QQuickTableViewPrivate::syncModel compares two variants, modelVariant and assignedModel. Without this change, this comparison would always fail, even if assignedModel had been previously assigned to modelVariant. With this change, the comparison returns true again when the two QQmlListReferences have the same identiy (i.e., same d pointer). Change-Id: I9f71e530928408f14a78df4b743e5700a2d104b2 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
-rw-r--r--src/qml/qml/qqmllist.cpp10
-rw-r--r--src/qml/qml/qqmllist.h1
2 files changed, 11 insertions, 0 deletions
diff --git a/src/qml/qml/qqmllist.cpp b/src/qml/qml/qqmllist.cpp
index 9f1ffd24c5..717170d362 100644
--- a/src/qml/qml/qqmllist.cpp
+++ b/src/qml/qml/qqmllist.cpp
@@ -568,4 +568,14 @@ Synonym for \c {void (*)(QQmlListProperty<T> *property)}.
Remove the last element from the list \a property.
*/
+/*!
+\fn bool QQmlListReference::operator==(const QQmlListReference &other) const
+
+Compares two QQmlListReferences. They are only considered equal if one was
+created from the other via copy assignment or copy construction.
+
+\note Independently created references to the same object are not considered
+to be equal.
+*/
+
QT_END_NAMESPACE
diff --git a/src/qml/qml/qqmllist.h b/src/qml/qml/qqmllist.h
index 17333ca9e4..313d7449fe 100644
--- a/src/qml/qml/qqmllist.h
+++ b/src/qml/qml/qqmllist.h
@@ -227,6 +227,7 @@ public:
int count() const;
bool replace(int, QObject *) const;
bool removeLast() const;
+ bool operator==(const QQmlListReference &other) const {return d == other.d;}
private:
friend class QQmlListReferencePrivate;