summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorDavid Faure <faure@kde.org>2011-11-29 19:55:26 (GMT)
committerGabriel de Dietrich <gabriel.dietrich-de@nokia.com>2011-11-30 14:01:56 (GMT)
commitfd25323de7b5d5f3e0ffb1bd81ea4d251e071566 (patch)
tree6d318b2e72b617c7f126263af522849bd99b1ab1 /src
parent53d854eb3ba095f2e13a35f4d7eb01670d9874b4 (diff)
downloadQt-fd25323de7b5d5f3e0ffb1bd81ea4d251e071566.zip
Qt-fd25323de7b5d5f3e0ffb1bd81ea4d251e071566.tar.gz
Qt-fd25323de7b5d5f3e0ffb1bd81ea4d251e071566.tar.bz2
QTreeView: fix crash when starting a drag with hidden columns.
Crash was introduced by d639105759491 (Qt-4.8 only) Amended to remove "unused variable" warning. Task-number: QTBUG-15834 Merge-request: MR-2725 Reviewed-by: Gabriel
Diffstat (limited to 'src')
-rw-r--r--src/gui/itemviews/qtreeview.cpp16
1 files changed, 12 insertions, 4 deletions
diff --git a/src/gui/itemviews/qtreeview.cpp b/src/gui/itemviews/qtreeview.cpp
index 868cd92..b678801 100644
--- a/src/gui/itemviews/qtreeview.cpp
+++ b/src/gui/itemviews/qtreeview.cpp
@@ -1388,11 +1388,19 @@ void QTreeViewPrivate::adjustViewOptionsForIndex(QStyleOptionViewItemV4 *option,
option->showDecorationSelected = (selectionBehavior & QTreeView::SelectRows)
|| option->showDecorationSelected;
- QVector<int> logicalIndices;
- QVector<QStyleOptionViewItemV4::ViewItemPosition> viewItemPosList; // vector of left/middle/end for each logicalIndex
+ QVector<int> logicalIndices; // index = visual index of visible columns only. data = logical index.
+ QVector<QStyleOptionViewItemV4::ViewItemPosition> viewItemPosList; // vector of left/middle/end for each logicalIndex, visible columns only.
calcLogicalIndices(&logicalIndices, &viewItemPosList);
- int logicalIndex = header->logicalIndex(current.column());
- option->viewItemPosition = viewItemPosList.at(logicalIndex);
+
+ int columnIndex = 0;
+ for (int visualIndex = 0; visualIndex < current.column(); ++visualIndex) {
+ int logicalIndex = header->logicalIndex(visualIndex);
+ if (!header->isSectionHidden(logicalIndex)) {
+ ++columnIndex;
+ }
+ }
+
+ option->viewItemPosition = viewItemPosList.at(columnIndex);
}