本文整理汇总了C++中tomahawk::query_ptr类的典型用法代码示例。如果您正苦于以下问题:C++ query_ptr类的具体用法?C++ query_ptr怎么用?C++ query_ptr使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了query_ptr类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: connect
void
DynamicModel::newTrackGenerated( const Tomahawk::query_ptr& query )
{
if ( m_onDemandRunning )
{
bool isDuplicate = false;
for ( int i = 0; i < m_deduper.size(); i++ )
{
if ( m_deduper[ i ].first == query->track()->track() && m_deduper[ i ].second == query->track()->artist() )
isDuplicate = true;
}
if ( isDuplicate )
{
m_playlist->generator()->fetchNext();
return;
}
else
{
m_deduper.append( QPair< QString, QString >( query->track()->track(), query->track()->artist() ) );
}
connect( query.data(), SIGNAL( resolvingFinished( bool ) ), this, SLOT( trackResolveFinished( bool ) ) );
m_waitingFor << query.data();
appendQuery( query );
}
}
示例2: trackPlayed
void
DatabaseCommand_LogPlayback::postCommitHook()
{
connect( this, SIGNAL( trackPlaying( Tomahawk::query_ptr ) ),
source().data(), SLOT( onPlaybackStarted( Tomahawk::query_ptr ) ), Qt::QueuedConnection );
connect( this, SIGNAL( trackPlayed( Tomahawk::query_ptr ) ),
source().data(), SLOT( onPlaybackFinished( Tomahawk::query_ptr ) ), Qt::QueuedConnection );
Tomahawk::query_ptr q;
if ( !m_result.isNull() )
{
q = m_result->toQuery();
}
else
{
// do not auto resolve this track
q = Tomahawk::Query::get( m_artist, m_track, QString() );
}
q->setPlayedBy( source(), m_playtime );
if ( m_action == Finished )
{
emit trackPlayed( q );
}
// if the play time is more than 10 minutes in the past, ignore
else if ( m_action == Started && QDateTime::fromTime_t( playtime() ).secsTo( QDateTime::currentDateTime() ) < STARTED_THRESHOLD )
{
emit trackPlaying( q );
}
if ( source()->isLocal() )
{
Servent::instance()->triggerDBSync();
}
}
示例3: f
void
M3uLoader::getTags( const QFileInfo& info )
{
QByteArray fileName = QFile::encodeName( info.canonicalFilePath() );
const char *encodedName = fileName.constData();
TagLib::FileRef f( encodedName );
TagLib::Tag *tag = f.tag();
QString artist = TStringToQString( tag->artist() ).trimmed();
QString album = TStringToQString( tag->album() ).trimmed();
QString track = TStringToQString( tag->title() ).trimmed();
if ( artist.isEmpty() || track.isEmpty() )
{
qDebug() << "Error parsing" << info.fileName();
return;
}
else
{
qDebug() << Q_FUNC_INFO << artist << track << album;
Tomahawk::query_ptr q = Tomahawk::Query::get( artist, track, album, uuid(), !m_createNewPlaylist );
if ( !q.isNull() )
m_tracks << q;
}
}
示例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() );
return;
}
JobStatusView::instance()->model()->addJob(
new ErrorStatusMessage( tr( "Sorry, Tomahawk couldn't find the track '%1' by %2" ).arg( query->track() ).arg( query->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 );
}
}
示例5: connect
void
TrackModelItem::setupItem( const Tomahawk::query_ptr& query, TrackModelItem* parent, int row )
{
this->parent = parent;
if ( parent )
{
if ( row < 0 )
{
parent->children.append( this );
row = parent->children.count() - 1;
}
else
{
parent->children.insert( row, this );
}
this->model = parent->model;
}
m_isPlaying = false;
toberemoved = false;
m_query = query;
if ( !query->numResults() )
{
connect( query.data(), SIGNAL( resultsAdded( QList<Tomahawk::result_ptr> ) ),
SIGNAL( dataChanged() ) );
connect( query.data(), SIGNAL( resultsRemoved( Tomahawk::result_ptr ) ),
SIGNAL( dataChanged() ) );
connect( query.data(), SIGNAL( resultsChanged() ),
SIGNAL( dataChanged() ) );
}
}
示例6: QObject
TreeModelItem::TreeModelItem( const Tomahawk::query_ptr& query, TreeModelItem* parent, int row )
: QObject( parent )
, m_query( query )
{
this->parent = parent;
fetchingMore = false;
m_isPlaying = false;
if ( parent )
{
if ( row < 0 )
{
parent->children.append( this );
row = parent->children.count() - 1;
}
else
{
parent->children.insert( row, this );
}
this->model = parent->model;
}
toberemoved = false;
onResultsChanged();
connect( query.data(), SIGNAL( resultsAdded( QList<Tomahawk::result_ptr> ) ),
SLOT( onResultsChanged() ) );
connect( query.data(), SIGNAL( resultsRemoved( Tomahawk::result_ptr ) ),
SLOT( onResultsChanged() ) );
connect( query.data(), SIGNAL( resultsChanged() ),
SLOT( onResultsChanged() ) );
}
示例7: tracks
void
DatabaseCommand_PlaybackHistory::exec( DatabaseImpl* dbi )
{
TomahawkSqlQuery query = dbi->newquery();
QList<Tomahawk::query_ptr> ql;
QString whereToken;
if ( !source().isNull() )
{
whereToken = QString( "WHERE source %1" ).arg( source()->isLocal() ? "IS NULL" : QString( "= %1" ).arg( source()->id() ) );
}
QString sql = QString(
"SELECT track, playtime, secs_played, source "
"FROM playback_log "
"%1 "
"ORDER BY playtime DESC "
"%2" ).arg( whereToken )
.arg( m_amount > 0 ? QString( "LIMIT 0, %1" ).arg( m_amount ) : QString() );
query.prepare( sql );
query.exec();
while( query.next() )
{
TomahawkSqlQuery query_track = dbi->newquery();
QString sql = QString(
"SELECT track.name, artist.name "
"FROM track, artist "
"WHERE artist.id = track.artist "
"AND track.id = %1"
).arg( query.value( 0 ).toUInt() );
query_track.prepare( sql );
query_track.exec();
if ( query_track.next() )
{
Tomahawk::query_ptr q = Tomahawk::Query::get( query_track.value( 1 ).toString(), query_track.value( 0 ).toString(), QString() );
if ( query.value( 3 ).toUInt() == 0 )
{
q->setPlayedBy( SourceList::instance()->getLocal(), query.value( 1 ).toUInt() );
}
else
{
q->setPlayedBy( SourceList::instance()->get( query.value( 3 ).toUInt() ), query.value( 1 ).toUInt() );
}
ql << q;
}
}
if ( ql.count() )
emit tracks( ql );
}
示例8: connect
void
DynamicModel::newTrackGenerated( const Tomahawk::query_ptr& query )
{
if( m_onDemandRunning ) {
connect( query.data(), SIGNAL( resolvingFinished( bool ) ), this, SLOT( trackResolveFinished( bool ) ) );
m_waitingFor << query.data();
append( query );
}
}
示例9:
void
PlaylistModel::append( const Tomahawk::query_ptr& query )
{
if ( query.isNull() )
return;
if ( !query->resolvingFinished() )
Pipeline::instance()->resolve( query );
TrackModel::append( query );
}
示例10: 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();
}
示例11: lock
QMap< int, float >
FuzzyIndex::searchAlbum( const Tomahawk::query_ptr& query )
{
Q_ASSERT( query->isFullTextQuery() );
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 );
}
QueryParserPtr parser = newLucene<QueryParser>( LuceneVersion::LUCENE_CURRENT, L"album", m_analyzer );
QString q = Tomahawk::DatabaseImpl::sortname( query->fullTextQuery() );
FuzzyQueryPtr qry = newLucene<FuzzyQuery>( newLucene<Term>( L"album", q.toStdWString() ) );
TopScoreDocCollectorPtr collector = TopScoreDocCollector::create( 99999, false );
m_luceneSearcher->search( boost::dynamic_pointer_cast<Query>( qry ), collector );
Collection<ScoreDocPtr> hits = collector->topDocs()->scoreDocs;
for ( int i = 0; i < collector->getTotalHits(); i++ )
{
DocumentPtr d = m_luceneSearcher->doc( hits[i]->doc );
float score = hits[i]->score;
int id = QString::fromStdWString( d->get( L"albumid" ) ).toInt();
if ( score > 0.30 )
{
resultsmap.insert( id, score );
// tDebug() << "Index hit:" << id << score;
}
}
}
catch( LuceneException& error )
{
tDebug() << "Caught Lucene error:" << error.what();
QTimer::singleShot( 0, this, SLOT( wipeIndex() ) );
}
return resultsmap;
}
示例12: QObject
PlayableItem::PlayableItem( const Tomahawk::query_ptr& query, PlayableItem* parent, int row )
: QObject( parent )
, m_query( query )
{
init( parent, row );
connect( query->track().data(), SIGNAL( socialActionsLoaded() ),
SIGNAL( dataChanged() ) );
connect( query->track().data(), SIGNAL( updated() ),
SIGNAL( dataChanged() ) );
connect( query.data(), SIGNAL( resultsChanged() ),
SLOT( onResultsChanged() ) );
}
示例13: stream
void
SourceTreeView::dropEvent( QDropEvent* event )
{
bool accept = false;
const QPoint pos = event->pos();
const QModelIndex index = indexAt( pos );
if ( event->mimeData()->hasFormat( "application/tomahawk.query.list" ) )
{
const QPoint pos = event->pos();
const QModelIndex index = indexAt( pos );
if ( index.isValid() )
{
if ( SourcesModel::indexType( index ) == SourcesModel::PlaylistSource )
{
playlist_ptr playlist = SourcesModel::indexToPlaylist( index );
if ( !playlist.isNull() && playlist->author()->isLocal() )
{
accept = true;
QByteArray itemData = event->mimeData()->data( "application/tomahawk.query.list" );
QDataStream stream( &itemData, QIODevice::ReadOnly );
QList<Tomahawk::query_ptr> queries;
while ( !stream.atEnd() )
{
qlonglong qptr;
stream >> qptr;
Tomahawk::query_ptr* query = reinterpret_cast<Tomahawk::query_ptr*>(qptr);
if ( query && !query->isNull() )
{
qDebug() << "Dropped query item:" << query->data()->artist() << "-" << query->data()->track();
queries << *query;
}
}
qDebug() << "on playlist:" << playlist->title() << playlist->guid();
SourceTreeItem* treeItem = SourcesModel::indexToTreeItem( index );
if ( treeItem )
{
QString rev = treeItem->currentlyLoadedPlaylistRevision( playlist->guid() );
playlist->addEntries( queries, rev );
}
}
}
}
示例14: if
void
AudioEngine::playItem( Tomahawk::playlistinterface_ptr playlist, const Tomahawk::result_ptr& result, const Tomahawk::query_ptr& fromQuery )
{
tDebug( LOGEXTRA ) << Q_FUNC_INFO << ( result.isNull() ? QString() : result->url() );
if ( !m_playlist.isNull() )
m_playlist.data()->reset();
setPlaylist( playlist );
if ( playlist.isNull() && !fromQuery.isNull() )
m_currentTrackPlaylist = playlistinterface_ptr( new SingleTrackPlaylistInterface( fromQuery ) );
else
m_currentTrackPlaylist = playlist;
if ( !result.isNull() )
{
loadTrack( result );
}
else if ( !m_playlist.isNull() && m_playlist.data()->retryMode() == PlaylistModes::Retry )
{
m_waitingOnNewTrack = true;
if ( isStopped() )
emit sendWaitingNotification();
else
stop();
}
}
示例15: playbackStarted
void
Source::onPlaybackStarted( const Tomahawk::query_ptr& query )
{
qDebug() << Q_FUNC_INFO << query->toString();
m_currentTrack = query;
emit playbackStarted( query );
}