Bug 111873 - Modifying and then navigating in the thumbbar does not update photo thumbnail
Summary: Modifying and then navigating in the thumbbar does not update photo thumbnail
Status: RESOLVED FIXED
Alias: None
Product: digikam
Classification: Applications
Component: Showfoto-Thumbs (show other bugs)
Version: unspecified
Platform: Compiled Sources Linux
: NOR normal
Target Milestone: ---
Assignee: Digikam Developers
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2005-09-01 12:15 UTC by Tung NGUYEN
Modified: 2022-02-05 04:57 UTC (History)
1 user (show)

See Also:
Latest Commit:
Version Fixed In: 7.6.0


Attachments
Photo 003.jpg (730.39 KB, image/jpeg)
2005-09-01 18:09 UTC, Tung NGUYEN
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Tung NGUYEN 2005-09-01 12:15:09 UTC
Version:           0.3.0-cvs (packaged with Digikam 0.8.0-beta1) (using KDE KDE 3.4.2)
Installed from:    Compiled From Sources
OS:                Linux

For exemple:

- Run "showfoto Photo-01.jpg Photo-02.jpg".
- Apply the menu: Filters->Black & White on Photo-01.jpg.
- Click on Photo-02.jpg in the thumbbar and click on "Save" to confirm.

=> Photo-01.jpg thumbnail is not updated in the thumbbar.

----------------------------------------------------
I have another little display problem in the thumbbar:

For exemple:

- Run "showfoto Photo-01.jpg Photo-02.jpg".
- Apply the menu: Filters->Black & White on Photo-01.jpg.
- Click on Photo-02.jpg in the thumbbar and click on "Cancel".

=> Photo-02.jpg thumbnail is selected but it's Photo-01.jpg which is displayed in ShowFoto.
Comment 1 caulier.gilles 2005-09-01 13:26:52 UTC
SVN commit 455796 by cgilles:

re-select preview item in thumbar if cancel is selected when prompt user save.
CCBUG: 111873

 M  +5 -0      showfoto.cpp  


--- trunk/extragear/graphics/digikam/showfoto/showfoto.cpp #455795:455796
@@ -863,7 +863,12 @@
 void ShowFoto::slotOpenURL(const KURL& url)
 {
     if(!promptUserSave())
+    {
+        m_bar->blockSignals(true);
+        m_bar->setSelected(m_currentItem);
+        m_bar->blockSignals(false);
         return;
+    }
 
     m_currentItem = m_bar->currentItem();
     if(!m_currentItem)
Comment 2 caulier.gilles 2005-09-01 13:28:33 UTC
#1 This bug cannot be reproduce with all images here. Sometime it running, sometimes no.

#2 Fixed in svn. Please try again.

Gilles
Comment 3 Tung NGUYEN 2005-09-01 17:55:51 UTC
Gilles, 

I would like to give you an example, I hope it can help you.

-----
>"#1 This bug cannot be reproduce with all images here. Sometime it running, sometimes no."

  Yes and generally the correct thumbnails are displayed after restarting ShowFoto. But I have another problem which seems to be in connection with the thumbnail stocked in the photo.

I hope you can reproduce the same behavior with the attached "Photo 003.jpg" (original photo).

1) - Run ShowFoto "Photo 003.jpg".
   - Apply the menu: Filters->Black & White on "Photo 003.jpg". 
   - Save and quit ShowFoto.
   - Restart ShowFoto which displays now a B&W photo with a color thumbnail !

   - Now, access to "Photo 003.jpg" in Konqueror in icon view and you can see a color thumbnail too (instead of B&W thumbnail).
   - Display "Photo 003.jpg" with the embedded viewer and you can see a Black & White photo.

   - In Konqueror settings, uncheck the option "Apercus et Méta-informations->Utiliser les miniatures qui sont intégrées dans les fichiers".
   - delete the folder ~/thumbnails.
   - Now, access to "Photo 003.jpg" and you can see a Black & White thumbnail (which corresponds to the real Black & White photo).

