diff --git a/livesupport/products/gLiveSupport/src/PlaylistListWindow.cxx b/livesupport/products/gLiveSupport/src/PlaylistListWindow.cxx index 30c4f6240..3ba10db55 100644 --- a/livesupport/products/gLiveSupport/src/PlaylistListWindow.cxx +++ b/livesupport/products/gLiveSupport/src/PlaylistListWindow.cxx @@ -22,7 +22,7 @@ Author : $Author: maroy $ - Version : $Revision: 1.2 $ + Version : $Revision: 1.3 $ Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/gLiveSupport/src/Attic/PlaylistListWindow.cxx,v $ ------------------------------------------------------------------------------*/ @@ -153,6 +153,12 @@ PlaylistListWindow :: PlaylistListWindow ( std::cerr << e.what() << std::endl; } + // attach the event handler for the user selecting an entry from + // the list of playlist details + detailTreeSelection = detailTreeView.get_selection(); + detailTreeSelection->signal_changed().connect( + sigc::mem_fun(*this, &PlaylistListWindow::onDetailSelection)); + // set up the button box buttonBox.pack_start(*closeButton, PACK_SHRINK); buttonBox.set_border_width(5); @@ -184,7 +190,7 @@ PlaylistListWindow :: showAllPlaylists(void) throw () playlists = storage->getAllPlaylists(sessionId); it = playlists->begin(); end = playlists->end(); - while (it < end) { + while (it != end) { playlist = *it; row = *(listTreeModel->append()); lengthStr = boost::posix_time::to_simple_string( @@ -238,6 +244,38 @@ PlaylistListWindow :: onPlaylistListSelection(void) throw () } +/*------------------------------------------------------------------------------ + * Event handler for a row being selected in the detail tree view. + *----------------------------------------------------------------------------*/ +void +PlaylistListWindow :: onDetailSelection(void) throw () +{ + TreeModel::iterator iter = detailTreeSelection->get_selected(); + if (iter) { + TreeModel::Row row = *iter; + Ptr::Ref selectedId(new UniqueId(row[modelColumns.idColumn])); + + // TODO: only proceed if the selected item is a playlist, + // not an audio clip + + // find the item in listTreeModel with the same id, and select it + // TODO: find a more efficient way of doing this + TreeModel::iterator it = listTreeModel->children().begin(); + TreeModel::iterator end = listTreeModel->children().end(); + + while (it != end) { + row = *it; + Ptr::Ref id(new UniqueId(row[modelColumns.idColumn])); + if (*id == *selectedId) { + listTreeSelection->select(row); + break; + } + ++it; + } + } +} + + /*------------------------------------------------------------------------------ * Show the details of a playlist *----------------------------------------------------------------------------*/ diff --git a/livesupport/products/gLiveSupport/src/PlaylistListWindow.h b/livesupport/products/gLiveSupport/src/PlaylistListWindow.h index 932921656..4692a1708 100644 --- a/livesupport/products/gLiveSupport/src/PlaylistListWindow.h +++ b/livesupport/products/gLiveSupport/src/PlaylistListWindow.h @@ -22,7 +22,7 @@ Author : $Author: maroy $ - Version : $Revision: 1.2 $ + Version : $Revision: 1.3 $ Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/gLiveSupport/src/Attic/PlaylistListWindow.h,v $ ------------------------------------------------------------------------------*/ @@ -84,7 +84,7 @@ using namespace LiveSupport::Core; * * * @author $Author: maroy $ - * @version $Revision: 1.2 $ + * @version $Revision: 1.3 $ */ class PlaylistListWindow : public Gtk::Window, public GtkLocalizedObject { @@ -120,7 +120,7 @@ class PlaylistListWindow : public Gtk::Window, public GtkLocalizedObject * Lists one playlist per row. * * @author $Author: maroy $ - * @version $Revision: 1.2 $ + * @version $Revision: 1.3 $ */ class ModelColumns : public Gtk::TreeModel::ColumnRecord { @@ -214,6 +214,12 @@ class PlaylistListWindow : public Gtk::Window, public GtkLocalizedObject */ Glib::RefPtr listTreeSelection; + /** + * The tree selection, as a GTK reference, holding info on + * what's selected from the detail view. + */ + Glib::RefPtr detailTreeSelection; + /** * The container holding the playlist detail tree view and accompanying * label. @@ -260,6 +266,13 @@ class PlaylistListWindow : public Gtk::Window, public GtkLocalizedObject virtual void onPlaylistListSelection(void) throw (); + /** + * Signal to catch the event of the user selecting a row + * in the detail tree view. + */ + virtual void + onDetailSelection(void) throw (); + /** * Signal handler for the close button clicked. */