From 0fc4dd64d6f84f1882ef9db49a060fbd7212cc21 Mon Sep 17 00:00:00 2001 From: fgerlits Date: Wed, 20 Apr 2005 14:36:54 +0000 Subject: [PATCH] moved SearchCriteria from Storage to Core; added get_text() function to Widgets/EntryBin; moved advanced search input box to Widgets; added (first, testing) functionality to search button in advanced search --- livesupport/modules/core/etc/Makefile.in | 10 +- .../LiveSupport/Core}/SearchCriteria.h | 20 ++- .../{storage => core}/src/SearchCriteria.cxx | 8 +- .../src/SearchCriteriaTest.cxx | 12 +- .../src/SearchCriteriaTest.h | 6 +- livesupport/modules/storage/etc/Makefile.in | 6 +- .../Storage/StorageClientInterface.h | 11 +- livesupport/modules/widgets/etc/Makefile.in | 8 +- .../LiveSupport/Widgets/AdvancedSearchEntry.h | 134 ++++++++++++++++ .../include/LiveSupport/Widgets/EntryBin.h | 15 +- .../widgets/src/AdvancedSearchEntry.cxx | 146 ++++++++++++++++++ .../gLiveSupport/src/SearchWindow.cxx | 61 +++----- .../products/gLiveSupport/src/SearchWindow.h | 23 ++- 13 files changed, 377 insertions(+), 83 deletions(-) rename livesupport/modules/{storage/include/LiveSupport/Storage => core/include/LiveSupport/Core}/SearchCriteria.h (95%) rename livesupport/modules/{storage => core}/src/SearchCriteria.cxx (96%) rename livesupport/modules/{storage => core}/src/SearchCriteriaTest.cxx (97%) rename livesupport/modules/{storage => core}/src/SearchCriteriaTest.h (96%) create mode 100644 livesupport/modules/widgets/include/LiveSupport/Widgets/AdvancedSearchEntry.h create mode 100644 livesupport/modules/widgets/src/AdvancedSearchEntry.cxx diff --git a/livesupport/modules/core/etc/Makefile.in b/livesupport/modules/core/etc/Makefile.in index c9e91235c..c0b091c8f 100644 --- a/livesupport/modules/core/etc/Makefile.in +++ b/livesupport/modules/core/etc/Makefile.in @@ -20,8 +20,8 @@ # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # # -# Author : $Author: maroy $ -# Version : $Revision: 1.26 $ +# Author : $Author: fgerlits $ +# Version : $Revision: 1.27 $ # Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/core/etc/Makefile.in,v $ # # @configure_input@ @@ -126,7 +126,8 @@ CORE_LIB_OBJS = ${TMP_DIR}/UniqueId.o \ ${TMP_DIR}/XmlRpcTools.o \ ${TMP_DIR}/XmlRpcException.o \ ${TMP_DIR}/TagConversion.o \ - ${TMP_DIR}/BaseTestMethod.o + ${TMP_DIR}/BaseTestMethod.o \ + ${TMP_DIR}/SearchCriteria.o TEST_RUNNER_OBJS = ${TMP_DIR}/TestRunner.o \ ${TMP_DIR}/UniqueIdTest.o \ @@ -141,7 +142,8 @@ TEST_RUNNER_OBJS = ${TMP_DIR}/TestRunner.o \ ${TMP_DIR}/LocalizedConfigurableTest.o \ ${TMP_DIR}/Md5Test.o \ ${TMP_DIR}/XmlRpcToolsTest.o \ - ${TMP_DIR}/TagConversionTest.o + ${TMP_DIR}/TagConversionTest.o \ + ${TMP_DIR}/SearchCriteriaTest.o TEST_RUNNER_RES = ${TMP_DIR}/${PACKAGE_NAME}_root.res \ ${TMP_DIR}/${PACKAGE_NAME}_en.res \ diff --git a/livesupport/modules/storage/include/LiveSupport/Storage/SearchCriteria.h b/livesupport/modules/core/include/LiveSupport/Core/SearchCriteria.h similarity index 95% rename from livesupport/modules/storage/include/LiveSupport/Storage/SearchCriteria.h rename to livesupport/modules/core/include/LiveSupport/Core/SearchCriteria.h index 72f496535..0bc2199c5 100644 --- a/livesupport/modules/storage/include/LiveSupport/Storage/SearchCriteria.h +++ b/livesupport/modules/core/include/LiveSupport/Core/SearchCriteria.h @@ -22,12 +22,12 @@ Author : $Author: fgerlits $ - Version : $Revision: 1.4 $ - Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/storage/include/LiveSupport/Storage/Attic/SearchCriteria.h,v $ + Version : $Revision: 1.1 $ + Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/core/include/LiveSupport/Core/SearchCriteria.h,v $ ------------------------------------------------------------------------------*/ -#ifndef LiveSupport_Storage_SearchCriteria_h -#define LiveSupport_Storage_SearchCriteria_h +#ifndef LiveSupport_Core_SearchCriteria_h +#define LiveSupport_Core_SearchCriteria_h #ifndef __cplusplus #error This is a C++ include file @@ -44,10 +44,14 @@ #include #include +// forward declaration of friend class namespace LiveSupport { namespace Storage { + class TestStorageClient; +} } -class TestStorageClient; // forward declaration of friend class +namespace LiveSupport { +namespace Core { /* ================================================================ constants */ @@ -150,7 +154,7 @@ class SearchCriteria /** * Give access of private members to the TestStorageClient. */ - friend class Storage::TestStorageClient; + friend class LiveSupport::Storage::TestStorageClient; public: @@ -283,8 +287,8 @@ class SearchCriteria /* ====================================================== function prototypes */ -} // namespace Storage +} // namespace Core } // namespace LiveSupport -#endif // LiveSupport_Storage_SearchCriteria_h +#endif // LiveSupport_Core_SearchCriteria_h diff --git a/livesupport/modules/storage/src/SearchCriteria.cxx b/livesupport/modules/core/src/SearchCriteria.cxx similarity index 96% rename from livesupport/modules/storage/src/SearchCriteria.cxx rename to livesupport/modules/core/src/SearchCriteria.cxx index fb258c224..2f55e79a2 100644 --- a/livesupport/modules/storage/src/SearchCriteria.cxx +++ b/livesupport/modules/core/src/SearchCriteria.cxx @@ -22,8 +22,8 @@ Author : $Author: fgerlits $ - Version : $Revision: 1.4 $ - Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/storage/src/Attic/SearchCriteria.cxx,v $ + Version : $Revision: 1.1 $ + Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/core/src/SearchCriteria.cxx,v $ ------------------------------------------------------------------------------*/ @@ -33,9 +33,9 @@ #include "configure.h" #endif -#include "LiveSupport/Storage/SearchCriteria.h" +#include "LiveSupport/Core/SearchCriteria.h" -using namespace LiveSupport::Storage; +using namespace LiveSupport::Core; /* =================================================== local data structures */ diff --git a/livesupport/modules/storage/src/SearchCriteriaTest.cxx b/livesupport/modules/core/src/SearchCriteriaTest.cxx similarity index 97% rename from livesupport/modules/storage/src/SearchCriteriaTest.cxx rename to livesupport/modules/core/src/SearchCriteriaTest.cxx index 32d31c665..30e98c71c 100644 --- a/livesupport/modules/storage/src/SearchCriteriaTest.cxx +++ b/livesupport/modules/core/src/SearchCriteriaTest.cxx @@ -22,17 +22,19 @@ Author : $Author: fgerlits $ - Version : $Revision: 1.2 $ - Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/storage/src/Attic/SearchCriteriaTest.cxx,v $ + Version : $Revision: 1.1 $ + Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/core/src/SearchCriteriaTest.cxx,v $ ------------------------------------------------------------------------------*/ /* ============================================================ include files */ -#include "LiveSupport/Storage/SearchCriteria.h" +#include + +#include "LiveSupport/Core/SearchCriteria.h" #include "SearchCriteriaTest.h" -using namespace LiveSupport::Storage; +using namespace LiveSupport::Core; /* =================================================== local data structures */ @@ -66,8 +68,6 @@ SearchCriteriaTest :: tearDown(void) throw () } -#include - /*------------------------------------------------------------------------------ * Test to see if we can do some simple operations *----------------------------------------------------------------------------*/ diff --git a/livesupport/modules/storage/src/SearchCriteriaTest.h b/livesupport/modules/core/src/SearchCriteriaTest.h similarity index 96% rename from livesupport/modules/storage/src/SearchCriteriaTest.h rename to livesupport/modules/core/src/SearchCriteriaTest.h index ba75fe582..7317b15e5 100644 --- a/livesupport/modules/storage/src/SearchCriteriaTest.h +++ b/livesupport/modules/core/src/SearchCriteriaTest.h @@ -23,7 +23,7 @@ Author : $Author: fgerlits $ Version : $Revision: 1.1 $ - Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/storage/src/Attic/SearchCriteriaTest.h,v $ + Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/core/src/SearchCriteriaTest.h,v $ ------------------------------------------------------------------------------*/ #ifndef SearchCriteriaTest_h @@ -44,7 +44,7 @@ namespace LiveSupport { -namespace Storage { +namespace Core { /* ================================================================ constants */ @@ -100,7 +100,7 @@ class SearchCriteriaTest : public CPPUNIT_NS::TestFixture /* ====================================================== function prototypes */ -} // namespace Storage +} // namespace Core } // namespace LiveSupport #endif // SearchCriteriaTest_h diff --git a/livesupport/modules/storage/etc/Makefile.in b/livesupport/modules/storage/etc/Makefile.in index e9bde9fec..d38974b8a 100644 --- a/livesupport/modules/storage/etc/Makefile.in +++ b/livesupport/modules/storage/etc/Makefile.in @@ -21,7 +21,7 @@ # # # Author : $Author: fgerlits $ -# Version : $Revision: 1.20 $ +# Version : $Revision: 1.21 $ # Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/storage/etc/Makefile.in,v $ # # @configure_input@ @@ -115,13 +115,11 @@ LDFLAGS = @LDFLAGS@ -pthread \ #------------------------------------------------------------------------------- # Dependencies #------------------------------------------------------------------------------- -STORAGE_LIB_OBJS = ${TMP_DIR}/SearchCriteria.o \ - ${TMP_DIR}/StorageClientFactory.o \ +STORAGE_LIB_OBJS = ${TMP_DIR}/StorageClientFactory.o \ ${TMP_DIR}/TestStorageClient.o \ ${TMP_DIR}/WebStorageClient.o TEST_RUNNER_OBJS = ${TMP_DIR}/TestRunner.o \ - ${TMP_DIR}/SearchCriteriaTest.o \ ${TMP_DIR}/StorageClientFactoryTest.o \ ${TMP_DIR}/TestStorageClientTest.o \ ${TMP_DIR}/WebStorageClientTest.o diff --git a/livesupport/modules/storage/include/LiveSupport/Storage/StorageClientInterface.h b/livesupport/modules/storage/include/LiveSupport/Storage/StorageClientInterface.h index 9c918f0d1..60aaf586c 100644 --- a/livesupport/modules/storage/include/LiveSupport/Storage/StorageClientInterface.h +++ b/livesupport/modules/storage/include/LiveSupport/Storage/StorageClientInterface.h @@ -21,8 +21,8 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - Author : $Author: maroy $ - Version : $Revision: 1.11 $ + Author : $Author: fgerlits $ + Version : $Revision: 1.12 $ Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/storage/include/LiveSupport/Storage/StorageClientInterface.h,v $ ------------------------------------------------------------------------------*/ @@ -46,8 +46,7 @@ #include "LiveSupport/Core/Playlist.h" #include "LiveSupport/Core/SessionId.h" #include "LiveSupport/Core/XmlRpcException.h" - -#include "LiveSupport/Storage/SearchCriteria.h" +#include "LiveSupport/Core/SearchCriteria.h" namespace LiveSupport { @@ -66,8 +65,8 @@ using namespace Core; /** * An interface for storage clients. * - * @author $Author: maroy $ - * @version $Revision: 1.11 $ + * @author $Author: fgerlits $ + * @version $Revision: 1.12 $ */ class StorageClientInterface { diff --git a/livesupport/modules/widgets/etc/Makefile.in b/livesupport/modules/widgets/etc/Makefile.in index e05c88321..e55472779 100644 --- a/livesupport/modules/widgets/etc/Makefile.in +++ b/livesupport/modules/widgets/etc/Makefile.in @@ -20,8 +20,8 @@ # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # # -# Author : $Author: maroy $ -# Version : $Revision: 1.13 $ +# Author : $Author: fgerlits $ +# Version : $Revision: 1.14 $ # Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/widgets/etc/Makefile.in,v $ # # @configure_input@ @@ -120,7 +120,9 @@ WIDGETS_LIB_OBJS = ${TMP_DIR}/ImageButton.o \ ${TMP_DIR}/ZebraTreeView.o \ ${TMP_DIR}/ZebraCellRenderer.o \ ${TMP_DIR}/Colors.o \ - ${TMP_DIR}/MessageWindow.o + ${TMP_DIR}/MessageWindow.o \ + ${TMP_DIR}/AdvancedSearchEntry.o + TEST_EXE_OBJS = ${TMP_DIR}/TestWindow.o \ ${TMP_DIR}/main.o diff --git a/livesupport/modules/widgets/include/LiveSupport/Widgets/AdvancedSearchEntry.h b/livesupport/modules/widgets/include/LiveSupport/Widgets/AdvancedSearchEntry.h new file mode 100644 index 000000000..3072713d8 --- /dev/null +++ b/livesupport/modules/widgets/include/LiveSupport/Widgets/AdvancedSearchEntry.h @@ -0,0 +1,134 @@ +/*------------------------------------------------------------------------------ + + Copyright (c) 2004 Media Development Loan Fund + + This file is part of the LiveSupport project. + http://livesupport.campware.org/ + To report bugs, send an e-mail to bugs@campware.org + + LiveSupport 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 2 of the License, or + (at your option) any later version. + + LiveSupport 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 LiveSupport; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + + + Author : $Author: fgerlits $ + Version : $Revision: 1.1 $ + Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/widgets/include/LiveSupport/Widgets/Attic/AdvancedSearchEntry.h,v $ + +------------------------------------------------------------------------------*/ +#ifndef LiveSupport_Widgets_AdvancedSearchEntry_h +#define LiveSupport_Widgets_AdvancedSearchEntry_h + +#ifndef __cplusplus +#error This is a C++ include file +#endif + + +/* ============================================================ include files */ + +#ifdef HAVE_CONFIG_H +#include "configure.h" +#endif + +#include + +#include "LiveSupport/Core/Ptr.h" +#include "LiveSupport/Core/LocalizedObject.h" +#include "LiveSupport/Core/SearchCriteria.h" +#include "LiveSupport/Widgets/ComboBoxText.h" +#include "LiveSupport/Widgets/EntryBin.h" + + +namespace LiveSupport { +namespace Widgets { + +using namespace LiveSupport::Core; + +/* ================================================================ constants */ + + +/* =================================================================== macros */ + + +/* =============================================================== data types */ + +/** + * A Gtk::VBox with one or more search input fields in it. + * + * @author $Author: fgerlits $ + * @version $Revision: 1.1 $ + */ +class AdvancedSearchEntry : public Gtk::VBox, + public LocalizedObject +{ + private: + + /** + * The metadata field. + */ + ComboBoxText * metadataType; + + /** + * The operator field. + */ + ComboBoxText * operatorType; + + /** + * The "search for this value" field. + */ + EntryBin * entryBin; + + /** + * Default constructor. + */ + AdvancedSearchEntry(void) throw (); + + + public: + + /** + * Constructor with localization parameter. + */ + AdvancedSearchEntry(Ptr::Ref bundle) + throw (); + + /** + * A virtual destructor. + */ + virtual + ~AdvancedSearchEntry(void) throw () + { + } + + /** + * Return the current state of the search fields. + * + * @return a new LiveSupport::Storage::SearchCriteria instance, + * which contains the data entered by the user + */ + Ptr::Ref + getSearchCriteria(void) throw (); +}; + + +/* ================================================= external data structures */ + + +/* ====================================================== function prototypes */ + + +} // namespace Widgets +} // namespace LiveSupport + +#endif // LiveSupport_Widgets_AdvancedSearchEntry_h + diff --git a/livesupport/modules/widgets/include/LiveSupport/Widgets/EntryBin.h b/livesupport/modules/widgets/include/LiveSupport/Widgets/EntryBin.h index 9b39bf406..ebee49db4 100644 --- a/livesupport/modules/widgets/include/LiveSupport/Widgets/EntryBin.h +++ b/livesupport/modules/widgets/include/LiveSupport/Widgets/EntryBin.h @@ -22,7 +22,7 @@ Author : $Author: fgerlits $ - Version : $Revision: 1.3 $ + Version : $Revision: 1.4 $ Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/widgets/include/LiveSupport/Widgets/EntryBin.h,v $ ------------------------------------------------------------------------------*/ @@ -65,7 +65,7 @@ using namespace LiveSupport::Core; * A container, holding a Gtk::Entry as its only child. * * @author $Author: fgerlits $ - * @version $Revision: 1.3 $ + * @version $Revision: 1.4 $ */ class EntryBin : public BlueBin { @@ -103,6 +103,17 @@ class EntryBin : public BlueBin { return entry; } + + /** + * Return the text of the entry. + * + * @return the get_text() string of the Gtk::Entry. + */ + Glib::ustring + get_text(void) throw () + { + return getEntry()->get_text(); + } }; diff --git a/livesupport/modules/widgets/src/AdvancedSearchEntry.cxx b/livesupport/modules/widgets/src/AdvancedSearchEntry.cxx new file mode 100644 index 000000000..f5f3fb61a --- /dev/null +++ b/livesupport/modules/widgets/src/AdvancedSearchEntry.cxx @@ -0,0 +1,146 @@ +/*------------------------------------------------------------------------------ + + Copyright (c) 2004 Media Development Loan Fund + + This file is part of the LiveSupport project. + http://livesupport.campware.org/ + To report bugs, send an e-mail to bugs@campware.org + + LiveSupport 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 2 of the License, or + (at your option) any later version. + + LiveSupport 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 LiveSupport; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + + + Author : $Author: fgerlits $ + Version : $Revision: 1.1 $ + Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/widgets/src/Attic/AdvancedSearchEntry.cxx,v $ + +------------------------------------------------------------------------------*/ + +/* ============================================================ include files */ + +#ifdef HAVE_CONFIG_H +#include "configure.h" +#endif + +#include + +#include "LiveSupport/Widgets/WidgetFactory.h" + +#include "LiveSupport/Widgets/AdvancedSearchEntry.h" + + +using namespace LiveSupport::Core; +using namespace LiveSupport::Widgets; + +/* =================================================== local data structures */ + + +/* ================================================ local constants & macros */ + + +/* =============================================== local function prototypes */ + + +/* ============================================================= module code */ + +/*------------------------------------------------------------------------------ + * Constructor. + *----------------------------------------------------------------------------*/ +AdvancedSearchEntry :: AdvancedSearchEntry(Ptr::Ref bundle) + throw () + : LocalizedObject(bundle) +{using namespace LiveSupport::Storage; + + Ptr::Ref wf = WidgetFactory::getInstance(); + + // only one option for now + Gtk::Box * searchOptionsBox = Gtk::manage(new Gtk::HBox); + pack_start(*searchOptionsBox, Gtk::PACK_SHRINK, 5); + + try { + Gtk::Label * searchByLabel = Gtk::manage(new Gtk::Label( + *getResourceUstring("searchByTextLabel") )); + searchOptionsBox->pack_start(*searchByLabel, Gtk::PACK_SHRINK, 0); + + } catch (std::invalid_argument &e) { + std::cerr << e.what() << std::endl; + std::exit(1); + } + metadataType = Gtk::manage(wf->createComboBoxText()); + metadataType->append_text("Title"); + metadataType->append_text("Creator"); + metadataType->append_text("Length"); + metadataType->set_active_text("Title"); + searchOptionsBox->pack_start(*metadataType, Gtk::PACK_EXPAND_WIDGET, 0); + + operatorType = Gtk::manage(wf->createComboBoxText()); + operatorType->append_text("contains"); + operatorType->append_text("starts with"); + operatorType->append_text("equals"); + operatorType->append_text(">="); + operatorType->append_text("<="); + operatorType->set_active_text("contains"); + searchOptionsBox->pack_start(*operatorType, Gtk::PACK_EXPAND_WIDGET, 0); + + entryBin = Gtk::manage(wf->createEntryBin()); + searchOptionsBox->pack_start(*entryBin, Gtk::PACK_EXPAND_WIDGET, 0); +} + + +/*------------------------------------------------------------------------------ + * Return the current state of the search fields. + *----------------------------------------------------------------------------*/ +Ptr::Ref +AdvancedSearchEntry :: getSearchCriteria(void) throw () +{ + Ptr::Ref criteria(new SearchCriteria("all")); + + std::string key; + if (metadataType->get_active_text() == "Title") { + key = "dc:title"; + } else if (metadataType->get_active_text() == "Creator") { + key = "dc:creator"; + } else if (metadataType->get_active_text() == "Length") { + key = "dcterms:extent"; + } else { + std::cerr << "unknown metadata type in advanced search entry" + << std::endl + << "(this should never happen)" << std::endl; + std::exit(1); + } + + std::string comparisonOperator; + if (operatorType->get_active_text() == "contains") { + comparisonOperator = "partial"; + } else if (operatorType->get_active_text() == "starts with") { + comparisonOperator = "prefix"; + } else if (operatorType->get_active_text() == "equals") { + comparisonOperator = "="; + } else if (operatorType->get_active_text() == ">=") { + comparisonOperator = ">="; + } else if (operatorType->get_active_text() == "<=") { + comparisonOperator = "<="; + } else { + std::cerr << "unknown comparison operator in advanced search entry" + << std::endl + << "(this should never happen)" << std::endl; + std::exit(1); + } + + std::string value = entryBin->get_text(); + + criteria->addCondition(key, comparisonOperator, value); + return criteria; +} + diff --git a/livesupport/products/gLiveSupport/src/SearchWindow.cxx b/livesupport/products/gLiveSupport/src/SearchWindow.cxx index a835bff12..3d9f07188 100644 --- a/livesupport/products/gLiveSupport/src/SearchWindow.cxx +++ b/livesupport/products/gLiveSupport/src/SearchWindow.cxx @@ -22,7 +22,7 @@ Author : $Author: fgerlits $ - Version : $Revision: 1.3 $ + Version : $Revision: 1.4 $ Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/gLiveSupport/src/SearchWindow.cxx,v $ ------------------------------------------------------------------------------*/ @@ -39,8 +39,7 @@ #include "LiveSupport/Widgets/WidgetFactory.h" #include "LiveSupport/Widgets/Notebook.h" #include "LiveSupport/Widgets/Button.h" -#include "LiveSupport/Widgets/ComboBoxText.h" -#include "LiveSupport/Widgets/EntryBin.h" +#include "LiveSupport/Widgets/AdvancedSearchEntry.h" #include "LiveSupport/Widgets/ZebraTreeView.h" #include "SearchWindow.h" @@ -121,49 +120,24 @@ SearchWindow :: constructAdvancedSearchView(void) throw () Ptr::Ref wf = WidgetFactory::getInstance(); // the three main components of the window - Gtk::Box * searchOptionsBox = Gtk::manage(new Gtk::HBox); + advancedSearchOptions = Gtk::manage(new AdvancedSearchEntry(getBundle())); Gtk::Box * searchButtonBox = Gtk::manage(new Gtk::HButtonBox( Gtk::BUTTONBOX_END )); - ZebraTreeView * searchResults = Gtk::manage(wf->createTreeView(treeModel)); + ZebraTreeView * searchResults = Gtk::manage(wf->createTreeView( + treeModel )); // make a new box, and pack the main components into it Gtk::VBox * view = Gtk::manage(new Gtk::VBox); - view->pack_start(*searchOptionsBox, Gtk::PACK_SHRINK, 5); - view->pack_start(*searchButtonBox, Gtk::PACK_SHRINK, 5); - view->pack_start(*searchResults, Gtk::PACK_SHRINK, 5); - - // set up the search options box - try { - Gtk::Label * searchByLabel = Gtk::manage(new Gtk::Label( - *getResourceUstring("searchByTextLabel") )); - searchOptionsBox->pack_start(*searchByLabel, Gtk::PACK_SHRINK, 5); - - } catch (std::invalid_argument &e) { - std::cerr << e.what() << std::endl; - std::exit(1); - } - ComboBoxText * metadataType = Gtk::manage(wf->createComboBoxText()); - metadataType->append_text("Title"); - metadataType->append_text("Creator"); - metadataType->append_text("Length"); - metadataType->set_active_text("Title"); - searchOptionsBox->pack_start(*metadataType, Gtk::PACK_EXPAND_WIDGET, 5); - - ComboBoxText * operatorType = Gtk::manage(wf->createComboBoxText()); - operatorType->append_text("contains"); - operatorType->append_text("equals"); - operatorType->append_text(">="); - operatorType->append_text("<"); - operatorType->set_active_text("contains"); - searchOptionsBox->pack_start(*operatorType, Gtk::PACK_EXPAND_WIDGET, 5); - - EntryBin * entryBin = Gtk::manage(wf->createEntryBin()); - searchOptionsBox->pack_start(*entryBin, Gtk::PACK_EXPAND_WIDGET, 5); + view->pack_start(*advancedSearchOptions, Gtk::PACK_SHRINK, 5); + view->pack_start(*searchButtonBox, Gtk::PACK_SHRINK, 5); + view->pack_start(*searchResults, Gtk::PACK_SHRINK, 5); // set up the search button box try { Button * searchButton = Gtk::manage(wf->createButton( *getResourceUstring("searchButtonLabel") )); + searchButton->signal_clicked().connect(sigc::mem_fun(*this, + &SearchWindow::onSearchButtonClicked)); searchButtonBox->pack_start(*searchButton, Gtk::PACK_SHRINK, 5); } catch (std::invalid_argument &e) { @@ -174,3 +148,18 @@ SearchWindow :: constructAdvancedSearchView(void) throw () return view; } + +#include + +/*------------------------------------------------------------------------------ + * Event handler for the Search button getting clicked + *----------------------------------------------------------------------------*/ +void +SearchWindow :: onSearchButtonClicked(void) throw () +{ + XmlRpc::XmlRpcValue xmlRpcValue(*advancedSearchOptions + ->getSearchCriteria()); + std::cerr << xmlRpcValue << std::endl; +} + + diff --git a/livesupport/products/gLiveSupport/src/SearchWindow.h b/livesupport/products/gLiveSupport/src/SearchWindow.h index 4fbab92ab..9780bc827 100644 --- a/livesupport/products/gLiveSupport/src/SearchWindow.h +++ b/livesupport/products/gLiveSupport/src/SearchWindow.h @@ -22,7 +22,7 @@ Author : $Author: fgerlits $ - Version : $Revision: 1.2 $ + Version : $Revision: 1.3 $ Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/gLiveSupport/src/SearchWindow.h,v $ ------------------------------------------------------------------------------*/ @@ -51,6 +51,7 @@ #include "LiveSupport/Widgets/WhiteWindow.h" #include "LiveSupport/Widgets/Button.h" #include "LiveSupport/Widgets/ZebraTreeModelColumnRecord.h" +#include "LiveSupport/Widgets/AdvancedSearchEntry.h" #include "GLiveSupport.h" namespace LiveSupport { @@ -72,29 +73,37 @@ using namespace LiveSupport::Widgets; * The Search/Browse window. * * @author $Author: fgerlits $ - * @version $Revision: 1.2 $ + * @version $Revision: 1.3 $ */ class SearchWindow : public WhiteWindow, public LocalizedObject { private: + /** + * The box containing the advanced search input fields. + */ + AdvancedSearchEntry * advancedSearchOptions; + /** * Construct the advanced search view. * * @return a pointer to the new box (already Gtk::manage()'ed) */ Gtk::VBox* - constructAdvancedSearchView(void) throw (); + constructAdvancedSearchView(void) throw (); - - protected: + /** + * Event handler for the Search button getting clicked. + */ + void + onSearchButtonClicked(void) throw (); /** * The columns model needed by Gtk::TreeView. * Lists one clip per row. * * @author $Author: fgerlits $ - * @version $Revision: 1.2 $ + * @version $Revision: 1.3 $ */ class ModelColumns : public ZebraTreeModelColumnRecord { @@ -137,7 +146,6 @@ class SearchWindow : public WhiteWindow, public LocalizedObject } }; - /** * The column model. */ @@ -153,6 +161,7 @@ class SearchWindow : public WhiteWindow, public LocalizedObject */ Ptr::Ref gLiveSupport; + public: /**