mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-03-13 20:39:57 +01:00
Show a 'Download All' button in the collection view's header. To be disabled for local collections.
This commit is contained in:
parent
7291246370
commit
1d836ad2de
@ -32,6 +32,7 @@
|
||||
#include "playlist/GridView.h"
|
||||
#include "playlist/PlayableProxyModelPlaylistInterface.h"
|
||||
#include "resolvers/ScriptCollection.h"
|
||||
#include "DownloadManager.h"
|
||||
#include "TomahawkSettings.h"
|
||||
#include "utils/ImageRegistry.h"
|
||||
#include "utils/TomahawkStyle.h"
|
||||
@ -89,13 +90,13 @@ CollectionViewPage::CollectionViewPage( const Tomahawk::collection_ptr& collecti
|
||||
m_header->ui->anchor2Label->setText( tr( "Albums" ) );
|
||||
m_header->ui->anchor3Label->setText( tr( "Songs" ) );
|
||||
|
||||
if( collection->browseCapabilities().contains( Collection::CapabilityBrowseArtists ) )
|
||||
if ( collection->browseCapabilities().contains( Collection::CapabilityBrowseArtists ) )
|
||||
m_header->ui->anchor1Label->show();
|
||||
|
||||
if( collection->browseCapabilities().contains( Collection::CapabilityBrowseAlbums ) )
|
||||
if ( collection->browseCapabilities().contains( Collection::CapabilityBrowseAlbums ) )
|
||||
m_header->ui->anchor2Label->show();
|
||||
|
||||
if( collection->browseCapabilities().contains( Collection::CapabilityBrowseTracks ) )
|
||||
if ( collection->browseCapabilities().contains( Collection::CapabilityBrowseTracks ) )
|
||||
m_header->ui->anchor3Label->show();
|
||||
|
||||
const float lowOpacity = 0.8;
|
||||
@ -113,6 +114,9 @@ CollectionViewPage::CollectionViewPage( const Tomahawk::collection_ptr& collecti
|
||||
NewClosure( m_header->ui->anchor3Label, SIGNAL( clicked() ), const_cast< CollectionViewPage* >( this ), SLOT( setCurrentMode( CollectionViewPageMode ) ), CollectionViewPage::Flat )->setAutoDelete( false );
|
||||
}
|
||||
|
||||
QAbstractButton* downloadButton = m_header->addButton( tr( "Download All" ) );
|
||||
connect( downloadButton, SIGNAL( clicked() ), SLOT( onDownloadAll() ) );
|
||||
|
||||
layout()->addWidget( m_header );
|
||||
layout()->addWidget( m_stack );
|
||||
|
||||
@ -418,6 +422,21 @@ CollectionViewPage::onCollectionChanged()
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
CollectionViewPage::onDownloadAll()
|
||||
{
|
||||
for ( int i = 0; i < m_flatModel->rowCount( QModelIndex() ); i++ )
|
||||
{
|
||||
PlayableItem* item = m_flatModel->itemFromIndex( m_flatModel->index( i, 0, QModelIndex() ) );
|
||||
if ( !item )
|
||||
continue;
|
||||
|
||||
if ( !item->result()->downloadFormats().isEmpty() )
|
||||
DownloadManager::instance()->addJob( item->result()->toDownloadJob( item->result()->downloadFormats().first() ) );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
bool
|
||||
CollectionViewPage::isTemporaryPage() const
|
||||
{
|
||||
|
@ -82,6 +82,8 @@ private slots:
|
||||
void onModelChanged();
|
||||
void onCollectionChanged();
|
||||
|
||||
void onDownloadAll();
|
||||
|
||||
private:
|
||||
FilterHeader* m_header;
|
||||
QPixmap m_pixmap;
|
||||
|
Loading…
x
Reference in New Issue
Block a user