diff options
author | Robin Burchell <robin.burchell@jollamobile.com> | 2013-12-03 11:22:49 +0100 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2013-12-03 12:46:10 +0100 |
commit | 3570f32d98ef46ea7ac8f014727f4c2cf59bda6f (patch) | |
tree | 2940d026bd9acc7d02bfd23570e82eb78d7b37e1 | |
parent | a753d09e8f9c93eb182a6f4fc0d029a4d7540d7f (diff) |
Translate orientation strings to integer values.
Change-Id: I2550577d33fcea441e8e10bf881b35b4e16506a1
Done-with: Andrew den Exter <andrew.den.exter@jollamobile.com>
Reviewed-by: Alex Blasche <alexander.blasche@digia.com>
-rw-r--r-- | src/gallery/tracker/qgallerytrackerlistcolumn.cpp | 20 | ||||
-rw-r--r-- | src/gallery/tracker/qgallerytrackerlistcolumn_p.h | 16 | ||||
-rw-r--r-- | src/gallery/tracker/qgallerytrackerschema.cpp | 44 |
3 files changed, 75 insertions, 5 deletions
diff --git a/src/gallery/tracker/qgallerytrackerlistcolumn.cpp b/src/gallery/tracker/qgallerytrackerlistcolumn.cpp index e1ba7bd..145a278 100644 --- a/src/gallery/tracker/qgallerytrackerlistcolumn.cpp +++ b/src/gallery/tracker/qgallerytrackerlistcolumn.cpp @@ -160,4 +160,24 @@ QGalleryTrackerCompositeColumn *QGalleryTrackerFileExtensionColumn::create(const return new QGalleryTrackerFileExtensionColumn(QGALLERYTRACKERFILEURLCOLUMN_DEFAULT_COL); } +QVariant QGalleryTrackerOrientationColumn::value(QVector<QVariant>::const_iterator row) const +{ + QString orientation = (row + m_column)->toString(); + if (orientation == QLatin1String("http://www.semanticdesktop.org/ontologies/2007/03/22/nfo#orientation-top")) + return 0; + else if (orientation == QLatin1String("http://www.semanticdesktop.org/ontologies/2007/03/22/nfo#orientation-left")) + return 90; + else if (orientation == QLatin1String("http://www.semanticdesktop.org/ontologies/2007/03/22/nfo#orientation-bottom")) + return 180; + else if (orientation == QLatin1String("http://www.semanticdesktop.org/ontologies/2007/03/22/nfo#orientation-right")) + return 270; + else + return 0; +} + +QGalleryTrackerCompositeColumn *QGalleryTrackerOrientationColumn::create(const QVector<int> &columns) +{ + return new QGalleryTrackerOrientationColumn(columns.first()); +} + QT_END_NAMESPACE_DOCGALLERY diff --git a/src/gallery/tracker/qgallerytrackerlistcolumn_p.h b/src/gallery/tracker/qgallerytrackerlistcolumn_p.h index c3cc958..27b0ed7 100644 --- a/src/gallery/tracker/qgallerytrackerlistcolumn_p.h +++ b/src/gallery/tracker/qgallerytrackerlistcolumn_p.h @@ -198,6 +198,22 @@ private: const int m_column; }; + +class QGalleryTrackerOrientationColumn : public QGalleryTrackerCompositeColumn +{ +public: + QGalleryTrackerOrientationColumn(int column) + : m_column(column) {} + + QVariant value(QVector<QVariant>::const_iterator row) const; + + static QGalleryTrackerCompositeColumn *create(const QVector<int> &); + +private: + const int m_column; +}; + + QT_END_NAMESPACE_DOCGALLERY #endif diff --git a/src/gallery/tracker/qgallerytrackerschema.cpp b/src/gallery/tracker/qgallerytrackerschema.cpp index 1a1117e..4b90675 100644 --- a/src/gallery/tracker/qgallerytrackerschema.cpp +++ b/src/gallery/tracker/qgallerytrackerschema.cpp @@ -633,6 +633,35 @@ static bool qt_writeFileExtensionCondition( } } + +static bool qt_writeOrientationCondition( + QDocumentGallery::Error *error, + QString *query, + const QGalleryCompositeProperty &, + const QGalleryMetaDataFilter &filter) +{ + if (filter.comparator() != QGalleryFilter::Equals || filter.value().type() != QVariant::Int) { + *error = QDocumentGallery::FilterError; + return false; + } else switch (filter.value().toInt()) { + case 0: + *query += QLatin1String("nfo:orientation(?x) = 'http://www.semanticdesktop.org/ontologies/2007/03/22/nfo#orientation-top'"); + return true; + case 90: + *query += QLatin1String("nfo:orientation(?x) = 'http://www.semanticdesktop.org/ontologies/2007/03/22/nfo#orientation-left'"); + return true; + case 180: + *query += QLatin1String("nfo:orientation(?x) = 'http://www.semanticdesktop.org/ontologies/2007/03/22/nfo#orientation-bottom'"); + return true; + case 270: + *query += QLatin1String("nfo:orientation(?x) = 'http://www.semanticdesktop.org/ontologies/2007/03/22/nfo#orientation-right'"); + return true; + default: + *error = QDocumentGallery::FilterError; + return false; + } +} + //nie:DataObject // nie:url nie:isPartOf, nie:created, nie:lastRefreshed, nie:interpretedAs, nie:dataSource, // nie:byteSize @@ -792,13 +821,18 @@ static const QGalleryItemProperty qt_galleryImagePropertyList[] = QT_GALLERY_ITEM_PROPERTY("flashEnabled" , "nmm:flash(?x)" , String , CanRead | CanWrite | CanSort | CanFilter), QT_GALLERY_ITEM_PROPERTY("focalLength" , "nmm:focalLength(?x)" , Double , CanRead | CanWrite | CanSort | CanFilter), QT_GALLERY_ITEM_PROPERTY("meteringMode" , "nmm:meteringMode(?x)" , String , CanRead | CanWrite | CanSort | CanFilter), - QT_GALLERY_ITEM_PROPERTY("orientation" , "nfo:orientation(?x)" , Int , CanRead | CanWrite | CanSort | CanFilter), - QT_GALLERY_ITEM_PROPERTY("whiteBalance" , "nmm:whiteBalance(?x)" , String , CanRead | CanWrite | CanSort | CanFilter) + QT_GALLERY_ITEM_PROPERTY("whiteBalance" , "nmm:whiteBalance(?x)" , String , CanRead | CanWrite | CanSort | CanFilter), + QT_GALLERY_ITEM_PROPERTY("_orientation", "nfo:orientation(?x)" , String, CanRead) +}; + +static const QGalleryItemProperty qt_galleryOrientationPropertyList[] = { + QT_GALLERY_ITEM_PROPERTY("_orientation", "nfo:orientation(?x)", String, CanRead | CanFilter) }; static const QGalleryCompositeProperty qt_galleryImageCompositePropertyList[] = { - QT_GALLERY_NFO_FILEDATAOBJECT_COMPOSITE_PROPERTIES + QT_GALLERY_NFO_FILEDATAOBJECT_COMPOSITE_PROPERTIES, + QT_GALLERY_COMPOSITE_PROPERTY("orientation", Int, qt_galleryOrientationPropertyList, QGalleryTrackerOrientationColumn::create, qt_writeOrientationCondition) }; //////// @@ -1454,9 +1488,9 @@ void QGalleryTrackerSchema::populateItemArguments( int fieldIndex = arguments->fieldNames.indexOf(field); if (fieldIndex >= 0) { - columns.append(fieldIndex + 2); + columns.append(fieldIndex + 3); } else { - columns.append(arguments->fieldNames.count() + 2); + columns.append(arguments->fieldNames.count() + 3); arguments->fieldNames.append(field); extendedValueTypes.append(dependencies[i].type); |