2) I have the same problem with the Image Editor:

   - Import "Photo 003.jpg" in DigiKam.
   - Open "Photo 003.jpg" with the Image Editor, apply filters B&W, save and quit.
   - OK, the thumbnail in DigiKam is B&W but I have the same issue as ShowFoto.

3) Now, I resize the original "Photo 003.jpg" to 640x480 (with resize batch kipiplugin) and apply filter B&W =>all the problems disappear (thumbnails are correct in ShowFoto and Konqueror).
Comment 4 Tung NGUYEN 2005-09-01 18:09:04 UTC
Created attachment 12447 [details]
Photo 003.jpg

Original photo
Comment 5 caulier.gilles 2005-09-02 21:38:38 UTC
SVN commit 456411 by cgilles:

Don't using KFilePreview thumbnails cache to display properly the image modifications on showfoto thumbbar. Please, give me a feedback...

Nota: using KIO:KfilePreview isn't the better way to render thumbnails. This method don't work properly with any 
TIFF and PNG files generated with imlib2 (especially for example with hight PNG compression level). 
Perhaps the better way is to use the digikamthumbnails kioslave when it's available (for example in a both
installation of showfoto and digikam in the same computer).

CCBUG: 111873



 M  +4 -4      thumbbar.cpp  


--- trunk/extragear/graphics/digikam/libs/thumbbar/thumbbar.cpp #456410:456411
@@ -198,8 +198,8 @@
         delete item->m_pixmap;
         item->m_pixmap = 0;
     }
