mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-04-13 20:41:58 +02:00
make the dropmenu work with categoryitems
This commit is contained in:
parent
74fa941159
commit
f1dfd84213
@ -142,7 +142,21 @@ CategoryAddItem::willAcceptDrag( const QMimeData* data ) const
|
||||
SourceTreeItem::DropTypes
|
||||
CategoryAddItem::supportedDropTypes( const QMimeData* data ) const
|
||||
{
|
||||
return DropTypesNone;
|
||||
SourceTreeItem::DropTypes types = DropTypesNone;
|
||||
|
||||
if ( m_categoryType == SourcesModel::PlaylistsCategory )
|
||||
{
|
||||
if ( data->hasFormat( "application/tomahawk.query.list" ) )
|
||||
return types | DropTypeThisTrack | DropTypeThisAlbum | DropTypeAllFromArtist | DropTypeLocalItems | DropTypeTop50;
|
||||
else if ( data->hasFormat( "application/tomahawk.result.list" ) )
|
||||
return types | DropTypeThisTrack | DropTypeThisAlbum | DropTypeAllFromArtist | DropTypeLocalItems | DropTypeTop50;
|
||||
else if ( data->hasFormat( "application/tomahawk.metadata.album" ) )
|
||||
return types | DropTypeThisAlbum | DropTypeAllFromArtist | DropTypeLocalItems | DropTypeTop50;
|
||||
else if ( data->hasFormat( "application/tomahawk.metadata.artist" ) )
|
||||
return types | DropTypeAllFromArtist | DropTypeLocalItems | DropTypeTop50;
|
||||
}
|
||||
|
||||
return types;
|
||||
}
|
||||
|
||||
|
||||
@ -237,7 +251,23 @@ CategoryAddItem::dropMimeData( const QMimeData* data, Qt::DropAction )
|
||||
// Create a new playlist seeded with these items
|
||||
DropJob *dj = new DropJob();
|
||||
connect( dj, SIGNAL( tracks( QList< Tomahawk::query_ptr > ) ), this, SLOT( parsedDroppedTracks( QList< Tomahawk::query_ptr > ) ) );
|
||||
dj->tracksFromMimeData( data );
|
||||
if ( dropType() == DropTypeAllFromArtist )
|
||||
dj->setGetWholeArtists( true );
|
||||
if ( dropType() == DropTypeThisAlbum )
|
||||
dj->setGetWholeAlbums( true );
|
||||
|
||||
if ( dropType() == DropTypeLocalItems )
|
||||
{
|
||||
dj->setGetWholeArtists( true );
|
||||
dj->tracksFromMimeData( data, false, true );
|
||||
}
|
||||
else if ( dropType() == DropTypeTop50 )
|
||||
{
|
||||
dj->setGetWholeArtists( true );
|
||||
dj->tracksFromMimeData( data, false, false, true );
|
||||
}
|
||||
else
|
||||
dj->tracksFromMimeData( data, false, false );
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -49,10 +49,11 @@ SourceDelegate::sizeHint( const QStyleOptionViewItem& option, const QModelIndex&
|
||||
{
|
||||
if ( !m_expandedMap.value( index )->initialized() )
|
||||
{
|
||||
qDebug() << "droptypecount is " << dropTypeCount( item );
|
||||
int dropTypes = dropTypeCount( item );
|
||||
qDebug() << "droptypecount is " << dropTypes;
|
||||
QSize originalSize = QStyledItemDelegate::sizeHint( option, index );
|
||||
// QSize targetSize = originalSize + QSize( 0, originalSize.height() * dropTypeCount( item ) ); // useful for vertical menu
|
||||
QSize targetSize = originalSize + QSize( 0, 56 );
|
||||
QSize targetSize = originalSize + QSize( 0, dropTypes == 0 ? 0 : 56 );
|
||||
m_expandedMap.value( index )->initialize( originalSize, targetSize, 500 );
|
||||
m_expandedMap.value( index )->expand();
|
||||
}
|
||||
|
@ -498,9 +498,10 @@ SourceTreeView::dropEvent( QDropEvent* event )
|
||||
const QPoint pos = event->pos();
|
||||
const QModelIndex index = indexAt( pos );
|
||||
|
||||
if ( model()->data( index, SourcesModel::SourceTreeItemTypeRole ).toInt() == SourcesModel::StaticPlaylist )
|
||||
if ( model()->data( index, SourcesModel::SourceTreeItemTypeRole ).toInt() == SourcesModel::StaticPlaylist
|
||||
|| model()->data( index, SourcesModel::SourceTreeItemTypeRole ).toInt() == SourcesModel::CategoryAdd )
|
||||
{
|
||||
PlaylistItem* item = itemFromIndex< PlaylistItem >( index );
|
||||
SourceTreeItem* item = itemFromIndex< SourceTreeItem >( index );
|
||||
Q_ASSERT( item );
|
||||
|
||||
item->setDropType( m_delegate->hoveredDropType() );
|
||||
|
Loading…
x
Reference in New Issue
Block a user