summaryrefslogtreecommitdiffstats
path: root/src/gui/itemviews
diff options
context:
space:
mode:
authorStephen Kelly <stephen@kdab.com>2010-06-14 11:23:15 (GMT)
committerOlivier Goffart <olivier.goffart@nokia.com>2010-07-07 10:02:14 (GMT)
commit6d337a3dd715597aa8ec797f6aeb8f42db129a00 (patch)
tree313d7980c6a6eeba1a5dedb37edafa27b53914ec /src/gui/itemviews
parent591e2a1e096618979250f062648b731367e60710 (diff)
downloadQt-6d337a3dd715597aa8ec797f6aeb8f42db129a00.zip
Qt-6d337a3dd715597aa8ec797f6aeb8f42db129a00.tar.gz
Qt-6d337a3dd715597aa8ec797f6aeb8f42db129a00.tar.bz2
Add QItemSelectionRange::operator<()
Reviewed-by: Olivier Goffart Merge-Request: 688
Diffstat (limited to 'src/gui/itemviews')
-rw-r--r--src/gui/itemviews/qitemselectionmodel.h24
1 files changed, 24 insertions, 0 deletions
diff --git a/src/gui/itemviews/qitemselectionmodel.h b/src/gui/itemviews/qitemselectionmodel.h
index 436514f..e2bd06b 100644
--- a/src/gui/itemviews/qitemselectionmodel.h
+++ b/src/gui/itemviews/qitemselectionmodel.h
@@ -101,6 +101,30 @@ public:
{ return (tl == other.tl && br == other.br); }
inline bool operator!=(const QItemSelectionRange &other) const
{ return !operator==(other); }
+ inline bool operator<(const QItemSelectionRange &other) const
+ {
+ // Comparing parents will compare the models, but if two equivalent ranges
+ // in two different models have invalid parents, they would appear the same
+ if (other.tl.model() == tl.model()) {
+ // parent has to be calculated, so we only do so once.
+ const QModelIndex topLeftParent = tl.parent();
+ const QModelIndex otherTopLeftParent = other.tl.parent();
+ if (topLeftParent == otherTopLeftParent) {
+ if (other.tl.row() == tl.row()) {
+ if (other.tl.column() == tl.column()) {
+ if (other.br.row() == br.row()) {
+ return br.column() < other.br.column();
+ }
+ return br.row() < other.br.row();
+ }
+ return tl.column() < other.tl.column();
+ }
+ return tl.row() < other.tl.row();
+ }
+ return topLeftParent < otherTopLeftParent;
+ }
+ return tl.model() < other.tl.model();
+ }
inline bool isValid() const
{