added browse tab to the Search window

This commit is contained in:
fgerlits 2005-04-26 16:52:04 +00:00
parent 4749cd5c81
commit afb16ee5dd
13 changed files with 270 additions and 154 deletions

View file

@ -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/core/include/LiveSupport/Core/SearchCriteria.h,v $ Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/core/include/LiveSupport/Core/SearchCriteria.h,v $
------------------------------------------------------------------------------*/ ------------------------------------------------------------------------------*/
@ -69,7 +69,7 @@ namespace Core {
* Its fields are: * Its fields are:
* <ul> * <ul>
* <li>type - values in (audioClip | playlist | all); the default is * <li>type - values in (audioClip | playlist | all); the default is
* <i>audioClip</i></li> * <i>all</i></li>
* <li>operator - values in (and | or); the default is <i>and</i></li> * <li>operator - values in (and | or); the default is <i>and</i></li>
* <li>condition1 : { key : string, comparison: string, value : string } * <li>condition1 : { key : string, comparison: string, value : string }
* - a search condition, where <i>key</i> is one of the * - a search condition, where <i>key</i> is one of the
@ -177,7 +177,7 @@ class SearchCriteria
* @param type one of "audioClip" (default), "playlist" or "all" * @param type one of "audioClip" (default), "playlist" or "all"
* @param logicalOperator either "and" (default) or "or" * @param logicalOperator either "and" (default) or "or"
*/ */
SearchCriteria(const std::string & type = "audioClip", SearchCriteria(const std::string & type = "all",
const std::string & logicalOperator = "and") const std::string & logicalOperator = "and")
throw(std::invalid_argument) throw(std::invalid_argument)
: limit(0), offset(0) : limit(0), offset(0)

View file

@ -21,8 +21,8 @@
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Author : $Author: maroy $ Author : $Author: fgerlits $
Version : $Revision: 1.2 $ Version : $Revision: 1.3 $
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/widgets/include/LiveSupport/Widgets/ComboBoxText.h,v $ Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/widgets/include/LiveSupport/Widgets/ComboBoxText.h,v $
------------------------------------------------------------------------------*/ ------------------------------------------------------------------------------*/
@ -63,8 +63,8 @@ using namespace LiveSupport::Core;
/** /**
* A combo box holding text entries. * A combo box holding text entries.
* *
* @author $Author: maroy $ * @author $Author: fgerlits $
* @version $Revision: 1.2 $ * @version $Revision: 1.3 $
*/ */
class ComboBoxText : public Gtk::ComboBoxText class ComboBoxText : public Gtk::ComboBoxText
{ {
@ -240,6 +240,11 @@ class ComboBoxText : public Gtk::ComboBoxText
virtual GtkType virtual GtkType
child_type_vfunc() const throw (); child_type_vfunc() const throw ();
/**
* A signal object to notify people that the selection has changed.
*/
sigc::signal<void> signalSelectionChangedObject;
public: public:
/** /**
@ -293,6 +298,20 @@ class ComboBoxText : public Gtk::ComboBoxText
void void
set_active_text(const Glib::ustring & text) throw (); set_active_text(const Glib::ustring & text) throw ();
/**
* Accessor for the selectionChanged signal.
* This signal is emitted by onMenuItemSelected() when the active
* text of the ComboBoxText has changed.
* It has the same function as Gtk::ComboBoxText::signal_changed().
*
* TODO: it would be nicer to override signal_changed();
* need to figure out how.
*
* @return the signal object (a protected member of this class)
*/
sigc::signal<void>
signalSelectionChanged(void) throw ();
}; };

View file

@ -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/widgets/src/Attic/AdvancedSearchItem.cxx,v $ Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/widgets/src/Attic/AdvancedSearchItem.cxx,v $
------------------------------------------------------------------------------*/ ------------------------------------------------------------------------------*/
@ -178,11 +178,17 @@ AdvancedSearchItem :: readMetadataTypes(void)
metadataTypes.reset(new MapVector); metadataTypes.reset(new MapVector);
metadataTypes->push_back(std::make_pair( metadataTypes->push_back(std::make_pair(
*getResourceUstring("titleMetadataDisplay"), *getResourceUstring("genreMetadataDisplay"),
*getResourceUstring("titleMetadataSearchKey") )); *getResourceUstring("genreMetadataSearchKey") ));
metadataTypes->push_back(std::make_pair( metadataTypes->push_back(std::make_pair(
*getResourceUstring("creatorMetadataDisplay"), *getResourceUstring("creatorMetadataDisplay"),
*getResourceUstring("creatorMetadataSearchKey") )); *getResourceUstring("creatorMetadataSearchKey") ));
metadataTypes->push_back(std::make_pair(
*getResourceUstring("albumMetadataDisplay"),
*getResourceUstring("albumMetadataSearchKey") ));
metadataTypes->push_back(std::make_pair(
*getResourceUstring("titleMetadataDisplay"),
*getResourceUstring("titleMetadataSearchKey") ));
metadataTypes->push_back(std::make_pair( metadataTypes->push_back(std::make_pair(
*getResourceUstring("lengthMetadataDisplay"), *getResourceUstring("lengthMetadataDisplay"),
*getResourceUstring("lengthMetadataSearchKey") )); *getResourceUstring("lengthMetadataSearchKey") ));

View file

@ -22,7 +22,7 @@
Author : $Author: fgerlits $ Author : $Author: fgerlits $
Version : $Revision: 1.4 $ Version : $Revision: 1.5 $
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/widgets/src/ComboBoxText.cxx,v $ Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/widgets/src/ComboBoxText.cxx,v $
------------------------------------------------------------------------------*/ ------------------------------------------------------------------------------*/
@ -393,6 +393,7 @@ ComboBoxText :: onMenuItemSelected(void) throw ()
Gtk::MenuItem * item = menu->get_active(); Gtk::MenuItem * item = menu->get_active();
Gtk::Label * selected = (Gtk::Label*) item->get_child(); Gtk::Label * selected = (Gtk::Label*) item->get_child();
set_active_text(selected->get_text()); set_active_text(selected->get_text());
signalSelectionChanged().emit();
} }
@ -448,3 +449,13 @@ ComboBoxText :: set_active_text(const Glib::ustring & text) throw ()
label->set_text(text); label->set_text(text);
} }
/*------------------------------------------------------------------------------
* Accessor for the selectionChanged signal.
*----------------------------------------------------------------------------*/
sigc::signal<void>
ComboBoxText :: signalSelectionChanged(void) throw ()
{
return signalSelectionChangedObject;
}

