added search functionality;

fixed bug in Playable::getMetadata;
added doxygen tag file generation in main doxygen.config file;
fixed silly bug in ZebraTreeView::cellDataFunction
This commit is contained in:
fgerlits 2005-04-21 15:51:35 +00:00
parent 4763ea6e2c
commit 4c19a1c60f
19 changed files with 249 additions and 57 deletions

View file

@ -20,8 +20,8 @@
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#
#
# Author : $Author: maroy $
# Version : $Revision: 1.11 $
# Author : $Author: fgerlits $
# Version : $Revision: 1.12 $
# Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/etc/doxygen.config,v $
#-------------------------------------------------------------------------------
@ -1003,7 +1003,7 @@ TAGFILES = \
# When a file name is specified after GENERATE_TAGFILE, doxygen will create
# a tag file that is based on the input files it reads.
GENERATE_TAGFILE =
GENERATE_TAGFILE = ./doc/doxygen/liveSupport.tag
# If the ALLEXTERNALS tag is set to YES all external classes will be listed
# in the class index. If set to NO only the inherited external classes

View file

@ -22,7 +22,7 @@
Author : $Author: fgerlits $
Version : $Revision: 1.23 $
Version : $Revision: 1.24 $
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/core/include/LiveSupport/Core/AudioClip.h,v $
------------------------------------------------------------------------------*/
@ -130,7 +130,7 @@ using namespace boost::posix_time;
* </code></pre>
*
* @author $Author: fgerlits $
* @version $Revision: 1.23 $
* @version $Revision: 1.24 $
*/
class AudioClip : public Configurable,
public Playable
@ -479,6 +479,8 @@ class AudioClip : public Configurable,
/**
* Return the value of a metadata field in this audio clip.
* If the audio clip does not have this metadata field, returns a null
* pointer.
*
* @param key the name of the metadata field
* @return the value of the metadata field; 0 if there is

View file

@ -22,7 +22,7 @@
Author : $Author: fgerlits $
Version : $Revision: 1.9 $
Version : $Revision: 1.10 $
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/core/include/LiveSupport/Core/Playable.h,v $
------------------------------------------------------------------------------*/
@ -73,7 +73,7 @@ using namespace boost::posix_time;
* It contains the methods which are common to these classes.
*
* @author $Author: fgerlits $
* @version $Revision: 1.9 $
* @version $Revision: 1.10 $
*/
class Playable : public boost::enable_shared_from_this<Playable>
{
@ -192,6 +192,8 @@ class Playable : public boost::enable_shared_from_this<Playable>
/**
* Return the value of a metadata field in this audio clip or playlist.
* If the playable does not have this metadata field, returns a null
* pointer.
*
* @param key the name of the metadata field
* @return the value of the metadata field; 0 if there is

View file

@ -22,7 +22,7 @@
Author : $Author: fgerlits $
Version : $Revision: 1.33 $
Version : $Revision: 1.34 $
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/core/include/LiveSupport/Core/Playlist.h,v $
------------------------------------------------------------------------------*/
@ -128,7 +128,7 @@ using namespace boost::posix_time;
* </code></pre>
*
* @author $Author: fgerlits $
* @version $Revision: 1.33 $
* @version $Revision: 1.34 $
*/
class Playlist : public Configurable,
public Playable
@ -663,6 +663,8 @@ class Playlist : public Configurable,
/**
* Return the value of a metadata field in this playlist.
* If the playlist does not have this metadata field, returns a null
* pointer.
*
* @param key the name of the metadata field
* @return the value of the metadata field; 0 if there is

View file

@ -22,7 +22,7 @@
Author : $Author: fgerlits $
Version : $Revision: 1.23 $
Version : $Revision: 1.24 $
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/core/src/AudioClip.cxx,v $
------------------------------------------------------------------------------*/
@ -416,7 +416,7 @@ AudioClip :: getMetadata(const string &key) const
if (rootList.size() == 0) {
return value;
}
xmlpp::Node* metadata = rootList.front();
xmlpp::Node::NodeList nodeList = metadata->get_children(name);
xmlpp::Node::NodeList::iterator it = nodeList.begin();
@ -424,9 +424,13 @@ AudioClip :: getMetadata(const string &key) const
while (it != nodeList.end()) {
xmlpp::Node* node = *it;
if (node->get_namespace_prefix() == prefix) {
xmlpp::Element* element = dynamic_cast<xmlpp::Element*> (node);
value.reset(new Glib::ustring(element->get_child_text()
->get_content()));
xmlpp::Element* element = dynamic_cast<xmlpp::Element*> (node);
xmlpp::TextNode* textNode = element->get_child_text();
if (textNode) {
value.reset(new Glib::ustring(textNode->get_content()));
} else {
value.reset(new Glib::ustring(""));
}
return value;
}
++it;

View file

@ -22,7 +22,7 @@
Author : $Author: fgerlits $
Version : $Revision: 1.33 $
Version : $Revision: 1.34 $
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/core/src/Playlist.cxx,v $
------------------------------------------------------------------------------*/
@ -605,9 +605,13 @@ Playlist :: getMetadata(const string &key) const
while (it != nodeList.end()) {
xmlpp::Node* node = *it;
if (node->get_namespace_prefix() == prefix) {
xmlpp::Element* element = dynamic_cast<xmlpp::Element*> (node);
value.reset(new Glib::ustring(element->get_child_text()
->get_content()));
xmlpp::Element* element = dynamic_cast<xmlpp::Element*> (node);
xmlpp::TextNode* textNode = element->get_child_text();
if (textNode) {
value.reset(new Glib::ustring(textNode->get_content()));
} else {
value.reset(new Glib::ustring(""));
}
return value;
}
++it;

View file

@ -22,7 +22,7 @@
Author : $Author: fgerlits $
Version : $Revision: 1.1 $
Version : $Revision: 1.2 $
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/widgets/include/LiveSupport/Widgets/Attic/AdvancedSearchEntry.h,v $
------------------------------------------------------------------------------*/
@ -66,7 +66,7 @@ using namespace LiveSupport::Core;
* A Gtk::VBox with one or more search input fields in it.
*
* @author $Author: fgerlits $
* @version $Revision: 1.1 $
* @version $Revision: 1.2 $
*/
class AdvancedSearchEntry : public Gtk::VBox,
public LocalizedObject
@ -118,6 +118,14 @@ class AdvancedSearchEntry : public Gtk::VBox,
*/
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 ();
};

View file

@ -22,7 +22,7 @@
Author : $Author: fgerlits $
Version : $Revision: 1.4 $
Version : $Revision: 1.5 $
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/widgets/include/LiveSupport/Widgets/EntryBin.h,v $
------------------------------------------------------------------------------*/
@ -65,7 +65,7 @@ using namespace LiveSupport::Core;
* A container, holding a Gtk::Entry as its only child.
*
* @author $Author: fgerlits $
* @version $Revision: 1.4 $
* @version $Revision: 1.5 $
*/
class EntryBin : public BlueBin
{
@ -114,6 +114,17 @@ class EntryBin : public BlueBin
{
return getEntry()->get_text();
}
/**
* The signal proxy for pressing enter in the entry field.
*
* @return the signal_activate() proxy of the Gtk::Entry.
*/
Glib::SignalProxy0<void>
signal_activate(void) throw ()
{
return getEntry()->signal_activate();
}
};

View file

@ -22,7 +22,7 @@
Author : $Author: fgerlits $
Version : $Revision: 1.1 $
Version : $Revision: 1.2 $
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/widgets/include/LiveSupport/Widgets/ZebraCellRenderer.h,v $
------------------------------------------------------------------------------*/
@ -56,9 +56,11 @@ namespace Widgets {
/**
* A custom cell renderer for blue-gray striped TreeView's.
* This is not used anywhere at the moment, but it's left in here because
* we will probably need (something like) this later.
*
* @author $Author: fgerlits $
* @version $Revision: 1.1 $
* @version $Revision: 1.2 $
*/
class ZebraCellRenderer : public Gtk::CellRendererText
{

View file

@ -22,7 +22,7 @@
Author : $Author: fgerlits $
Version : $Revision: 1.6 $
Version : $Revision: 1.7 $
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.6 $
* @version $Revision: 1.7 $
*/
class ZebraTreeView : public Gtk::TreeView
{
@ -129,7 +129,7 @@ class ZebraTreeView : public Gtk::TreeView
~ZebraTreeView(void) throw ();
/**
* Add a column to the TreeView.
* Add a text column to the TreeView.
*
* @param title the title of the column
* @param modelColumn the model column this view will display

View file

@ -22,7 +22,7 @@
Author : $Author: fgerlits $
Version : $Revision: 1.1 $
Version : $Revision: 1.2 $
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/widgets/src/Attic/AdvancedSearchEntry.cxx,v $
------------------------------------------------------------------------------*/
@ -144,3 +144,14 @@ AdvancedSearchEntry :: getSearchCriteria(void) throw ()
return criteria;
}
/*------------------------------------------------------------------------------
* Connect a callback to the "enter key pressed" event.
*----------------------------------------------------------------------------*/
void
AdvancedSearchEntry :: connectCallback(const sigc::slot<void> & callback)
throw ()
{
entryBin->signal_activate().connect(callback);
}

View file

@ -22,7 +22,7 @@
Author : $Author: fgerlits $
Version : $Revision: 1.6 $
Version : $Revision: 1.7 $
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/widgets/src/ZebraTreeView.cxx,v $
------------------------------------------------------------------------------*/
@ -83,13 +83,18 @@ ZebraTreeView :: appendColumn(
const Gtk::TreeModelColumn<Glib::ustring>& modelColumn)
throw ()
{
/*
ZebraCellRenderer* renderer = Gtk::manage(new ZebraCellRenderer);
// 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);
}
@ -121,9 +126,9 @@ ZebraTreeView :: cellDataFunction(Gtk::CellRenderer* cell,
throw ()
{
ZebraTreeModelColumnRecord model;
Colors::ColorName colorName = (*iter)[model.rowNumberColumn] ?
Colors::Gray :
Colors::LightBlue;
Colors::ColorName colorName = (*iter)[model.rowNumberColumn] % 2
? Colors::Gray
: Colors::LightBlue;
cell->property_cell_background_gdk() = Colors::getColor(colorName);
}

View file

@ -21,8 +21,8 @@
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Author : $Author: maroy $
Version : $Revision: 1.29 $
Author : $Author: fgerlits $
Version : $Revision: 1.30 $
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/gLiveSupport/src/GLiveSupport.cxx,v $
------------------------------------------------------------------------------*/
@ -510,13 +510,24 @@ GLiveSupport :: getPlaylength(Ptr<const std::string>::Ref uri)
*----------------------------------------------------------------------------*/
void
LiveSupport :: GLiveSupport ::
GLiveSupport :: uploadFile(Ptr<AudioClip>::Ref audioClip)
GLiveSupport :: uploadFile(Ptr<AudioClip>::Ref audioClip)
throw (XmlRpcException)
{
storage->storeAudioClip(sessionId, audioClip);
// add the uploaded file to the Scratchpad, and update it
scratchpadContents->push_front(audioClip);
addToScratchPad(audioClip);
}
/*------------------------------------------------------------------------------
* Add a file to the Scratchpad, and update it.
*----------------------------------------------------------------------------*/
void
LiveSupport :: GLiveSupport ::
GLiveSupport :: addToScratchPad(Ptr<Playable>::Ref playable)
throw ()
{
scratchpadContents->push_front(playable);
masterPanel->updateScratchpadWindow();
}
@ -745,3 +756,33 @@ GLiveSupport :: stopAudio(void)
audioPlayerIsPaused = false;
}
/*------------------------------------------------------------------------------
* Search in the local storage.
*----------------------------------------------------------------------------*/
Ptr<LiveSupport::GLiveSupport::GLiveSupport::PlayableList>::Ref
LiveSupport :: GLiveSupport ::
GLiveSupport :: search(Ptr<SearchCriteria>::Ref criteria)
throw (XmlRpcException)
{
Ptr<LiveSupport::GLiveSupport::GLiveSupport::PlayableList>::Ref
results(new PlayableList);
storage->search(sessionId, criteria);
Ptr<std::vector<Ptr<UniqueId>::Ref> >::Ref
audioClipIds = storage->getAudioClipIds();
std::vector<Ptr<UniqueId>::Ref>::const_iterator it;
for (it = audioClipIds->begin(); it != audioClipIds->end(); ++it) {
results->push_back(storage->getAudioClip(sessionId, *it));
}
Ptr<std::vector<Ptr<UniqueId>::Ref> >::Ref
playlistIds = storage->getPlaylistIds();
for (it = playlistIds->begin(); it != playlistIds->end(); ++it) {
results->push_back(storage->getPlaylist(sessionId, *it));
}
return results;
}

View file

@ -21,8 +21,8 @@
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Author : $Author: maroy $
Version : $Revision: 1.25 $
Author : $Author: fgerlits $
Version : $Revision: 1.26 $
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/gLiveSupport/src/GLiveSupport.h,v $
------------------------------------------------------------------------------*/
@ -99,8 +99,8 @@ class MasterPanelWindow;
* <code>schedulerClientFactory</code> elements see their
* respective documentation.
*
* @author $Author: maroy $
* @version $Revision: 1.25 $
* @author $Author: fgerlits $
* @version $Revision: 1.26 $
* @see LocalizedObject#getBundle(const xmlpp::Element &)
* @see AuthenticationClientFactory
* @see StorageClientFactory
@ -409,6 +409,14 @@ class GLiveSupport : public LocalizedConfigurable,
uploadFile(Ptr<AudioClip>::Ref audioClip)
throw (XmlRpcException);
/**
* Add a file to the Scratchpad, and update it.
*
* @param playable the audio clip or playlist to be added
*/
void
addToScratchPad(Ptr<Playable>::Ref playable) throw ();
/**
* Return the Scratchpad contents.
*
@ -575,6 +583,17 @@ class GLiveSupport : public LocalizedConfigurable,
pauseAudio(void)
throw (std::logic_error);
/**
* Search in the local storage.
*
* @param criteria the search conditions to use.
* @return the list of audio clips and playlists found.
* @exception XmlRpcException passed on from Storage::search()
*/
Ptr<PlayableList>::Ref
search(Ptr<SearchCriteria>::Ref criteria)
throw (XmlRpcException);
};
/* ================================================= external data structures */

View file

@ -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/ScratchpadWindow.cxx,v $
------------------------------------------------------------------------------*/
@ -126,7 +126,7 @@ ScratchpadWindow :: ScratchpadWindow (Ptr<GLiveSupport>::Ref gLiveSupport,
std::exit(1);
}
// color the columns blue
// color the rows blue and gray
treeView->setCellDataFunction();
// register the signal handler for treeview entries being clicked

View file

@ -22,7 +22,7 @@
Author : $Author: fgerlits $
Version : $Revision: 1.4 $
Version : $Revision: 1.5 $
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/gLiveSupport/src/SearchWindow.cxx,v $
------------------------------------------------------------------------------*/
@ -35,6 +35,7 @@
#include <iostream>
#include <stdexcept>
#include <boost/date_time/posix_time/posix_time.hpp>
#include "LiveSupport/Widgets/WidgetFactory.h"
#include "LiveSupport/Widgets/Notebook.h"
@ -45,6 +46,7 @@
using namespace Glib;
using namespace boost::posix_time;
using namespace LiveSupport::Core;
using namespace LiveSupport::Widgets;
@ -94,7 +96,7 @@ SearchWindow :: SearchWindow (Ptr<GLiveSupport>::Ref gLiveSupport,
// show
set_name("searchWindow");
// set_default_size(300, 300);
set_default_size(450, 350);
set_modal(false);
property_window_position().set_value(Gtk::WIN_POS_NONE);
@ -126,6 +128,28 @@ SearchWindow :: constructAdvancedSearchView(void) throw ()
ZebraTreeView * searchResults = Gtk::manage(wf->createTreeView(
treeModel ));
// set up the callback function for the entry field
advancedSearchOptions->connectCallback(sigc::mem_fun(*this,
&SearchWindow::onSearch));
// add the TreeView's view columns
try {
searchResults->appendColumn(*getResourceUstring("typeColumnLabel"),
modelColumns.typeColumn);
searchResults->appendColumn(*getResourceUstring("titleColumnLabel"),
modelColumns.titleColumn);
searchResults->appendColumn(*getResourceUstring("creatorColumnLabel"),
modelColumns.creatorColumn);
searchResults->appendColumn(*getResourceUstring("lengthColumnLabel"),
modelColumns.lengthColumn);
} catch (std::invalid_argument &e) {
std::cerr << e.what() << std::endl;
std::exit(1);
}
// color the rows blue and gray
searchResults->setCellDataFunction();
// make a new box, and pack the main components into it
Gtk::VBox * view = Gtk::manage(new Gtk::VBox);
view->pack_start(*advancedSearchOptions, Gtk::PACK_SHRINK, 5);
@ -149,17 +173,60 @@ SearchWindow :: constructAdvancedSearchView(void) throw ()
}
#include <XmlRpcValue.h>
/*------------------------------------------------------------------------------
* Event handler for the Search button getting clicked
* Event handler for the Search button getting clicked.
*----------------------------------------------------------------------------*/
void
SearchWindow :: onSearchButtonClicked(void) throw ()
{
XmlRpc::XmlRpcValue xmlRpcValue(*advancedSearchOptions
->getSearchCriteria());
std::cerr << xmlRpcValue << std::endl;
onSearch();
}
/*------------------------------------------------------------------------------
* Do the searching.
*----------------------------------------------------------------------------*/
void
SearchWindow :: onSearch(void) throw ()
{
Ptr<SearchCriteria>::Ref criteria = advancedSearchOptions
->getSearchCriteria();
Ptr<std::list<Ptr<Playable>::Ref> >::Ref
searchResults = gLiveSupport->search(criteria);
std::list<Ptr<Playable>::Ref>::const_iterator it;
treeModel->clear();
int rowNumber = 0;
for (it = searchResults->begin(); it != searchResults->end();
++it, ++rowNumber) {
Ptr<Playable>::Ref playable = *it;
Gtk::TreeModel::Row row = *treeModel->append();
row[modelColumns.rowNumberColumn] = rowNumber;
row[modelColumns.playableColumn] = playable;
switch (playable->getType()) {
case Playable::AudioClipType:
row[modelColumns.typeColumn] = "audioclip";
break;
case Playable::PlaylistType:
row[modelColumns.typeColumn] = "playlist";
break;
default:
break;
}
Ptr<const Glib::ustring>::Ref title = playable->getTitle();
row[modelColumns.titleColumn] = title ? *title : "";
Ptr<Glib::ustring>::Ref creator = playable->getMetadata("dc:creator");
row[modelColumns.creatorColumn] = creator ? *creator : "";
Ptr<time_duration>::Ref length = playable->getPlaylength();
row[modelColumns.lengthColumn] = length ? to_simple_string(*length)
: "";
}
}

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/SearchWindow.h,v $
------------------------------------------------------------------------------*/
@ -44,7 +44,6 @@
#include <unicode/resbund.h>
#include <gtkmm.h>
#include <boost/date_time/posix_time/posix_time.hpp>
#include "LiveSupport/Core/Ptr.h"
#include "LiveSupport/Core/LocalizedObject.h"
@ -57,7 +56,6 @@
namespace LiveSupport {
namespace GLiveSupport {
using namespace boost::posix_time;
using namespace LiveSupport::Core;
using namespace LiveSupport::Widgets;
@ -73,7 +71,7 @@ using namespace LiveSupport::Widgets;
* The Search/Browse window.
*
* @author $Author: fgerlits $
* @version $Revision: 1.3 $
* @version $Revision: 1.4 $
*/
class SearchWindow : public WhiteWindow, public LocalizedObject
{
@ -98,12 +96,18 @@ class SearchWindow : public WhiteWindow, public LocalizedObject
void
onSearchButtonClicked(void) throw ();
/**
* Do the searching.
*/
void
onSearch(void) throw ();
/**
* The columns model needed by Gtk::TreeView.
* Lists one clip per row.
*
* @author $Author: fgerlits $
* @version $Revision: 1.3 $
* @version $Revision: 1.4 $
*/
class ModelColumns : public ZebraTreeModelColumnRecord
{
@ -131,7 +135,7 @@ class SearchWindow : public WhiteWindow, public LocalizedObject
/**
* The column for the length of the audio clip or playlist.
*/
Gtk::TreeModelColumn<time_duration> lengthColumn;
Gtk::TreeModelColumn<Glib::ustring> lengthColumn;
/**
* Constructor.

View file

@ -139,6 +139,11 @@ hu:table
searchByTextLabel:string { "Keresési feltétel:" }
searchButtonLabel:string { "Keress!" }
typeColumnLabel:string { "" }
titleColumnLabel:string { "Cím" }
creatorColumnLabel:string { "Előadó" }
lengthColumnLabel:string { "Hossz" }
}
}

View file

@ -141,6 +141,11 @@ root:table
searchByTextLabel:string { "Search by" }
searchButtonLabel:string { "Search" }
typeColumnLabel:string { "" }
titleColumnLabel:string { "Title" }
creatorColumnLabel:string { "Creator" }
lengthColumnLabel:string { "Length" }
}
}