mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-08-29 16:50:11 +02:00
Add download context menu to all playlist views but database collections
This commit is contained in:
@@ -775,25 +775,43 @@ TrackView::onCustomContextMenu( const QPoint& pos )
|
|||||||
m_contextMenu->setSupportedActions( m_contextMenu->supportedActions() | ContextMenu::ActionMarkListened
|
m_contextMenu->setSupportedActions( m_contextMenu->supportedActions() | ContextMenu::ActionMarkListened
|
||||||
| ContextMenu::ActionDelete );
|
| ContextMenu::ActionDelete );
|
||||||
|
|
||||||
if ( proxyModel()->style() == PlayableProxyModel::Locker )
|
if ( proxyModel()->style() != PlayableProxyModel::Collection )
|
||||||
{
|
{
|
||||||
bool allDownloaded = true;
|
bool allDownloaded = true;
|
||||||
|
bool noneDownloadable = true;
|
||||||
|
bool downloadable = false;
|
||||||
foreach ( const QModelIndex& index, selectedIndexes() )
|
foreach ( const QModelIndex& index, selectedIndexes() )
|
||||||
{
|
{
|
||||||
if ( index.column() )
|
if ( index.column() )
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
PlayableItem* item = proxyModel()->itemFromIndex( proxyModel()->mapToSource( index ) );
|
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;
|
allDownloaded = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( !allDownloaded || !noneDownloadable )
|
||||||
|
{
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( !allDownloaded )
|
if ( !allDownloaded || !noneDownloadable )
|
||||||
|
{
|
||||||
m_contextMenu->setSupportedActions( m_contextMenu->supportedActions() | ContextMenu::ActionDownload );
|
m_contextMenu->setSupportedActions( m_contextMenu->supportedActions() | ContextMenu::ActionDownload );
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
QList<query_ptr> queries;
|
QList<query_ptr> queries;
|
||||||
foreach ( const QModelIndex& index, selectedIndexes() )
|
foreach ( const QModelIndex& index, selectedIndexes() )
|
||||||
@@ -915,12 +933,15 @@ TrackView::downloadSelectedItems()
|
|||||||
|
|
||||||
PlayableItem* item = proxyModel()->itemFromIndex( proxyModel()->mapToSource( index ) );
|
PlayableItem* item = proxyModel()->itemFromIndex( proxyModel()->mapToSource( index ) );
|
||||||
|
|
||||||
if ( !DownloadManager::instance()->localFileForDownload( item->query()->results().first()->downloadFormats().first().url.toString() ).isEmpty() )
|
|
||||||
continue;
|
|
||||||
if ( !item )
|
if ( !item )
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if ( !item->result()->downloadFormats().isEmpty() )
|
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() ) );
|
DownloadManager::instance()->addJob( item->result()->toDownloadJob( item->result()->downloadFormats().first() ) );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user