| Summary: | Disable "Remove tag" entry from the menu when none tag is assigned. | ||
|---|---|---|---|
| Product: | [Applications] digikam | Reporter: | M. Ignacio Monge Garc <ignaciomonge> |
| Component: | Usability-Menus | Assignee: | Digikam Developers <digikam-bugs-null> |
| Status: | RESOLVED FIXED | ||
| Severity: | wishlist | CC: | caulier.gilles |
| Priority: | NOR | ||
| Version First Reported In: | 0.8.0 | ||
| Target Milestone: | --- | ||
| Platform: | unspecified | ||
| OS: | Linux | ||
| Latest Commit: | Version Fixed/Implemented In: | 8.4.0 | |
| Sentry Crash Report: | |||
|
Description
M. Ignacio Monge Garc
2005-08-31 02:33:02 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. 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 ----------------------------
|