[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: KDE/kdelibs/kdeui/itemviews
From: Stephen Kelly <steveire () gmail ! com>
Date: 2010-09-13 13:38:12
Message-ID: 20100913133813.00498AC887 () svn ! kde ! org
[Download RAW message or body]
SVN commit 1174880 by skelly:
Don't use QAbstractProxyModel::mapSelectionFromSource() because it creates invalid ranges.
M +31 -4 kselectionproxymodel.cpp
--- trunk/KDE/kdelibs/kdeui/itemviews/kselectionproxymodel.cpp #1174879:1174880
@@ -2332,8 +2332,21 @@
QItemSelection KSelectionProxyModel::mapSelectionFromSource(const QItemSelection& selection) const
{
Q_D(const KSelectionProxyModel);
- if (!d->m_startWithChildTrees && d->m_includeAllSelected)
- return QAbstractProxyModel::mapSelectionFromSource(selection);
+ if (!d->m_startWithChildTrees && d->m_includeAllSelected) {
+ // QAbstractProxyModel::mapSelectionFromSource puts invalid ranges in the result
+ // without checking. We can't have that.
+ QItemSelection proxySelection;
+ foreach(const QItemSelectionRange &range, selection)
+ {
+ QModelIndex proxyTopLeft = mapFromSource(range.topLeft());
+ if (!proxyTopLeft.isValid())
+ continue;
+ QModelIndex proxyBottomRight = mapFromSource(range.bottomRight());
+ Q_ASSERT(proxyBottomRight.isValid());
+ proxySelection.append(QItemSelectionRange(proxyTopLeft, proxyBottomRight));
+ }
+ return proxySelection;
+ }
QItemSelection proxySelection;
QItemSelection::const_iterator it = selection.constBegin();
@@ -2358,9 +2371,23 @@
if (selection.isEmpty())
return selection;
- if (!d->m_startWithChildTrees && d->m_includeAllSelected)
- return QAbstractProxyModel::mapSelectionToSource(selection);
+ if (!d->m_startWithChildTrees && d->m_includeAllSelected) {
+ // QAbstractProxyModel::mapSelectionFromSource puts invalid ranges in the result
+ // without checking. We can't have that.
+ QItemSelection sourceSelection;
+ foreach(const QItemSelectionRange &range, selection)
+ {
+ QModelIndex sourceTopLeft = mapToSource(range.topLeft());
+ Q_ASSERT(sourceTopLeft.isValid());
+ QModelIndex sourceBottomRight = mapToSource(range.bottomRight());
+ Q_ASSERT(sourceBottomRight.isValid());
+ sourceSelection.append(QItemSelectionRange(sourceTopLeft, sourceBottomRight));
+ }
+ return sourceSelection;
+ }
+
+
QItemSelection sourceSelection;
QItemSelection extraSelection;
QItemSelection::const_iterator it = selection.constBegin();
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic