本文整理汇总了C++中MediaQuery::query方法的典型用法代码示例。如果您正苦于以下问题:C++ MediaQuery::query方法的具体用法?C++ MediaQuery::query怎么用?C++ MediaQuery::query使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MediaQuery
的用法示例。
在下文中一共展示了MediaQuery::query方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: start
void OntologyUpdater::start()
{
QApplication::processEvents();
Soprano::Model *m_mainModel;
bool m_nepomukInited = Utilities::nepomukInited();
if (m_nepomukInited) {
m_mainModel = Nepomuk2::ResourceManager::instance()->mainModel();
} else {
return;
}
m_stopUpdate = false;
MediaVocabulary mediaVocabulary;
//Update audio
QString queryPrefix = QString("PREFIX xesam: <%1> "
"PREFIX rdf: <%2> "
"PREFIX xls: <%3> "
"PREFIX nmm: <http://www.semanticdesktop.org/ontologies/nmm#> "
"PREFIX nie: <http://www.semanticdesktop.org/ontologies/2007/01/19/nie#> "
"PREFIX nfo: <http://www.semanticdesktop.org/ontologies/2007/03/22/nfo#> ")
.arg(Soprano::Vocabulary::Xesam::xesamNamespace().toString())
.arg(Soprano::Vocabulary::RDF::rdfNamespace().toString())
.arg(Soprano::Vocabulary::XMLSchema::xsdNamespace().toString());
QString queryStr = queryPrefix + QString("SELECT ?r "
"WHERE { {?r rdf:type <http://www.semanticdesktop.org/ontologies/nfo#Audio>} "
"UNION "
"{?r rdf:type <http://www.semanticdesktop.org/ontologies/nmm#MusicPiece>} "
"UNION "
"{?r rdf:type <http://www.semanticdesktop.org/ontologies/nmm#DigitalRadio>} "
"UNION "
"{?r rdf:type <http://www.semanticdesktop.org/ontologies/nmm#MusicAlbum>} "
"UNION "
"{?r rdf:type <%1>} "
"UNION "
"{?r rdf:type <%2>} "
"UNION "
"{?r rdf:type <%3>} }")
.arg(mediaVocabulary.typeAudio().toString())
.arg(mediaVocabulary.typeAudioMusic().toString())
.arg(mediaVocabulary.typeMediaStream().toString());
Soprano::QueryResultIterator it = m_mainModel->executeQuery(queryStr, Soprano::Query::QueryLanguageSparql);
emit infoMessage(i18n("<b>Updating audio types and properties</b><br>0 items updated..."));
QApplication::processEvents();
int i = 0;
while( it.next() && !m_stopUpdate) {
QApplication::processEvents();
i++;
Nepomuk2::Resource resource = Nepomuk2::Resource(it.binding("r").uri());
//Update types
QUrl type = QUrl("http://www.semanticdesktop.org/ontologies/nfo#Audio");
if (resource.hasType(type)) {
removeType(resource, type);
if (!resource.hasType(mediaVocabulary.typeAudio())) {
resource.addType(mediaVocabulary.typeAudio());
}
}
type = QUrl("http://www.semanticdesktop.org/ontologies/nmm#MusicPiece");
if (resource.hasType(type)) {
removeType(resource, type);
if (!resource.hasType(mediaVocabulary.typeAudioMusic())) {
resource.addType(mediaVocabulary.typeAudioMusic());
}
//Update properties
QUrl property = QUrl("http://www.semanticdesktop.org/ontologies/nmm#musicAlbum");
if (resource.hasProperty(property)) {
Nepomuk2::Variant value = resource.property(property);
resource.removeProperty(property);
resource.setProperty(mediaVocabulary.musicAlbum(), value);
}
property = QUrl("http://www.semanticdesktop.org/ontologies/nmm#trackNumber");
if (resource.hasProperty(property)) {
Nepomuk2::Variant value = resource.property(property);
resource.removeProperty(property);
resource.setProperty(mediaVocabulary.musicTrackNumber(), value);
}
}
type = QUrl("http://www.semanticdesktop.org/ontologies/nmm#DigitalRadio");
if (resource.hasType(type)) {
removeType(resource, type);
if (!resource.hasType(mediaVocabulary.typeMediaStream())) {
resource.addType(mediaVocabulary.typeMediaStream());
}
}
type = QUrl("http://www.semanticdesktop.org/ontologies/nmm#MusicAlbum");
if (resource.hasType(type)) {
removeType(resource, type);
if (!resource.hasType(mediaVocabulary.typeMusicAlbum())) {
resource.addType(mediaVocabulary.typeMusicAlbum());
}
}
//Update common properties
QUrl property = QUrl("http://www.semanticdesktop.org/ontologies/nfo#duration");
if (resource.hasProperty(property)) {
Nepomuk2::Variant value = resource.property(property);
resource.removeProperty(property);
resource.setProperty(mediaVocabulary.duration(), value);
//.........这里部分代码省略.........