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 $
|
||||
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 <iostream>
|
||||
|
||||
#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<ResourceBundle>::Ref bundle)
|
||||
throw ()
|
||||
: LocalizedObject(bundle)
|
||||
{using namespace LiveSupport::Storage;
|
||||
|
||||
Ptr<WidgetFactory>::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<ResourceBundle>::Ref bundle)
|
|||
Ptr<SearchCriteria>::Ref
|
||||
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();
|
||||
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<AdvancedSearchItem *>(
|
||||
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<void> & 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<AdvancedSearchItem *>(
|
||||
it->get_widget() );
|
||||
child->signal_activate().connect(callback);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
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 $
|
||||
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);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue