From 2ae344152528721362d792bca7a71981dbc7d2db Mon Sep 17 00:00:00 2001 From: nhnielsen Date: Wed, 3 Oct 2007 14:13:51 +0000 Subject: [PATCH] when dropping an item below all other elements in the playlist, make it the last element of the playlist instead of leaving it in limbo git-svn-id: svn+ssh://svn.kde.org/home/kde/trunk/extragear/multimedia/amarok@720699 283d02a7-25f6-0310-bc7c-ecb5cbfe19da --- src/playlist/PlaylistGraphicsItem.cpp | 9 ++++++++- src/playlist/PlaylistGraphicsView.cpp | 11 +++++++++-- 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/src/playlist/PlaylistGraphicsItem.cpp b/src/playlist/PlaylistGraphicsItem.cpp index 22ccabbfc..cbf39c825 100644 --- a/src/playlist/PlaylistGraphicsItem.cpp +++ b/src/playlist/PlaylistGraphicsItem.cpp @@ -602,7 +602,14 @@ void Playlist::GraphicsItem::mouseReleaseEvent( QGraphicsSceneMouseEvent *event { setPos( above->pos() ); The::playlistView()->moveItem( this, above ); - } + } else { + //Don't just drop item into the void, make it the last item! + + The::playlistView()->moveItem( this, 0 ); + //setPos( above->pos() ); + //The::playlistView()->moveItem( this, above ); + + } //make sure item resets its z value setZValue( 1.0 ); diff --git a/src/playlist/PlaylistGraphicsView.cpp b/src/playlist/PlaylistGraphicsView.cpp index e8752f099..7f0d58e62 100644 --- a/src/playlist/PlaylistGraphicsView.cpp +++ b/src/playlist/PlaylistGraphicsView.cpp @@ -186,13 +186,18 @@ Playlist::GraphicsView::rowsRemoved(const QModelIndex& parent, int start, int en void Playlist::GraphicsView::moveItem( Playlist::GraphicsItem *moveMe, Playlist::GraphicsItem *above ) { + int moveMeIndex = m_tracks.indexOf( moveMe ); - int aboveIndex = m_tracks.indexOf( above ); + int aboveIndex; + if ( above ) + aboveIndex = m_tracks.indexOf( above ); + else + aboveIndex = m_tracks.count(); + //call set row on all items below the first one potentially modified to //make sure that all items have correct background color and group info - if( moveMeIndex < aboveIndex ) { m_model->moveRow( moveMeIndex, aboveIndex -1 ); @@ -219,8 +224,10 @@ Playlist::GraphicsView::moveItem( Playlist::GraphicsItem *moveMe, Playlist::Grap //shuffleTracks( aboveIndex, moveMeIndex + 1); shuffleTracks( 0 ); } + } + void Playlist::GraphicsView::shuffleTracks( int startPosition, int stopPosition ) { -- 2.11.4.GIT