QItemSelectionModel: simplify QItemSelectionRange::intersects()

Simplify QItemSelectionRange::intersects() and make it more readable.

Task-number: QTBUG-113137
Change-Id: I20f78192e59f5a878a5db2c177d8ee89d8872b2c
Reviewed-by: David Faure <david.faure@kdab.com>
This commit is contained in:
Christian Ehrlicher 2024-09-09 20:56:56 +02:00
parent b8521b89df
commit e4173bc7bc

View File

@ -185,14 +185,19 @@ QT_IMPL_METATYPE_EXTERN(QItemSelection)
bool QItemSelectionRange::intersects(const QItemSelectionRange &other) const
{
// isValid() and parent() last since they are more expensive
return (model() == other.model()
&& ((top() <= other.top() && bottom() >= other.top())
|| (top() >= other.top() && top() <= other.bottom()))
&& ((left() <= other.left() && right() >= other.left())
|| (left() >= other.left() && left() <= other.right()))
&& parent() == other.parent()
&& isValid() && other.isValid()
);
if (model() != other.model())
return false;
if (top() > other.bottom() || bottom() < other.top())
return false;
if (left() > other.right() || right() < other.left())
return false;
if (parent() != other.parent())
return false;
return isValid() && other.isValid();
}
/*!