[Digikam-devel] extragear/graphics/digikam/digikam

Gilles Caulier caulier.gilles at kdemail.net
Wed Jan 31 21:13:30 CET 2007


SVN commit 628885 by cgilles:

digikam from trunk : connect batch Album Icon View actions to progress bar (on status bar of Album GUI). Actions are listed below :

- Assign Tags by drag and drop
- Assign Tags by pop-up menu
- Remove Tags by pop-up menu
- Assign Rating by Pop-up menu or Shortcuts.
- Fix Exif orientation tag.

Marcel, MetadataHub connection still todo in AlbumIconView. i have tagged source code with TODO annotations where MetadataHub must be used. Can you take a look ?

CCMAIL: digikam-devel at kde.org, marcel.wiesweg at gmx.de

 M  +94 -5     albumiconview.cpp  
 M  +3 -1      albumiconview.h  
 M  +6 -0      digikamview.cpp  
 M  +19 -3     iconview.cpp  
 M  +5 -2      iconview.h  


--- trunk/extragear/graphics/digikam/digikam/albumiconview.cpp #628884:628885
@@ -6,7 +6,7 @@
  * Description : album icon view 
  * 
  * Copyright 2002-2005 by Renchi Raju and Gilles Caulier
- * Copyright      2006 by Gilles Caulier and Marcel Wiesweg
+ * Copyright 2006-2007 by Gilles Caulier and Marcel Wiesweg
  *
  * This program is free software; you can redistribute it
  * and/or modify it under the terms of the GNU General
@@ -116,6 +116,7 @@
 #include "albumiconitem.h"
 #include "albumicongroupitem.h"
 #include "loadingcacheinterface.h"
+#include "statusprogressbar.h"
 #include "albumiconview.h"
 #include "albumiconview.moc"
 
@@ -1157,6 +1158,7 @@
     {
         QByteArray ba = event->encodedData("digikam/tag-id");
         QDataStream ds(ba, IO_ReadOnly);
+        int i = 0;
         int tagID;
         ds >> tagID;
 
@@ -1197,40 +1199,62 @@
             {
                 case 10:    // Selected and Dropped Items
                 {
+                    emit signalProgressBarMode(StatusProgressBar::ProgressBarMode, 
+                                               i18n("Assign tag to pictures. Please wait..."));
+                    
+                    float cnt = (float)countSelected();
                     for (IconItem *it = firstItem(); it; it = it->nextItem())
                     {
                         if (it->isSelected())
                         {
                             AlbumIconItem *albumItem = static_cast<AlbumIconItem *>(it);
                             albumItem->imageInfo()->setTag(tagID);
+                            // TODO: add MetadataHub call here.
+                            emit signalProgressValue((int)((i++/cnt)*100.0));
+                            kapp->processEvents();
                         }
                     }
 
                     AlbumIconItem *albumItem = findItem(event->pos());
                     if (albumItem)
+                    {
                         albumItem->imageInfo()->setTag(tagID);
+                        // TODO: add MetadataHub call here.
+                    }
     
                     d->imageLister->refresh();
                     updateContents();
+                    emit signalProgressBarMode(StatusProgressBar::TextMode, QString::null);
                     break;
                 }
                 case 11:    // All Items
                 {
+                    emit signalProgressBarMode(StatusProgressBar::ProgressBarMode, 
+                                               i18n("Assign tag to pictures. Please wait..."));
+
+                    float cnt = (float)count();
                     for (IconItem *it = firstItem(); it; it = it->nextItem())
                     {
                         AlbumIconItem *albumItem = static_cast<AlbumIconItem *>(it);
                         albumItem->imageInfo()->setTag(tagID);
+                        // TODO: add MetadataHub call here.
+                        emit signalProgressValue((int)((i++/cnt)*100.0));
+                        kapp->processEvents();
                     }
     
                     d->imageLister->refresh();
                     updateContents();
+                    emit signalProgressBarMode(StatusProgressBar::TextMode, QString::null);
                     break;
                 }
                 case 12:    // Dropped Item only.
                 {
                     AlbumIconItem *albumItem = findItem(event->pos());
                     if (albumItem)
+                    {
                         albumItem->imageInfo()->setTag(tagID);
+                        // TODO: add MetadataHub call here.
+                    }
 
                     d->imageLister->refresh();
                     updateContents();
@@ -1245,6 +1269,7 @@
     {
         QByteArray ba = event->encodedData("digikam/taglist");
         QDataStream ds(ba, IO_ReadOnly);
+        int i = 0;
         QValueList<int> tagIDs;
         ds >> tagIDs;
 
@@ -1277,6 +1302,10 @@
         {
             case 10:    // Selected and Dropped Items
             {
+                emit signalProgressBarMode(StatusProgressBar::ProgressBarMode, 
+                                            i18n("Assign tags to pictures. Please wait..."));
+
+                float cnt = (float)countSelected();
                 for (IconItem *it = firstItem(); it; it = it->nextItem())
                 {
                     if (it->isSelected())
@@ -1286,7 +1315,11 @@
                             it != tagIDs.end(); ++it)
                         {
                             albumItem->imageInfo()->setTag(*it);
+                            // TODO: add MetadataHub call here.
                         }
+
+                        emit signalProgressValue((int)((i++/cnt)*100.0));
+                        kapp->processEvents();
                     }
                 }
 
@@ -1297,15 +1330,21 @@
                         it != tagIDs.end(); ++it)
                     {
                         albumItem->imageInfo()->setTag(*it);
+                        // TODO: add MetadataHub call here.
                     }
                 }
-    
+
+                emit signalProgressBarMode(StatusProgressBar::TextMode, QString::null);    
                 d->imageLister->refresh();
                 updateContents();
                 break;
             }
             case 11:    // All Items
             {
+                emit signalProgressBarMode(StatusProgressBar::ProgressBarMode, 
+                                            i18n("Assign tags to pictures. Please wait..."));
+                
+                float cnt = (float)count();
                 for (IconItem *it = firstItem(); it; it = it->nextItem())
                 {
                     AlbumIconItem *albumItem = static_cast<AlbumIconItem*>(it);
@@ -1313,9 +1352,14 @@
                         it != tagIDs.end(); ++it)
                     {
                         albumItem->imageInfo()->setTag(*it);
+                        // TODO: add MetadataHub call here.
                     }
+
+                    emit signalProgressValue((int)((i++/cnt)*100.0));
+                    kapp->processEvents();
                 }
-    
+
+                emit signalProgressBarMode(StatusProgressBar::TextMode, QString::null);    
                 d->imageLister->refresh();
                 updateContents();
                 break;
@@ -1329,6 +1373,7 @@
                         it != tagIDs.end(); ++it)
                     {
                         albumItem->imageInfo()->setTag(*it);
+                        // TODO: add MetadataHub call here.
                     }
                 }
 
