[gnome-photos/wip/favorites: 3/15] query-builder: Add a new flag and queries for the Favorites mode
- From: Debarshi Ray <debarshir src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-photos/wip/favorites: 3/15] query-builder: Add a new flag and queries for the Favorites mode
- Date: Fri, 14 Dec 2012 06:28:51 +0000 (UTC)
commit b0471261361c7cc3a3101491a185faaff4495877
Author: Debarshi Ray <debarshir gnome org>
Date: Wed Dec 12 23:07:15 2012 +0530
query-builder: Add a new flag and queries for the Favorites mode
src/photos-query-builder.c | 36 +++++++++++++++++++++++++++++++++++-
src/photos-query-builder.h | 4 ++++
src/photos-query.h | 3 ++-
3 files changed, 41 insertions(+), 2 deletions(-)
---
diff --git a/src/photos-query-builder.c b/src/photos-query-builder.c
index 804bcc1..2dcf571 100644
--- a/src/photos-query-builder.c
+++ b/src/photos-query-builder.c
@@ -96,7 +96,10 @@ photos_query_builder_query (gboolean global, gint flags)
gchar *where_sparql;
optional = photos_query_builder_optional ();
- where_sparql = g_strconcat ("WHERE { ?urn a rdfs:Resource ", optional, NULL);
+ if (flags & PHOTOS_QUERY_FLAGS_FAVORITES)
+ where_sparql = g_strconcat ("WHERE { ?urn nao:hasTag nao:predefined-tag-favorite ", optional, NULL);
+ else
+ where_sparql = g_strconcat ("WHERE { ?urn a rdfs:Resource ", optional, NULL);
g_free (optional);
if (!(flags & PHOTOS_QUERY_FLAGS_UNFILTERED))
@@ -154,6 +157,27 @@ photos_query_builder_query (gboolean global, gint flags)
PhotosQuery *
+photos_query_builder_count_favorites_query (void)
+{
+ gchar *filter;
+ gchar *optional;
+ gchar *sparql;
+
+ filter = photos_query_builder_filter ();
+ optional = photos_query_builder_optional ();
+ sparql = g_strconcat ("SELECT DISTINCT COUNT(?urn) WHERE { ?urn nao:hasTag nao:predefined-tag-favorite ",
+ optional,
+ filter,
+ " }", NULL);
+
+ g_free (optional);
+ g_free (filter);
+
+ return photos_query_new (sparql);
+}
+
+
+PhotosQuery *
photos_query_builder_count_query (void)
{
gchar *filter;
@@ -172,6 +196,16 @@ photos_query_builder_count_query (void)
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)
{
gchar *sparql;
diff --git a/src/photos-query-builder.h b/src/photos-query-builder.h
index 886c72f..46ae8aa 100644
--- a/src/photos-query-builder.h
+++ b/src/photos-query-builder.h
@@ -31,8 +31,12 @@
G_BEGIN_DECLS
+PhotosQuery *photos_query_builder_count_favorites_query (void);
+
PhotosQuery *photos_query_builder_count_query (void);
+PhotosQuery *photos_query_builder_global_favorites_query (void);
+
PhotosQuery *photos_query_builder_global_query (void);
PhotosQuery *photos_query_builder_single_query (gint flags, const gchar *resource);
diff --git a/src/photos-query.h b/src/photos-query.h
index 1aac9a5..5d21452 100644
--- a/src/photos-query.h
+++ b/src/photos-query.h
@@ -52,7 +52,8 @@ typedef enum
typedef enum
{
PHOTOS_QUERY_FLAGS_NONE = 0,
- PHOTOS_QUERY_FLAGS_UNFILTERED = 1 << 0
+ PHOTOS_QUERY_FLAGS_UNFILTERED = 1 << 0,
+ PHOTOS_QUERY_FLAGS_FAVORITES = 1 << 1
} PhotosQueryFlags;
typedef struct _PhotosQuery PhotosQuery;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]