mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-03-31 06:02:27 +02:00
* Fixed a few playlist issues: don't lose current track when dropping / moving items on the playlist.
This commit is contained in:
parent
08426e2822
commit
20181affd1
@ -71,6 +71,10 @@ PlaylistModel::headerData( int section, Qt::Orientation orientation, int role )
|
||||
void
|
||||
PlaylistModel::loadPlaylist( const Tomahawk::playlist_ptr& playlist, bool loadEntries )
|
||||
{
|
||||
QString currentuuid;
|
||||
if ( currentItem().isValid() )
|
||||
currentuuid = itemFromIndex( currentItem() )->query()->id();
|
||||
|
||||
if ( !m_playlist.isNull() )
|
||||
{
|
||||
disconnect( m_playlist.data(), SIGNAL( revisionLoaded( Tomahawk::PlaylistRevision ) ), this, SLOT( onRevisionLoaded( Tomahawk::PlaylistRevision ) ) );
|
||||
@ -114,6 +118,9 @@ PlaylistModel::loadPlaylist( const Tomahawk::playlist_ptr& playlist, bool loadEn
|
||||
|
||||
connect( plitem, SIGNAL( dataChanged() ), SLOT( onDataChanged() ) );
|
||||
|
||||
if ( entry->query()->id() == currentuuid )
|
||||
setCurrentItem( plitem->index );
|
||||
|
||||
if ( !entry->query()->resolvingFinished() && !entry->query()->playable() )
|
||||
{
|
||||
m_waitingForResolved.append( entry->query().data() );
|
||||
@ -339,6 +346,7 @@ bool
|
||||
PlaylistModel::dropMimeData( const QMimeData* data, Qt::DropAction action, int row, int column, const QModelIndex& parent )
|
||||
{
|
||||
Q_UNUSED( column );
|
||||
|
||||
if ( action == Qt::IgnoreAction || isReadOnly() )
|
||||
return true;
|
||||
|
||||
@ -355,7 +363,10 @@ PlaylistModel::dropMimeData( const QMimeData* data, Qt::DropAction action, int r
|
||||
else
|
||||
beginRow = rowCount( QModelIndex() );
|
||||
|
||||
qDebug() << data->formats();
|
||||
// qDebug() << data->formats();
|
||||
QString currentuuid;
|
||||
if ( currentItem().isValid() )
|
||||
currentuuid = itemFromIndex( currentItem() )->query()->id();
|
||||
|
||||
QList<Tomahawk::query_ptr> queries;
|
||||
if ( data->hasFormat( "application/tomahawk.result.list" ) )
|
||||
@ -418,14 +429,15 @@ PlaylistModel::dropMimeData( const QMimeData* data, Qt::DropAction action, int r
|
||||
TrackModelItem* plitem = new TrackModelItem( e, m_rootItem, beginRow );
|
||||
plitem->index = createIndex( beginRow++, 0, plitem );
|
||||
|
||||
if ( query->id() == currentuuid )
|
||||
setCurrentItem( plitem->index );
|
||||
|
||||
connect( plitem, SIGNAL( dataChanged() ), SLOT( onDataChanged() ) );
|
||||
}
|
||||
emit endInsertRows();
|
||||
|
||||
if ( action == Qt::CopyAction )
|
||||
{
|
||||
onPlaylistChanged();
|
||||
}
|
||||
onPlaylistChanged( true );
|
||||
}
|
||||
|
||||
return true;
|
||||
@ -507,7 +519,7 @@ PlaylistModel::removeIndex( const QModelIndex& index, bool moreToCome )
|
||||
|
||||
if ( !moreToCome && !m_playlist.isNull() )
|
||||
{
|
||||
onPlaylistChanged();
|
||||
onPlaylistChanged( true );
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user