@@ -1471,6 +1516,7 @@
 void AlbumIconView::slotSetExifOrientation( int orientation )
 {
     KURL::List urlList;
+    int i = 0;
 
     for (IconItem *it = firstItem(); it; it=it->nextItem())
     {
@@ -1484,6 +1530,9 @@
     if (urlList.count() <= 0) return;
 
     KURL::List::Iterator it;
+    float cnt = (float)urlList.count();
+    emit signalProgressBarMode(StatusProgressBar::ProgressBarMode, 
+                                i18n("Fix Exif Orientation tag on pictures. Please wait..."));
 
     for( it = urlList.begin(); it != urlList.end(); ++it )
     {
@@ -1503,8 +1552,12 @@
         {
             ImageAttributesWatch::instance()->fileMetadataChanged((*it));
         }
+
+        emit signalProgressValue((int)((i++/cnt)*100.0));
+        kapp->processEvents();
     }
 
+    emit signalProgressBarMode(StatusProgressBar::TextMode, QString::null);    
     refreshItems(urlList);
 }
 
@@ -1827,6 +1880,12 @@
 
 void AlbumIconView::slotAssignTag(int tagID)
 {
+    emit signalProgressBarMode(StatusProgressBar::ProgressBarMode, 
+                                i18n("Assign tag to pictures. Please wait..."));
+
+    int   i   = 0;
+    float cnt = (float)countSelected();
+
     for (IconItem *it = firstItem(); it; it = it->nextItem())
     {
         if (it->isSelected())
@@ -1839,6 +1898,8 @@
 
             info->setTag(tagID);
 
+            // TODO: fix this part to use MetadataHub instead.
+
             // Store Image Tags like Iptc keywords tag.
         
             if (AlbumSettings::instance())
@@ -1855,14 +1916,24 @@
                     ImageAttributesWatch::instance()->fileMetadataChanged(info->kurl());
                 }
             }
+
+            emit signalProgressValue((int)((i++/cnt)*100.0));
+            kapp->processEvents();
         }
     }
 
+    emit signalProgressBarMode(StatusProgressBar::TextMode, QString::null);
     updateContents();
 }
 
 void AlbumIconView::slotRemoveTag(int tagID)
 {
+    emit signalProgressBarMode(StatusProgressBar::ProgressBarMode, 
+                                i18n("Remove tag from pictures. Please wait..."));
+
+    int   i   = 0;
+    float cnt = (float)countSelected();
+
     for (IconItem *it = firstItem(); it; it = it->nextItem())
     {
         if (it->isSelected())
@@ -1875,6 +1946,8 @@
 
             info->removeTag(tagID);
 
+            // TODO: fix this part to use MetadataHub instead.
+
             // Update Image Tags like Iptc keywords tags.
 
             if (AlbumSettings::instance())
@@ -1891,9 +1964,14 @@
                     ImageAttributesWatch::instance()->fileMetadataChanged(info->kurl());
                 }
             }
+
+            emit signalProgressValue((int)((i++/cnt)*100.0));
+            kapp->processEvents();
         }
     }
 
