mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-08-11 16:44:05 +02:00
* Tomahawk::Result now keeps track of the originating resolver and maintains a proper online state.
This commit is contained in:
@@ -20,7 +20,9 @@
|
|||||||
|
|
||||||
#include "Album.h"
|
#include "Album.h"
|
||||||
#include "Collection.h"
|
#include "Collection.h"
|
||||||
|
#include "Resolver.h"
|
||||||
#include "Source.h"
|
#include "Source.h"
|
||||||
|
#include "Pipeline.h"
|
||||||
#include "database/Database.h"
|
#include "database/Database.h"
|
||||||
#include "database/DatabaseCommand_Resolve.h"
|
#include "database/DatabaseCommand_Resolve.h"
|
||||||
#include "database/DatabaseCommand_AllTracks.h"
|
#include "database/DatabaseCommand_AllTracks.h"
|
||||||
@@ -72,6 +74,7 @@ Result::Result( const QString& url )
|
|||||||
, m_trackId( 0 )
|
, m_trackId( 0 )
|
||||||
, m_fileId( 0 )
|
, m_fileId( 0 )
|
||||||
{
|
{
|
||||||
|
connect( Pipeline::instance(), SIGNAL( resolverRemoved( Tomahawk::Resolver* ) ), SLOT( onResolverRemoved( Tomahawk::Resolver* ) ), Qt::QueuedConnection );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -94,12 +97,24 @@ Result::deleteLater()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
Result::onResolverRemoved( Tomahawk::Resolver* resolver )
|
||||||
|
{
|
||||||
|
if ( m_resolvedBy.data() == resolver )
|
||||||
|
{
|
||||||
|
m_resolvedBy.clear();
|
||||||
|
emit statusChanged();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
artist_ptr
|
artist_ptr
|
||||||
Result::artist() const
|
Result::artist() const
|
||||||
{
|
{
|
||||||
return m_artist;
|
return m_artist;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
artist_ptr
|
artist_ptr
|
||||||
Result::composer() const
|
Result::composer() const
|
||||||
{
|
{
|
||||||
@@ -124,19 +139,11 @@ Result::collection() const
|
|||||||
float
|
float
|
||||||
Result::score() const
|
Result::score() const
|
||||||
{
|
{
|
||||||
if ( !collection().isNull() && collection()->source()->isOnline() )
|
if ( isOnline() )
|
||||||
{
|
|
||||||
return m_score;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// check if this a valid collection-less result (e.g. from youtube, but ignore offline sources still)
|
|
||||||
if ( collection().isNull() )
|
|
||||||
return m_score;
|
return m_score;
|
||||||
else
|
else
|
||||||
return 0.0;
|
return 0.0;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
RID
|
RID
|
||||||
@@ -152,7 +159,14 @@ Result::id() const
|
|||||||
bool
|
bool
|
||||||
Result::isOnline() const
|
Result::isOnline() const
|
||||||
{
|
{
|
||||||
return ( ( !collection().isNull() && collection()->source()->isOnline() ) || collection().isNull() );
|
if ( !collection().isNull() )
|
||||||
|
{
|
||||||
|
return collection()->source()->isOnline();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return !m_resolvedBy.isNull();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -274,3 +288,20 @@ Result::friendlySource() const
|
|||||||
else
|
else
|
||||||
return collection()->source()->friendlyName();
|
return collection()->source()->friendlyName();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Tomahawk::Resolver*
|
||||||
|
Result::resolvedBy() const
|
||||||
|
{
|
||||||
|
if ( m_resolvedBy.isNull() )
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
return m_resolvedBy.data();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
Result::setResolvedBy( Tomahawk::Resolver* resolver )
|
||||||
|
{
|
||||||
|
m_resolvedBy = QWeakPointer< Tomahawk::Resolver >( resolver );
|
||||||
|
}
|
||||||
|
@@ -36,6 +36,8 @@ class DatabaseCommand_LoadFile;
|
|||||||
namespace Tomahawk
|
namespace Tomahawk
|
||||||
{
|
{
|
||||||
|
|
||||||
|
class Resolver;
|
||||||
|
|
||||||
class DLLEXPORT Result : public QObject
|
class DLLEXPORT Result : public QObject
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
@@ -54,6 +56,9 @@ public:
|
|||||||
QString toString() const;
|
QString toString() const;
|
||||||
Tomahawk::query_ptr toQuery();
|
Tomahawk::query_ptr toQuery();
|
||||||
|
|
||||||
|
Tomahawk::Resolver* resolvedBy() const;
|
||||||
|
void setResolvedBy( Tomahawk::Resolver* resolver );
|
||||||
|
|
||||||
float score() const;
|
float score() const;
|
||||||
RID id() const;
|
RID id() const;
|
||||||
bool isOnline() const;
|
bool isOnline() const;
|
||||||
@@ -111,6 +116,8 @@ private slots:
|
|||||||
void onOffline();
|
void onOffline();
|
||||||
void onOnline();
|
void onOnline();
|
||||||
|
|
||||||
|
void onResolverRemoved( Tomahawk::Resolver* resolver );
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// private constructor
|
// private constructor
|
||||||
explicit Result( const QString& url );
|
explicit Result( const QString& url );
|
||||||
@@ -121,6 +128,7 @@ private:
|
|||||||
mutable RID m_rid;
|
mutable RID m_rid;
|
||||||
collection_ptr m_collection;
|
collection_ptr m_collection;
|
||||||
Tomahawk::query_ptr m_query;
|
Tomahawk::query_ptr m_query;
|
||||||
|
QWeakPointer< Tomahawk::Resolver > m_resolvedBy;
|
||||||
|
|
||||||
Tomahawk::artist_ptr m_artist;
|
Tomahawk::artist_ptr m_artist;
|
||||||
Tomahawk::album_ptr m_album;
|
Tomahawk::album_ptr m_album;
|
||||||
|
Reference in New Issue
Block a user