本文整理汇总了C++中tomahawk::query_ptr::queryTrack方法的典型用法代码示例。如果您正苦于以下问题:C++ query_ptr::queryTrack方法的具体用法?C++ query_ptr::queryTrack怎么用?C++ query_ptr::queryTrack使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类tomahawk::query_ptr
的用法示例。
在下文中一共展示了query_ptr::queryTrack方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: statusChanged
void
PipelineStatusItem::resolving( const Tomahawk::query_ptr& query )
{
if ( query->isFullTextQuery() )
m_latestQuery = query->fullTextQuery();
else
m_latestQuery = QString( "%1 - %2" ).arg( query->queryTrack()->artist() ).arg( query->queryTrack()->track() );
Q_ASSERT( !m_latestQuery.isEmpty() );
emit statusChanged();
}
示例2: catch
QMap< int, float >
FuzzyIndex::search( const Tomahawk::query_ptr& query )
{
// QMutexLocker lock( &m_mutex );
QMap< int, float > resultsmap;
if ( !m_luceneReader || !m_luceneSearcher )
return resultsmap;
try
{
// float minScore = 0.00;
Collection<String> fields; // = newCollection<String>();
MultiFieldQueryParserPtr parser = newLucene<MultiFieldQueryParser>( LuceneVersion::LUCENE_CURRENT, fields, m_analyzer );
BooleanQueryPtr qry = newLucene<BooleanQuery>();
if ( query->isFullTextQuery() )
{
const QString q = Tomahawk::DatabaseImpl::sortname( query->fullTextQuery() );
FuzzyQueryPtr fqry = newLucene<FuzzyQuery>( newLucene<Term>( L"track", q.toStdWString() ) );
qry->add( boost::dynamic_pointer_cast<Query>( fqry ), BooleanClause::SHOULD );
FuzzyQueryPtr fqry2 = newLucene<FuzzyQuery>( newLucene<Term>( L"artist", q.toStdWString() ) );
qry->add( boost::dynamic_pointer_cast<Query>( fqry2 ), BooleanClause::SHOULD );
FuzzyQueryPtr fqry3 = newLucene<FuzzyQuery>( newLucene<Term>( L"fulltext", q.toStdWString() ) );
qry->add( boost::dynamic_pointer_cast<Query>( fqry3 ), BooleanClause::SHOULD );
}
else
{
const QString track = Tomahawk::DatabaseImpl::sortname( query->queryTrack()->track() );
const QString artist = Tomahawk::DatabaseImpl::sortname( query->queryTrack()->artist() );
//QString album = Tomahawk::DatabaseImpl::sortname( query->queryTrack()->album() );
FuzzyQueryPtr fqry = newLucene<FuzzyQuery>( newLucene<Term>( L"track", track.toStdWString() ), 0.5, 3 );
qry->add( boost::dynamic_pointer_cast<Query>( fqry ), BooleanClause::MUST );
FuzzyQueryPtr fqry2 = newLucene<FuzzyQuery>( newLucene<Term>( L"artist", artist.toStdWString() ), 0.5, 3 );
qry->add( boost::dynamic_pointer_cast<Query>( fqry2 ), BooleanClause::MUST );
}
TopScoreDocCollectorPtr collector = TopScoreDocCollector::create( 20, true );
m_luceneSearcher->search( qry, collector );
Collection<ScoreDocPtr> hits = collector->topDocs()->scoreDocs;
for ( int i = 0; i < collector->getTotalHits() && i < 20; i++ )
{
DocumentPtr d = m_luceneSearcher->doc( hits[i]->doc );
const float score = hits[i]->score;
const int id = QString::fromStdWString( d->get( L"trackid" ) ).toInt();
// if ( score > minScore )
{
resultsmap.insert( id, score );
// tDebug() << "Index hit:" << id << score << QString::fromWCharArray( ((Query*)qry)->toString() );
}
}
}
catch( LuceneException& error )
{
tDebug() << "Caught Lucene error:" << QString::fromWCharArray( error.getError().c_str() ) << query->toString();
}
return resultsmap;
}
示例3: lock
QMap< int, float >
FuzzyIndex::search( const Tomahawk::query_ptr& query )
{
QMutexLocker lock( &m_mutex );
QMap< int, float > resultsmap;
try
{
if ( !m_luceneReader )
{
if ( !IndexReader::indexExists( m_luceneDir ) )
{
tDebug( LOGVERBOSE ) << Q_FUNC_INFO << "index didn't exist.";
return resultsmap;
}
m_luceneReader = IndexReader::open( m_luceneDir );
m_luceneSearcher = newLucene<IndexSearcher>( m_luceneReader );
}
float minScore;
Collection<String> fields; // = newCollection<String>();
MultiFieldQueryParserPtr parser = newLucene<MultiFieldQueryParser>( LuceneVersion::LUCENE_CURRENT, fields, m_analyzer );
BooleanQueryPtr qry = newLucene<BooleanQuery>();
if ( query->isFullTextQuery() )
{
QString q = Tomahawk::DatabaseImpl::sortname( query->fullTextQuery() );
FuzzyQueryPtr fqry = newLucene<FuzzyQuery>( newLucene<Term>( L"track", q.toStdWString() ) );
qry->add( boost::dynamic_pointer_cast<Query>( fqry ), BooleanClause::SHOULD );
FuzzyQueryPtr fqry2 = newLucene<FuzzyQuery>( newLucene<Term>( L"artist", q.toStdWString() ) );
qry->add( boost::dynamic_pointer_cast<Query>( fqry2 ), BooleanClause::SHOULD );
FuzzyQueryPtr fqry3 = newLucene<FuzzyQuery>( newLucene<Term>( L"fulltext", q.toStdWString() ) );
qry->add( boost::dynamic_pointer_cast<Query>( fqry3 ), BooleanClause::SHOULD );
minScore = 0.00;
}
else
{
QString track = Tomahawk::DatabaseImpl::sortname( query->queryTrack()->track() );
QString artist = Tomahawk::DatabaseImpl::sortname( query->queryTrack()->artist() );
//QString album = Tomahawk::DatabaseImpl::sortname( query->queryTrack()->album() );
FuzzyQueryPtr fqry = newLucene<FuzzyQuery>( newLucene<Term>( L"track", track.toStdWString() ) );
qry->add( boost::dynamic_pointer_cast<Query>( fqry ), BooleanClause::MUST );
FuzzyQueryPtr fqry2 = newLucene<FuzzyQuery>( newLucene<Term>( L"artist", artist.toStdWString() ) );
qry->add( boost::dynamic_pointer_cast<Query>( fqry2 ), BooleanClause::MUST );
minScore = 0.00;
}
TopScoreDocCollectorPtr collector = TopScoreDocCollector::create( 50, false );
m_luceneSearcher->search( qry, collector );
Collection<ScoreDocPtr> hits = collector->topDocs()->scoreDocs;
for ( int i = 0; i < collector->getTotalHits() && i < 50; i++ )
{
DocumentPtr d = m_luceneSearcher->doc( hits[i]->doc );
float score = hits[i]->score;
int id = QString::fromStdWString( d->get( L"trackid" ) ).toInt();
if ( score > minScore )
{
resultsmap.insert( id, score );
// tDebug() << "Index hit:" << id << score << QString::fromWCharArray( ((Query*)qry)->toString() );
}
}
}
catch( LuceneException& error )
{
tDebug() << "Caught Lucene error:" << error.what() << query->toString();
QTimer::singleShot( 0, this, SLOT( wipeIndex() ) );
}
return resultsmap;
}
示例4: ErrorStatusMessage
void
AudioEngine::playItem( Tomahawk::playlistinterface_ptr playlist, const Tomahawk::query_ptr& query )
{
if ( query->resolvingFinished() )
{
if ( query->numResults() && query->results().first()->isOnline() )
{
playItem( playlist, query->results().first(), query );
return;
}
JobStatusView::instance()->model()->addJob(
new ErrorStatusMessage( tr( "Sorry, Tomahawk couldn't find the track '%1' by %2" ).arg( query->queryTrack()->track() ).arg( query->queryTrack()->artist() ), 15 ) );
if ( isStopped() )
emit stopped(); // we do this so the original caller knows we couldn't find this track
}
else
{
Pipeline::instance()->resolve( query );
NewClosure( query.data(), SIGNAL( resolvingFinished( bool ) ),
const_cast<AudioEngine*>(this), SLOT( playItem( Tomahawk::playlistinterface_ptr, Tomahawk::query_ptr ) ), playlist, query );
}
}