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

Jörn Ahrens joern.ahrens at kdemail.net
Sun Jul 24 00:09:59 BST 2005


SVN commit 438029 by jahrens:

After I've played some time with the new AlbumFolderView / TagFolderView
I realized, that it is sometimes impossible to add a new album to the
root album or dragging an album to the root.

I've added a new root folder to the two views, which are displayed red, 
to show their different meaning. Additionally they are displayed without
rootDecorations.

You can rmb click to that root album to add a new child to the root or 
drag another album on it. 

Digikam doesn't allow images to be stored in the root folder.

Todo: disable the some parts of the import menu, when the root album
is selected.

CCMAIL: digikam-devel at kde.org



 M  +34 -15    albumfolderview.cpp  
 M  +17 -6     tagfolderview.cpp  


--- trunk/extragear/graphics/digikam/digikam/albumfolderview.cpp #438028:438029
@@ -186,7 +186,7 @@
     
     addColumn(i18n("My Albums"));
     setResizeMode(QListView::LastColumn);
-    setRootIsDecorated(true);
+    setRootIsDecorated(false);
     setAllColumnsShowFocus(true);
 
     setAcceptDrops(true);
@@ -220,7 +220,7 @@
 
 void AlbumFolderView::slotAlbumAdded(Album *album)
 {
-    if(!album || album->isRoot())
+    if(!album)
         return;
     
     PAlbum *palbum = dynamic_cast<PAlbum*>(album);
@@ -236,24 +236,25 @@
         return;
     }
 
+    KIconLoader *iconLoader = KApplication::kApplication()->iconLoader();        
     AlbumFolderViewItem *item;
     if (!parent)
     {
-        // child of root
-
+        // root album
         item = new AlbumFolderViewItem(this, palbum);
         palbum->setExtraData(this, item);
+        item->setPixmap(0, iconLoader->loadIcon("folder_red", KIcon::NoGroup,
+                        32, KIcon::DefaultState, 0, true));        
     }
     else
     {
         item = new AlbumFolderViewItem(parent, palbum);
         palbum->setExtraData(this, item);
+        
+        item->setPixmap(0, iconLoader->loadIcon("folder", KIcon::NoGroup,
+                        32, KIcon::DefaultState, 0, true));
     }
 
-    KIconLoader *iconLoader = KApplication::kApplication()->iconLoader();    
-    item->setPixmap(0, iconLoader->loadIcon("folder", KIcon::NoGroup,
-                    32, KIcon::DefaultState, 0, true));
-    
     setAlbumThumbnail(palbum);
 }
 
@@ -324,9 +325,18 @@
     else
     {
         KIconLoader *iconLoader = KApplication::kApplication()->iconLoader();
-        item->setPixmap(0, iconLoader->loadIcon("folder", KIcon::NoGroup,
-                                                32, KIcon::DefaultState,
-                                                0, true));
+        if(album->isRoot())
+        {
+            item->setPixmap(0, iconLoader->loadIcon("folder_red", KIcon::NoGroup,
+                                                    32, KIcon::DefaultState,
+                                                    0, true));
+        }
+        else
+        {
+            item->setPixmap(0, iconLoader->loadIcon("folder", KIcon::NoGroup,
+                            32, KIcon::DefaultState,
+                            0, true));            
+        }
     }
 }
 
@@ -415,7 +425,8 @@
     popmenu.insertItem(SmallIcon("album"), i18n("New Album..."), 10);
     
     AlbumFolderViewItem *item = dynamic_cast<AlbumFolderViewItem*>(listitem);
-    if(item)
+    // Root folder only shows "New Album..."
+    if(item && item->parent())
     {
         popmenu.insertItem(SmallIcon("pencil"), i18n("Edit Album Properties..."), 11);
         
@@ -705,8 +716,7 @@
         }
 
         emit signalAlbumModified();
-    }
-    
+    }    
 }
 
 QDragObject* AlbumFolderView::dragObject()
@@ -716,6 +726,9 @@
         return 0;
     
     PAlbum *album = item->getAlbum();
+    if(album->isRoot())
+        return 0;
+    
     AlbumDrag *a = new AlbumDrag(album->kurl(), album->id(), this);
     if(!a)
         return 0;
@@ -767,6 +780,12 @@
         }
         };
     }
+    
+    if(itemDrop  && !itemDrop->parent())
+    {
+        // Do not allow drop images on album root
+        return false;
+    }
 
     if (itemDrop && itemDrop->isGroupItem())
     {
@@ -1122,7 +1141,7 @@
 
 AlbumFolderViewItem* AlbumFolderView::findParentByFolder(PAlbum* album, bool& failed)
 {
-    if (album->parent()->isRoot())
+    if (album->isRoot())
     {
         failed = false;
         return 0;
--- trunk/extragear/graphics/digikam/digikam/tagfolderview.cpp #438028:438029
@@ -134,7 +134,7 @@
         
     addColumn(i18n("My Tags"));
     setResizeMode(QListView::LastColumn);
-    setRootIsDecorated(true);
+    setRootIsDecorated(false);
     
     setAcceptDrops(true);
     viewport()->setAcceptDrops(true);
@@ -166,17 +166,19 @@
 
 void TagFolderView::slotAlbumAdded(Album *album)
 {
-    if(!album || album->isRoot())
+    if(!album)
         return;
     
     TAlbum *tag = dynamic_cast<TAlbum*>(album);
     if(!tag)
         return;
     
-    if(tag->parent()->isRoot())
+    if(tag->isRoot())
     {
         TagFolderViewItem *item = new TagFolderViewItem(this, tag);
-        item->setPixmap(0, getBlendedIcon(tag));
+        KIconLoader *iconLoader = KApplication::kApplication()->iconLoader();                
+        item->setPixmap(0, iconLoader->loadIcon("folder_red", KIcon::NoGroup,
+                        32, KIcon::DefaultState, 0, true));                
         tag->setExtraData(this, item);
     }
     else
@@ -305,7 +307,7 @@
     popmenu.insertItem(SmallIcon("tag"), i18n("Create Tag from AddressBook"),
                        d->ABCMenu);
 
-    if(tag)
+    if(tag && tag->parent())
     {
         popmenu.insertItem(SmallIcon("pencil"), i18n("Edit Tag Properties..."), 11);
         popmenu.insertItem(SmallIcon("edittrash"), i18n("Delete Tag"), 12);
@@ -505,6 +507,9 @@
     if(!item)
         return 0;
     
+    if(!item->parent())
+        return 0;
+    
     TagDrag *t = new TagDrag(item->getTag()->globalID(), this);
     t->setPixmap(*item->pixmap(0));
 
@@ -519,7 +524,7 @@
  
     if(TagDrag::canDecode(e) || TagListDrag::canDecode(e))
     {
-        // Allow dragging at the root, to move the tag at the root
+        // Allow dragging at the root, to move the tag to the root
         if(!itemDrop)
             return true;
         
@@ -534,6 +539,12 @@
         return true;
     }
 
+    if(itemDrop && !itemDrop->parent())
+    {
+        // Allow only tags dragging at the root
+        return false;
+    }
+    
     if(ItemDrag::canDecode(e))
     {
         return true;



More information about the Digikam-devel mailing list