View file

@ -21,7 +21,7 @@
# #
# #
# Author : $Author: fgerlits $ # Author : $Author: fgerlits $
# Version : $Revision: 1.31 $ # Version : $Revision: 1.32 $
# Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/gLiveSupport/etc/Makefile.in,v $ # Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/gLiveSupport/etc/Makefile.in,v $
# #
# @configure_input@ # @configure_input@
@ -191,6 +191,7 @@ G_LIVESUPPORT_OBJS = ${TMP_DIR}/GLiveSupport.o \
${TMP_DIR}/SchedulerWindow.o \ ${TMP_DIR}/SchedulerWindow.o \
${TMP_DIR}/SchedulePlaylistWindow.o \ ${TMP_DIR}/SchedulePlaylistWindow.o \
${TMP_DIR}/SearchWindow.o \ ${TMP_DIR}/SearchWindow.o \
${TMP_DIR}/BrowseEntry.o \
${TMP_DIR}/BrowseItem.o ${TMP_DIR}/BrowseItem.o
G_LIVESUPPORT_RES = ${TMP_DIR}/${PACKAGE_NAME}_root.res \ G_LIVESUPPORT_RES = ${TMP_DIR}/${PACKAGE_NAME}_root.res \

View file

@ -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/products/gLiveSupport/src/BrowseEntry.cxx,v $ Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/gLiveSupport/src/BrowseEntry.cxx,v $
------------------------------------------------------------------------------*/ ------------------------------------------------------------------------------*/
@ -35,13 +35,12 @@
#include <iostream> #include <iostream>
#include "LiveSupport/Widgets/BrowseItem.h"
#include "BrowseEntry.h" #include "BrowseEntry.h"
using namespace LiveSupport::Core; using namespace LiveSupport::Core;
using namespace LiveSupport::Widgets; using namespace LiveSupport::Widgets;
using namespace LiveSupport::GLiveSupport;
/* =================================================== local data structures */ /* =================================================== local data structures */
@ -57,71 +56,37 @@ using namespace LiveSupport::Widgets;
/*------------------------------------------------------------------------------ /*------------------------------------------------------------------------------
* Constructor. * Constructor.
*----------------------------------------------------------------------------*/ *----------------------------------------------------------------------------*/
BrowseEntry :: BrowseEntry(Ptr<ResourceBundle>::Ref bundle) BrowseEntry :: BrowseEntry(
Ptr<LiveSupport::GLiveSupport::GLiveSupport>::Ref gLiveSupport,
Ptr<ResourceBundle>::Ref bundle)
throw () throw ()
: LocalizedObject(bundle) : LocalizedObject(bundle)
{ {
BrowseItem * searchOptionsBox = Gtk::manage(new browseItemOne = Gtk::manage(new BrowseItem(
BrowseItem(true, getBundle()) ); gLiveSupport,
pack_start(*searchOptionsBox, Gtk::PACK_SHRINK, 5); *getResourceUstring("genreMetadataDisplay"),
bundle ));
browseItemTwo = Gtk::manage(new BrowseItem(
gLiveSupport,
*getResourceUstring("creatorMetadataDisplay"),
bundle ));
browseItemThree = Gtk::manage(new BrowseItem(
gLiveSupport,
*getResourceUstring("albumMetadataDisplay"),
bundle ));
searchOptionsBox->signal_add_new().connect(sigc::mem_fun(*this,
&BrowseEntry::onAddNewCondition )); browseItemOne->signalSelectionChanged().connect(
} sigc::bind<BrowseItem*>(
sigc::mem_fun(*browseItemTwo, &BrowseItem::onParentChangedShow),
browseItemOne ));
/*------------------------------------------------------------------------------ browseItemTwo->signalSelectionChanged().connect(
* Add a new search condition entrys item. sigc::bind<BrowseItem*>(
*----------------------------------------------------------------------------*/ sigc::mem_fun(*browseItemThree, &BrowseItem::onParentChangedShow),
void browseItemTwo ));
BrowseEntry :: onAddNewCondition(void) throw ()
{ pack_start(*browseItemOne, Gtk::PACK_EXPAND_WIDGET, 5);
BrowseItem * searchOptionsBox = Gtk::manage(new pack_start(*browseItemTwo, Gtk::PACK_EXPAND_WIDGET, 5);
BrowseItem(false, getBundle()) ); pack_start(*browseItemThree, Gtk::PACK_EXPAND_WIDGET, 5);
pack_start(*searchOptionsBox, Gtk::PACK_SHRINK, 5);
searchOptionsBox->signal_add_new().connect(sigc::mem_fun(*this,
&BrowseEntry::onAddNewCondition ));
searchOptionsBox->show_all_children();
searchOptionsBox->show();
}
/*------------------------------------------------------------------------------
* Return the current state of the search fields.
*----------------------------------------------------------------------------*/
Ptr<SearchCriteria>::Ref
BrowseEntry :: getSearchCriteria(void) throw ()
{
Ptr<SearchCriteria>::Ref criteria(new SearchCriteria("all", "and"));
Gtk::Box_Helpers::BoxList children = this->children();
Gtk::Box_Helpers::BoxList::type_base::iterator it;
for (it = children.begin(); it != children.end(); ++it) {
BrowseItem * child = dynamic_cast<BrowseItem *>(
it->get_widget() );
criteria->addCondition(child->getSearchCondition());
}
return criteria;
}
/*------------------------------------------------------------------------------
* Connect a callback to the "enter key pressed" event.
*----------------------------------------------------------------------------*/
void
BrowseEntry :: connectCallback(const sigc::slot<void> & callback)
throw ()
{
Gtk::Box_Helpers::BoxList children = this->children();
Gtk::Box_Helpers::BoxList::type_base::iterator it;
for (it = children.begin(); it != children.end(); ++it) {
BrowseItem * child = dynamic_cast<BrowseItem *>(
it->get_widget() );
child->signal_activate().connect(callback);
}
} }

