added ability to select a playlist from the detailed view

This commit is contained in:
maroy 2004-12-03 12:05:25 +00:00
parent bae10ac014
commit e7c5fe3756
2 changed files with 56 additions and 5 deletions

View File

@ -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<UniqueId>::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<UniqueId>::Ref id(new UniqueId(row[modelColumns.idColumn]));
if (*id == *selectedId) {
listTreeSelection->select(row);
break;
}
++it;
}
}
}
/*------------------------------------------------------------------------------
* Show the details of a playlist
*----------------------------------------------------------------------------*/

View File

@ -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;
* </pre></code>
*
* @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<Gtk::TreeSelection> listTreeSelection;
/**
* The tree selection, as a GTK reference, holding info on
* what's selected from the detail view.
*/
Glib::RefPtr<Gtk::TreeSelection> 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.
*/