+    emit signalProgressBarMode(StatusProgressBar::TextMode, QString::null);
+
     if (d->currentAlbum && d->currentAlbum->type() == Album::TAG)
     {
         d->imageLister->refresh();
@@ -1903,16 +1981,23 @@
 
 void AlbumIconView::slotAssignRating(int rating)
 {
-    rating = QMIN(5, QMAX(0, rating));
+    emit signalProgressBarMode(StatusProgressBar::ProgressBarMode, 
+                                i18n("Assign rating to pictures. Please wait..."));
+
+    int   i   = 0;
+    float cnt = (float)countSelected();
+    rating    = QMIN(5, QMAX(0, rating));
     
     for (IconItem *it = firstItem() ; it ; it = it->nextItem())
     {
         if (it->isSelected())
         {
             AlbumIconItem *albumItem = static_cast<AlbumIconItem *>(it);
-            ImageInfo* info = albumItem->imageInfo();
+            ImageInfo* info          = albumItem->imageInfo();
             info->setRating(rating);
 
+            // TODO: fix this part to use MetadataHub instead.
+            
             // Store Image rating as Iptc tag.
         
             if (AlbumSettings::instance())
@@ -1925,9 +2010,13 @@
                     ImageAttributesWatch::instance()->fileMetadataChanged(info->kurl());
                 }
             }
+
+            emit signalProgressValue((int)((i++/cnt)*100.0));
+            kapp->processEvents();
         }
     }
 
+    emit signalProgressBarMode(StatusProgressBar::TextMode, QString::null);
     triggerUpdate();
 }
 
--- trunk/extragear/graphics/digikam/digikam/albumiconview.h #628884:628885
@@ -6,7 +6,7 @@
  * Description : album icon view 
  * 
  * Copyright 2002-2005 by Renchi Raju and Gilles Caulier
- * Copyright      2006 by Gilles Caulier and Marcel Wiesweg
+ * Copyright 2006-2007 by Gilles Caulier and Marcel Wiesweg
  *
  * This program is free software; you can redistribute it
  * and/or modify it under the terms of the GNU General
@@ -120,6 +120,8 @@
     void signalItemsAdded();
     void signalItemDeleted(AlbumIconItem*);
     void signalCleared();
+    void signalProgressBarMode(int, const QString&);
+    void signalProgressValue(int);
 
 public slots:
 
--- trunk/extragear/graphics/digikam/digikam/digikamview.cpp #628884:628885
@@ -247,6 +247,12 @@
     connect(d->folderView, SIGNAL(signalAlbumModified()),
             d->iconView, SLOT(slotAlbumModified()));
 
+    connect(d->iconView, SIGNAL(signalProgressBarMode(int, const QString&)),
+            d->parent, SLOT(slotProgressBarMode(int, const QString&)));
+
+    connect(d->iconView, SIGNAL(signalProgressValue(int)),
+            d->parent, SLOT(slotProgressValue(int)));
+
     // -- Sidebar Connections -------------------------------------
 
     connect(d->leftSideBar, SIGNAL(signalChangedTab(QWidget*)),
--- trunk/extragear/graphics/digikam/digikam/iconview.cpp #628884:628885
@@ -1,9 +1,11 @@
 /* ============================================================
- * Author: Renchi Raju <renchi at pooh.tam.uiuc.edu>
- * Date  : 2005-04-24
+ * Authors: Renchi Raju <renchi at pooh.tam.uiuc.edu>
+ *          Caulier Gilles <caulier dot gilles at kdemail dot net>
+ * Date   : 2005-04-24
  * Description : 
- * 
+ *
  * Copyright 2005 by Renchi Raju
+ * Copyright 2006-2007 by Gilles Caulier
  *
  * This program is free software; you can redistribute it
  * and/or modify it under the terms of the GNU General
@@ -235,6 +237,20 @@
     return c;
 }
 
+
+int IconView::countSelected() const
+{
+    int c = 0;
+    for (IconGroupItem* group = d->firstGroup; group; group = group->nextGroup())
+    {
+        for (IconItem *it = group->firstItem(); it; it = it->nextItem())
+            if (it->isSelected())
+                c++;
+    }
+
+    return c;
+}
+
 int IconView::groupCount() const
 {
     int c = 0;
--- trunk/extragear/graphics/digikam/digikam/iconview.h #628884:628885
@@ -1,9 +1,11 @@
 /* ============================================================
- * Author: Renchi Raju <renchi at pooh.tam.uiuc.edu>
- * Date  : 2005-04-24
+ * Authors: Renchi Raju <renchi at pooh.tam.uiuc.edu>
+ *          Caulier Gilles <caulier dot gilles at kdemail dot net>
+ * Date   : 2005-04-24
  * Description : 
  *
  * Copyright 2005 by Renchi Raju
+ * Copyright 2006-2007 by Gilles Caulier
  *
  * This program is free software; you can redistribute it
  * and/or modify it under the terms of the GNU General
@@ -58,6 +60,7 @@
     void setCurrentItem(IconItem* item);
 
     int  count() const;
+    int  countSelected() const;
     int  groupCount() const;
 
     virtual void clear(bool update=true);


More information about the Digikam-devel mailing list