QList<QGalleryResource> QGalleryTrackerResultSet::resources() const { Q_D(const QGalleryTrackerResultSet); QList<QGalleryResource> resources; if (d->currentRow) { const QUrl url = d->urlColumn->value(d->currentRow).toUrl(); if (!url.isEmpty()) { QMap<int, QVariant> attributes; typedef QVector<int>::const_iterator iterator; for (iterator it = d->resourceKeys.begin(), end = d->resourceKeys.end(); it != end; ++it) { QVariant value = metaData(*it); if (!value.isNull()) attributes.insert(*it, value); } resources.append(QGalleryResource(url, attributes)); } } return resources; }
QList<QGalleryResource> QMDEGalleryResultSet::resources() const { QList<QGalleryResource> resources; if (m_itemArray[m_cursorPosition]) { const QUrl url = QUrl( QDocumentGalleryMDSUtility::s60DescToQString(m_itemArray[m_cursorPosition]->Uri())); QStringList propertyList; QDocumentGalleryMDSUtility::GetDataFieldsForItemType( propertyList, itemType() ); const int count = propertyList.count(); QMap<int, QVariant> attributes; for (int i = 0; i < count; i++) { int propertyKey = QDocumentGalleryMDSUtility::GetPropertyKey( propertyList[i] ); QVariant value = metaData( propertyKey ); if (!value.isNull()) attributes.insert(propertyKey, value); } resources.append(QGalleryResource(url, attributes)); } return resources; }
void tst_QGalleryResource::equality_data() { const int sampleRateKey = 3; const int audioCodecKey = 6; const int videoCodecKey = 9; const QUrl url1("file:///a/local/video/file.m4v"); const QUrl url2("http://example.com/video.mpg"); QMap<int, QVariant> attributes1; attributes1.insert(sampleRateKey, 44100); attributes1.insert(audioCodecKey, QLatin1String("aac")); attributes1.insert(videoCodecKey, QLatin1String("h264")); QMap<int, QVariant> attributes2; attributes2.insert(sampleRateKey, 22050); const QGalleryResource resource1(url1); const QGalleryResource resource2(url2); const QGalleryResource resource3(url1, attributes1); const QGalleryResource resource4(url1, attributes2); const QGalleryResource resource5(url2, attributes1); QTest::addColumn<QGalleryResource>("resource1"); QTest::addColumn<QGalleryResource>("resource2"); QTest::addColumn<bool>("isEqual"); QTest::newRow("Null resources") << QGalleryResource() << QGalleryResource() << true; QTest::newRow("Same resource (No attributes)") << resource1 << resource1 << true; QTest::newRow("Same resource (Attributes)") << resource3 << resource3 << true; QTest::newRow("Equal resource (No attributes)") << QGalleryResource(url1) << QGalleryResource(url1) << true; QTest::newRow("Equal resource (Attributes)") << QGalleryResource(url1, attributes1) << QGalleryResource(url1, attributes1) << true; QTest::newRow("Null resource != Non-null (No attributes)") << QGalleryResource() << resource1 << false; QTest::newRow("Null resource != Non-null (Attributes)") << QGalleryResource() << resource3 << false; QTest::newRow("Different URL, no attributes") << resource1 << resource2 << false; QTest::newRow("Same URL, With/without attributes") << resource1 << resource3 << false; QTest::newRow("Same Url, Different attributes") << resource3 << resource4 << false; QTest::newRow("Different URL, same attributes") << resource3 << resource5 << false; }