View file

@ -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/products/gLiveSupport/src/BrowseEntry.h,v $ Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/gLiveSupport/src/BrowseEntry.h,v $
------------------------------------------------------------------------------*/ ------------------------------------------------------------------------------*/
@ -45,6 +45,8 @@
#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 "BrowseItem.h"
#include "GLiveSupport.h"
namespace LiveSupport { namespace LiveSupport {
@ -61,12 +63,12 @@ using namespace LiveSupport::Core;
/* =============================================================== data types */ /* =============================================================== data types */
/** /**
* A Gtk::VBox with one or more search input fields in it. * A Gtk::HBox with one or more search input fields in it.
* *
* @author $Author: fgerlits $ * @author $Author: fgerlits $
* @version $Revision: 1.1 $ * @version $Revision: 1.2 $
*/ */
class BrowseEntry : public Gtk::VBox, class BrowseEntry : public Gtk::HBox,
public LocalizedObject public LocalizedObject
{ {
private: private:
@ -76,12 +78,30 @@ class BrowseEntry : public Gtk::VBox,
*/ */
BrowseEntry(void) throw (); BrowseEntry(void) throw ();
/**
* The first BrowseItem entry field.
*/
BrowseItem * browseItemOne;
/**
* The second BrowseItem entry field.
*/
BrowseItem * browseItemTwo;
/**
* The third BrowseItem entry field.
*/
BrowseItem * browseItemThree;
public: public:
/** /**
* Constructor with localization parameter. * Constructor with localization parameter.
*/ */
BrowseEntry(Ptr<ResourceBundle>::Ref bundle) BrowseEntry(
Ptr<LiveSupport::GLiveSupport::GLiveSupport>::Ref gLiveSupport,
Ptr<ResourceBundle>::Ref bundle)
throw (); throw ();
/** /**
@ -92,12 +112,6 @@ class BrowseEntry : 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.
* *
@ -105,15 +119,23 @@ class BrowseEntry : public Gtk::VBox,
* which contains the data entered by the user * which contains the data entered by the user
*/ */
Ptr<SearchCriteria>::Ref Ptr<SearchCriteria>::Ref
getSearchCriteria(void) throw (); getSearchCriteria(void) throw ()
{
return browseItemThree->getSearchCriteria();
}
/** /**
* Connect a callback to the "enter key pressed" event. * The signal raised when either the combo box or the tree view
* selection has changed.
* *
* @param callback the function to execute when enter is pressed. * @return the signalSelectionChanged() of the last browse item
*/ */
void sigc::signal<void>
connectCallback(const sigc::slot<void> & callback) throw (); signalSelectionChanged(void) throw ()
{
return browseItemThree->signalSelectionChanged();
}
}; };

View file

@ -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/products/gLiveSupport/src/BrowseItem.cxx,v $ Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/gLiveSupport/src/BrowseItem.cxx,v $
------------------------------------------------------------------------------*/ ------------------------------------------------------------------------------*/
@ -60,13 +60,11 @@ using namespace LiveSupport::GLiveSupport;
*----------------------------------------------------------------------------*/ *----------------------------------------------------------------------------*/
BrowseItem :: BrowseItem( BrowseItem :: BrowseItem(
Ptr<LiveSupport::GLiveSupport::GLiveSupport>::Ref gLiveSupport, Ptr<LiveSupport::GLiveSupport::GLiveSupport>::Ref gLiveSupport,
Ptr<Glib::ustring>::Ref metadata, const Glib::ustring & metadata,
Ptr<SearchCriteria>::Ref parentCriteria,
Ptr<ResourceBundle>::Ref bundle) Ptr<ResourceBundle>::Ref bundle)
throw () throw ()
: LocalizedObject(bundle), : LocalizedObject(bundle),
gLiveSupport(gLiveSupport), gLiveSupport(gLiveSupport)
parentCriteria(parentCriteria)
{ {
try { try {
if (!metadataTypes) { if (!metadataTypes) {
@ -80,6 +78,8 @@ BrowseItem :: BrowseItem(
std::exit(1); std::exit(1);
} }
parentCriteria.reset(new SearchCriteria);
Ptr<WidgetFactory>::Ref wf = WidgetFactory::getInstance(); Ptr<WidgetFactory>::Ref wf = WidgetFactory::getInstance();
metadataEntry = Gtk::manage(wf->createComboBoxText()); metadataEntry = Gtk::manage(wf->createComboBoxText());
@ -87,28 +87,32 @@ BrowseItem :: BrowseItem(
for (it = metadataTypes->begin(); it != metadataTypes->end(); ++it) { for (it = metadataTypes->begin(); it != metadataTypes->end(); ++it) {
metadataEntry->append_text(it->first); metadataEntry->append_text(it->first);
} }
metadataEntry->set_active_text(*metadata); metadataEntry->set_active_text(metadata);
if (metadataEntry->get_active_text() != *metadata) { if (metadataEntry->get_active_text() != metadata) {
metadataEntry->set_active_text(metadataTypes->front().first); metadataEntry->set_active_text(metadataTypes->front().first);
} }
pack_start(*metadataEntry, Gtk::PACK_EXPAND_WIDGET, 5); metadataEntry->signalSelectionChanged().connect(sigc::mem_fun(*this,
&BrowseItem::onShow ));
pack_start(*metadataEntry, Gtk::PACK_SHRINK, 5);
treeModel = Gtk::ListStore::create(modelColumns); treeModel = Gtk::ListStore::create(modelColumns);
metadataValues = Gtk::manage(wf->createTreeView(treeModel)); metadataValues = Gtk::manage(wf->createTreeView(treeModel));
metadataValues->appendColumn("", modelColumns.column); metadataValues->appendColumn("", modelColumns.column);
metadataValues->set_headers_visible(false); metadataValues->set_headers_visible(false);
pack_start(*metadataValues, Gtk::PACK_EXPAND_WIDGET, 5); metadataValues->signal_cursor_changed().connect(sigc::mem_fun(*this,
&BrowseItem::emitSignalSelectionChanged ));
pack_start(*metadataValues, Gtk::PACK_SHRINK, 5);
reset(); onShow();
} }
/*------------------------------------------------------------------------------ /*------------------------------------------------------------------------------
* Return the current state of the search fields. * Return the search criteria selected by the user.
*----------------------------------------------------------------------------*/ *----------------------------------------------------------------------------*/
Ptr<SearchCriteria::SearchConditionType>::Ref Ptr<SearchCriteria>::Ref
BrowseItem :: getSearchCondition(void) throw (std::invalid_argument) BrowseItem :: getSearchCriteria(void) throw (std::invalid_argument)
{ {
std::string metadataName = metadataEntry->get_active_text(); std::string metadataName = metadataEntry->get_active_text();
std::string metadataKey; std::string metadataKey;
@ -134,18 +138,23 @@ BrowseItem :: getSearchCondition(void) throw (std::invalid_argument)
if (refSelection) { if (refSelection) {
Gtk::TreeModel::iterator iter = refSelection->get_selected(); Gtk::TreeModel::iterator iter = refSelection->get_selected();
if (iter) { if (iter) {
found = true;
metadataValue = (*iter)[modelColumns.column]; metadataValue = (*iter)[modelColumns.column];
} }
} }
if (!found) { if (!found) {
metadataValue = *getResourceUstring("allStringForBrowse"); return parentCriteria; // should never happen, but für alle Fälle
} // may throw std::invalid_argument }
Ptr<SearchCriteria::SearchConditionType>::Ref if (metadataValue == allString) {
condition(new SearchCriteria::SearchConditionType( return parentCriteria;
metadataKey, "=", metadataValue ));
return condition; } else {
Ptr<SearchCriteria>::Ref criteria(new SearchCriteria(*parentCriteria));
criteria->addCondition(metadataKey, "=", metadataValue);
return criteria;
}
} }
@ -159,11 +168,17 @@ BrowseItem :: readMetadataTypes(void)
metadataTypes.reset(new MapVector); metadataTypes.reset(new MapVector);
metadataTypes->push_back(std::make_pair( metadataTypes->push_back(std::make_pair(
*getResourceUstring("titleMetadataDisplay"), *getResourceUstring("genreMetadataDisplay"),
*getResourceUstring("titleMetadataSearchKey") )); *getResourceUstring("genreMetadataSearchKey") ));
metadataTypes->push_back(std::make_pair( metadataTypes->push_back(std::make_pair(
*getResourceUstring("creatorMetadataDisplay"), *getResourceUstring("creatorMetadataDisplay"),
*getResourceUstring("creatorMetadataSearchKey") )); *getResourceUstring("creatorMetadataSearchKey") ));
metadataTypes->push_back(std::make_pair(
*getResourceUstring("albumMetadataDisplay"),
*getResourceUstring("albumMetadataSearchKey") ));
metadataTypes->push_back(std::make_pair(
*getResourceUstring("titleMetadataDisplay"),
*getResourceUstring("titleMetadataSearchKey") ));
metadataTypes->push_back(std::make_pair( metadataTypes->push_back(std::make_pair(
*getResourceUstring("lengthMetadataDisplay"), *getResourceUstring("lengthMetadataDisplay"),
*getResourceUstring("lengthMetadataSearchKey") )); *getResourceUstring("lengthMetadataSearchKey") ));
@ -201,7 +216,7 @@ BrowseItem :: readOperatorTypes(void)
* Fill in the column with the possible values. * Fill in the column with the possible values.
*----------------------------------------------------------------------------*/ *----------------------------------------------------------------------------*/
void void
BrowseItem :: reset(void) throw () BrowseItem :: onShow(void) throw ()
{ {
std::string metadataName = metadataEntry->get_active_text(); std::string metadataName = metadataEntry->get_active_text();
Ptr<Glib::ustring>::Ref metadataKey(new Glib::ustring); Ptr<Glib::ustring>::Ref metadataKey(new Glib::ustring);
@ -224,11 +239,12 @@ BrowseItem :: reset(void) throw ()
int rowNumber = 1; int rowNumber = 1;
Gtk::TreeModel::Row row = *treeModel->append(); Gtk::TreeModel::Row row = *treeModel->append();
try { try {
row[modelColumns.column] = *getResourceUstring("allStringForBrowse"); allString = *getResourceUstring("allStringForBrowse");
} catch (std::invalid_argument &e) { } catch (std::invalid_argument &e) {
std::cerr << e.what() << std::endl; std::cerr << e.what() << std::endl;
std::exit(1); std::exit(1);
} }
row[modelColumns.column] = allString;
row[modelColumns.rowNumberColumn] = rowNumber++; row[modelColumns.rowNumberColumn] = rowNumber++;
metadataValues->get_selection()->select(*row); metadataValues->get_selection()->select(*row);
@ -240,5 +256,7 @@ BrowseItem :: reset(void) throw ()
row[modelColumns.column] = *valuesIt; row[modelColumns.column] = *valuesIt;
row[modelColumns.rowNumberColumn] = rowNumber++; row[modelColumns.rowNumberColumn] = rowNumber++;
} }
emitSignalSelectionChanged();
} }

View file

@ -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/products/gLiveSupport/src/BrowseItem.h,v $ Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/gLiveSupport/src/BrowseItem.h,v $
------------------------------------------------------------------------------*/ ------------------------------------------------------------------------------*/
@ -72,8 +72,15 @@ using namespace LiveSupport::Widgets;
/** /**
* A single browse input field. * A single browse input field.
* *
* It consists of a Widgets::ComboBoxText and a Widgets::ZebraTreeView
* (without header). It stores a "parent search criteria", and shows all
* possible metadata values of the type selected in the ComboBoxText which
* match this condition. The parent search criteria should be conjunction
* of all search conditions selected in BrowseItem objects to the left of
* this one.
*
* @author $Author: fgerlits $ * @author $Author: fgerlits $
* @version $Revision: 1.1 $ * @version $Revision: 1.2 $
*/ */
class BrowseItem : public Gtk::VBox, class BrowseItem : public Gtk::VBox,
public LocalizedObject public LocalizedObject
@ -112,7 +119,7 @@ class BrowseItem : public Gtk::VBox,
* Lists one clip per row. * Lists one clip per row.
* *
* @author $Author: fgerlits $ * @author $Author: fgerlits $
* @version $Revision: 1.1 $ * @version $Revision: 1.2 $
*/ */
class ModelColumns : public ZebraTreeModelColumnRecord class ModelColumns : public ZebraTreeModelColumnRecord
{ {
@ -141,6 +148,12 @@ class BrowseItem : public Gtk::VBox,
*/ */
Glib::RefPtr<Gtk::ListStore> treeModel; Glib::RefPtr<Gtk::ListStore> treeModel;
/**
* This is pretty lame, but we store the localized version of the
* "--- all ---" string here.
*/
Glib::ustring allString;
/** /**
* The GLiveSupport object, holding the state of the application. * The GLiveSupport object, holding the state of the application.
*/ */
@ -174,6 +187,23 @@ class BrowseItem : public Gtk::VBox,
void void
readOperatorTypes(void) throw (std::invalid_argument); readOperatorTypes(void) throw (std::invalid_argument);
/**
* Emit the "selection changed" signal.
*/
void
emitSignalSelectionChanged(void) throw ()
{
signalSelectionChanged().emit();
}
protected:
/**
* A signal object to notify people that the selection has changed.
*/
sigc::signal<void> signalSelectionChangedObject;
public: public:
@ -186,8 +216,7 @@ class BrowseItem : public Gtk::VBox,
*/ */
BrowseItem( BrowseItem(
Ptr<LiveSupport::GLiveSupport::GLiveSupport>::Ref gLiveSupport, Ptr<LiveSupport::GLiveSupport::GLiveSupport>::Ref gLiveSupport,
Ptr<Glib::ustring>::Ref metadata, const Glib::ustring & metadata,
Ptr<SearchCriteria>::Ref parentCriteria,
Ptr<ResourceBundle>::Ref bundle) Ptr<ResourceBundle>::Ref bundle)
throw (); throw ();
@ -200,20 +229,50 @@ class BrowseItem : public Gtk::VBox,
} }
/** /**
* Return the current state of the search fields. * Return the search criteria selected by the user.
* This is the parent criteria (assumed to have operator "and")
* with the search condition showing the current selection added
* (if any).
* *
* @return a new LiveSupport::Storage::SearchCriteria instance, * @return a new LiveSupport::Storage::SearchCriteria instance,
* which contains the data entered by the user * which contains the data entered by the user
*/ */
Ptr<SearchCriteria::SearchConditionType>::Ref Ptr<SearchCriteria>::Ref
getSearchCondition(void) throw (std::invalid_argument); getSearchCriteria(void) throw (std::invalid_argument);
/** /**
* Fill in the column with the possible values (limited by the * Fill in the column with the possible values (limited by the
* parent criteria), and set the selection to "all". * parent criteria), and set the selection to "all".
*/ */
void void
reset(void) throw (); onShow(void) throw ();
/**
* The signal handler for refreshing the treeview of metadata values,
* if we also need to change the parent criteria. Same as onShow(),
* plus changing the parent criteria.
*
* @param criteria the new parent search criteria
*/
void
onParentChangedShow(BrowseItem * leftNeighbor)
throw ()
{
parentCriteria = leftNeighbor->getSearchCriteria();
onShow();
}
/**
* The signal raised when either the combo box or the tree view
* selection has changed.
*
* @return the signal object (a protected member of this class)
*/
sigc::signal<void>
signalSelectionChanged(void) throw ()
{
return signalSelectionChangedObject;
}
}; };

View file

@ -22,7 +22,7 @@
Author : $Author: fgerlits $ Author : $Author: fgerlits $
Version : $Revision: 1.7 $ Version : $Revision: 1.8 $
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/gLiveSupport/src/SearchWindow.cxx,v $ Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/gLiveSupport/src/SearchWindow.cxx,v $
------------------------------------------------------------------------------*/ ------------------------------------------------------------------------------*/
@ -202,26 +202,18 @@ SearchWindow :: constructAdvancedSearchView(void) throw ()
Gtk::VBox* Gtk::VBox*
SearchWindow :: constructBrowseView(void) throw () SearchWindow :: constructBrowseView(void) throw ()
{ {
Ptr<WidgetFactory>::Ref wf = WidgetFactory::getInstance(); // set up the browse input fields
browseEntry = Gtk::manage(new BrowseEntry(gLiveSupport, getBundle()));
// FIXME browseEntry->signalSelectionChanged().connect(sigc::mem_fun(
Ptr<Glib::ustring>::Ref metadata(new Glib::ustring("Title")); *this, &SearchWindow::onBrowse ));
Ptr<SearchCriteria>::Ref criteria(new SearchCriteria);
// set up the selection panel
// FIXME
BrowseItem * browsePanel = Gtk::manage(new BrowseItem(
gLiveSupport,
metadata,
criteria,
getBundle() ));
// set up the search results display // set up the search results display
ZebraTreeView * searchResults = constructSearchResults(); ZebraTreeView * searchResults = constructSearchResults();
// make a new box and pack the main components into it // make a new box and pack the main components into it
Gtk::VBox * view = Gtk::manage(new Gtk::VBox); Gtk::VBox * view = Gtk::manage(new Gtk::VBox);
view->pack_start(*browsePanel, Gtk::PACK_EXPAND_WIDGET, 5); view->pack_start(*browseEntry, Gtk::PACK_EXPAND_WIDGET, 5);
view->pack_start(*searchResults, Gtk::PACK_EXPAND_WIDGET, 5); view->pack_start(*searchResults, Gtk::PACK_EXPAND_WIDGET, 5);
return view; return view;
} }
@ -284,6 +276,16 @@ SearchWindow :: onAdvancedSearch(void) throw ()
} }
/*------------------------------------------------------------------------------
* Event handler for changed selection in the Browse view.
*----------------------------------------------------------------------------*/
void
SearchWindow :: onBrowse(void) throw ()
{
onSearch(browseEntry->getSearchCriteria());
}
/*------------------------------------------------------------------------------ /*------------------------------------------------------------------------------
* Do the searching. * Do the searching.
*----------------------------------------------------------------------------*/ *----------------------------------------------------------------------------*/

