Bug 132011 - Add search criteria to take sub-tags into account
Summary: Add search criteria to take sub-tags into account
Status: RESOLVED FIXED
Alias: None
Product: digikam
Classification: Applications
Component: Searches-Advanced (show other bugs)
Version: 0.8.2
Platform: Debian testing Linux
: NOR wishlist
Target Milestone: ---
Assignee: Digikam Developers
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2006-08-07 17:37 UTC by Richard Kralovic
Modified: 2017-08-18 09:46 UTC (History)
1 user (show)

See Also:
Latest Commit:
Version Fixed In: 0.9.0


Attachments
Proposed patch to solve the feature request. (2.73 KB, patch)
2006-08-07 17:37 UTC, Richard Kralovic
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Richard Kralovic 2006-08-07 17:37:02 UTC
Version:           0.8.2 (using KDE KDE 3.5.3)
Installed from:    Debian testing/unstable Packages

When searching for pictures, it is possible to specify the tag the picture should have, so the search returns all pictures with this tag. However, it does not return any pictures with sub-tags of the specified tag. IMHO it would be useful to add operators "Contains" and "Does not contain" for tag searching that would take sub-tags into account.

E.g. selecting "Tag contains People/Family" would return all pictures tagged with any subtag of People/Family.
Comment 1 Richard Kralovic 2006-08-07 17:37:56 UTC
Created attachment 17267 [details]
Proposed patch to solve the feature request.
Comment 2 Marcel Wiesweg 2006-08-07 22:58:08 UTC
SVN commit 570853 by mwiesweg:

Applying proposed patch. Thanks to Richard Kralovic.

BUG: 132011


 M  +2 -0      digikam/searchwidgets.cpp  
 M  +15 -1     kioslave/digikamsearch.cpp  


--- trunk/extragear/graphics/digikam/digikam/searchwidgets.cpp #570852:570853
@@ -95,6 +95,8 @@
     { I18N_NOOP("Does Not Equal"),     "NE",           SearchAdvancedRule::ALBUMS },
     { I18N_NOOP("Equals"),             "EQ",           SearchAdvancedRule::TAGS },
     { I18N_NOOP("Does Not Equal"),     "NE",           SearchAdvancedRule::TAGS },
+    { I18N_NOOP("Contains"),           "LIKE",         SearchAdvancedRule::TAGS },
+    { I18N_NOOP("Does Not Contain"),   "NLIKE",        SearchAdvancedRule::TAGS },
     { I18N_NOOP("After"),              "GT",           SearchAdvancedRule::DATE },
     { I18N_NOOP("Before"),             "LT",           SearchAdvancedRule::DATE },
     { I18N_NOOP("Equals"),             "EQ",           SearchAdvancedRule::DATE },
--- trunk/extragear/graphics/digikam/kioslave/digikamsearch.cpp #570852:570853
@@ -471,14 +471,26 @@
             query = " (Images.id IN "
                     "   (SELECT imageid FROM ImageTags "
                     "    WHERE tagid = $$@@$$)) ";
-        else 
+        else if (op == NE)
             query = " (Images.id NOT IN "
                     "   (SELECT imageid FROM ImageTags "
                     "    WHERE tagid = $$@@$$)) ";
+        else if (op == LIKE) 
+            query = " (Images.id IN "
+                    "   (SELECT ImageTags.imageid FROM ImageTags JOIN TagsTree on ImageTags.tagid = TagsTree.id "
+                    "    WHERE TagsTree.pid = $$@@$$ or ImageTags.tagid = $$@@$$ )) ";
+        else // op == NLIKE
+            query = " (Images.id NOT IN "
+                    "   (SELECT ImageTags.imageid FROM ImageTags JOIN TagsTree on ImageTags.tagid = TagsTree.id "
+                    "    WHERE TagsTree.pid = $$@@$$ or ImageTags.tagid = $$@@$$ )) ";
 
 //         query = " (Images.id IN "
 //                 "   (SELECT imageid FROM ImageTags "
 //                 "    WHERE tagid $$##$$ $$@@$$)) ";
+
+        query.replace("$$@@$$", QString::fromLatin1("'") + escapeString(val)
+                      + QString::fromLatin1("'"));
+
         break;
     }
     case(TAGNAME):
@@ -516,6 +528,7 @@
     }
     }
 
+    if (key != TAG) {
     switch (op)
     {
     case(EQ):
@@ -561,6 +574,7 @@
         break;
     }
     }
+    }
 
     // special case for imagedate. If the key is imagedate and the operator is EQ,
     // we need to split it into two rules