added multiple input lines in advanced search
This commit is contained in:
parent
51da1904c7
commit
79caff8787
13 changed files with 509 additions and 187 deletions
|
@ -22,7 +22,7 @@
|
||||||
|
|
||||||
|
|
||||||
Author : $Author: fgerlits $
|
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 $
|
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/core/include/LiveSupport/Core/SearchCriteria.h,v $
|
||||||
|
|
||||||
------------------------------------------------------------------------------*/
|
------------------------------------------------------------------------------*/
|
||||||
|
@ -44,6 +44,8 @@
|
||||||
#include <cctype>
|
#include <cctype>
|
||||||
#include <XmlRpcValue.h>
|
#include <XmlRpcValue.h>
|
||||||
|
|
||||||
|
#include "LiveSupport/Core/Ptr.h"
|
||||||
|
|
||||||
// forward declaration of friend class
|
// forward declaration of friend class
|
||||||
namespace LiveSupport {
|
namespace LiveSupport {
|
||||||
namespace Storage {
|
namespace Storage {
|
||||||
|
@ -103,6 +105,13 @@ class SearchCriteria
|
||||||
std::string key;
|
std::string key;
|
||||||
std::string comparisonOperator;
|
std::string comparisonOperator;
|
||||||
std::string value;
|
std::string value;
|
||||||
|
|
||||||
|
SearchConditionType(const std::string & key,
|
||||||
|
const std::string & comparisonOperator,
|
||||||
|
const std::string & value)
|
||||||
|
: key(key), comparisonOperator(comparisonOperator), value(value)
|
||||||
|
{
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@ -249,12 +258,12 @@ class SearchCriteria
|
||||||
* @param condition the search condition to add
|
* @param condition the search condition to add
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
addCondition(const SearchConditionType & condition)
|
addCondition(const Ptr<SearchConditionType>::Ref condition)
|
||||||
throw(std::invalid_argument)
|
throw(std::invalid_argument)
|
||||||
{
|
{
|
||||||
addCondition(condition.key,
|
addCondition(condition->key,
|
||||||
condition.comparisonOperator,
|
condition->comparisonOperator,
|
||||||
condition.value);
|
condition->value);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -22,7 +22,7 @@
|
||||||
|
|
||||||
|
|
||||||
Author : $Author: fgerlits $
|
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 $
|
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 == "partial" || lowerCaseOp == "prefix"
|
||||||
|| lowerCaseOp == "<" || lowerCaseOp == "<="
|
|| lowerCaseOp == "<" || lowerCaseOp == "<="
|
||||||
|| lowerCaseOp == ">" || lowerCaseOp == ">=") {
|
|| lowerCaseOp == ">" || lowerCaseOp == ">=") {
|
||||||
SearchConditionType condition = { key, lowerCaseOp, value };
|
SearchConditionType condition(key, lowerCaseOp, value);
|
||||||
searchConditions.push_back(condition);
|
searchConditions.push_back(condition);
|
||||||
} else {
|
} else {
|
||||||
throw std::invalid_argument("bad comparison operator argument");
|
throw std::invalid_argument("bad comparison operator argument");
|
||||||
|
|
|
@ -21,7 +21,7 @@
|
||||||
#
|
#
|
||||||
#
|
#
|
||||||
# Author : $Author: fgerlits $
|
# 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 $
|
# Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/widgets/etc/Makefile.in,v $
|
||||||
#
|
#
|
||||||
# @configure_input@
|
# @configure_input@
|
||||||
|
@ -121,6 +121,7 @@ WIDGETS_LIB_OBJS = ${TMP_DIR}/ImageButton.o \
|
||||||
${TMP_DIR}/ZebraCellRenderer.o \
|
${TMP_DIR}/ZebraCellRenderer.o \
|
||||||
${TMP_DIR}/Colors.o \
|
${TMP_DIR}/Colors.o \
|
||||||
${TMP_DIR}/MessageWindow.o \
|
${TMP_DIR}/MessageWindow.o \
|
||||||
|
${TMP_DIR}/AdvancedSearchItem.o \
|
||||||
${TMP_DIR}/AdvancedSearchEntry.o
|
${TMP_DIR}/AdvancedSearchEntry.o
|
||||||
|
|
||||||
TEST_EXE_OBJS = ${TMP_DIR}/TestWindow.o \
|
TEST_EXE_OBJS = ${TMP_DIR}/TestWindow.o \
|
||||||
|
|
|
@ -22,7 +22,7 @@
|
||||||
|
|
||||||
|
|
||||||
Author : $Author: fgerlits $
|
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 $
|
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/Ptr.h"
|
||||||
#include "LiveSupport/Core/LocalizedObject.h"
|
#include "LiveSupport/Core/LocalizedObject.h"
|
||||||
#include "LiveSupport/Core/SearchCriteria.h"
|
#include "LiveSupport/Core/SearchCriteria.h"
|
||||||
#include "LiveSupport/Widgets/ComboBoxText.h"
|
|
||||||
#include "LiveSupport/Widgets/EntryBin.h"
|
|
||||||
|
|
||||||
|
|
||||||
namespace LiveSupport {
|
namespace LiveSupport {
|
||||||
|
@ -66,69 +64,18 @@ using namespace LiveSupport::Core;
|
||||||
* A Gtk::VBox with one or more search input fields in it.
|
* A Gtk::VBox with one or more search input fields in it.
|
||||||
*
|
*
|
||||||
* @author $Author: fgerlits $
|
* @author $Author: fgerlits $
|
||||||
* @version $Revision: 1.3 $
|
* @version $Revision: 1.4 $
|
||||||
*/
|
*/
|
||||||
class AdvancedSearchEntry : public Gtk::VBox,
|
class AdvancedSearchEntry : public Gtk::VBox,
|
||||||
public LocalizedObject
|
public LocalizedObject
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
|
|
||||||
/**
|
|
||||||
* The type for storing both the metadata and the comparison operator
|
|
||||||
* localizations.
|
|
||||||
*/
|
|
||||||
typedef std::vector<std::pair<Glib::ustring, Glib::ustring> >
|
|
||||||
MapVector;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The list of possible metadata field names.
|
|
||||||
*/
|
|
||||||
Ptr<MapVector>::Ref metadataTypes;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The list of possible comparison operators.
|
|
||||||
*/
|
|
||||||
Ptr<MapVector>::Ref operatorTypes;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The metadata field.
|
|
||||||
*/
|
|
||||||
ComboBoxText * metadataEntry;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The operator field.
|
|
||||||
*/
|
|
||||||
ComboBoxText * operatorEntry;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The "search for this value" field.
|
|
||||||
*/
|
|
||||||
EntryBin * valueEntry;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Default constructor.
|
* Default constructor.
|
||||||
*/
|
*/
|
||||||
AdvancedSearchEntry(void) throw ();
|
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:
|
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.
|
* Return the current state of the search fields.
|
||||||
*
|
*
|
||||||
|
|
|
@ -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 <vector>
|
||||||
|
#include <utility>
|
||||||
|
|
||||||
|
#include <gtkmm/box.h>
|
||||||
|
|
||||||
|
#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<std::pair<Glib::ustring, Glib::ustring> >
|
||||||
|
MapVector;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The list of possible metadata field names.
|
||||||
|
*/
|
||||||
|
Ptr<MapVector>::Ref metadataTypes;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The list of possible comparison operators.
|
||||||
|
*/
|
||||||
|
Ptr<MapVector>::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<ResourceBundle>::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<SearchCriteria::SearchConditionType>::Ref
|
||||||
|
getSearchCondition(void) throw ();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The signal proxy for pressing enter in the entry field.
|
||||||
|
*
|
||||||
|
* @return the signal_activate() proxy of the EntryBin.
|
||||||
|
*/
|
||||||
|
Glib::SignalProxy0<void>
|
||||||
|
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<void>
|
||||||
|
signal_add_new(void) throw ()
|
||||||
|
{
|
||||||
|
return plusButton->signal_clicked();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
/* ================================================= external data structures */
|
||||||
|
|
||||||
|
|
||||||
|
/* ====================================================== function prototypes */
|
||||||
|
|
||||||
|
|
||||||
|
} // namespace Widgets
|
||||||
|
} // namespace LiveSupport
|
||||||
|
|
||||||
|
#endif // LiveSupport_Widgets_AdvancedSearchItem_h
|
||||||
|
|
|
@ -22,7 +22,7 @@
|
||||||
|
|
||||||
|
|
||||||
Author : $Author: fgerlits $
|
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 $
|
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/widgets/include/LiveSupport/Widgets/WidgetFactory.h,v $
|
||||||
|
|
||||||
------------------------------------------------------------------------------*/
|
------------------------------------------------------------------------------*/
|
||||||
|
@ -89,7 +89,7 @@ class WhiteWindow;
|
||||||
* </code></pre>
|
* </code></pre>
|
||||||
*
|
*
|
||||||
* @author $Author: fgerlits $
|
* @author $Author: fgerlits $
|
||||||
* @version $Revision: 1.15 $
|
* @version $Revision: 1.16 $
|
||||||
*/
|
*/
|
||||||
class WidgetFactory :
|
class WidgetFactory :
|
||||||
virtual public Configurable
|
virtual public Configurable
|
||||||
|
@ -103,7 +103,7 @@ class WidgetFactory :
|
||||||
/**
|
/**
|
||||||
* The types of available image buttons.
|
* The types of available image buttons.
|
||||||
*/
|
*/
|
||||||
typedef enum { deleteButton,
|
typedef enum { deleteButton, plusButton,
|
||||||
smallPlayButton, smallPauseButton, smallStopButton,
|
smallPlayButton, smallPauseButton, smallStopButton,
|
||||||
hugePlayButton,
|
hugePlayButton,
|
||||||
cuePlayButton, cueStopButton }
|
cuePlayButton, cueStopButton }
|
||||||
|
|
|
@ -22,7 +22,7 @@
|
||||||
|
|
||||||
|
|
||||||
Author : $Author: fgerlits $
|
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 $
|
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/widgets/src/Attic/AdvancedSearchEntry.cxx,v $
|
||||||
|
|
||||||
------------------------------------------------------------------------------*/
|
------------------------------------------------------------------------------*/
|
||||||
|
@ -35,7 +35,7 @@
|
||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
#include "LiveSupport/Widgets/WidgetFactory.h"
|
#include "LiveSupport/Widgets/AdvancedSearchItem.h"
|
||||||
|
|
||||||
#include "LiveSupport/Widgets/AdvancedSearchEntry.h"
|
#include "LiveSupport/Widgets/AdvancedSearchEntry.h"
|
||||||
|
|
||||||
|
@ -60,45 +60,30 @@ using namespace LiveSupport::Widgets;
|
||||||
AdvancedSearchEntry :: AdvancedSearchEntry(Ptr<ResourceBundle>::Ref bundle)
|
AdvancedSearchEntry :: AdvancedSearchEntry(Ptr<ResourceBundle>::Ref bundle)
|
||||||
throw ()
|
throw ()
|
||||||
: LocalizedObject(bundle)
|
: LocalizedObject(bundle)
|
||||||
{using namespace LiveSupport::Storage;
|
{
|
||||||
|
AdvancedSearchItem * searchOptionsBox = Gtk::manage(new
|
||||||
Ptr<WidgetFactory>::Ref wf = WidgetFactory::getInstance();
|
AdvancedSearchItem(true, getBundle()) );
|
||||||
|
|
||||||
// only one option for now
|
|
||||||
Gtk::Box * searchOptionsBox = Gtk::manage(new Gtk::HBox);
|
|
||||||
pack_start(*searchOptionsBox, Gtk::PACK_SHRINK, 5);
|
pack_start(*searchOptionsBox, Gtk::PACK_SHRINK, 5);
|
||||||
|
|
||||||
Gtk::Label * searchByLabel;
|
searchOptionsBox->signal_add_new().connect(sigc::mem_fun(*this,
|
||||||
try {
|
&AdvancedSearchEntry::onAddNewCondition ));
|
||||||
searchByLabel = Gtk::manage(new Gtk::Label(
|
|
||||||
*getResourceUstring("searchByTextLabel") ));
|
|
||||||
readMetadataTypes();
|
|
||||||
readOperatorTypes();
|
|
||||||
|
|
||||||
} 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;
|
* Add a new search condition entrys item.
|
||||||
for (it = metadataTypes->begin(); it != metadataTypes->end(); ++it) {
|
*----------------------------------------------------------------------------*/
|
||||||
metadataEntry->append_text(it->first);
|
void
|
||||||
}
|
AdvancedSearchEntry :: onAddNewCondition(void) throw ()
|
||||||
metadataEntry->set_active_text(metadataTypes->front().first);
|
{
|
||||||
searchOptionsBox->pack_start(*metadataEntry, Gtk::PACK_EXPAND_WIDGET, 0);
|
AdvancedSearchItem * searchOptionsBox = Gtk::manage(new
|
||||||
|
AdvancedSearchItem(false, getBundle()) );
|
||||||
|
pack_start(*searchOptionsBox, Gtk::PACK_SHRINK, 5);
|
||||||
|
|
||||||
operatorEntry = Gtk::manage(wf->createComboBoxText());
|
searchOptionsBox->signal_add_new().connect(sigc::mem_fun(*this,
|
||||||
for (it = operatorTypes->begin(); it != operatorTypes->end(); ++it) {
|
&AdvancedSearchEntry::onAddNewCondition ));
|
||||||
operatorEntry->append_text(it->first);
|
searchOptionsBox->show_all_children();
|
||||||
}
|
searchOptionsBox->show();
|
||||||
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);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -108,44 +93,17 @@ AdvancedSearchEntry :: AdvancedSearchEntry(Ptr<ResourceBundle>::Ref bundle)
|
||||||
Ptr<SearchCriteria>::Ref
|
Ptr<SearchCriteria>::Ref
|
||||||
AdvancedSearchEntry :: getSearchCriteria(void) throw ()
|
AdvancedSearchEntry :: getSearchCriteria(void) throw ()
|
||||||
{
|
{
|
||||||
Ptr<SearchCriteria>::Ref criteria(new SearchCriteria("all"));
|
Ptr<SearchCriteria>::Ref criteria(new SearchCriteria("all", "and"));
|
||||||
|
|
||||||
std::string metadataName = metadataEntry->get_active_text();
|
Gtk::Box_Helpers::BoxList children = this->children();
|
||||||
std::string metadataKey;
|
Gtk::Box_Helpers::BoxList::type_base::iterator it;
|
||||||
bool found = false;
|
|
||||||
MapVector::const_iterator it;
|
for (it = children.begin(); it != children.end(); ++it) {
|
||||||
for (it = metadataTypes->begin(); it != metadataTypes->end(); ++it) {
|
AdvancedSearchItem * child = dynamic_cast<AdvancedSearchItem *>(
|
||||||
if (it->first == metadataName) {
|
it->get_widget() );
|
||||||
found = true;
|
criteria->addCondition(child->getSearchCondition());
|
||||||
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();
|
|
||||||
|
|
||||||
criteria->addCondition(metadataKey, operatorKey, value);
|
|
||||||
return criteria;
|
return criteria;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -157,54 +115,13 @@ void
|
||||||
AdvancedSearchEntry :: connectCallback(const sigc::slot<void> & callback)
|
AdvancedSearchEntry :: connectCallback(const sigc::slot<void> & callback)
|
||||||
throw ()
|
throw ()
|
||||||
{
|
{
|
||||||
valueEntry->signal_activate().connect(callback);
|
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<AdvancedSearchItem *>(
|
||||||
* Read the localized metadata field names.
|
it->get_widget() );
|
||||||
*----------------------------------------------------------------------------*/
|
child->signal_activate().connect(callback);
|
||||||
void
|
}
|
||||||
AdvancedSearchEntry :: 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
|
|
||||||
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") ));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
217
livesupport/modules/widgets/src/AdvancedSearchItem.cxx
Normal file
217
livesupport/modules/widgets/src/AdvancedSearchItem.cxx
Normal file
|
@ -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 <iostream>
|
||||||
|
|
||||||
|
#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<ResourceBundle>::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<WidgetFactory>::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<SearchCriteria::SearchConditionType>::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<SearchCriteria::SearchConditionType>::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") ));
|
||||||
|
}
|
||||||
|
|
|
@ -22,7 +22,7 @@
|
||||||
|
|
||||||
|
|
||||||
Author : $Author: fgerlits $
|
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 $
|
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";
|
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.
|
* The name of the passive image for the small play button.
|
||||||
*/
|
*/
|
||||||
|
@ -361,6 +371,11 @@ WidgetFactory :: createButton(ImageButtonType type) throw ()
|
||||||
rollImage = loadImage(deleteButtonRollName);
|
rollImage = loadImage(deleteButtonRollName);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case plusButton:
|
||||||
|
passiveImage = loadImage(plusButtonPassiveName);
|
||||||
|
rollImage = loadImage(plusButtonRollName);
|
||||||
|
break;
|
||||||
|
|
||||||
case smallPlayButton:
|
case smallPlayButton:
|
||||||
passiveImage = loadImage(smallPlayButtonPassiveName);
|
passiveImage = loadImage(smallPlayButtonPassiveName);
|
||||||
rollImage = loadImage(smallPlayButtonRollName);
|
rollImage = loadImage(smallPlayButtonRollName);
|
||||||
|
|
BIN
livesupport/modules/widgets/var/imageButton/plus.png
Normal file
BIN
livesupport/modules/widgets/var/imageButton/plus.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 3.3 KiB |
BIN
livesupport/modules/widgets/var/imageButton/plusRoll.png
Normal file
BIN
livesupport/modules/widgets/var/imageButton/plusRoll.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 3.3 KiB |
Binary file not shown.
After Width: | Height: | Size: 3.3 KiB |
Binary file not shown.
After Width: | Height: | Size: 3.3 KiB |
Loading…
Add table
Add a link
Reference in a new issue