-    KIO::PreviewJob* job = KIO::filePreview(item->url(),
-                                            d->tileSize);
+    KIO::PreviewJob* job = KIO::filePreview(item->url(), d->tileSize, 0, 0, 70, true, false);
+    
     connect(job, SIGNAL(gotPreview(const KFileItem *, const QPixmap &)),
             SLOT(slotGotPreview(const KFileItem *, const QPixmap &)));
     connect(job, SIGNAL(failed(const KFileItem *)),
@@ -374,8 +374,8 @@
     
     if (!urlList.isEmpty())
     {
-        KIO::PreviewJob* job = KIO::filePreview(urlList,
-                                                d->tileSize);
+        KIO::PreviewJob* job = KIO::filePreview(urlList, d->tileSize, 0, 0, 70, true, false);
+        
         connect(job, SIGNAL(gotPreview(const KFileItem *, const QPixmap &)),
                 SLOT(slotGotPreview(const KFileItem *, const QPixmap &)));
         connect(job, SIGNAL(failed(const KFileItem *)),
Comment 6 Tung NGUYEN 2005-09-03 20:54:49 UTC
Gilles,

I have tested your lastest changes in SVN, here is a summary of what works and what does not work:

- I have checked the option Konqueror->Settings->"Apercus et Méta-informations->Utiliser les miniatures qui sont intégrées dans les fichiers" (default setting).

- All the previous thumbnails update problems remains valid.

- Then I have unchecked the option and delete ~/thumbnails.

- It seems that the situation is better: in Showfoto, when I modify a photo and save it, the thumbnail is updated immediately in the thumbbar. And in Konqueror, the right thumbnail is displayed too.

=> Actually, I use this second setting and all my photos work fine in ShowFoto and Konqueror, in spite of that the problem of this bug report "Modifying and then navigating in the thumbbar does not update photo thumbnail" remain always valid.
Comment 7 caulier.gilles 2005-09-05 10:44:16 UTC
SVN commit 457252 by cgilles:

Use digikamthumbnail protocol with showfoto thumbar when its available, for exemple in a both digikam/showfoto installation. This way :
- always update properly thumbnails after image save/saveas.
- improve thumnails computation speed, especially with PNG and JPEG files.
- digikamthumbnail protocol will render properly PNG, TIFF, and JPEG files preview in all case (KIO::filePreview can't do it).

If showfoto is installed without digikam (digikamthumbnail protocol unavialable), showfoto thumbar use KIO::filePreview protocol instead to rendering thumbnails.

CCBUG: 111873

 M  +1 -1      digikam/Makefile.am  
 D             digikam/thumbnailjob.cpp  
 D             digikam/thumbnailjob.h  
 M  +1 -1      libs/thumbbar/Makefile.am  
 M  +60 -7     libs/thumbbar/thumbbar.cpp  
 M  +2 -0      libs/thumbbar/thumbbar.h  
 A             libs/thumbbar/thumbnailjob.cpp   [License: GPL]
 A             libs/thumbbar/thumbnailjob.h   [License: GPL]
 M  +7 -7      showfoto/Makefile.am  


--- trunk/extragear/graphics/digikam/digikam/Makefile.am #457251:457252
@@ -22,7 +22,7 @@
 
 libdigikam_la_SOURCES = albummanager.cpp album.cpp \
 			albumitemhandler.cpp albumdb.cpp albumdb_sqlite2.cpp \
-			albumlister.cpp thumbnailjob.cpp dragobjects.cpp \
+			albumlister.cpp dragobjects.cpp \
 			iconview.cpp icongroupitem.cpp iconitem.cpp \
 			digikamapp.cpp digikamview.cpp \
 		        albumfolderview.cpp \
--- trunk/extragear/graphics/digikam/libs/thumbbar/Makefile.am #457251:457252
@@ -2,7 +2,7 @@
 
 noinst_LTLIBRARIES = libthumbbar.la
 
-libthumbbar_la_SOURCES = thumbbar.cpp 
+libthumbbar_la_SOURCES = thumbbar.cpp thumbnailjob.cpp
 
 libthumbbar_la_LDFLAGS = $(all_libraries) $(KDE_RPATH)
 
--- trunk/extragear/graphics/digikam/libs/thumbbar/thumbbar.cpp #457251:457252
@@ -25,6 +25,7 @@
 #include <qdict.h>
 #include <qpoint.h>
 #include <qdatetime.h>
+#include <qguardedptr.h>
 
 #include <kfileitem.h>
 #include <kapplication.h>
@@ -38,6 +39,7 @@
 #include <cmath>
 
 #include "thumbbar.h"
+#include "thumbnailjob.h"
 
 namespace Digikam
 {
@@ -67,6 +69,8 @@
     
     QTimer*          timer;
     ThumbBarToolTip* tip;
+    
+    QGuardedPtr<ThumbnailJob> thumbJob;
 };
 
 ThumbBarView::ThumbBarView(QWidget* parent)
@@ -93,8 +97,11 @@
 
 ThumbBarView::~ThumbBarView()
 {
+    if (!d->thumbJob.isNull())
+        d->thumbJob->kill();
+    
     clear(false);
-
+        
     delete d->timer;
     delete d->tip;
     delete d;
@@ -198,12 +205,17 @@
         delete item->m_pixmap;
         item->m_pixmap = 0;
     }
-    KIO::PreviewJob* job = KIO::filePreview(item->url(), d->tileSize, 0, 0, 70, true, false);
     
-    connect(job, SIGNAL(gotPreview(const KFileItem *, const QPixmap &)),
-            SLOT(slotGotPreview(const KFileItem *, const QPixmap &)));
-    connect(job, SIGNAL(failed(const KFileItem *)),
-            SLOT(slotFailedPreview(const KFileItem *)));
+    if (!d->thumbJob.isNull())
+       d->thumbJob->kill();
+       
+    d->thumbJob = new ThumbnailJob(item->url(), d->tileSize, true);
+    
+    connect(d->thumbJob, SIGNAL(signalThumbnail(const KURL&, const QPixmap&)),
+            this, SLOT(slotGotThumbnail(const KURL&, const QPixmap&)));
+   
+    connect(d->thumbJob, SIGNAL(signalFailed(const KURL&)),
+            this, SLOT(slotFailedThumbnail(const KURL&)));     
 }
 
 void ThumbBarView::viewportPaintEvent(QPaintEvent* e)
@@ -374,12 +386,24 @@
     
     if (!urlList.isEmpty())
     {
+        if (!d->thumbJob.isNull())
+           d->thumbJob->kill();
+
+        d->thumbJob = new ThumbnailJob(urlList, d->tileSize, true);
+        
+        connect(d->thumbJob, SIGNAL(signalThumbnail(const KURL&, const QPixmap&)),
+                this, SLOT(slotGotThumbnail(const KURL&, const QPixmap&)));
+    
+        connect(d->thumbJob, SIGNAL(signalFailed(const KURL&)),
+                this, SLOT(slotFailedThumbnail(const KURL&)));     
+        
+/*        
         KIO::PreviewJob* job = KIO::filePreview(urlList, d->tileSize, 0, 0, 70, true, false);
         
         connect(job, SIGNAL(gotPreview(const KFileItem *, const QPixmap &)),
                 SLOT(slotGotPreview(const KFileItem *, const QPixmap &)));
         connect(job, SIGNAL(failed(const KFileItem *)),
-                SLOT(slotFailedPreview(const KFileItem *)));
+                SLOT(slotFailedPreview(const KFileItem *)));*/
     }
 }
 
@@ -398,6 +422,35 @@
     viewport()->update();
 }
 
+void ThumbBarView::slotGotThumbnail(const KURL& url, const QPixmap& pix)
+{
+    if (!pix.isNull())
+    {
+        ThumbBarItem* item = d->itemDict.find(url.url());
+        if (!item)
+            return;
+    
+        if (item->m_pixmap)
+        {
+            delete item->m_pixmap;
+            item->m_pixmap = 0;
+        }
+        
+        item->m_pixmap = new QPixmap(pix);
+        item->repaint();
+    }
+}
+
+void ThumbBarView::slotFailedThumbnail(const KURL& url)
+{
+    KIO::PreviewJob* job = KIO::filePreview(url, d->tileSize, 0, 0, 70, true, false);
+    
+    connect(job, SIGNAL(gotPreview(const KFileItem *, const QPixmap &)),
+            SLOT(slotGotPreview(const KFileItem *, const QPixmap &)));
+    connect(job, SIGNAL(failed(const KFileItem *)),
+            SLOT(slotFailedPreview(const KFileItem *)));
+}
+
 void ThumbBarView::slotGotPreview(const KFileItem *fileItem,
                                   const QPixmap& pix)
 {
--- trunk/extragear/graphics/digikam/libs/thumbbar/thumbbar.h #457251:457252
@@ -86,6 +86,8 @@
     void slotUpdate();
     void slotGotPreview(const KFileItem *, const QPixmap &);
     void slotFailedPreview(const KFileItem *);
+    void slotGotThumbnail(const KURL& url, const QPixmap& pix);
+    void slotFailedThumbnail(const KURL& url);
     
 private:
 
--- trunk/extragear/graphics/digikam/showfoto/Makefile.am #457251:457252
@@ -13,16 +13,16 @@
 		   imageproperties.cpp imagepropertiesgeneral.cpp \
 		   imagepropertiesexif.cpp imagepropertieshistogram.cpp 
 
-showfoto_LDADD   = $(LIB_QT) $(LIB_KDECORE) $(LIB_KDEUI) \
+showfoto_LDADD   = $(LIB_QT) $(LIB_KDECORE) $(LIB_KDEUI) $(LIB_KUTILS) \
 		   $(LIB_KFILE) $(LIB_KPARTS) $(LIBJPEG) \
+		   $(top_builddir)/digikam/libs/histogram/libhistogram.la \
+		   $(top_builddir)/digikam/libs/widgets/libwidgets.la \
+		   $(top_builddir)/digikam/libs/thumbbar/libthumbbar.la \
+		   $(top_builddir)/digikam/libs/curves/libcurves.la \
+		   $(top_builddir)/digikam/utilities/imageeditor/libimageeditor.la \
 		   $(top_builddir)/digikam/utilities/imageeditor/libimagecanvas.la \
 		   $(top_builddir)/digikam/utilities/imageeditor/libshowfoto.la \
-		   $(top_builddir)/digikam/libs/histogram/libhistogram.la \
-		   $(top_builddir)/digikam/libs/widgets/libwidgets.la \
-		   $(top_builddir)/digikam/utilities/splashscreen/libsplashscreen.la \
-           $(top_builddir)/digikam/libs/thumbbar/libthumbbar.la \
-           $(top_builddir)/digikam/utilities/imageeditor/libimageeditor.la \
-           $(top_builddir)/digikam/libs/curves/libcurves.la
+		   $(top_builddir)/digikam/utilities/splashscreen/libsplashscreen.la                    
 
 showfoto_LDFLAGS = $(KDE_RPATH) $(all_libraries)
 
Comment 8 Tung NGUYEN 2005-09-06 23:21:44 UTC
Gilles, 
 
 I have tested your lastest changes in SVN commit 457252 and almost everything works fine now.

Only a little problem remains after my tests (perhaps it's just a thumbnail selection problem):

- Run "showfoto Photo1.jpg Photo2.jpg".
- Modify Photo1 with the filter Black&White (for exemple).
- Click on Photo2 thumbnail and then click on "Save" to confirm the save of Photo1.
- You can see that the thumbnail of Photo1 is not updated immediately.
- Now, modify Photo2 with the filter Black&White (for exemple).
- Click on Photo1 thumbnail and then click on "Save" to confirm the save of Photo2.

=> you can see that the thumbnail of Photo1 is now updated correctly to Black&White.

---
Promised ! after that I will not annoy you any more... :o)
Comment 9 caulier.gilles 2005-09-07 09:31:05 UTC
SVN commit 458078 by cgilles:

showfoto BugFix : 

- Refresh the right item to save/saveas properly in showfoto thumbbar. Using a new method in thumbbar.cpp to find item by url.
- Don't prompt user about to save image after to do SaveAs operation.
CCBUG: 111873     

 M  +16 -0     libs/thumbbar/thumbbar.cpp  
 M  +1 -0      libs/thumbbar/thumbbar.h  
 M  +9 -16     showfoto/showfoto.cpp  


--- trunk/extragear/graphics/digikam/libs/thumbbar/thumbbar.cpp #458077:458078
@@ -170,8 +170,24 @@
     return 0;
 }
 
+ThumbBarItem* ThumbBarView::findItemByURL(const KURL& url) const
+{
+    for (ThumbBarItem *item = d->firstItem; item; item = item->m_next)
+    {
+        if (item->url().equals(url))
+        {
+            return item;
+        }
+    }
+
+    return 0;
+}
+
 void ThumbBarView::setSelected(ThumbBarItem* item)
 {
+    if (!item)
+        return;
+        
     if (d->currItem == item)
         return;
 
--- trunk/extragear/graphics/digikam/libs/thumbbar/thumbbar.h #458077:458078
@@ -62,6 +62,7 @@
     ThumbBarItem* firstItem() const;
     ThumbBarItem* lastItem()  const;
     ThumbBarItem* findItem(const QPoint& pos) const;
+    ThumbBarItem* findItemByURL(const KURL& url) const;
 
     void invalidateThumb(ThumbBarItem* item);
         
--- trunk/extragear/graphics/digikam/showfoto/showfoto.cpp #458077:458078
@@ -764,25 +764,19 @@
         ::unlink(QFile::encodeName(tmpFile));
         return;
     }
+    
+    m_saveAction->setEnabled(false);
 
     // add the file to the list of images if it's not there already
-    Digikam::ThumbBarItem* foundItem = 0;
-    for (Digikam::ThumbBarItem *item = m_bar->firstItem(); item; item = item->next())
+    Digikam::ThumbBarItem* item = m_bar->findItemByURL(saveAsURL);
+    m_bar->invalidateThumb(item);
+    
+    if (!item)
     {
-        if (item->url().equals(saveAsURL))
-        {
-            foundItem = item;
-            m_bar->invalidateThumb(item);
-            break;
-        }
+        item = new Digikam::ThumbBarItem(m_bar, saveAsURL);
     }
 
-    if (!foundItem)
-    {
-        foundItem = new Digikam::ThumbBarItem(m_bar, saveAsURL);
-    }
-
-    m_bar->setSelected(foundItem);
+    m_bar->setSelected(item);
     kapp->restoreOverrideCursor();
 }
 
