mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-08-10 08:04:25 +02:00
make the dropmenu work with categoryitems
This commit is contained in:
@@ -142,7 +142,21 @@ CategoryAddItem::willAcceptDrag( const QMimeData* data ) const
|
|||||||
SourceTreeItem::DropTypes
|
SourceTreeItem::DropTypes
|
||||||
CategoryAddItem::supportedDropTypes( const QMimeData* data ) const
|
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
|
// Create a new playlist seeded with these items
|
||||||
DropJob *dj = new DropJob();
|
DropJob *dj = new DropJob();
|
||||||
connect( dj, SIGNAL( tracks( QList< Tomahawk::query_ptr > ) ), this, SLOT( parsedDroppedTracks( QList< Tomahawk::query_ptr > ) ) );
|
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;
|
return true;
|
||||||
}
|
}
|
||||||
|
@@ -49,10 +49,11 @@ SourceDelegate::sizeHint( const QStyleOptionViewItem& option, const QModelIndex&
|
|||||||
{
|
{
|
||||||
if ( !m_expandedMap.value( index )->initialized() )
|
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 originalSize = QStyledItemDelegate::sizeHint( option, index );
|
||||||
// QSize targetSize = originalSize + QSize( 0, originalSize.height() * dropTypeCount( item ) ); // useful for vertical menu
|
// 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 )->initialize( originalSize, targetSize, 500 );
|
||||||
m_expandedMap.value( index )->expand();
|
m_expandedMap.value( index )->expand();
|
||||||
}
|
}
|
||||||
|
@@ -498,9 +498,10 @@ SourceTreeView::dropEvent( QDropEvent* event )
|
|||||||
const QPoint pos = event->pos();
|
const QPoint pos = event->pos();
|
||||||
const QModelIndex index = indexAt( 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 );
|
Q_ASSERT( item );
|
||||||
|
|
||||||
item->setDropType( m_delegate->hoveredDropType() );
|
item->setDropType( m_delegate->hoveredDropType() );
|
||||||
|
Reference in New Issue
Block a user