commit 20fafceec54df92a91596071be1d8093655d9d2f
Author: Adrien Dorsaz <adrien@adorsaz.ch>
Date:   Sat Mar 14 22:53:39 2015 +0100

    tracker-needle: add a query to find tags without sensitivity

diff --git a/src/tracker-needle/tracker-query.vala b/src/tracker-needle/tracker-query.vala
index 0a03e80..bdd0f04 100644
--- a/src/tracker-needle/tracker-query.vala
+++ b/src/tracker-needle/tracker-query.vala
@@ -41,6 +41,7 @@ public class Tracker.Query {
 		TITLES,
 		TITLES_INDIRECT,
 		TAGS_ONLY,
+		TAGS_ONLY_INSENSITIVE,
 		TAGS_ONLY_INDIRECT
 	}
 
@@ -74,6 +75,10 @@ public class Tracker.Query {
 		"?urn nao:hasTag ?tag .
 		 FILTER (nao:prefLabel(?tag) IN (%s))",
 
+		// TAGS_ONLY_INSENSITIVE (same as TAGS_ONLY but insensitive and with same %s but lower cased)
+		"?urn nao:hasTag ?tag .
+		 FILTER (fn:lower-case(nao:prefLabel(?tag)) IN (%s))",
+
 		// TAGS_ONLY_INDIRECT (same as TAGS_ONLY for ?match)
 		"?match nao:hasTag ?tag .
 		 FILTER (nao:prefLabel(?tag) IN (%s))"
@@ -265,7 +270,8 @@ public class Tracker.Query {
 			!(match_type == Match.NONE ||
 			  match_type == Match.FTS ||
 			  match_type == Match.TITLES ||
-			  match_type == Match.TAGS_ONLY)) {
+			  match_type == Match.TAGS_ONLY ||
+			  match_type == Match.TAGS_ONLY_INSENSITIVE)) {
 			critical ("You can not use a non-MUSIC or non-DOCUMENTS query (%d) with INDIRECT matching (%d)", query_type, match_type);
 			return false;
 		}
@@ -286,13 +292,14 @@ public class Tracker.Query {
 			if (match_type == Match.FTS_INDIRECT ||
 			    match_type == Match.TITLES_INDIRECT) {
 				match_type = Match.TAGS_ONLY_INDIRECT;
-			} else {
+			} else if(match_type != Match.TAGS_ONLY_INSENSITIVE) {
 				match_type = Match.TAGS_ONLY;
 			}
 		}
 		debug ("match_type:%d", match_type);
 		if (match_type != Match.NONE &&
 		    match_type != Match.TAGS_ONLY &&
+		    match_type != Match.TAGS_ONLY_INSENSITIVE &&
 		    match_type != Match.TAGS_ONLY_INDIRECT &&
 		    (criteria == null || criteria.length < 1)) {
 			warning ("Criteria was NULL or an empty string no query performed");
@@ -304,6 +311,8 @@ public class Tracker.Query {
 		if (match_type == Match.TAGS_ONLY ||
 		    match_type == Match.TAGS_ONLY_INDIRECT) {
 			match = match_clauses[match_type].printf (get_tags_filter ());
+		} else if (match_type == Match.TAGS_ONLY_INSENSITIVE) {
+			match = match_clauses[match_type].printf (get_tags_filter ().down 	());
 		} else {
 			string criteria_escaped = Tracker.Sparql.escape_string (criteria);
 
@@ -349,13 +358,14 @@ public class Tracker.Query {
 			if (match_type == Match.FTS_INDIRECT ||
 			    match_type == Match.TITLES_INDIRECT) {
 				match_type = Match.TAGS_ONLY_INDIRECT;
-			} else {
-				match_type = Match.TAGS_ONLY;
+			} else if(match_type != Match.TAGS_ONLY_INSENSITIVE){
+					match_type = Match.TAGS_ONLY;
 			}
 		}
 
 		if (match_type != Match.NONE &&
 		    match_type != Match.TAGS_ONLY &&
+		    match_type != Match.TAGS_ONLY_INSENSITIVE &&
 		    match_type != Match.TAGS_ONLY_INDIRECT &&
 		    (criteria == null || criteria.length < 1)) {
 			warning ("Criteria was NULL or an empty string no query performed");
@@ -372,6 +382,8 @@ public class Tracker.Query {
 		if (match_type == Match.TAGS_ONLY ||
 		    match_type == Match.TAGS_ONLY_INDIRECT) {
 			match = match_clauses[match_type].printf (get_tags_filter ());
+		} else if(match_type == Match.TAGS_ONLY_INSENSITIVE) {
+			match = match_clauses[match_type].printf (get_tags_filter ().down ());
 		} else {
 			string criteria_escaped = Tracker.Sparql.escape_string (criteria);
 
