[solang] Basic free text search
- From: Debarshi Ray <debarshir src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [solang] Basic free text search
- Date: Sat, 30 Jan 2010 15:02:55 +0000 (UTC)
commit 3c6a2f8ef05a2f8d6f50fb6c4e1f2c1544e72a27
Author: Debarshi Ray <rishi gnu org>
Date: Fri Jan 29 02:04:07 2010 +0200
Basic free text search
Search for photos having a user-specified string in their URI.
src/attribute/Makefile.am | 2 +
src/attribute/free-text.cpp | 77 ++++++++++++++++++++++++++++++++++++++
src/attribute/free-text.h | 62 ++++++++++++++++++++++++++++++
src/attribute/search-manager.cpp | 31 +++++++++++++++
src/attribute/search-manager.h | 5 ++
5 files changed, 177 insertions(+), 0 deletions(-)
---
diff --git a/src/attribute/Makefile.am b/src/attribute/Makefile.am
index d146c7d..1662b05 100644
--- a/src/attribute/Makefile.am
+++ b/src/attribute/Makefile.am
@@ -13,6 +13,8 @@ libattribute_la_SOURCES = \
date-view-model-column-record.h \
date-view.cpp \
date-view.h \
+ free-text.cpp \
+ free-text.h \
modification-date.cpp \
modification-date.h \
photo-tag.cpp \
diff --git a/src/attribute/free-text.cpp b/src/attribute/free-text.cpp
new file mode 100644
index 0000000..b493c7e
--- /dev/null
+++ b/src/attribute/free-text.cpp
@@ -0,0 +1,77 @@
+/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */
+/*
+ * Copyright (C) 2010 Debarshi Ray <rishi gnu org>
+ *
+ * Solang is free software: you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the
+ * Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Solang is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ * See the GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif // HAVE_CONFIG_H
+
+#include "id-base.h"
+#include "free-text.h"
+
+namespace Solang
+{
+
+FreeText::FreeText(const Glib::ustring & text) throw() :
+ IPhotoSearchCriteria(),
+ text_(text)
+{
+}
+
+FreeText::~FreeText() throw()
+{
+}
+
+Glib::ustring
+FreeText::get_query_criteria() const throw()
+{
+ return Glib::ustring::compose("nie:url ?url . "
+ "FILTER REGEX (?url, '%1', 'i')",
+ text_);
+}
+
+const Glib::ustring &
+FreeText::get_text() const throw()
+{
+ return text_;
+}
+
+IPhotoSearchCriteria::ClubbingOperationType
+FreeText::get_clubbing_type() const throw()
+{
+ return IPhotoSearchCriteria::CLUB_AND;
+}
+
+gint32
+FreeText::get_id() const throw()
+{
+ return IDBase<FreeText>::get_id();
+}
+
+Glib::ustring
+FreeText::get_criteria_description() const throw()
+{
+ return "Text: " + get_text();
+}
+
+Glib::ustring
+FreeText::get_criteria_icon_path() const throw()
+{
+ return Glib::ustring();
+}
+
+} // namespace Solang
diff --git a/src/attribute/free-text.h b/src/attribute/free-text.h
new file mode 100644
index 0000000..c51c405
--- /dev/null
+++ b/src/attribute/free-text.h
@@ -0,0 +1,62 @@
+/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */
+/*
+ * Copyright (C) 2010 Debarshi Ray <rishi gnu org>
+ *
+ * Solang is free software: you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the
+ * Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Solang is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ * See the GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef SOLANG_FREE_TEXT_H
+#define SOLANG_FREE_TEXT_H
+
+#include <glibmm.h>
+
+#include "i-photo-search-criteria.h"
+
+namespace Solang
+{
+
+class FreeText :
+ public IPhotoSearchCriteria
+{
+ private:
+ Glib::ustring text_;
+
+ public:
+ FreeText(const Glib::ustring & text) throw();
+
+ virtual
+ ~FreeText() throw();
+
+ virtual Glib::ustring
+ get_query_criteria() const throw();
+
+ virtual ClubbingOperationType
+ get_clubbing_type() const throw();
+
+ virtual gint32
+ get_id() const throw();
+
+ virtual Glib::ustring
+ get_criteria_description() const throw();
+
+ virtual Glib::ustring
+ get_criteria_icon_path() const throw();
+
+ const Glib::ustring &
+ get_text() const throw();
+};
+
+} // namespace Solang
+
+#endif // SOLANG_FREE_TEXT_H
diff --git a/src/attribute/search-manager.cpp b/src/attribute/search-manager.cpp
index 116a282..b13fd43 100644
--- a/src/attribute/search-manager.cpp
+++ b/src/attribute/search-manager.cpp
@@ -29,6 +29,7 @@
#include "browser-renderer.h"
#include "engine.h"
#include "enlarged-renderer.h"
+#include "free-text.h"
#include "main-window.h"
#include "search-basket-column-record.h"
#include "search-manager.h"
@@ -53,6 +54,7 @@ SearchManager::SearchManager() throw() :
dockItemBehaviour_(GDL_DOCK_ITEM_BEH_NORMAL),
dockItem_(NULL),
vBox_( false, 6 ),
+ entry_(),
scrolledWindow_(),
listStore_(Gtk::ListStore::create(SearchBasketColumnRecord())),
searchBasket_(listStore_),
@@ -81,6 +83,8 @@ SearchManager::SearchManager() throw() :
&SearchManager::on_action_remove_selected));
}
+ vBox_.pack_start(entry_, Gtk::PACK_SHRINK, 0);
+
scrolledWindow_.set_policy(Gtk::POLICY_AUTOMATIC,
Gtk::POLICY_AUTOMATIC);
@@ -104,6 +108,9 @@ SearchManager::SearchManager() throw() :
vBox_.pack_start( scrolledWindow_, Gtk::PACK_EXPAND_WIDGET,0 );
+ entry_.signal_changed().connect(
+ sigc::mem_fun(*this, &SearchManager::on_entry_changed));
+
std::vector<Gtk::TargetEntry> targets;
targets.push_back(Gtk::TargetEntry("STRING",
Gtk::TARGET_SAME_APP, 0));
@@ -239,6 +246,22 @@ SearchManager::on_drag_data_received(
}
void
+SearchManager::on_entry_changed() throw()
+{
+ static sigc::connection connection;
+
+ connection.disconnect();
+
+ connection
+ = Glib::signal_timeout().connect_seconds(
+ sigc::bind_return(
+ sigc::mem_fun(*this,
+ &SearchManager::apply_criterion),
+ false),
+ 1, Glib::PRIORITY_DEFAULT);
+}
+
+void
SearchManager::on_renderer_changed(
RendererRegistry & renderer_registry) throw()
{
@@ -334,6 +357,14 @@ SearchManager::get_criterion(
= row[ model_column_record.get_column_criteria()];
criterion.push_back( tag );
}
+
+ if (0 != entry_.get_text_length())
+ {
+ const IPhotoSearchCriteriaPtr free_text(
+ new FreeText(entry_.get_text()));
+ criterion.push_back(free_text);
+ }
+
return;
}
diff --git a/src/attribute/search-manager.h b/src/attribute/search-manager.h
index 19867f1..b11b090 100644
--- a/src/attribute/search-manager.h
+++ b/src/attribute/search-manager.h
@@ -88,6 +88,9 @@ class SearchManager :
guint info, guint time) throw();
void
+ on_entry_changed() throw();
+
+ void
on_renderer_changed(RendererRegistry & renderer_registry)
throw();
@@ -114,6 +117,8 @@ class SearchManager :
Gtk::VBox vBox_;
+ Gtk::Entry entry_;
+
Gtk::ScrolledWindow scrolledWindow_;
ListStorePtr listStore_;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]