From kfm-devel Thu Aug 14 16:29:11 2003 From: Luis Pedro Coelho Date: Thu, 14 Aug 2003 16:29:11 +0000 To: kfm-devel Subject: [PATCH for bug:50902] icon rows' top margins not updated until all X-MARC-Message: https://marc.info/?l=kfm-devel&m=106087877523536 MIME-Version: 1 Content-Type: multipart/mixed; boundary="--Boundary-00=_Xj7O/yVScm4kMKQ" --Boundary-00=_Xj7O/yVScm4kMKQ Content-Type: Text/Plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Content-Disposition: inline =2D----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Hello, [ relevant link: http://bugs.kde.org/show_bug.cgi?id=3D50902 ] Below is a patch for bug 50902. It rearranges the icons whenever it is need= ed,=20 but it doees so with a small delay (ie, no more than two rearrangement per= =20 second) so as not to have too much flicker. It seems to work ok (not really optimal: but a balance must be struck: too= =20 fast updates and it flickers, too slow and it is, well, too slow) in both=20 fast thumbnail (from cache) and slow (large images not cached). Ok to commit? =2D --=20 Luis Pedro Coelho On user interfaces and languages, see: http://luispedro.journalspace.com/ =2D----BEGIN PGP SIGNATURE----- Version: GnuPG v1.0.7 (GNU/Linux) iD8DBQE/O7jbGpBAvyRwXdgRAmMLAJ49qn4POah8rAlgrBul9dWrbWMGyQCgycVo 58xQcaHj8WyeK1pcFMA6VM8=3D =3DYqLF =2D----END PGP SIGNATURE----- --Boundary-00=_Xj7O/yVScm4kMKQ Content-Type: text/x-diff; charset="us-ascii"; name="kmail-attach.MCTuCm" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="kmail-attach.MCTuCm" ? 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 & ) ), this, SLOT( slotDropped( QDropEvent*, const QValueList & ) ) ); @@ -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(it)->item() == item) + KFileIVI* current = static_cast(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(it)->setThumbnailPixmap(p); + current->setThumbnailPixmap(p); + } else { + current->setThumbnailPixmap(pix); + } + if ( needsUpdate + && autoArrange() + && !d->rearrangeIconsTimer->isActive() ) { + d->rearrangeIconsTimer->start( 500, true ); } - else - static_cast(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 &files); +private slots: + void slotRearrangeIcons(); + protected: virtual QDragObject *dragObject(); KonqIconDrag *konqDragObject( QWidget * dragSource = 0L ); --Boundary-00=_Xj7O/yVScm4kMKQ--