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

List:       kfm-devel
Subject:    [PATCH for bug:50902] icon rows' top margins not updated until all
From:       Luis Pedro Coelho <luis_pedro () netcabo ! pt>
Date:       2003-08-14 16:29:11
[Download RAW message or body]

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hello,

[ relevant link: http://bugs.kde.org/show_bug.cgi?id=50902 ]

Below is a patch for bug 50902. It rearranges the icons whenever it is needed, 
but it doees so with a small delay (ie, no more than two rearrangement per 
second) so as not to have too much flicker.

It seems to work ok (not really optimal: but a balance must be struck: too 
fast updates and it flickers, too slow and it is, well, too slow) in both 
fast thumbnail (from cache) and slow (large images not cached).

Ok to commit?
- -- 
Luis Pedro Coelho

On user interfaces and languages, see:
http://luispedro.journalspace.com/

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.7 (GNU/Linux)

iD8DBQE/O7jbGpBAvyRwXdgRAmMLAJ49qn4POah8rAlgrBul9dWrbWMGyQCgycVo
58xQcaHj8WyeK1pcFMA6VM8=
=YqLF
-----END PGP SIGNATURE-----

["kmail-attach.MCTuCm" (text/x-diff)]

? patch.always
? patch.final
? patch.with-5
Index: konq_iconviewwidget.cc
===================================================================
RCS file: /home/kde/kdebase/libkonq/konq_iconviewwidget.cc,v
retrieving revision 1.249
diff -u -3 -p -r1.249 konq_iconviewwidget.cc
--- konq_iconviewwidget.cc	6 Aug 2003 21:46:54 -0000	1.249
+++ konq_iconviewwidget.cc	14 Aug 2003 16:25:34 -0000
@@ -327,7 +327,6 @@ struct KonqIconViewWidgetPrivate
         pSoundPlayer = 0;
         pSoundTimer = 0;
         pPreviewJob = 0;
-        updateAfterPreview = false;
         bAllowSetWallpaper = false;
 	gridXspacing = 50;
 
@@ -350,9 +349,10 @@ struct KonqIconViewWidgetPrivate
     QTimer *pSoundTimer;
     bool bSoundPreviews;
     bool bSoundItemClicked;
-    bool updateAfterPreview;
     bool bAllowSetWallpaper;
     int gridXspacing;
+    
+    QTimer* rearrangeIconsTimer;
 
     // Animated icons support
     bool doAnimations;
@@ -373,6 +373,7 @@ KonqIconViewWidget::KonqIconViewWidget( 
       m_bSetGridX( !kdesktop ) /* No line breaking on the desktop */
 {
     d = new KonqIconViewWidgetPrivate;
+    d->rearrangeIconsTimer = new QTimer( this );
     connect( this, SIGNAL( dropped( QDropEvent *, const QValueList<QIconDragItem> & \
                ) ),
              this, SLOT( slotDropped( QDropEvent*, const QValueList<QIconDragItem> & \
) ) );  
@@ -385,6 +386,8 @@ KonqIconViewWidget::KonqIconViewWidget( 
     connect( this, SIGNAL(onViewport()), SLOT(slotOnViewport()) );
     connect( this, SIGNAL(itemRenamed(QIconViewItem *, const QString &)), \
SLOT(slotItemRenamed(QIconViewItem *, const QString &)) );  
+    connect( d->rearrangeIconsTimer, SIGNAL( timeout() ), SLOT( slotRearrangeIcons() \
) ); +
     // hardcoded settings
     setSelectionMode( QIconView::Extended );
     setItemTextPos( QIconView::Bottom );
@@ -656,23 +659,30 @@ void KonqIconViewWidget::slotStartSoundP
   d->pSoundPlayer->play(d->pSoundItem->item()->url().url());
 }
 
+
 void KonqIconViewWidget::slotPreview(const KFileItem *item, const QPixmap &pix)
 {
     // ### slow. Idea: move KonqKfmIconView's m_itemDict into this class
     for (QIconViewItem *it = firstItem(); it; it = it->nextItem())
     {
-        if (static_cast<KFileIVI *>(it)->item() == item)
+        KFileIVI* current = static_cast<KFileIVI *>(it);
+        if (current->item() == item)
         {
+            bool needsUpdate = ( current->width() < pix.width() || current->height() \
< pix.height() );  if(item->overlays() & KIcon::HiddenOverlay)
             {
                 QPixmap p(pix);
 
                 KIconEffect::semiTransparent(p);
-                static_cast<KFileIVI *>(it)->setThumbnailPixmap(p);
+                current->setThumbnailPixmap(p);
+            } else {
+                current->setThumbnailPixmap(pix);
+            }
+            if ( needsUpdate 
+                    && autoArrange() 
+                    && !d->rearrangeIconsTimer->isActive() ) {
+                d->rearrangeIconsTimer->start( 500, true );
             }
-            else
-                static_cast<KFileIVI *>(it)->setThumbnailPixmap(pix);
-            d->updateAfterPreview = true;
         }
     }
 }
@@ -680,9 +690,9 @@ void KonqIconViewWidget::slotPreview(con
 void KonqIconViewWidget::slotPreviewResult()
 {
     d->pPreviewJob = 0;
-    if (autoArrange() && d->updateAfterPreview ) {
-        arrangeItemsInGrid();
-        d->updateAfterPreview = false;
+    if ( d->rearrangeIconsTimer->isActive() ) { 
+        d->rearrangeIconsTimer->stop();
+        slotRearrangeIcons();
     }
     emit imagePreviewFinished();
 }
@@ -1056,6 +1066,13 @@ void KonqIconViewWidget::slotAboutToCrea
 {
    // Do nothing :-)
 }
+
+void KonqIconViewWidget::slotRearrangeIcons()
+{
+    // We cannot actually call arrangeItemsInGrid directly as a slot because it has \
a default parameter. +  arrangeItemsInGrid();
+}
+
 
 void KonqIconViewWidget::drawBackground( QPainter *p, const QRect &r )
 {
Index: konq_iconviewwidget.h
===================================================================
RCS file: /home/kde/kdebase/libkonq/konq_iconviewwidget.h,v
retrieving revision 1.98
diff -u -3 -p -r1.98 konq_iconviewwidget.h
--- konq_iconviewwidget.h	2 Jul 2003 12:37:08 -0000	1.98
+++ konq_iconviewwidget.h	14 Aug 2003 16:25:34 -0000
@@ -253,6 +253,9 @@ protected slots:
 
     void slotAboutToCreate(const QPoint &pos, const QValueList<KIO::CopyInfo> \
&files);  
+private slots:
+    void slotRearrangeIcons();
+
 protected:
     virtual QDragObject *dragObject();
     KonqIconDrag *konqDragObject( QWidget * dragSource = 0L );



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

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