1
0
mirror of https://github.com/tomahawk-player/tomahawk.git synced 2025-08-28 16:20:01 +02:00

Add download context menu to all playlist views but database collections

This commit is contained in:
Dominik Schmidt
2016-02-03 13:28:43 +01:00
parent a5693d6663
commit 87278456f4

View File

@@ -775,24 +775,42 @@ TrackView::onCustomContextMenu( const QPoint& pos )
m_contextMenu->setSupportedActions( m_contextMenu->supportedActions() | ContextMenu::ActionMarkListened
| ContextMenu::ActionDelete );
if ( proxyModel()->style() == PlayableProxyModel::Locker )
if ( proxyModel()->style() != PlayableProxyModel::Collection )
{
bool allDownloaded = true;
bool noneDownloadable = true;
bool downloadable = false;
foreach ( const QModelIndex& index, selectedIndexes() )
{
if ( index.column() )
continue;
PlayableItem* item = proxyModel()->itemFromIndex( proxyModel()->mapToSource( index ) );
if ( DownloadManager::instance()->localFileForDownload( item->query()->results().first()->downloadFormats().first().url.toString() ).isEmpty() )
if( item->query()->results().isEmpty() )
continue;
downloadable = !item->query()->results().first()->downloadFormats().isEmpty();
if ( downloadable )
{
noneDownloadable = false;
}
if ( downloadable && DownloadManager::instance()->localFileForDownload( item->query()->results().first()->downloadFormats().first().url.toString() ).isEmpty() )
{
allDownloaded = false;
}
if ( !allDownloaded || !noneDownloadable )
{
break;
}
}
if ( !allDownloaded )
if ( !allDownloaded || !noneDownloadable )
{
m_contextMenu->setSupportedActions( m_contextMenu->supportedActions() | ContextMenu::ActionDownload );
}
}
QList<query_ptr> queries;
@@ -915,13 +933,16 @@ TrackView::downloadSelectedItems()
PlayableItem* item = proxyModel()->itemFromIndex( proxyModel()->mapToSource( index ) );
if ( !DownloadManager::instance()->localFileForDownload( item->query()->results().first()->downloadFormats().first().url.toString() ).isEmpty() )
continue;
if ( !item )
continue;
if ( !item->result()->downloadFormats().isEmpty() )
DownloadManager::instance()->addJob( item->result()->toDownloadJob( item->result()->downloadFormats().first() ) );
if ( item->query()->results().isEmpty() || item->query()->results().first()->downloadFormats().isEmpty() )
continue;
if ( !DownloadManager::instance()->localFileForDownload( item->query()->results().first()->downloadFormats().first().url.toString() ).isEmpty() )
continue;
DownloadManager::instance()->addJob( item->result()->toDownloadJob( item->result()->downloadFormats().first() ) );
}
}