summaryrefslogtreecommitdiffstats
path: root/src/corelib/itemmodels
diff options
context:
space:
mode:
authorTatiana Borisova <tatiana.borisova@qt.io>2024-03-28 13:46:21 +0100
committerTatiana Borisova <tatiana.borisova@qt.io>2024-04-18 14:23:15 +0200
commit6324075a2dec4a70fc459e2ce471f89a533d7ddb (patch)
treeb23110cca7bbe29e3a5b568fa6b281c65f2a607f /src/corelib/itemmodels
parenta87764789feaa0575b9f4f0957bb7ec3e3b9a4d1 (diff)
QItemSelectionRange: use new comparison helper macros
Replace public operators operator==(), operator!=() of QItemSelectionRange class to friend methods comparesEqual(). Use QT_CORE_REMOVED_SINCE and removed_api.cpp to get rid of current comparison methods and replace them with a friend. Task-number: QTBUG-120304 Change-Id: Ideff990c942d5ee1c89a93ac2081cc5d7067b23f Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
Diffstat (limited to 'src/corelib/itemmodels')
-rw-r--r--src/corelib/itemmodels/qitemselectionmodel.cpp10
-rw-r--r--src/corelib/itemmodels/qitemselectionmodel.h14
2 files changed, 16 insertions, 8 deletions
diff --git a/src/corelib/itemmodels/qitemselectionmodel.cpp b/src/corelib/itemmodels/qitemselectionmodel.cpp
index 70063a10bf..6df60aaf61 100644
--- a/src/corelib/itemmodels/qitemselectionmodel.cpp
+++ b/src/corelib/itemmodels/qitemselectionmodel.cpp
@@ -27,6 +27,8 @@ QT_IMPL_METATYPE_EXTERN(QItemSelection)
\ingroup model-view
+ \compares equality
+
A QItemSelectionRange contains information about a range of
selected items in a model. A range of items is a contiguous array
of model items, extending to cover a number of adjacent rows and
@@ -216,17 +218,17 @@ QItemSelectionRange QItemSelectionRange::intersected(const QItemSelectionRange &
}
/*!
- \fn bool QItemSelectionRange::operator==(const QItemSelectionRange &other) const
+ \fn bool QItemSelectionRange::operator==(const QItemSelectionRange &lhs, const QItemSelectionRange &rhs)
- Returns \c true if the selection range is exactly the same as the \a other
+ Returns \c true if \a lhs selection range is exactly the same as the \a rhs
range given; otherwise returns \c false.
*/
/*!
- \fn bool QItemSelectionRange::operator!=(const QItemSelectionRange &other) const
+ \fn bool QItemSelectionRange::operator!=(const QItemSelectionRange &lhs, const QItemSelectionRange &rhs)
- Returns \c true if the selection range differs from the \a other range given;
+ Returns \c true if \a lhs selection range differs from the \a rhs range given;
otherwise returns \c false.
*/
diff --git a/src/corelib/itemmodels/qitemselectionmodel.h b/src/corelib/itemmodels/qitemselectionmodel.h
index a19923a90b..c4b8dadc97 100644
--- a/src/corelib/itemmodels/qitemselectionmodel.h
+++ b/src/corelib/itemmodels/qitemselectionmodel.h
@@ -57,12 +57,12 @@ public:
bool intersects(const QItemSelectionRange &other) const;
QItemSelectionRange intersected(const QItemSelectionRange &other) const;
-
+#if QT_CORE_REMOVED_SINCE(6, 8)
inline bool operator==(const QItemSelectionRange &other) const
- { return (tl == other.tl && br == other.br); }
+ { return comparesEqual(*this, other); }
inline bool operator!=(const QItemSelectionRange &other) const
- { return !operator==(other); }
-
+ { return !operator==(other); }
+#endif
inline bool isValid() const
{
return (tl.isValid() && br.isValid() && tl.parent() == br.parent()
@@ -74,6 +74,12 @@ public:
QModelIndexList indexes() const;
private:
+ friend bool comparesEqual(const QItemSelectionRange &lhs,
+ const QItemSelectionRange &rhs) noexcept
+ {
+ return (lhs.tl == rhs.tl && lhs.br == rhs.br);
+ }
+ Q_DECLARE_EQUALITY_COMPARABLE(QItemSelectionRange)
QPersistentModelIndex tl, br;
};
Q_DECLARE_TYPEINFO(QItemSelectionRange, Q_RELOCATABLE_TYPE);