From b4c9ed0e769b621dd82d38946aae556f82ea71c8 Mon Sep 17 00:00:00 2001 From: fgerlits Date: Wed, 22 Nov 2006 18:33:28 +0000 Subject: [PATCH] implemented the calls to the preload() function; this closes #2012 --- .../LiveSupport/Widgets/ZebraTreeView.h | 28 +++++++++++ .../src/modules/widgets/src/ZebraTreeView.cxx | 3 ++ .../gLiveSupport/src/LiveModeWindow.cxx | 49 ++++++++++--------- .../gLiveSupport/src/LiveModeWindow.h | 18 ++++--- 4 files changed, 69 insertions(+), 29 deletions(-) diff --git a/campcaster/src/modules/widgets/include/LiveSupport/Widgets/ZebraTreeView.h b/campcaster/src/modules/widgets/include/LiveSupport/Widgets/ZebraTreeView.h index 4dbd240cc..2d69c1d4c 100644 --- a/campcaster/src/modules/widgets/include/LiveSupport/Widgets/ZebraTreeView.h +++ b/campcaster/src/modules/widgets/include/LiveSupport/Widgets/ZebraTreeView.h @@ -150,6 +150,16 @@ class ZebraTreeView : public Gtk::TreeView signalCellEdited().emit(path, columnId, newText); } + /** + * Emit the "tree model has changed" signal. + */ + void + emitSignalTreeModelChanged(void) + throw () + { + signalTreeModelChanged().emit(); + } + /** * Renumber the rows after they have changed. * @@ -181,6 +191,11 @@ class ZebraTreeView : public Gtk::TreeView int, const Glib::ustring &> signalCellEditedObject; + /** + * A signal object to notify people that the tree model has changed. + */ + sigc::signal signalTreeModelChangedObject; + /** * Event handler for the row_inserted signal. * @@ -397,6 +412,19 @@ class ZebraTreeView : public Gtk::TreeView return signalCellEditedObject; } + /** + * The signal raised when the rows in the tree model have changed. + * This signal is emitted whenever the tree model emits a + * row_inserted, row_deleted or rows_reordered signal. + * + * @return the signal object (a protected member of this class) + */ + sigc::signal + signalTreeModelChanged(void) throw () + { + return signalTreeModelChangedObject; + } + /** * Manually connect the 'model has changed' signals to the tree view. * This is useful if you want to use the same ZebraTreeView object diff --git a/campcaster/src/modules/widgets/src/ZebraTreeView.cxx b/campcaster/src/modules/widgets/src/ZebraTreeView.cxx index 1e088001e..3c4924637 100644 --- a/campcaster/src/modules/widgets/src/ZebraTreeView.cxx +++ b/campcaster/src/modules/widgets/src/ZebraTreeView.cxx @@ -501,6 +501,7 @@ ZebraTreeView :: onRowInserted(const Gtk::TreeModel::Path & path, { renumberRows(); columns_autosize(); + emitSignalTreeModelChanged(); } @@ -513,6 +514,7 @@ ZebraTreeView :: onRowDeleted(const Gtk::TreeModel::Path & path) { renumberRows(); columns_autosize(); + emitSignalTreeModelChanged(); } @@ -526,6 +528,7 @@ ZebraTreeView :: onRowsReordered(const Gtk::TreeModel::Path & path, throw () { renumberRows(); + emitSignalTreeModelChanged(); } diff --git a/campcaster/src/products/gLiveSupport/src/LiveModeWindow.cxx b/campcaster/src/products/gLiveSupport/src/LiveModeWindow.cxx index e4aa0b252..1ae05a670 100644 --- a/campcaster/src/products/gLiveSupport/src/LiveModeWindow.cxx +++ b/campcaster/src/products/gLiveSupport/src/LiveModeWindow.cxx @@ -109,9 +109,11 @@ LiveModeWindow :: LiveModeWindow (Ptr::Ref gLiveSupport, // register the signal handler for treeview entries being clicked treeView->signal_button_press_event().connect_notify(sigc::mem_fun(*this, - &LiveModeWindow::onEntryClicked)); + &LiveModeWindow::onEntryClicked)); treeView->signal_row_activated().connect(sigc::mem_fun(*this, - &LiveModeWindow::onDoubleClick)); + &LiveModeWindow::onDoubleClick)); + treeView->signalTreeModelChanged().connect(sigc::mem_fun(*this, + &LiveModeWindow::onTreeModelChanged)); // register the signal handler for keyboard key presses treeView->signal_key_press_event().connect(sigc::mem_fun(*this, @@ -197,10 +199,7 @@ void LiveModeWindow :: addItem(Ptr::Ref playable) throw () { addItem(treeModel->append(), playable); - - if (treeModel->children().size() == 1) { - preloadNextItem(); - } + onTreeModelChanged(); } @@ -272,22 +271,6 @@ LiveModeWindow :: popTop(void) throw () } -/*------------------------------------------------------------------------------ - * Preload the item at the top of the window. - *----------------------------------------------------------------------------*/ -void -LiveModeWindow :: preloadNextItem(void) throw () -{ - Ptr::Ref playable; - Gtk::TreeModel::iterator iter = treeModel->children().begin(); - - if (iter) { - playable = (*iter)[modelColumns.playableColumn]; - gLiveSupport->preload(playable); - } -} - - /*------------------------------------------------------------------------------ * Find the selected row. *----------------------------------------------------------------------------*/ @@ -669,6 +652,28 @@ LiveModeWindow :: onRemoveItemButtonClicked(void) throw () } +/*------------------------------------------------------------------------------ + * Signal handler for a change in the tree model. + *----------------------------------------------------------------------------*/ +void +LiveModeWindow :: onTreeModelChanged(void) throw () +{ + Gtk::TreeModel::iterator iter = treeModel->children().begin(); + + if (iter) { + Ptr::Ref playable = (*iter)[modelColumns.playableColumn]; + if (playable) { + if (!savedTopPlayable || savedTopPlayable && + *savedTopPlayable->getId() != *playable->getId()) { + gLiveSupport->preload(playable); + } + savedTopPlayable = playable; + } + + } +} + + /*------------------------------------------------------------------------------ * Event handler called when the the window gets hidden. *----------------------------------------------------------------------------*/ diff --git a/campcaster/src/products/gLiveSupport/src/LiveModeWindow.h b/campcaster/src/products/gLiveSupport/src/LiveModeWindow.h index f6f78908d..1b5c2a0d8 100644 --- a/campcaster/src/products/gLiveSupport/src/LiveModeWindow.h +++ b/campcaster/src/products/gLiveSupport/src/LiveModeWindow.h @@ -81,6 +81,11 @@ using namespace LiveSupport::Widgets; class LiveModeWindow : public GuiWindow { private: + /** + * The Playable item at the top of the window. + */ + Ptr::Ref savedTopPlayable; + /** * The Export Playlist pop-up window. */ @@ -280,6 +285,12 @@ class LiveModeWindow : public GuiWindow virtual void onRemoveItemButtonClicked(void) throw (); + /** + * Signal handler for a change in the tree model. + */ + virtual void + onTreeModelChanged(void) throw (); + /** * Event handler called when the the window gets hidden. * @@ -341,13 +352,6 @@ class LiveModeWindow : public GuiWindow Ptr::Ref popTop(void) throw (); - /** - * Preload the item at the top of the window. - * This is to shorten the time a playlist takes to start. - */ - void - preloadNextItem() throw (); - /** * Update the cue player display to show a stopped state. */