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:
parent
b8521b89df
commit
e4173bc7bc
@ -185,14 +185,19 @@ QT_IMPL_METATYPE_EXTERN(QItemSelection)
|
|||||||
bool QItemSelectionRange::intersects(const QItemSelectionRange &other) const
|
bool QItemSelectionRange::intersects(const QItemSelectionRange &other) const
|
||||||
{
|
{
|
||||||
// isValid() and parent() last since they are more expensive
|
// isValid() and parent() last since they are more expensive
|
||||||
return (model() == other.model()
|
if (model() != other.model())
|
||||||
&& ((top() <= other.top() && bottom() >= other.top())
|
return false;
|
||||||
|| (top() >= other.top() && top() <= other.bottom()))
|
|
||||||
&& ((left() <= other.left() && right() >= other.left())
|
if (top() > other.bottom() || bottom() < other.top())
|
||||||
|| (left() >= other.left() && left() <= other.right()))
|
return false;
|
||||||
&& parent() == other.parent()
|
|
||||||
&& isValid() && other.isValid()
|
if (left() > other.right() || right() < other.left())
|
||||||
);
|
return false;
|
||||||
|
|
||||||
|
if (parent() != other.parent())
|
||||||
|
return false;
|
||||||
|
|
||||||
|
return isValid() && other.isValid();
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
|
Loading…
x
Reference in New Issue
Block a user