Bug 111798 - Disable "Remove tag" entry from the menu when none tag is assigned
Summary: Disable "Remove tag" entry from the menu when none tag is assigned
Status: RESOLVED FIXED
Alias: None
Product: digikam
Classification: Applications
Component: Usability-Menus (show other bugs)
Version: 0.8.0
Platform: unspecified Linux
: NOR wishlist
Target Milestone: ---
Assignee: Digikam Developers
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2005-08-31 02:33 UTC by M. Ignacio Monge Garc
Modified: 2017-08-02 21:09 UTC (History)
0 users

See Also:
Latest Commit:
Version Fixed In:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description M. Ignacio Monge Garc 2005-08-31 02:33:02 UTC
Version:           0.8.0-beta1 (using KDE 3.4.90 (alpha1, >= 20050806), compiled sources)
Compiler:          gcc version 3.4.4 (Gentoo 3.4.4-r1, ssp-3.4.4-1.0, pie-8.7.8)
OS:                Linux (i686) release 2.6.13-ck1

If none tag is assigned to an image the "Remove tag" entry from the mouse menu should disable or removed.
Comment 1 Tina Trillitzsch 2005-09-07 12:51:36 UTC
Disabling may be ok. But do not remove the entry altogether. Removing entries that are available in other circumstances is a major usability no-no.
Comment 2 Tom Albers 2005-09-17 18:51:24 UTC
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 ----------------------------