diff --git a/livesupport/modules/core/include/LiveSupport/Core/SearchCriteria.h b/livesupport/modules/core/include/LiveSupport/Core/SearchCriteria.h index 5e58b009d..c58fe19af 100644 --- a/livesupport/modules/core/include/LiveSupport/Core/SearchCriteria.h +++ b/livesupport/modules/core/include/LiveSupport/Core/SearchCriteria.h @@ -22,7 +22,7 @@ Author : $Author: fgerlits $ - Version : $Revision: 1.2 $ + Version : $Revision: 1.3 $ Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/core/include/LiveSupport/Core/SearchCriteria.h,v $ ------------------------------------------------------------------------------*/ @@ -44,6 +44,8 @@ #include #include +#include "LiveSupport/Core/Ptr.h" + // forward declaration of friend class namespace LiveSupport { namespace Storage { @@ -103,6 +105,13 @@ class SearchCriteria std::string key; std::string comparisonOperator; std::string value; + + SearchConditionType(const std::string & key, + const std::string & comparisonOperator, + const std::string & value) + : key(key), comparisonOperator(comparisonOperator), value(value) + { + } }; private: @@ -249,12 +258,12 @@ class SearchCriteria * @param condition the search condition to add */ void - addCondition(const SearchConditionType & condition) + addCondition(const Ptr::Ref condition) throw(std::invalid_argument) { - addCondition(condition.key, - condition.comparisonOperator, - condition.value); + addCondition(condition->key, + condition->comparisonOperator, + condition->value); } /** diff --git a/livesupport/modules/core/src/SearchCriteria.cxx b/livesupport/modules/core/src/SearchCriteria.cxx index 2f55e79a2..9485e1a94 100644 --- a/livesupport/modules/core/src/SearchCriteria.cxx +++ b/livesupport/modules/core/src/SearchCriteria.cxx @@ -22,7 +22,7 @@ Author : $Author: fgerlits $ - Version : $Revision: 1.1 $ + Version : $Revision: 1.2 $ Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/core/src/SearchCriteria.cxx,v $ ------------------------------------------------------------------------------*/ @@ -78,7 +78,7 @@ SearchCriteria :: addCondition(const std::string & key, || lowerCaseOp == "partial" || lowerCaseOp == "prefix" || lowerCaseOp == "<" || lowerCaseOp == "<=" || lowerCaseOp == ">" || lowerCaseOp == ">=") { - SearchConditionType condition = { key, lowerCaseOp, value }; + SearchConditionType condition(key, lowerCaseOp, value); searchConditions.push_back(condition); } else { throw std::invalid_argument("bad comparison operator argument"); diff --git a/livesupport/modules/widgets/etc/Makefile.in b/livesupport/modules/widgets/etc/Makefile.in index e55472779..82c066618 100644 --- a/livesupport/modules/widgets/etc/Makefile.in +++ b/livesupport/modules/widgets/etc/Makefile.in @@ -21,7 +21,7 @@ # # # Author : $Author: fgerlits $ -# Version : $Revision: 1.14 $ +# Version : $Revision: 1.15 $ # Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/widgets/etc/Makefile.in,v $ # # @configure_input@ @@ -121,6 +121,7 @@ WIDGETS_LIB_OBJS = ${TMP_DIR}/ImageButton.o \ ${TMP_DIR}/ZebraCellRenderer.o \ ${TMP_DIR}/Colors.o \ ${TMP_DIR}/MessageWindow.o \ + ${TMP_DIR}/AdvancedSearchItem.o \ ${TMP_DIR}/AdvancedSearchEntry.o TEST_EXE_OBJS = ${TMP_DIR}/TestWindow.o \ diff --git a/livesupport/modules/widgets/include/LiveSupport/Widgets/AdvancedSearchEntry.h b/livesupport/modules/widgets/include/LiveSupport/Widgets/AdvancedSearchEntry.h index cae91281c..4cc7b0cc4 100644 --- a/livesupport/modules/widgets/include/LiveSupport/Widgets/AdvancedSearchEntry.h +++ b/livesupport/modules/widgets/include/LiveSupport/Widgets/AdvancedSearchEntry.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/Attic/AdvancedSearchEntry.h,v $ ------------------------------------------------------------------------------*/ @@ -45,8 +45,6 @@ #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 { @@ -66,69 +64,18 @@ using namespace LiveSupport::Core; * A Gtk::VBox with one or more search input fields in it. * * @author $Author: fgerlits $ - * @version $Revision: 1.3 $ + * @version $Revision: 1.4 $ */ class AdvancedSearchEntry : public Gtk::VBox, public LocalizedObject { private: - /** - * The type for storing both the metadata and the comparison operator - * localizations. - */ - typedef std::vector > - MapVector; - - /** - * The list of possible metadata field names. - */ - Ptr::Ref metadataTypes; - - /** - * The list of possible comparison operators. - */ - Ptr::Ref operatorTypes; - - /** - * The metadata field. - */ - ComboBoxText * metadataEntry; - - /** - * The operator field. - */ - ComboBoxText * operatorEntry; - - /** - * The "search for this value" field. - */ - EntryBin * valueEntry; - /** * Default constructor. */ AdvancedSearchEntry(void) throw (); - /** - * Read the localized metadata field names. - * - * @exception std::invalid_argument if some keys are not found in - * the resource bundle - */ - void - readMetadataTypes(void) throw (std::invalid_argument); - - /** - * Read the localized comparison operator names. - * - * @exception std::invalid_argument if some keys are not found in - * the resource bundle - */ - void - readOperatorTypes(void) throw (std::invalid_argument); - - public: /** @@ -145,6 +92,12 @@ class AdvancedSearchEntry : public Gtk::VBox, { } + /** + * Add a new search condition entry item. + */ + void + onAddNewCondition(void) throw (); + /** * Return the current state of the search fields. * diff --git a/livesupport/modules/widgets/include/LiveSupport/Widgets/AdvancedSearchItem.h b/livesupport/modules/widgets/include/LiveSupport/Widgets/AdvancedSearchItem.h new file mode 100644 index 000000000..969fb0830 --- /dev/null +++ b/livesupport/modules/widgets/include/LiveSupport/Widgets/AdvancedSearchItem.h @@ -0,0 +1,210 @@ +/*------------------------------------------------------------------------------ + + 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/AdvancedSearchItem.h,v $ + +------------------------------------------------------------------------------*/ +#ifndef LiveSupport_Widgets_AdvancedSearchItem_h +#define LiveSupport_Widgets_AdvancedSearchItem_h + +#ifndef __cplusplus +#error This is a C++ include file +#endif + + +/* ============================================================ include files */ + +#ifdef HAVE_CONFIG_H +#include "configure.h" +#endif + +#include +#include + +#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" +#include "LiveSupport/Widgets/ImageButton.h" + + +namespace LiveSupport { +namespace Widgets { + +using namespace LiveSupport::Core; + +/* ================================================================ constants */ + + +/* =================================================================== macros */ + + +/* =============================================================== data types */ + +/** + * A single search input field. + * + * @author $Author: fgerlits $ + * @version $Revision: 1.1 $ + */ +class AdvancedSearchItem : public Gtk::HBox, + public LocalizedObject +{ + private: + + /** + * The type for storing both the metadata and the comparison operator + * localizations. + */ + typedef std::vector > + MapVector; + + /** + * The list of possible metadata field names. + */ + Ptr::Ref metadataTypes; + + /** + * The list of possible comparison operators. + */ + Ptr::Ref operatorTypes; + + /** + * The metadata field. + */ + ComboBoxText * metadataEntry; + + /** + * The operator field. + */ + ComboBoxText * operatorEntry; + + /** + * The "search for this value" field. + */ + EntryBin * valueEntry; + + /** + * The "add new search item" button. + */ + ImageButton * plusButton; + + /** + * The "remove this item" button. + */ + ImageButton * closeButton; + + /** + * Default constructor. + */ + AdvancedSearchItem(void) throw (); + + /** + * Read the localized metadata field names. + * + * @exception std::invalid_argument if some keys are not found in + * the resource bundle + */ + void + readMetadataTypes(void) throw (std::invalid_argument); + + /** + * Read the localized comparison operator names. + * + * @exception std::invalid_argument if some keys are not found in + * the resource bundle + */ + void + readOperatorTypes(void) throw (std::invalid_argument); + + + public: + + /** + * Constructor with localization parameter. + * + * @param isFirst true if this is the first search condition + * (so it does not need a Close button) + * @param bundle the resource bundle for localization + */ + AdvancedSearchItem(bool isFirst, + Ptr::Ref bundle) + throw (); + + /** + * A virtual destructor. + */ + virtual + ~AdvancedSearchItem(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 + getSearchCondition(void) throw (); + + /** + * The signal proxy for pressing enter in the entry field. + * + * @return the signal_activate() proxy of the EntryBin. + */ + Glib::SignalProxy0 + signal_activate(void) throw () + { + return valueEntry->signal_activate(); + } + + /** + * The signal proxy for pressing the add new condition button. + * + * @return the signal_activate() proxy of the Plus button. + */ + Glib::SignalProxy0 + signal_add_new(void) throw () + { + return plusButton->signal_clicked(); + } +}; + + +/* ================================================= external data structures */ + + +/* ====================================================== function prototypes */ + + +} // namespace Widgets +} // namespace LiveSupport + +#endif // LiveSupport_Widgets_AdvancedSearchItem_h + diff --git a/livesupport/modules/widgets/include/LiveSupport/Widgets/WidgetFactory.h b/livesupport/modules/widgets/include/LiveSupport/Widgets/WidgetFactory.h index 95f993e86..03b6bcd09 100644 --- a/livesupport/modules/widgets/include/LiveSupport/Widgets/WidgetFactory.h +++ b/livesupport/modules/widgets/include/LiveSupport/Widgets/WidgetFactory.h @@ -22,7 +22,7 @@ Author : $Author: fgerlits $ - Version : $Revision: 1.15 $ + Version : $Revision: 1.16 $ Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/widgets/include/LiveSupport/Widgets/WidgetFactory.h,v $ ------------------------------------------------------------------------------*/ @@ -89,7 +89,7 @@ class WhiteWindow; * * * @author $Author: fgerlits $ - * @version $Revision: 1.15 $ + * @version $Revision: 1.16 $ */ class WidgetFactory : virtual public Configurable @@ -103,7 +103,7 @@ class WidgetFactory : /** * The types of available image buttons. */ - typedef enum { deleteButton, + typedef enum { deleteButton, plusButton, smallPlayButton, smallPauseButton, smallStopButton, hugePlayButton, cuePlayButton, cueStopButton } diff --git a/livesupport/modules/widgets/src/AdvancedSearchEntry.cxx b/livesupport/modules/widgets/src/AdvancedSearchEntry.cxx index 176c86203..9fa79129e 100644 --- a/livesupport/modules/widgets/src/AdvancedSearchEntry.cxx +++ b/livesupport/modules/widgets/src/AdvancedSearchEntry.cxx @@ -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/src/Attic/AdvancedSearchEntry.cxx,v $ ------------------------------------------------------------------------------*/ @@ -35,7 +35,7 @@ #include -#include "LiveSupport/Widgets/WidgetFactory.h" +#include "LiveSupport/Widgets/AdvancedSearchItem.h" #include "LiveSupport/Widgets/AdvancedSearchEntry.h" @@ -60,45 +60,30 @@ using namespace LiveSupport::Widgets; 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); +{ + AdvancedSearchItem * searchOptionsBox = Gtk::manage(new + AdvancedSearchItem(true, getBundle()) ); pack_start(*searchOptionsBox, Gtk::PACK_SHRINK, 5); - Gtk::Label * searchByLabel; - try { - searchByLabel = Gtk::manage(new Gtk::Label( - *getResourceUstring("searchByTextLabel") )); - readMetadataTypes(); - readOperatorTypes(); + searchOptionsBox->signal_add_new().connect(sigc::mem_fun(*this, + &AdvancedSearchEntry::onAddNewCondition )); +} - } catch (std::invalid_argument &e) { - std::cerr << e.what() << std::endl; - std::exit(1); - } - - searchOptionsBox->pack_start(*searchByLabel, Gtk::PACK_SHRINK, 0); - metadataEntry = Gtk::manage(wf->createComboBoxText()); - MapVector::const_iterator it; - for (it = metadataTypes->begin(); it != metadataTypes->end(); ++it) { - metadataEntry->append_text(it->first); - } - metadataEntry->set_active_text(metadataTypes->front().first); - searchOptionsBox->pack_start(*metadataEntry, Gtk::PACK_EXPAND_WIDGET, 0); +/*------------------------------------------------------------------------------ + * Add a new search condition entrys item. + *----------------------------------------------------------------------------*/ +void +AdvancedSearchEntry :: onAddNewCondition(void) throw () +{ + AdvancedSearchItem * searchOptionsBox = Gtk::manage(new + AdvancedSearchItem(false, getBundle()) ); + pack_start(*searchOptionsBox, Gtk::PACK_SHRINK, 5); - operatorEntry = Gtk::manage(wf->createComboBoxText()); - for (it = operatorTypes->begin(); it != operatorTypes->end(); ++it) { - operatorEntry->append_text(it->first); - } - operatorEntry->set_active_text(operatorTypes->front().first); - searchOptionsBox->pack_start(*operatorEntry, Gtk::PACK_EXPAND_WIDGET, 0); - - valueEntry = Gtk::manage(wf->createEntryBin()); - searchOptionsBox->pack_start(*valueEntry, Gtk::PACK_EXPAND_WIDGET, 0); + searchOptionsBox->signal_add_new().connect(sigc::mem_fun(*this, + &AdvancedSearchEntry::onAddNewCondition )); + searchOptionsBox->show_all_children(); + searchOptionsBox->show(); } @@ -108,44 +93,17 @@ AdvancedSearchEntry :: AdvancedSearchEntry(Ptr::Ref bundle) Ptr::Ref AdvancedSearchEntry :: getSearchCriteria(void) throw () { - Ptr::Ref criteria(new SearchCriteria("all")); + Ptr::Ref criteria(new SearchCriteria("all", "and")); - std::string metadataName = metadataEntry->get_active_text(); - std::string metadataKey; - bool found = false; - MapVector::const_iterator it; - for (it = metadataTypes->begin(); it != metadataTypes->end(); ++it) { - if (it->first == metadataName) { - found = true; - metadataKey = it->second; - break; - } + Gtk::Box_Helpers::BoxList children = this->children(); + Gtk::Box_Helpers::BoxList::type_base::iterator it; + + for (it = children.begin(); it != children.end(); ++it) { + AdvancedSearchItem * child = dynamic_cast( + it->get_widget() ); + criteria->addCondition(child->getSearchCondition()); } - if (!found) { - std::cerr << "unknown metadata type: " << metadataName - << std::endl << "(this should never happen)" << std::endl; - std::exit(1); - } - - std::string operatorName = operatorEntry->get_active_text(); - std::string operatorKey; - found = false; - for (it = operatorTypes->begin(); it != operatorTypes->end(); ++it) { - if (it->first == operatorName) { - found = true; - operatorKey = it->second; - break; - } - } - if (!found) { - std::cerr << "unknown comparison operator: " << operatorName - << std::endl << "(this should never happen)" << std::endl; - std::exit(1); - } - - std::string value = valueEntry->get_text(); - - criteria->addCondition(metadataKey, operatorKey, value); + return criteria; } @@ -157,54 +115,13 @@ void AdvancedSearchEntry :: connectCallback(const sigc::slot & callback) throw () { - valueEntry->signal_activate().connect(callback); -} - - -/*------------------------------------------------------------------------------ - * Read the localized metadata field names. - *----------------------------------------------------------------------------*/ -void -AdvancedSearchEntry :: readMetadataTypes(void) - throw (std::invalid_argument) -{ - metadataTypes.reset(new MapVector); + Gtk::Box_Helpers::BoxList children = this->children(); + Gtk::Box_Helpers::BoxList::type_base::iterator it; - metadataTypes->push_back(std::make_pair( - *getResourceUstring("titleMetadataDisplay"), - *getResourceUstring("titleMetadataSearchKey") )); - metadataTypes->push_back(std::make_pair( - *getResourceUstring("creatorMetadataDisplay"), - *getResourceUstring("creatorMetadataSearchKey") )); - metadataTypes->push_back(std::make_pair( - *getResourceUstring("lengthMetadataDisplay"), - *getResourceUstring("lengthMetadataSearchKey") )); -} - - -/*------------------------------------------------------------------------------ - * Read the localized comparison operator names. - *----------------------------------------------------------------------------*/ -void -AdvancedSearchEntry :: readOperatorTypes(void) - throw (std::invalid_argument) -{ - operatorTypes.reset(new MapVector); - - operatorTypes->push_back(std::make_pair( - *getResourceUstring("partialOperatorDisplay"), - *getResourceUstring("partialOperatorSearchKey") )); - operatorTypes->push_back(std::make_pair( - *getResourceUstring("prefixOperatorDisplay"), - *getResourceUstring("prefixOperatorSearchKey") )); - operatorTypes->push_back(std::make_pair( - *getResourceUstring("=OperatorDisplay"), - *getResourceUstring("=OperatorSearchKey") )); - operatorTypes->push_back(std::make_pair( - *getResourceUstring("<=OperatorDisplay"), - *getResourceUstring("<=OperatorSearchKey") )); - operatorTypes->push_back(std::make_pair( - *getResourceUstring(">=OperatorDisplay"), - *getResourceUstring(">=OperatorSearchKey") )); + for (it = children.begin(); it != children.end(); ++it) { + AdvancedSearchItem * child = dynamic_cast( + it->get_widget() ); + child->signal_activate().connect(callback); + } } diff --git a/livesupport/modules/widgets/src/AdvancedSearchItem.cxx b/livesupport/modules/widgets/src/AdvancedSearchItem.cxx new file mode 100644 index 000000000..ab3b60d76 --- /dev/null +++ b/livesupport/modules/widgets/src/AdvancedSearchItem.cxx @@ -0,0 +1,217 @@ +/*------------------------------------------------------------------------------ + + 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/AdvancedSearchItem.cxx,v $ + +------------------------------------------------------------------------------*/ + +/* ============================================================ include files */ + +#ifdef HAVE_CONFIG_H +#include "configure.h" +#endif + +#include + +#include "LiveSupport/Widgets/WidgetFactory.h" + +#include "LiveSupport/Widgets/AdvancedSearchItem.h" + + +using namespace LiveSupport::Core; +using namespace LiveSupport::Widgets; + +/* =================================================== local data structures */ + + +/* ================================================ local constants & macros */ + + +/* =============================================== local function prototypes */ + + +/* ============================================================= module code */ + +/*------------------------------------------------------------------------------ + * Constructor. + *----------------------------------------------------------------------------*/ +AdvancedSearchItem :: AdvancedSearchItem(bool isFirst, + Ptr::Ref bundle) + throw () + : LocalizedObject(bundle) +{ + try { + if (!metadataTypes) { + readMetadataTypes(); + } + if (!operatorTypes) { + readOperatorTypes(); + } + } catch (std::invalid_argument &e) { + std::cerr << e.what() << std::endl; + std::exit(1); + } + + Ptr::Ref wf = WidgetFactory::getInstance(); + + Gtk::Label * searchByLabel; + try { + searchByLabel = Gtk::manage(new Gtk::Label( + *getResourceUstring("searchByTextLabel") )); + + } catch (std::invalid_argument &e) { + std::cerr << e.what() << std::endl; + std::exit(1); + } + + pack_start(*searchByLabel, Gtk::PACK_SHRINK, 5); + + metadataEntry = Gtk::manage(wf->createComboBoxText()); + MapVector::const_iterator it; + for (it = metadataTypes->begin(); it != metadataTypes->end(); ++it) { + metadataEntry->append_text(it->first); + } + metadataEntry->set_active_text(metadataTypes->front().first); + pack_start(*metadataEntry, Gtk::PACK_EXPAND_WIDGET, 5); + + operatorEntry = Gtk::manage(wf->createComboBoxText()); + for (it = operatorTypes->begin(); it != operatorTypes->end(); ++it) { + operatorEntry->append_text(it->first); + } + operatorEntry->set_active_text(operatorTypes->front().first); + pack_start(*operatorEntry, Gtk::PACK_EXPAND_WIDGET, 5); + + valueEntry = Gtk::manage(wf->createEntryBin()); + pack_start(*valueEntry, Gtk::PACK_EXPAND_WIDGET, 5); + + plusButton = Gtk::manage(wf->createButton(WidgetFactory::plusButton)); + pack_start(*plusButton, Gtk::PACK_SHRINK, 5); + + if (!isFirst) { + closeButton = Gtk::manage(wf->createButton(WidgetFactory::deleteButton)); + closeButton->signal_clicked().connect(sigc::mem_fun(*this, + &AdvancedSearchItem::destroy_ )); + pack_start(*closeButton, Gtk::PACK_SHRINK, 5); + } +} + + +/*------------------------------------------------------------------------------ + * Return the current state of the search fields. + *----------------------------------------------------------------------------*/ +Ptr::Ref +AdvancedSearchItem :: getSearchCondition(void) throw () +{ + std::string metadataName = metadataEntry->get_active_text(); + std::string metadataKey; + bool found = false; + MapVector::const_iterator it; + for (it = metadataTypes->begin(); it != metadataTypes->end(); ++it) { + if (it->first == metadataName) { + found = true; + metadataKey = it->second; + break; + } + } + if (!found) { + std::cerr << "unknown metadata type: " << metadataName + << std::endl << "(this should never happen)" << std::endl; + std::exit(1); + } + + std::string operatorName = operatorEntry->get_active_text(); + std::string operatorKey; + found = false; + for (it = operatorTypes->begin(); it != operatorTypes->end(); ++it) { + if (it->first == operatorName) { + found = true; + operatorKey = it->second; + break; + } + } + if (!found) { + std::cerr << "unknown comparison operator: " << operatorName + << std::endl << "(this should never happen)" << std::endl; + std::exit(1); + } + + std::string value = valueEntry->get_text(); + + Ptr::Ref + condition(new SearchCriteria::SearchConditionType(metadataKey, + operatorKey, + value) ); + + return condition; +} + + +/*------------------------------------------------------------------------------ + * Read the localized metadata field names. + *----------------------------------------------------------------------------*/ +void +AdvancedSearchItem :: readMetadataTypes(void) + throw (std::invalid_argument) +{ + metadataTypes.reset(new MapVector); + + metadataTypes->push_back(std::make_pair( + *getResourceUstring("titleMetadataDisplay"), + *getResourceUstring("titleMetadataSearchKey") )); + metadataTypes->push_back(std::make_pair( + *getResourceUstring("creatorMetadataDisplay"), + *getResourceUstring("creatorMetadataSearchKey") )); + metadataTypes->push_back(std::make_pair( + *getResourceUstring("lengthMetadataDisplay"), + *getResourceUstring("lengthMetadataSearchKey") )); +} + + +/*------------------------------------------------------------------------------ + * Read the localized comparison operator names. + *----------------------------------------------------------------------------*/ +void +AdvancedSearchItem :: readOperatorTypes(void) + throw (std::invalid_argument) +{ + operatorTypes.reset(new MapVector); + + operatorTypes->push_back(std::make_pair( + *getResourceUstring("partialOperatorDisplay"), + *getResourceUstring("partialOperatorSearchKey") )); + operatorTypes->push_back(std::make_pair( + *getResourceUstring("prefixOperatorDisplay"), + *getResourceUstring("prefixOperatorSearchKey") )); + operatorTypes->push_back(std::make_pair( + *getResourceUstring("=OperatorDisplay"), + *getResourceUstring("=OperatorSearchKey") )); + operatorTypes->push_back(std::make_pair( + *getResourceUstring("<=OperatorDisplay"), + *getResourceUstring("<=OperatorSearchKey") )); + operatorTypes->push_back(std::make_pair( + *getResourceUstring(">=OperatorDisplay"), + *getResourceUstring(">=OperatorSearchKey") )); +} + diff --git a/livesupport/modules/widgets/src/WidgetFactory.cxx b/livesupport/modules/widgets/src/WidgetFactory.cxx index b1018053f..2f5354815 100644 --- a/livesupport/modules/widgets/src/WidgetFactory.cxx +++ b/livesupport/modules/widgets/src/WidgetFactory.cxx @@ -22,7 +22,7 @@ Author : $Author: fgerlits $ - Version : $Revision: 1.17 $ + Version : $Revision: 1.18 $ Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/widgets/src/WidgetFactory.cxx,v $ ------------------------------------------------------------------------------*/ @@ -103,6 +103,16 @@ static const std::string deleteButtonPassiveName = "imageButton/delete.png"; */ static const std::string deleteButtonRollName = "imageButton/deleteRoll.png"; +/** + * The name of the passive image for the plus button. + */ +static const std::string plusButtonPassiveName = "imageButton/plus.png"; + +/** + * The name of the rollover image for the plus button. + */ +static const std::string plusButtonRollName = "imageButton/plusRoll.png"; + /** * The name of the passive image for the small play button. */ @@ -361,6 +371,11 @@ WidgetFactory :: createButton(ImageButtonType type) throw () rollImage = loadImage(deleteButtonRollName); break; + case plusButton: + passiveImage = loadImage(plusButtonPassiveName); + rollImage = loadImage(plusButtonRollName); + break; + case smallPlayButton: passiveImage = loadImage(smallPlayButtonPassiveName); rollImage = loadImage(smallPlayButtonRollName); diff --git a/livesupport/modules/widgets/var/imageButton/plus.png b/livesupport/modules/widgets/var/imageButton/plus.png new file mode 100644 index 000000000..1d38ca470 Binary files /dev/null and b/livesupport/modules/widgets/var/imageButton/plus.png differ diff --git a/livesupport/modules/widgets/var/imageButton/plusRoll.png b/livesupport/modules/widgets/var/imageButton/plusRoll.png new file mode 100644 index 000000000..ba4fea1ac Binary files /dev/null and b/livesupport/modules/widgets/var/imageButton/plusRoll.png differ diff --git a/livesupport/products/gLiveSupport/var/widgets/imageButton/plus.png b/livesupport/products/gLiveSupport/var/widgets/imageButton/plus.png new file mode 100644 index 000000000..1d38ca470 Binary files /dev/null and b/livesupport/products/gLiveSupport/var/widgets/imageButton/plus.png differ diff --git a/livesupport/products/gLiveSupport/var/widgets/imageButton/plusRoll.png b/livesupport/products/gLiveSupport/var/widgets/imageButton/plusRoll.png new file mode 100644 index 000000000..ba4fea1ac Binary files /dev/null and b/livesupport/products/gLiveSupport/var/widgets/imageButton/plusRoll.png differ