[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kfm-devel
Subject:    Re: [PATCH] Please review, fixes #20194.
From:       Ravi <ravi () kde ! org>
Date:       2004-05-06 19:03:31
Message-ID: 200405061503.31149.ravi () kde ! org
[Download RAW message or body]

Hi Matt,
  I think the patch is right. The only other thing I would do is to add a 
comment indicating why the blockSignals() call is necessary. I know it has 
been around for a while, but a single line comment usually helps whenever you 
use that function.
  I am cc-ing kde-core-devel as that is the right list for this.

Regards,
Ravi

On Thursday 06 May 2004 01:34 pm, Matt Newell wrote:
> This is a patch to kiconview that fixes bug #20194 (shift-clicking causes
> currentItem to change, so further shift-clicks don't extend/reduce the
> selection) and eliminates flicker when shift-clicking.  Should apply to
> current kdelibs cvs.  I will commit it if someone says it looks ok.

["kdelibs_iconview.diff" (text/x-diff)]

? kdelibs_iconview.diff
? konq_select_kdelibs.diff
? kabc/plugins/imap/Makefile
? kabc/plugins/imap/Makefile.in
? kdewidgets/makekdewidgets
? khtml/ecma/xmlhttprequest.lut.h
? kutils/libkutils_la.all_cpp.loT
? pics/crystalsvg/cr128-mime-mime_ascii.png
Index: kdeui/kiconview.cpp
===================================================================
RCS file: /home/kde/kdelibs/kdeui/kiconview.cpp,v
retrieving revision 1.72
diff -u -3 -p -u -r1.72 kiconview.cpp
--- kdeui/kiconview.cpp	14 Apr 2004 15:12:05 -0000	1.72
+++ kdeui/kiconview.cpp	6 May 2004 17:22:55 -0000
@@ -298,12 +298,39 @@ void KIconView::leaveEvent( QEvent *e )
 void KIconView::contentsMousePressEvent( QMouseEvent *e )
 {
   if( (selectionMode() == Extended) && (e->state() & ShiftButton) && !(e->state() & \
                ControlButton) ) {
-    bool block = signalsBlocked();
-    blockSignals( true );
-
-    clearSelection();
-
-    blockSignals( block );
+    // Since QIconView will change currentItem and it won't
+    // clear the selection of the items that aren't in the
+    // selection rect(current item to clicked item), we will
+    // do all of the work here to avoid flickering.
+    
+    // Make sure we have an item and currentItem
+    QIconViewItem *item = findItem( e->pos() );
+    QIconViewItem *cur = currentItem();
+    if( item && cur ){
+        // Get a proper rect for them - This should be the same as qlistview
+        bool cxs = cur->x() < item->x();
+        bool cys = cur->y() < item->y();
+        QRect r( cxs ? cur->x() : item->x(),
+                   cys ? cur->y() : item->y(),
+                   cxs ? (item->x() - cur->x() + item->width()) : (cur->x() - \
item->x() + cur->width()), +                   cys ? (item->y() - cur->y() + \
item->height()) : (cur->y() - item->y() + cur->height()) ); +        r = \
r.normalize(); +        // Block signals and updates
+        bool block = signalsBlocked();
+        blockSignals( true );
+        bool needSelectionChanged = false;
+        for(QIconViewItem * item = firstItem(); item; item = item->nextItem() ){
+            bool select = r.intersects( item->rect() );
+            if( select != item->isSelected() ){
+                needSelectionChanged = true;
+                item->setSelected( select, true );
+            }
+        }
+        blockSignals( block );
+        if( needSelectionChanged )
+            emit selectionChanged();
+        return;
+    }
   }
 
   QIconView::contentsMousePressEvent( e );



[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic