added BrowseItem class;
moved "zebra striping" from separate function to addColumn()
This commit is contained in:
parent
27b7e34dde
commit
da57a326cd
14 changed files with 811 additions and 51 deletions
|
@ -22,7 +22,7 @@
|
|||
|
||||
|
||||
Author : $Author: fgerlits $
|
||||
Version : $Revision: 1.7 $
|
||||
Version : $Revision: 1.8 $
|
||||
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/widgets/include/LiveSupport/Widgets/ZebraTreeView.h,v $
|
||||
|
||||
------------------------------------------------------------------------------*/
|
||||
|
@ -91,7 +91,7 @@ using namespace LiveSupport::Core;
|
|||
* 3) connected with a TreeModelColumn using set_renderer().
|
||||
*
|
||||
* @author $Author: fgerlits $
|
||||
* @version $Revision: 1.7 $
|
||||
* @version $Revision: 1.8 $
|
||||
*/
|
||||
class ZebraTreeView : public Gtk::TreeView
|
||||
{
|
||||
|
@ -139,13 +139,6 @@ class ZebraTreeView : public Gtk::TreeView
|
|||
appendColumn(const Glib::ustring& title,
|
||||
const Gtk::TreeModelColumn<Glib::ustring>& modelColumn)
|
||||
throw ();
|
||||
|
||||
/**
|
||||
* Set the callback function for every column.
|
||||
*/
|
||||
void
|
||||
setCellDataFunction(void)
|
||||
throw ();
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
|
||||
|
||||
Author : $Author: fgerlits $
|
||||
Version : $Revision: 1.7 $
|
||||
Version : $Revision: 1.8 $
|
||||
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/widgets/src/ZebraTreeView.cxx,v $
|
||||
|
||||
------------------------------------------------------------------------------*/
|
||||
|
@ -83,37 +83,22 @@ ZebraTreeView :: appendColumn(
|
|||
const Gtk::TreeModelColumn<Glib::ustring>& modelColumn)
|
||||
throw ()
|
||||
{
|
||||
/*
|
||||
ZebraCellRenderer* renderer = Gtk::manage(new ZebraCellRenderer);
|
||||
// a standard cell renderer; can be replaced with a ZebraCellRenderer
|
||||
Gtk::CellRendererText* renderer = Gtk::manage(new Gtk::CellRendererText);
|
||||
|
||||
// the constructor packs the renderer into the TreeViewColumn
|
||||
Gtk::TreeViewColumn* viewColumn = Gtk::manage(new
|
||||
Gtk::TreeViewColumn(title, *renderer) );
|
||||
|
||||
// and then we associate this renderer with the model column
|
||||
viewColumn->set_renderer(*renderer, modelColumn);
|
||||
|
||||
return append_column(*viewColumn);
|
||||
*/
|
||||
// instead of the above, we just do the simple-minded thing, for now
|
||||
return append_column(title, modelColumn);
|
||||
}
|
||||
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Set the callback function for every column.
|
||||
*----------------------------------------------------------------------------*/
|
||||
void
|
||||
ZebraTreeView :: setCellDataFunction(void) throw ()
|
||||
{
|
||||
std::list<Column*> columnList = get_columns();
|
||||
std::list<Column*>::iterator it;
|
||||
|
||||
for (it = columnList.begin(); it != columnList.end(); ++it) {
|
||||
(*it)->set_cell_data_func(
|
||||
*(*it)->get_first_cell_renderer(),
|
||||
// this cell data function will do the blue-gray zebra stripes
|
||||
viewColumn->set_cell_data_func(
|
||||
*renderer,
|
||||
sigc::mem_fun(*this, &ZebraTreeView::cellDataFunction) );
|
||||
}
|
||||
|
||||
// set_rules_hint(); // suggest coloring with alternate colors
|
||||
return append_column(*viewColumn);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -21,7 +21,7 @@
|
|||
#
|
||||
#
|
||||
# Author : $Author: fgerlits $
|
||||
# Version : $Revision: 1.30 $
|
||||
# Version : $Revision: 1.31 $
|
||||
# Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/gLiveSupport/etc/Makefile.in,v $
|
||||
#
|
||||
# @configure_input@
|
||||
|
@ -190,7 +190,8 @@ G_LIVESUPPORT_OBJS = ${TMP_DIR}/GLiveSupport.o \
|
|||
${TMP_DIR}/SimplePlaylistManagementWindow.o \
|
||||
${TMP_DIR}/SchedulerWindow.o \
|
||||
${TMP_DIR}/SchedulePlaylistWindow.o \
|
||||
${TMP_DIR}/SearchWindow.o
|
||||
${TMP_DIR}/SearchWindow.o \
|
||||
${TMP_DIR}/BrowseItem.o
|
||||
|
||||
G_LIVESUPPORT_RES = ${TMP_DIR}/${PACKAGE_NAME}_root.res \
|
||||
${TMP_DIR}/${PACKAGE_NAME}_en.res \
|
||||
|
|
127
livesupport/products/gLiveSupport/src/BrowseEntry.cxx
Normal file
127
livesupport/products/gLiveSupport/src/BrowseEntry.cxx
Normal file
|
@ -0,0 +1,127 @@
|
|||
/*------------------------------------------------------------------------------
|
||||
|
||||
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/products/gLiveSupport/src/BrowseEntry.cxx,v $
|
||||
|
||||
------------------------------------------------------------------------------*/
|
||||
|
||||
/* ============================================================ include files */
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "configure.h"
|
||||
#endif
|
||||
|
||||
#include <iostream>
|
||||
|
||||
#include "LiveSupport/Widgets/BrowseItem.h"
|
||||
|
||||
#include "BrowseEntry.h"
|
||||
|
||||
|
||||
using namespace LiveSupport::Core;
|
||||
using namespace LiveSupport::Widgets;
|
||||
|
||||
/* =================================================== local data structures */
|
||||
|
||||
|
||||
/* ================================================ local constants & macros */
|
||||
|
||||
|
||||
/* =============================================== local function prototypes */
|
||||
|
||||
|
||||
/* ============================================================= module code */
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Constructor.
|
||||
*----------------------------------------------------------------------------*/
|
||||
BrowseEntry :: BrowseEntry(Ptr<ResourceBundle>::Ref bundle)
|
||||
throw ()
|
||||
: LocalizedObject(bundle)
|
||||
{
|
||||
BrowseItem * searchOptionsBox = Gtk::manage(new
|
||||
BrowseItem(true, getBundle()) );
|
||||
pack_start(*searchOptionsBox, Gtk::PACK_SHRINK, 5);
|
||||
|
||||
searchOptionsBox->signal_add_new().connect(sigc::mem_fun(*this,
|
||||
&BrowseEntry::onAddNewCondition ));
|
||||
}
|
||||
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Add a new search condition entrys item.
|
||||
*----------------------------------------------------------------------------*/
|
||||
void
|
||||
BrowseEntry :: onAddNewCondition(void) throw ()
|
||||
{
|
||||
BrowseItem * searchOptionsBox = Gtk::manage(new
|
||||
BrowseItem(false, getBundle()) );
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
130
livesupport/products/gLiveSupport/src/BrowseEntry.h
Normal file
130
livesupport/products/gLiveSupport/src/BrowseEntry.h
Normal file
|
@ -0,0 +1,130 @@
|
|||
/*------------------------------------------------------------------------------
|
||||
|
||||
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/products/gLiveSupport/src/BrowseEntry.h,v $
|
||||
|
||||
------------------------------------------------------------------------------*/
|
||||
#ifndef LiveSupport_GLiveSupport_BrowseEntry_h
|
||||
#define LiveSupport_GLiveSupport_BrowseEntry_h
|
||||
|
||||
#ifndef __cplusplus
|
||||
#error This is a C++ include file
|
||||
#endif
|
||||
|
||||
|
||||
/* ============================================================ include files */
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "configure.h"
|
||||
#endif
|
||||
|
||||
#include <gtkmm/box.h>
|
||||
|
||||
#include "LiveSupport/Core/Ptr.h"
|
||||
#include "LiveSupport/Core/LocalizedObject.h"
|
||||
#include "LiveSupport/Core/SearchCriteria.h"
|
||||
|
||||
|
||||
namespace LiveSupport {
|
||||
namespace GLiveSupport {
|
||||
|
||||
using namespace LiveSupport::Core;
|
||||
|
||||
/* ================================================================ constants */
|
||||
|
||||
|
||||
/* =================================================================== macros */
|
||||
|
||||
|
||||
/* =============================================================== data types */
|
||||
|
||||
/**
|
||||
* A Gtk::VBox with one or more search input fields in it.
|
||||
*
|
||||
* @author $Author: fgerlits $
|
||||
* @version $Revision: 1.1 $
|
||||
*/
|
||||
class BrowseEntry : public Gtk::VBox,
|
||||
public LocalizedObject
|
||||
{
|
||||
private:
|
||||
|
||||
/**
|
||||
* Default constructor.
|
||||
*/
|
||||
BrowseEntry(void) throw ();
|
||||
|
||||
public:
|
||||
|
||||
/**
|
||||
* Constructor with localization parameter.
|
||||
*/
|
||||
BrowseEntry(Ptr<ResourceBundle>::Ref bundle)
|
||||
throw ();
|
||||
|
||||
/**
|
||||
* A virtual destructor.
|
||||
*/
|
||||
virtual
|
||||
~BrowseEntry(void) throw ()
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a new search condition entry item.
|
||||
*/
|
||||
void
|
||||
onAddNewCondition(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>::Ref
|
||||
getSearchCriteria(void) throw ();
|
||||
|
||||
/**
|
||||
* Connect a callback to the "enter key pressed" event.
|
||||
*
|
||||
* @param callback the function to execute when enter is pressed.
|
||||
*/
|
||||
void
|
||||
connectCallback(const sigc::slot<void> & callback) throw ();
|
||||
};
|
||||
|
||||
|
||||
/* ================================================= external data structures */
|
||||
|
||||
|
||||
/* ====================================================== function prototypes */
|
||||
|
||||
|
||||
} // namespace Widgets
|
||||
} // namespace LiveSupport
|
||||
|
||||
#endif // LiveSupport_Widgets_BrowseEntry_h
|
||||
|
244
livesupport/products/gLiveSupport/src/BrowseItem.cxx
Normal file
244
livesupport/products/gLiveSupport/src/BrowseItem.cxx
Normal file
|
@ -0,0 +1,244 @@
|
|||
/*------------------------------------------------------------------------------
|
||||
|
||||
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/products/gLiveSupport/src/BrowseItem.cxx,v $
|
||||
|
||||
------------------------------------------------------------------------------*/
|
||||
|
||||
/* ============================================================ include files */
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "configure.h"
|
||||
#endif
|
||||
|
||||
#include <iostream>
|
||||
|
||||
#include "LiveSupport/Widgets/WidgetFactory.h"
|
||||
|
||||
#include "BrowseItem.h"
|
||||
|
||||
|
||||
using namespace LiveSupport::Core;
|
||||
using namespace LiveSupport::Widgets;
|
||||
using namespace LiveSupport::GLiveSupport;
|
||||
|
||||
/* =================================================== local data structures */
|
||||
|
||||
|
||||
/* ================================================ local constants & macros */
|
||||
|
||||
|
||||
/* =============================================== local function prototypes */
|
||||
|
||||
|
||||
/* ============================================================= module code */
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Constructor.
|
||||
*----------------------------------------------------------------------------*/
|
||||
BrowseItem :: BrowseItem(
|
||||
Ptr<LiveSupport::GLiveSupport::GLiveSupport>::Ref gLiveSupport,
|
||||
Ptr<Glib::ustring>::Ref metadata,
|
||||
Ptr<SearchCriteria>::Ref parentCriteria,
|
||||
Ptr<ResourceBundle>::Ref bundle)
|
||||
throw ()
|
||||
: LocalizedObject(bundle),
|
||||
gLiveSupport(gLiveSupport),
|
||||
parentCriteria(parentCriteria)
|
||||
{
|
||||
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();
|
||||
|
||||
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);
|
||||
}
|
||||
pack_start(*metadataEntry, Gtk::PACK_EXPAND_WIDGET, 5);
|
||||
|
||||
treeModel = Gtk::ListStore::create(modelColumns);
|
||||
|
||||
metadataValues = Gtk::manage(wf->createTreeView(treeModel));
|
||||
metadataValues->appendColumn("", modelColumns.column);
|
||||
metadataValues->set_headers_visible(false);
|
||||
pack_start(*metadataValues, Gtk::PACK_EXPAND_WIDGET, 5);
|
||||
|
||||
reset();
|
||||
}
|
||||
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Return the current state of the search fields.
|
||||
*----------------------------------------------------------------------------*/
|
||||
Ptr<SearchCriteria::SearchConditionType>::Ref
|
||||
BrowseItem :: getSearchCondition(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);
|
||||
}
|
||||
|
||||
Glib::ustring metadataValue;
|
||||
found = false;
|
||||
Glib::RefPtr<Gtk::TreeView::Selection> refSelection =
|
||||
metadataValues->get_selection();
|
||||
if (refSelection) {
|
||||
Gtk::TreeModel::iterator iter = refSelection->get_selected();
|
||||
if (iter) {
|
||||
metadataValue = (*iter)[modelColumns.column];
|
||||
}
|
||||
}
|
||||
|
||||
if (!found) {
|
||||
metadataValue = *getResourceUstring("allStringForBrowse");
|
||||
} // may throw std::invalid_argument
|
||||
|
||||
Ptr<SearchCriteria::SearchConditionType>::Ref
|
||||
condition(new SearchCriteria::SearchConditionType(
|
||||
metadataKey, "=", metadataValue ));
|
||||
return condition;
|
||||
}
|
||||
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* 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("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
|
||||
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 :: reset(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);
|
||||
}
|
||||
|
||||
treeModel->clear();
|
||||
int rowNumber = 1;
|
||||
Gtk::TreeModel::Row row = *treeModel->append();
|
||||
try {
|
||||
row[modelColumns.column] = *getResourceUstring("allStringForBrowse");
|
||||
} catch (std::invalid_argument &e) {
|
||||
std::cerr << e.what() << std::endl;
|
||||
std::exit(1);
|
||||
}
|
||||
row[modelColumns.rowNumberColumn] = rowNumber++;
|
||||
metadataValues->get_selection()->select(*row);
|
||||
|
||||
Ptr<std::vector<Glib::ustring> >::Ref
|
||||
values = gLiveSupport->browse(metadataKey, parentCriteria);
|
||||
std::vector<Glib::ustring>::const_iterator valuesIt;
|
||||
for (valuesIt = values->begin(); valuesIt != values->end(); ++valuesIt) {
|
||||
row = *treeModel->append();
|
||||
row[modelColumns.column] = *valuesIt;
|
||||
row[modelColumns.rowNumberColumn] = rowNumber++;
|
||||
}
|
||||
}
|
||||
|
230
livesupport/products/gLiveSupport/src/BrowseItem.h
Normal file
230
livesupport/products/gLiveSupport/src/BrowseItem.h
Normal file
|
@ -0,0 +1,230 @@
|
|||
/*------------------------------------------------------------------------------
|
||||
|
||||
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/products/gLiveSupport/src/BrowseItem.h,v $
|
||||
|
||||
------------------------------------------------------------------------------*/
|
||||
#ifndef LiveSupport_GLiveSupport_BrowseItem_h
|
||||
#define LiveSupport_GLiveSupport_BrowseItem_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.h>
|
||||
|
||||
#include "LiveSupport/Core/Ptr.h"
|
||||
#include "LiveSupport/Core/LocalizedObject.h"
|
||||
#include "LiveSupport/Core/SearchCriteria.h"
|
||||
#include "LiveSupport/Widgets/ComboBoxText.h"
|
||||
#include "LiveSupport/Widgets/ZebraTreeView.h"
|
||||
#include "LiveSupport/Widgets/ZebraTreeModelColumnRecord.h"
|
||||
|
||||
#include "GLiveSupport.h"
|
||||
|
||||
|
||||
namespace LiveSupport {
|
||||
namespace GLiveSupport {
|
||||
|
||||
using namespace LiveSupport::Core;
|
||||
using namespace LiveSupport::Widgets;
|
||||
|
||||
/* ================================================================ constants */
|
||||
|
||||
|
||||
/* =================================================================== macros */
|
||||
|
||||
|
||||
/* =============================================================== data types */
|
||||
|
||||
/**
|
||||
* A single browse input field.
|
||||
*
|
||||
* @author $Author: fgerlits $
|
||||
* @version $Revision: 1.1 $
|
||||
*/
|
||||
class BrowseItem : public Gtk::VBox,
|
||||
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 selection field.
|
||||
*/
|
||||
ZebraTreeView * metadataValues;
|
||||
|
||||
/**
|
||||
* The columns model needed by Gtk::TreeView.
|
||||
* Lists one clip per row.
|
||||
*
|
||||
* @author $Author: fgerlits $
|
||||
* @version $Revision: 1.1 $
|
||||
*/
|
||||
class ModelColumns : public ZebraTreeModelColumnRecord
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* The single displayed column.
|
||||
*/
|
||||
Gtk::TreeModelColumn<Glib::ustring> column;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*/
|
||||
ModelColumns(void) throw ()
|
||||
{
|
||||
add(column);
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* The column model.
|
||||
*/
|
||||
ModelColumns modelColumns;
|
||||
|
||||
/**
|
||||
* The tree model, as a GTK reference.
|
||||
*/
|
||||
Glib::RefPtr<Gtk::ListStore> treeModel;
|
||||
|
||||
/**
|
||||
* The GLiveSupport object, holding the state of the application.
|
||||
*/
|
||||
Ptr<LiveSupport::GLiveSupport::GLiveSupport>::Ref gLiveSupport;
|
||||
|
||||
/**
|
||||
* The criteria from the browse items to the left of this one.
|
||||
*/
|
||||
Ptr<SearchCriteria>::Ref parentCriteria;
|
||||
|
||||
/**
|
||||
* Default constructor.
|
||||
*/
|
||||
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);
|
||||
|
||||
|
||||
public:
|
||||
|
||||
/**
|
||||
* 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
|
||||
*/
|
||||
BrowseItem(
|
||||
Ptr<LiveSupport::GLiveSupport::GLiveSupport>::Ref gLiveSupport,
|
||||
Ptr<Glib::ustring>::Ref metadata,
|
||||
Ptr<SearchCriteria>::Ref parentCriteria,
|
||||
Ptr<ResourceBundle>::Ref bundle)
|
||||
throw ();
|
||||
|
||||
/**
|
||||
* A virtual destructor.
|
||||
*/
|
||||
virtual
|
||||
~BrowseItem(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 (std::invalid_argument);
|
||||
|
||||
/**
|
||||
* Fill in the column with the possible values (limited by the
|
||||
* parent criteria), and set the selection to "all".
|
||||
*/
|
||||
void
|
||||
reset(void) throw ();
|
||||
};
|
||||
|
||||
|
||||
/* ================================================= external data structures */
|
||||
|
||||
|
||||
/* ====================================================== function prototypes */
|
||||
|
||||
|
||||
} // namespace GLiveSupport
|
||||
} // namespace LiveSupport
|
||||
|
||||
#endif // LiveSupport_GLiveSupport_BrowseItem_h
|
||||
|
|
@ -22,7 +22,7 @@
|
|||
|
||||
|
||||
Author : $Author: fgerlits $
|
||||
Version : $Revision: 1.30 $
|
||||
Version : $Revision: 1.31 $
|
||||
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/gLiveSupport/src/GLiveSupport.cxx,v $
|
||||
|
||||
------------------------------------------------------------------------------*/
|
||||
|
@ -786,3 +786,16 @@ GLiveSupport :: search(Ptr<SearchCriteria>::Ref criteria)
|
|||
return results;
|
||||
}
|
||||
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Browse in the local storage.
|
||||
*----------------------------------------------------------------------------*/
|
||||
Ptr<std::vector<Glib::ustring> >::Ref
|
||||
LiveSupport :: GLiveSupport ::
|
||||
GLiveSupport :: browse(Ptr<Glib::ustring>::Ref metadata,
|
||||
Ptr<SearchCriteria>::Ref criteria)
|
||||
throw (XmlRpcException)
|
||||
{
|
||||
return storage->browse(sessionId, metadata, criteria);
|
||||
}
|
||||
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
|
||||
|
||||
Author : $Author: fgerlits $
|
||||
Version : $Revision: 1.26 $
|
||||
Version : $Revision: 1.27 $
|
||||
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/gLiveSupport/src/GLiveSupport.h,v $
|
||||
|
||||
------------------------------------------------------------------------------*/
|
||||
|
@ -100,7 +100,7 @@ class MasterPanelWindow;
|
|||
* respective documentation.
|
||||
*
|
||||
* @author $Author: fgerlits $
|
||||
* @version $Revision: 1.26 $
|
||||
* @version $Revision: 1.27 $
|
||||
* @see LocalizedObject#getBundle(const xmlpp::Element &)
|
||||
* @see AuthenticationClientFactory
|
||||
* @see StorageClientFactory
|
||||
|
@ -594,6 +594,19 @@ class GLiveSupport : public LocalizedConfigurable,
|
|||
search(Ptr<SearchCriteria>::Ref criteria)
|
||||
throw (XmlRpcException);
|
||||
|
||||
/**
|
||||
* Browse in the local storage.
|
||||
*
|
||||
* @param metadata the type of metadata to list (e.g., "dc:title").
|
||||
* @param criteria the search conditions to use.
|
||||
* @return the list of metadata values found.
|
||||
* @exception XmlRpcException passed on from Storage::browse()
|
||||
*/
|
||||
Ptr<std::vector<Glib::ustring> >::Ref
|
||||
browse(Ptr<Glib::ustring>::Ref metadata,
|
||||
Ptr<SearchCriteria>::Ref criteria)
|
||||
throw (XmlRpcException);
|
||||
|
||||
};
|
||||
|
||||
/* ================================================= external data structures */
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
|
||||
|
||||
Author : $Author: fgerlits $
|
||||
Version : $Revision: 1.7 $
|
||||
Version : $Revision: 1.8 $
|
||||
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/gLiveSupport/src/ScratchpadWindow.cxx,v $
|
||||
|
||||
------------------------------------------------------------------------------*/
|
||||
|
@ -126,9 +126,6 @@ ScratchpadWindow :: ScratchpadWindow (Ptr<GLiveSupport>::Ref gLiveSupport,
|
|||
std::exit(1);
|
||||
}
|
||||
|
||||
// color the rows blue and gray
|
||||
treeView->setCellDataFunction();
|
||||
|
||||
// register the signal handler for treeview entries being clicked
|
||||
treeView->signal_button_press_event().connect_notify(sigc::mem_fun(*this,
|
||||
&ScratchpadWindow::onEntryClicked));
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
|
||||
|
||||
Author : $Author: fgerlits $
|
||||
Version : $Revision: 1.6 $
|
||||
Version : $Revision: 1.7 $
|
||||
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/gLiveSupport/src/SearchWindow.cxx,v $
|
||||
|
||||
------------------------------------------------------------------------------*/
|
||||
|
@ -204,7 +204,25 @@ SearchWindow :: constructBrowseView(void) throw ()
|
|||
{
|
||||
Ptr<WidgetFactory>::Ref wf = WidgetFactory::getInstance();
|
||||
|
||||
// FIXME
|
||||
Ptr<Glib::ustring>::Ref metadata(new Glib::ustring("Title"));
|
||||
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
|
||||
ZebraTreeView * searchResults = constructSearchResults();
|
||||
|
||||
// make a new box and pack the main components into it
|
||||
Gtk::VBox * view = Gtk::manage(new Gtk::VBox);
|
||||
view->pack_start(*browsePanel, Gtk::PACK_EXPAND_WIDGET, 5);
|
||||
view->pack_start(*searchResults, Gtk::PACK_EXPAND_WIDGET, 5);
|
||||
return view;
|
||||
}
|
||||
|
||||
|
@ -235,9 +253,6 @@ SearchWindow :: constructSearchResults(void) throw ()
|
|||
std::exit(1);
|
||||
}
|
||||
|
||||
// color the rows blue and gray
|
||||
searchResults->setCellDataFunction();
|
||||
|
||||
return searchResults;
|
||||
}
|
||||
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
|
||||
|
||||
Author : $Author: fgerlits $
|
||||
Version : $Revision: 1.5 $
|
||||
Version : $Revision: 1.6 $
|
||||
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/gLiveSupport/src/SearchWindow.h,v $
|
||||
|
||||
------------------------------------------------------------------------------*/
|
||||
|
@ -52,6 +52,8 @@
|
|||
#include "LiveSupport/Widgets/ZebraTreeModelColumnRecord.h"
|
||||
#include "LiveSupport/Widgets/AdvancedSearchEntry.h"
|
||||
#include "GLiveSupport.h"
|
||||
//FIXME
|
||||
#include "BrowseItem.h"
|
||||
|
||||
namespace LiveSupport {
|
||||
namespace GLiveSupport {
|
||||
|
@ -71,7 +73,7 @@ using namespace LiveSupport::Widgets;
|
|||
* The Search/Browse window.
|
||||
*
|
||||
* @author $Author: fgerlits $
|
||||
* @version $Revision: 1.5 $
|
||||
* @version $Revision: 1.6 $
|
||||
*/
|
||||
class SearchWindow : public WhiteWindow, public LocalizedObject
|
||||
{
|
||||
|
@ -87,6 +89,12 @@ class SearchWindow : public WhiteWindow, public LocalizedObject
|
|||
*/
|
||||
AdvancedSearchEntry * advancedSearchEntry;
|
||||
|
||||
/**
|
||||
* The box containing the browse input fields.
|
||||
*/
|
||||
// FIXME
|
||||
BrowseItem * browseEntry;
|
||||
|
||||
/**
|
||||
* Construct the simple search view.
|
||||
* If you enter a string in the simple search view and press Enter
|
||||
|
@ -147,7 +155,7 @@ class SearchWindow : public WhiteWindow, public LocalizedObject
|
|||
* Lists one clip per row.
|
||||
*
|
||||
* @author $Author: fgerlits $
|
||||
* @version $Revision: 1.5 $
|
||||
* @version $Revision: 1.6 $
|
||||
*/
|
||||
class ModelColumns : public ZebraTreeModelColumnRecord
|
||||
{
|
||||
|
|
|
@ -162,6 +162,8 @@ hu:table
|
|||
<=OperatorSearchKey:string { "<=" }
|
||||
>=OperatorDisplay:string { ">=" }
|
||||
>=OperatorSearchKey:string { ">=" }
|
||||
|
||||
allStringForBrowse { "--- minden ---" }
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -164,6 +164,8 @@ root:table
|
|||
<=OperatorSearchKey:string { "<=" }
|
||||
>=OperatorDisplay:string { ">=" }
|
||||
>=OperatorSearchKey:string { ">=" }
|
||||
|
||||
allStringForBrowse { "--- all ---" }
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue