diff options
author | Xizhi Zhu <xizhi.zhu@gmail.com> | 2012-08-14 20:40:33 +0300 |
---|---|---|
committer | Qt by Nokia <qt-info@nokia.com> | 2012-08-14 21:07:06 +0200 |
commit | c883b837170f531c1ab05601d4025f3e6b500af6 (patch) | |
tree | 74816ebc91c5ade247ebffd01074892430255d45 | |
parent | 1294c850cb92f1fe32dffe9073aade169fb7e26b (diff) |
Removed "simple" backend.
It's never used nor maintained.
Change-Id: I08eb98e3c033bb3af252e0a6f98371d31e960f0d
Reviewed-by: Xizhi Zhu <xizhi.zhu@gmail.com>
23 files changed, 2 insertions, 4198 deletions
diff --git a/src/gallery/gallery.pro b/src/gallery/gallery.pro index db1ce14..3dd4170 100644 --- a/src/gallery/gallery.pro +++ b/src/gallery/gallery.pro @@ -51,8 +51,6 @@ simulator: { } else: linux-* { contains(QT_CONFIG, dbus): contains(tracker_enabled, yes): { include (tracker/tracker.pri) - } else: contains(QT_CONFIG, jsondb): { - include (simple/simple.pri) } else: { DEFINES += QT_DOCUMENT_GALLERY_NULL } diff --git a/src/gallery/simple/qdocumentgallery_simple.cpp b/src/gallery/simple/qdocumentgallery_simple.cpp deleted file mode 100644 index e8159c4..0000000 --- a/src/gallery/simple/qdocumentgallery_simple.cpp +++ /dev/null @@ -1,147 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDocGallery module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qdocumentgallery.h" - -#include "qabstractgallery_p.h" - -#include "qgalleryitemrequest.h" -#include "qgalleryqueryrequest.h" -#include "qgallerytyperequest.h" - -#include "qsimplegalleryitemresultset.h" -#include "qsimplegalleryqueryresultset.h" -#include "qgallerysimpleutility.h" - -QT_ADDON_GALLERY_BEGIN_NAMESPACE - -class QDocumentGalleryPrivate : public QAbstractGalleryPrivate -{ -public: - QGalleryAbstractResponse *createItemResponse(QGalleryItemRequest *request); - QGalleryAbstractResponse *createTypeResponse(QGalleryTypeRequest *request); - QGalleryAbstractResponse *createFilterResponse(QGalleryQueryRequest *request); - - -}; - -QGalleryAbstractResponse *QDocumentGalleryPrivate::createItemResponse(QGalleryItemRequest *request) -{ - // Fill up response class with with request data (create proper query) - QSimpleGalleryItemResultSet *response = new QSimpleGalleryItemResultSet(request); - return response; -} - -QGalleryAbstractResponse *QDocumentGalleryPrivate::createTypeResponse(QGalleryTypeRequest *request) -{ - Q_UNUSED(request) - return 0; -} - -QGalleryAbstractResponse *QDocumentGalleryPrivate::createFilterResponse( - QGalleryQueryRequest *request) -{ - // Fill up response class with with request data (create proper query) - QSimpleGalleryQueryResultSet *response = new QSimpleGalleryQueryResultSet(request); - return response; -} - -QDocumentGallery::QDocumentGallery(QObject *parent) - : QAbstractGallery(*new QDocumentGalleryPrivate, parent) -{ -} - -QDocumentGallery::~QDocumentGallery() -{ -} - -bool QDocumentGallery::isRequestSupported(QGalleryAbstractRequest::RequestType type) const -{ - switch (type) { - case QGalleryAbstractRequest::QueryRequest: - case QGalleryAbstractRequest::ItemRequest: - //case QGalleryAbstractRequest::TypeRequest: - //case QGalleryAbstractRequest::RemoveRequest: - return true; - default: - return false; - } -} - -QStringList QDocumentGallery::itemTypePropertyNames(const QString &itemType) const -{ - QStringList list; - QDocumentGallerySimpleUtility::GetDataFieldsForItemType(list, itemType);//::GetDataFieldsForItemType( list, itemType ); - return list; -} - -QGalleryProperty::Attributes QDocumentGallery::propertyAttributes( - const QString &propertyName, const QString &itemType) const -{ - Q_UNUSED(itemType) - if (propertyName == QDocumentGallery::url.name()) - return (QGalleryProperty::CanRead | QGalleryProperty::CanSort | QGalleryProperty::CanFilter ); - else - return (QGalleryProperty::CanRead | QGalleryProperty::CanWrite | QGalleryProperty::CanSort | QGalleryProperty::CanFilter ); -} - -QGalleryAbstractResponse *QDocumentGallery::createResponse(QGalleryAbstractRequest *request) -{ - Q_D(QDocumentGallery); - - switch (request->type()) { - case QGalleryAbstractRequest::QueryRequest: - return d->createFilterResponse(static_cast<QGalleryQueryRequest *>(request)); - case QGalleryAbstractRequest::ItemRequest: - return d->createItemResponse(static_cast<QGalleryItemRequest *>(request)); - //case QGalleryAbstractRequest::TypeRequest: - // return d->createTypeResponse(static_cast<QGalleryTypeRequest *>(request)); - //case QGalleryAbstractRequest::RemoveRequest: - // return d->createRemoveResponse(static_cast<QGalleryRemoveRequest *>(request)); - default: - return 0; - } -} - -#include "moc_qdocumentgallery.cpp" - -QT_ADDON_GALLERY_END_NAMESPACE - diff --git a/src/gallery/simple/qgallerysimpleutility.cpp b/src/gallery/simple/qgallerysimpleutility.cpp deleted file mode 100644 index 50d1854..0000000 --- a/src/gallery/simple/qgallerysimpleutility.cpp +++ /dev/null @@ -1,428 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDocGallery module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include <QUrl> -//Backend -#include "qgallerysimpleutility.h" -#include <qdocumentgallery.h> - -QT_ADDON_GALLERY_BEGIN_NAMESPACE - -QDocumentGallerySimpleUtility::QDocumentGallerySimpleUtility() -{ - -} -QDocumentGallerySimpleUtility::~QDocumentGallerySimpleUtility() -{ - -} - -void QDocumentGallerySimpleUtility::GetDataFieldsForItemType( QStringList &propertyList, QString itemType ) -{ - if (itemType == QDocumentGallery::Artist.name()) { - propertyList.append(QDocumentGallery::artist.name() ); - propertyList.append(QLatin1String("songCount")); // The list of songs (_uuid) by this artist - propertyList.append(QLatin1String("albums")); // The list of albums (_uuid) by this artist - propertyList.append(QLatin1String("covers")); // List of urls to album cover thumbnails - } else if (itemType == QDocumentGallery::AlbumArtist.name()) { - propertyList.append(QDocumentGallery::artist.name() ); // Artist - propertyList.append(QLatin1String("songCount")); // The list of songs (_uuid) by this artist in this album - propertyList.append(QDocumentGallery::albumArtist.name() ); - propertyList.append(QDocumentGallery::albumTitle); - propertyList.append(QLatin1String("albumArt")); - propertyList.append(QLatin1String("albumId")); - } else if (itemType == QDocumentGallery::Album.name()) { - propertyList.append(QLatin1String("albumArt")); - /*propertyList.append( QDocumentGallery::fileSize.name() ); - propertyList.append( QDocumentGallery::lastModified.name() );*/ - propertyList.append(QDocumentGallery::title.name() ); - propertyList.append(QDocumentGallery::artist.name() ); - propertyList.append(QDocumentGallery::albumArtist.name() ); - //propertyList.append( QDocumentGallery::mimeType.name() ); - } else if (itemType == QDocumentGallery::Audio.name()) { - propertyList.append(QDocumentGallery::url.name() ); - /*propertyList.append( QDocumentGallery::fileSize.name() ); - propertyList.append( QDocumentGallery::lastModified.name() );*/ - propertyList.append(QDocumentGallery::title.name() ); - //propertyList.append( QDocumentGallery::mimeType.name() ); - propertyList.append(QDocumentGallery::artist.name() ); - propertyList.append(QDocumentGallery::albumTitle); - propertyList.append(QDocumentGallery::albumArtist); - propertyList.append(QLatin1String("albumArt")); - //propertyList.append( QDocumentGallery::copyright.name() ); - //propertyList.append( QDocumentGallery::description.name() ); - //propertyList.append( QDocumentGallery::comments.name() ); - //propertyList.append( QDocumentGallery::rating.name() ); <-- TODO - - //propertyList.append( QDocumentGallery::duration.name() ); <-- TODO - //propertyList.append( QDocumentGallery::performer.name() ); - - //propertyList.append( QDocumentGallery::audioCodec.name() ); - //propertyList.append( QDocumentGallery::audioBitRate.name() ); - //propertyList.append( QDocumentGallery::playCount.name() ); - - //propertyList.append( QDocumentGallery::sampleRate.name() ); - - propertyList.append(QDocumentGallery::trackNumber); - propertyList.append(QDocumentGallery::genre); - /*} else if (itemType == QDocumentGallery::File.name()) { - // From MDS base object - propertyList.append( QDocumentGallery::url.name() ); - propertyList.append( QDocumentGallery::fileSize.name() ); - propertyList.append( QDocumentGallery::lastModified.name() ); - propertyList.append( QDocumentGallery::title.name() ); - propertyList.append( QDocumentGallery::mimeType.name() ); - // From MDS media object - propertyList.append( QDocumentGallery::author.name() ); - propertyList.append( QDocumentGallery::copyright.name() ); - propertyList.append( QDocumentGallery::description.name() ); - propertyList.append( QDocumentGallery::comments.name() ); - propertyList.append( QDocumentGallery::rating.name() );*/ - } else if (itemType == QDocumentGallery::Image.name()) { // TODO: add the properties needed by Image Viewer - propertyList.append(QDocumentGallery::url.name() ); - /*propertyList.append( QDocumentGallery::fileSize.name() ); - propertyList.append( QDocumentGallery::lastModified.name() );*/ - propertyList.append(QDocumentGallery::title.name() ); - /*propertyList.append( QDocumentGallery::mimeType.name() ); - propertyList.append( QDocumentGallery::author.name() ); - propertyList.append( QDocumentGallery::copyright.name() ); - propertyList.append( QDocumentGallery::description.name() ); <-- TODO*/ - propertyList.append(QDocumentGallery::comments.name() ); - /*propertyList.append( QDocumentGallery::rating.name() ); - - propertyList.append( QDocumentGallery::duration.name() ); - propertyList.append( QDocumentGallery::performer.name() ); - - propertyList.append( QDocumentGallery::playCount.name() ); - - propertyList.append( QDocumentGallery::width.name() ); <-- TODO - propertyList.append( QDocumentGallery::height.name() ); <-- TODO - // From MDS image object - propertyList.append( QDocumentGallery::orientation.name() ); <-- TODO - propertyList.append( QDocumentGallery::dateTaken.name() ); <-- TODO - propertyList.append( QDocumentGallery::cameraManufacturer.name() ); - propertyList.append( QDocumentGallery::cameraModel.name() ); - propertyList.append( QDocumentGallery::exposureProgram.name() ); - propertyList.append( QDocumentGallery::exposureTime.name() ); - propertyList.append( QDocumentGallery::fNumber.name() ); - propertyList.append( QDocumentGallery::flashEnabled.name() ); - propertyList.append( QDocumentGallery::focalLength.name() ); - propertyList.append( QDocumentGallery::meteringMode.name() ); - propertyList.append( QDocumentGallery::whiteBalance.name() );*/ - }/* else if (itemType == QDocumentGallery::Video.name()) { <-- TODO - propertyList.append( QDocumentGallery::url.name() ); - propertyList.append( QDocumentGallery::fileSize.name() ); - propertyList.append( QDocumentGallery::lastModified.name() ); - propertyList.append( QDocumentGallery::title.name() ); - propertyList.append( QDocumentGallery::mimeType.name() ); - // From MDS media object - propertyList.append( QDocumentGallery::author.name() ); - propertyList.append( QDocumentGallery::copyright.name() ); - propertyList.append( QDocumentGallery::description.name() ); - propertyList.append( QDocumentGallery::comments.name() ); - propertyList.append( QDocumentGallery::rating.name() ); - - propertyList.append( QDocumentGallery::duration.name() ); - propertyList.append( QDocumentGallery::performer.name() ); - - propertyList.append( QDocumentGallery::videoBitRate.name() ); - propertyList.append( QDocumentGallery::playCount.name() ); - - propertyList.append( QDocumentGallery::width.name() ); - propertyList.append( QDocumentGallery::height.name() ); - // From MDS video object - propertyList.append( QDocumentGallery::language.name() ); - propertyList.append( QDocumentGallery::frameRate.name() ); - propertyList.append( QDocumentGallery::resumePosition.name() ); - }*/ -} - - -int QDocumentGallerySimpleUtility::GetPropertyKey( const QString &property ) -{ - if (property == QDocumentGallery::url.name()) { - return EUri; - /*} else if (property == QDocumentGallery::fileSize.name()) { - return EFileSize; - } else if (property == QDocumentGallery::lastModified.name()) { - return ELastModified;*/ - } else if (property == QDocumentGallery::title.name()) { - return ETitle; - /*} else if (property == QDocumentGallery::mimeType.name()) { - return EMime; - } else if (property == QDocumentGallery::duration.name()) { - return EDuration; - } else if (property == QDocumentGallery::performer.name()) { - return EPerformer; - } else if (property == QDocumentGallery::width.name()) { - return EWidth; - } else if (property == QDocumentGallery::height.name()) { - return EHeight; - } else if (property == QDocumentGallery::orientation.name()) { - return EOrientation; - } else if (property == QDocumentGallery::audioBitRate.name()) { - return EAudioBitrate; - } else if (property == QDocumentGallery::videoBitRate.name()) { - return EVideoBitrate; - } else if (property == QDocumentGallery::frameRate.name()) { - return EFrameRate; - } else if (property == QDocumentGallery::copyright.name()) { - return ECopyright; - } else if (property == QDocumentGallery::description.name()) { - return EDescription;*/ - } else if (property == QDocumentGallery::comments.name()) { - return EComments; - /*} else if (property == QDocumentGallery::author.name()) { - return EAuthor; - } else if (property == QDocumentGallery::rating.name()) { - return ERating; - } else if (property == QDocumentGallery::audioCodec.name()) { - return EAudioCodec; - } else if (property == QDocumentGallery::playCount.name()) { - return EPlayCount; - } else if (property == QDocumentGallery::sampleRate.name()) { - return ESampleRate; - } else if (property == QDocumentGallery::dateTaken.name()) { - return EDateTaken; - } else if (property == QDocumentGallery::cameraManufacturer.name()) { - return ECameraManufacturer; - } else if (property == QDocumentGallery::cameraModel.name()) { - return ECameraModel; - } else if (property == QDocumentGallery::exposureProgram.name()) { - return EExposureProgram; - } else if (property == QDocumentGallery::exposureTime.name()) { - return EExposureTime; - } else if (property == QDocumentGallery::fNumber.name()) { - return EFNumber; - } else if (property == QDocumentGallery::flashEnabled.name()) { - return EFlashEnabled; - } else if (property == QDocumentGallery::focalLength.name()) { - return EFocalLength; - } else if (property == QDocumentGallery::meteringMode.name()) { - return EMeteringMode; - } else if (property == QDocumentGallery::whiteBalance.name()) { - return EWhiteBalance; - } else if (property == QDocumentGallery::language.name()) { - return ELanguage; - } else if (property == QDocumentGallery::resumePosition.name()) { - return EResumePosition;*/ - } else if (property == QDocumentGallery::artist) { - return EArtist; - } else if (property == QDocumentGallery::albumArtist) { - return EAlbumArtist; - } else if (property == QDocumentGallery::albumTitle) { - return EAlbumTitle; - } else if (property == QDocumentGallery::genre) { - return EGenre; - } else if (property == QDocumentGallery::trackNumber) { - return ETrackNumber; - } else if (property == QLatin1String("albumArt")) { - return EAlbumArt; - //} else if (property == "count") { - // return ECount; - //} else if (property == "albumCount") { - // return EAlbumCount; - } else if (property == QLatin1String("songCount")) { - return ESongCount; - } else if (property == QLatin1String("albums")) { - return EAlbums; - } else if (property == QLatin1String("covers")) { - return ECovers; - } else if (property == QLatin1String("albumId")) { - return EAlbumId; - } - - return -1; -} - -QVariant::Type QDocumentGallerySimpleUtility::GetPropertyType( int key ) -{ - //TODO: remove compile warnings - switch (key) { - case EUri: - return QVariant::Url; - /*case EFileSize: - case EAudioCodec: - case EPlayCount: - return QVariant::ULongLong; - case ELastModified: - case EDateTaken: - return QVariant::DateTime;*/ - case ETitle: - /*case EMime: - case EAuthor: -} else if (property == "count") { - return ECount; -} - case ECopyright: - case EDescription:*/ - case EComments: - /*case EPerformer: - case ECameraManufacturer: - case ECameraModel: - case ELanguage:*/ - case EArtist: - case EAlbumArtist: - case EAlbumTitle: - case EAlbumArt: - case EGenre: - case EAlbumId: - return QVariant::String; - /*case ERating: - case EAudioBitrate: - case EWidth: - case EHeight: - case EOrientation: - case EExposureProgram: - case EFlashEnabled: - case EFocalLength: - case EMeteringMode: - case EWhiteBalance: - case EVideoBitrate:*/ - case ETrackNumber: - //case ECount: - //case EAlbumCount: - return QVariant::UInt; - /*case EDuration: - case ESampleRate: - case EExposureTime: - case EFNumber: - case EFrameRate: - case EResumePosition: - return QVariant::Double;*/ - default: - return QVariant::Invalid; - } -} - - -// Get the index of given property in the sql query -int QDocumentGallerySimpleUtility::GetPropertyIndex( int key, const QString& itemType ) -{ - if (itemType ==QDocumentGallery::AlbumArtist.name()) { - switch (key) { - case EArtist: - return 1; - case ESongCount: - return 2; - case EAlbumArtist: - return 3; - case EAlbumTitle: - return 4; - case EAlbumArt: - return 5; - case EAlbumId: - return 6; - } - return -1; - } - else { - switch (key) { - case EUri: - return 1; - /*case EFileSize: - case EAudioCodec: - case EPlayCount: - case ELastModified: - case EDateTaken:*/ - case ETitle: - return 2; - //case ECount: - // return 2; - case ESongCount: - return 2; - /*case EMime: - case EAuthor: - case ECopyright: - case EDescription:*/ - // Only in images - case EComments: - // In Album, Audio and in AlbumArtist - case EArtist: - if (itemType == QDocumentGallery::Artist.name()) - return 1; - case EAlbums: - return 3; - /*case EPerformer: - case ECameraManufacturer: - case ECameraModel: - case ELanguage:*/ - case EAlbumTitle: - case ECovers: - return 4; - case EAlbumArtist: - if (itemType == QDocumentGallery::Album.name()) - return 4; - case EAlbumId: - return 5; - case EAlbumArt: - if (itemType == QDocumentGallery::Album.name()) - return 1; - return 6; - case ETrackNumber: - return 7; - case EGenre: - return 8; - /*case ERating: - case EAudioBitrate: - case EWidth: - case EHeight: - case EOrientation: - case EExposureProgram: - case EFlashEnabled: - case EFocalLength: - case EMeteringMode: - case EWhiteBalance: - case EVideoBitrate:*/ - /*case EDuration: - case ESampleRate: - case EExposureTime: - case EFNumber: - case EFrameRate: - case EResumePosition: - return QVariant::Double;*/ - default: - return -1; - } - } -} - -QT_ADDON_GALLERY_END_NAMESPACE diff --git a/src/gallery/simple/qgallerysimpleutility.h b/src/gallery/simple/qgallerysimpleutility.h deleted file mode 100644 index 107b7b2..0000000 --- a/src/gallery/simple/qgallerysimpleutility.h +++ /dev/null @@ -1,118 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDocGallery module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QDOCUMENTGALLERYSIMPLEUTILITY_H -#define QDOCUMENTGALLERYSIMPLEUTILITY_H - -#include <QString> -#include <QDateTime> -//API -#include "qgalleryqueryrequest.h" - -QT_ADDON_GALLERY_BEGIN_NAMESPACE - -class QDocumentGallerySimpleUtility -{ -public: - enum TPropertyKeys { - EUri = 0, - //EFileSize, - //ELastModified, - ETitle, - //EMime, - //EAuthor, - EArtist, - EAlbumArtist, - EAlbumTitle, - EAlbumArt, - ECount, - EAlbumCount, - EGenre, - ETrackNumber, - ESongCount, - EAlbums, - ECovers, - EAlbumId, - //ECopyright, - //EDescription, - EComments/*, - ERating, - EDuration, - EPerformer, - EAudioCodec, - EAudioBitrate, - EPlayCount, - ESampleRate, - EWidth, - EHeight, - EOrientation, - EDateTaken, - ECameraManufacturer, - ECameraModel, - EExposureProgram, - EExposureTime, - EFNumber, - EFlashEnabled, - EFocalLength, - EMeteringMode, - EWhiteBalance, - EVideoBitrate, - ELanguage, - EFrameRate, - EResumePosition*/ - }; - - QDocumentGallerySimpleUtility(); - ~QDocumentGallerySimpleUtility(); - - /** - * Maps Document Gallery itemtype to MdE object class - * - */ - static void GetDataFieldsForItemType(QStringList &propertyList, QString itemType); - static int GetPropertyKey(const QString &property); - static QVariant::Type GetPropertyType(int key); - static int GetPropertyIndex(int key, const QString &itemType); -}; - -QT_ADDON_GALLERY_END_NAMESPACE - -#endif // QDOCUMENTGALLERYSIMPLEUTILITY_H diff --git a/src/gallery/simple/qmdlite.cpp b/src/gallery/simple/qmdlite.cpp deleted file mode 100644 index 9ff4d7c..0000000 --- a/src/gallery/simple/qmdlite.cpp +++ /dev/null @@ -1,386 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDocGallery module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include <QDesktopServices> -#include <QStringList> -#include <QtDebug> -#include <QDir> -#include <QVector> -#include <QCryptographicHash> -#include <QImage> -#include <QDateTime> - -#include "qmdlite.h" -#include "qmdlite_p.h" - -#ifdef _SQLITE_QMDBACKEND -#include <QSqlQuery> -#include "qmdlitequeryresultsqlite_p.h" -#else -#include <private/jsondb-connection_p.h> -#include <jsondb-client.h> -#include <private/jsondb-strings_p.h> -#include "qmdlitequeryresultjsondb_p.h" -QT_ADDON_JSONDB_USE_NAMESPACE -#endif - -QMdLitePrivate::QMdLitePrivate () -{ -} - -QMdLitePrivate::~QMdLitePrivate () -{ -#ifdef _SQLITE_QMDBACKEND - m_db.close(); -#endif -} - -QString QMdLitePrivate::sortProperties2String (const QStringList& sortProperties, bool ascending) -{ - QString ret; - - if (sortProperties.count() > 0) { -#ifdef _SQLITE_QMDBACKEND - ret.append(QLatin1String(" ORDER BY ")); - if (!ascending) ret.append(sortProperties.join(QLatin1String(" DESC, "))); - else ret.append(sortProperties.join(QLatin1String(", "))); -#else - foreach (const QString &property, sortProperties) { - ret.append (QLatin1String("[")); - if (ascending) ret.append(QLatin1String("/")).append(property); - else ret.append(QLatin1String("\\")).append(property); - ret.append (QLatin1String("]")); - } -#endif - } - return ret; -} - -// Return id always as the first item in row. Properties in index+1. -QString QMdLitePrivate::createQueryString -(const QString& table, const QStringList& properties, const QString& filterStr, const QStringList& sortProperties) -{ -#ifdef _SQLITE_QMDBACKEND - // Always read id - QString sqlQueryStr("SELECT id"); - if (properties.length() > 0) { - sqlQueryStr.append(", "); - sqlQueryStr.append(properties.join(", ")); - } - sqlQueryStr.append(" FROM ").append(table); - - if (filterStr.length() > 0) { - sqlQueryStr.append(" WHERE "); - sqlQueryStr.append(filterStr); - } - sqlQueryStr.append(sortProperties2String (sortProperties)); - //qDebug () << "Select: " << sqlQueryStr; - return sqlQueryStr; -#else - QString jsonQuery = QLatin1String("[?_type=\""); - jsonQuery.append(table).append(QLatin1String("\"]")); - - if (filterStr.length() > 0) { - jsonQuery.append(QLatin1String("[")); - jsonQuery.append(filterStr); - jsonQuery.append(QLatin1String("]")); - } - if (properties.length() > 0) { - jsonQuery.append(QLatin1String("[= [ _uuid")); - foreach (QString property, properties) { - jsonQuery.append(QLatin1String(" , ")); - jsonQuery.append(property); - } - - //jsonQuery.append(properties.join(QLatin1String(","))); - jsonQuery.append(QLatin1String(" ] ]")); - } - jsonQuery.append(sortProperties2String (sortProperties)); - //qDebug () << "query: " << jsonQuery; - return jsonQuery; -#endif -} - -int QMdLitePrivate::query -(const QString& table, QList<QVariantList>& rows, const QStringList& properties, const QString& filterStr, const QStringList& sortProperties) -{ - QString queryStr = createQueryString (table, properties, filterStr, sortProperties); - int ret = 0; - -#ifdef _SQLITE_QMDBACKEND - QSqlQuery query(queryStr, m_db); - - while (query.next()) { - QVariantList row; - row.append(query.value(0)); // Id - for (int ii=1; ii<=properties.count(); ii++) { - row.append (query.value(ii)); - } - rows.append(row); ret++; - } -#else - // TODO: change into using int request (QVariantMap&) + a connections to void response (int, QVariant&) -signal - const QVariant data = m_db->sync(JsonDbConnection::makeQueryRequest(queryStr)); - const QVariantList list = data.toMap().value(QLatin1String("data")).toList(); - foreach (const QVariant &item, list) { - QVariantList row = item.toList(); - rows.append(row); ret++; - } - //qDebug () << "query count returned: " << ret; -#endif - return ret; -} - -#ifndef _SQLITE_QMDBACKEND -QVariant QMdLitePrivate::jsonDbCreate (JsonDbConnection *db, const QStringList& properties, const QVariantList& values) -{ - QVariantMap map; - for (int ii=0; ii<values.length(); ii++) { - map.insert (properties[ii], values[ii]); - } - const QVariant data = db->sync(JsonDbConnection::makeCreateRequest(map)); - const QVariantMap result = data.toMap(); - return result.value(QLatin1String("_uuid")); -} -#endif - -QVariant QMdLitePrivate::insert (const QString &table, QStringList& properties, QVariantList& values) -{ - Q_ASSERT (properties.length() == values.length()); - -#ifdef _SQLITE_QMDBACKEND - QString queryStr(QString::fromLatin1("INSERT INTO ").append(table).append(" (")); - queryStr.append(properties.join(", ")).append(") VALUES ("); - for (int ii=0; ii<values.length(); ii++) { - if (values.at(ii).isNull()) - queryStr.append("NULL"); - else if (values.at(ii).type() == QVariant::String) { - QString insStr = values.at(ii).toString(); - insStr.replace(QString("'"), QString("''")); - queryStr.append("'").append(insStr).append("'"); - } - else - queryStr.append(values.at(ii).toString()); - if (ii < values.length()-1) queryStr.append(", "); - } - queryStr.append(")"); - - //qDebug() << "Insert query: " << queryStr; - - QSqlQuery query(m_db); - bool ret = query.exec(queryStr); - quint32 insertId = -1; - - if (!ret) { - qDebug () << "Error: " << query.lastError().text() << " on insert query: " << queryStr; - return -1; - } - else { - insertId = query.lastInsertId().toInt(); - } - - return insertId; -#else - properties.prepend (QLatin1String("_type")); - values.prepend (table); - return QMdLitePrivate::jsonDbCreate (m_db, properties, values); -#endif -} - -bool QMdLitePrivate::update (const QString &table, QVariant id, const QStringList& properties, const QVariantList& values) -{ - Q_ASSERT (properties.length() == values.length()); -#ifdef _SQLITE_QMDBACKEND - QString queryStr(QString::fromLatin1("UPDATE ").append(table).append(" SET ")); - for (int ii=0; ii<properties.length(); ii++) { - if (values.at(ii).isNull()) - queryStr.append("=NULL"); - if (values.at(ii).type() == QVariant::String) { - QString updStr = values[ii].toString(); - updStr.replace(QString("'"), QString("''")); - queryStr.append(properties[ii]).append ("=").append("'").append(updStr).append("'"); - } - else - queryStr.append(properties[ii]).append ("=").append(values[ii].toString()); - if (ii < properties.length()-1) queryStr.append(","); - } - queryStr.append(" WHERE id = ").append(QString::number(id.toInt())); - //qDebug() << "Update query: " << queryStr; - - QSqlQuery query(m_db); - bool ret = query.exec(queryStr); - - if (!ret) - qDebug () << "Error: " << query.lastError().text() << " on update query: " << queryStr; - - return ret; -#else - //qDebug () << "Updating object: " << id << " of type " << table; - QString _uuid = id.toString(); - QString jsonQuery = QLatin1String("[?_type=\""); - jsonQuery.append(table).append(QLatin1String("\"][?_uuid=\"")).append(_uuid).append(QLatin1String("\"]")); - const QVariant data = m_db->sync(JsonDbConnection::makeQueryRequest(jsonQuery)); - const QVariantList list = data.toMap().value(QLatin1String("data")).toList(); - if (list.count() != 1) { - qDebug () << "Error on update: no object to be updated found, _uuid: " << id; - return false; - } - QVariantMap object; - object = list.at(0).toMap(); - qDebug () << "Updating object(2): " << object[QLatin1String("_uuid")] << " of type " << object[QLatin1String("_type")]; - for (int ii=0; ii<properties.length(); ii++) { - /*if (object.contains(properties[ii])) - qDebug () << " setting " << properties[ii] << " from " << object[properties[ii]] << " to " << values[ii]; - else - qDebug () << " adding " << properties[ii] << " with value " << values[ii];*/ - object[properties[ii]] = values[ii]; - } - const QVariant data2 = m_db->sync(JsonDbConnection::makeUpdateRequest(object)); - //qDebug () << "Update returned: " << data2; - return true; -#endif -} - -QString QMdLitePrivate::cleanStr (const QString &str) { - if (str.isNull() || str.length() < 1) return QString::fromLatin1(" "); - QString ret = str; - //QRegExp re("\\(.*\\)|\\{.*\\}|\\[.*\\]|<.*>|[\\(\\)_\\{\\}\\[\\]\\!@#$\\^&\\*\\+\\=\\|\\\\/\"'\\?~`]"); - QRegExp re(QLatin1String("[\\(\\)_\\{\\}\\[\\]\\!@#$\\^&\\*\\+\\=\\|\\\\/\"'\\?~`]")); - //QRegExp re2("\\ *"); - while (ret.length() != ret.replace(re, QLatin1String("")).length()) { - //while (ret.length() != ret.replace(re2, " ").length()); - } - return ret.toLower().simplified(); -} - -bool QMdLitePrivate::remove(const QString &table, QList<QVariant> &ids) -{ - Q_UNUSED(table) - - if (ids.length() < 1) - return true; - -#ifdef _SQLITE_QMDBACKEND - QStringList idStrs; - foreach (QVariant id, ids) { - QString numStr; numStr.setNum(id.toUInt()); - idStrs.append(numStr); - } - - QString queryStr(QString::fromLatin1("DELETE FROM ").append(table).append(" WHERE id IN (")); - queryStr.append(idStrs.join(", ")).append(")"); - - qDebug() << "Delete query: " << queryStr; - - QSqlQuery deleteQuery(queryStr, m_db); - bool ret = deleteQuery.exec(); - - if (!ret) qDebug () << "Error: " << deleteQuery.lastError().text() << " on delete."; - - return ret; -#else - foreach (QVariant id, ids) { - QVariantMap object; - object[QLatin1String("_uuid")] = id; - m_db->sync(JsonDbConnection::makeRemoveRequest(object)); - //m_jsonDbclient->remove(object); - } -#endif - return true; -} - -QFileInfoList QMdLitePrivate::listAllFiles (const QString& dirPath, const QStringList& filters) -{ - QDir files(dirPath); - //qDebug() << "listAllFiles: " << files.canonicalPath(); - files.setFilter(QDir::Files); - files.setNameFilters(filters); - QFileInfoList ret = files.entryInfoList(); - QDir directories(dirPath); - directories.setFilter(QDir::Dirs | QDir::NoDotAndDotDot); - QFileInfoList dirs = directories.entryInfoList(); - foreach (QFileInfo fi, dirs) { - ret.append(listAllFiles(fi.canonicalFilePath(), filters)); - } - return ret; -} - -QString QMdLitePrivate::dbDirName () -{ - QString ret = QDir::homePath(); - if (ret.isEmpty()) - ret = QString::fromLatin1("/krakatau"); - ret.append (QDir::separator()).append(QLatin1String(".qmdlite")); - - if (!QFile::exists (ret)) { - QDir dirO; - dirO.mkpath(ret); - } - //qDebug () << "dbDirName: " << ret; - //qDebug () << "current path: " << QDir::currentPath(); - return ret; -} - -bool QMdLitePrivate::openDb(const QString &dbPath, const QString &dbName) -{ -#ifdef _SQLITE_QMDBACKEND - // Find QSLite driver - m_db = QSqlDatabase::addDatabase("QSQLITE", dbName); - m_db.setDatabaseName(dbPath); - // Open database - return m_db.open(); -#else - Q_UNUSED(dbPath) - Q_UNUSED(dbName) -#endif - return true; -} - -QMdLite::QMdLite(QObject *parent) - : QObject(parent) -{ - //qDebug() << "QMdLite::QMdLite"; -} - -QMdLite::~QMdLite() -{ - //qDebug() << "QMdLite::~QMdLite"; -} diff --git a/src/gallery/simple/qmdlite.h b/src/gallery/simple/qmdlite.h deleted file mode 100644 index e5c20a9..0000000 --- a/src/gallery/simple/qmdlite.h +++ /dev/null @@ -1,106 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDocGallery module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QMDLITE_H -#define QMDLITE_H - -#include <QObject> -#include <QVariantList> -#include <QStringList> - -class QMdLiteQueryResultIf : public QObject -{ - Q_OBJECT - -public: - virtual ~QMdLiteQueryResultIf() {} - -protected: - // This is an abstract base class - QMdLiteQueryResultIf() {} - -public: - virtual int at() const = 0; - virtual bool first() = 0; - virtual bool isActive() const = 0; - virtual bool last() = 0; - virtual bool next() = 0; - virtual bool previous() = 0; - virtual bool seek(int index, bool relative = false, bool forceRefresh = false) = 0; - virtual int size() const = 0; - virtual bool isValid() const = 0; - virtual QVariant value(int index) const = 0; - -signals: - void rowChanged(quint32 index, int count); - void itemsInserted(int index, int count); - void itemsRemoved(int index, int count); -}; - -class QMdLite : public QObject -{ -public: - ~QMdLite(); - -protected: - // This is an abstract base class - QMdLite(QObject *parent = 0); - -public: - enum DBType { - SQLite, - JsonDB - }; - - virtual DBType dbType () = 0; - //virtual void *DBConnection() = 0; - - QString createQueryString(const QString &table, const QStringList &properties, - const QString &filterStr = QString(), - const QStringList &sortProperties = QStringList()); - int query(const QString &table, QList<QVariantList> &rows, const QStringList &properties = QStringList(), - const QString &filterStr = QString(), const QStringList &sortProperties = QStringList()); - bool remove(const QString &table, QList<quint32> &ids); - quint32 insert(const QString &table, const QStringList &properties, const QVariantList &values); - bool update(const QString &table, quint32 id, const QStringList &properties, const QVariantList &values); -}; - -#endif // QMDLITE_H diff --git a/src/gallery/simple/qmdlite_p.h b/src/gallery/simple/qmdlite_p.h deleted file mode 100644 index ce2b12d..0000000 --- a/src/gallery/simple/qmdlite_p.h +++ /dev/null @@ -1,102 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDocGallery module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QMDLITEPRIVATE_H -#define QMDLITEPRIVATE_H - -#include <QObject> -#include <QFile> -#include <QDir> -#include <QImage> -#include <QVariantList> -#include "qmdlite.h" - -#ifdef _SQLITE_QMDBACKEND -class QDqlDatabase; -#else -#include <private/jsondb-connection_p.h> -QT_ADDON_JSONDB_BEGIN_NAMESPACE -class JsonDbConnection; -QT_ADDON_JSONDB_END_NAMESPACE -QT_ADDON_JSONDB_USE_NAMESPACE -#endif - -class QMdLitePrivate : public QObject -{ - Q_OBJECT - -public: - QMdLitePrivate(); - ~QMdLitePrivate(); - - bool openDb(const QString &dbPath, const QString &dbName); - static QString sortProperties2String(const QStringList &sortProperties, bool ascending = true); - QString createQueryString(const QString &table, const QStringList& properties, - const QString &filterStr = QString(), - const QStringList&sortProperties = QStringList()); - int query(const QString &table, QList<QVariantList> &rows, const QStringList &properties = QStringList(), - const QString &filterStr = QString(), const QStringList &sortProperties = QStringList()); - bool remove(const QString &table, QList<QVariant> &ids); - QVariant insert(const QString &table, QStringList &properties, QVariantList &values); - bool update(const QString &table, QVariant id, const QStringList &properties, const QVariantList &values); - - static QString filterToString(const QString &tableName, const QString &filterStr = QString()); - static QString cleanStr(const QString &str); - static QFileInfoList listAllFiles(const QString &, const QStringList &); - static QString dbDirName(); - QMdLite::DBType dbType() - { -#ifdef _SQLITE_QMDBACKEND - return QMdLite::SQLite; -#else - return QMdLite::JsonDB; -#endif - } - -#ifdef _SQLITE_QMDBACKEND - QSqlDatabase m_db; -#else - JsonDbConnection *m_db; - static QVariant jsonDbCreate(JsonDbConnection *, const QStringList &, const QVariantList &); -#endif -}; - -#endif // QMDLITEPRIVATE_H diff --git a/src/gallery/simple/qmdlitemusic.cpp b/src/gallery/simple/qmdlitemusic.cpp deleted file mode 100644 index 878c2a7..0000000 --- a/src/gallery/simple/qmdlitemusic.cpp +++ /dev/null @@ -1,509 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDocGallery module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qmdlitemusic.h" -#include "qmdlitemusic_p.h" -#include "qmdlite_p.h" -#include <QtDebug> -#include <QCryptographicHash> -#include <QDateTime> -#include <QDesktopServices> -#include <QBuffer> -#include <QImage> - -#ifdef _SQLITE_QMDBACKEND - -#include "qmdlitequeryresultsqlite_p.h" -#include <QSqlQuery> - -#else - -#include "qmdlitequeryresultjsondb_p.h" -#include <private/jsondb-connection_p.h> -#include <jsondb-client.h> - -#endif - - -QString QMdLiteMusicPrivate::m_albumArtDir; - -QString QMdLiteMusicPrivate::musicAlbumArtDir () -{ - if (m_albumArtDir.isNull()) { - QString ret = dbDirName(); - ret.append(QDir::separator()).append(QLatin1String("album-art")).append(QDir::separator()); - ret = QDir::toNativeSeparators(ret); - if (!QFile::exists (ret)) { - QDir dirO; - dirO.mkpath(ret); - } - m_albumArtDir = ret; - } - return m_albumArtDir; -} - - //bool updateMusic = false; -#ifdef _SQLITE_QMDBACKEND -QMdLiteMusicPrivate::QMdLiteMusicPrivate (QMdLiteMusic *q) : m_q(q) -{ - QString mDbName = QMdLiteMusic::musicDbName(); - - //if (!QFile::exists(mDbName)) - //updateMusic = true; - if (!openDb (mDbName, "music")) - qWarning () << "Can not open the music database!" + m_db.lastError().text(); - else { - // Create the database, if not existing - QSqlQuery query(m_db); - // Note that due to clean_str the album url can not be unique at the moment (some albums might end up having the same cover) - ret = query.exec("CREATE TABLE IF NOT EXISTS albums " - "(id INTEGER PRIMARY KEY, " - "url TEXT, " - "title TEXT UNIQUE, " - "artist TEXT)"); - if (!ret) - qWarning() << query.lastError().text() << " on create table albums."; - ret = query.exec("CREATE TABLE IF NOT EXISTS songs " - "(id INTEGER PRIMARY KEY, " - "url TEXT UNIQUE, " - "albumId INTEGER, " - "trackNumber INTEGER, " - "title TEXT, " - "artist TEXT, " - "genre TEXT, " - "FOREIGN KEY(albumId) REFERENCES albums(id) ON DELETE CASCADE)" - ); - if (!ret) - qWarning() << query.lastError().text() << " on create table songs."; - - createMusicIndexes(); - - //if (updateMusic) - // _updateMusicDb(); - } -} -#else -QMdLiteMusicPrivate::QMdLiteMusicPrivate (QMdLiteMusic *q, JsonDbConnection *jsonDbConn) : m_q(q) -{ - if (jsonDbConn) { - //qDebug() << "QMdLiteMusicPrivate::QMdLiteMusicPrivate using: " << jsonDbConn; - m_db = jsonDbConn; - } - else { - //qDebug() << "QMdLiteMusicPrivate::QMdLiteMusicPrivate creating a JsonDbConnection"; - m_db = JsonDbConnection::instance(); - /*m_db = new JsonDbConnection; - qDebug() << "QMdLiteMusicPrivate::QMdLiteMusicPrivate connecting to the server"; - m_db->connectToServer();*/ - } -} -#endif - -QMdLiteMusicPrivate::~QMdLiteMusicPrivate () -{ -#ifdef _SQLITE_QMDBACKEND - m_db.close(); - QSqlDatabase::removeDatabase("music"); -#endif -} - -QString QMdLiteMusicPrivate::albumArtImageBaseName (const QString& albumArtist, const QString& title) -{ - QString helper = cleanStr (title); - QString ret = QString::fromLatin1(QCryptographicHash::hash ( helper.toLocal8Bit(), QCryptographicHash::Md5).toHex()); - helper = cleanStr(albumArtist); - ret.append(QLatin1String("-")).append(QString::fromLatin1(QCryptographicHash::hash ( helper.toLocal8Bit(), QCryptographicHash::Md5).toHex())); - return ret; -} - -QString QMdLiteMusicPrivate::albumArtImagePath (const QString& baseName) -{ - QString path = baseName; - path.append(QLatin1String(".jpeg")); - return path; -} - -QString QMdLiteMusicPrivate::albumArtImageCompressedPath (const QString& baseName) -{ - QString path = baseName; - path.append(QLatin1String(".pkm")); - return path; -} - -QString QMdLiteMusicPrivate::albumArtThumbnailImagePath (const QString& baseName) -{ - QString path = baseName; - path.append(QLatin1String("-thumbnail.ppm")); - return path; -} - -QString QMdLiteMusicPrivate::albumArtCompressedTexturePath (const QString& baseName) -{ - QString path = baseName; - path.append(QLatin1String("-thumbnail.pkm")); - return path; -} - -QMdLiteMusic::QMdLiteMusic(QObject *parent, JsonDbConnection *jsonDbConn) : - QMdLite(parent), d(new QMdLiteMusicPrivate (this, jsonDbConn)) -{ - //qDebug() << "QMdLiteMusic::QMdLiteMusic"; -} - -QMdLiteMusic::~QMdLiteMusic() -{ - //qDebug() << "QMdLiteMusic::~QMdLiteMusic"; -} - -QMdLite::DBType QMdLiteMusic::dbType() -{ - return d->dbType(); -} - -#ifndef _SQLITE_QMDBACKEND -QMdLiteQueryResultIf *QMdLiteMusic::createAlbumQuery (const QStringList& properties, const QString& filterStr, const QStringList& sortProperties) -{ - //QString jsonQuery = d->createQueryString("albums", properties, filterStr, sortProperties); - //return d->m_db.exec(sqlQueryStr); - QString type(cJsondbNamespace + QLatin1String("AlbumsView")); - QString baseQuery(QLatin1String("[?_type=\"") + cJsondbNamespace + QLatin1String("AlbumsView\"]")); - QStringList _properties; - _properties.append (QLatin1String("_uuid")); - foreach (QString property, properties) { - if (property.compare(QLatin1String("title"), Qt::CaseInsensitive) == 0) - _properties.append(QLatin1String("album.title")); - else if (property.compare(QLatin1String("artist"), Qt::CaseInsensitive) == 0) - _properties.append(QLatin1String("artistToDisplay")); - else if (property.compare(QLatin1String("albumArtist"), Qt::CaseInsensitive) == 0) - _properties.append(QLatin1String("album.artist")); - else - _properties.append (property); - } - QStringList _sortProperties; - foreach (QString sortProperty, sortProperties) { - if (sortProperty.compare(QLatin1String("title"), Qt::CaseInsensitive) == 0) - _sortProperties.append(QLatin1String("album.title")); - else if (sortProperty.compare(QLatin1String("artist"), Qt::CaseInsensitive) == 0) - _sortProperties.append(QLatin1String("artistToDisplay")); - else if (sortProperty.compare(QLatin1String("albumArtist"), Qt::CaseInsensitive) == 0) - _sortProperties.append(QLatin1String("album.artist")); - else - _sortProperties.append (sortProperty); - } - QMdLiteQueryResult *query = - new QMdLiteQueryResult(d->m_db, type, baseQuery, filterStr, _properties, _sortProperties); - return query; -} - -// -QMdLiteQueryResultIf *QMdLiteMusic::createArtistAlbumsQuery (const QString& artist, const QString& filterStr) -{ - /*QString artistCleaned(artist); - artistCleaned.replace(QString("'"), QString("''")); - // Always read id - QString sqlQueryStr("SELECT songs.albumId, songs.artist, COUNT(*), COUNT(*), albums.title, albums.url " - "FROM songs, albums WHERE " - "songs.albumId = albums.id AND songs.artist = '"); - sqlQueryStr.append(artistCleaned).append("'"); - if (!filterStr.isEmpty()) { - sqlQueryStr.append(" ").append(filterStr); - } - sqlQueryStr.append(" GROUP BY songs.albumId ORDER BY albums.title"); - return d->m_db.exec(sqlQueryStr);*/ - QString artistCleaned = artist; - artistCleaned.replace(QLatin1String("\""), QLatin1String("\\\"")); - artistCleaned.replace(QLatin1String("\\"), QLatin1String("\\\\")); - QString type(cJsondbNamespace + QLatin1String("AlbumsOfArtistsView")); - QString baseQuery(QLatin1String("[?_type=\"") + cJsondbNamespace + QLatin1String("AlbumsOfArtistsView\"][?artist=\"")); - baseQuery.append(artistCleaned).append (QLatin1String("\"]")); - QStringList _properties; - _properties.append(QLatin1String("_uuid")); - _properties.append(QLatin1String("artist")); - _properties.append(QLatin1String("songCount")); - _properties.append(QLatin1String("album.artist")); - _properties.append(QLatin1String("album.title")); - _properties.append(QLatin1String("albumArt")); - //_properties.append(QLatin1String("albumId")); - QStringList _sortProperties; - _sortProperties.append(QLatin1String("album.title")); - - QMdLiteQueryResult *query = - new QMdLiteQueryResult(d->m_db, type, baseQuery, filterStr, _properties, _sortProperties); - //qDebug () << "createArtistAlbumsQuery: " << baseQuery << ", " << filterStr << ", " << _properties << ", " << _sortProperties; - return query; -} - -// -QMdLiteQueryResultIf *QMdLiteMusic::createArtistQuery (const QString& filterStr) -{ - /* - // SELECT id, GROUP_CONCAT(url, ",,"), GROUP_CONCAT(title, ",,"), artist, COUNT(*) FROM albums GROUP BY artist ORDER BY artist - // Always read id - QString sqlQueryStr("SELECT songs.id, songs.artist, COUNT(*), COUNT(DISTINCT albums.title), GROUP_CONCAT(albums.title, ',,'), GROUP_CONCAT(albums.url, ',,') " - "FROM songs, albums WHERE songs.albumId = albums.id "); - if (!filterStr.isEmpty()) { - sqlQueryStr.append(" AND ").append(filterStr); - } - sqlQueryStr.append(" GROUP BY songs.artist ORDER BY songs.artist"); - return d->m_db.exec(sqlQueryStr); - - QString jsonQuery(QLatin1String()); - */ - QString type(cJsondbNamespace + QLatin1String("ArtistsView")); - QString baseQuery(QLatin1String("[?_type=\"") + cJsondbNamespace + QLatin1String("ArtistsView\"]")); - QStringList _properties; - _properties.append (QLatin1String("_uuid")); - _properties.append(QLatin1String("artist")); - _properties.append(QLatin1String("songCount")); - _properties.append(QLatin1String("albums")); - _properties.append(QLatin1String("covers")); - QStringList _sortProperties; - _sortProperties.append (QLatin1String("artist")); - QMdLiteQueryResult *query = - new QMdLiteQueryResult(d->m_db, type, baseQuery, filterStr, _properties, _sortProperties); - //qDebug () << "createArtistQuery: " << baseQuery << ", " << filterStr << ", " << _properties << ", " << _sortProperties; - return query; -} - -QMdLiteQueryResultIf *QMdLiteMusic::createMusicQuery (const QStringList& properties, const QString& filterStr, const QStringList& sortProperties) -{ - // [?_type="songs"][?title=~"/*searchstr*/wi"][= albumId->title, albumId->artist, albumId->url][/title] - // [?_type="songs"][?albumId->title=~"/*searchstr*/wi"][= albumId->title, albumId->artist, albumId->url][/title] - - QStringList _properties; - _properties.append(QLatin1String("_uuid")); - foreach (QString property, properties) { - if (property.compare(QLatin1String("albumTitle"), Qt::CaseInsensitive) == 0) - _properties.append(QLatin1String("album.title")); - else if (property.compare(QLatin1String("albumArtist"), Qt::CaseInsensitive) == 0) - _properties.append(QLatin1String("album.artist")); - else - _properties.append(property); - } - _properties.append(QLatin1String("_uuid")); - QStringList _sortProperties; - foreach (QString sortProperty, sortProperties) { - if (sortProperty.compare(QLatin1String("albumTitle"), Qt::CaseInsensitive) == 0) - _sortProperties.append(QLatin1String("album.title")); - else if (sortProperty.compare(QLatin1String("albumArtist"), Qt::CaseInsensitive) == 0) - _sortProperties.append(QLatin1String("album.artist")); - else - _sortProperties.append(sortProperty); - } - - QString type(cJsondbNamespace + QLatin1String("SongsView")); - QString baseQuery(QLatin1String("[?_type=\"") + cJsondbNamespace + QLatin1String("SongsView\"]")); - //qDebug () << "createMusicQuery: " << baseQuery << ", " << filterStr << ", " << _properties; - QMdLiteQueryResult *query = - new QMdLiteQueryResult(d->m_db, type, baseQuery, filterStr, _properties, _sortProperties); - return query; -} - -#else - -QMdLiteQueryResult QMdLiteMusic::createAlbumQuery (const QStringList& properties, const QString& filterStr, const QStringList& sortProperties) -{ - QString sqlQueryStr = d->createQueryString("albums", properties, filterStr, sortProperties); - QSqlQuery q = d->m_db.exec(sqlQueryStr); - if (!q.isActive()) - qWarning () << "Error: " << q.lastError().text() << " on album query."; - return QMdLiteQueryResult(new QMdLiteSqlQueryResult (q)); -} - -// -/*QSqlQuery QMdLiteMusic::createAlbumArtistQuery (const QString& artist, const QString& filterStr) -{ - // Always read id - QString sqlQueryStr("SELECT id, artist, COUNT(*), GROUP_CONCAT(albums.title, ',,'), GROUP_CONCAT(albums.url, ',,') " - "FROM songs, albums GROUP BY songs.albumId ORDER BY artist WHERE " - "songs.albuId = albums.id AND songs.artist = "); - sqlQueryStr.append(artist); - if (!filterStr.isEmpty()) { - sqlQueryStr.append(" ").append(filterStr); - } - QSqlQuery q = d->m_db.exec(sqlQueryStr); - if (!q.isActive()) - qWarning () << "Error: " << q.lastError().text() << " on album query."; - return QMdLiteSqlQueryResult (q); -}*/ - -// -QMdLiteQueryResult QMdLiteMusic::createArtistAlbumsQuery (const QString& artist, const QString& filterStr) -{ - QString artistCleaned(artist); - artistCleaned.replace(QString("'"), QString("''")); - // Always read id - QString sqlQueryStr("SELECT songs.albumId, songs.artist, COUNT(*), COUNT(*), albums.title, albums.url " - "FROM songs, albums WHERE " - "songs.albumId = albums.id AND songs.artist = '"); - sqlQueryStr.append(artistCleaned).append("'"); - if (!filterStr.isEmpty()) { - sqlQueryStr.append(" ").append(filterStr); - } - sqlQueryStr.append(" GROUP BY songs.albumId ORDER BY albums.title"); - QSqlQuery q = d->m_db.exec(sqlQueryStr); - if (!q.isActive()) - qWarning () << "Error: " << q.lastError().text() << " on artists albums query."; - return QMdLiteQueryResult(new QMdLiteSqlQueryResult (q)); -} - - -// -QMdLiteQueryResult QMdLiteMusic::createArtistQuery (const QString& filterStr) -{ - // SELECT id, GROUP_CONCAT(url, ",,"), GROUP_CONCAT(title, ",,"), artist, COUNT(*) FROM albums GROUP BY artist ORDER BY artist - // Always read id - QString sqlQueryStr("SELECT songs.id, songs.artist, COUNT(*), COUNT(DISTINCT albums.title), GROUP_CONCAT(albums.title, ',,'), GROUP_CONCAT(albums.url, ',,') " - "FROM songs, albums WHERE songs.albumId = albums.id "); - if (!filterStr.isEmpty()) { - sqlQueryStr.append(" AND ").append(filterStr); - } - sqlQueryStr.append(" GROUP BY songs.artist ORDER BY songs.artist"); - QSqlQuery q = d->m_db.exec(sqlQueryStr); - if (!q.isActive()) - qWarning () << "Error: " << q.lastError().text() << " on artist query."; - return QMdLiteQueryResult(new QMdLiteSqlQueryResult (q)); -} - -// -QMdLiteQueryResult QMdLiteMusic::createMusicQuery (const QStringList& properties, const QString& filterStr, const QStringList& sortProperties) -{ - // Always read id - QString sqlQueryStr("SELECT songs.id"); - bool joinAlbumTable = false; - foreach (QString property, properties) { - sqlQueryStr.append(", "); - if (property.compare("albumTitle", Qt::CaseInsensitive) == 0) { - joinAlbumTable = true; - sqlQueryStr.append("albums.title"); - } - else if (property.compare("albumArtist", Qt::CaseInsensitive) == 0) { - joinAlbumTable = true; - sqlQueryStr.append("albums.artist"); - } - else if (property.compare("albumCover", Qt::CaseInsensitive) == 0) { - joinAlbumTable = true; - sqlQueryStr.append("albums.url"); - } - else - sqlQueryStr.append("songs.").append(property); - } - - sqlQueryStr.append(" FROM songs"); - if (joinAlbumTable) { - sqlQueryStr.append(", albums"); - } - - - if (filterStr.length() > 0) { - sqlQueryStr.append(" WHERE "); - sqlQueryStr.append(filterStr); - if (joinAlbumTable) { - sqlQueryStr.append(" AND songs.albumId=albums.id"); - } - } - else if (joinAlbumTable) { - sqlQueryStr.append(" WHERE songs.albumId=albums.id"); - } - if (sortProperties.count() > 0) { - sqlQueryStr.append(" ORDER BY "); - if (joinAlbumTable) { - bool beg = true; - foreach (QString property, sortProperties) { - if (!beg) - sqlQueryStr.append(", "); - else beg = false; - if (property.compare("albumTitle", Qt::CaseInsensitive) == 0) { - joinAlbumTable = true; - sqlQueryStr.append("albums.title"); - } - else if (property.compare("albumArtist", Qt::CaseInsensitive) == 0) { - joinAlbumTable = true; - sqlQueryStr.append("albums.artist"); - } - else if (property.compare("albumCover", Qt::CaseInsensitive) == 0) { - joinAlbumTable = true; - sqlQueryStr.append("albums.url"); - } - else - sqlQueryStr.append("songs.").append(property); - } - - } - else - sqlQueryStr.append(sortProperties.join(", ")); - } - //qDebug () << "Music query: " << sqlQueryStr; - QSqlQuery q = d->m_db.exec(sqlQueryStr); - if (!q.isActive()) - qWarning () << "Error: " << q.lastError().text() << " on music query."; - return QMdLiteQueryResult(new QMdLiteSqlQueryResult (q)); -} - -#endif - -/*QString QMdLiteMusic::albumArtImagePath (const QString& title) -{ - QString imageBaseName = QMdLiteMusicPrivate::albumArtImageBaseName(title); - QString imageName = QMdLiteMusicPrivate::albumArtImagePath(QMdLiteMusicPrivate::musicAlbumArtDir()+imageBaseName); - return imageName; -} - -QString QMdLiteMusic::albumArtThumbnailImagePath (const QString& title) -{ - QString imageBaseName = QMdLiteMusicPrivate::albumArtImageBaseName(title); - QString thumbnailName; - -#ifdef QT_OPENGL_ES - thumbnailName = QMdLiteMusicPrivate::albumArtCompressedTexturePath(QMdLiteMusicPrivate::musicAlbumArtDir()+imageBaseName); - if (!QFile::exists(thumbnailName)) { - thumbnailName = QMdLiteMusicPrivate::albumArtCompressedTexturePath(QString::fromLatin1(":/image/default")); - } -#else - thumbnailName = QMdLiteMusicPrivate::albumArtThumbnailImagePath(QMdLiteMusicPrivate::musicAlbumArtDir()+imageBaseName); - if (!QFile::exists(thumbnailName)) { - thumbnailName = QMdLiteMusicPrivate::albumArtThumbnailImagePath(QString::fromLatin1(":/image/default")); - } -#endif - //qDebug() << "albumArtThumbnailImagePath returning: " << thumbnailName; - - return thumbnailName; -}*/ diff --git a/src/gallery/simple/qmdlitemusic.h b/src/gallery/simple/qmdlitemusic.h deleted file mode 100644 index b2d8d49..0000000 --- a/src/gallery/simple/qmdlitemusic.h +++ /dev/null @@ -1,83 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDocGallery module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QMDLITEMUSIC_H -#define QMDLITEMUSIC_H - -#include <QString> -#include <private/jsondb-connection_p.h> -#include "qmdlite.h" - -const QString cJsondbNamespace = QLatin1String("com.nokia.mp.content."); - -class QMdLiteMusicPrivate; -QT_ADDON_JSONDB_BEGIN_NAMESPACE -class JsonDbConnection; -QT_ADDON_JSONDB_END_NAMESPACE - -QT_ADDON_JSONDB_USE_NAMESPACE - -class QMdLiteMusic : public QMdLite -{ - Q_OBJECT - -public: - explicit QMdLiteMusic(QObject *parent = 0, JsonDbConnection *jsonDbConn = 0); - ~QMdLiteMusic(); - - QMdLiteQueryResultIf *createAlbumQuery(const QStringList &properties, const QString &filterStr = QString(), - const QStringList &sortProperties = QStringList()); - //QMdLiteQueryResult *createAlbumArtistQuery(const QString &filterStr = QString()); - QMdLiteQueryResultIf *createArtistQuery(const QString &filterStr = QString()); - QMdLiteQueryResultIf *createArtistAlbumsQuery(const QString &artist, const QString &filterStr); - QMdLiteQueryResultIf *createMusicQuery(const QStringList &properties, const QString &filterStr = QString(), - const QStringList &sortProperties = QStringList()); - - QMdLite::DBType dbType(); - -private: - friend class QMdLiteMusicPrivate; - QScopedPointer<QMdLiteMusicPrivate> d; - - Q_DISABLE_COPY(QMdLiteMusic) -}; - -#endif // QMDLITEMUSIC_H diff --git a/src/gallery/simple/qmdlitemusic_p.h b/src/gallery/simple/qmdlitemusic_p.h deleted file mode 100644 index 4bb28d8..0000000 --- a/src/gallery/simple/qmdlitemusic_p.h +++ /dev/null @@ -1,87 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDocGallery module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QMDLITEMUSIC_P_H -#define QMDLITEMUSIC_P_H - -#include <private/jsondb-connection_p.h> -#include <jsondb-client.h> -#include "qmdlite_p.h" - -#include <QFileInfoList> - -class QMdLiteMusic; - -QT_ADDON_JSONDB_BEGIN_NAMESPACE -class JsonDbConnection; -class JsonDbClient; -QT_ADDON_JSONDB_END_NAMESPACE - -QT_ADDON_JSONDB_USE_NAMESPACE - -class QMdLiteMusicPrivate : public QMdLitePrivate -{ - Q_OBJECT - -public: -#ifdef _SQLITE_QMDBACKEND - QMdLiteMusicPrivate(QMdLiteMusic *q); -#else - QMdLiteMusicPrivate(QMdLiteMusic *q, JsonDbConnection *jsonDbConn); -#endif - ~QMdLiteMusicPrivate(); - static QString albumArtImageBaseName(const QString &albumArtist, const QString &title); - static QString albumArtImagePath(const QString &); // 512x512 - static QString albumArtImageCompressedPath(const QString &); // 512x512 .pkm - static QString albumArtThumbnailImagePath(const QString &); // 128x128 - static QString albumArtCompressedTexturePath(const QString &); // 128x128 .pkm file - static QString musicAlbumArtDir(); - - int m_fileCount; - int m_albumCount; - int m_updateProgress; - - static QString m_albumArtDir; - - QMdLiteMusic *m_q; -}; - -#endif // QMDLITEMUSIC_P_H diff --git a/src/gallery/simple/qmdlitequeryresultjsondb.cpp b/src/gallery/simple/qmdlitequeryresultjsondb.cpp deleted file mode 100644 index 93e5811..0000000 --- a/src/gallery/simple/qmdlitequeryresultjsondb.cpp +++ /dev/null @@ -1,693 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDocGallery module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qmdlite_p.h" -#include "qmdlitequeryresultjsondb_p.h" - -#include <private/jsondb-connection_p.h> -#include <jsondb-client.h> -#include <private/jsondb-strings_p.h> - -#include <QStringList> -#include <QTime> - -QMdLiteQueryResultPrivate::QMdLiteQueryResultPrivate -(QMdLiteQueryResult *q, JsonDbConnection *jdbCon, const QString& type, const QString& baseQuery, - const QString& filterStr, const QStringList& properties, const QStringList& sortProperties, bool chunk) : - m_type(type), m_baseQuery(baseQuery), - m_filterString(filterStr), m_properties(properties), - m_sortProperties(sortProperties), m_count(0), m_index(-1), - m_chunk(chunk), m_valid(false), m_itemsInsertedSent(false), m_cache_start(-1), m_requestPending(false), - m_jsonDbConnection(jdbCon), m_q(q) -{ - m_jsonDbClient = new JsonDbClient(jdbCon); - - //qDebug () << "JsonDb client " << m_jsonDbClient << " created."; - connect(m_jsonDbClient, SIGNAL(response(int, const QVariant&)), this, - SLOT(jsonDbResponse(int, const QVariant&))); - connect(m_jsonDbClient, SIGNAL(error( int, int, const QString&)), - this, SLOT(jsonDbError(int, int, const QString&))); - connect(m_jsonDbClient, SIGNAL(notified(const QString&,const QVariant&,const QString&)), - this, SLOT(jsonDbNotified(const QString&,const QVariant&,const QString&))); - //qDebug () << "Slots connected."; - - QString query = m_baseQuery; - if (!m_filterString.isEmpty()) query.append(m_filterString); - if (m_chunk) { - query.append(QLatin1String("[count]")); - } - else { - query.append(QMdLitePrivate::sortProperties2String (m_sortProperties)); - query.append(QLatin1String("[=")).append(JsonDbString::kUuidStr).append(QLatin1String("]")); - } - //qDebug () << "Sending query:" << query; - m_countRequestId.append(m_jsonDbClient->query(query)); - //const QVariant data = m_jsonDbConnection->sync(JsonDbConnection::makeQueryRequest(query)); - - // Create the notification object - QStringList notificationProperties; - notificationProperties << QLatin1String ("_type") << QLatin1String ("query") << QLatin1String ("actions"); - QVariantList notificationValues; - notificationValues << QLatin1String ("notification") << m_baseQuery.append(m_filterString); - QVariantList actions; - actions << QLatin1String ("create") << QLatin1String ("update") << QLatin1String ("remove"); - notificationValues << QVariant(actions); - QVariantMap map; - for (int ii=0; ii<notificationValues.length(); ii++) { - map.insert (notificationProperties[ii], notificationValues[ii]); - } - //qDebug () << "Creating:" << map; - m_notifRequestId = m_jsonDbClient->create(map); -} - -void QMdLiteQueryResultPrivate::handleCountAndNotifRequest (int id, const QVariant &v) -{ - //QTime t; - //t.start(); - - int idx = -1; - if ((idx = m_countRequestId.indexOf(id)) >= 0) { - for (int ii=0; ii<=idx; ii++) - m_countRequestId.removeAt(ii); - const QVariantList list = v.toMap().value(QLatin1String("data")).toList(); - if (m_chunk) { - m_count = list.at(0).toMap().value(QLatin1String("count")).toInt(); - } - else { - QStringList newUuids; - foreach (const QVariant &item, list) { - QString id = item.toString(); - newUuids.append(id); - } - bool bruteForce = false; - if (!m_count) bruteForce = true; - else if ((quint32)newUuids.count() > m_count) { - // Objects added - // Sorting should be the same - //qDebug () << "(optimized) newCount is " << newUuids.count() << ", m_count: " << m_count; - - QList<quint32> insertedItems; - for (quint32 ii=0; ii<(quint32)newUuids.count(); ii++) { - if ((quint32)m_uuids.count() > ii && newUuids[ii] == m_uuids[ii]) continue; - else {//if (newUuids[ii] == m_insertedObject[QLatin1String("_uuid")]){ - m_uuids.insert(ii, newUuids[ii]); - insertedItems.append (ii); - if (m_index >= (int)ii) m_index++; - QMap<quint32, quint64>::iterator voidIs; - for (voidIs = m_voidIndexes.begin(); voidIs != m_voidIndexes.end(); ++voidIs) { - if (voidIs.key() >= ii) { - quint32 key = voidIs.key(); - quint64 stamp = voidIs.value(); - m_voidIndexes.remove (key); - key++; - m_voidIndexes[key] = stamp; - } - } - QVariantMap newObject = m_insertedObjects.take(newUuids[ii]); - if (in_cache(ii)) { - //qDebug () << "index: " << ii << "_uuid: " << newUuids[ii] << " is in cache"; - QVariantList newRow; - if (!newObject.isEmpty()) { - //qDebug () << "Found object from insertedObjects"; - for (int jj=0; jj<m_properties.count(); jj++) { - newRow.append(newObject[m_properties.at(jj)]); - } - m_row_cache.insert(ii-m_cache_start, newRow); - if ((int)ii>m_index) - m_row_cache.removeLast(); - else { - m_row_cache.removeFirst(); - m_cache_start++; - } - } - else { - qDebug () << "Warning: New object not found from inserted objects."; - m_q->seek(m_index, false, true); - } - } - else if (m_cache_start >= (qint32)ii) { - m_cache_start++; - } - } - } - m_count = m_uuids.count(); - //qDebug () << "(optimized) Setting count to " << m_count; - - if (insertedItems.count()) { - quint32 firstIndex = insertedItems[0], count = 1; - for (int ii=1; ii<insertedItems.count(); ii++) { - if (insertedItems[ii] == firstIndex+count) { - count++; - continue; - } - else { - //qDebug () << "itemsInserted: " << firstIndex << ", count: " << count; - emit m_q->itemsInserted(firstIndex, count); - firstIndex = insertedItems[ii]; count = 1; - } - } - if (count) { - //qDebug () << "itemsInserted: " << firstIndex << ", count: " << count; - emit m_q->itemsInserted(firstIndex, count); - } - } - } - else if ((quint32)newUuids.count() < m_count) { - // Objects removed - // Sorting should be the same - //qDebug () << "(optimized) newCount is " << newUuids.count() << ", m_count: " << m_count; - - QList<quint32> removedItems; - for (quint32 ii=0; ii<(quint32)m_uuids.count(); ii++) { - if ((quint32)newUuids.count() > ii && newUuids[ii] == m_uuids[ii]) continue; - else { - m_uuids.removeAt(ii); - m_count--; - removedItems.append (ii); - if (in_cache(ii)) { - m_row_cache.removeAt (ii-m_cache_start); - // TODO: Should maybe add an item to the end of the cache? - } - else if (m_cache_start > (qint32)ii) m_cache_start--; - } - } - //qDebug () << "(optimized) Setting count to " << m_count; - - if (removedItems.count()) { - quint32 firstIndex = removedItems[0], count = 1; - for (int ii=1; ii<removedItems.count(); ii++) { - if (removedItems[ii] == firstIndex+count) { - count++; - continue; - } - else { - //qDebug () << "itemsRemoved: " << firstIndex << ", count: " << count; - emit m_q->itemsRemoved(firstIndex, count); - firstIndex = removedItems[ii]; count = 1; - } - } - if (count) { - //qDebug () << "itemsRemoved: " << firstIndex << ", count: " << count; - emit m_q->itemsRemoved(firstIndex, count); - } - } - } - else { - //qDebug () << "Same count, do nothing."; - bruteForce = false; - } - - if (bruteForce) { - // Brute-Force method... - m_row_cache.clear(); - m_cache_start = -1; - m_uuids.clear(); - bool firstCountrequest = m_count == 0; - if (m_count) { - quint32 count = m_count; - m_count = 0; - emit m_q->itemsRemoved(0, count); - } - m_uuids = newUuids; - m_count = m_uuids.count(); - //qDebug () << "(Brute-Force) Setting count to " << m_count; - if (!firstCountrequest && m_count) { - // For first request send itemsInserted only when real rows received - emit m_q->itemsInserted (0, m_count); - m_itemsInsertedSent = true; - } - else - m_q->seek(0); - - //m_q->seek (m_index); - } - } - m_valid = true; - } - else if (id == m_notifRequestId) { - const QVariantMap result = v.toMap(); - m_notifUuid = result.value(QLatin1String("_uuid")).toString(); - //qDebug () << "Notification object " << m_notifUuid << " created."; - m_notifRequestId = 0; - } - else { - // Most probably an 'old' count request - // and we want to use always the latest one - qDebug () << "Count/notif request skipped."; - } - //qDebug () << "Handling the count/notif request took: " << t.elapsed() << " milliseconds."; -} - -QMdLiteQueryResultPrivate::~QMdLiteQueryResultPrivate () -{ - //qDebug () << "JsonDb client " << m_jsonDbClient << " to be deleted."; - - //Delete the notification object - if (!m_notifUuid.isEmpty()) { - QVariantMap object; - object[QLatin1String("_uuid")] = m_notifUuid; - //qDebug () << "Notification object " << m_notifUuid << " to be deleted."; - - m_jsonDbClient->remove(object); - } - delete m_jsonDbClient; -} - -void QMdLiteQueryResultPrivate::jsonDbError(int id, int code, const QString& message) -{ - qDebug () << "jsonDbError, id: " << id << ", code: " << code << ", message: " << message; -} - -void QMdLiteQueryResultPrivate::jsonDbNotified(const QString& _uuid, const QVariant& object, const QString& action) -{ - //QTime t; - //t.start(); - - QVariantMap obj = object.toMap(); - // Hack. TODO: think how the subobjects would be handled better - // Now hardcoded the album subobject handling here - if (obj.value(QLatin1String("album")).isValid()) { - QVariantMap album = obj.take(QLatin1String("album")).toMap(); - obj[QLatin1String("album.title")] = album[QLatin1String("title")]; - obj[QLatin1String("album.artist")] = album[QLatin1String("artist")]; - } - - // TODO: cancel the old count request, if new is needed. - //if (m_countRequestId > 0) return; - - if (action == QLatin1String("create")) { - if (obj[QLatin1String("_type")].toString() != m_type) { - //qDebug() << "(create) Non-relevant notification sent by jsondb. Ignored. " << m_type << ", " << obj[QLatin1String("_type")].toString(); - return; - } - if (m_chunk) { - // Brute-Force method... - m_row_cache.clear(); - emit m_q->itemsRemoved (0, m_count); - m_count++; - emit m_q->itemsInserted (0, m_count); - } - else { - QString query = m_baseQuery; - if (!m_filterString.isEmpty()) query.append(m_filterString); - query.append(QMdLitePrivate::sortProperties2String (m_sortProperties)); - query.append(QLatin1String("[=")).append(JsonDbString::kUuidStr).append(QLatin1String("]")); - - //qDebug () << "Insert _uuid: " << obj[QLatin1String("_uuid")] << " into insertedObjects. Type: " << obj[QLatin1String("_type")]; - m_insertedObjects.insert(obj[QLatin1String("_uuid")].toString(), obj); - //if (!m_countRequestId) - //qDebug() << "Create: " << _uuid << ", " << m_baseQuery << ", inserted objects count: " << m_insertedObjects.count(); - m_countRequestId.append(m_jsonDbClient->query(query)); - //qDebug () << "Handling the notified (create) took: " << t.elapsed() << " milliseconds."; - } - } - else if (action == QLatin1String("update")) { - if (obj[QLatin1String("_type")].toString() != m_type) { - //qDebug() << "(update) Non-relevant notification sent by jsondb. Ignored. " << m_type << ", " << obj[QLatin1String("_type")].toString(); - return; - } - // Check if the changed item is in the cache - if (m_cache_start > -1 && m_row_cache.count() > 0) { - if (m_chunk) { - quint32 idx = m_cache_start; - foreach (QVariantList row, m_row_cache) { - if (!row.isEmpty()) { - // NOTE: _uuid must be the first item for this to work - if (row.first().toString() == obj[QLatin1String("_uuid")]) { - //qDebug () << "_uuid: " << obj[QLatin1String("_uuid")] << " updated."; - if (in_cache(idx)) { - for (int ii=0; ii<m_properties.count(); ii++) { - if (m_row_cache[idx-m_cache_start].count() < ii+1) - m_row_cache[idx-m_cache_start].append (obj[m_properties.at(ii)]); - else - m_row_cache[idx-m_cache_start][ii] = obj[m_properties.at(ii)]; - } - //qDebug () << "rowChanged: " << idx; - emit m_q->rowChanged(idx, 1); - } - //if (m_requestPending) - // Not sure, if this works... - //m_voidIndexes.insert(idx, QDateTime::currentMSecsSinceEpoch ()); - return; - } - idx++; - } - } - } - else { - quint32 idx = 0; - foreach (QString uuid, m_uuids) { - if (uuid == obj[QLatin1String("_uuid")]) { - if (in_cache(idx)) { - for (int ii=0; ii<m_properties.count(); ii++) { - if (m_row_cache[idx-m_cache_start].count() < ii+1) - m_row_cache[idx-m_cache_start].append (obj[m_properties.at(ii)]); - else - m_row_cache[idx-m_cache_start][ii] = obj[m_properties.at(ii)]; - } - emit m_q->rowChanged(idx, 1); - //if (m_requestPending) - // Not sure, if this works - //m_voidIndexes.insert(idx, QDateTime::currentMSecsSinceEpoch ()); - } - //qDebug () << "Handling the notified (update) took: " << t.elapsed() << " milliseconds."; - return; - } - idx++; - } - } - } - //qDebug () << "jsonDbNotification, _uuid: " << _uuid << ", object id: " << obj[QLatin1String("_uuid")] << ", action: " << action; - } - else if (action == QLatin1String("remove")) { - if (m_chunk) { - // Brute-Force method... - emit m_q->itemsRemoved (0, m_count); - m_count--; - emit m_q->itemsInserted (0, m_count); - } - else { - QString query = m_baseQuery; - if (!m_filterString.isEmpty()) query.append(m_filterString); - query.append(QMdLitePrivate::sortProperties2String (m_sortProperties)); - query.append(QLatin1String("[=")).append(JsonDbString::kUuidStr).append(QLatin1String("]")); - m_removedObjects.insert(obj[QLatin1String("_uuid")].toString(), obj); - //if (!m_countRequestId) - m_countRequestId.append(m_jsonDbClient->query(query)); - //qDebug () << "(Remove) Setting count request id to " << m_countRequestId; - } - } - else - qDebug () << "qtm-gallery: jsonDbNotification, _uuid: " << _uuid << ", object id: " << obj[QLatin1String("_uuid")] << ", action: " << action; -} - -void QMdLiteQueryResultPrivate::jsonDbResponse(int id, const QVariant &v) -{ - - if (m_countRequestId.contains(id) || id == m_notifRequestId) { - handleCountAndNotifRequest(id, v); - return; - } - if (!m_requestPending) { - // Most probably an 'old' count request - // and we want to use always the latest one - qDebug () << "Request skipped."; - return; - } - //QTime t; - //t.start(); - - QList<QVariantList> newRows; - QVariantMap m = v.toMap(); - //qDebug () << "Response: " << v; - //qDebug () << "toMap: " << m; - if (m.contains(QLatin1String("data"))) { - QVariantList data = m.value(QLatin1String("data")).toList(); - //qDebug () << "data: " << data; - foreach (QVariant item, data) { - QVariantList row = item.toList(); - newRows.append(row); - } - } - else { - qDebug() << "Illegal response from JsonDB. No data found."; - return; - } - - // Add new rows to cache - if (m_requestOffset < m_cache_start) { - // remove the unneeded entries - int removed = 0; - while (!m_row_cache.isEmpty() && m_row_cache.count()+newRows.count() > CACHE_SIZE) { - m_row_cache.removeLast(); removed++; - } - //qDebug() << "Removed " << removed <<" rows from the end of the cache."; - //qDebug() << "Adding rows from: " << m_requestOffset <<", to: " << m_requestOffset+m_requestLimit << " to the beginning of cache."; - while (!newRows.isEmpty()) - m_row_cache.prepend(newRows.takeLast()); - m_cache_start = m_requestOffset; - //emit m_q->rowChanged(m_requestOffset, m_requestLimit); - } - else { - if (m_cache_start > -1 && m_row_cache.count() > 0) { - // remove the unneeded entries - int removed = 0; - while (!m_row_cache.isEmpty() && m_row_cache.count()+newRows.count() > CACHE_SIZE) { - m_row_cache.removeFirst(); - m_cache_start++; removed++; - } - //qDebug() << "Removed " << removed <<" rows from the beginning of the cache."; - } - else m_cache_start = m_requestOffset; - //qDebug() << "Adding rows from: " << m_requestOffset <<", to: " << m_requestOffset+m_requestLimit << " to the end of the cache."; - m_row_cache.append(newRows); - //emit m_q->rowChanged(m_requestOffset, m_requestLimit); - //m_cache_start += m_requestLimit; - } - //qDebug () << "m_cacheStart: " << m_cache_start << ", count: " << m_row_cache.count(); - // Do something with void indexes - quint64 latestSeek = m_requestTimestamp; - qint32 idxToSeek = -1; - if (!m_voidIndexes.isEmpty()) { - //qDebug() << "m_voidIndexes.count(): " << m_voidIndexes.count(); - qint32 firstIdx = -1; - qint32 lastIdx = -1; - QMutableMapIterator<quint32, quint64> ii(m_voidIndexes); - while (ii.hasNext()) { - ii.next(); - quint32 idx = ii.key(); - quint64 tstamp = ii.value(); - //qDebug() << "idx: " << idx; - if ((qint32)idx >= m_cache_start && (qint32)idx < m_cache_start + m_row_cache.count()) { - // Try to avoid emitting row changed multiple times. - if (firstIdx < 0) { - firstIdx = lastIdx = idx; - } - else if ((qint32)idx == lastIdx + 1) { - lastIdx++; - } - else { - //qDebug() << "Emitting row changed for: " << firstIdx << ", " << lastIdx - firstIdx + 1; - emit m_q->rowChanged (firstIdx, lastIdx - firstIdx + 1); - firstIdx = lastIdx = idx; - } - ii.remove(); - } - else { - if (tstamp > latestSeek) { - latestSeek = tstamp; - idxToSeek = idx; - } - } - } - if (firstIdx > -1) { - //qDebug() << "Emitting row changed for: " << firstIdx << ", " << lastIdx - firstIdx + 1; - emit m_q->rowChanged (firstIdx, lastIdx - firstIdx + 1); - } - } - if (!m_itemsInsertedSent) { - emit m_q->itemsInserted (0, m_count); - m_itemsInsertedSent = true; - } - m_requestPending = false; - if (idxToSeek > -1) { - qDebug() << "Needing a new request immediately. Consider tuning your system."; - m_q->seek(idxToSeek, false, true); - } - //qDebug () << "Handling the response took: " << t.elapsed() << " milliseconds."; -} - - -int QMdLiteQueryResult::at () const -{ - return d->m_index; -} - -bool QMdLiteQueryResult::first () -{ - if (isActive()) - return seek (0); - return false; -} - -bool QMdLiteQueryResult::isActive () const -{ - return d->m_valid && d->m_count > 0; -} - -bool QMdLiteQueryResult::last () -{ - if (isActive()) - return seek (d->m_count-1); - return false; -} - -bool QMdLiteQueryResult::next () -{ - if (isActive()) - return seek (d->m_index+1); - return false; -} - -bool QMdLiteQueryResult::previous () -{ - if (isActive() && d->m_index > -1) - return seek (d->m_index-1); - return false; -} - -bool QMdLiteQueryResult::seek ( int index, bool relative, bool forceRefresh ) -{ - /* If we would go for the _uuid based queries -QStringList uuidList; -for (int ii=newRowsStart; ii<newRowsEnd; ii++) uuidList.append(d->m_uuids.at(ii)); - query.append ("[?_uuid in %1]").arg(uuidList.join(QLatin1String(",")));*/ - - //QTime t; - //t.start(); - - if (relative) index += d->m_index < 0 ? 0 : d->m_index; - d->m_index = index; - if (index < 0 || (quint32)index >= d->m_count) return false; - - //qDebug () << "seek: " << d->m_index; - - if (!d->m_requestPending) { - if (forceRefresh) { - // Refresh the whole cache - d->m_requestOffset = qMax (index-CACHE_SIZE/2, 0); - int newRowsEnd = qMin ((quint32)index+CACHE_SIZE/2, d->m_count); - d->m_requestLimit = newRowsEnd - d->m_requestOffset; - d->m_cache_start = -1; - d->m_row_cache.clear(); - } - // Check if we need to read more stuff in front of the cache - else if (index >= 0 && index < d->m_cache_start + SAFETY_MARGIN && d->m_cache_start > 0) { - // create & send the request - d->m_requestOffset = qMax (index-CACHE_SIZE/2, 0); - int newRowsEnd = qMin (index+CACHE_SIZE/2, d->m_cache_start); - newRowsEnd = qMin ((quint32)newRowsEnd, d->m_count); - d->m_requestLimit = newRowsEnd - d->m_requestOffset; - } - // Check if we need to read more stuff to the end of the cache - else if (d->m_cache_start < 0 || - ((quint32)d->m_cache_start + d->m_row_cache.count() < d->m_count && - index > d->m_cache_start + d->m_row_cache.count() - SAFETY_MARGIN)) { - d->m_requestOffset = qMax(index, (int)(d->m_cache_start + d->m_row_cache.count())); - int newRowsEnd = qMin ((quint32)index+CACHE_SIZE/2, d->m_count); - d->m_requestLimit = newRowsEnd - d->m_requestOffset; - } - else return true; - //qDebug () << "seek ( " << index << ", " << relative << ", " << forceRefresh << " )"; - //qDebug () << "d->m_requestOffset = " << d->m_requestOffset << ", d->m_requestLimit" << d->m_requestLimit; - QString query = d->m_baseQuery; - if (d->m_chunk) { - if (!d->m_filterString.isEmpty()) query.append(d->m_filterString); - query.append(QMdLitePrivate::sortProperties2String (d->m_sortProperties)); - } - else { - query.append(QLatin1String("[? _uuid in [")); - for (int ii=0; ii<d->m_requestLimit && ii<d->m_uuids.count()-d->m_requestOffset; ii++) { - if (ii) query.append(QLatin1String(", ")); - query.append(QLatin1String("\"")).append(d->m_uuids[ii+d->m_requestOffset]).append(QLatin1String("\"")); - } - query.append(QLatin1String("]]")); - query.append(QMdLitePrivate::sortProperties2String (d->m_sortProperties)); - //qDebug () << "Sending a request: " << query; - } - if (d->m_properties.length() > 0) { - query.append(QLatin1String("[= [ ")); - query.append(d->m_properties.join(QLatin1String(","))); - query.append(QLatin1String(" ] ]")); - } - //qDebug () << "Sending a request: " << query << " with offset: " << d->m_requestOffset - // << " and limit: " << d->m_requestLimit; - d->m_requestPending = true; - d->m_requestTimestamp = QDateTime::currentMSecsSinceEpoch (); - //qDebug () << "Request timestamp is " << d->m_requestTimestamp; - if (d->m_chunk) - d->m_requestId = d->m_jsonDbClient->query(query, d->m_requestOffset, d->m_requestLimit); - else { - d->m_requestId = d->m_jsonDbClient->query(query); - } - //qDebug () << "Request " << d->m_requestId << " sent."; - } - else { - //qDebug () << "Seek to " << d->m_index << " missed."; - } - //qDebug () << "Handling the seek took: " << t.elapsed() << " milliseconds."; - return true; -} - -int QMdLiteQueryResult::size () const -{ - return d->m_count; -} - -QVariant QMdLiteQueryResult::value ( int index ) const -{ - if (d->m_index < 0) { - qDebug () << "Asking value before seek!"; - return QVariant(); - } - //qDebug() << "QMdLiteQueryResult::value (" << index << ") " << "m_index = " << d->m_index; - //qDebug() << "QMdLiteQueryResult::value: m_index = " << d->m_index << ", m_cache_start = " << d->m_cache_start; - if (d->in_cache(d->m_index)) { - //qDebug() << "Returing value " << d->m_row_cache.at(d->m_index-d->m_cache_start).at(index) << - // "for row: " << d->m_index << "and index: " << index; - if (!d->m_row_cache.at(d->m_index-d->m_cache_start).isEmpty()) { - // Remove the index from void indexes as we are now returning the real value - d->m_voidIndexes.remove(d->m_index); - return d->m_row_cache.at(d->m_index-d->m_cache_start).at(index); - } - } - //qDebug() << "Returing an empty value for " << d->m_index; - d->m_voidIndexes.insert(d->m_index, QDateTime::currentMSecsSinceEpoch ()); - - return QVariant(QString(QLatin1String(""))); -} - -bool QMdLiteQueryResult::isValid () const -{ - if (d->m_index < 0 || d->m_index >= (qint32)d->m_count) return false; - return true; -} - diff --git a/src/gallery/simple/qmdlitequeryresultjsondb_p.h b/src/gallery/simple/qmdlitequeryresultjsondb_p.h deleted file mode 100644 index ae1f4f3..0000000 --- a/src/gallery/simple/qmdlitequeryresultjsondb_p.h +++ /dev/null @@ -1,151 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDocGallery module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QMDLITEQUERYRESULTJSONDB_P_H -#define QMDLITEQUERYRESULTJSONDB_P_H - -#include <QString> -#include <QStringList> -#include <QMap> -#include <QObject> -#include <private/jsondb-connection_p.h> -#include <jsondb-client.h> -#include "qmdlite.h" - -// Number of rows in cache -// TODO: Change this to KBytes instead of number of rows? -#define CACHE_SIZE 50 -// When to update the cache -#define SAFETY_MARGIN 15 - -QT_ADDON_JSONDB_BEGIN_NAMESPACE -class JsonDbConnection; -class JsonDbClient; -QT_ADDON_JSONDB_END_NAMESPACE - -QT_ADDON_JSONDB_USE_NAMESPACE -class QMdLiteQueryResult; - -class QMdLiteQueryResultPrivate : public QObject -{ - Q_OBJECT -public: - QMdLiteQueryResultPrivate(QMdLiteQueryResult *q, JsonDbConnection *jdbCon, const QString &type, - const QString &baseQuery, const QString &filterStr, - const QStringList &properties, const QStringList &sortProperties, - bool chunk = false); - ~QMdLiteQueryResultPrivate(); - QString m_type; - QString m_baseQuery; - QString m_filterString; - QStringList m_properties; - QStringList m_sortProperties; - QStringList m_uuids; - quint32 m_count; - qint32 m_index; - bool m_chunk; // Do we use chunk queries or uuid based - bool m_valid; // True when both count/uuid query is complete as well as notification object creation - bool m_itemsInsertedSent; - QString m_notifUuid; - qint32 m_cache_start; - QList<QVariantList> m_row_cache; - bool m_requestPending; - QList<int> m_countRequestId; - int m_notifRequestId; - quint32 m_requestId; - quint64 m_requestTimestamp; // Time when request was sent - qint32 m_requestOffset; // - qint32 m_requestLimit; // - QMap<quint32, quint64> m_voidIndexes; // Indexes returned with default values + timestamp - QMap<QString, QVariantMap> m_insertedObjects; - QMap<QString, QVariantMap> m_removedObjects; - JsonDbConnection *m_jsonDbConnection; - JsonDbClient *m_jsonDbClient; - - QMdLiteQueryResult *m_q; - - inline bool in_cache (quint32 idx) const - { - return m_cache_start >= 0 - && idx >= (quint32)m_cache_start - && idx < (quint32)m_cache_start + m_row_cache.count(); - } - - void handleCountAndNotifRequest(int id, const QVariant &v); - -public Q_SLOTS: - void jsonDbResponse(int id, const QVariant &v); - void jsonDbError(int id, int code, const QString &message); - void jsonDbNotified(const QString &, const QVariant &, const QString &); -}; - -class QMdLiteQueryResult : public QMdLiteQueryResultIf -{ - Q_OBJECT - -public: - QMdLiteQueryResult(JsonDbConnection *jdbCon, const QString &type, const QString &baseQuery, - const QString &filterStr, const QStringList &properties, const QStringList &sortProperties) - : d(new QMdLiteQueryResultPrivate(this, jdbCon, type, baseQuery, filterStr, - properties, sortProperties, false)) - { - } - - virtual ~QMdLiteQueryResult() {} - - virtual int at() const; - virtual bool first(); - virtual bool isActive() const; - virtual bool last(); - virtual bool next(); - virtual bool previous(); - virtual bool seek(int index, bool relative = false, bool forceRefresh = false); - virtual int size() const; - virtual bool isValid() const; - virtual QVariant value(int index) const; - -private: - friend class QMdLiteQueryResultPrivate; - QScopedPointer<QMdLiteQueryResultPrivate> d; - - Q_DISABLE_COPY(QMdLiteQueryResult) -}; -#endif // QMDLITEQUERYRESULTJSONDB_P_H diff --git a/src/gallery/simple/qmdlitequeryresultsqlite.cpp b/src/gallery/simple/qmdlitequeryresultsqlite.cpp deleted file mode 100644 index fa26139..0000000 --- a/src/gallery/simple/qmdlitequeryresultsqlite.cpp +++ /dev/null @@ -1,102 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDocGallery module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qmdlitequeryresultsqlite_p.h" - -#include <QSqlQuery> -#include <QVariant> - -int QMdLiteQueryResult::at () const -{ - return d->m_query.at (); -} - -bool QMdLiteQueryResult::first () -{ - return d->m_query.first (); -} - -bool QMdLiteQueryResult::isActive () const -{ - return d->m_query.isActive(); -} - -bool QMdLiteQueryResult::last () -{ - return d->m_query.last(); -} - -bool QMdLiteQueryResult::next () -{ - return d->m_query.next(); -} - -bool QMdLiteQueryResult::previous () -{ - return d->m_query.previous (); -} - -bool QMdLiteQueryResult::seek ( int index, bool relative ) -{ - return d->m_query.seek(index, relative); -} - -int QMdLiteQueryResult::size () const -{ - return d->m_query.size(); -} - -QVariant QMdLiteQueryResult::value ( int index ) const -{ - return d->m_query.value(index); -} - - -void QMdLiteQueryResult::setSqlQuery ( QSqlQuery& query ) -{ - d->m_query = query; -} - -void QMdLiteQueryResult::isValid ( ) -{ - return d->m_query.isValid(); -} - diff --git a/src/gallery/simple/qmdlitequeryresultsqlite_p.h b/src/gallery/simple/qmdlitequeryresultsqlite_p.h deleted file mode 100644 index 98235ea..0000000 --- a/src/gallery/simple/qmdlitequeryresultsqlite_p.h +++ /dev/null @@ -1,80 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDocGallery module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QMDLITEQUERYRESULTSQLITE_P_H -#define QMDLITEQUERYRESULTSQLITE_P_H - -class QSqlQuery; -class QSqlDatabase; - -class QMdLiteQueryResultPrivate -{ -public: - QMdLiteQueryResultPrivate(QSqlQuery &query) : m_query(query) {} - QSqlQuery m_query; -}; - -class QMdLiteQueryResult : public QMdLiteQueryResultIf -{ -public: - QMdLiteSqlQueryResult(QSqlQuery &query) - : d(new QMdLiteQueryResultPrivate(query)) {} - virtual ~QMdLiteSqlQueryResult() {} - - virtual int at() const; - virtual bool first(); - virtual bool isActive() const; - virtual bool last(); - virtual bool next(); - virtual bool previous(); - virtual bool seek(int index, bool relative = false, bool forceRefresh = false); - virtual int size() const; - virtual QVariant value(int index) const; - void setSqlQuery(QSqlQuery &query); - -private: - friend class QMdLiteQueryResultPrivate; - QScopedPointer<QMdLiteQueryResultPrivate> d; - - Q_DISABLE_COPY(QMdLiteSqlQueryResult); -}; - -#endif // QMDLITEQUERYRESULTSQLITE_P_H diff --git a/src/gallery/simple/qsimplegalleryitemresultset.cpp b/src/gallery/simple/qsimplegalleryitemresultset.cpp deleted file mode 100644 index 26998dd..0000000 --- a/src/gallery/simple/qsimplegalleryitemresultset.cpp +++ /dev/null @@ -1,77 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDocGallery module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -//Backend -#include "qsimplegalleryitemresultset.h" -#include "qgallerysimpleutility.h" -//API -#include "qdocumentgallery.h" -#include "qgalleryitemrequest.h" - -QT_ADDON_GALLERY_BEGIN_NAMESPACE - -QSimpleGalleryItemResultSet::QSimpleGalleryItemResultSet(QObject *parent) -:QSimpleGalleryResultSet(parent) -{ - m_request = static_cast<QGalleryItemRequest *>(parent); - //m_live = m_request->autoUpdate(); - - createQuery(); -} - -QSimpleGalleryItemResultSet::~QSimpleGalleryItemResultSet() -{ -} - -QString QSimpleGalleryItemResultSet::itemType() const -{ - if (isValid()) { - return m_request->itemType(); - } - return QString(); -} - -void QSimpleGalleryItemResultSet::createQuery() -{ -} - -#include "moc_qsimplegalleryitemresultset.cpp" -QT_ADDON_GALLERY_END_NAMESPACE diff --git a/src/gallery/simple/qsimplegalleryitemresultset.h b/src/gallery/simple/qsimplegalleryitemresultset.h deleted file mode 100644 index 9ffc15d..0000000 --- a/src/gallery/simple/qsimplegalleryitemresultset.h +++ /dev/null @@ -1,68 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDocGallery module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QFOLDERGALLERYITEMRESULTSET_H -#define QFOLDERGALLERYITEMRESULTSET_H - -#include "qsimplegalleryresultset.h" - -QT_ADDON_GALLERY_BEGIN_NAMESPACE - -class QGalleryItemRequest; - -class QSimpleGalleryItemResultSet : public QSimpleGalleryResultSet -{ - Q_OBJECT - -public: - QSimpleGalleryItemResultSet(QObject *parent = 0); - ~QSimpleGalleryItemResultSet(); - - void createQuery(); - QString itemType() const; - -private: - QGalleryItemRequest * m_request; -}; - -QT_ADDON_GALLERY_END_NAMESPACE - -#endif // QFOLDERGALLERYITEMRESULTSET_H diff --git a/src/gallery/simple/qsimplegalleryqueryresultset.cpp b/src/gallery/simple/qsimplegalleryqueryresultset.cpp deleted file mode 100755 index 7e14bb5..0000000 --- a/src/gallery/simple/qsimplegalleryqueryresultset.cpp +++ /dev/null @@ -1,303 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDocGallery module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -//Backend -#include "qgallerysimpleutility.h" -#include "qsimplegalleryqueryresultset.h" -//API -#include "qdocumentgallery.h" -#include "qgalleryqueryrequest.h" - -#include <QDir> -#include <QStringList> -#include <QtDebug> -#include <QDateTime> -#include "qmdlitemusic.h" - -QT_ADDON_GALLERY_BEGIN_NAMESPACE - -QSimpleGalleryQueryResultSet::QSimpleGalleryQueryResultSet(QObject *parent) - : QSimpleGalleryResultSet(parent) -{ - m_request = static_cast<QGalleryQueryRequest *>(parent); - //m_live = m_request->autoUpdate(); - - createQuery(); -} - -QSimpleGalleryQueryResultSet::~QSimpleGalleryQueryResultSet() -{ -} - -QString QSimpleGalleryQueryResultSet::itemType() const -{ - if (isValid()) { - if (m_itemType.isEmpty()) - return m_request->rootType(); - else - return m_itemType; - } - return QString(); -} - -void QSimpleGalleryQueryResultSet::createQuery() -{ - m_itemType = QString(); - //qDebug() << "createQuery: " << m_request->rootType() << ", filter: " << m_request->filter(); - if (m_request->rootType() == QDocumentGallery::Album) { - QMdLiteMusic musicDb; - bool isJsonDb = musicDb.dbType(); - //m_isValid = true; - QStringList propertyList; - propertyList << QString::fromLatin1("albumArt") - << QString::fromLatin1("title") - << QString::fromLatin1("artist") - << QString::fromLatin1("albumArtist"); - //m_result.clear(); - QString filterStr = filterToString(QString::fromLatin1("albums"), m_request->filter(), isJsonDb); - // Add the root item to the query - if (!m_request->rootItem().toString().isEmpty()) { - - QStringList parts = m_request->rootItem().toString().split(QString::fromLatin1(":/")); - if (QString::compare(QString::fromLatin1("artist"), parts.at(0), Qt::CaseInsensitive) == 0) { - QString artistCleaned(parts.at(1)); - // TODO: Jsondb stuff here - - if (isJsonDb) { - artistCleaned.replace(QString::fromLatin1("\""), QString::fromLatin1("\\\"")); - artistCleaned.replace(QString::fromLatin1("\\"), QString::fromLatin1("\\\\")); - QString artistFilter(QLatin1String("[?artist=\"")); - artistFilter.append(artistCleaned).append(QString::fromLatin1("\"]")); - filterStr.prepend(artistFilter); - //qDebug() << filterStr; - } - else { - artistCleaned.replace(QString::fromLatin1("'"), QString::fromLatin1("''")); - if (!filterStr.isEmpty()) - filterStr.append(QString::fromLatin1(" AND artist = '")).append(artistCleaned).append(QString::fromLatin1("'")); - else - filterStr.append(QString::fromLatin1("artist = '")).append(artistCleaned).append(QString::fromLatin1("'")); - } - } - } - m_resultQuery = musicDb.createAlbumQuery(propertyList, filterStr, m_request->sortPropertyNames()); - - connect(m_resultQuery, SIGNAL(rowChanged(quint32, int)), this, SLOT(itemChanged(quint32, int)), Qt::QueuedConnection); - connect(m_resultQuery, SIGNAL(itemsInserted(int, int)), this, SIGNAL(itemsInserted(int, int)), Qt::QueuedConnection); - connect(m_resultQuery, SIGNAL(itemsRemoved(int, int)), this, SIGNAL(itemsRemoved(int, int)), Qt::QueuedConnection); - - /*if (query->isActive()) { - m_count = 0;*/ - emit progressChanged(1, 3); - /*QStringList propertyList; - QDocumentGallerySimpleUtility::GetDataFieldsForItemType( propertyList, itemType() ); - int count = propertyList.count(); - qDebug () << "Property list count: " << count; - while (query->next()) { - QVariantList row; - row.append(query->value(0)); // Add id as the first item - for (int ii=0; ii<count; ii++) { - int propertyKey = QDocumentGallerySimpleUtility::GetPropertyKey( propertyList[ii] ); - row.append(query->value(QDocumentGallerySimpleUtility::GetPropertyIndex(propertyKey, itemType()))); - //qDebug () << "Appending: " << query.value(QDocumentGallerySimpleUtility::GetPropertyIndex(propertyKey, itemType())) << " to row"; - } - //qDebug () << "Appending row to m_result"; - m_result.append(row); - m_count++; - }*/ - emit progressChanged(2, 3); - emit finished(); - //m_cursorPosition = -1; - //} - //else { - // m_isValid = false; - // emit finished(); - //} - } - else if (m_request->rootType() == QDocumentGallery::Artist) { - QMdLiteMusic musicDb; - bool isJsonDb = musicDb.dbType(); - //m_isValid = true; - //m_result.clear(); - QString filterStr = filterToString(QString::fromLatin1("songs"), m_request->filter(), isJsonDb); - bool artistRootItem = false; - if (!m_request->rootItem().toString().isEmpty()) { - QStringList parts = m_request->rootItem().toString().split(QString::fromLatin1(":/")); - if (QString::compare(QString::fromLatin1("artist"), parts.at(0), Qt::CaseInsensitive) == 0) { - artistRootItem = true; - m_itemType = QDocumentGallery::AlbumArtist; - m_resultQuery = musicDb.createArtistAlbumsQuery(parts.at(1), filterStr); - } - } - else m_resultQuery = musicDb.createArtistQuery(filterStr); - - connect(m_resultQuery, SIGNAL(rowChanged(quint32, int)), this, SLOT(itemChanged(quint32, int)), Qt::QueuedConnection); - connect(m_resultQuery, SIGNAL(itemsInserted(int, int)), this, SIGNAL(itemsInserted(int, int)), Qt::QueuedConnection); - connect(m_resultQuery, SIGNAL(itemsRemoved(int, int)), this, SIGNAL(itemsRemoved(int, int)), Qt::QueuedConnection); - //QMdLiteQueryResult query = musicDb.createAlbumArtistQuery(); - //if (query->isActive()) { - //m_count = 0; - emit progressChanged(1, 3); - //QStringList propertyList; - //QDocumentGallerySimpleUtility::GetDataFieldsForItemType( propertyList, itemType() ); - /*int count = propertyList.count(); - //qDebug () << "Property list count: " << count; - while (query->next()) { - QVariantList row; - row.append(query->value(0)); // Add id as the first item - for (int ii=0; ii<count; ii++) { - int propertyKey = QDocumentGallerySimpleUtility::GetPropertyKey( propertyList[ii] ); - if (!artistRootItem && (propertyKey == QDocumentGallerySimpleUtility::EAlbumTitle || - propertyKey == QDocumentGallerySimpleUtility::EAlbumArt)) { - QString value = query->value (QDocumentGallerySimpleUtility::GetPropertyIndex(propertyKey, itemType())).toString(); - QStringList values = value.split (",,"); - values.removeDuplicates(); - row.append (values); - //qDebug () << "Appending: " << values << " to row"; - } - else { - row.append(query->value(QDocumentGallerySimpleUtility::GetPropertyIndex(propertyKey, itemType()))); - //qDebug () << "Appending: " << query.value(QDocumentGallerySimpleUtility::GetPropertyIndex(propertyKey, itemType())) << " to row"; - } - } - //qDebug () << "Appending row to m_result"; - m_result.append(row); - m_count++; - }*/ - emit progressChanged(2, 3); - emit finished(); - //m_cursorPosition = -1; - /*} - else { - //m_isValid = false; - emit finished(); - }*/ - } - else if (m_request->rootType() == QDocumentGallery::Audio) { - QMdLiteMusic musicDb; - bool isJsonDb = musicDb.dbType(); - //m_isValid = true; - //m_result.clear(); - QStringList propertyList; - propertyList << QString::fromLatin1("url") - << QString::fromLatin1("title") - << QString::fromLatin1("artist") - << QString::fromLatin1("albumTitle") - << QString::fromLatin1("albumArtist") - << QString::fromLatin1("albumArt") - << QString::fromLatin1("trackNumber") - << QString::fromLatin1("genre"); - QString filterStr = filterToString(QString::fromLatin1("songs"), m_request->filter(), isJsonDb); - // Add the root item to the query - // TODO: add jsondb support to below - if (!m_request->rootItem().toString().isEmpty()) { - QStringList parts = m_request->rootItem().toString().split(QString::fromLatin1(":/")); - /*if (QString::compare("album", parts.at(0), Qt::CaseInsensitive) == 0) { - if (isJsonDb) { - QString albumFilter(QLatin1String("[?_uuid in \"")); - albumFilter.append(parts.at(1)).append("->songs\"]"); - filterStr.prepend(albumFilter); - qDebug() << filterStr; - } - else { - if (!filterStr.isEmpty()) - filterStr.append(" AND songs.albumId = ").append(parts.at(1)); - else - filterStr.append("songs.albumId = ").append(parts.at(1)); - } - } - else*/ if (QString::compare(QString::fromLatin1("artist"), parts.at(0), Qt::CaseInsensitive) == 0) { - QString artistCleaned(parts.at(1)); - if (isJsonDb) { - artistCleaned.replace(QString::fromLatin1("\""), QString::fromLatin1("\\\"")); - artistCleaned.replace(QString::fromLatin1("\\"), QString::fromLatin1("\\\\")); - QString artistFilter(QLatin1String("[?artist=\"")); - artistFilter.append(artistCleaned).append(QString::fromLatin1("\"]")); - filterStr.prepend(artistFilter); - //qDebug() << filterStr; - } - else { - artistCleaned.replace(QString::fromLatin1("'"), QString::fromLatin1("''")); - if (!filterStr.isEmpty()) - filterStr.append(QString::fromLatin1(" AND songs.artist = ")).append(artistCleaned); - else - filterStr.append(QString::fromLatin1("songs.artist = ")).append(artistCleaned); - } - } - } - m_resultQuery = musicDb.createMusicQuery(propertyList, filterStr, m_request->sortPropertyNames()); - - connect(m_resultQuery, SIGNAL(rowChanged(quint32, int)), this, SLOT(itemChanged(quint32, int)), Qt::QueuedConnection); - connect(m_resultQuery, SIGNAL(itemsInserted(int, int)), this, SIGNAL(itemsInserted(int, int)), Qt::QueuedConnection); - connect(m_resultQuery, SIGNAL(itemsRemoved(int, int)), this, SIGNAL(itemsRemoved(int, int)), Qt::QueuedConnection); - /*if (query->isActive()) { - m_count = 0;*/ - emit progressChanged(1, 3); - /*while (query->next()) { - QVariantList row; - QStringList propertyList; - row.append(query->value(0)); // Add id as the first item - QDocumentGallerySimpleUtility::GetDataFieldsForItemType( propertyList, itemType() ); - const int count = propertyList.count(); - for (int ii=0; ii<count; ii++) { - int propertyKey = QDocumentGallerySimpleUtility::GetPropertyKey( propertyList[ii] ); - row.append(query->value(QDocumentGallerySimpleUtility::GetPropertyIndex(propertyKey, itemType()))); - //qDebug () << "Appending: " << query.value(QDocumentGallerySimpleUtility::GetPropertyIndex(propertyKey, itemType())) << " to row"; - } - m_result.append(row); - m_count++; - }*/ - emit progressChanged(2, 3); - emit finished(); - /*} - else { - m_isValid = false; - emit finished(); - }*/ - } - else if (m_request->rootType() == QDocumentGallery::Image) { - //QMdLiteImages imagesDb; - } - //qDebug() << "createQuery done: " << QDateTime::currentMSecsSinceEpoch() - startTime; -} - -#include "moc_qsimplegalleryqueryresultset.cpp" -QT_ADDON_GALLERY_END_NAMESPACE diff --git a/src/gallery/simple/qsimplegalleryqueryresultset.h b/src/gallery/simple/qsimplegalleryqueryresultset.h deleted file mode 100644 index 1eb2133..0000000 --- a/src/gallery/simple/qsimplegalleryqueryresultset.h +++ /dev/null @@ -1,72 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDocGallery module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QFOLDERGALLERYQUERYRESULTSET_H -#define QFOLDERGALLERYQUERYRESULTSET_H - -#include "qsimplegalleryresultset.h" - -QT_ADDON_GALLERY_BEGIN_NAMESPACE - -class QGalleryQueryRequest; - -class QSimpleGalleryQueryResultSet : public QSimpleGalleryResultSet -{ - Q_OBJECT - -public: - QSimpleGalleryQueryResultSet(QObject *parent = 0); - ~QSimpleGalleryQueryResultSet(); - - void createQuery(); - QString itemType() const; - -//private: - //void handleUpdatedResults(); - -private: - QGalleryQueryRequest *m_request; - QString m_itemType; -}; - -QT_ADDON_GALLERY_END_NAMESPACE - -#endif // QFOLDERGALLERYQUERYRESULTSET_H diff --git a/src/gallery/simple/qsimplegalleryresultset.cpp b/src/gallery/simple/qsimplegalleryresultset.cpp deleted file mode 100644 index 20e8b92..0000000 --- a/src/gallery/simple/qsimplegalleryresultset.cpp +++ /dev/null @@ -1,483 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDocGallery module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qgalleryresource.h" -#include "qdocumentgallery.h" -//Backend -#include "qsimplegalleryresultset.h" -#include "qgallerysimpleutility.h" - -#include <QtDebug> - - -QT_ADDON_GALLERY_BEGIN_NAMESPACE - -QSimpleGalleryResultSet::QSimpleGalleryResultSet(QObject *parent) - : QGalleryResultSet(parent) - , m_resultQuery(0) -// , m_musicDb(0) -// , m_imagesDb(0) -// , m_count(0) -// , m_cursorPosition(-1) -// , m_isValid(false) -{ -} - -QSimpleGalleryResultSet::~QSimpleGalleryResultSet() -{ - /*if (m_musicDb) delete m_musicDb; - if (m_imagesDb) delete m_imagesDb;*/ - if (m_resultQuery) - delete m_resultQuery; -} - -QString QSimpleGalleryResultSet::_jsonDbFilterToString(const QString &tableName, - const QGalleryFilter& filter, bool inOr) -{ - QString ret; - switch (filter.type()) { - case QGalleryFilter::Invalid: - break; - case QGalleryFilter::Intersection: { - if (inOr) { - qDebug () << "And inside or not supported."; - return QString(); - } - QGalleryIntersectionFilter interFilter = filter.toIntersectionFilter(); - for (int ii=0; ii<interFilter.filters().length(); ii++) - ret.append(_jsonDbFilterToString(tableName, interFilter.filters()[ii])); - break; - } - case QGalleryFilter::Union: { - if (!inOr) - ret.append(QLatin1String("[?")); - QGalleryUnionFilter unionFilter = filter.toUnionFilter(); - for (int ii=0; ii<unionFilter.filters().length(); ii++) { - if (ii) - ret.append(QString::fromLatin1(" | ")); - ret.append(_jsonDbFilterToString(tableName, unionFilter.filters()[ii], !inOr)); - } - if (!inOr) - ret.append(QLatin1String("]")); - break; - } - case QGalleryFilter::MetaData: - QGalleryMetaDataFilter metadataFilter = filter.toMetaDataFilter(); - if (!inOr) - ret.append(QLatin1String("[?")); - if (metadataFilter.propertyName().compare(QString::fromLatin1("albumTitle"), Qt::CaseInsensitive) == 0) - ret.append(QString::fromLatin1("album.title")); - else if (metadataFilter.propertyName().compare(QString::fromLatin1("albumArtist"), Qt::CaseInsensitive) == 0) - ret.append(QString::fromLatin1("album.artist")); - /*else if (metadataFilter.propertyName().compare("albumCover", Qt::CaseInsensitive) == 0) - ret.append ("albumId->url");*/ - else - ret.append(metadataFilter.propertyName()); - switch (metadataFilter.comparator()) { - case QGalleryFilter::Equals: - if (metadataFilter.isNegated()) - ret.append(QString::fromLatin1("!")); - ret.append(QString::fromLatin1("=")); - ret.append(QString::fromLatin1("\"")).append(metadataFilter.value().toString()).append(QString::fromLatin1("\"")); - break; - case QGalleryFilter::LessThan: - if (metadataFilter.isNegated()) - ret.append(QString::fromLatin1(">=")); - else - ret.append(QString::fromLatin1("<")); - ret.append(metadataFilter.value().toString()); - break; - case QGalleryFilter::GreaterThan: - if (metadataFilter.isNegated()) - ret.append(QString::fromLatin1("<=")); - else - ret.append(QString::fromLatin1(">")); - ret.append(metadataFilter.value().toString()); - break; - case QGalleryFilter::LessThanEquals: - if (metadataFilter.isNegated()) - ret.append(QString::fromLatin1(">")); - else - ret.append(QString::fromLatin1("<=")); - ret.append(metadataFilter.value().toString()); - break; - case QGalleryFilter::GreaterThanEquals: - if (metadataFilter.isNegated()) - ret.append(QString::fromLatin1("<")); - else - ret.append(QString::fromLatin1(">=")); - ret.append(metadataFilter.value().toString()); - break; - case QGalleryFilter::Contains: - ret.append(QString::fromLatin1("=~")); - ret.append(QString::fromLatin1("\"/*")).append(metadataFilter.value().toString(). - replace(QString::fromLatin1("\""), QString::fromLatin1("\\\""))).append(QString::fromLatin1("*/iw\"")); - break; - case QGalleryFilter::StartsWith: - ret.append(QString::fromLatin1("=~")); - ret.append(QString::fromLatin1("\"/")).append(metadataFilter.value().toString(). - replace(QString::fromLatin1("\""), QString::fromLatin1("\\\""))).append(QString::fromLatin1("*/iw\"")); - break; - case QGalleryFilter::EndsWith: - ret.append(QString::fromLatin1("=~")); - ret.append(QString::fromLatin1("\"/*")).append(metadataFilter.value().toString(). - replace(QString::fromLatin1("\""), QString::fromLatin1("\\\""))).append(QString::fromLatin1("/iw\"")); - break; - case QGalleryFilter::Wildcard: - ret.append(QString::fromLatin1("=~")); - ret.append(QString::fromLatin1("\"/*")).append(metadataFilter.value().toString(). - replace(QString::fromLatin1("\""), QString::fromLatin1("\\\""))).append(QString::fromLatin1("*/iw\"")); - break; - case QGalleryFilter::RegExp: - ret.append(QString::fromLatin1("=~")); - ret.append(QString::fromLatin1("\"/")).append(metadataFilter.value().toString(). - replace(QString::fromLatin1("\""), QString::fromLatin1("\\\""))).append(QString::fromLatin1("/i\"")); - break; - } - if (!inOr) - ret.append(QLatin1String("]")); - //qDebug () << ret; - break; - } - return ret; -} - -QString QSimpleGalleryResultSet::filterToString(const QString &tableName, const QGalleryFilter& filter, bool jsonDb) -{ - QString ret; - if (!jsonDb) { // SQL - switch (filter.type()) { - case QGalleryFilter::Invalid: - break; - case QGalleryFilter::Intersection: - { - QGalleryIntersectionFilter interFilter = filter.toIntersectionFilter(); - ret.append(QLatin1String(" (")); - ret.append(filterToString(tableName, interFilter.filters()[0], false)); - for (int ii=1; ii<interFilter.filters().length(); ii++) { - ret.append(QLatin1String(" AND ")); - ret.append(filterToString(tableName, interFilter.filters()[ii], false)); - } - ret.append(QLatin1String(" )")); - } - break; - case QGalleryFilter::Union: - { - QGalleryUnionFilter unionFilter = filter.toUnionFilter(); - ret.append(QLatin1String(" (")); - ret.append(filterToString(tableName, unionFilter.filters()[0], false)); - for (int ii=1; ii<unionFilter.filters().length(); ii++) { - ret.append(QLatin1String(" OR ")); - ret.append(filterToString(tableName, unionFilter.filters()[ii], false)); - } - ret.append(QLatin1String(") ")); - } - break; - case QGalleryFilter::MetaData: - QGalleryMetaDataFilter metadataFilter = filter.toMetaDataFilter(); - if (metadataFilter.isNegated()) ret.append(QLatin1String(" NOT ")); - if (metadataFilter.propertyName().compare(QLatin1String("albumTitle"), Qt::CaseInsensitive) == 0) { - ret.append(QLatin1String("albums.title")); - } - else if (metadataFilter.propertyName().compare(QLatin1String("albumArtist"), Qt::CaseInsensitive) == 0) { - ret.append(QLatin1String("albums.artist")); - } - else if (metadataFilter.propertyName().compare(QLatin1String("albumCover"), Qt::CaseInsensitive) == 0) { - ret.append(QLatin1String("albums.url")); - } - else ret.append(tableName).append(QLatin1String(".")).append(metadataFilter.propertyName()); - switch (metadataFilter.comparator()) { - case QGalleryFilter::Equals: - ret.append(QLatin1String(" = ")); - ret.append(metadataFilter.value().toString()); - break; - case QGalleryFilter::LessThan: - ret.append(QLatin1String(" < ")); - ret.append(metadataFilter.value().toString()); - break; - case QGalleryFilter::GreaterThan: - ret.append(QLatin1String(" > ")); - ret.append(metadataFilter.value().toString()); - break; - case QGalleryFilter::LessThanEquals: - ret.append(QLatin1String(" <= ")); - ret.append(metadataFilter.value().toString()); - break; - case QGalleryFilter::GreaterThanEquals: - ret.append(QLatin1String(" >= ")); - ret.append(metadataFilter.value().toString()); - break; - case QGalleryFilter::Contains: - ret.append(QLatin1String(" LIKE ")); - ret.append(QLatin1String("'%")).append(metadataFilter.value().toString().replace(QLatin1String("'"), QLatin1String("''"))).append(QLatin1String("%'")); - break; - case QGalleryFilter::StartsWith: - ret.append(QLatin1String(" LIKE ")); - ret.append(QLatin1String("'")).append(metadataFilter.value().toString().replace(QLatin1String("'"), QLatin1String("''"))).append(QLatin1String("%'")); - break; - case QGalleryFilter::EndsWith: - ret.append(QLatin1String(" LIKE ")); - ret.append(QLatin1String("'%")).append(metadataFilter.value().toString().replace(QLatin1String("'"), QLatin1String("''"))).append(QLatin1String("'")); - break; - case QGalleryFilter::Wildcard: - ret.append(QLatin1String(" GLOB ")); - ret.append(QLatin1String("'")).append(metadataFilter.value().toString().replace(QLatin1String("'"), QLatin1String("''"))).append(QLatin1String("'")); - break; - case QGalleryFilter::RegExp: - qWarning() << "RegExp not supported."; - break; - } - break; - } - } - else { - // JsonDb - ret = _jsonDbFilterToString(tableName, filter); - //qDebug() << ret; - } - return ret; -} - -int QSimpleGalleryResultSet::propertyKey(const QString &property) const -{ - return QDocumentGallerySimpleUtility::GetPropertyKey( property ); -} - -QGalleryProperty::Attributes QSimpleGalleryResultSet::propertyAttributes(int key) const -{ - if (key == QDocumentGallerySimpleUtility::EUri) { - return (QGalleryProperty::CanRead | QGalleryProperty::CanSort | QGalleryProperty::CanFilter ); - } else { - return (QGalleryProperty::CanRead | QGalleryProperty::CanWrite | QGalleryProperty::CanSort | QGalleryProperty::CanFilter ); - } -} - -QVariant::Type QSimpleGalleryResultSet::propertyType(int key) const -{ - return QDocumentGallerySimpleUtility::GetPropertyType( key ); -} - -int QSimpleGalleryResultSet::itemCount() const -{ - //qDebug () << "Count asked. Returning " << m_resultQuery->size(); - return m_resultQuery->size(); -} - -bool QSimpleGalleryResultSet::isValid() const -{ - //qDebug () << "isValid asked. Returning " << m_resultQuery->isValid(); - return m_resultQuery->isValid(); -} - -// Item type + :/ + unique id = itemId -QVariant QSimpleGalleryResultSet::itemId() const -{ - QString idVar; - - if (isValid()) { - // Id is always the first value in the query - QString id = m_resultQuery->value(0).toString(); - idVar = itemType() + QLatin1String(":/") + id; - } - //qDebug () << "itemId asked. Returning " << idVar; - - return QVariant(idVar); -} - -QUrl QSimpleGalleryResultSet::itemUrl() const -{ - if ( isValid()) { - // Url is always the second value - const QUrl url = - QUrl::fromLocalFile(m_resultQuery->value(1).toString()); - //qDebug () << "itemUrl asked. Returning " << url.toString(); - return url; - } - return QUrl(); -} - -QList<QGalleryResource> QSimpleGalleryResultSet::resources() const -{ - QList<QGalleryResource> resources; - //qDebug () << "resources asked."; - - if (isValid()) { - const QUrl url = itemUrl(); - - QStringList propertyList; - QDocumentGallerySimpleUtility::GetDataFieldsForItemType( propertyList, itemType() ); - - const int count = propertyList.count(); - QMap<int, QVariant> attributes; - - for (int i = 0; i < count; i++) { - int propertyKey = QDocumentGallerySimpleUtility::GetPropertyKey( propertyList[i] ); - QVariant value = metaData( propertyKey ); - if (!value.isNull()) - attributes.insert(propertyKey, value); - } - resources.append(QGalleryResource(url, attributes)); - } - return resources; -} - -QVariant QSimpleGalleryResultSet::metaData(int key) const -{ - if (!isValid()) - return QVariant(); - - //qDebug () << "Returning: " << - // m_resultQuery->value(QDocumentGallerySimpleUtility::GetPropertyIndex(key, itemType())) << - // " for " << key << " idx: " << currentIndex(); - return m_resultQuery->value(QDocumentGallerySimpleUtility::GetPropertyIndex(key, itemType())); -} - -bool QSimpleGalleryResultSet::setMetaData(int key, const QVariant &value) -{ - //Q_UNUSED(key) - //Q_UNUSED(value) - qDebug () << "setMetaData for key: " << key << " to value: " << value << " called."; - // TODO: implement editing with qexif - - /*bool ret = false; - - TRAPD( err, QDocumentGalleryMDSUtility::SetMetaDataFieldL( - m_itemArray[m_cursorPosition], value, key) ); - if (err) { - return false; - } else { - if (ret) { - TRAP( err, m_session->CommitObjectL( *m_itemArray[m_cursorPosition] ) ); - if (err) { - return false; - } else { - return true; - } - } - } - return false;*/ - return false; -} - -int QSimpleGalleryResultSet::currentIndex() const -{ - - if (isValid()) { - //qDebug () << "currentIndex asked. Returning: " << m_cursorPosition; - return m_resultQuery->at(); - } - return -1; -} - -bool QSimpleGalleryResultSet::fetch(int index) -{ - //qDebug () << "fetch with index: " << index << " called."; - if (m_resultQuery->seek(index)) { - emit currentIndexChanged(currentIndex()); - //emit currentItemChanged(); - return true; - } - return false; -} - -bool QSimpleGalleryResultSet::fetchNext() -{ - //qDebug () << "fetchNext called."; - if (m_resultQuery->next()) { - emit currentIndexChanged(currentIndex()); - //emit currentItemChanged(); - return true; - } - return false; -} - -bool QSimpleGalleryResultSet::fetchPrevious() -{ - //qDebug () << "fetchPrevious called."; - if (m_resultQuery->previous()) { - emit currentIndexChanged(currentIndex()); - //emit currentItemChanged(); - return true; - } - return false; -} - -bool QSimpleGalleryResultSet::fetchFirst() -{ - //qDebug () << "fetchFirst called."; - if (m_resultQuery->first()) { - emit currentIndexChanged(currentIndex()); - //emit currentItemChanged(); - return true; - } - return false; -} - -bool QSimpleGalleryResultSet::fetchLast() -{ - //qDebug () << "fetchLast called."; - if (m_resultQuery->last()) { - emit currentIndexChanged(currentIndex()); - //emit currentItemChanged(); - return true; - } - return false; -} - -void QSimpleGalleryResultSet::itemChanged(quint32 index, int count) -{ - QList<int> keys; - foreach (const QString& property, propertyNames()) { - keys.append(propertyKey(property)); - } - emit metaDataChanged(index, count, keys); -} - -QStringList QSimpleGalleryResultSet::propertyNames() const -{ - QStringList propertyNames; - QDocumentGallerySimpleUtility::GetDataFieldsForItemType (propertyNames, itemType()); - return propertyNames; -} - -#include "moc_qsimplegalleryresultset.cpp" - -QT_ADDON_GALLERY_END_NAMESPACE diff --git a/src/gallery/simple/qsimplegalleryresultset.h b/src/gallery/simple/qsimplegalleryresultset.h deleted file mode 100644 index 8219031..0000000 --- a/src/gallery/simple/qsimplegalleryresultset.h +++ /dev/null @@ -1,141 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDocGallery module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QSIMPLEGALLERYRESULTSET_H -#define QSIMPLEGALLERYRESULTSET_H - -// -// W A R N I N G -// ------------- -// -// This file is not part of the Qt API. It exists purely as an -// implementation detail. This header file may change from version to -// version without notice, or even be removed. -// -// We mean it. -// - -#include <QObject> -#include <QUrl> -#include <QStringList> -#include <QVector> -#include <QHash> -#include <QVariantList> -#include <qgalleryresultset.h> - -#include "qmdlitemusic.h" - -QT_ADDON_GALLERY_BEGIN_NAMESPACE - -class QSimpleGalleryResultSet : public QGalleryResultSet -{ - Q_OBJECT - -public: - QSimpleGalleryResultSet(QObject *parent = 0); - ~QSimpleGalleryResultSet(); - - QStringList propertyNames() const; - int propertyKey(const QString &property) const; - QGalleryProperty::Attributes propertyAttributes(int key) const; - QVariant::Type propertyType(int key) const; - - int itemCount() const; - - int currentIndex() const; - bool fetch(int index); - bool fetchNext(); - bool fetchPrevious(); - bool fetchFirst(); - bool fetchLast(); - - QVariant itemId() const; - QUrl itemUrl() const; - QList<QGalleryResource> resources() const; - - QVariant metaData(int key) const; - bool setMetaData(int key, const QVariant &value); - - bool isValid() const; - - static QString filterToString(const QString &tableName, const QGalleryFilter& filter, bool jsonDb); - - //void cancel(); - - //bool waitForFinished(int msecs); - - //bool event(QEvent *event); - -public Q_SLOTS: - //void refresh(int serviceId = -1); - void itemChanged (quint32, int); - -Q_SIGNALS: - void itemEdited(const QString &service); - -protected: - //QSimpleGalleryResultSet(QSimpleGalleryResultSetPrivate &dd, QObject *parent); - - //void timerEvent(QTimerEvent *event); - - /*QMdLiteMusic *m_musicDb; - QMdLiteImages *m_imagesDb; - QSqlQuery m_query;*/ - //int m_count; - //bool m_live; - - //QList<QVariantList> m_result; - - QMdLiteQueryResultIf *m_resultQuery; - QList<int> m_keys; - - //int m_cursorPosition; - //bool m_isValid; - -private: - //Q_DECLARE_PRIVATE(QSimpleGalleryResultSet) - - static QString _jsonDbFilterToString(const QString &tableName, const QGalleryFilter& filter, bool inOr = false); -}; - -QT_ADDON_GALLERY_END_NAMESPACE - -#endif diff --git a/src/gallery/simple/simple.pri b/src/gallery/simple/simple.pri deleted file mode 100644 index 46f3ff8..0000000 --- a/src/gallery/simple/simple.pri +++ /dev/null @@ -1,35 +0,0 @@ -INCLUDEPATH += $$PWD - -QT += gui jsondbcompat jsondbcompat-private - -PRIVATE_HEADERS += \ - $$PWD/qsimplegalleryresultset.h \ - $$PWD/qsimplegalleryqueryresultset.h \ - $$PWD/qsimplegalleryitemresultset.h \ - $$PWD/qgallerysimpleutility.h \ - $$PWD/qmdlite.h \ - $$PWD/qmdlitemusic.h \ - $$PWD/qmdlite_p.h \ - $$PWD/qmdlitemusic_p.h - -SOURCES += \ - $$PWD/qdocumentgallery_simple.cpp \ - $$PWD/qsimplegalleryqueryresultset.cpp \ - $$PWD/qsimplegalleryitemresultset.cpp \ - $$PWD/qsimplegalleryresultset.cpp \ - $$PWD/qgallerysimpleutility.cpp \ - $$PWD/qmdlite.cpp \ - $$PWD/qmdlitemusic.cpp - -QMDLITE_SQLITE=$$(QMDLITE_SQLITE) -!isEmpty(QMDLITE_SQLITE) { - DEFINES += _SQLITE_QMDBACKEND - QT += sql - SOURCES += $$PWD/qmdlitequeryresultsqlite.cpp - PRIVATE_HEADERS += $$PWD/qmdlitequeryresultsqlite_p.h - message(Setting SQLITE) -} else { - SOURCES += $$PWD/qmdlitequeryresultjsondb.cpp - PRIVATE_HEADERS += $$PWD/qmdlitequeryresultjsondb_p.h - message(Setting JSONDB) -} diff --git a/tests/auto/qdocumentgallery/qdocumentgallery.pro b/tests/auto/qdocumentgallery/qdocumentgallery.pro index 422667c..d217a9d 100644 --- a/tests/auto/qdocumentgallery/qdocumentgallery.pro +++ b/tests/auto/qdocumentgallery/qdocumentgallery.pro @@ -4,7 +4,5 @@ SOURCES += tst_qdocumentgallery.cpp linux-*: { contains(QT_CONFIG, dbus): contains(tracker_enabled, yes): DEFINES += QT_TRACKER_ENABLED - - contains(QT_CONFIG, jsondb): DEFINES += QT_SIMPLE_ENABLED } DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0 diff --git a/tests/auto/qdocumentgallery/tst_qdocumentgallery.cpp b/tests/auto/qdocumentgallery/tst_qdocumentgallery.cpp index 36daaab..67b0b20 100644 --- a/tests/auto/qdocumentgallery/tst_qdocumentgallery.cpp +++ b/tests/auto/qdocumentgallery/tst_qdocumentgallery.cpp @@ -41,7 +41,7 @@ //TESTED_COMPONENT=src/gallery -#include <qdocumentgallery.h> +#include <QtDocGallery/qdocumentgallery.h> #include <QtTest/QtTest> @@ -65,7 +65,7 @@ private: void tst_QDocumentGallery::isRequestSupported() { -#if (defined(Q_OS_LINUX) && (defined(QT_TRACKER_ENABLED) || defined(QT_SIMPLE_ENABLED))) +#if (defined(Q_OS_LINUX) && defined(QT_TRACKER_ENABLED)) const bool platformSupported = true; #else const bool platformSupported = false; @@ -73,12 +73,7 @@ void tst_QDocumentGallery::isRequestSupported() QCOMPARE(gallery.isRequestSupported(QGalleryAbstractRequest::QueryRequest), platformSupported); QCOMPARE(gallery.isRequestSupported(QGalleryAbstractRequest::ItemRequest), platformSupported); - -#if defined(Q_OS_LINUX) && defined(QT_SIMPLE_ENABLED) - QCOMPARE(gallery.isRequestSupported(QGalleryAbstractRequest::TypeRequest), false); -#else QCOMPARE(gallery.isRequestSupported(QGalleryAbstractRequest::TypeRequest), platformSupported); -#endif QCOMPARE(gallery.isRequestSupported(QGalleryAbstractRequest::RequestType(1000)), false); } @@ -133,15 +128,6 @@ void tst_QDocumentGallery::itemTypeProperties_data() << QDocumentGallery::trackNumber << QDocumentGallery::performer << QDocumentGallery::composer -#elif defined(QT_SIMPLE_ENABLED) - << QDocumentGallery::url - << QDocumentGallery::title - << QDocumentGallery::artist - << QDocumentGallery::albumTitle - << QDocumentGallery::albumArtist - << QDocumentGallery::trackNumber - << QDocumentGallery::genre - << QLatin1String("albumArt") #endif #endif ); @@ -155,11 +141,6 @@ void tst_QDocumentGallery::itemTypeProperties_data() << QDocumentGallery::duration << QDocumentGallery::title << QDocumentGallery::trackCount -#elif defined(QT_SIMPLE_ENABLED) - << QLatin1String("albumArt") - << QDocumentGallery::title - << QDocumentGallery::artist - << QDocumentGallery::albumArtist #endif #endif ); @@ -259,9 +240,7 @@ void tst_QDocumentGallery::propertyAttributes() QFETCH(QString, itemType); QFETCH(QString, propertyName); QFETCH(QGalleryProperty::Attributes, propertyAttributes); -#if !defined(QT_SIMPLE_ENABLED) QCOMPARE(int(gallery.propertyAttributes(propertyName, itemType)), int(propertyAttributes)); -#endif } #include "tst_qdocumentgallery.moc" |