mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-03-23 01:09:42 +01:00
aFix crash in dragging artist, don't assume AlbumModel only contains albums as it's hacked to also contain artists.
(cherry picked from commit 68d541d2e8dc847c40f6782c65beb4e15ff6aa72)
This commit is contained in:
parent
e828dadec8
commit
753e1b3c90
@ -178,6 +178,7 @@ AlbumModel::mimeData( const QModelIndexList &indexes ) const
|
||||
QByteArray queryData;
|
||||
QDataStream queryStream( &queryData, QIODevice::WriteOnly );
|
||||
|
||||
bool isAlbumData = true;
|
||||
foreach ( const QModelIndex& i, indexes )
|
||||
{
|
||||
if ( i.column() > 0 )
|
||||
@ -185,16 +186,25 @@ AlbumModel::mimeData( const QModelIndexList &indexes ) const
|
||||
|
||||
QModelIndex idx = index( i.row(), 0, i.parent() );
|
||||
AlbumItem* item = itemFromIndex( idx );
|
||||
if ( item )
|
||||
if ( item && !item->album().isNull() )
|
||||
{
|
||||
const album_ptr& album = item->album();
|
||||
queryStream << album->artist()->name();
|
||||
queryStream << album->name();
|
||||
|
||||
isAlbumData = true;
|
||||
}
|
||||
else if ( item && !item->artist().isNull() )
|
||||
{
|
||||
const artist_ptr& artist = item->artist();
|
||||
queryStream << artist->name();
|
||||
|
||||
isAlbumData = false;
|
||||
}
|
||||
}
|
||||
|
||||
QMimeData* mimeData = new QMimeData();
|
||||
mimeData->setData( "application/tomahawk.metadata.album", queryData );
|
||||
QMimeData* mimeData = new QMimeData;
|
||||
mimeData->setData( isAlbumData ? "application/tomahawk.metadata.album" : "application/tomahawk.metadata.artist", queryData );
|
||||
|
||||
return mimeData;
|
||||
}
|
||||
@ -431,7 +441,7 @@ AlbumModel::findItem( const artist_ptr& artist ) const
|
||||
return item;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -447,6 +457,6 @@ AlbumModel::findItem( const album_ptr& album ) const
|
||||
return item;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user