mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-08-02 04:10:20 +02:00
Add basic JS fuzzy resolve implementations
This commit is contained in:
@@ -195,6 +195,25 @@ FuzzyIndex::appendFields( const Tomahawk::IndexData& data )
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
FuzzyIndex::deleteIndex()
|
||||||
|
{
|
||||||
|
if ( m_luceneReader != 0 )
|
||||||
|
{
|
||||||
|
tDebug( LOGVERBOSE ) << "Deleting old lucene stuff.";
|
||||||
|
|
||||||
|
m_luceneSearcher->close();
|
||||||
|
m_luceneReader->close();
|
||||||
|
delete m_luceneSearcher;
|
||||||
|
delete m_luceneReader;
|
||||||
|
m_luceneSearcher = 0;
|
||||||
|
m_luceneReader = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
TomahawkUtils::removeDirectory( m_lucenePath );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
FuzzyIndex::loadLuceneIndex()
|
FuzzyIndex::loadLuceneIndex()
|
||||||
{
|
{
|
||||||
|
@@ -61,6 +61,13 @@ public:
|
|||||||
void endIndexing();
|
void endIndexing();
|
||||||
void appendFields( const Tomahawk::IndexData& data );
|
void appendFields( const Tomahawk::IndexData& data );
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Delete the index from the harddrive.
|
||||||
|
*
|
||||||
|
* You should no longer use this FuzzyIndex object after this call.
|
||||||
|
*/
|
||||||
|
void deleteIndex();
|
||||||
|
|
||||||
virtual void updateIndex() = 0;
|
virtual void updateIndex() = 0;
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
|
@@ -487,6 +487,59 @@ JSResolverHelper::reportStreamUrl( const QString& qid,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool
|
||||||
|
JSResolverHelper::hasFuzzyIndex()
|
||||||
|
{
|
||||||
|
return !m_resolver->d_func()->fuzzyIndex.isNull();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
JSResolverHelper::createFuzzyIndex( const QVariantList& list )
|
||||||
|
{
|
||||||
|
// TODO
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
JSResolverHelper::addToFuzzyIndex( const QVariantList& list )
|
||||||
|
{
|
||||||
|
// TODO
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
QMap<int, float>
|
||||||
|
JSResolverHelper::searchFuzzyIndex( const QString& query )
|
||||||
|
{
|
||||||
|
if ( m_resolver->d_func()->fuzzyIndex )
|
||||||
|
{
|
||||||
|
return m_resolver->d_func()->fuzzyIndex->search( Query::get( query, QString() ) );
|
||||||
|
}
|
||||||
|
return QMap<int, float>();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
QMap<int, float>
|
||||||
|
JSResolverHelper::resolveFromFuzzyIndex( const QString& artist, const QString& album, const QString& track )
|
||||||
|
{
|
||||||
|
if ( m_resolver->d_func()->fuzzyIndex )
|
||||||
|
{
|
||||||
|
// Important: Do not autoresolve!
|
||||||
|
query_ptr query = Query::get( artist, album, track, QString(), false );
|
||||||
|
return m_resolver->d_func()->fuzzyIndex->search( query );
|
||||||
|
}
|
||||||
|
return QMap<int, float>();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
JSResolverHelper::deleteFuzzyIndex()
|
||||||
|
{
|
||||||
|
m_resolver->d_func()->fuzzyIndex->deleteIndex();
|
||||||
|
m_resolver->d_func()->fuzzyIndex->deleteLater();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
JSResolverHelper::returnStreamUrl( const QString& streamUrl, const QMap<QString, QString>& headers,
|
JSResolverHelper::returnStreamUrl( const QString& streamUrl, const QMap<QString, QString>& headers,
|
||||||
boost::function< void( const QString&, QSharedPointer< QIODevice >& ) > callback )
|
boost::function< void( const QString&, QSharedPointer< QIODevice >& ) > callback )
|
||||||
|
@@ -47,6 +47,17 @@ public:
|
|||||||
Q_INVOKABLE void reportStreamUrl( const QString& qid, const QString& streamUrl );
|
Q_INVOKABLE void reportStreamUrl( const QString& qid, const QString& streamUrl );
|
||||||
Q_INVOKABLE void reportStreamUrl( const QString& qid, const QString& streamUrl, const QVariantMap& headers );
|
Q_INVOKABLE void reportStreamUrl( const QString& qid, const QString& streamUrl, const QVariantMap& headers );
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Clucene indices for JS resolvers
|
||||||
|
**/
|
||||||
|
|
||||||
|
Q_INVOKABLE bool hasFuzzyIndex();
|
||||||
|
Q_INVOKABLE void createFuzzyIndex( const QVariantList& list );
|
||||||
|
Q_INVOKABLE void addToFuzzyIndex( const QVariantList& list );
|
||||||
|
Q_INVOKABLE QMap<int, float> searchFuzzyIndex( const QString& query );
|
||||||
|
Q_INVOKABLE QMap<int, float> resolveFromFuzzyIndex( const QString& artist, const QString& album, const QString& tracks );
|
||||||
|
Q_INVOKABLE void deleteFuzzyIndex();
|
||||||
|
|
||||||
void customIODeviceFactory( const Tomahawk::result_ptr&, const QString& url,
|
void customIODeviceFactory( const Tomahawk::result_ptr&, const QString& url,
|
||||||
boost::function< void( const QString&, QSharedPointer< QIODevice >& ) > callback ); // async
|
boost::function< void( const QString&, QSharedPointer< QIODevice >& ) > callback ); // async
|
||||||
|
|
||||||
|
@@ -25,6 +25,7 @@
|
|||||||
#include "JSResolver.h"
|
#include "JSResolver.h"
|
||||||
|
|
||||||
#include "JSResolverHelper.h"
|
#include "JSResolverHelper.h"
|
||||||
|
#include "database/fuzzyindex/FuzzyIndex.h"
|
||||||
|
|
||||||
class JSResolverPrivate
|
class JSResolverPrivate
|
||||||
{
|
{
|
||||||
@@ -57,6 +58,7 @@ private:
|
|||||||
Tomahawk::ExternalResolver::ErrorState error;
|
Tomahawk::ExternalResolver::ErrorState error;
|
||||||
|
|
||||||
JSResolverHelper* resolverHelper;
|
JSResolverHelper* resolverHelper;
|
||||||
|
QScopedPointer<FuzzyIndex> fuzzyIndex;
|
||||||
QPointer< AccountConfigWidget > configWidget;
|
QPointer< AccountConfigWidget > configWidget;
|
||||||
QList< QVariant > dataWidgets;
|
QList< QVariant > dataWidgets;
|
||||||
QStringList requiredScriptPaths;
|
QStringList requiredScriptPaths;
|
||||||
|
Reference in New Issue
Block a user