1
0
mirror of https://github.com/tomahawk-player/tomahawk.git synced 2025-08-08 07:07:05 +02:00

Merge remote branch 'origin/master' into dynamic

This commit is contained in:
Leo Franchi
2011-02-06 15:34:53 -05:00
4 changed files with 34 additions and 28 deletions

View File

@@ -19,7 +19,7 @@ FuzzyIndex::FuzzyIndex( DatabaseImpl& db )
bool create = !lucene::index::IndexReader::indexExists( lucenePath.toStdString().c_str() ); bool create = !lucene::index::IndexReader::indexExists( lucenePath.toStdString().c_str() );
m_luceneDir = lucene::store::FSDirectory::getDirectory( lucenePath.toStdString().c_str(), create ); m_luceneDir = lucene::store::FSDirectory::getDirectory( lucenePath.toStdString().c_str(), create );
m_analyzer = new lucene::analysis::SimpleAnalyzer(); m_analyzer = _CLNEW lucene::analysis::SimpleAnalyzer();
} }
@@ -68,13 +68,13 @@ FuzzyIndex::appendFields( const QString& table, const QMap< unsigned int, QStrin
QString name = it.value(); QString name = it.value();
{ {
lucene::document::Field* field = new lucene::document::Field( table.toStdWString().c_str(), name.toStdWString().c_str(), lucene::document::Field* field = _CLNEW lucene::document::Field( table.toStdWString().c_str(), name.toStdWString().c_str(),
lucene::document::Field::STORE_YES | lucene::document::Field::INDEX_UNTOKENIZED ); lucene::document::Field::STORE_YES | lucene::document::Field::INDEX_UNTOKENIZED );
doc.add( *field ); doc.add( *field );
} }
{ {
lucene::document::Field* field = new lucene::document::Field( _T( "id" ), QString::number( id ).toStdWString().c_str(), lucene::document::Field* field = _CLNEW lucene::document::Field( _T( "id" ), QString::number( id ).toStdWString().c_str(),
lucene::document::Field::STORE_YES | lucene::document::Field::INDEX_NO ); lucene::document::Field::STORE_YES | lucene::document::Field::INDEX_NO );
doc.add( *field ); doc.add( *field );
} }
@@ -109,7 +109,7 @@ FuzzyIndex::search( const QString& table, const QString& name )
} }
m_luceneReader = lucene::index::IndexReader::open( m_luceneDir ); m_luceneReader = lucene::index::IndexReader::open( m_luceneDir );
m_luceneSearcher = new lucene::search::IndexSearcher( m_luceneReader ); m_luceneSearcher = _CLNEW lucene::search::IndexSearcher( m_luceneReader );
} }
if ( name.isEmpty() ) if ( name.isEmpty() )
@@ -119,8 +119,7 @@ FuzzyIndex::search( const QString& table, const QString& name )
lucene::queryParser::QueryParser parser( table.toStdWString().c_str(), m_analyzer ); lucene::queryParser::QueryParser parser( table.toStdWString().c_str(), m_analyzer );
lucene::search::Hits* hits = 0; lucene::search::Hits* hits = 0;
lucene::search::FuzzyQuery* qry = new lucene::search::FuzzyQuery( new lucene::index::Term( table.toStdWString().c_str(), lucene::search::FuzzyQuery* qry = _CLNEW lucene::search::FuzzyQuery( _CLNEW lucene::index::Term( table.toStdWString().c_str(), name.toStdWString().c_str() ) );
name.toStdWString().c_str() ) );
hits = m_luceneSearcher->search( qry ); hits = m_luceneSearcher->search( qry );
for ( unsigned int i = 0; i < hits->length(); i++ ) for ( unsigned int i = 0; i < hits->length(); i++ )

View File

@@ -85,7 +85,6 @@ Pipeline::resolve( const QList<query_ptr>& qlist, bool prioritized )
m_qids.insert( q->id(), q ); m_qids.insert( q->id(), q );
} }
} }
}
if ( prioritized ) if ( prioritized )
{ {
@@ -96,6 +95,7 @@ Pipeline::resolve( const QList<query_ptr>& qlist, bool prioritized )
{ {
m_queries_pending.append( qlist ); m_queries_pending.append( qlist );
} }
}
if ( m_index_ready && m_queries_pending.count() ) if ( m_index_ready && m_queries_pending.count() )
shuntNext(); shuntNext();
@@ -162,6 +162,11 @@ Pipeline::reportResults( QID qid, const QList< result_ptr >& results )
void void
Pipeline::shuntNext() Pipeline::shuntNext()
{ {
query_ptr q;
{
QMutexLocker lock( &m_mut );
if ( m_queries_pending.isEmpty() ) if ( m_queries_pending.isEmpty() )
{ {
emit idle(); emit idle();
@@ -172,9 +177,10 @@ Pipeline::shuntNext()
Since resolvers are async, we now dispatch to the highest weighted ones Since resolvers are async, we now dispatch to the highest weighted ones
and after timeout, dispatch to next highest etc, aborting when solved and after timeout, dispatch to next highest etc, aborting when solved
*/ */
q = m_queries_pending.takeFirst();
query_ptr q = m_queries_pending.takeFirst();
q->setLastPipelineWeight( 101 ); q->setLastPipelineWeight( 101 );
}
shunt( q ); // bump into next stage of pipeline (highest weights are 100) shunt( q ); // bump into next stage of pipeline (highest weights are 100)
} }

View File

@@ -8,7 +8,8 @@ using namespace Tomahawk;
Result::Result() {} Result::Result() {}
Result::Result( const QVariant& v, const collection_ptr& collection ) Result::Result( const QVariant& v, const collection_ptr& collection )
: m_v( v ) : QObject()
, m_v( v )
, m_collection( collection ) , m_collection( collection )
{ {
QVariantMap m = m_v.toMap(); QVariantMap m = m_v.toMap();

View File

@@ -27,7 +27,7 @@ WelcomeWidget::WelcomeWidget( QWidget* parent )
m_tracksModel = new PlaylistModel( ui->tracksView ); m_tracksModel = new PlaylistModel( ui->tracksView );
ui->tracksView->setModel( m_tracksModel ); ui->tracksView->setModel( m_tracksModel );
m_tracksModel->loadHistory( Tomahawk::source_ptr() ); m_tracksModel->loadHistory( Tomahawk::source_ptr(), 50 );
connect( SourceList::instance(), SIGNAL( sourceAdded( Tomahawk::source_ptr ) ), SLOT( onSourceAdded( Tomahawk::source_ptr ) ) ); connect( SourceList::instance(), SIGNAL( sourceAdded( Tomahawk::source_ptr ) ), SLOT( onSourceAdded( Tomahawk::source_ptr ) ) );