本文整理汇总了C++中TomahawkSqlQuery::first方法的典型用法代码示例。如果您正苦于以下问题:C++ TomahawkSqlQuery::first方法的具体用法?C++ TomahawkSqlQuery::first怎么用?C++ TomahawkSqlQuery::first使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TomahawkSqlQuery
的用法示例。
在下文中一共展示了TomahawkSqlQuery::first方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: generateEntries
void
DatabaseCommand_LoadDynamicPlaylistEntries::exec( DatabaseImpl* dbi )
{
// qDebug() << "Loading dynamic playlist guid" << guid();
// load the entries first
generateEntries( dbi );
// now load the controls etc
TomahawkSqlQuery controlsQuery = dbi->newquery();
controlsQuery.prepare("SELECT playlist_revision.playlist, controls, plmode, pltype "
"FROM dynamic_playlist_revision, playlist_revision "
"WHERE dynamic_playlist_revision.guid = ? AND playlist_revision.guid = dynamic_playlist_revision.guid");
controlsQuery.addBindValue( revisionGuid() );
controlsQuery.exec();
QString type;
GeneratorMode mode;
QList< QVariantMap > controls;
QString playlist_guid;
// qDebug() << "Loading controls..." << revisionGuid();
// qDebug() << "SELECT playlist_revision.playlist, controls, plmode, pltype "
// "FROM dynamic_playlist_revision, playlist_revision "
// "WHERE dynamic_playlist_revision.guid = "<< revisionGuid() << " AND playlist_revision.guid = dynamic_playlist_revision.guid";
if( controlsQuery.first() )
{
playlist_guid = controlsQuery.value( 0 ).toString();
QJson::Parser parser;
bool ok;
QVariant v = parser.parse( controlsQuery.value(1).toByteArray(), &ok );
Q_ASSERT( ok && v.type() == QVariant::List ); //TODO
type = controlsQuery.value( 3 ).toString();
mode = static_cast<GeneratorMode>( controlsQuery.value( 2 ).toInt() );
QStringList controlIds = v.toStringList();
// qDebug() << "Got controls in dynamic playlist, loading:" << controlIds << controlsQuery.value(1);
foreach( const QString& controlId, controlIds )
{
TomahawkSqlQuery controlQuery = dbi->newquery();
controlQuery.prepare( "SELECT selectedType, match, input "
"FROM dynamic_playlist_controls "
"WHERE id = :id" );
controlQuery.bindValue( ":id", controlId );
controlQuery.exec();
if( controlQuery.next() )
{
QVariantMap c;
c[ "type" ] = type;
c[ "id" ] = controlId;
c[ "selectedType" ] = controlQuery.value( 0 ).toString();
c[ "match" ] = controlQuery.value( 1 ).toString();
c[ "input" ] = controlQuery.value( 2 ).toString();
controls << c;
}
}