From ae16fcda43fe8b4feffbc8ed8f024b92c0a2e194 Mon Sep 17 00:00:00 2001 From: Christian Muehlhaeuser Date: Sun, 5 Oct 2014 08:06:37 +0200 Subject: [PATCH] * Query::numResults( onlyPlayableResults ) lets you count only online results. --- src/libtomahawk/Query.cpp | 15 ++++++++++++++- src/libtomahawk/Query.h | 2 +- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/src/libtomahawk/Query.cpp b/src/libtomahawk/Query.cpp index 645af6ef0..1c4702376 100644 --- a/src/libtomahawk/Query.cpp +++ b/src/libtomahawk/Query.cpp @@ -322,10 +322,23 @@ Query::results() const unsigned int -Query::numResults() const +Query::numResults( bool onlyPlayableResults ) const { Q_D( const Query ); QMutexLocker lock( &d->mutex ); + + if ( onlyPlayableResults ) + { + unsigned int c = 0; + foreach ( const result_ptr& result, d->results ) + { + if ( result->isOnline() ) + c++; + } + + return c; + } + return d->results.length(); } diff --git a/src/libtomahawk/Query.h b/src/libtomahawk/Query.h index c3b8f0832..1b9bb9342 100644 --- a/src/libtomahawk/Query.h +++ b/src/libtomahawk/Query.h @@ -71,7 +71,7 @@ public: QList< result_ptr > results() const; /// how many results found so far? - unsigned int numResults() const; + unsigned int numResults( bool onlyPlayableResults = false ) const; bool resolvingFinished() const; /// true when a perfect result has been found (score of 1.0)