@@ -871,8 +865,7 @@
     }
 
     m_canvas->setModified( false );
-    slotOpenURL(m_currentItem->url());
-    m_bar->invalidateThumb(m_currentItem);
+    m_bar->invalidateThumb(m_bar->findItemByURL(url));
     kapp->restoreOverrideCursor();
 
     return true;
Comment 10 caulier.gilles 2005-09-08 09:32:42 UTC
Give me any feedback to close this file if all is ok now...

Gilles Caulier
Comment 11 Tung NGUYEN 2005-09-08 18:17:45 UTC
Gilles, 
   
 - With your lastest changes in SVN, thumbnails refresh works fine now in ShowFoto.

 - >>"Don't prompt user about to save image after to do SaveAs operation" => But, I always have the message "The image Photo-1 has been modified. Do you want to save it?"
Comment 12 caulier.gilles 2005-09-08 20:51:02 UTC
>>"Don't prompt user about to save image after to do SaveAs operation" => But, I always have the message...

==> in showfoto or image editor (or both) ?

Gilles
Comment 13 Tung NGUYEN 2005-09-08 21:05:07 UTC
>>"==> in showfoto or image editor (or both) ?"

Only in ShowFoto.
Comment 14 caulier.gilles 2005-09-09 07:50:54 UTC
ok, will fix it

