[Digikam-devel] [Bug 111798] Disable "Remove tag" entry from the menu when none tag is assigned

Tom Albers tomalbers at kde.nl
Sat Sep 17 17:51:26 BST 2005


------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.
         
http://bugs.kde.org/show_bug.cgi?id=111798         
tomalbers kde nl changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
         Resolution|                            |FIXED



------- Additional Comments From tomalbers kde nl  2005-09-17 18:51 -------
SVN commit 461456 by toma:

Disable "remove tags" menu item when there are no common tags, but to not delay the menu appearance due to finding out if there are common items, I disable the menu item when there are more then 250 images.
Partly based on patch by Gregory Kokanosky
BUG: 111798


 M  +32 -0     albumdb.cpp  
 M  +8 -0      albumdb.h  
 M  +12 -1     albumiconview.cpp  


--- trunk/extragear/graphics/digikam/digikam/albumdb.cpp #461455:461456
 @ -764,6 +764,38  @
     return ids;
 }
 
+bool AlbumDB::hasTags(const LLongList& imageIDList)
+{
+    IntList ids;
+
+    if (imageIDList.isEmpty())
+        return false;
+
+    QStringList values;
+
+    QString sql = QString("SELECT count(tagid) FROM ImageTags "
+            "WHERE imageid=%1 ")
+            .arg(imageIDList.first());
+
+    LLongList::const_iterator iter = imageIDList.begin();
+    ++iter;
+
+    while (iter != imageIDList.end())
+    {
+        sql += QString(" OR imageid=%2 ")
+                .arg(*iter);
+        ++iter;
+    }
+
+    sql += QString(";");
+    execSql( sql, &values );
+
+    if (values[0] == "0")
+        return false;
+    else
+        return true;
+}
+
 IntList AlbumDB::getItemCommonTagIDs(const LLongList& imageIDList)
 {
     IntList ids;
--- trunk/extragear/graphics/digikam/digikam/albumdb.h #461455:461456
 @ -353,6 +353,14  @
 
     /**
      * Given a set of items (identified by their IDs),
+     * this will see if any of the items has a tag.
+     *  param imageIDList a list of IDs of the items
+     *  return true if at least one of the items has a tag
+     */
+    bool hasTags(const LLongList& imageIDList);
+    
+    /**
+     * Given a set of items (identified by their IDs),
      * get a list of ID of all common tags
      *  param imageIDList a list of IDs of the items
      *  return the list of common IDs of the given items
--- trunk/extragear/graphics/digikam/digikam/albumiconview.cpp #461455:461456
 @ -114,6 +114,8  @
 #include "albumicongroupitem.h"
 #include "albumiconview.h"
 
+#include "albumdb.h"
+
 class AlbumIconViewPrivate
 {
 public:
 @ -471,7 +473,16  @
             SLOT(slotRemoveTag(int)));
 
     popmenu.insertItem(i18n("Assign Tag"), assignTagsPopup);
-    popmenu.insertItem(i18n("Remove Tag"), removeTagsPopup);
+
+    int removeTagId =  popmenu.insertItem(i18n("Remove Tag"), removeTagsPopup);
+
+    AlbumManager* man = AlbumManager::instance();
+
+    // Performance: Only check for common tags if there are less then 250 tags.
+    if (selectedImageIDs.count() > 250 ||
+        !man->albumDB()->hasTags(selectedImageIDs))
+            popmenu.setItemEnabled(removeTagId, false);
+
     popmenu.insertSeparator();
 
     // Merge in the KIPI plugins actions ----------------------------



More information about the Digikam-devel mailing list