Bug 113801

Summary: Little problem with image files extensions
Product: [Applications] digikam Reporter: Tung NGUYEN <ntung>
Component: DImg-FileIOAssignee: Digikam Developers <digikam-bugs-null>
Status: RESOLVED FIXED    
Severity: normal CC: caulier.gilles
Priority: NOR    
Version: 0.8.0   
Target Milestone: ---   
Platform: Compiled Sources   
OS: Linux   
Latest Commit: Version Fixed In: 0.9.0
Sentry Crash Report:

Description Tung NGUYEN 2005-10-03 21:51:34 UTC
Version:           0.8.0-beta2 (using KDE KDE 3.4.2)
Installed from:    Compiled From Sources
OS:                Linux

Currently, when a Photo1.jpg is renamed to Photo1.xyz, the extension *.xyz is added to the option "Settings->Configure digiKam->Mime Type->Show only image files with extensions" in order to display Photo1.xyz in the album.

But, there is another way to change the extension of an image file: during the import of an existing photo, and if Photo1.jpg is renamed to Photo1.xyz in the "File Already Exists" dialog box then the extension *.xyz is not added to the option and Photo1.xyz will be never displayed in the album.
Comment 1 Marshalleq 2005-12-27 01:42:47 UTC
I have a similar problem.  That is, (using .80) while adjusting redeye in an image I saved it as a new name and then found it was no longer available.  Normally I am savvy enough to pick up such a small difficulty but for some reason it did not appear obvious, we are obviously aiming for this to be 'the' image app, so why not make it really simple for anyone and make it so you cannot change the extension without actually clicking on it such as many of the other os apps are becoming.
Comment 2 Mikolaj Machowski 2005-12-27 15:40:35 UTC
> it really simple for anyone and make it so you cannot change the
> extension without actually clicking on it such as many of the other os
> apps are becoming. _______________________________________________


Related to bug 117375
Comment 3 caulier.gilles 2006-07-27 09:22:24 UTC
SVN commit 566834 by cgilles:

digikam from trunk : do not include file name extension during file renaming operation from users.

Note : with the old implementation, when the the filename extension is changed by user, we will check if this one is in the mimetype setup. if no, it's added, bu _always_ like an image mimetype !!! Imaging if you put a sound or a video mimetype in the image mimetype list : image editor will trying to open it... 

The mimetype registration with renaming is now removed. 

BUG: 117375
CCBUGS: 113801

 M  +19 -30    albumiconview.cpp  
 M  +28 -30    albumiconview.h  


