[rygel] tracker: TrackerQuery.from_template -> clone



commit 3fec870c3521a66610ef6b2ba5f1141224e53f18
Author: Zeeshan Ali (Khattak) <zeeshanak gnome org>
Date:   Mon Nov 30 16:20:35 2009 +0200

    tracker: TrackerQuery.from_template -> clone
    
    Replace contructor to create TrackerQuery from a template by a constructor
    that makes the new instance a clone of the query provided as parameter.

 src/plugins/tracker/rygel-tracker-query.vala       |   24 +++++++++++++------
 .../tracker/rygel-tracker-search-container.vala    |    4 +-
 2 files changed, 18 insertions(+), 10 deletions(-)
---
diff --git a/src/plugins/tracker/rygel-tracker-query.vala b/src/plugins/tracker/rygel-tracker-query.vala
index 5e8877b..c6fc0a4 100644
--- a/src/plugins/tracker/rygel-tracker-query.vala
+++ b/src/plugins/tracker/rygel-tracker-query.vala
@@ -64,14 +64,14 @@ public class Rygel.TrackerQuery {
         this.max_count = max_count;
     }
 
-    public TrackerQuery.from_template (TrackerQuery template) {
-        this (template.variables,
-              template.mandatory,
-              template.optional,
-              template.filters,
-              template.order_by,
-              template.offset,
-              template.max_count);
+    public TrackerQuery.clone (TrackerQuery query) {
+        this (this.copy_str_list (query.variables),
+              new TrackerQueryTriplets.clone (query.mandatory),
+              new TrackerQueryTriplets.clone (query.optional),
+              this.copy_str_list (query.filters),
+              query.order_by,
+              query.offset,
+              query.max_count);
     }
 
     public string to_string () {
@@ -124,6 +124,14 @@ public class Rygel.TrackerQuery {
 
         return str;
     }
+
+    private ArrayList<string> copy_str_list (Gee.List<string> str_list) {
+        var copy = new ArrayList<string> ();
+
+        copy.add_all (str_list);
+
+        return copy;
+    }
 }
 
 /**
diff --git a/src/plugins/tracker/rygel-tracker-search-container.vala b/src/plugins/tracker/rygel-tracker-search-container.vala
index 3971fe1..d7ff4d8 100644
--- a/src/plugins/tracker/rygel-tracker-search-container.vala
+++ b/src/plugins/tracker/rygel-tracker-search-container.vala
@@ -95,7 +95,7 @@ public class Rygel.TrackerSearchContainer : Rygel.MediaContainer {
 
     private async void get_children_count () {
         try {
-            var query = new TrackerQuery.from_template (this.query);
+            var query = new TrackerQuery.clone (this.query);
 
             query.variables = new ArrayList<string> ();
             query.variables.add ("COUNT(" + ITEM_VARIABLE + ") AS x");
@@ -193,7 +193,7 @@ public class Rygel.TrackerSearchContainer : Rygel.MediaContainer {
             return null;
         }
 
-        var query = new TrackerQuery.from_template (this.query);
+        var query = new TrackerQuery.clone (this.query);
 
         if (filter != null) {
             var filters = query.filters;



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]