This commit is contained in:
fgerlits 2006-08-01 16:04:59 +00:00
parent aa30066bdb
commit 1c1455085c
4 changed files with 46 additions and 11 deletions

View file

@ -951,12 +951,14 @@ GLiveSupport :: setNowPlaying(Ptr<Playable>::Ref playable)
/*------------------------------------------------------------------------------ /*------------------------------------------------------------------------------
* Open a playlist for editing. * Open a playlist for editing.
*----------------------------------------------------------------------------*/ *----------------------------------------------------------------------------*/
Ptr<Playlist>::Ref void
LiveSupport :: GLiveSupport :: LiveSupport :: GLiveSupport ::
GLiveSupport :: openPlaylistForEditing(Ptr<const UniqueId>::Ref playlistId) GLiveSupport :: openPlaylistForEditing(Ptr<const UniqueId>::Ref playlistId)
throw (XmlRpcException) throw (XmlRpcException)
{ {
cancelEditedPlaylist(); if (masterPanel->cancelEditedPlaylist() == false) {
return; // the user canceled the operation
}
if (!playlistId.get()) { if (!playlistId.get()) {
playlistId = storage->createPlaylist(sessionId); playlistId = storage->createPlaylist(sessionId);
@ -983,8 +985,6 @@ GLiveSupport :: openPlaylistForEditing(Ptr<const UniqueId>::Ref playlistId)
editedPlaylist->createSavedCopy(); editedPlaylist->createSavedCopy();
masterPanel->updateSimplePlaylistMgmtWindow(); masterPanel->updateSimplePlaylistMgmtWindow();
return editedPlaylist;
} }

View file

@ -724,7 +724,16 @@ class GLiveSupport : public LocalizedConfigurable,
* Create a new playlist or Open a playlist for editing. * Create a new playlist or Open a playlist for editing.
* The opened playlist can be later accessed by getEditedPlaylist(). * The opened playlist can be later accessed by getEditedPlaylist().
* Always release the opened playlist by calling * Always release the opened playlist by calling
* releaseEditedPlaylist() * releaseEditedPlaylist().
*
* If the argument is 0, a new playlist is created in the storage.
*
* After a call to this function, getEditedPlaylist() is guaranteed
* to return a non-0 value.
*
* If there is a playlist being edited, the
* SimplePlaylistManagementWindow's confirmation message is displayed.
* If the user presses "Cancel", then this function does nothing.
* *
* @param playlistId the id of the playlist to open for editing. * @param playlistId the id of the playlist to open for editing.
* if a reference to 0, create a new playlist. * if a reference to 0, create a new playlist.
@ -733,7 +742,7 @@ class GLiveSupport : public LocalizedConfigurable,
* @see #getEditedPlaylist * @see #getEditedPlaylist
* @see #releaseEditedPlaylist * @see #releaseEditedPlaylist
*/ */
Ptr<Playlist>::Ref void
openPlaylistForEditing( openPlaylistForEditing(
Ptr<const UniqueId>::Ref playlistId Ptr<const UniqueId>::Ref playlistId
= Ptr<const UniqueId>::Ref()) = Ptr<const UniqueId>::Ref())

View file

@ -214,9 +214,9 @@ SimplePlaylistManagementWindow :: SimplePlaylistManagementWindow (
// Register the signal handlers for the buttons // Register the signal handlers for the buttons
saveButton->signal_clicked().connect(sigc::mem_fun(*this, saveButton->signal_clicked().connect(sigc::mem_fun(*this,
&SimplePlaylistManagementWindow::onSaveButtonClicked)); &SimplePlaylistManagementWindow::onSaveButtonClicked));
closeButton->signal_clicked().connect(sigc::mem_fun(*this, closeButton->signal_clicked().connect(sigc::mem_fun(*this,
&SimplePlaylistManagementWindow::onCloseButtonClicked)); &SimplePlaylistManagementWindow::onBottomCloseButtonClicked));
// show // show
set_name(windowName); set_name(windowName);
@ -325,6 +325,7 @@ SimplePlaylistManagementWindow :: cancelPlaylist(void) throw ()
std::cerr << e.what() << std::endl; std::cerr << e.what() << std::endl;
return false; return false;
} }
isPlaylistModified = false;
break; break;
case DialogWindow::yesButton: case DialogWindow::yesButton:
@ -361,6 +362,18 @@ SimplePlaylistManagementWindow :: closeWindow(void) throw ()
} }
/*------------------------------------------------------------------------------
* Signal handler for the save button getting clicked.
*----------------------------------------------------------------------------*/
void
SimplePlaylistManagementWindow :: onBottomCloseButtonClicked(void) throw ()
{
if (cancelPlaylist()) {
closeWindow();
}
}
/*------------------------------------------------------------------------------ /*------------------------------------------------------------------------------
* Signal handler for the "lock fades" check button toggled. * Signal handler for the "lock fades" check button toggled.
*----------------------------------------------------------------------------*/ *----------------------------------------------------------------------------*/
@ -432,7 +445,9 @@ SimplePlaylistManagementWindow :: onTitleEdited(void) throw()
Ptr<Playlist>::Ref playlist = gLiveSupport->getEditedPlaylist(); Ptr<Playlist>::Ref playlist = gLiveSupport->getEditedPlaylist();
if (!playlist) { if (!playlist) {
try { try {
playlist = gLiveSupport->openPlaylistForEditing(); gLiveSupport->openPlaylistForEditing();
playlist = gLiveSupport->getEditedPlaylist();
} catch (XmlRpcException &e) { } catch (XmlRpcException &e) {
std::cerr << "error in SimplePlaylistManagementWindow::" std::cerr << "error in SimplePlaylistManagementWindow::"
"onTitleEdited(): " "onTitleEdited(): "

View file

@ -183,11 +183,22 @@ class SimplePlaylistManagementWindow : public GuiWindow
selectRow(int rowNumber) throw (); selectRow(int rowNumber) throw ();
/** /**
* Signal handler for the save button clicked. * Signal handler for a click on the save button.
*/ */
void void
onSaveButtonClicked(void) throw (); onSaveButtonClicked(void) throw ();
/**
* Signal handler for a click on the close button at the bottom
* right corner.
* This cancels the edited playlist; the normal close button (X)
* at the upper right corner hides the window only.
* If the playlist has been modified, a confirmation message will
* be displayed.
*/
void
onBottomCloseButtonClicked(void) throw ();
/** /**
* Signal handler for the "lock fades" check button toggled. * Signal handler for the "lock fades" check button toggled.
*/ */