[tracker/tracker-0.12: 195/202] tracker-needle: tell the user when a query is too generic
- From: Martyn James Russell <mr src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [tracker/tracker-0.12: 195/202] tracker-needle: tell the user when a query is too generic
- Date: Thu, 6 Oct 2011 18:04:50 +0000 (UTC)
commit 5ad96673271bc1d4c7df0432f401aafa7f373347
Author: Carlos Garnacho <carlos lanedo com>
Date: Thu Oct 6 14:02:54 2011 +0200
tracker-needle: tell the user when a query is too generic
There's now a limit of 500 items per category, and the info bar
is used whenever a query is too generic to fit in the limit
src/tracker-needle/tracker-needle.vala | 19 ++++++++++++++++++-
src/tracker-needle/tracker-result-store.vala | 14 +++++++++++++-
2 files changed, 31 insertions(+), 2 deletions(-)
---
diff --git a/src/tracker-needle/tracker-needle.vala b/src/tracker-needle/tracker-needle.vala
index 8cfbd22..6a72419 100644
--- a/src/tracker-needle/tracker-needle.vala
+++ b/src/tracker-needle/tracker-needle.vala
@@ -55,6 +55,7 @@ public class Tracker.Needle {
private int size_small = 0;
private int size_medium = 0;
private int size_big = 0;
+ private uint limit = 500;
static bool current_find_in_filelist = true;
static bool current_find_in_icons = true;
@@ -64,9 +65,17 @@ public class Tracker.Needle {
private ResultStore images_model;
private ResultStore images_in_title_model;
+ private void result_overflow () {
+ show_info_message ("Search result was too generic\n" +
+ "<small>Only the first 500 items will be displayed</small>",
+ MessageType.INFO);
+ }
+
private void create_models () {
// Categories model
categories_model = new ResultStore (6);
+ categories_model.limit = limit;
+ categories_model.result_overflow.connect (result_overflow);
categories_model.add_query (Tracker.Query.Type.APPLICATIONS,
Tracker.Query.Match.FTS,
"?urn",
@@ -135,6 +144,8 @@ public class Tracker.Needle {
// Files model
files_model = new ResultStore (7);
+ files_model.limit = limit;
+ files_model.result_overflow.connect (result_overflow);
files_model.add_query (Tracker.Query.Type.ALL,
Tracker.Query.Match.FTS,
"?urn",
@@ -146,6 +157,8 @@ public class Tracker.Needle {
"nie:url(?urn)");
files_in_title_model = new ResultStore (7);
+ files_in_title_model.limit = limit;
+ files_in_title_model.result_overflow.connect (result_overflow);
files_in_title_model.add_query (Tracker.Query.Type.ALL,
Tracker.Query.Match.TITLES,
"?urn",
@@ -158,6 +171,8 @@ public class Tracker.Needle {
// Images model
images_model = new ResultStore (6);
+ images_model.limit = limit;
+ images_model.result_overflow.connect (result_overflow);
images_model.icon_size = 128;
images_model.add_query (Tracker.Query.Type.IMAGES,
Tracker.Query.Match.NONE,
@@ -170,6 +185,8 @@ public class Tracker.Needle {
"nie:url(?urn)");
images_in_title_model = new ResultStore (6);
+ images_in_title_model.limit = limit;
+ images_in_title_model.result_overflow.connect (result_overflow);
images_in_title_model.icon_size = 128;
images_in_title_model.add_query (Tracker.Query.Type.IMAGES,
Tracker.Query.Match.TITLES,
@@ -606,7 +623,7 @@ public class Tracker.Needle {
public void show_info_message (string message,
Gtk.MessageType type) {
info_bar.set_message_type (type);
- info_bar_label.set_label (message);
+ info_bar_label.set_markup (message);
info_bar.show ();
}
diff --git a/src/tracker-needle/tracker-result-store.vala b/src/tracker-needle/tracker-result-store.vala
index 8a54af9..5478438 100644
--- a/src/tracker-needle/tracker-result-store.vala
+++ b/src/tracker-needle/tracker-result-store.vala
@@ -61,6 +61,13 @@ public class Tracker.ResultStore : Gtk.TreeModel, GLib.Object {
set;
}
+ public uint limit {
+ get;
+ set;
+ }
+
+ public signal void result_overflow ();
+
private Operation? find_operation (GenericArray<Operation> array, CategoryNode node, int offset) {
Operation op;
int i;
@@ -88,7 +95,7 @@ public class Tracker.ResultStore : Gtk.TreeModel, GLib.Object {
query = new Tracker.Query ();
query.criteria = _search_term;
query.tags = search_tags;
- query.limit = 100;
+ query.limit = limit;
query.offset = op.offset;
cursor = yield query.perform_async (op.node.query.type, op.node.query.match, op.node.query.args, cancellable);
@@ -224,6 +231,11 @@ public class Tracker.ResultStore : Gtk.TreeModel, GLib.Object {
ResultNode *res;
int i;
+ if (count > limit) {
+ result_overflow ();
+ count = limit;
+ }
+
Gtk.TreeIter iter;
Gtk.TreePath path;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]