[solang] Tags can now have a description, again
- From: Debarshi Ray <debarshir src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [solang] Tags can now have a description, again
- Date: Fri, 22 Jan 2010 21:12:24 +0000 (UTC)
commit 59d266379d1d636f97b57fa9eeb13ba9814f9157
Author: Debarshi Ray <rishi gnu org>
Date: Mon Jan 18 23:48:48 2010 +0200
Tags can now have a description, again
Tags are now instances of nie:InformationElement too. The description
is represented by the nie:comment relation.
src/attribute/tag-manager.cpp | 4 ++-
src/attribute/tag-new-dialog.cpp | 18 ++++++++--------
src/attribute/tag.cpp | 40 +++++++++++++++++++++++++++----------
src/attribute/tag.h | 6 ++++-
src/common/database.cpp | 12 ++++++++--
src/common/database.h | 1 +
6 files changed, 56 insertions(+), 25 deletions(-)
---
diff --git a/src/attribute/tag-manager.cpp b/src/attribute/tag-manager.cpp
index 7be6789..2f3c6ec 100644
--- a/src/attribute/tag-manager.cpp
+++ b/src/attribute/tag-manager.cpp
@@ -249,7 +249,8 @@ TagManager::on_action_tag_new() throw()
{
case Gtk::RESPONSE_OK:
{
- TagPtr tag(new Tag(tag_new_dialog.get_name()));
+ TagPtr tag(new Tag(tag_new_dialog.get_name(),
+ tag_new_dialog.get_description()));
DatabasePtr db = application_->get_engine().get_db();
tag->save_async(
*db,
@@ -299,6 +300,7 @@ TagManager::on_action_tag_edit() throw()
DatabasePtr db = application_->get_engine().get_db();
tag->edit_async(
tag_new_dialog.get_name(),
+ tag_new_dialog.get_description(),
*db,
sigc::mem_fun(*this,
&TagManager::on_updated_tag));
diff --git a/src/attribute/tag-new-dialog.cpp b/src/attribute/tag-new-dialog.cpp
index 9f5abc3..dcc27ef 100644
--- a/src/attribute/tag-new-dialog.cpp
+++ b/src/attribute/tag-new-dialog.cpp
@@ -235,19 +235,19 @@ TagNewDialog::setup_gui() throw()
Gtk::FILL | Gtk::EXPAND,
0, 0);
-// mainTable_.attach(descriptionLabel_, 1, 2, 2, 3,
-// Gtk::FILL | Gtk::EXPAND,
-// Gtk::FILL | Gtk::EXPAND,
-// 0, 0);
+ mainTable_.attach(descriptionLabel_, 1, 2, 2, 3,
+ Gtk::FILL | Gtk::EXPAND,
+ Gtk::FILL | Gtk::EXPAND,
+ 0, 0);
descriptionScrolledWindow_.set_policy(Gtk::POLICY_AUTOMATIC,
Gtk::POLICY_AUTOMATIC);
-// mainTable_.attach(descriptionScrolledWindow_, 2, 3, 2, 3,
-// Gtk::FILL | Gtk::EXPAND,
-// Gtk::FILL | Gtk::EXPAND,
-// 0, 0);
+ mainTable_.attach(descriptionScrolledWindow_, 2, 3, 2, 3,
+ Gtk::FILL | Gtk::EXPAND,
+ Gtk::FILL | Gtk::EXPAND,
+ 0, 0);
-// descriptionScrolledWindow_.add(descriptionTextView_);
+ descriptionScrolledWindow_.add(descriptionTextView_);
add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL);
add_button(Gtk::Stock::OK, Gtk::RESPONSE_OK);
diff --git a/src/attribute/tag.cpp b/src/attribute/tag.cpp
index bf68ae9..2575e8e 100644
--- a/src/attribute/tag.cpp
+++ b/src/attribute/tag.cpp
@@ -30,11 +30,13 @@
namespace Solang
{
-Tag::Tag(const Glib::ustring & name, const std::string & urn)
- throw() :
+Tag::Tag(const Glib::ustring & name,
+ const Glib::ustring & description,
+ const std::string & urn) throw() :
DBObject(),
PhotoSearchCriteria(),
name_(name),
+ description_(description),
urn_(urn)
{
}
@@ -54,7 +56,7 @@ Glib::ustring
Tag::get_delete_query() const throw()
{
return Glib::ustring::compose("DELETE {"
- " <%1> a nao:Tag ."
+ " <%1> a rdfs:Resource ."
"}",
urn_);
}
@@ -70,16 +72,23 @@ Tag::get_save_query() const throw()
{
return Glib::ustring::compose("INSERT {"
" _:tag a nao:Tag ;"
- " nao:prefLabel '%1' ."
+ " nao:prefLabel '%1' ;"
+ " a nie:InformationElement ;"
+ " nie:comment '%2' ."
"} "
"WHERE {"
" OPTIONAL {"
" ?tag a nao:Tag ;"
- " nao:prefLabel '%2'"
+ " nao:prefLabel '%3' ;"
+ " a nie:InformationElement ;"
+ " nie:comment '%4' ."
" } ."
" FILTER (!bound(?tag)) "
"}",
- name_, name_);
+ name_,
+ description_,
+ name_,
+ description_);
}
void
@@ -91,22 +100,31 @@ Tag::save_async(Database & database, const SlotAsyncReady & slot)
void
Tag::edit_async(const Glib::ustring & name,
+ const Glib::ustring & description,
Database & database,
const SlotAsyncReady & slot) throw()
{
- database.edit_async(*this, name, slot);
+ database.edit_async(*this, name, description, slot);
}
Glib::ustring
-Tag::get_edit_query(const Glib::ustring & name) const throw()
+Tag::get_edit_query(const Glib::ustring & name,
+ const Glib::ustring & description) const throw()
{
return Glib::ustring::compose("DELETE {"
- " <%1> nao:prefLabel '%2' ."
+ " <%1> nao:prefLabel '%2' ;"
+ " nie:comment '%3' ."
"} "
"INSERT {"
- " <%3> nao:prefLabel '%4' ."
+ " <%4> nao:prefLabel '%5' ;"
+ " nie:comment '%6' ."
"}",
- urn_, name_, urn_, name);
+ urn_,
+ name_,
+ description_,
+ urn_,
+ name,
+ description);
}
void
diff --git a/src/attribute/tag.h b/src/attribute/tag.h
index ec78b53..6d02212 100644
--- a/src/attribute/tag.h
+++ b/src/attribute/tag.h
@@ -44,6 +44,7 @@ class Tag :
public:
Tag(const Glib::ustring & name,
+ const Glib::ustring & description,
const std::string & urn = std::string())
throw();
@@ -66,11 +67,14 @@ class Tag :
void
edit_async(const Glib::ustring & name,
+ const Glib::ustring & description,
Database & database,
const SlotAsyncReady & slot) throw();
Glib::ustring
- get_edit_query(const Glib::ustring & name) const throw();
+ get_edit_query(const Glib::ustring & name,
+ const Glib::ustring & description) const
+ throw();
inline const Glib::ustring &
get_name() const throw();
diff --git a/src/common/database.cpp b/src/common/database.cpp
index eb1e6ff..b1acbe9 100644
--- a/src/common/database.cpp
+++ b/src/common/database.cpp
@@ -108,13 +108,15 @@ Database::delete_async(const Tag & tag, const SlotAsyncReady & slot)
void
Database::edit_async(Tag & tag,
const Glib::ustring & name,
+ const Glib::ustring & description,
const SlotAsyncReady & slot) throw()
{
trackerClient_.sparql_update_async(
- tag.get_edit_query(name),
+ tag.get_edit_query(name, description),
sigc::bind(sigc::mem_fun(*this, &Database::on_async_ready),
slot));
tag.set_name(name);
+ tag.set_description(description);
}
void
@@ -278,10 +280,14 @@ void
Database::get_tags_async(const SlotAsyncTags & slot) const throw()
{
trackerClient_.sparql_query_async(
- "SELECT DISTINCT ?t ?u "
+ "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),
@@ -350,7 +356,7 @@ Database::on_async_tags(std::vector<UStringList> & result,
result.end() != it;
it++)
{
- TagPtr tag(new Tag((*it)[0], (*it)[1]));
+ TagPtr tag(new Tag((*it)[0], (*it)[1], (*it)[2]));
tags.push_back(tag);
}
diff --git a/src/common/database.h b/src/common/database.h
index 2624c18..9e65e70 100644
--- a/src/common/database.h
+++ b/src/common/database.h
@@ -65,6 +65,7 @@ class Database
void
edit_async(Tag & tag,
const Glib::ustring & name,
+ const Glib::ustring & description,
const SlotAsyncReady & slot) throw();
void
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]