summaryrefslogtreecommitdiff
path: root/libraries/qt4/patches/0255-qtreeview-selection-columns-hidden.diff
blob: 08677af633f125e7b2177fbf78c03724a098c2ab (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
qt-bugs@ issue : N232819
Trolltech task ID : 232831
applied: no
author: Rafael Fernández López <ereslibre@kde.org>

In a treeview with columns like this:

Column 1 | Column 2 | ... | Column k | ... | Column n

When selecting with rubberband (by clicking on the blank part of the viewport) while Column k is
hidden, you get double items on the selection model, when asking for selection(). This is becase
ranges are incorrectly calculated when there are hidden columns. A way to reproduce:

Column 1 | Column 2 | Column 4 (Column 3 is hidden)
 item
 item
 item
  x <- press button here and move it up to select items (on this same column)

If you do like this:

Column 1 | Column 2 | Column 4 (Column 3 is hidden)
 item
 item
 item
                         x <- press button here and move it up

you won't be able to reproduce, since you need the hidden column to be between the one you click and
the last one. The reason is that columnRanges returns two ranges when there is supposed to return 1
range (even when there are hidden columns).

diff --git a/src/gui/itemviews/qtreeview.cpp b/src/gui/itemviews/qtreeview.cpp
index d5ca633..b7975be 100644
--- src/gui/itemviews/qtreeview.cpp
+++ src/gui/itemviews/qtreeview.cpp
@@ -3494,7 +3494,7 @@
     current.first = -2; // -1 is not enough because -1+1 = 0
     current.second = -2;
     foreach (int logicalColumn, logicalIndexes) {
-        if (current.second + 1 != logicalColumn) {
+        if (current.second + 1 != logicalColumn && !header->isSectionHidden(current.second + 1)) {
             if (current.first != -2) {
                 //let's save the current one
                 ret += current;