本文整理汇总了C++中MediaQuery类的典型用法代码示例。如果您正苦于以下问题:C++ MediaQuery类的具体用法?C++ MediaQuery怎么用?C++ MediaQuery使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了MediaQuery类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: eval
bool MediaQueryEvaluator::eval(const MediaQuerySet* querySet, MediaQueryResultList* viewportDependentMediaQueryResults) const
{
if (!querySet)
return true;
const WillBeHeapVector<OwnPtrWillBeMember<MediaQuery> >& queries = querySet->queryVector();
if (!queries.size())
return true; // Empty query list evaluates to true.
// Iterate over queries, stop if any of them eval to true (OR semantics).
bool result = false;
for (size_t i = 0; i < queries.size() && !result; ++i) {
MediaQuery* query = queries[i].get();
if (mediaTypeMatch(query->mediaType())) {
const ExpressionHeapVector& expressions = query->expressions();
// Iterate through expressions, stop if any of them eval to false (AND semantics).
size_t j = 0;
for (; j < expressions.size(); ++j) {
bool exprResult = eval(expressions.at(j).get());
if (viewportDependentMediaQueryResults && expressions.at(j)->isViewportDependent())
viewportDependentMediaQueryResults->append(adoptRefWillBeNoop(new MediaQueryResult(*expressions.at(j), exprResult)));
if (!exprResult)
break;
}
// Assume true if we are at the end of the list, otherwise assume false.
result = applyRestrictor(query->restrictor(), expressions.size() == j);
} else {
result = applyRestrictor(query->restrictor(), false);
}
}
return result;
}
示例2: eval
bool MediaQueryEvaluator::eval(const MediaListImpl* mediaList, CSSStyleSelector* styleSelector) const
{
if (!mediaList)
return true;
const QList<MediaQuery*>* queries = mediaList->mediaQueries();
if (!queries->size())
return true; // empty query list evaluates to true
// iterate over queries, stop if any of them eval to true (OR semantics)
bool result = false;
for (int i = 0; i < queries->size() && !result; ++i) {
MediaQuery* query = queries->at(i);
if (mediaTypeMatch(query->mediaType())) {
const QList<MediaQueryExp*>* exps = query->expressions();
// iterate through expressions, stop if any of them eval to false
// (AND semantics)
int j = 0;
for (; j < exps->size(); ++j) {
bool exprResult = eval(exps->at(j));
if (styleSelector && exps->at(j)->isViewportDependent())
styleSelector->addViewportDependentMediaQueryResult(exps->at(j), exprResult);
if (!exprResult)
break;
}
// assume true if we are at the end of the list,
// otherwise assume false
result = applyRestrictor(query->restrictor(), exps->size() == j);
} else
result = applyRestrictor(query->restrictor(), false);
}
return result;
}
示例3: eval
bool MediaQueryEvaluator::eval(const MediaList* mediaList) const
{
if (!mediaList)
return true;
const Vector<MediaQuery*>* queries = mediaList->mediaQueries();
if (!queries->size())
return true; // empty query list evaluates to true
// iterate over queries, stop if any of them eval to true (OR semantics)
bool result = false;
for (size_t i = 0; i < queries->size() && !result; ++i) {
MediaQuery* query = queries->at(i);
if (mediaTypeMatch(query->mediaType())) {
const Vector<MediaQueryExp*>* exps = query->expressions();
// iterate through expressions, stop if any of them eval to false
// (AND semantics)
size_t j = 0;
for (; j < exps->size() && eval(exps->at(j)); ++j) /* empty*/;
// assume true if we are at the end of the list,
// otherwise assume false
result = applyRestrictor(query->restrictor(), exps->size() == j);
} else
result = applyRestrictor(query->restrictor(), false);
}
return result;
}
示例4: process
void LessMediaQuery::process(Stylesheet &s) {
MediaQuery* query = s.createMediaQuery();
query->setSelector(*getSelector());
getContext()->processValue(query->getSelector());
LessStylesheet::process(*query, *parent->getContext());
}
示例5: item
String MediaList::item(unsigned index) const
{
if (index < m_queries.size()) {
MediaQuery* query = m_queries[index];
return query->cssText();
}
return String();
}
示例6: eval
bool MediaQueryEvaluator::evalCheckingViewportDependentResults(const MediaQuerySet* querySet, Vector<std::unique_ptr<MediaQueryResult>>& results)
{
if (!querySet)
return true;
auto& queries = querySet->queryVector();
if (!queries.size())
return true;
bool result = false;
for (size_t i = 0; i < queries.size() && !result; ++i) {
MediaQuery* query = queries[i].get();
if (query->ignored())
continue;
if (mediaTypeMatch(query->mediaType())) {
auto& expressions = query->expressions();
size_t j = 0;
for (; j < expressions.size(); ++j) {
bool exprResult = eval(expressions.at(j).get());
if (expressions.at(j)->isViewportDependent())
results.append(std::make_unique<MediaQueryResult>(*expressions.at(j), exprResult));
if (!exprResult)
break;
}
result = applyRestrictor(query->restrictor(), expressions.size() == j);
} else
result = applyRestrictor(query->restrictor(), false);
}
return result;
}
示例7: VLOG
void MediaQueryRuleset::process(Stylesheet &s, Selector* prefix, ProcessingContext &context) {
MediaQuery* query;
Ruleset* target;
Selector selector;
#ifdef WITH_LIBGLOG
VLOG(2) << "Processing Less Ruleset: " <<
getSelector().toString();
#endif
query = s.createMediaQuery();
selector = getSelector();
context.interpolate(selector);
if (query->getSelector().size() > 0) {
selector.pop_front();
query->getSelector().push_back(Token(" ", Token::WHITESPACE));
query->getSelector().push_back(Token("and", Token::IDENTIFIER));
query->getSelector().insert(query->getSelector().end(),
selector.begin(),
selector.end());
} else
query->setSelector(selector);
if (prefix != NULL) {
target = query->createRuleset();
target->setSelector(*prefix);
#ifdef WITH_LIBGLOG
VLOG(3) << "Interpolating selector " <<
target->getSelector().toString();
#endif
context.interpolate(target->getSelector());
insert(NULL, *target, context);
} else
insert(NULL, *query, context);
}
示例8: QString
//.........这里部分代码省略.........
Nepomuk2::Variant value = resource.property(property);
if (value.toResource().hasType(Nepomuk2::Vocabulary::NFO::Image())) {
resource.removeProperty(property);
resource.setProperty(mediaVocabulary.artwork(), value);
}
}
property = QUrl("http://www.semanticdesktop.org/ontologies/nmm#genre");
if (resource.hasProperty(property)) {
Nepomuk2::Variant value = resource.property(property);
resource.removeProperty(property);
resource.setProperty(mediaVocabulary.genre(), value);
}
property = QUrl("http://www.semanticdesktop.org/ontologies/nmm#releaseDate");
if (resource.hasProperty(property)) {
Nepomuk2::Variant value = resource.property(property);
resource.removeProperty(property);
resource.setProperty(mediaVocabulary.releaseDate(), value);
}
property = Soprano::Vocabulary::Xesam::useCount();
if (resource.hasProperty(property)) {
Nepomuk2::Variant value = resource.property(property);
resource.removeProperty(property);
resource.setProperty(mediaVocabulary.playCount(), value);
}
property = Soprano::Vocabulary::Xesam::lastUsed();
if (resource.hasProperty(property)) {
Nepomuk2::Variant value = resource.property(property);
resource.removeProperty(property);
resource.setProperty(mediaVocabulary.lastPlayed(), value);
}
emit infoMessage(i18n("<b>Updating video types and properties</b><br>%1 video items done...", i));
QApplication::processEvents();
}
//Fix screwed up properties
MediaQuery query;
QStringList bindings;
bindings.append(mediaVocabulary.mediaResourceBinding());
bindings.append(mediaVocabulary.ratingBinding());
query.select(bindings, MediaQuery::Distinct);
query.startWhere();
query.addCondition(mediaVocabulary.hasTypeAnyAudio(MediaQuery::Required));
query.addCondition(mediaVocabulary.hasRating(MediaQuery::Required, 10, MediaQuery::GreaterThan));
query.endWhere();
it = m_mainModel->executeQuery(query.query(), Soprano::Query::QueryLanguageSparql);
emit infoMessage(i18n("<b>Updating audio types and properties</b><br>0 items updated..."));
QApplication::processEvents();
i = 0;
while( it.next() && !m_stopUpdate) {
QApplication::processEvents();
i++;
Nepomuk2::Resource resource = Nepomuk2::Resource(it.binding("r").uri());
QUrl property = QUrl("http://www.semanticdesktop.org/ontologies/2007/08/15/nao#numericRating");
if (resource.hasProperty(property)) {
int rating = resource.property(property).toInt();
if (rating > 10) {
resource.removeProperty(property);
}
}
emit infoMessage(i18n("<b>Cleaning up erroneous audio properties</b><br>%1 audio items done...", i));
QApplication::processEvents();
}
MediaQuery query1;
bindings.clear();
bindings.append(mediaVocabulary.mediaResourceBinding());
bindings.append(mediaVocabulary.ratingBinding());
query1.select(bindings, MediaQuery::Distinct);
query1.startWhere();
query1.addCondition(mediaVocabulary.hasTypeAnyVideo(MediaQuery::Required));
query1.addCondition(mediaVocabulary.hasRating(MediaQuery::Required, 10, MediaQuery::GreaterThan));
query1.endWhere();
it = m_mainModel->executeQuery(query.query(), Soprano::Query::QueryLanguageSparql);
emit infoMessage(i18n("<b>Updating audio types and properties</b><br>0 items updated..."));
QApplication::processEvents();
i = 0;
while( it.next() && !m_stopUpdate) {
QApplication::processEvents();
i++;
Nepomuk2::Resource resource = Nepomuk2::Resource(it.binding("r").uri());
QUrl property = QUrl("http://www.semanticdesktop.org/ontologies/2007/08/15/nao#numericRating");
if (resource.hasProperty(property)) {
int rating = resource.property(property).toInt();
if (rating > 10) {
resource.removeProperty(property);
}
}
emit infoMessage(i18n("<b>Cleaning up erroneous video properties</b><br>%1 video items done...", i));
QApplication::processEvents();
}
if (!m_stopUpdate) {
emit infoMessage(i18n("<b>Update complete.</b>"));
} else {
emit infoMessage(i18n("<b>Update stopped.</b>"));
}
emit done();
}
示例9: MediaVocabulary
void AudioStreamListEngine::run()
{
QThread::setTerminationEnabled(true);
m_stop = false;
if (m_updateSourceInfo || m_removeSourceInfo) {
NepomukListEngine::run();
return;
}
//Create media list based on engine argument and filter
QList<MediaItem> mediaList;
MediaVocabulary mediaVocabulary = MediaVocabulary();
QString engineArg = m_mediaListProperties.engineArg();
QString engineFilter = m_mediaListProperties.engineFilter();
if (m_nepomukInited) {
if (engineArg.isEmpty()) {
MediaQuery query;
QStringList bindings;
bindings.append(mediaVocabulary.mediaResourceBinding());
bindings.append(mediaVocabulary.mediaResourceUrlBinding());
bindings.append(mediaVocabulary.titleBinding());
bindings.append(mediaVocabulary.ratingBinding());
bindings.append(mediaVocabulary.descriptionBinding());
bindings.append(mediaVocabulary.artworkBinding());
//bindings.append(mediaVocabulary.genreBinding());
query.select(bindings, MediaQuery::Distinct);
query.startWhere();
query.addCondition(mediaVocabulary.hasTypeAudioStream(MediaQuery::Required));
query.addCondition(mediaVocabulary.hasTitle(MediaQuery::Required));
query.addCondition(mediaVocabulary.hasRating(MediaQuery::Optional));
query.addCondition(mediaVocabulary.hasDescription(MediaQuery::Optional));
query.addCondition(mediaVocabulary.hasArtwork(MediaQuery::Optional));
query.endWhere();
QStringList orderByBindings;
orderByBindings.append(mediaVocabulary.titleBinding());
query.orderBy(orderByBindings);
Soprano::QueryResultIterator it = query.executeSelect(m_mainModel);
//Build media list from results
while( it.next() ) {
if (m_stop) {
return;
}
MediaItem mediaItem = Utilities::mediaItemFromIterator(it, QString("Audio Stream"), m_mediaListProperties.lri);
if (!mediaItem.url.startsWith(QLatin1String("nepomuk:/"))) {
mediaList.append(mediaItem);
}
}
m_mediaListProperties.summary = i18np("1 stream", "%1 streams", mediaList.count());
MediaItem mediaItem;
mediaItem.type = "Audio";
mediaItem.url.clear();
mediaItem.title = i18n("New Audio Stream");
mediaItem.subTitle = i18n("Edit info to create new audio stream");
mediaItem.artwork = KIcon("text-html");
mediaItem.fields["title"] = i18n("Untitled");
mediaItem.fields["audioType"] = "Audio Stream";
mediaItem.fields["isTemplate"] = true;
mediaList.append(mediaItem);
m_mediaListProperties.type = QString("Sources");
} else if (engineArg.toLower() == "search") {
MediaQuery query;
QStringList bindings;
bindings.append(mediaVocabulary.mediaResourceBinding());
bindings.append(mediaVocabulary.mediaResourceUrlBinding());
bindings.append(mediaVocabulary.titleBinding());
bindings.append(mediaVocabulary.ratingBinding());
bindings.append(mediaVocabulary.descriptionBinding());
bindings.append(mediaVocabulary.artworkBinding());
//bindings.append(mediaVocabulary.genreBinding());
query.select(bindings, MediaQuery::Distinct);
query.startWhere();
query.addCondition(mediaVocabulary.hasTypeAudioStream(MediaQuery::Required));
query.addCondition(mediaVocabulary.hasTitle(MediaQuery::Required));
query.addCondition(mediaVocabulary.hasRating(MediaQuery::Optional));
query.addCondition(mediaVocabulary.hasDescription(MediaQuery::Optional));
query.addCondition(mediaVocabulary.hasArtwork(MediaQuery::Optional));
query.startFilter();
query.addFilterConstraint(mediaVocabulary.titleBinding(), engineFilter, MediaQuery::Contains);
query.addFilterOr();
query.addFilterConstraint(mediaVocabulary.descriptionBinding(), engineFilter, MediaQuery::Contains);
query.endFilter();
query.endWhere();
QStringList orderByBindings;
orderByBindings.append(mediaVocabulary.titleBinding());
query.orderBy(orderByBindings);
Soprano::QueryResultIterator it = query.executeSelect(m_mainModel);
//Build media list from results
while( it.next() ) {
MediaItem mediaItem = Utilities::mediaItemFromIterator(it, QString("Audio Stream"), m_mediaListProperties.lri);
//.........这里部分代码省略.........
示例10: MediaVocabulary
void SemanticsListEngine::run()
{
QThread::setTerminationEnabled(true);
m_stop = false;
if (m_updateSourceInfo || m_removeSourceInfo) {
NepomukListEngine::run();
return;
}
//Create media list based on engine argument and filter
QList<MediaItem> mediaList;
MediaVocabulary mediaVocabulary = MediaVocabulary();
QString engineArg = m_mediaListProperties.engineArg();
QString engineFilter = m_mediaListProperties.engineFilter();
QStringList engineFilterList = m_mediaListProperties.engineFilterList();
//Parse filter
QString mediaType;
QString groupByCategoryType;
QString groupByField;
QString limitFilter;
int originalGenreLimit = 0;
if (engineFilterList.count() != 0) {
mediaType = engineFilterList.at(0);
if (engineFilterList.filter("groupBy=").count() != 0) {
QString groupByFilter = engineFilterList.filter("groupBy=").at(0);
groupByField = groupByFilter.remove("groupBy=").trimmed();
if (groupByField == "artist") {
groupByCategoryType = "Artist";
} else if (groupByField == "album") {
groupByCategoryType = "Album";
} else if (groupByField == "genre") {
if (mediaType == "audio") {
groupByCategoryType = "AudioGenre";
} else if (mediaType == "video") {
groupByCategoryType = "VideoGenre";
}
} else if (groupByField == "seriesName") {
groupByCategoryType = "TV Series";
} else if (groupByField == "actor") {
groupByCategoryType = "Actor";
} else if (groupByField == "director") {
groupByCategoryType = "Director";
} else if (groupByField == "tag") {
if (mediaType == "audio") {
groupByCategoryType = "AudioTag";
} else if (mediaType == "video") {
groupByCategoryType = "VideoTag";
}
}
}
if (engineFilterList.filter("limit=").count() !=0) {
limitFilter = engineFilterList.filter("limit=").at(0);
if (groupByField == "genre") {
originalGenreLimit = m_mediaListProperties.filterValue(limitFilter).trimmed().toInt();
int originalFilterIndex = engineFilterList.indexOf(limitFilter);
limitFilter = QString("%1%2%3").arg(m_mediaListProperties.filterField(limitFilter))
.arg(m_mediaListProperties.filterOperator(limitFilter))
.arg(m_mediaListProperties.filterValue(limitFilter).trimmed().toInt()*3);
engineFilterList.replace(originalFilterIndex, limitFilter);
}
}
}
if (m_nepomukInited) {
if (engineArg.toLower() == "frequent") {
mediaList.clear();
if (mediaType == "audio" || mediaType == "video") {
MediaQuery query;
bool ignoreZeros = false;
if (groupByCategoryType.isEmpty()) {
QStringList bindings;
bindings.append(mediaVocabulary.mediaResourceBinding());
bindings.append(mediaVocabulary.mediaResourceUrlBinding());
bindings.append(mediaVocabulary.playCountBinding());
query.select(bindings, MediaQuery::Distinct);
query.startWhere();
if (mediaType == "audio") {
query.addCondition(mediaVocabulary.hasTypeAnyAudio(MediaQuery::Required));
} else if (mediaType == "video") {
query.addCondition(mediaVocabulary.hasTypeAnyVideo(MediaQuery::Required));
}
query.addLRIFilterConditions(engineFilterList, mediaVocabulary);
if (m_mediaListProperties.filterForField("playCount").isEmpty()) {
query.addCondition(mediaVocabulary.hasPlayCount(MediaQuery::Required, 0, MediaQuery::GreaterThan));
ignoreZeros = true;
}
query.addCondition(mediaVocabulary.hasLastPlayed(MediaQuery::Optional));
query.endWhere();
QStringList orderByBindings;
QList<MediaQuery::Order> order;
orderByBindings.append(mediaVocabulary.playCountBinding());
order.append(MediaQuery::Descending);
orderByBindings.append(mediaVocabulary.lastPlayedBinding());
order.append(MediaQuery::Descending);
query.orderBy(orderByBindings, order);
} else {
QStringList bindings;
//.........这里部分代码省略.........