diff --git a/livesupport/modules/storage/include/LiveSupport/Storage/StorageClientInterface.h b/livesupport/modules/storage/include/LiveSupport/Storage/StorageClientInterface.h index ca18ef216..077bd3fdd 100644 --- a/livesupport/modules/storage/include/LiveSupport/Storage/StorageClientInterface.h +++ b/livesupport/modules/storage/include/LiveSupport/Storage/StorageClientInterface.h @@ -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 >::Ref - browse(Ptr::Ref sessionId, - Ptr::Ref metadata, - Ptr::Ref searchCriteria) + browse(Ptr::Ref sessionId, + Ptr::Ref metadata, + Ptr::Ref searchCriteria) throw (XmlRpcException) = 0; diff --git a/livesupport/modules/storage/src/TestStorageClient.h b/livesupport/modules/storage/src/TestStorageClient.h index 7d115cafa..4ed5af736 100644 --- a/livesupport/modules/storage/src/TestStorageClient.h +++ b/livesupport/modules/storage/src/TestStorageClient.h @@ -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; * * * @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 >::Ref - browse(Ptr::Ref sessionId, - Ptr::Ref metadataType, - Ptr::Ref searchCriteria) + browse(Ptr::Ref sessionId, + Ptr::Ref metadataType, + Ptr::Ref searchCriteria) throw (XmlRpcException) { Ptr >::Ref null; diff --git a/livesupport/modules/storage/src/WebStorageClient.cxx b/livesupport/modules/storage/src/WebStorageClient.cxx index 9774b52ce..bf2e4c5f6 100644 --- a/livesupport/modules/storage/src/WebStorageClient.cxx +++ b/livesupport/modules/storage/src/WebStorageClient.cxx @@ -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::Ref sessionId, * Browse for metadata values. *----------------------------------------------------------------------------*/ Ptr >::Ref -WebStorageClient :: browse(Ptr::Ref sessionId, - Ptr::Ref metadataType, - Ptr::Ref searchCriteria) +WebStorageClient :: browse(Ptr::Ref sessionId, + Ptr::Ref metadataType, + Ptr::Ref searchCriteria) throw (XmlRpcException) { XmlRpcValue parameters; diff --git a/livesupport/modules/storage/src/WebStorageClient.h b/livesupport/modules/storage/src/WebStorageClient.h index 2cd60c56d..b81266e6f 100644 --- a/livesupport/modules/storage/src/WebStorageClient.h +++ b/livesupport/modules/storage/src/WebStorageClient.h @@ -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; * * * @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 >::Ref - browse(Ptr::Ref sessionId, - Ptr::Ref metadataType, - Ptr::Ref searchCriteria) + browse(Ptr::Ref sessionId, + Ptr::Ref metadataType, + Ptr::Ref searchCriteria) throw (XmlRpcException); /** diff --git a/livesupport/products/gLiveSupport/src/BrowseEntry.cxx b/livesupport/products/gLiveSupport/src/BrowseEntry.cxx index c603209a6..57e2854fd 100644 --- a/livesupport/products/gLiveSupport/src/BrowseEntry.cxx +++ b/livesupport/products/gLiveSupport/src/BrowseEntry.cxx @@ -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,20 +62,17 @@ 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( sigc::mem_fun(*browseItemTwo, &BrowseItem::onParentChangedShow), diff --git a/livesupport/products/gLiveSupport/src/BrowseItem.cxx b/livesupport/products/gLiveSupport/src/BrowseItem.cxx index 8c9ee29be..579e44d24 100644 --- a/livesupport/products/gLiveSupport/src/BrowseItem.cxx +++ b/livesupport/products/gLiveSupport/src/BrowseItem.cxx @@ -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::Ref gLiveSupport, - const Glib::ustring & metadata, - Ptr::Ref bundle) + Ptr::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::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); @@ -108,7 +90,14 @@ BrowseItem :: BrowseItem( scrolledWindow->set_policy(Gtk::POLICY_AUTOMATIC, Gtk::POLICY_AUTOMATIC); 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::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::Ref metadataKey = metadataEntry->getActiveKey(); - Glib::ustring metadataValue; - found = false; + Glib::ustring metadataValue; Glib::RefPtr 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::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::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::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); diff --git a/livesupport/products/gLiveSupport/src/BrowseItem.h b/livesupport/products/gLiveSupport/src/BrowseItem.h index 2840e39b1..1fa754d94 100644 --- a/livesupport/products/gLiveSupport/src/BrowseItem.h +++ b/livesupport/products/gLiveSupport/src/BrowseItem.h @@ -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 > MapVector; - /** - * The list of possible metadata field names. - */ - Ptr::Ref metadataTypes; - - /** - * The list of possible comparison operators. - */ - Ptr::Ref operatorTypes; - /** * The metadata field. */ - ComboBoxText * metadataEntry; + 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 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::Ref gLiveSupport, - const Glib::ustring & metadata, - Ptr::Ref bundle) + Ptr::Ref bundle, + int defaultIndex) throw (); /** diff --git a/livesupport/products/gLiveSupport/src/GLiveSupport.cxx b/livesupport/products/gLiveSupport/src/GLiveSupport.cxx index c9b9439de..a1aa144d4 100644 --- a/livesupport/products/gLiveSupport/src/GLiveSupport.cxx +++ b/livesupport/products/gLiveSupport/src/GLiveSupport.cxx @@ -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::Ref criteria) *----------------------------------------------------------------------------*/ Ptr >::Ref LiveSupport :: GLiveSupport :: -GLiveSupport :: browse(Ptr::Ref metadata, - Ptr::Ref criteria) +GLiveSupport :: browse(Ptr::Ref metadata, + Ptr::Ref criteria) throw (XmlRpcException) { return storage->browse(sessionId, metadata, criteria); diff --git a/livesupport/products/gLiveSupport/src/GLiveSupport.h b/livesupport/products/gLiveSupport/src/GLiveSupport.h index f043dc1f8..77f5ac281 100644 --- a/livesupport/products/gLiveSupport/src/GLiveSupport.h +++ b/livesupport/products/gLiveSupport/src/GLiveSupport.h @@ -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 >::Ref - browse(Ptr::Ref metadata, - Ptr::Ref criteria) + browse(Ptr::Ref metadata, + Ptr::Ref criteria) throw (XmlRpcException); /** diff --git a/livesupport/products/gLiveSupport/var/root.txt b/livesupport/products/gLiveSupport/var/root.txt index ad4a52252..3c7138a5b 100644 --- a/livesupport/products/gLiveSupport/var/root.txt +++ b/livesupport/products/gLiveSupport/var/root.txt @@ -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" }