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