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.
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 ----------------------------