summaryrefslogtreecommitdiffstats
path: root/src/iconview
diff options
context:
space:
mode:
authorEnrico Ros <eros.kde@email.it>2014-09-16 03:37:06 +0200
committerSlávek Banko <slavek.banko@axis.cz>2015-12-15 19:54:02 +0100
commit217873db13ca3a74fc24224969a3dc421bb33f28 (patch)
tree5132a717d853bfe6a2a70cda127f99262204b04a /src/iconview
parentfd6922e60b548c4beddc29acedab72563148382b (diff)
downloadqt3-217873db13ca3a74fc24224969a3dc421bb33f28.tar.gz
qt3-217873db13ca3a74fc24224969a3dc421bb33f28.zip
Fix unwanted toggling TQIconViewItem focus on click
This fixes the 'flashing' icon when clicking repeatedly on a TQIconView 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. (cherry picked from commit fbc4cf8e7f2170744c12fd0d435639516c733db9)
Diffstat (limited to 'src/iconview')
-rw-r--r--src/iconview/qiconview.cpp43
1 files changed, 26 insertions, 17 deletions
diff --git a/src/iconview/qiconview.cpp b/src/iconview/qiconview.cpp
index e5ae298..0a1f8df 100644
--- a/src/iconview/qiconview.cpp
+++ b/src/iconview/qiconview.cpp
@@ -240,6 +240,7 @@ public:
QPoint dragStartPos;
QFontMetrics *fm;
int minLeftBearing, minRightBearing;
+ int rubberStartX, rubberStartY;
uint mousePressed :1;
uint cleared :1;
@@ -259,6 +260,7 @@ public:
uint firstSizeHint : 1;
uint showTips :1;
uint pressedSelected :1;
+ uint canStartRubber :1;
uint dragging :1;
uint drawActiveSelection :1;
uint inMenuMode :1;
@@ -2796,6 +2798,7 @@ QIconView::QIconView( QWidget *parent, const char *name, WFlags f )
d->currentItem = 0;
d->highlightedItem = 0;
d->rubber = 0;
+ d->canStartRubber = FALSE;
d->backBuffer = 0;
d->scrollTimer = 0;
d->startDragItem = 0;
@@ -4637,29 +4640,19 @@ void QIconView::contentsMousePressEventEx( QMouseEvent *e )
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 );
- if ( d->rubber )
- delete d->rubber;
- d->rubber = 0;
- d->rubber = new QRect( e->x(), e->y(), 0, 0 );
- d->selectedItems.clear();
- if ( ( e->state() & ControlButton ) == ControlButton ) {
- 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;
}
emit_signals:
- if ( !d->rubber ) {
+ if ( !d->canStartRubber ) {
emit mouseButtonPressed( e->button(), item, e->globalPos() );
emit pressed( item );
emit pressed( item, e->globalPos() );
@@ -4703,6 +4696,7 @@ void QIconView::contentsMouseReleaseEvent( QMouseEvent *e )
d->mousePressed = FALSE;
d->startDragItem = 0;
+ d->canStartRubber = FALSE;
if ( d->rubber ) {
QRect r(d->rubber->normalize());
@@ -4788,7 +4782,22 @@ void QIconView::contentsMouseMoveEvent( QMouseEvent *e )
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();
}
}