diff options
author | Andrew den Exter <andrew.den.exter@jollamobile.com> | 2012-11-16 09:55:35 +1000 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2013-05-31 10:02:48 +0200 |
commit | 7f1e6566a1bc356d29a2307810d16f5a43df7bfe (patch) | |
tree | a1cd8c986f315255198545e66c91e3d74599bae2 | |
parent | 08fa879cd2fa64f5ef0d1435bb001195e1e18893 (diff) |
Fix query syntax for PhotoAlbum children.
The nie:isLogicalPartOf(?x) syntax won't match against an id, so this
query would never return anything. Instead return the contents
of the list rather than relying on a connection that may never
be established.
The same query will also return the contents of a Playlist, support
for which was mysteriously absent.
Reviewed-by: Christopher Adams <chris.adams@jollamobile.com>
(cherry picked from commit c473e738f884563e557e1d18fbb5fd515386325b)
Change-Id: Id448e06f8d183e064c8966b22d44414057a45f8a
Reviewed-by: Martin Jones <martin.jones@jollamobile.com>
3 files changed, 40 insertions, 8 deletions
diff --git a/src/gallery/tracker/qgallerytrackerchangenotifier.cpp b/src/gallery/tracker/qgallerytrackerchangenotifier.cpp index f64f10d..d55af0c 100644 --- a/src/gallery/tracker/qgallerytrackerchangenotifier.cpp +++ b/src/gallery/tracker/qgallerytrackerchangenotifier.cpp @@ -74,7 +74,9 @@ void QGalleryTrackerChangeNotifier::graphUpdated( QString identifier(m_service); identifier.replace(QLatin1Char(':'), QLatin1Char('#')); if (className.endsWith(identifier) - || (m_service == QLatin1String("nmm:Artist") && className.endsWith(QLatin1String("nfo#Audio")))) { + || (m_service == QLatin1String("nmm:Artist") && className.endsWith("nfo#Audio")) + || (m_service == QLatin1String("nmm:Photo") && className.endsWith("nmm#ImageList")) + || (m_service == QLatin1String("nfo:Audio") && className.endsWith("nmm#Playlist"))) { emit itemsChanged(QGalleryTrackerSchema::serviceUpdateId(m_service)); } } diff --git a/src/gallery/tracker/qgallerytrackerschema.cpp b/src/gallery/tracker/qgallerytrackerschema.cpp index bb76144..1a1117e 100644 --- a/src/gallery/tracker/qgallerytrackerschema.cpp +++ b/src/gallery/tracker/qgallerytrackerschema.cpp @@ -1242,12 +1242,16 @@ QDocumentGallery::Error QGalleryTrackerSchema::buildFilterQuery( } else { result = QDocumentGallery::ItemIdError; } - } else if (itemTypes[index].itemType == QDocumentGallery::PhotoAlbum) { - if (qt_galleryItemTypeList[m_itemIndex].itemType == QDocumentGallery::Image) { - filterStatement - = QLatin1String("nie:isLogicalPartOf(?x)=<") + } else if (itemTypes[index].itemType == QDocumentGallery::PhotoAlbum + || itemTypes[index].itemType == QDocumentGallery::Playlist) { + if ((qt_galleryItemTypeList[m_itemIndex].itemType == QDocumentGallery::Image + && itemTypes[index].itemType == QDocumentGallery::PhotoAlbum) + || (qt_galleryItemTypeList[m_itemIndex].itemType == QDocumentGallery::Audio + && itemTypes[index].itemType == QDocumentGallery::Playlist)) { + rootItemStatement = QLatin1String("{<") + itemTypes[index].prefix.strip(rootItemId).toString() - + QLatin1String(">"); + + QLatin1String("> nfo:hasMediaFileListEntry ?entry}"); + filterStatement = QLatin1String("nie:url(?x) = nfo:entryUrl(?entry)"); } else { result = QDocumentGallery::ItemIdError; } diff --git a/tests/auto/qgallerytrackerschema_tracker/tst_qgallerytrackerschema.cpp b/tests/auto/qgallerytrackerschema_tracker/tst_qgallerytrackerschema.cpp index 39f5a82..1c937ee 100644 --- a/tests/auto/qgallerytrackerschema_tracker/tst_qgallerytrackerschema.cpp +++ b/tests/auto/qgallerytrackerschema_tracker/tst_qgallerytrackerschema.cpp @@ -1561,7 +1561,8 @@ void tst_QGalleryTrackerSchema::queryResponseRootItem_data() << "SELECT ?x nie:url(?x) rdf:type(?x) " "WHERE {" "{?x rdf:type nmm:Photo}" - "FILTER(nie:isLogicalPartOf(?x)=<photoAlbum:Camping>)" + "{<photoAlbum:Camping> nfo:hasMediaFileListEntry ?entry}" + "FILTER(nie:url(?x) = nfo:entryUrl(?entry))" "} " "GROUP BY ?x"; @@ -1572,7 +1573,32 @@ void tst_QGalleryTrackerSchema::queryResponseRootItem_data() << "SELECT ?x nie:url(?x) rdf:type(?x) " "WHERE {" "{?x rdf:type nmm:Photo}" - "FILTER(nie:isLogicalPartOf(?x)=<photoAlbum:Camping>)" + "{<photoAlbum:Camping> nfo:hasMediaFileListEntry ?entry}" + "FILTER(nie:url(?x) = nfo:entryUrl(?entry))" + "} " + "GROUP BY ?x"; + + QTest::newRow("Playlist, All Image Descendants") + << QString::fromLatin1("Audio") + << QString::fromLatin1("playlist::playlist:mix") + << QGalleryQueryRequest::AllDescendants + << "SELECT ?x nie:url(?x) rdf:type(?x) " + "WHERE {" + "{?x rdf:type nfo:Audio}" + "{<playlist:mix> nfo:hasMediaFileListEntry ?entry}" + "FILTER(nie:url(?x) = nfo:entryUrl(?entry))" + "} " + "GROUP BY ?x"; + + QTest::newRow("Playlist, Direct Audio Descendants") + << QString::fromLatin1("Audio") + << QString::fromLatin1("playlist::playlist:mix") + << QGalleryQueryRequest::DirectDescendants + << "SELECT ?x nie:url(?x) rdf:type(?x) " + "WHERE {" + "{?x rdf:type nfo:Audio}" + "{<playlist:mix> nfo:hasMediaFileListEntry ?entry}" + "FILTER(nie:url(?x) = nfo:entryUrl(?entry))" "} " "GROUP BY ?x"; |