Bug 50902 - icon rows' top margins not updated until all previews are generated
Summary: icon rows' top margins not updated until all previews are generated
Status: RESOLVED FIXED
Alias: None
Product: konqueror
Classification: Applications
Component: general (show other bugs)
Version: unspecified
Platform: Compiled Sources Linux
: VHI critical
Target Milestone: ---
Assignee: Konqueror Developers
URL:
Keywords:
: 51276 62396 (view as bug list)
Depends on:
Blocks:
 
Reported: 2002-11-18 13:27 UTC by Morten Hustveit
Modified: 2003-09-24 19:11 UTC (History)
4 users (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Morten Hustveit 2002-11-18 13:27:09 UTC
Version:            (using KDE Devel)
Installed from:    Compiled sources

While previews are being generated, the top margin of the icons isn't increased as neccesary until all the previews are generated.  This is what it looks like when the preview generation is in progress: <URI: http://kde.ping.uio.no/preview.png >.  Expected behaviour is that whenever an icong with a greater height than the current maximum on its row is added, the height is increased.  The bug is most easily noticed in directories with lots of PostScript and HTML files.
Comment 1 George Staikos 2003-03-07 08:08:30 UTC
This is a critical bug.  It renders the icon view useless, really. 
Comment 2 John Firebaugh 2003-07-28 02:18:40 UTC
*** Bug 51276 has been marked as a duplicate of this bug. ***
Comment 3 Kai Lahmann 2003-08-08 22:39:49 UTC
*** Bug 62396 has been marked as a duplicate of this bug. ***
Comment 4 Ricardo Ferreira 2003-08-15 19:39:22 UTC
This has been the case for as long as i can remember. 
I didnt report it because i assume it was a well known thing. 
Comment 5 Luís Pedro Coelho 2003-08-16 22:20:11 UTC
Subject: Re: [PATCH for bug:50902] icon rows' top margins not updated until all previews are generated

> Ok to commit?

I just committed a fix to HEAD (following a two day timeout on kfm-devel).

I attach a manual applying of the patch, since it didn't apply automatically.

This one I will _not_ apply without an explicit OK, since I do not run BRANCH 
(not enough disk for two kde trees, sorry).

It does seem to work in a mixed environment (kdebase/libkonq from branch, 
everything else from head), but I am wary of breaking anything.

so, ok to commit?
Index: konq_iconviewwidget.cc
===================================================================
RCS file: /home/kde/kdebase/libkonq/konq_iconviewwidget.cc,v
retrieving revision 1.219.2.13
diff -u -3 -p -r1.219.2.13 konq_iconviewwidget.cc
--- konq_iconviewwidget.cc	27 Jun 2003 15:26:03 -0000	1.219.2.13
+++ konq_iconviewwidget.cc	16 Aug 2003 20:10:57 -0000
@@ -319,7 +319,6 @@ struct KonqIconViewWidgetPrivate
         pSoundTimer = 0;
         pPreviewJob = 0;
         bAllowSetWallpaper = false;
-        updateAfterPreview = false;
 	gridXspacing = 50;
 
         doAnimations = true;
@@ -342,9 +341,10 @@ struct KonqIconViewWidgetPrivate
     bool bSoundPreviews;
     bool bSoundItemClicked;
     bool bAllowSetWallpaper;
-    bool updateAfterPreview;
     int gridXspacing;
 
+    QTimer* rearrangeIconsTimer;
+
     // Animated icons support
     bool doAnimations;
     QMovie* m_movie;
@@ -363,6 +363,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> & ) ) );
 
@@ -375,6 +376,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 );
@@ -646,21 +649,23 @@ void KonqIconViewWidget::slotPreview(con
     // ### 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)
+        if (static_cast<KFileIVI *>(it)->item() == item) {
+            bool needsUpdate = ( static_cast<KFileIVI*>( it )->width() < pix.width() ) || ( static_cast<KFileIVI*>( it )->height() < pix.height() );
             static_cast<KFileIVI *>(it)->setThumbnailPixmap(pix);
-        {
-    }
-            d->updateAfterPreview = true;
+            if ( autoArrange() && !d->rearrangeIconsTimer->isActive() ) { 
+                if ( needsUpdate ) d->rearrangeIconsTimer->start( 500, true );
+            }
         }
+    }
 }
 
 void KonqIconViewWidget::slotPreviewResult()
 {
     d->pPreviewJob = 0;
     emit imagePreviewFinished();
-    if (autoArrange() && d->updateAfterPreview ) {
+    if (d->rearrangeIconsTimer->isActive() ){
+        d->rearrangeIconsTimer->stop();
         arrangeItemsInGrid();
-        d->updateAfterPreview = false;
     }
 }
 
@@ -1021,6 +1026,13 @@ void KonqIconViewWidget::slotDropped( QD
 {
     // Drop on background
     KonqOperations::doDrop( m_rootItem /* may be 0L */, url(), ev, this );
+}
+
+
+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.93
diff -u -3 -p -r1.93 konq_iconviewwidget.h
--- konq_iconviewwidget.h	3 Nov 2002 23:46:21 -0000	1.93
+++ konq_iconviewwidget.h	16 Aug 2003 20:10:57 -0000
@@ -251,6 +251,9 @@ protected slots:
     void slotMovieStatus( int status );
     void slotReenableAnimation();
 
+private slots:
+	void slotRearrangeIcons();
+
 protected:
     virtual QDragObject *dragObject();
     KonqIconDrag *konqDragObject( QWidget * dragSource = 0L );
Comment 6 Ricardo Ferreira 2003-08-17 17:41:09 UTC
Luis, i'm running HEAD and that patch doesnt always fix it. 
Sometimes it appears to lack some redraws. Going to another tab & then back 
usually fixes it. Sometimes it doesnt update even when all thumbs are done. 
The tab trick appears to always fix it. 
Comment 7 Luís Pedro Coelho 2003-09-06 20:42:48 UTC
Subject: kdebase/libkonq

CVS commit by luis_pedro: 

Fix a small logic error.
According to R. Ferreira, this fixes the problems he reported against my previous commit.

CCMAIL: 50902@bugs.kde.org


  M +1 -1      konq_iconviewwidget.cc   1.258


--- kdebase/libkonq/konq_iconviewwidget.cc  #1.257:1.258
@@ -674,5 +674,5 @@ void KonqIconViewWidget::slotPreview(con
         if (current->item() == item)
         {
-            bool needsUpdate = ( current->width() < pix.width() || current->height() < pix.height() );
+            bool needsUpdate = ( !current->pixmap() || current->pixmap()->width() < pix.width() || current->pixmap()->height() < pix.height() );
             if(item->overlays() & KIcon::HiddenOverlay)
             {


Comment 8 Luís Pedro Coelho 2003-09-24 19:11:44 UTC
As seen above, this is fixed in HEAD. 
 
No one stepped forward to backport this (I do not run branch and will not blindly 
backport) and there probably will not be another BRANCH release 
Also, we are moving fast towards 3.2 
 
Therefore, I am closing it as FIXED.