--- trunk/extragear/graphics/digikam/digikam/albumiconview.cpp #566833:566834
@@ -1,8 +1,8 @@
 /* ============================================================
  * Authors: Renchi Raju <renchi@pooh.tam.uiuc.edu>
  *          Caulier Gilles <caulier dot gilles at kdemail dot net>
- * Date  : 2002-16-10
- * Description : 
+ * Date   : 2002-16-10
+ * Description : album icon view 
  * 
  * Copyright 2002-2005 by Renchi Raju and Gilles Caulier
  * Copyright      2006 by Gilles Caulier
@@ -254,7 +254,6 @@
 
     connect(watch, SIGNAL(signalImageCaptionChanged(Q_LLONG)),
             this, SLOT(slotImageAttributesChanged(Q_LLONG)));
-
 }
 
 AlbumIconView::~AlbumIconView()
@@ -744,8 +743,9 @@
             KURLDrag::decode(data, srcURLs);
 
             KIO::Job* job = DIO::copy(srcURLs, destURL);
+
             connect(job, SIGNAL(result(KIO::Job*)),
-                    SLOT(slotDIOResult(KIO::Job*)));
+                    this, SLOT(slotDIOResult(KIO::Job*)));
         }
     }
 }
@@ -781,20 +781,21 @@
     if (!item)
         return;
 
-    QString oldName = item->imageInfo()->name();
+    QFileInfo fi(item->imageInfo()->name());
+    QString ext  = QString(".") + fi.extension();
+    QString name = fi.fileName();
+    name.truncate(fi.fileName().length() - ext.length());
 
     bool ok;
 
 #if KDE_IS_VERSION(3,2,0)
-    QString newName = KInputDialog::getText(i18n("Rename Item"),
-                                            i18n("Enter new name:"),
-                                            oldName,
-                                            &ok, this);
+    QString newName = KInputDialog::getText(i18n("Rename Item (%1)").arg(fi.fileName()), 
+                                            i18n("Enter new name (without extension):"),
+                                            name, &ok, this);
 #else
-    QString newName = KLineEditDlg::getText(i18n("Rename Item"),
-                                            i18n("Enter new name:"),
-                                            oldName,
-                                            &ok, this);
+    QString newName = KLineEditDlg::getText(i18n("Rename Item (%1)").arg(fi.fileName()), 
+                                            i18n("Enter new name (without extension):"),
+                                            name, &ok, this);
 #endif
 
     if (!ok)
@@ -802,26 +803,13 @@
 
     QString oldURL = item->imageInfo()->kurl().url();
 
-    if (!item->imageInfo()->setName(newName))
+    if (!item->imageInfo()->setName(newName + ext))
         return;
 
     d->itemDict.remove(oldURL);
     d->itemDict.insert(item->imageInfo()->kurl().url(), item);
 
     item->repaint();
-
-    // if user has inadvertently renamed a file to one with an extension
-    // not in the current list of extensions, add it to the list of
-    // extension
-
-    QFileInfo fi(newName);
-    QString newExt("*." + fi.extension());
-    AlbumSettings* settings = AlbumSettings::instance();
-    if (settings->addImageFileExtension(newExt))
-    {
-        d->imageLister->setNameFilter(settings->getAllFileFilter());
-    }
-
     signalItemsAdded();
 }
 
@@ -871,8 +859,9 @@
     }
 
     KIO::Job* job = DIO::del(urlList);
+
     connect(job, SIGNAL(result(KIO::Job*)),
-            SLOT(slotDIOResult(KIO::Job*)));
+            this, SLOT(slotDIOResult(KIO::Job*)));
 }
 
 void AlbumIconView::slotFilesModified()
@@ -1118,14 +1107,14 @@
             {
                 KIO::Job* job = DIO::move(srcURLs, destURL);
                 connect(job, SIGNAL(result(KIO::Job*)),
-                        SLOT(slotDIOResult(KIO::Job*)));
+                        this, SLOT(slotDIOResult(KIO::Job*)));
                 break;
             }
             case 11: 
             {
                 KIO::Job* job = DIO::copy(srcURLs, destURL);
                 connect(job, SIGNAL(result(KIO::Job*)),
-                        SLOT(slotDIOResult(KIO::Job*)));
+                        this, SLOT(slotDIOResult(KIO::Job*)));
                 break;
             }
             default:
--- trunk/extragear/graphics/digikam/digikam/albumiconview.h #566833:566834
@@ -1,8 +1,8 @@
 /* ============================================================
  * Authors: Renchi Raju <renchi@pooh.tam.uiuc.edu>
  *          Caulier Gilles <caulier dot gilles at kdemail dot net>
- * Date  : 2002-16-10
- * Description : 
+ * Date   : 2002-16-10
+ * Description : album icon view 
  * 
  * Copyright 2002-2005 by Renchi Raju and Gilles Caulier
  * Copyright      2006 by Gilles Caulier
@@ -34,13 +34,11 @@
 #include "imageinfo.h"
 #include "albumitemhandler.h"
 
-class QMouseEvent;
 class QResizeEvent;
 class QDragMoveEvent;
 class QDropEvent;
 class QPoint;
 class QString;
-class QPainter;
 class QPixmap;
 
 namespace KIO
@@ -53,10 +51,10 @@
 
 class AlbumIconItem;
 class AlbumSettings;
-class AlbumIconViewPrivate;
 class ThumbnailSize;
 class Album;
 class PixmapManager;
+class AlbumIconViewPrivate;
 
 class AlbumIconView : public IconView,
                       public AlbumItemHandler
@@ -112,7 +110,32 @@
     AlbumIconItem* findItem(const QString& url) const;
     AlbumIconItem* nextItemToThumbnail() const;
     PixmapManager* pixmapManager() const;
+   
+signals:
+
+    void signalItemsAdded();
+    void signalItemDeleted(AlbumIconItem* iconItem);
+    void signalCleared();
+
+public slots:
+
+    void slotSetExifOrientation(int orientation);
+    void slotRename(AlbumIconItem* item);
+    void slotDeleteSelectedItems();
+    void slotDisplayItem(AlbumIconItem *item=0);
+    void slotAlbumModified();
+    void slotSetAlbumThumbnail(AlbumIconItem *iconItem);
+    void slotCopy();
+    void slotPaste();
     
+    void slotAssignRating(int rating);
+    void slotAssignRatingNoStar();
+    void slotAssignRatingOneStar();
+    void slotAssignRatingTwoStar();
+    void slotAssignRatingThreeStar();
+    void slotAssignRatingFourStar();
+    void slotAssignRatingFiveStar();
+
 protected:
 
     void resizeEvent(QResizeEvent* e);
@@ -152,31 +175,6 @@
     void slotImageAttributesChanged(Q_LLONG imageId);
     void slotAlbumImagesChanged(int albumId);
 
-public slots:
-
-    void slotSetExifOrientation(int orientation);
-    void slotRename(AlbumIconItem* item);
-    void slotDeleteSelectedItems();
-    void slotDisplayItem(AlbumIconItem *item=0);
-    void slotAlbumModified();
-    void slotSetAlbumThumbnail(AlbumIconItem *iconItem);
-    void slotCopy();
-    void slotPaste();
-    
-    void slotAssignRating(int rating);
-    void slotAssignRatingNoStar();
-    void slotAssignRatingOneStar();
-    void slotAssignRatingTwoStar();
-    void slotAssignRatingThreeStar();
-    void slotAssignRatingFourStar();
-    void slotAssignRatingFiveStar();
-    
-signals:
-
-    void signalItemsAdded();
-    void signalItemDeleted(AlbumIconItem* iconItem);
-    void signalCleared();
-
 private:
     
     void updateBannerRectPixmap();
Comment 4 caulier.gilles 2006-12-12 08:25:34 UTC
This file have been fixed in 0.9.0. I close it.

Gilles