本文整理汇总了C++中tomahawk::result_ptr::setSize方法的典型用法代码示例。如果您正苦于以下问题:C++ result_ptr::setSize方法的具体用法?C++ result_ptr::setSize怎么用?C++ result_ptr::setSize使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类tomahawk::result_ptr
的用法示例。
在下文中一共展示了result_ptr::setSize方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: results
void
DatabaseCommand_Resolve::resolve( DatabaseImpl* lib )
{
QList<Tomahawk::result_ptr> res;
// STEP 1
QList< QPair<int, float> > tracks = lib->search( m_query );
if ( tracks.length() == 0 )
{
qDebug() << "No candidates found in first pass, aborting resolve" << m_query->queryTrack()->toString();
emit results( m_query->id(), res );
return;
}
// STEP 2
TomahawkSqlQuery files_query = lib->newquery();
QStringList trksl;
for ( int k = 0; k < tracks.count(); k++ )
trksl.append( QString::number( tracks.at( k ).first ) );
QString trksToken = QString( "file_join.track IN (%1)" ).arg( trksl.join( "," ) );
QString sql = QString( "SELECT "
"url, mtime, size, md5, mimetype, duration, bitrate, " //0
"file_join.artist, file_join.album, file_join.track, " //7
"file_join.composer, file_join.discnumber, " //10
"artist.name as artname, " //12
"album.name as albname, " //13
"track.name as trkname, " //14
"composer.name as cmpname, " //15
"file.source, " //16
"file_join.albumpos, " //17
"artist.id as artid, " //18
"album.id as albid, " //19
"composer.id as cmpid " //20
"FROM file, file_join, artist, track "
"LEFT JOIN album ON album.id = file_join.album "
"LEFT JOIN artist AS composer ON composer.id = file_join.composer "
"WHERE "
"artist.id = file_join.artist AND "
"track.id = file_join.track AND "
"file.id = file_join.file AND "
"(%1)" )
.arg( trksToken );
files_query.prepare( sql );
files_query.exec();
while ( files_query.next() )
{
QString url = files_query.value( 0 ).toString();
source_ptr s = SourceList::instance()->get( files_query.value( 16 ).toUInt() );
if ( !s )
{
tDebug() << "Could not find source" << files_query.value( 16 ).toUInt();
continue;
}
if ( !s->isLocal() )
url = QString( "servent://%1\t%2" ).arg( s->nodeId() ).arg( url );
Tomahawk::result_ptr result = Tomahawk::Result::getCached( url );
if ( result )
{
tDebug( LOGVERBOSE ) << "Result already cached:" << result->toString();
res << result;
continue;
}
track_ptr track = Track::get( files_query.value( 9 ).toUInt(), files_query.value( 12 ).toString(), files_query.value( 14 ).toString(), files_query.value( 13 ).toString(), files_query.value( 5 ).toUInt(), files_query.value( 15 ).toString(), files_query.value( 17 ).toUInt(), files_query.value( 11 ).toUInt() );
if ( !track )
continue;
track->loadAttributes();
result = Result::get( url, track );
if ( !result )
continue;
result->setModificationTime( files_query.value( 1 ).toUInt() );
result->setSize( files_query.value( 2 ).toUInt() );
result->setMimetype( files_query.value( 4 ).toString() );
result->setBitrate( files_query.value( 6 ).toUInt() );
result->setRID( uuid() );
result->setCollection( s->dbCollection() );
res << result;
}
emit results( m_query->id(), res );
}
示例2: tracks
void
DatabaseCommand_AllTracks::exec( DatabaseImpl* dbi )
{
TomahawkSqlQuery query = dbi->newquery();
QList<Tomahawk::query_ptr> ql;
QString m_orderToken, sourceToken;
switch ( m_sortOrder )
{
case 0:
break;
case Album:
m_orderToken = "album.name, file_join.albumpos";
break;
case ModificationTime:
m_orderToken = "file.mtime";
break;
case AlbumPosition:
m_orderToken = "file_join.albumpos";
break;
}
if ( !m_collection.isNull() )
sourceToken = QString( "AND file.source %1" ).arg( m_collection->source()->isLocal() ? "IS NULL" : QString( "= %1" ).arg( m_collection->source()->id() ) );
QString albumToken;
if ( m_album )
{
if ( m_album->id() == 0 )
{
m_artist = m_album->artist().data();
albumToken = QString( "AND album.id IS NULL" );
}
else
albumToken = QString( "AND album.id = %1" ).arg( m_album->id() );
}
QString sql = QString(
"SELECT file.id, artist.name, album.name, track.name, file.size, "
"file.duration, file.bitrate, file.url, file.source, file.mtime, file.mimetype, file_join.albumpos, artist.id, album.id, track.id "
"FROM file, artist, track, file_join "
"LEFT OUTER JOIN album "
"ON file_join.album = album.id "
"WHERE file.id = file_join.file "
"AND file_join.artist = artist.id "
"AND file_join.track = track.id "
"%1 "
"%2 %3 "
"%4 %5 %6"
).arg( sourceToken )
.arg( !m_artist ? QString() : QString( "AND artist.id = %1" ).arg( m_artist->id() ) )
.arg( !m_album ? QString() : albumToken )
.arg( m_sortOrder > 0 ? QString( "ORDER BY %1" ).arg( m_orderToken ) : QString() )
.arg( m_sortDescending ? "DESC" : QString() )
.arg( m_amount > 0 ? QString( "LIMIT 0, %1" ).arg( m_amount ) : QString() );
query.prepare( sql );
query.exec();
while( query.next() )
{
Tomahawk::source_ptr s;
QString url = query.value( 7 ).toString();
if ( query.value( 8 ).toUInt() == 0 )
{
s = SourceList::instance()->getLocal();
}
else
{
s = SourceList::instance()->get( query.value( 8 ).toUInt() );
if ( s.isNull() )
{
Q_ASSERT( false );
continue;
}
url = QString( "servent://%1\t%2" ).arg( s->userName() ).arg( url );
}
QString artist, track, album;
artist = query.value( 1 ).toString();
album = query.value( 2 ).toString();
track = query.value( 3 ).toString();
Tomahawk::result_ptr result = Tomahawk::Result::get( url );
Tomahawk::query_ptr qry = Tomahawk::Query::get( artist, track, album );
Tomahawk::artist_ptr artistptr = Tomahawk::Artist::get( query.value( 12 ).toUInt(), artist );
Tomahawk::album_ptr albumptr = Tomahawk::Album::get( query.value( 13 ).toUInt(), album, artistptr );
result->setTrackId( query.value( 14 ).toUInt() );
result->setArtist( artistptr );
result->setAlbum( albumptr );
result->setTrack( query.value( 3 ).toString() );
result->setSize( query.value( 4 ).toUInt() );
result->setDuration( query.value( 5 ).toUInt() );
result->setBitrate( query.value( 6 ).toUInt() );
//.........这里部分代码省略.........
示例3: tracks
void
DatabaseCommand_AllTracks::exec( DatabaseImpl* dbi )
{
TomahawkSqlQuery query = dbi->newquery();
QList<Tomahawk::query_ptr> ql;
QString m_orderToken, sourceToken;
switch ( m_sortOrder )
{
case 0:
break;
case Album:
m_orderToken = "album.name, file_join.discnumber, file_join.albumpos";
break;
case ModificationTime:
m_orderToken = "file.mtime";
break;
case AlbumPosition:
m_orderToken = "file_join.discnumber, file_join.albumpos";
break;
}
if ( !m_collection.isNull() )
sourceToken = QString( "AND file.source %1" ).arg( m_collection->source()->isLocal() ? "IS NULL" : QString( "= %1" ).arg( m_collection->source()->id() ) );
QString albumToken;
if ( m_album )
{
if ( m_album->id() == 0 )
{
m_artist = m_album->artist();
albumToken = QString( "AND album.id IS NULL" );
}
else
albumToken = QString( "AND album.id = %1" ).arg( m_album->id() );
}
QString sql = QString(
"SELECT file.id, artist.name, album.name, track.name, composer.name, file.size, " //0
"file.duration, file.bitrate, file.url, file.source, file.mtime, " //6
"file.mimetype, file_join.discnumber, file_join.albumpos, artist.id, " //11
"album.id, track.id, composer.id " //15
"FROM file, artist, track, file_join "
"LEFT OUTER JOIN album "
"ON file_join.album = album.id "
"LEFT OUTER JOIN artist AS composer "
"ON file_join.composer = composer.id "
"WHERE file.id = file_join.file "
"AND file_join.artist = artist.id "
"AND file_join.track = track.id "
"%1 "
"%2 %3 "
"%4 %5 %6"
).arg( sourceToken )
.arg( !m_artist ? QString() : QString( "AND artist.id = %1" ).arg( m_artist->id() ) )
.arg( !m_album ? QString() : albumToken )
.arg( m_sortOrder > 0 ? QString( "ORDER BY %1" ).arg( m_orderToken ) : QString() )
.arg( m_sortDescending ? "DESC" : QString() )
.arg( m_amount > 0 ? QString( "LIMIT 0, %1" ).arg( m_amount ) : QString() );
query.prepare( sql );
query.exec();
while( query.next() )
{
QString url = query.value( 8 ).toString();
Tomahawk::source_ptr s = SourceList::instance()->get( query.value( 9 ).toUInt() );
if ( !s )
{
Q_ASSERT( false );
continue;
}
if ( !s->isLocal() )
url = QString( "servent://%1\t%2" ).arg( s->nodeId() ).arg( url );
QString artist, track, album, composer;
artist = query.value( 1 ).toString();
album = query.value( 2 ).toString();
track = query.value( 3 ).toString();
composer = query.value( 4 ).toString();
Tomahawk::result_ptr result = Tomahawk::Result::get( url );
Tomahawk::query_ptr qry = Tomahawk::Query::get( artist, track, album );
Tomahawk::track_ptr t = Tomahawk::Track::get( query.value( 16 ).toUInt(), artist, track, album, query.value( 6 ).toUInt(), composer, query.value( 13 ).toUInt(), query.value( 12 ).toUInt() );
t->loadAttributes();
result->setTrack( t );
result->setSize( query.value( 5 ).toUInt() );
result->setBitrate( query.value( 7 ).toUInt() );
result->setModificationTime( query.value( 10 ).toUInt() );
result->setMimetype( query.value( 11 ).toString() );
result->setScore( 1.0 );
result->setCollection( s->dbCollection() );
QList<Tomahawk::result_ptr> results;
results << result;
//.........这里部分代码省略.........