From 5d72c82e0194a35139b7cb3172cd5658946984de Mon Sep 17 00:00:00 2001 From: Christian Muehlhaeuser Date: Wed, 1 Apr 2015 01:45:52 +0200 Subject: [PATCH] Handle preferred download format in Results. --- src/libtomahawk/Result.cpp | 15 +++++++++++++++ src/libtomahawk/Result.h | 2 +- 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/src/libtomahawk/Result.cpp b/src/libtomahawk/Result.cpp index b989b0ea8..e07634f3c 100644 --- a/src/libtomahawk/Result.cpp +++ b/src/libtomahawk/Result.cpp @@ -33,6 +33,7 @@ #include "Pipeline.h" #include "PlaylistInterface.h" #include "Source.h" +#include "TomahawkSettings.h" #include "Track.h" #include "Typedefs.h" @@ -530,6 +531,20 @@ Result::track() const } +void +Result::setDownloadFormats( const QList& formats ) +{ + m_formats.clear(); + foreach ( const DownloadFormat& format, formats ) + { + if ( format.extension.toLower() == TomahawkSettings::instance()->downloadsPreferredFormat().toLower() ) + m_formats.insert( 0, format ); + else + m_formats << format; + } +} + + downloadjob_ptr Result::toDownloadJob( const DownloadFormat& format ) { diff --git a/src/libtomahawk/Result.h b/src/libtomahawk/Result.h index 5a99ac73e..16edcdf35 100644 --- a/src/libtomahawk/Result.h +++ b/src/libtomahawk/Result.h @@ -132,7 +132,7 @@ public: track_ptr track() const; QList downloadFormats() const { return m_formats; } - void setDownloadFormats( const QList& formats ) { m_formats = formats; } + void setDownloadFormats( const QList& formats ); downloadjob_ptr downloadJob() const { return m_downloadJob; } downloadjob_ptr toDownloadJob( const DownloadFormat& format );