aboutsummaryrefslogtreecommitdiff
path: root/x11-toolkits/qt33/files/0017-qiconview-ctrl_rubber.patch
blob: 02611de85f137becd5760b0c5db3b017b696789b (plain) (blame)
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
qt-bugs@ issue : 23919
applied: no
author: Pascal Létourneau <pletourn@globetrotter.net>

This patch modifies the behavior of the rubber selection.
Now Shift-rubber behaves like the old Ctrl-rubber.
And now Ctrl-rubber toggles the state of the icons.
This is more consistant with other iconview (Nautilus, Win Explorer, ...)
and with Qt itself (Ctrl-click toggle the state of an icon).

Index: src/iconview/qiconview.cpp
===================================================================
RCS file: /home/kde/qt-copy/src/iconview/qiconview.cpp,v
retrieving revision 1.48
diff -u -3 -p -r1.48 qiconview.cpp
--- src/iconview/qiconview.cpp	23 Jun 2003 11:48:21 -0000	1.48
+++ src/iconview/qiconview.cpp	1 Jul 2003 16:36:17 -0000
@@ -257,7 +257,8 @@ public:
     uint dragging		:1;
     uint drawActiveSelection	:1;
     uint inMenuMode		:1;
-
+    uint controlPressed         :1;
+
     QIconViewToolTip *toolTip;
     QPixmapCache maskCache;
     QPtrDict<QIconViewItem> selectedItems;
@@ -2726,6 +2727,7 @@ QIconView::QIconView( QWidget *parent, c
     d->lastItem = 0;
     d->count = 0;
     d->mousePressed = FALSE;
+    d->controlPressed = FALSE;
     d->selectionMode = Single;
     d->currentItem = 0;
     d->highlightedItem = 0;
@@ -3288,9 +3290,18 @@ void QIconView::doAutoScroll()
 	    alreadyIntersected = TRUE;
 	    QIconViewItem *item = c->items.first();
 	    for ( ; item; item = c->items.next() ) {
-		if ( d->selectedItems.find( item ) )
-		    continue;
-		if ( !item->intersects( nr ) ) {
+               if ( d->selectedItems.find( item ) ) {
+                   if ( item->intersects( nr ) && item->isSelected() && d->controlPressed ) {
+                       item->setSelected( FALSE );
+                       changed = TRUE;
+                       rr = rr.unite( item->rect() );
+                   } else if ( !item->intersects( nr ) && !item->isSelected() && d->controlPressed ) {
+                       item->setSelected( TRUE, TRUE );
+                       changed = TRUE;
+                       rr = rr.unite( item->rect() );
+                   } else
+                       continue;
+               } else if ( !item->intersects( nr ) ) {
 		    if ( item->isSelected() ) {
 			item->setSelected( FALSE );
 			changed = TRUE;
@@ -4480,7 +4491,7 @@ void QIconView::contentsMousePressEventE
 	    }
 	}
     } else if ( ( d->selectionMode != Single || e->button() == RightButton )
-		&& !( e->state() & ControlButton ) )
+		&& !( e->state() & ControlButton ) && !( e->state() & ShiftButton ) )
 	selectAll( FALSE );
 
     setCurrentItem( item );
@@ -4491,12 +4502,11 @@ void QIconView::contentsMousePressEventE
 	    d->tmpCurrentItem = d->currentItem;
 	    d->currentItem = 0;
 	    repaintItem( d->tmpCurrentItem );
-	    if ( d->rubber )
-		delete d->rubber;
-	    d->rubber = 0;
+	    delete d->rubber;
 	    d->rubber = new QRect( e->x(), e->y(), 0, 0 );
 	    d->selectedItems.clear();
-	    if ( ( e->state() & ControlButton ) == ControlButton ) {
+	    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 );
@@ -4504,6 +4514,7 @@ void QIconView::contentsMousePressEventE
 	}
 
 	d->mousePressed = TRUE;
+	d->controlPressed = ( ( e->state() & ControlButton ) == ControlButton );
     }
 
  emit_signals: