summaryrefslogtreecommitdiffstats
path: root/libs/qt-x11-free/files/0049-qiconview-rubber_on_move.diff
blob: 0dfcf93504295083997f201671ef4c51ba6b6e3b (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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
qt-bugs@ issue : none 
applied: no
author: Enrico Ros <eros.kde@email.it>

Unwanted toggling QIconViewItem focus on click.

This fixes the 'flashing' icon when clicking repeatedly on a QIconView or
derivates (ie TDEIconView, KonqIconViewWidget, the KDesktop and so on..).
The current behavior considers that if not over an icon, the user is
clicking down to perform icons selection (with the rubberband).
This is not always true, since a click might be used to give focus to a 
window or unselect some icons.

How this is fixed: when clicking down the mouse a flag is set. If the pointer
is moved on the iconview with the button held down, then (and only at that
moment) the rubber is created. Now a selection operation (the one done with
the rubber) begins when moving the mouse and not only when clicking on the
empty space.

--- work/qt-x11-free-3.3.8/src.orig/iconview/qiconview.cpp	2004-05-05 18:55:55.471057880 +0000
+++ work/qt-x11-free-3.3.8/src/iconview/qiconview.cpp	2004-05-30 18:24:16.311014024 +0000
@@ -236,6 +236,7 @@
     QPoint dragStartPos;
     QFontMetrics *fm;
     int minLeftBearing, minRightBearing;
+    int rubberStartX, rubberStartY;
 
     uint mousePressed		:1;
     uint cleared		:1;
@@ -255,6 +256,7 @@
     uint firstSizeHint : 1;
     uint showTips		:1;
     uint pressedSelected	:1;
+    uint canStartRubber		:1;
     uint dragging		:1;
     uint drawActiveSelection	:1;
     uint inMenuMode		:1;
@@ -2733,6 +2735,7 @@
     d->currentItem = 0;
     d->highlightedItem = 0;
     d->rubber = 0;
+    d->canStartRubber = FALSE;
     d->scrollTimer = 0;
     d->startDragItem = 0;
     d->tmpCurrentItem = 0;
@@ -4501,29 +4504,20 @@
 
     setCurrentItem( item );
 
+    d->canStartRubber = FALSE;
     if ( e->button() == LeftButton ) {
-	if ( !item && ( d->selectionMode == Multi ||
-				  d->selectionMode == Extended ) ) {
-	    d->tmpCurrentItem = d->currentItem;
-	    d->currentItem = 0;
-	    repaintItem( d->tmpCurrentItem );
-	    delete d->rubber;
-	    d->rubber = new QRect( e->x(), e->y(), 0, 0 );
-	    d->selectedItems.clear();
-	    if ( ( e->state() & ControlButton ) == ControlButton ||
-	         ( e->state() & ShiftButton ) == ShiftButton ) {
-		for ( QIconViewItem *i = firstItem(); i; i = i->nextItem() )
-		    if ( i->isSelected() )
-			d->selectedItems.insert( i, i );
-	    }
+	if ( !item && ( d->selectionMode == Multi || d->selectionMode == Extended ) )
+	{
+	    d->canStartRubber = TRUE;
+	    d->rubberStartX = e->x();
+	    d->rubberStartY = e->y();
 	}
-
 	d->mousePressed = TRUE;
 	d->controlPressed = ( ( e->state() & ControlButton ) == ControlButton );
     }
 
  emit_signals:
-    if ( !d->rubber ) {
+    if ( !d->canStartRubber ) {
 	emit mouseButtonPressed( e->button(), item, e->globalPos() );
 	emit pressed( item );
 	emit pressed( item, e->globalPos() );
@@ -4567,6 +4561,7 @@
     d->mousePressed = FALSE;
     d->startDragItem = 0;
 
+    d->canStartRubber = FALSE;
     if ( d->rubber ) {
 	QPainter p;
 	p.begin( viewport() );
@@ -4656,7 +4651,22 @@
 	    if ( d->tmpCurrentItem )
 		repaintItem( d->tmpCurrentItem );
 	}
-    } else if ( d->mousePressed && !d->currentItem && d->rubber ) {
+    } else if ( d->mousePressed && ((!d->currentItem && d->rubber) || d->canStartRubber) ) {
+	if ( d->canStartRubber ) {
+	    d->canStartRubber = FALSE;
+	    d->tmpCurrentItem = d->currentItem;
+	    d->currentItem = 0;
+	    repaintItem( d->tmpCurrentItem );
+	    delete d->rubber;
+	    d->rubber = new QRect( d->rubberStartX, d->rubberStartY, 0, 0 );
+	    d->selectedItems.clear();
+	    if ( ( e->state() & ControlButton ) == ControlButton ||
+	         ( e->state() & ShiftButton ) == ShiftButton ) {
+		for ( QIconViewItem *i = firstItem(); i; i = i->nextItem() )
+		    if ( i->isSelected() )
+			d->selectedItems.insert( i, i );
+	    }
+	}
 	doAutoScroll();
     }
 }