[gnome-photos/wip/foo: 7/8] query-builder: Fold all the count and global query methods into one
- From: Debarshi Ray <debarshir src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-photos/wip/foo: 7/8] query-builder: Fold all the count and global query methods into one
- Date: Mon, 8 Apr 2013 23:10:28 +0000 (UTC)
commit c139e83d34d88057db882b084fbe516188a5ddcb
Author: Debarshi Ray <debarshir gnome org>
Date: Tue Apr 9 00:54:23 2013 +0200
query-builder: Fold all the count and global query methods into one
src/photos-offset-collections-controller.c | 2 +-
src/photos-offset-favorites-controller.c | 4 +-
src/photos-offset-overview-controller.c | 4 +-
src/photos-query-builder.c | 96 ++-------------------------
src/photos-query-builder.h | 12 +---
src/photos-tracker-collections-controller.c | 2 +-
src/photos-tracker-favorites-controller.c | 4 +-
src/photos-tracker-overview-controller.c | 4 +-
8 files changed, 17 insertions(+), 111 deletions(-)
---
diff --git a/src/photos-offset-collections-controller.c b/src/photos-offset-collections-controller.c
index 3898a86..269c4ba 100644
--- a/src/photos-offset-collections-controller.c
+++ b/src/photos-offset-collections-controller.c
@@ -37,7 +37,7 @@ G_DEFINE_TYPE (PhotosOffsetCollectionsController,
static PhotosQuery *
photos_offset_collections_controller_get_query (void)
{
- return photos_query_builder_count_collections_query ();
+ return photos_query_builder_count_query (PHOTOS_QUERY_FLAGS_COLLECTIONS);
}
diff --git a/src/photos-offset-favorites-controller.c b/src/photos-offset-favorites-controller.c
index baaf16d..82f797f 100644
--- a/src/photos-offset-favorites-controller.c
+++ b/src/photos-offset-favorites-controller.c
@@ -1,6 +1,6 @@
/*
* Photos - access, organize and share your photos on GNOME
- * Copyright © 2012 Red Hat, Inc.
+ * Copyright © 2012, 2013 Red Hat, Inc.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
@@ -35,7 +35,7 @@ G_DEFINE_TYPE (PhotosOffsetFavoritesController, photos_offset_favorites_controll
static PhotosQuery *
photos_offset_favorites_controller_get_query (void)
{
- return photos_query_builder_count_favorites_query ();
+ return photos_query_builder_count_query (PHOTOS_QUERY_FLAGS_FAVORITES);
}
diff --git a/src/photos-offset-overview-controller.c b/src/photos-offset-overview-controller.c
index b4e8dbe..644e927 100644
--- a/src/photos-offset-overview-controller.c
+++ b/src/photos-offset-overview-controller.c
@@ -1,6 +1,6 @@
/*
* Photos - access, organize and share your photos on GNOME
- * Copyright © 2012 Red Hat, Inc.
+ * Copyright © 2012, 2013 Red Hat, Inc.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
@@ -35,7 +35,7 @@ G_DEFINE_TYPE (PhotosOffsetOverviewController, photos_offset_overview_controller
static PhotosQuery *
photos_offset_overview_controller_get_query (void)
{
- return photos_query_builder_count_query ();
+ return photos_query_builder_count_query (PHOTOS_QUERY_FLAGS_NONE);
}
diff --git a/src/photos-query-builder.c b/src/photos-query-builder.c
index 0c5650d..1d8fb2f 100644
--- a/src/photos-query-builder.c
+++ b/src/photos-query-builder.c
@@ -254,7 +254,7 @@ photos_query_builder_collection_icon_query (const gchar *resource)
PhotosQuery *
-photos_query_builder_count_collections_query (void)
+photos_query_builder_count_query (gint flags)
{
PhotosBaseManager *srch_typ_mngr;
gchar *filter;
@@ -262,77 +262,11 @@ photos_query_builder_count_collections_query (void)
gchar *sparql;
gchar *where;
- filter = photos_query_builder_filter (PHOTOS_QUERY_FLAGS_COLLECTIONS);
+ filter = photos_query_builder_filter (flags);
optional = photos_query_builder_optional ();
srch_typ_mngr = photos_search_type_manager_new ();
- photos_query_builder_set_search_type (PHOTOS_QUERY_FLAGS_COLLECTIONS);
- where = photos_search_type_manager_get_where (PHOTOS_SEARCH_TYPE_MANAGER (srch_typ_mngr));
-
- sparql = g_strconcat ("SELECT DISTINCT COUNT(?urn) WHERE { ",
- where, " ",
- optional, " ",
- filter,
- " }",
- NULL);
-
- photos_query_builder_set_search_type (PHOTOS_QUERY_FLAGS_NONE);
- g_free (where);
- g_free (optional);
- g_free (filter);
- g_object_unref (srch_typ_mngr);
-
- return photos_query_new (sparql);
-}
-
-
-PhotosQuery *
-photos_query_builder_count_favorites_query (void)
-{
- PhotosBaseManager *srch_typ_mngr;
- gchar *filter;
- gchar *optional;
- gchar *sparql;
- gchar *where;
-
- filter = photos_query_builder_filter (PHOTOS_QUERY_FLAGS_FAVORITES);
- optional = photos_query_builder_optional ();
-
- srch_typ_mngr = photos_search_type_manager_new ();
- photos_query_builder_set_search_type (PHOTOS_QUERY_FLAGS_FAVORITES);
- where = photos_search_type_manager_get_where (PHOTOS_SEARCH_TYPE_MANAGER (srch_typ_mngr));
-
- sparql = g_strconcat ("SELECT DISTINCT COUNT(?urn) WHERE { ",
- where, " ",
- optional, " ",
- filter,
- " }",
- NULL);
-
- photos_query_builder_set_search_type (PHOTOS_QUERY_FLAGS_NONE);
- g_free (where);
- g_free (optional);
- g_free (filter);
- g_object_unref (srch_typ_mngr);
-
- return photos_query_new (sparql);
-}
-
-
-PhotosQuery *
-photos_query_builder_count_query (void)
-{
- PhotosBaseManager *srch_typ_mngr;
- gchar *filter;
- gchar *optional;
- gchar *sparql;
- gchar *where;
-
- filter = photos_query_builder_filter (PHOTOS_QUERY_FLAGS_NONE);
- optional = photos_query_builder_optional ();
-
- srch_typ_mngr = photos_search_type_manager_new ();
- photos_query_builder_set_search_type (PHOTOS_QUERY_FLAGS_NONE);
+ photos_query_builder_set_search_type (flags);
where = photos_search_type_manager_get_where (PHOTOS_SEARCH_TYPE_MANAGER (srch_typ_mngr));
sparql = g_strconcat ("SELECT DISTINCT COUNT(?urn) WHERE { ",
@@ -363,31 +297,11 @@ photos_query_builder_fetch_collections_query (const gchar *resource)
PhotosQuery *
-photos_query_builder_global_collections_query (void)
-{
- gchar *sparql;
-
- sparql = photos_query_builder_query (TRUE, PHOTOS_QUERY_FLAGS_COLLECTIONS);
- return photos_query_new (sparql);
-}
-
-
-PhotosQuery *
-photos_query_builder_global_favorites_query (void)
-{
- gchar *sparql;
-
- sparql = photos_query_builder_query (TRUE, PHOTOS_QUERY_FLAGS_FAVORITES);
- return photos_query_new (sparql);
-}
-
-
-PhotosQuery *
-photos_query_builder_global_query (void)
+photos_query_builder_global_query (gint flags)
{
gchar *sparql;
- sparql = photos_query_builder_query (TRUE, PHOTOS_QUERY_FLAGS_NONE);
+ sparql = photos_query_builder_query (TRUE, flags);
return photos_query_new (sparql);
}
diff --git a/src/photos-query-builder.h b/src/photos-query-builder.h
index 7522259..5780cb9 100644
--- a/src/photos-query-builder.h
+++ b/src/photos-query-builder.h
@@ -35,19 +35,11 @@ PhotosQuery *photos_query_builder_create_collection_query (const gchar *name);
PhotosQuery *photos_query_builder_collection_icon_query (const gchar *resource);
-PhotosQuery *photos_query_builder_count_collections_query (void);
-
-PhotosQuery *photos_query_builder_count_favorites_query (void);
-
-PhotosQuery *photos_query_builder_count_query (void);
+PhotosQuery *photos_query_builder_count_query (gint flags);
PhotosQuery *photos_query_builder_fetch_collections_query (const gchar *resource);
-PhotosQuery *photos_query_builder_global_collections_query (void);
-
-PhotosQuery *photos_query_builder_global_favorites_query (void);
-
-PhotosQuery *photos_query_builder_global_query (void);
+PhotosQuery *photos_query_builder_global_query (gint flags);
PhotosQuery *photos_query_builder_set_collection_query (const gchar *item_urn,
const gchar *collection_urn,
diff --git a/src/photos-tracker-collections-controller.c b/src/photos-tracker-collections-controller.c
index 9ad3984..67eaf74 100644
--- a/src/photos-tracker-collections-controller.c
+++ b/src/photos-tracker-collections-controller.c
@@ -41,7 +41,7 @@ photos_tracker_collections_controller_get_offset_controller (void)
static PhotosQuery *
photos_tracker_collections_controller_get_query (void)
{
- return photos_query_builder_global_collections_query ();
+ return photos_query_builder_global_query (PHOTOS_QUERY_FLAGS_COLLECTIONS);
}
diff --git a/src/photos-tracker-favorites-controller.c b/src/photos-tracker-favorites-controller.c
index 9289f53..46c7c80 100644
--- a/src/photos-tracker-favorites-controller.c
+++ b/src/photos-tracker-favorites-controller.c
@@ -1,6 +1,6 @@
/*
* Photos - access, organize and share your photos on GNOME
- * Copyright © 2012 Red Hat, Inc.
+ * Copyright © 2012, 2013 Red Hat, Inc.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
@@ -41,7 +41,7 @@ photos_tracker_favorites_controller_get_offset_controller (void)
static PhotosQuery *
photos_tracker_favorites_controller_get_query (void)
{
- return photos_query_builder_global_favorites_query ();
+ return photos_query_builder_global_query (PHOTOS_QUERY_FLAGS_FAVORITES);
}
diff --git a/src/photos-tracker-overview-controller.c b/src/photos-tracker-overview-controller.c
index c80023b..dbfb30c 100644
--- a/src/photos-tracker-overview-controller.c
+++ b/src/photos-tracker-overview-controller.c
@@ -1,6 +1,6 @@
/*
* Photos - access, organize and share your photos on GNOME
- * Copyright © 2012 Red Hat, Inc.
+ * Copyright © 2012, 2013 Red Hat, Inc.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
@@ -43,7 +43,7 @@ photos_tracker_overview_controller_get_offset_controller (void)
static PhotosQuery *
photos_tracker_overview_controller_get_query (void)
{
- return photos_query_builder_global_query ();
+ return photos_query_builder_global_query (PHOTOS_QUERY_FLAGS_NONE);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]