[solang] Added Tags -> Show All Tags
- From: Debarshi Ray <debarshir src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [solang] Added Tags -> Show All Tags
- Date: Sat, 3 Apr 2010 00:11:12 +0000 (UTC)
commit 9d1cade77b1842648bccfe7101e98258f064babf
Author: Debarshi Ray <rishi gnu org>
Date: Thu Apr 1 01:03:45 2010 +0300
Added Tags -> Show All Tags
Only those tags that are attached to photos or are attached to nothing
(because they maybe newly created) are listed by default.
data/solang-tag-manager.ui | 2 +
src/application/engine.cpp | 6 ++--
src/application/engine.h | 4 +-
src/attribute/tag-manager.cpp | 17 +++++++++++++-
src/attribute/tag-manager.h | 5 ++++
src/common/database.cpp | 49 +++++++++++++++++++++++++++++++----------
src/common/database.h | 3 +-
7 files changed, 67 insertions(+), 19 deletions(-)
---
diff --git a/data/solang-tag-manager.ui b/data/solang-tag-manager.ui
index 4f912ba..0d8fab5 100644
--- a/data/solang-tag-manager.ui
+++ b/data/solang-tag-manager.ui
@@ -10,6 +10,8 @@
<separator name="TagsSeparator1"/>
<menuitem action="ActionTagsAttach"/>
<menuitem action="ActionTagsRemove"/>
+ <separator name="TagsSeparator2"/>
+ <menuitem action="ActionTagsShowAll"/>
</menu>
</placeholder>
</menubar>
diff --git a/src/application/engine.cpp b/src/application/engine.cpp
index d334423..1a61c5d 100644
--- a/src/application/engine.cpp
+++ b/src/application/engine.cpp
@@ -90,10 +90,10 @@ Engine::erase(const PhotoList & photos)
}
void
-Engine::get_tags_async(const Database::SlotAsyncTags & slot) const
- throw()
+Engine::get_tags_async(bool all, const Database::SlotAsyncTags & slot)
+ const throw()
{
- database_.get_tags_async(slot);
+ database_.get_tags_async(all, slot);
}
DatePhotoInfoList
diff --git a/src/application/engine.h b/src/application/engine.h
index 9f113d7..f377d24 100644
--- a/src/application/engine.h
+++ b/src/application/engine.h
@@ -65,8 +65,8 @@ class Engine :
erase(const PhotoList & photos);
void
- get_tags_async(const Database::SlotAsyncTags & slot) const
- throw();
+ get_tags_async(bool all, const Database::SlotAsyncTags & slot)
+ const throw();
//Group by year
DatePhotoInfoList
diff --git a/src/attribute/tag-manager.cpp b/src/attribute/tag-manager.cpp
index 2e5f79c..5d5e0f8 100644
--- a/src/attribute/tag-manager.cpp
+++ b/src/attribute/tag-manager.cpp
@@ -57,6 +57,7 @@ TagManager::TagManager() throw() :
vBox_( false, 6 ),
scrolledWindow_(),
tagView_( ),
+ showAll_(false),
signalRendererChanged_()
{
Gtk::IconSource icon_source;
@@ -138,6 +139,12 @@ TagManager::TagManager() throw() :
Gtk::AccelKey(""),
sigc::mem_fun(*this, &TagManager::on_action_remove_tag));
+ actionGroup_->add(
+ Gtk::ToggleAction::create("ActionTagsShowAll",
+ _("_Show All Tags")),
+ Gtk::AccelKey(""),
+ sigc::mem_fun(*this, &TagManager::on_action_show_all_tags));
+
scrolledWindow_.set_policy(Gtk::POLICY_AUTOMATIC,
Gtk::POLICY_AUTOMATIC);
scrolledWindow_.set_shadow_type(Gtk::SHADOW_IN);
@@ -423,6 +430,13 @@ TagManager::on_action_remove_tag() throw()
}
void
+TagManager::on_action_show_all_tags() throw()
+{
+ showAll_ = !showAll_;
+ populate_view();
+}
+
+void
TagManager::on_get_tags(TagList & tags) throw()
{
tagView_.populate(tags);
@@ -451,7 +465,8 @@ void
TagManager::populate_view() throw()
{
Engine & engine = application_->get_engine();
- engine.get_tags_async(sigc::mem_fun(
+ engine.get_tags_async(showAll_,
+ sigc::mem_fun(
*this,
&TagManager::on_get_tags));
}
diff --git a/src/attribute/tag-manager.h b/src/attribute/tag-manager.h
index d50d2c9..07f3993 100644
--- a/src/attribute/tag-manager.h
+++ b/src/attribute/tag-manager.h
@@ -75,6 +75,9 @@ class TagManager :
on_action_remove_tag() throw();
void
+ on_action_show_all_tags() throw();
+
+ void
on_get_tags(TagList & tags) throw();
void
@@ -115,6 +118,8 @@ class TagManager :
TagView tagView_;
+ bool showAll_;
+
sigc::connection signalRendererChanged_;
private:
diff --git a/src/common/database.cpp b/src/common/database.cpp
index 552e034..9afda4f 100644
--- a/src/common/database.cpp
+++ b/src/common/database.cpp
@@ -248,20 +248,45 @@ Database::get_dates_with_picture_count(const Glib::ustring & sql)
}
void
-Database::get_tags_async(const SlotAsyncTags & slot) const throw()
+Database::get_tags_async(bool all, const SlotAsyncTags & slot) const
+ throw()
{
+ std::ostringstream sout;
+ sout << "SELECT ";
+
+ if (false == all)
+ {
+ sout << "DISTINCT ";
+ }
+
+ sout << "nao:prefLabel(?tag) as ?label ?desc ?tag "
+ "WHERE {"
+ " ?tag a nao:Tag ."
+ " OPTIONAL {"
+ " ?tag a nie:InformationElement ;"
+ " nie:comment ?desc ."
+ " }";
+
+ if (false == all)
+ {
+ sout << " OPTIONAL {"
+ " ?photo a nmm:Photo ;"
+ " nao:hasTag ?tag ."
+ " }"
+ " FILTER ("
+ " (SELECT COUNT(?u) WHERE {"
+ " ?u nao:hasTag ?tag}) = 0"
+ " || BOUND(?photo)"
+ " )";
+ }
+
+ sout << "} "
+ "ORDER BY ASC (?label)";
+
trackerClient_.sparql_query_async(
- "SELECT DISTINCT ?t ?d ?u "
- "WHERE {"
- " ?u a nao:Tag ;"
- " nao:prefLabel ?t ."
- " OPTIONAL {"
- " ?u a nie:InformationElement ;"
- " nie:comment ?d ."
- " }"
- "} "
- "ORDER BY ASC(?t)",
- sigc::bind(sigc::mem_fun(*this, &Database::on_async_tags),
+ sout.str(),
+ sigc::bind(sigc::mem_fun(*this,
+ &Database::on_async_tags),
slot));
}
diff --git a/src/common/database.h b/src/common/database.h
index 498bf4c..5d022fa 100644
--- a/src/common/database.h
+++ b/src/common/database.h
@@ -102,7 +102,8 @@ class Database
get_dates_with_picture_count(gint year, gint month);
void
- get_tags_async(const SlotAsyncTags & slot) const throw();
+ get_tags_async(bool all, const SlotAsyncTags & slot) const
+ throw();
private:
DatePhotoInfoList
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]