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

Gilles Caulier caulier.gilles at gmail.com
Fri May 18 13:31:34 BST 2007


SVN commit 665957 by cgilles:

digikam from trunk : Light Table : now, you can drag & drop drag & drop an album from Album Gui to Light Table. All items from this album wil be automaticly loaded in thumbbar. 
CCMAIL: digikam-devel at kde.org


 M  +36 -7     lighttablebar.cpp  
 M  +46 -27    lighttablepreview.cpp  


--- trunk/extragear/graphics/digikam/utilities/lighttable/lighttablebar.cpp #665956:665957
@@ -39,6 +39,8 @@
 
 #include "ddebug.h"
 #include "album.h"
+#include "albumdb.h"
+#include "albummanager.h"
 #include "albumsettings.h"
 #include "dragobjects.h"
 #include "imageattributeswatch.h"
@@ -647,25 +649,29 @@
 
 void LightTableBar::contentsDragMoveEvent(QDragMoveEvent *e)
 {
+    int             albumID;
+    QValueList<int> albumIDs;
+    QValueList<int> imageIDs;
     KURL::List      urls;
     KURL::List      kioURLs;        
-    QValueList<int> albumIDs;
-    QValueList<int> imageIDs;
 
-    if (!ItemDrag::decode(e, urls, kioURLs, albumIDs, imageIDs))
+    if (ItemDrag::decode(e, urls, kioURLs, albumIDs, imageIDs) ||
+        AlbumDrag::decode(e, urls, albumID))
     {
-        e->ignore();
+        e->accept();
         return;
     }
-    e->accept();
+
+    e->ignore();
 }
 
 void LightTableBar::contentsDropEvent(QDropEvent *e)
 {
+    int             albumID;
+    QValueList<int> albumIDs;
+    QValueList<int> imageIDs;
     KURL::List      urls;
     KURL::List      kioURLs;        
-    QValueList<int> albumIDs;
-    QValueList<int> imageIDs;
 
     if (ItemDrag::decode(e, urls, kioURLs, albumIDs, imageIDs))
     {
@@ -686,7 +692,30 @@
         }
         
         emit signalDroppedItems(imageInfoList);
+        e->accept();
     }
+    else if (AlbumDrag::decode(e, urls, albumID))
+    {
+        QValueList<Q_LLONG> itemIDs = AlbumManager::instance()->albumDB()->getItemIDsInAlbum(albumID);
+        ImageInfoList imageInfoList;
+
+        for (QValueList<Q_LLONG>::const_iterator it = itemIDs.begin();
+             it != itemIDs.end(); ++it)
+        {
+            ImageInfo *info = new ImageInfo(*it);
+            if (!findItemByInfo(info))
+            {
+                imageInfoList.append(info);
+            }
+            else
+            {
+                delete info;
+            }
+        }
+
+        emit signalDroppedItems(imageInfoList);
+        e->accept();
+    }
     else 
     {
         e->ignore();
--- trunk/extragear/graphics/digikam/utilities/lighttable/lighttablepreview.cpp #665956:665957
@@ -653,44 +653,63 @@
 
 void LightTablePreview::contentsDragMoveEvent(QDragMoveEvent *e)
 {
-    if (!d->dragAndDropEnabled) return;
-
-    KURL::List      urls;
-    KURL::List      kioURLs;        
-    QValueList<int> albumIDs;
-    QValueList<int> imageIDs;
-
-    if (!ItemDrag::decode(e, urls, kioURLs, albumIDs, imageIDs))
+    if (d->dragAndDropEnabled)
     {
-        e->ignore();
-        return;
+        int             albumID;
+        QValueList<int> albumIDs;
+        QValueList<int> imageIDs;
+        KURL::List      urls;
+        KURL::List      kioURLs;        
+    
+        if (ItemDrag::decode(e, urls, kioURLs, albumIDs, imageIDs) ||
+            AlbumDrag::decode(e, urls, albumID))
+        {
+            e->accept();
+            return;
+        }
     }
-    e->accept();
+
+    e->ignore();
 }
 
 void LightTablePreview::contentsDropEvent(QDropEvent *e)
 {
-    if (!d->dragAndDropEnabled) return;
-
-    KURL::List      urls;
-    KURL::List      kioURLs;        
-    QValueList<int> albumIDs;
-    QValueList<int> imageIDs;
-    ImageInfoList   list;
-
-    if (ItemDrag::decode(e, urls, kioURLs, albumIDs, imageIDs))
+    if (d->dragAndDropEnabled)
     {
-        for (QValueList<int>::const_iterator it = imageIDs.begin();
-                it != imageIDs.end(); ++it)
+        int             albumID;
+        QValueList<int> albumIDs;
+        QValueList<int> imageIDs;
+        KURL::List      urls;
+        KURL::List      kioURLs;  
+        ImageInfoList   list;
+    
+        if (ItemDrag::decode(e, urls, kioURLs, albumIDs, imageIDs))
         {
-            list.append(new ImageInfo(*it));
+            for (QValueList<int>::const_iterator it = imageIDs.begin();
+                 it != imageIDs.end(); ++it)
+            {
+                list.append(new ImageInfo(*it));
+            }
             emit signalDroppedItems(list);
+            e->accept();
+            return;
         }
+        else if (AlbumDrag::decode(e, urls, albumID))
+        {
+            QValueList<Q_LLONG> itemIDs = AlbumManager::instance()->albumDB()->getItemIDsInAlbum(albumID);
+    
+            for (QValueList<Q_LLONG>::const_iterator it = itemIDs.begin();
+                it != itemIDs.end(); ++it)
+            {
+                list.append(new ImageInfo(*it));
+            }
+            emit signalDroppedItems(list);
+            e->accept();
+            return;
+        }
     }
-    else 
-    {
-        e->ignore();
-    }
+
+    e->ignore();
 }
 
 void LightTablePreview::setSelected(bool sel)



More information about the Digikam-devel mailing list