modified the browse tab to use the new MetadataComboBoxText widget;

had to change function argument types from Ptr<Glib::ustring>::Ref to Ptr<const Glib::ustring>::Ref all the way down the line.
This commit is contained in:
fgerlits 2005-05-26 20:54:55 +00:00
parent 733b565668
commit e1f3e0e9ca
10 changed files with 68 additions and 211 deletions

View file

@ -22,7 +22,7 @@
Author : $Author: fgerlits $
Version : $Revision: 1.13 $
Version : $Revision: 1.14 $
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/storage/include/LiveSupport/Storage/StorageClientInterface.h,v $
------------------------------------------------------------------------------*/
@ -66,7 +66,7 @@ using namespace Core;
* An interface for storage clients.
*
* @author $Author: fgerlits $
* @version $Revision: 1.13 $
* @version $Revision: 1.14 $
*/
class StorageClientInterface
{
@ -388,9 +388,9 @@ class StorageClientInterface
* call.
*/
virtual Ptr<std::vector<Glib::ustring> >::Ref
browse(Ptr<SessionId>::Ref sessionId,
Ptr<Glib::ustring>::Ref metadata,
Ptr<SearchCriteria>::Ref searchCriteria)
browse(Ptr<SessionId>::Ref sessionId,
Ptr<const Glib::ustring>::Ref metadata,
Ptr<SearchCriteria>::Ref searchCriteria)
throw (XmlRpcException)
= 0;

View file

@ -22,7 +22,7 @@
Author : $Author: fgerlits $
Version : $Revision: 1.32 $
Version : $Revision: 1.33 $
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/storage/src/TestStorageClient.h,v $
------------------------------------------------------------------------------*/
@ -86,7 +86,7 @@ using namespace LiveSupport::Core;
* </code></pre>
*
* @author $Author: fgerlits $
* @version $Revision: 1.32 $
* @version $Revision: 1.33 $
*/
class TestStorageClient :
virtual public Configurable,
@ -536,9 +536,9 @@ class TestStorageClient :
* call.
*/
virtual Ptr<std::vector<Glib::ustring> >::Ref
browse(Ptr<SessionId>::Ref sessionId,
Ptr<Glib::ustring>::Ref metadataType,
Ptr<SearchCriteria>::Ref searchCriteria)
browse(Ptr<SessionId>::Ref sessionId,
Ptr<const Glib::ustring>::Ref metadataType,
Ptr<SearchCriteria>::Ref searchCriteria)
throw (XmlRpcException)
{
Ptr<std::vector<Glib::ustring> >::Ref null;

View file

@ -22,7 +22,7 @@
Author : $Author: fgerlits $
Version : $Revision: 1.39 $
Version : $Revision: 1.40 $
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/storage/src/WebStorageClient.cxx,v $
------------------------------------------------------------------------------*/
@ -2130,9 +2130,9 @@ WebStorageClient :: search(Ptr<SessionId>::Ref sessionId,
* Browse for metadata values.
*----------------------------------------------------------------------------*/
Ptr<std::vector<Glib::ustring> >::Ref
WebStorageClient :: browse(Ptr<SessionId>::Ref sessionId,
Ptr<Glib::ustring>::Ref metadataType,
Ptr<SearchCriteria>::Ref searchCriteria)
WebStorageClient :: browse(Ptr<SessionId>::Ref sessionId,
Ptr<const Glib::ustring>::Ref metadataType,
Ptr<SearchCriteria>::Ref searchCriteria)
throw (XmlRpcException)
{
XmlRpcValue parameters;

View file

@ -22,7 +22,7 @@
Author : $Author: fgerlits $
Version : $Revision: 1.26 $
Version : $Revision: 1.27 $
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/storage/src/WebStorageClient.h,v $
------------------------------------------------------------------------------*/
@ -96,7 +96,7 @@ using namespace LiveSupport::Core;
* </code></pre>
*
* @author $Author: fgerlits $
* @version $Revision: 1.26 $
* @version $Revision: 1.27 $
*/
class WebStorageClient :
virtual public Configurable,
@ -532,9 +532,9 @@ class WebStorageClient :
* call.
*/
virtual Ptr<std::vector<Glib::ustring> >::Ref
browse(Ptr<SessionId>::Ref sessionId,
Ptr<Glib::ustring>::Ref metadataType,
Ptr<SearchCriteria>::Ref searchCriteria)
browse(Ptr<SessionId>::Ref sessionId,
Ptr<const Glib::ustring>::Ref metadataType,
Ptr<SearchCriteria>::Ref searchCriteria)
throw (XmlRpcException);
/**

View file

@ -22,7 +22,7 @@
Author : $Author: fgerlits $
Version : $Revision: 1.2 $
Version : $Revision: 1.3 $
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/gLiveSupport/src/BrowseEntry.cxx,v $
------------------------------------------------------------------------------*/
@ -62,19 +62,16 @@ BrowseEntry :: BrowseEntry(
throw ()
: LocalizedObject(bundle)
{
browseItemOne = Gtk::manage(new BrowseItem(
gLiveSupport,
*getResourceUstring("genreMetadataDisplay"),
bundle ));
browseItemTwo = Gtk::manage(new BrowseItem(
gLiveSupport,
*getResourceUstring("creatorMetadataDisplay"),
bundle ));
browseItemThree = Gtk::manage(new BrowseItem(
gLiveSupport,
*getResourceUstring("albumMetadataDisplay"),
bundle ));
browseItemOne = Gtk::manage(new BrowseItem(gLiveSupport,
bundle,
4 /* Genre */));
browseItemTwo = Gtk::manage(new BrowseItem(gLiveSupport,
bundle,
1 /* Creator */));
browseItemThree = Gtk::manage(new BrowseItem(gLiveSupport,
bundle,
2 /* Album */));
// TODO: change hard-coded indices to stuff read from config
browseItemOne->signalSelectionChanged().connect(
sigc::bind<BrowseItem*>(

View file

@ -22,7 +22,7 @@
Author : $Author: fgerlits $
Version : $Revision: 1.3 $
Version : $Revision: 1.4 $
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/gLiveSupport/src/BrowseItem.cxx,v $
------------------------------------------------------------------------------*/
@ -60,37 +60,19 @@ using namespace LiveSupport::GLiveSupport;
*----------------------------------------------------------------------------*/
BrowseItem :: BrowseItem(
Ptr<LiveSupport::GLiveSupport::GLiveSupport>::Ref gLiveSupport,
const Glib::ustring & metadata,
Ptr<ResourceBundle>::Ref bundle)
Ptr<ResourceBundle>::Ref bundle,
int defaultIndex)
throw ()
: LocalizedObject(bundle),
gLiveSupport(gLiveSupport)
{
try {
if (!metadataTypes) {
readMetadataTypes();
}
if (!operatorTypes) {
readOperatorTypes();
}
} catch (std::invalid_argument &e) {
std::cerr << e.what() << std::endl;
std::exit(1);
}
parentCriteria.reset(new SearchCriteria);
Ptr<WidgetFactory>::Ref wf = WidgetFactory::getInstance();
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(metadata);
if (metadataEntry->get_active_text() != metadata) {
metadataEntry->set_active_text(metadataTypes->front().first);
}
metadataEntry = Gtk::manage(wf->createMetadataComboBoxText(
gLiveSupport->getMetadataTypeContainer()));
metadataEntry->set_active(defaultIndex);
metadataEntry->signalSelectionChanged().connect(sigc::mem_fun(*this,
&BrowseItem::onShow ));
pack_start(*metadataEntry, Gtk::PACK_SHRINK, 5);
@ -109,6 +91,13 @@ BrowseItem :: BrowseItem(
scrolledWindow->add(*metadataValues);
pack_start(*scrolledWindow, Gtk::PACK_SHRINK, 5);
try {
allString = *getResourceUstring("allStringForBrowse");
} catch (std::invalid_argument &e) {
std::cerr << e.what() << std::endl;
std::exit(1);
}
onShow();
}
@ -119,27 +108,12 @@ BrowseItem :: BrowseItem(
Ptr<SearchCriteria>::Ref
BrowseItem :: getSearchCriteria(void) throw (std::invalid_argument)
{
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);
}
Ptr<const Glib::ustring>::Ref metadataKey = metadataEntry->getActiveKey();
Glib::ustring metadataValue;
found = false;
Glib::ustring metadataValue;
Glib::RefPtr<Gtk::TreeView::Selection> refSelection =
metadataValues->get_selection();
bool found = false;
if (refSelection) {
Gtk::TreeModel::iterator iter = refSelection->get_selected();
if (iter) {
@ -157,98 +131,23 @@ BrowseItem :: getSearchCriteria(void) throw (std::invalid_argument)
} else {
Ptr<SearchCriteria>::Ref criteria(new SearchCriteria(*parentCriteria));
criteria->addCondition(metadataKey, "=", metadataValue);
criteria->addCondition(*metadataKey, "=", metadataValue);
return criteria;
}
}
/*------------------------------------------------------------------------------
* Read the localized metadata field names.
*----------------------------------------------------------------------------*/
void
BrowseItem :: readMetadataTypes(void)
throw (std::invalid_argument)
{
metadataTypes.reset(new MapVector);
metadataTypes->push_back(std::make_pair(
*getResourceUstring("genreMetadataDisplay"),
*getResourceUstring("genreMetadataSearchKey") ));
metadataTypes->push_back(std::make_pair(
*getResourceUstring("creatorMetadataDisplay"),
*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(
*getResourceUstring("lengthMetadataDisplay"),
*getResourceUstring("lengthMetadataSearchKey") ));
}
/*------------------------------------------------------------------------------
* Read the localized comparison operator names.
*----------------------------------------------------------------------------*/
void
BrowseItem :: 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") ));
}
/*------------------------------------------------------------------------------
* Fill in the column with the possible values.
*----------------------------------------------------------------------------*/
void
BrowseItem :: onShow(void) throw ()
{
std::string metadataName = metadataEntry->get_active_text();
Ptr<Glib::ustring>::Ref metadataKey(new Glib::ustring);
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);
}
Ptr<const Glib::ustring>::Ref metadataKey = metadataEntry->getActiveKey();
treeModel->clear();
int rowNumber = 1;
Gtk::TreeModel::Row row = *treeModel->append();
try {
allString = *getResourceUstring("allStringForBrowse");
} catch (std::invalid_argument &e) {
std::cerr << e.what() << std::endl;
std::exit(1);
}
row[modelColumns.column] = allString;
row[modelColumns.rowNumberColumn] = rowNumber++;
metadataValues->get_selection()->select(*row);

View file

@ -22,7 +22,7 @@
Author : $Author: fgerlits $
Version : $Revision: 1.2 $
Version : $Revision: 1.3 $
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/gLiveSupport/src/BrowseItem.h,v $
------------------------------------------------------------------------------*/
@ -80,7 +80,7 @@ using namespace LiveSupport::Widgets;
* this one.
*
* @author $Author: fgerlits $
* @version $Revision: 1.2 $
* @version $Revision: 1.3 $
*/
class BrowseItem : public Gtk::VBox,
public LocalizedObject
@ -94,20 +94,10 @@ class BrowseItem : public Gtk::VBox,
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;
MetadataComboBoxText * metadataEntry;
/**
* The selection field.
@ -119,7 +109,7 @@ class BrowseItem : public Gtk::VBox,
* Lists one clip per row.
*
* @author $Author: fgerlits $
* @version $Revision: 1.2 $
* @version $Revision: 1.3 $
*/
class ModelColumns : public ZebraTreeModelColumnRecord
{
@ -149,8 +139,7 @@ class BrowseItem : public Gtk::VBox,
Glib::RefPtr<Gtk::ListStore> treeModel;
/**
* This is pretty lame, but we store the localized version of the
* "--- all ---" string here.
* The localized version of the "--- all ---" string.
*/
Glib::ustring allString;
@ -169,24 +158,6 @@ class BrowseItem : public Gtk::VBox,
*/
BrowseItem(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);
/**
* Emit the "selection changed" signal.
*/
@ -210,14 +181,15 @@ class BrowseItem : public Gtk::VBox,
/**
* Constructor with parent and 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
* @param gLiveSupport the main program object
* @param bundle the resource bundle for localization
* @param defaultIndex the index of the metadata entry to display
* initially
*/
BrowseItem(
Ptr<LiveSupport::GLiveSupport::GLiveSupport>::Ref gLiveSupport,
const Glib::ustring & metadata,
Ptr<ResourceBundle>::Ref bundle)
Ptr<ResourceBundle>::Ref bundle,
int defaultIndex)
throw ();
/**

View file

@ -22,7 +22,7 @@
Author : $Author: fgerlits $
Version : $Revision: 1.45 $
Version : $Revision: 1.46 $
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/gLiveSupport/src/GLiveSupport.cxx,v $
------------------------------------------------------------------------------*/
@ -1071,8 +1071,8 @@ GLiveSupport :: search(Ptr<SearchCriteria>::Ref criteria)
*----------------------------------------------------------------------------*/
Ptr<std::vector<Glib::ustring> >::Ref
LiveSupport :: GLiveSupport ::
GLiveSupport :: browse(Ptr<Glib::ustring>::Ref metadata,
Ptr<SearchCriteria>::Ref criteria)
GLiveSupport :: browse(Ptr<const Glib::ustring>::Ref metadata,
Ptr<SearchCriteria>::Ref criteria)
throw (XmlRpcException)
{
return storage->browse(sessionId, metadata, criteria);

View file

@ -22,7 +22,7 @@
Author : $Author: fgerlits $
Version : $Revision: 1.36 $
Version : $Revision: 1.37 $
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/gLiveSupport/src/GLiveSupport.h,v $
------------------------------------------------------------------------------*/
@ -102,7 +102,7 @@ class MasterPanelWindow;
* respective documentation.
*
* @author $Author: fgerlits $
* @version $Revision: 1.36 $
* @version $Revision: 1.37 $
* @see LocalizedObject#getBundle(const xmlpp::Element &)
* @see AuthenticationClientFactory
* @see StorageClientFactory
@ -714,8 +714,8 @@ class GLiveSupport : public LocalizedConfigurable,
* @exception XmlRpcException passed on from Storage::browse()
*/
Ptr<std::vector<Glib::ustring> >::Ref
browse(Ptr<Glib::ustring>::Ref metadata,
Ptr<SearchCriteria>::Ref criteria)
browse(Ptr<const Glib::ustring>::Ref metadata,
Ptr<SearchCriteria>::Ref criteria)
throw (XmlRpcException);
/**

View file

@ -151,17 +151,6 @@ root:table
creatorColumnLabel:string { "Creator" }
lengthColumnLabel:string { "Length" }
genreMetadataDisplay:string { "Genre" }
genreMetadataSearchKey:string { "dc:type" }
creatorMetadataDisplay:string { "Creator" }
creatorMetadataSearchKey:string { "dc:creator" }
albumMetadataDisplay:string { "Album" }
albumMetadataSearchKey:string { "dc:source" }
titleMetadataDisplay:string { "Title" }
titleMetadataSearchKey:string { "dc:title" }
lengthMetadataDisplay:string { "Length" }
lengthMetadataSearchKey:string { "dcterms:extent" }
partialOperatorDisplay:string { "contains" }
partialOperatorSearchKey:string { "partial" }
prefixOperatorDisplay:string { "starts with" }