[solang] Tags can now be removed from photos, again
- From: Debarshi Ray <debarshir src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [solang] Tags can now be removed from photos, again
- Date: Wed, 13 Jan 2010 17:09:18 +0000 (UTC)
commit a582f948f85b412f7e32f048214f2ae3f3c4bf01
Author: Debarshi Ray <rishi gnu org>
Date: Tue Dec 29 15:11:59 2009 +0200
Tags can now be removed from photos, again
src/attribute/photo-tag.cpp | 10 ++++++++-
src/attribute/tag-manager.cpp | 45 +++++++++++++++++-----------------------
src/common/database.cpp | 10 +++++++++
src/common/database.h | 4 +++
4 files changed, 42 insertions(+), 27 deletions(-)
---
diff --git a/src/attribute/photo-tag.cpp b/src/attribute/photo-tag.cpp
index 53e5472..8c754c2 100644
--- a/src/attribute/photo-tag.cpp
+++ b/src/attribute/photo-tag.cpp
@@ -41,12 +41,20 @@ void
PhotoTag::delete_async(Database & database,
const SlotAsyncReady & slot) const throw()
{
+ database.delete_async(*this, slot);
}
Glib::ustring
PhotoTag::get_delete_query() const throw()
{
- return Glib::ustring();
+ return Glib::ustring::compose("DELETE {"
+ " ?photo nao:hasTag <%1> ."
+ "}"
+ "WHERE {"
+ " ?photo nie:isStoredAs ?data ."
+ " ?data nie:url '%2' ."
+ "}",
+ tag_->get_urn(), photo_->get_uri());
}
Glib::ustring
diff --git a/src/attribute/tag-manager.cpp b/src/attribute/tag-manager.cpp
index f09ba22..26fabc5 100644
--- a/src/attribute/tag-manager.cpp
+++ b/src/attribute/tag-manager.cpp
@@ -26,8 +26,6 @@
#include "application.h"
#include "browser-renderer.h"
#include "console-renderer.h"
-#include "delete-action.h"
-#include "deletion-queue.h"
#include "editor-renderer.h"
#include "engine.h"
#include "enlarged-renderer.h"
@@ -395,40 +393,35 @@ TagManager::on_action_apply_tag() throw()
void
TagManager::on_action_remove_tag() throw()
{
-/* Glib::RefPtr<Gtk::TreeSelection> selected
+ Glib::RefPtr<Gtk::TreeSelection> selected
= tagView_.get_selection();
+ Gtk::TreeModel::iterator item = selected->get_selected();
- if( 0 == selected->count_selected_rows() )
+ if (false == item)
+ {
return;
+ }
- Gtk::TreeModel::iterator item = selected->get_selected();
const TagViewModelColumnRecord &rec
= tagView_.get_column_records();
- if( item != selected->get_model()->children().end() )
- {
- Gtk::TreeModel::Row row= (*item);
- TagPtr tag = row[ rec.get_column_tag() ];
+ Gtk::TreeModel::Row row= (*item);
+ TagPtr tag = row[ rec.get_column_tag() ];
- if( Tag::ALL_PHOTOS_TAGID == tag->get_tag_id() )
- return;
+ RendererRegistry & renderer_registry
+ = application_->get_renderer_registry();
+ const IRendererPtr renderer = renderer_registry.get_current();
- RendererRegistry & renderer_registry
- = application_->get_renderer_registry();
- const IRendererPtr renderer = renderer_registry.get_current();
- PhotoList photos = renderer->get_current_selection();
- DeletionQueue &queue
- = application_->get_engine().get_delete_actions();
+ const DatabasePtr db = application_->get_engine().get_db();
+ PhotoList photos = renderer->get_current_selection();
- for( PhotoList::iterator it = photos.begin();
- it != photos.end(); it++ )
- {
- PhotoTag photoTag( (*it)->get_photo_id(),
- tag->get_tag_id() );
- DeleteActionPtr action = photoTag.get_delete_action();
- queue.schedule_delete_action( action );
- }
- }*/
+ for (PhotoList::const_iterator photos_iter = photos.begin();
+ photos.end() != photos_iter;
+ photos_iter++)
+ {
+ PhotoTag photo_tag(*photos_iter, tag);
+ photo_tag.delete_async(*db, sigc::slot<void>());
+ }
return;
}
diff --git a/src/common/database.cpp b/src/common/database.cpp
index a17dc1e..eb1e6ff 100644
--- a/src/common/database.cpp
+++ b/src/common/database.cpp
@@ -86,6 +86,16 @@ Database::get_exif_data_async(const Photo & photo,
}
void
+Database::delete_async(const PhotoTag & photo_tag,
+ const SlotAsyncReady & slot) throw()
+{
+ trackerClient_.sparql_update_async(
+ photo_tag.get_delete_query(),
+ sigc::bind(sigc::mem_fun(*this, &Database::on_async_ready),
+ slot));
+}
+
+void
Database::delete_async(const Tag & tag, const SlotAsyncReady & slot)
throw()
{
diff --git a/src/common/database.h b/src/common/database.h
index cfdff3b..2624c18 100644
--- a/src/common/database.h
+++ b/src/common/database.h
@@ -55,6 +55,10 @@ class Database
~Database();
void
+ delete_async(const PhotoTag & photo_tag,
+ const SlotAsyncReady & slot) throw();
+
+ void
delete_async(const Tag & tag, const SlotAsyncReady & slot)
throw();
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]