View file

@ -22,7 +22,7 @@
Author : $Author: fgerlits $ Author : $Author: fgerlits $
Version : $Revision: 1.6 $ Version : $Revision: 1.7 $
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/gLiveSupport/src/SearchWindow.h,v $ Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/gLiveSupport/src/SearchWindow.h,v $
------------------------------------------------------------------------------*/ ------------------------------------------------------------------------------*/
@ -52,8 +52,8 @@
#include "LiveSupport/Widgets/ZebraTreeModelColumnRecord.h" #include "LiveSupport/Widgets/ZebraTreeModelColumnRecord.h"
#include "LiveSupport/Widgets/AdvancedSearchEntry.h" #include "LiveSupport/Widgets/AdvancedSearchEntry.h"
#include "GLiveSupport.h" #include "GLiveSupport.h"
//FIXME #include "BrowseEntry.h"
#include "BrowseItem.h"
namespace LiveSupport { namespace LiveSupport {
namespace GLiveSupport { namespace GLiveSupport {
@ -73,7 +73,7 @@ using namespace LiveSupport::Widgets;
* The Search/Browse window. * The Search/Browse window.
* *
* @author $Author: fgerlits $ * @author $Author: fgerlits $
* @version $Revision: 1.6 $ * @version $Revision: 1.7 $
*/ */
class SearchWindow : public WhiteWindow, public LocalizedObject class SearchWindow : public WhiteWindow, public LocalizedObject
{ {
@ -92,8 +92,7 @@ class SearchWindow : public WhiteWindow, public LocalizedObject
/** /**
* The box containing the browse input fields. * The box containing the browse input fields.
*/ */
// FIXME BrowseEntry * browseEntry;
BrowseItem * browseEntry;
/** /**
* Construct the simple search view. * Construct the simple search view.
@ -144,6 +143,12 @@ class SearchWindow : public WhiteWindow, public LocalizedObject
void void
onAdvancedSearch(void) throw (); onAdvancedSearch(void) throw ();
/**
* Event handler for changed selection in the Browse view.
*/
void
onBrowse(void) throw ();
/** /**
* Do the searching. * Do the searching.
*/ */
@ -155,7 +160,7 @@ class SearchWindow : public WhiteWindow, public LocalizedObject
* Lists one clip per row. * Lists one clip per row.
* *
* @author $Author: fgerlits $ * @author $Author: fgerlits $
* @version $Revision: 1.6 $ * @version $Revision: 1.7 $
*/ */
class ModelColumns : public ZebraTreeModelColumnRecord class ModelColumns : public ZebraTreeModelColumnRecord
{ {

View file

@ -145,10 +145,14 @@ hu:table
creatorColumnLabel:string { "Előadó" } creatorColumnLabel:string { "Előadó" }
lengthColumnLabel:string { "Hossz" } lengthColumnLabel:string { "Hossz" }
titleMetadataDisplay:string { "Cím" } genreMetadataDisplay:string { "Műfaj" }
titleMetadataSearchKey:string { "dc:title" } genreMetadataSearchKey:string { "dc:type" }
creatorMetadataDisplay:string { "Előadó" } creatorMetadataDisplay:string { "Előadó" }
creatorMetadataSearchKey:string { "dc:creator" } creatorMetadataSearchKey:string { "dc:creator" }
albumMetadataDisplay:string { "Lemez" }
albumMetadataSearchKey:string { "dc:source" }
titleMetadataDisplay:string { "Cím" }
titleMetadataSearchKey:string { "dc:title" }
lengthMetadataDisplay:string { "Hossz" } lengthMetadataDisplay:string { "Hossz" }
lengthMetadataSearchKey:string { "dcterms:extent" } lengthMetadataSearchKey:string { "dcterms:extent" }

View file

@ -147,10 +147,14 @@ root:table
creatorColumnLabel:string { "Creator" } creatorColumnLabel:string { "Creator" }
lengthColumnLabel:string { "Length" } lengthColumnLabel:string { "Length" }
titleMetadataDisplay:string { "Title" } genreMetadataDisplay:string { "Genre" }
titleMetadataSearchKey:string { "dc:title" } genreMetadataSearchKey:string { "dc:type" }
creatorMetadataDisplay:string { "Creator" } creatorMetadataDisplay:string { "Creator" }
creatorMetadataSearchKey:string { "dc:creator" } creatorMetadataSearchKey:string { "dc:creator" }
albumMetadataDisplay:string { "Album" }
albumMetadataSearchKey:string { "dc:source" }
titleMetadataDisplay:string { "Title" }
titleMetadataSearchKey:string { "dc:title" }
lengthMetadataDisplay:string { "Length" } lengthMetadataDisplay:string { "Length" }
lengthMetadataSearchKey:string { "dcterms:extent" } lengthMetadataSearchKey:string { "dcterms:extent" }