mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-08-13 09:34:53 +02:00
Pimple Query
This commit is contained in:
@@ -2,6 +2,7 @@
|
|||||||
*
|
*
|
||||||
* Copyright 2010-2011, Christian Muehlhaeuser <muesli@tomahawk-player.org>
|
* Copyright 2010-2011, Christian Muehlhaeuser <muesli@tomahawk-player.org>
|
||||||
* Copyright 2010-2012, Jeff Mitchell <jeff@tomahawk-player.org>
|
* Copyright 2010-2012, Jeff Mitchell <jeff@tomahawk-player.org>
|
||||||
|
* Copyright 2013, Uwe L. Korn <uwelk@xhochy.com>
|
||||||
*
|
*
|
||||||
* Tomahawk is free software: you can redistribute it and/or modify
|
* Tomahawk is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
@@ -17,7 +18,7 @@
|
|||||||
* along with Tomahawk. If not, see <http://www.gnu.org/licenses/>.
|
* along with Tomahawk. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "Query.h"
|
#include "Query_p.h"
|
||||||
|
|
||||||
#include "audio/AudioEngine.h"
|
#include "audio/AudioEngine.h"
|
||||||
#include "collection/Collection.h"
|
#include "collection/Collection.h"
|
||||||
@@ -87,8 +88,7 @@ Query::get( const QString& query, const QID& qid )
|
|||||||
|
|
||||||
|
|
||||||
Query::Query( const track_ptr& track, const QID& qid, bool autoResolve )
|
Query::Query( const track_ptr& track, const QID& qid, bool autoResolve )
|
||||||
: m_qid( qid )
|
: d_ptr( new QueryPrivate( this, track, qid ) )
|
||||||
, m_queryTrack( track )
|
|
||||||
{
|
{
|
||||||
init();
|
init();
|
||||||
|
|
||||||
@@ -102,8 +102,7 @@ Query::Query( const track_ptr& track, const QID& qid, bool autoResolve )
|
|||||||
|
|
||||||
|
|
||||||
Query::Query( const QString& query, const QID& qid )
|
Query::Query( const QString& query, const QID& qid )
|
||||||
: m_qid( qid )
|
: d_ptr( new QueryPrivate( this, query, qid ) )
|
||||||
, m_fullTextQuery( query )
|
|
||||||
{
|
{
|
||||||
init();
|
init();
|
||||||
|
|
||||||
@@ -116,46 +115,51 @@ Query::Query( const QString& query, const QID& qid )
|
|||||||
|
|
||||||
Query::~Query()
|
Query::~Query()
|
||||||
{
|
{
|
||||||
|
Q_D( Query );
|
||||||
tDebug( LOGVERBOSE ) << Q_FUNC_INFO << toString();
|
tDebug( LOGVERBOSE ) << Q_FUNC_INFO << toString();
|
||||||
|
|
||||||
QMutexLocker lock( &m_mutex );
|
QMutexLocker lock( &d->mutex );
|
||||||
m_ownRef.clear();
|
d->ownRef.clear();
|
||||||
m_results.clear();
|
d->results.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
Query::init()
|
Query::init()
|
||||||
{
|
{
|
||||||
m_resolveFinished = false;
|
Q_D( Query );
|
||||||
m_solved = false;
|
d->resolveFinished = false;
|
||||||
m_playable = false;
|
d->solved = false;
|
||||||
m_saveResultHint = false;
|
d->playable = false;
|
||||||
|
d->saveResultHint = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
track_ptr
|
track_ptr
|
||||||
Query::queryTrack() const
|
Query::queryTrack() const
|
||||||
{
|
{
|
||||||
return m_queryTrack;
|
Q_D( const Query );
|
||||||
|
return d->queryTrack;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
track_ptr
|
track_ptr
|
||||||
Query::track() const
|
Query::track() const
|
||||||
{
|
{
|
||||||
|
Q_D( const Query );
|
||||||
if ( !results().isEmpty() )
|
if ( !results().isEmpty() )
|
||||||
return results().first()->track();
|
return results().first()->track();
|
||||||
|
|
||||||
return m_queryTrack;
|
return d->queryTrack;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
Query::addResults( const QList< Tomahawk::result_ptr >& newresults )
|
Query::addResults( const QList< Tomahawk::result_ptr >& newresults )
|
||||||
{
|
{
|
||||||
|
Q_D( Query );
|
||||||
{
|
{
|
||||||
QMutexLocker lock( &m_mutex );
|
QMutexLocker lock( &d->mutex );
|
||||||
|
|
||||||
/* const QStringList smt = AudioEngine::instance()->supportedMimeTypes();
|
/* const QStringList smt = AudioEngine::instance()->supportedMimeTypes();
|
||||||
foreach ( const Tomahawk::result_ptr& result, newresults )
|
foreach ( const Tomahawk::result_ptr& result, newresults )
|
||||||
@@ -168,8 +172,8 @@ Query::addResults( const QList< Tomahawk::result_ptr >& newresults )
|
|||||||
m_results.append( result );
|
m_results.append( result );
|
||||||
}*/
|
}*/
|
||||||
|
|
||||||
m_results << newresults;
|
d->results << newresults;
|
||||||
qStableSort( m_results.begin(), m_results.end(), Query::resultSorter );
|
qStableSort( d->results.begin(), d->results.end(), Query::resultSorter );
|
||||||
|
|
||||||
// hook up signals, and check solved status
|
// hook up signals, and check solved status
|
||||||
foreach( const result_ptr& rp, newresults )
|
foreach( const result_ptr& rp, newresults )
|
||||||
@@ -188,8 +192,9 @@ void
|
|||||||
Query::addAlbums( const QList< Tomahawk::album_ptr >& newalbums )
|
Query::addAlbums( const QList< Tomahawk::album_ptr >& newalbums )
|
||||||
{
|
{
|
||||||
{
|
{
|
||||||
QMutexLocker lock( &m_mutex );
|
Q_D( Query );
|
||||||
m_albums << newalbums;
|
QMutexLocker lock( &d->mutex );
|
||||||
|
d->albums << newalbums;
|
||||||
}
|
}
|
||||||
|
|
||||||
emit albumsAdded( newalbums );
|
emit albumsAdded( newalbums );
|
||||||
@@ -200,8 +205,9 @@ void
|
|||||||
Query::addArtists( const QList< Tomahawk::artist_ptr >& newartists )
|
Query::addArtists( const QList< Tomahawk::artist_ptr >& newartists )
|
||||||
{
|
{
|
||||||
{
|
{
|
||||||
QMutexLocker lock( &m_mutex );
|
Q_D( Query );
|
||||||
m_artists << newartists;
|
QMutexLocker lock( &d->mutex );
|
||||||
|
d->artists << newartists;
|
||||||
}
|
}
|
||||||
|
|
||||||
emit artistsAdded( newartists );
|
emit artistsAdded( newartists );
|
||||||
@@ -211,23 +217,31 @@ Query::addArtists( const QList< Tomahawk::artist_ptr >& newartists )
|
|||||||
void
|
void
|
||||||
Query::refreshResults()
|
Query::refreshResults()
|
||||||
{
|
{
|
||||||
if ( m_resolveFinished )
|
Q_D( Query );
|
||||||
|
if ( d->resolveFinished )
|
||||||
{
|
{
|
||||||
m_resolveFinished = false;
|
d->resolveFinished = false;
|
||||||
query_ptr q = m_ownRef.toStrongRef();
|
query_ptr q = d->ownRef.toStrongRef();
|
||||||
if ( q )
|
if ( q )
|
||||||
Pipeline::instance()->resolve( q );
|
Pipeline::instance()->resolve( q );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Query::Query()
|
||||||
|
: d_ptr( new QueryPrivate( this ) )
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
Query::onResultStatusChanged()
|
Query::onResultStatusChanged()
|
||||||
{
|
{
|
||||||
{
|
{
|
||||||
QMutexLocker lock( &m_mutex );
|
Q_D( Query );
|
||||||
if ( m_results.count() )
|
QMutexLocker lock( &d->mutex );
|
||||||
qStableSort( m_results.begin(), m_results.end(), Query::resultSorter );
|
if ( d->results.count() )
|
||||||
|
qStableSort( d->results.begin(), d->results.end(), Query::resultSorter );
|
||||||
}
|
}
|
||||||
|
|
||||||
checkResults();
|
checkResults();
|
||||||
@@ -239,8 +253,9 @@ void
|
|||||||
Query::removeResult( const Tomahawk::result_ptr& result )
|
Query::removeResult( const Tomahawk::result_ptr& result )
|
||||||
{
|
{
|
||||||
{
|
{
|
||||||
QMutexLocker lock( &m_mutex );
|
Q_D( Query );
|
||||||
m_results.removeAll( result );
|
QMutexLocker lock( &d->mutex );
|
||||||
|
d->results.removeAll( result );
|
||||||
}
|
}
|
||||||
|
|
||||||
emit resultsRemoved( result );
|
emit resultsRemoved( result );
|
||||||
@@ -252,13 +267,14 @@ Query::removeResult( const Tomahawk::result_ptr& result )
|
|||||||
void
|
void
|
||||||
Query::onResolvingFinished()
|
Query::onResolvingFinished()
|
||||||
{
|
{
|
||||||
|
Q_D( Query );
|
||||||
tDebug( LOGVERBOSE ) << "Finished resolving:" << toString();
|
tDebug( LOGVERBOSE ) << "Finished resolving:" << toString();
|
||||||
if ( !m_resolveFinished )
|
if ( !d->resolveFinished )
|
||||||
{
|
{
|
||||||
m_resolveFinished = true;
|
d->resolveFinished = true;
|
||||||
m_resolvers.clear();
|
d->resolvers.clear();
|
||||||
|
|
||||||
emit resolvingFinished( m_playable );
|
emit resolvingFinished( d->playable );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -276,28 +292,55 @@ Query::onResolverAdded()
|
|||||||
QList< result_ptr >
|
QList< result_ptr >
|
||||||
Query::results() const
|
Query::results() const
|
||||||
{
|
{
|
||||||
QMutexLocker lock( &m_mutex );
|
Q_D( const Query );
|
||||||
return m_results;
|
QMutexLocker lock( &d->mutex );
|
||||||
|
return d->results;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
unsigned int
|
unsigned int
|
||||||
Query::numResults() const
|
Query::numResults() const
|
||||||
{
|
{
|
||||||
QMutexLocker lock( &m_mutex );
|
Q_D( const Query );
|
||||||
return m_results.length();
|
QMutexLocker lock( &d->mutex );
|
||||||
|
return d->results.length();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool
|
||||||
|
Query::resolvingFinished() const
|
||||||
|
{
|
||||||
|
Q_D( const Query );
|
||||||
|
return d->resolveFinished;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool
|
||||||
|
Query::solved() const
|
||||||
|
{
|
||||||
|
Q_D( const Query );
|
||||||
|
return d->solved;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool
|
||||||
|
Query::playable() const
|
||||||
|
{
|
||||||
|
Q_D( const Query );
|
||||||
|
return d->playable;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
QID
|
QID
|
||||||
Query::id() const
|
Query::id() const
|
||||||
{
|
{
|
||||||
if ( m_qid.isEmpty() )
|
Q_D( const Query );
|
||||||
|
if ( d->qid.isEmpty() )
|
||||||
{
|
{
|
||||||
m_qid = uuid();
|
d->qid = uuid();
|
||||||
}
|
}
|
||||||
|
|
||||||
return m_qid;
|
return d->qid;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -322,17 +365,19 @@ Query::resultSorter( const result_ptr& left, const result_ptr& right )
|
|||||||
void
|
void
|
||||||
Query::setCurrentResolver( Tomahawk::Resolver* resolver )
|
Query::setCurrentResolver( Tomahawk::Resolver* resolver )
|
||||||
{
|
{
|
||||||
m_resolvers << resolver;
|
Q_D( Query );
|
||||||
|
d->resolvers << resolver;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Tomahawk::Resolver*
|
Tomahawk::Resolver*
|
||||||
Query::currentResolver() const
|
Query::currentResolver() const
|
||||||
{
|
{
|
||||||
int x = m_resolvers.count();
|
Q_D( const Query );
|
||||||
|
int x = d->resolvers.count();
|
||||||
while ( --x )
|
while ( --x )
|
||||||
{
|
{
|
||||||
QPointer< Resolver > r = m_resolvers.at( x );
|
QPointer< Resolver > r = d->resolvers.at( x );
|
||||||
if ( r.isNull() )
|
if ( r.isNull() )
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
@@ -343,6 +388,38 @@ Query::currentResolver() const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
QList< QPointer<Resolver> >
|
||||||
|
Query::resolvedBy() const
|
||||||
|
{
|
||||||
|
Q_D( const Query );
|
||||||
|
return d->resolvers;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
QString
|
||||||
|
Query::fullTextQuery() const
|
||||||
|
{
|
||||||
|
Q_D( const Query );
|
||||||
|
return d->fullTextQuery;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool
|
||||||
|
Query::isFullTextQuery() const
|
||||||
|
{
|
||||||
|
Q_D( const Query );
|
||||||
|
return !d->fullTextQuery.isEmpty();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
Query::setResolveFinished( bool resolved )
|
||||||
|
{
|
||||||
|
Q_D( Query );
|
||||||
|
d->resolveFinished = resolved;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
Query::clearResults()
|
Query::clearResults()
|
||||||
{
|
{
|
||||||
@@ -356,14 +433,15 @@ Query::clearResults()
|
|||||||
void
|
void
|
||||||
Query::checkResults()
|
Query::checkResults()
|
||||||
{
|
{
|
||||||
|
Q_D( Query );
|
||||||
bool playable = false;
|
bool playable = false;
|
||||||
bool solved = false;
|
bool solved = false;
|
||||||
|
|
||||||
{
|
{
|
||||||
QMutexLocker lock( &m_mutex );
|
QMutexLocker lock( &d->mutex );
|
||||||
|
|
||||||
// hook up signals, and check solved status
|
// hook up signals, and check solved status
|
||||||
foreach( const result_ptr& rp, m_results )
|
foreach( const result_ptr& rp, d->results )
|
||||||
{
|
{
|
||||||
if ( rp->playable() )
|
if ( rp->playable() )
|
||||||
playable = true;
|
playable = true;
|
||||||
@@ -378,19 +456,19 @@ Query::checkResults()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( m_solved && !solved )
|
if ( d->solved && !solved )
|
||||||
{
|
{
|
||||||
refreshResults();
|
refreshResults();
|
||||||
}
|
}
|
||||||
if ( m_playable != playable )
|
if ( d->playable != playable )
|
||||||
{
|
{
|
||||||
m_playable = playable;
|
d->playable = playable;
|
||||||
emit playableStateChanged( m_playable );
|
emit playableStateChanged( d->playable );
|
||||||
}
|
}
|
||||||
if ( m_solved != solved )
|
if ( d->solved != solved )
|
||||||
{
|
{
|
||||||
m_solved = solved;
|
d->solved = solved;
|
||||||
emit solvedStateChanged( m_solved );
|
emit solvedStateChanged( d->solved );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -450,6 +528,7 @@ Query::toString() const
|
|||||||
float
|
float
|
||||||
Query::howSimilar( const Tomahawk::result_ptr& r )
|
Query::howSimilar( const Tomahawk::result_ptr& r )
|
||||||
{
|
{
|
||||||
|
Q_D( Query );
|
||||||
// result values
|
// result values
|
||||||
const QString rArtistname = r->track()->artistSortname();
|
const QString rArtistname = r->track()->artistSortname();
|
||||||
const QString rAlbumname = r->track()->albumSortname();
|
const QString rAlbumname = r->track()->albumSortname();
|
||||||
@@ -461,8 +540,8 @@ Query::howSimilar( const Tomahawk::result_ptr& r )
|
|||||||
|
|
||||||
if ( isFullTextQuery() )
|
if ( isFullTextQuery() )
|
||||||
{
|
{
|
||||||
qArtistname = DatabaseImpl::sortname( m_fullTextQuery, true );
|
qArtistname = DatabaseImpl::sortname( d->fullTextQuery, true );
|
||||||
qAlbumname = DatabaseImpl::sortname( m_fullTextQuery );
|
qAlbumname = DatabaseImpl::sortname( d->fullTextQuery );
|
||||||
qTrackname = qAlbumname;
|
qTrackname = qAlbumname;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -516,5 +595,47 @@ Query::howSimilar( const Tomahawk::result_ptr& r )
|
|||||||
void
|
void
|
||||||
Query::setSaveHTTPResultHint( bool saveResultHint )
|
Query::setSaveHTTPResultHint( bool saveResultHint )
|
||||||
{
|
{
|
||||||
m_saveResultHint = saveResultHint;
|
Q_D( Query );
|
||||||
|
d->saveResultHint = saveResultHint;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool
|
||||||
|
Query::saveHTTPResultHint() const
|
||||||
|
{
|
||||||
|
Q_D( const Query );
|
||||||
|
return d->saveResultHint;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
QString
|
||||||
|
Query::resultHint() const
|
||||||
|
{
|
||||||
|
Q_D( const Query );
|
||||||
|
return d->resultHint;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
Query::setResultHint( const QString& resultHint )
|
||||||
|
{
|
||||||
|
Q_D( Query );
|
||||||
|
d->resultHint = resultHint;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
QWeakPointer<Query>
|
||||||
|
Query::weakRef()
|
||||||
|
{
|
||||||
|
Q_D( Query );
|
||||||
|
return d->ownRef;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
Query::setWeakRef( QWeakPointer<Query> weakRef )
|
||||||
|
{
|
||||||
|
Q_D( Query );
|
||||||
|
d->ownRef = weakRef;
|
||||||
|
}
|
||||||
|
|
||||||
|
@@ -2,6 +2,7 @@
|
|||||||
*
|
*
|
||||||
* Copyright 2010-2011, Christian Muehlhaeuser <muesli@tomahawk-player.org>
|
* Copyright 2010-2011, Christian Muehlhaeuser <muesli@tomahawk-player.org>
|
||||||
* Copyright 2010-2012, Jeff Mitchell <jeff@tomahawk-player.org>
|
* Copyright 2010-2012, Jeff Mitchell <jeff@tomahawk-player.org>
|
||||||
|
* Copyright 2013, Uwe L. Korn <uwelk@xhochy.com>
|
||||||
*
|
*
|
||||||
* Tomahawk is free software: you can redistribute it and/or modify
|
* Tomahawk is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
@@ -17,11 +18,11 @@
|
|||||||
* along with Tomahawk. If not, see <http://www.gnu.org/licenses/>.
|
* along with Tomahawk. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#pragma once
|
||||||
#ifndef QUERY_H
|
#ifndef QUERY_H
|
||||||
#define QUERY_H
|
#define QUERY_H
|
||||||
|
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
#include <QMutex>
|
|
||||||
#include <QList>
|
#include <QList>
|
||||||
#include <QVariant>
|
#include <QVariant>
|
||||||
|
|
||||||
@@ -33,8 +34,8 @@ namespace Tomahawk
|
|||||||
{
|
{
|
||||||
|
|
||||||
class DatabaseCommand_LoadPlaylistEntries;
|
class DatabaseCommand_LoadPlaylistEntries;
|
||||||
|
|
||||||
class Resolver;
|
class Resolver;
|
||||||
|
class QueryPrivate;
|
||||||
|
|
||||||
class DLLEXPORT Query : public QObject
|
class DLLEXPORT Query : public QObject
|
||||||
{
|
{
|
||||||
@@ -67,28 +68,28 @@ public:
|
|||||||
/// how many results found so far?
|
/// how many results found so far?
|
||||||
unsigned int numResults() const;
|
unsigned int numResults() const;
|
||||||
|
|
||||||
bool resolvingFinished() const { return m_resolveFinished; }
|
bool resolvingFinished() const;
|
||||||
/// true when a perfect result has been found (score of 1.0)
|
/// true when a perfect result has been found (score of 1.0)
|
||||||
bool solved() const { return m_solved; }
|
bool solved() const;
|
||||||
/// true when any result has been found (score may be less than 1.0)
|
/// true when any result has been found (score may be less than 1.0)
|
||||||
bool playable() const { return m_playable; }
|
bool playable() const;
|
||||||
|
|
||||||
Tomahawk::Resolver* currentResolver() const;
|
Tomahawk::Resolver* currentResolver() const;
|
||||||
QList< QPointer< Tomahawk::Resolver > > resolvedBy() const { return m_resolvers; }
|
QList< QPointer< Tomahawk::Resolver > > resolvedBy() const;
|
||||||
|
|
||||||
QString fullTextQuery() const { return m_fullTextQuery; }
|
QString fullTextQuery() const;
|
||||||
bool isFullTextQuery() const { return !m_fullTextQuery.isEmpty(); }
|
bool isFullTextQuery() const;
|
||||||
|
|
||||||
void setResolveFinished( bool resolved ) { m_resolveFinished = resolved; }
|
void setResolveFinished( bool resolved );
|
||||||
|
|
||||||
void setSaveHTTPResultHint( bool saveResultHint );
|
void setSaveHTTPResultHint( bool saveResultHint );
|
||||||
bool saveHTTPResultHint() const { return m_saveResultHint; }
|
bool saveHTTPResultHint() const;
|
||||||
|
|
||||||
QString resultHint() const { return m_resultHint; }
|
QString resultHint() const;
|
||||||
void setResultHint( const QString& resultHint ) { m_resultHint = resultHint; }
|
void setResultHint( const QString& resultHint );
|
||||||
|
|
||||||
QWeakPointer< Tomahawk::Query > weakRef() { return m_ownRef; }
|
QWeakPointer< Tomahawk::Query > weakRef();
|
||||||
void setWeakRef( QWeakPointer< Tomahawk::Query > weakRef ) { m_ownRef = weakRef; }
|
void setWeakRef( QWeakPointer< Tomahawk::Query > weakRef );
|
||||||
|
|
||||||
/// sorter for list of results
|
/// sorter for list of results
|
||||||
static bool resultSorter( const result_ptr& left, const result_ptr& right );
|
static bool resultSorter( const result_ptr& left, const result_ptr& right );
|
||||||
@@ -116,6 +117,9 @@ public slots:
|
|||||||
void onResolvingFinished();
|
void onResolvingFinished();
|
||||||
void onResolverAdded();
|
void onResolverAdded();
|
||||||
|
|
||||||
|
protected:
|
||||||
|
QScopedPointer<QueryPrivate> d_ptr;
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void onResultStatusChanged();
|
void onResultStatusChanged();
|
||||||
void refreshResults();
|
void refreshResults();
|
||||||
@@ -125,31 +129,13 @@ private:
|
|||||||
explicit Query( const track_ptr& track, const QID& qid, bool autoResolve );
|
explicit Query( const track_ptr& track, const QID& qid, bool autoResolve );
|
||||||
explicit Query( const QString& query, const QID& qid );
|
explicit Query( const QString& query, const QID& qid );
|
||||||
|
|
||||||
|
Q_DECLARE_PRIVATE( Query )
|
||||||
|
|
||||||
void init();
|
void init();
|
||||||
|
|
||||||
void setCurrentResolver( Tomahawk::Resolver* resolver );
|
void setCurrentResolver( Tomahawk::Resolver* resolver );
|
||||||
void clearResults();
|
void clearResults();
|
||||||
void checkResults();
|
void checkResults();
|
||||||
|
|
||||||
QList< Tomahawk::artist_ptr > m_artists;
|
|
||||||
QList< Tomahawk::album_ptr > m_albums;
|
|
||||||
QList< Tomahawk::result_ptr > m_results;
|
|
||||||
bool m_solved;
|
|
||||||
bool m_playable;
|
|
||||||
bool m_resolveFinished;
|
|
||||||
mutable QID m_qid;
|
|
||||||
|
|
||||||
QString m_fullTextQuery;
|
|
||||||
|
|
||||||
QString m_resultHint;
|
|
||||||
bool m_saveResultHint;
|
|
||||||
|
|
||||||
QList< QPointer< Tomahawk::Resolver > > m_resolvers;
|
|
||||||
|
|
||||||
track_ptr m_queryTrack;
|
|
||||||
|
|
||||||
mutable QMutex m_mutex;
|
|
||||||
QWeakPointer< Tomahawk::Query > m_ownRef;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
} //ns
|
} //ns
|
||||||
|
60
src/libtomahawk/Query_p.h
Normal file
60
src/libtomahawk/Query_p.h
Normal file
@@ -0,0 +1,60 @@
|
|||||||
|
#ifndef QUERY_P_H
|
||||||
|
#define QUERY_P_H
|
||||||
|
|
||||||
|
#include "Query.h"
|
||||||
|
|
||||||
|
#include <QMutex>
|
||||||
|
|
||||||
|
namespace Tomahawk
|
||||||
|
{
|
||||||
|
|
||||||
|
class QueryPrivate
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
QueryPrivate( Query* q )
|
||||||
|
: q_ptr( q )
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
QueryPrivate( Query* q, const track_ptr& track, const QID& _qid )
|
||||||
|
: q_ptr( q )
|
||||||
|
, qid( _qid )
|
||||||
|
, queryTrack( track )
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
QueryPrivate( Query* q, const QString& query, const QID& _qid )
|
||||||
|
: q_ptr( q )
|
||||||
|
, qid( _qid )
|
||||||
|
, fullTextQuery( query )
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
Q_DECLARE_PUBLIC( Query )
|
||||||
|
Query* q_ptr;
|
||||||
|
|
||||||
|
private:
|
||||||
|
QList< Tomahawk::artist_ptr > artists;
|
||||||
|
QList< Tomahawk::album_ptr > albums;
|
||||||
|
QList< Tomahawk::result_ptr > results;
|
||||||
|
bool solved;
|
||||||
|
bool playable;
|
||||||
|
bool resolveFinished;
|
||||||
|
mutable QID qid;
|
||||||
|
|
||||||
|
QString fullTextQuery;
|
||||||
|
|
||||||
|
QString resultHint;
|
||||||
|
bool saveResultHint;
|
||||||
|
|
||||||
|
QList< QPointer< Tomahawk::Resolver > > resolvers;
|
||||||
|
|
||||||
|
track_ptr queryTrack;
|
||||||
|
|
||||||
|
mutable QMutex mutex;
|
||||||
|
QWeakPointer< Tomahawk::Query > ownRef;
|
||||||
|
};
|
||||||
|
|
||||||
|
} // Tomahawk
|
||||||
|
|
||||||
|
#endif // QUERY_P_H
|
Reference in New Issue
Block a user