本文整理汇总了C++中MediaQuery::addSubQuery方法的典型用法代码示例。如果您正苦于以下问题:C++ MediaQuery::addSubQuery方法的具体用法?C++ MediaQuery::addSubQuery怎么用?C++ MediaQuery::addSubQuery使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MediaQuery
的用法示例。
在下文中一共展示了MediaQuery::addSubQuery方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: run
//.........这里部分代码省略.........
order.append(MediaQuery::Descending);
query.orderBy(orderByBindings, order);
} else {
QStringList bindings;
//NOTE:query.addLRIFilterConditions will automatically add
//the groupBy field name to the binding list.
QString groupByResourceBinding = MediaVocabulary::resourceBindingForCategory(groupByCategoryType);
if (!groupByResourceBinding.isEmpty()) {
bindings.append(groupByResourceBinding);
}
bindings.append(query.fieldBindingDictionary[groupByField]);
bindings.append(MediaQuery::aggregateBinding(mediaVocabulary.playCountBinding(), MediaQuery::Sum));
query.select(bindings, MediaQuery::Distinct);
query.startWhere();
MediaQuery subQuery;
QStringList subBindings;
subBindings.append(mediaVocabulary.playCountBinding());
subBindings.append(mediaVocabulary.mediaResourceBinding());
subQuery.select(subBindings, MediaQuery::Distinct);
subQuery.startWhere();
if (mediaType == "audio") {
subQuery.addCondition(mediaVocabulary.hasTypeAnyAudio(MediaQuery::Required));
} else if (mediaType == "video") {
subQuery.addCondition(mediaVocabulary.hasTypeAnyVideo(MediaQuery::Required));
}
if (m_mediaListProperties.filterForField("playCount").isEmpty()) {
subQuery.addCondition(mediaVocabulary.hasPlayCount(MediaQuery::Required, 0, MediaQuery::GreaterThan));
ignoreZeros = true;
}
QStringList subQueryLRIFilterList = engineFilterList;
subQueryLRIFilterList.removeAll(limitFilter);
subQuery.addLRIFilterConditions(subQueryLRIFilterList, mediaVocabulary);
subQuery.endWhere();
query.addSubQuery(subQuery);
query.endWhere();
query.addLRIFilterCondition(limitFilter, mediaVocabulary);
QStringList orderByBindings;
QList<MediaQuery::Order> order;
orderByBindings.append(QString("%1_sum").arg(mediaVocabulary.playCountBinding()));
order.append(MediaQuery::Descending);
query.orderBy(orderByBindings, order);
}
Soprano::QueryResultIterator it = query.executeSelect(m_mainModel);
//Build media list from results
while( it.next() ) {
if (m_stop) {
return;
}
MediaItem mediaItem;
if (groupByCategoryType.isEmpty()) {
Nepomuk::Resource res = Nepomuk::Resource(it.binding(mediaVocabulary.mediaResourceBinding()).uri());
mediaItem = Utilities::mediaItemFromNepomuk(res, m_mediaListProperties.lri);
mediaItem.semanticComment = i18np("played once", "played %1 times", mediaItem.fields["playCount"].toInt());
} else {
mediaItem = Utilities::categoryMediaItemFromIterator(it, groupByCategoryType, m_mediaListProperties.lri);
int playCount = it.binding(QString("%1_sum").arg(mediaVocabulary.playCountBinding())).literal().toInt();
mediaItem.semanticComment = i18np("played once", "played %1 times", playCount);
mediaItem.fields["playCount"] = playCount;
}
if (!mediaItem.url.startsWith("nepomuk:/")) {
if ((ignoreZeros && mediaItem.fields["playCount"].toInt() > 0) ||
!ignoreZeros) {
if (groupByCategoryType == "AudioGenre") {
addUniqueGenreGroup("playCount", mediaItem, &mediaList, originalGenreLimit);