summaryrefslogtreecommitdiffstats
path: root/src/gui/itemviews/qitemselectionmodel.cpp
diff options
context:
space:
mode:
authorThierry Bastian <thierry.bastian@nokia.com>2010-04-12 07:18:10 (GMT)
committerThierry Bastian <thierry.bastian@nokia.com>2010-04-12 07:21:08 (GMT)
commitd45c0d3930e295e9798f9172fa0f151044f7036b (patch)
tree70dce24226897ef66075742bab77539799c5df9c /src/gui/itemviews/qitemselectionmodel.cpp
parent757b9bf63dedbc33205f482c80f6843b738aa389 (diff)
downloadQt-d45c0d3930e295e9798f9172fa0f151044f7036b.zip
Qt-d45c0d3930e295e9798f9172fa0f151044f7036b.tar.gz
Qt-d45c0d3930e295e9798f9172fa0f151044f7036b.tar.bz2
Make sure the selectionChanged signal is not called too much
It could happen that it was called with empty selectionrange Now we check to see if the selection ranges are empty Task-number: QTBUG-9507 Reviewed-by: gabi
Diffstat (limited to 'src/gui/itemviews/qitemselectionmodel.cpp')
-rw-r--r--src/gui/itemviews/qitemselectionmodel.cpp21
1 files changed, 21 insertions, 0 deletions
diff --git a/src/gui/itemviews/qitemselectionmodel.cpp b/src/gui/itemviews/qitemselectionmodel.cpp
index d6e68f6..f848321 100644
--- a/src/gui/itemviews/qitemselectionmodel.cpp
+++ b/src/gui/itemviews/qitemselectionmodel.cpp
@@ -292,6 +292,27 @@ static void indexesFromRange(const QItemSelectionRange &range, QModelIndexList &
}
/*!
+ Returns true if the selection range contains no selectable item
+ \since 4.7
+*/
+
+bool QItemSelectionRange::isEmpty() const
+{
+ if (!isValid() || !model())
+ return true;
+
+ for (int column = left(); column <= right(); ++column) {
+ for (int row = top(); row <= bottom(); ++row) {
+ QModelIndex index = model()->index(row, column, parent());
+ Qt::ItemFlags flags = model()->flags(index);
+ if ((flags & Qt::ItemIsSelectable) && (flags & Qt::ItemIsEnabled))
+ return false;
+ }
+ }
+ return true;
+}
+
+/*!
Returns the list of model index items stored in the selection.
*/