mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-08-08 15:16:34 +02:00
Add localUrlForDownload method
This commit is contained in:
@@ -24,6 +24,8 @@
|
|||||||
#include "TomahawkSettings.h"
|
#include "TomahawkSettings.h"
|
||||||
#include "infosystem/InfoSystem.h"
|
#include "infosystem/InfoSystem.h"
|
||||||
#include "utils/Logger.h"
|
#include "utils/Logger.h"
|
||||||
|
#include "Result.h"
|
||||||
|
#include "Query.h"
|
||||||
|
|
||||||
DownloadManager* DownloadManager::s_instance = 0;
|
DownloadManager* DownloadManager::s_instance = 0;
|
||||||
|
|
||||||
@@ -85,6 +87,36 @@ DownloadManager::localFileForDownload( const QString& url ) const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
QUrl
|
||||||
|
DownloadManager::localUrlForDownload( const Tomahawk::query_ptr& query ) const
|
||||||
|
{
|
||||||
|
Tomahawk::result_ptr result = query->numResults( true ) ? query->results().first() : Tomahawk::result_ptr();
|
||||||
|
if ( result )
|
||||||
|
{
|
||||||
|
return localUrlForDownload( result );
|
||||||
|
}
|
||||||
|
|
||||||
|
return QUrl();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
QUrl
|
||||||
|
DownloadManager::localUrlForDownload( const Tomahawk::result_ptr& result ) const
|
||||||
|
{
|
||||||
|
if ( result && !result->downloadFormats().isEmpty() &&
|
||||||
|
!localFileForDownload( result->downloadFormats().first().url.toString() ).isEmpty() )
|
||||||
|
{
|
||||||
|
return QUrl::fromLocalFile( QFileInfo( DownloadManager::instance()->localFileForDownload( result->downloadFormats().first().url.toString() ) ).absolutePath() );
|
||||||
|
}
|
||||||
|
else if ( result && result->downloadJob() && result->downloadJob()->state() == DownloadJob::Finished )
|
||||||
|
{
|
||||||
|
return QUrl::fromLocalFile( QFileInfo( result->downloadJob()->localFile() ).absolutePath() );
|
||||||
|
}
|
||||||
|
|
||||||
|
return QUrl();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
DownloadManager::storeJobs( const QList<downloadjob_ptr>& jobs )
|
DownloadManager::storeJobs( const QList<downloadjob_ptr>& jobs )
|
||||||
{
|
{
|
||||||
|
@@ -45,6 +45,8 @@ public:
|
|||||||
|
|
||||||
void storeJobs( const QList<downloadjob_ptr>& jobs );
|
void storeJobs( const QList<downloadjob_ptr>& jobs );
|
||||||
QString localFileForDownload( const QString& url ) const;
|
QString localFileForDownload( const QString& url ) const;
|
||||||
|
QUrl localUrlForDownload( const Tomahawk::result_ptr& result ) const;
|
||||||
|
QUrl localUrlForDownload( const Tomahawk::query_ptr& query ) const;
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
bool addJob( const downloadjob_ptr& job );
|
bool addJob( const downloadjob_ptr& job );
|
||||||
|
Reference in New Issue
Block a user