From 65e6bb83fa9cff2a69d258a03b91044a3a74b943 Mon Sep 17 00:00:00 2001 From: lvw Date: Sat, 25 Sep 2004 12:41:19 +0000 Subject: Playlist indexing enhanced git-svn-id: https://vdr-muggle.svn.sourceforge.net/svnroot/vdr-muggle/trunk@177 e10066b5-e1e2-0310-b819-94efdf66514b --- muggle-plugin/mg_playlist.c | 33 +++++++++++++++++++++------------ muggle-plugin/mg_playlist.h | 2 +- 2 files changed, 22 insertions(+), 13 deletions(-) diff --git a/muggle-plugin/mg_playlist.c b/muggle-plugin/mg_playlist.c index 82df4cb..6da5905 100644 --- a/muggle-plugin/mg_playlist.c +++ b/muggle-plugin/mg_playlist.c @@ -95,6 +95,23 @@ void mgPlaylist::insert( mgContentItem* item, unsigned int position ) } } +bool mgPlaylist::remove( unsigned int pos ) +{ + bool result = false; + + if( pos != m_current_idx ) + { + result = mgTracklist::remove( pos ); + + if( result && pos < m_current_idx ) + { + m_current_idx --; + } + } + + return result; +} + void mgPlaylist::clear() { // TODO: who takes care of memory allocation/deallocation of mgItems? @@ -170,7 +187,8 @@ void mgPlaylist::gotoPosition(unsigned int position) { if( position >= m_list.size() ) { - m_current_idx = -1; + // go to end -- a safe bet + m_current_idx = m_list.size() - 1; } else { @@ -184,13 +202,8 @@ void mgPlaylist::skipFwd() if( m_current_idx + 1 < m_list.size() ) // unless loop mode { m_current_idx ++; - cout << "mgPlaylist::skipFwd: " << m_current_idx << endl; - } - else - { - // or goto 1 in case of loop mode - m_current_idx = -1; } + // if we are already at the end -- just do nothing unless in loop mode } // goes back to the previous item @@ -200,11 +213,7 @@ void mgPlaylist::skipBack() { m_current_idx --; } - else - { - // or goto last in case of loop mode - m_current_idx = -1; - } + // if we are at the beginning -- just do nothing unless in loop mode } // get next track, do not update data structures diff --git a/muggle-plugin/mg_playlist.h b/muggle-plugin/mg_playlist.h index a46d29d..addf52e 100644 --- a/muggle-plugin/mg_playlist.h +++ b/muggle-plugin/mg_playlist.h @@ -107,7 +107,7 @@ public: * * \param pos - the index of the track to be removed */ - // bool remove( int pos ); + bool remove( unsigned int pos ); /* ==== access tracks ==== */ -- cgit v1.2.3