mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-03-21 16:29:43 +01:00
Add constructor for a fixed Query<->Result relation
This commit is contained in:
parent
d00e8c8a8b
commit
9debd1b39e
@ -87,6 +87,16 @@ Query::get( const QString& query, const QID& qid )
|
||||
}
|
||||
|
||||
|
||||
query_ptr
|
||||
Query::getFixed( const track_ptr& track, const result_ptr& result )
|
||||
{
|
||||
query_ptr q = query_ptr( new Query( track, result ), &QObject::deleteLater );
|
||||
q->setWeakRef( q.toWeakRef() );
|
||||
|
||||
return q;
|
||||
}
|
||||
|
||||
|
||||
Query::Query( const track_ptr& track, const QID& qid, bool autoResolve )
|
||||
: d_ptr( new QueryPrivate( this, track, qid ) )
|
||||
{
|
||||
@ -101,6 +111,21 @@ Query::Query( const track_ptr& track, const QID& qid, bool autoResolve )
|
||||
}
|
||||
|
||||
|
||||
Query::Query( const track_ptr& track, const result_ptr& result )
|
||||
: d_ptr( new QueryPrivate( this, track, QString() ) )
|
||||
{
|
||||
Q_D( Query );
|
||||
|
||||
init();
|
||||
d->allowReresolve = false;
|
||||
d->resolveFinished = true;
|
||||
d->results << result;
|
||||
d->playable = result->playable();
|
||||
d->solved = true;
|
||||
connect( result.data(), SIGNAL( statusChanged() ), SLOT( onResultStatusChanged() ) );
|
||||
}
|
||||
|
||||
|
||||
Query::Query( const QString& query, const QID& qid )
|
||||
: d_ptr( new QueryPrivate( this, query, qid ) )
|
||||
{
|
||||
|
@ -49,6 +49,11 @@ public:
|
||||
static query_ptr get( const Tomahawk::track_ptr& track, const QID& qid = QString() );
|
||||
static query_ptr get( const QString& query, const QID& qid );
|
||||
|
||||
/**
|
||||
* Get a Query object with a fixed Result reference which is not re-resolved.
|
||||
*/
|
||||
static query_ptr getFixed( const Tomahawk::track_ptr& track, const Tomahawk::result_ptr& result );
|
||||
|
||||
virtual ~Query();
|
||||
|
||||
bool equals( const Tomahawk::query_ptr& other, bool ignoreCase = false, bool ignoreAlbum = false ) const;
|
||||
@ -139,6 +144,10 @@ private slots:
|
||||
private:
|
||||
Query();
|
||||
explicit Query( const track_ptr& track, const QID& qid, bool autoResolve );
|
||||
/**
|
||||
* Respective constructor for getFixed
|
||||
*/
|
||||
explicit Query( const track_ptr& track, const result_ptr& result );
|
||||
explicit Query( const QString& query, const QID& qid );
|
||||
|
||||
Q_DECLARE_PRIVATE( Query )
|
||||
|
@ -143,8 +143,6 @@ DatabaseCommand_AllTracks::exec( DatabaseImpl* dbi )
|
||||
artist, track, album,
|
||||
duration, composer,
|
||||
albumpos, discnumber );
|
||||
Tomahawk::query_ptr qry = Tomahawk::Query::get( t );
|
||||
|
||||
if ( m_album || m_artist ) {
|
||||
t->loadAttributes();
|
||||
}
|
||||
@ -154,17 +152,10 @@ DatabaseCommand_AllTracks::exec( DatabaseImpl* dbi )
|
||||
result->setBitrate( bitrate );
|
||||
result->setModificationTime( modificationTime );
|
||||
result->setMimetype( mimetype );
|
||||
result->setScore( 1.0 );
|
||||
result->setScore( 1.0f );
|
||||
result->setCollection( s->dbCollection(), false );
|
||||
|
||||
QList<Tomahawk::result_ptr> results;
|
||||
results << result;
|
||||
qry->addResults( results );
|
||||
qry->setResolveFinished( true );
|
||||
// These tracks are fixed to the Source. Do not re-resolve.
|
||||
qry->disallowReresolve();
|
||||
|
||||
ql << qry;
|
||||
ql << Tomahawk::Query::getFixed( t, result );
|
||||
}
|
||||
|
||||
emit tracks( ql, data() );
|
||||
|
Loading…
x
Reference in New Issue
Block a user