summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorlvw <lvw@e10066b5-e1e2-0310-b819-94efdf66514b>2004-09-25 12:41:19 +0000
committerlvw <lvw@e10066b5-e1e2-0310-b819-94efdf66514b>2004-09-25 12:41:19 +0000
commite88482d287b0d0628462b2478a8be5f1cf2a223c (patch)
tree6c97b9476702bdd785731e77c4180f1896c9f10d
parentb9b8dd18c4c4798c168d42ce7c0d2651930f4e55 (diff)
downloadvdr-plugin-muggle-e88482d287b0d0628462b2478a8be5f1cf2a223c.tar.gz
vdr-plugin-muggle-e88482d287b0d0628462b2478a8be5f1cf2a223c.tar.bz2
Playlist indexing enhanced
git-svn-id: https://vdr-muggle.svn.sourceforge.net/svnroot/vdr-muggle/trunk/muggle-plugin@177 e10066b5-e1e2-0310-b819-94efdf66514b
-rw-r--r--mg_playlist.c33
-rw-r--r--mg_playlist.h2
2 files changed, 22 insertions, 13 deletions
diff --git a/mg_playlist.c b/mg_playlist.c
index 82df4cb..6da5905 100644
--- a/mg_playlist.c
+++ b/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/mg_playlist.h b/mg_playlist.h
index a46d29d..addf52e 100644
--- a/mg_playlist.h
+++ b/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 ==== */