summaryrefslogtreecommitdiffstats
path: root/src/gui/itemviews
diff options
context:
space:
mode:
authorStephen Kelly <stephen.kelly@kdab.com>2012-04-17 17:47:37 (GMT)
committerQt by Nokia <qt-info@nokia.com>2012-04-26 16:11:07 (GMT)
commit96f0449f6e7b9c3f35fb7c546b6bbdb633d1a7bc (patch)
tree5d38d6ab7c59b334443414434e1897aad75a1a36 /src/gui/itemviews
parentc507e783c931b74a3f200fa824fa9e9fee78ba9f (diff)
downloadQt-96f0449f6e7b9c3f35fb7c546b6bbdb633d1a7bc.zip
Qt-96f0449f6e7b9c3f35fb7c546b6bbdb633d1a7bc.tar.gz
Qt-96f0449f6e7b9c3f35fb7c546b6bbdb633d1a7bc.tar.bz2
Take account of spanned items in QTreeView when dragging.
Also remove some code which has been unused since it was introduced in 32182d107fa75e5619ecc91a81f50626f429ebe1 Task-number: QTBUG-25140 Change-Id: I27f9496c2c998de7ea858b943c2f19d979ef18c2 Reviewed-by: David Faure <faure@kde.org>
Diffstat (limited to 'src/gui/itemviews')
-rw-r--r--src/gui/itemviews/qtreeview.cpp41
1 files changed, 9 insertions, 32 deletions
diff --git a/src/gui/itemviews/qtreeview.cpp b/src/gui/itemviews/qtreeview.cpp
index 4006601..1a8a686 100644
--- a/src/gui/itemviews/qtreeview.cpp
+++ b/src/gui/itemviews/qtreeview.cpp
@@ -1343,39 +1343,16 @@ void QTreeViewPrivate::_q_modelDestroyed()
QItemViewPaintPairs QTreeViewPrivate::draggablePaintPairs(const QModelIndexList &indexes, QRect *r) const
{
Q_ASSERT(r);
- return QAbstractItemViewPrivate::draggablePaintPairs(indexes, r);
Q_Q(const QTreeView);
- QRect &rect = *r;
- const QRect viewportRect = viewport->rect();
- int itemOffset = 0;
- int row = firstVisibleItem(&itemOffset);
- QPair<int, int> startEnd = startAndEndColumns(viewportRect);
- QVector<int> columns;
- for (int i = startEnd.first; i <= startEnd.second; ++i) {
- int logical = header->logicalIndex(i);
- if (!header->isSectionHidden(logical))
- columns += logical;
- }
- QSet<QModelIndex> visibleIndexes;
- for (; itemOffset < viewportRect.bottom() && row < viewItems.count(); ++row) {
- const QModelIndex &index = viewItems.at(row).index;
- for (int colIndex = 0; colIndex < columns.count(); ++colIndex)
- visibleIndexes += index.sibling(index.row(), columns.at(colIndex));
- itemOffset += itemHeight(row);
- }
-
- //now that we have the visible indexes, we can try to find those which are selected
- QItemViewPaintPairs ret;
- for (int i = 0; i < indexes.count(); ++i) {
- const QModelIndex &index = indexes.at(i);
- if (visibleIndexes.contains(index)) {
- const QRect current = q->visualRect(index);
- ret += qMakePair(current, index);
- rect |= current;
- }
- }
- rect &= viewportRect;
- return ret;
+ if (spanningIndexes.isEmpty())
+ return QAbstractItemViewPrivate::draggablePaintPairs(indexes, r);
+ QModelIndexList list;
+ foreach (const QModelIndex &idx, indexes) {
+ if (idx.column() > 0 && q->isFirstColumnSpanned(idx.row(), idx.parent()))
+ continue;
+ list << idx;
+ }
+ return QAbstractItemViewPrivate::draggablePaintPairs(list, r);
}
void QTreeViewPrivate::adjustViewOptionsForIndex(QStyleOptionViewItemV4 *option, const QModelIndex &current) const