Gilles
Comment 15 caulier.gilles 2005-09-09 09:28:31 UTC
SVN commit 458880 by cgilles:

showfoto BugFix : Forget to commit this patch to don't prompt user about to save image after to do SaveAs operation.
CCBUG: 111873     

 M  +6 -13     showfoto.cpp  


--- trunk/extragear/graphics/digikam/showfoto/showfoto.cpp #458879:458880
@@ -758,23 +758,15 @@
         return;
     }
 
+    m_canvas->setModified( false );
+    
     // add the file to the list of images if it's not there already
-    Digikam::ThumbBarItem* foundItem = 0;
-    for (Digikam::ThumbBarItem *item = m_bar->firstItem(); item; item = item->next())
-    {
-        if (item->url().equals(saveAsURL))
-        {
-            foundItem = item;
-            m_bar->invalidateThumb(item);
-            break;
-        }
-    }
+    Digikam::ThumbBarItem* foundItem = m_bar->findItemByURL(saveAsURL);
+    m_bar->invalidateThumb(foundItem);
 
     if (!foundItem)
-    {
         foundItem = new Digikam::ThumbBarItem(m_bar, saveAsURL);
-    }
-
+    
     m_bar->setSelected(foundItem);
     kapp->restoreOverrideCursor();
 }
@@ -828,6 +820,7 @@
     
     QString tmpFile = url.directory() + QString("/.showfoto-tmp-")
                       + url.filename();
+    
     if (!m_canvas->saveAsTmpFile(tmpFile, m_JPEGCompression, m_PNGCompression,
                                  m_TIFFCompression))
     {
Comment 16 caulier.gilles 2005-09-09 09:35:07 UTC
Done on svn. Please give me feedback...

Gilles
Comment 17 Tung NGUYEN 2005-09-09 11:22:04 UTC
Gilles, 
 
 I have tested it : now, ShowFoto "Don't prompt user about to save image after to do SaveAs operation". 

 I think you can close the bug report. 
 Thank you very much.
 
 
Comment 18 caulier.gilles 2005-09-09 11:45:10 UTC
De nada (:=)))

Thanks you for your very constructive bug reports !!!

Gilles