summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndrew den Exter <andrew.den-exter@nokia.com>2010-08-03 12:50:04 +1000
committerAndrew den Exter <andrew.den-exter@nokia.com>2010-08-03 12:50:04 +1000
commit2e834676ce47e03e5e8aad855119c29792b611a1 (patch)
tree56a33d8fb0e2cee7ec103d907fb55043aa9e577c
parent700b91a84e053df95188c2e72d2a5132bf434247 (diff)
Restore QGalleryItemRequest and QGalleryTypeRequest.
QGalleryTypeRequest was QGalleryCountRequest.
-rw-r--r--plugins/declarative/gallery/gallery.pro6
-rw-r--r--plugins/declarative/gallery/qdeclarativegallery.cpp2
-rw-r--r--plugins/declarative/gallery/qdeclarativegalleryitem.cpp4
-rw-r--r--plugins/declarative/gallery/qdeclarativegalleryitem.h17
-rw-r--r--plugins/declarative/gallery/qdeclarativegallerytype.cpp331
-rw-r--r--plugins/declarative/gallery/qdeclarativegallerytype.h170
-rw-r--r--src/gallery/gallery.pro9
-rw-r--r--src/gallery/maemo5/maemo5.pri6
-rw-r--r--src/gallery/maemo5/qdocumentgallery_maemo5.cpp65
-rw-r--r--src/gallery/maemo5/qgallerytrackerschema.cpp33
-rw-r--r--src/gallery/maemo5/qgallerytrackerschema_p.h6
-rw-r--r--src/gallery/maemo5/qgallerytrackertyperesultset.cpp308
-rw-r--r--src/gallery/maemo5/qgallerytrackertyperesultset_p.h116
-rw-r--r--src/gallery/qabstractgallery.h2
-rw-r--r--src/gallery/qdocumentgallery.h2
-rw-r--r--src/gallery/qgalleryabstractrequest.cpp6
-rw-r--r--src/gallery/qgalleryabstractrequest.h17
-rw-r--r--src/gallery/qgalleryabstractrequest_p.h5
-rw-r--r--src/gallery/qgalleryitemrequest.cpp363
-rw-r--r--src/gallery/qgalleryitemrequest.h119
-rw-r--r--src/gallery/qgallerynullresultset_p.h84
-rw-r--r--src/gallery/qgalleryqueryrequest.cpp13
-rw-r--r--src/gallery/qgalleryqueryrequest.h3
-rw-r--r--src/gallery/qgalleryremoverequest.cpp2
-rw-r--r--src/gallery/qgalleryresultset.cpp11
-rw-r--r--src/gallery/qgalleryresultset.h3
-rw-r--r--src/gallery/qgallerytyperequest.cpp372
-rw-r--r--src/gallery/qgallerytyperequest.h121
-rw-r--r--tests/auto/auto.pro4
-rw-r--r--tests/auto/qdocumentgallery/tst_qdocumentgallery.cpp6
-rw-r--r--tests/auto/qgalleryabstractrequest/tst_qgalleryabstractrequest.cpp110
-rw-r--r--tests/auto/qgalleryitemrequest/qgalleryitemrequest/qgalleryitemrequest.pro12
-rw-r--r--tests/auto/qgalleryitemrequest/qgalleryitemrequest/tst_qgalleryitemrequest.cpp222
-rw-r--r--tests/auto/qgalleryitemrequest/tst_qgalleryitemrequest.cpp350
-rw-r--r--tests/auto/qgalleryquerymodel/tst_qgalleryquerymodel.cpp2
-rw-r--r--tests/auto/qgalleryqueryrequest/tst_qgalleryqueryrequest.cpp6
-rw-r--r--tests/auto/qgalleryremoverequest/tst_qgalleryremoverequest.cpp6
37 files changed, 2744 insertions, 170 deletions
diff --git a/plugins/declarative/gallery/gallery.pro b/plugins/declarative/gallery/gallery.pro
index 41b826c501..cbd9dab904 100644
--- a/plugins/declarative/gallery/gallery.pro
+++ b/plugins/declarative/gallery/gallery.pro
@@ -25,13 +25,15 @@ QT += declarative
HEADERS += \
qdeclarativegalleryfilter.h \
qdeclarativegalleryitem.h \
- qdeclarativegalleryquerymodel.h
+ qdeclarativegalleryquerymodel.h \
+ qdeclarativegallerytype.h
SOURCES += \
qdeclarativegallery.cpp \
qdeclarativegalleryfilter.cpp \
qdeclarativegalleryitem.cpp \
- qdeclarativegalleryquerymodel.cpp
+ qdeclarativegalleryquerymodel.cpp \
+ qdeclarativegallerytype.cpp
CONFIG += mobility
MOBILITY += gallery
diff --git a/plugins/declarative/gallery/qdeclarativegallery.cpp b/plugins/declarative/gallery/qdeclarativegallery.cpp
index a9c443ccd2..cfd593c91f 100644
--- a/plugins/declarative/gallery/qdeclarativegallery.cpp
+++ b/plugins/declarative/gallery/qdeclarativegallery.cpp
@@ -47,6 +47,7 @@
#include "qdeclarativegalleryfilter.h"
#include "qdeclarativegalleryitem.h"
#include "qdeclarativegalleryquerymodel.h"
+#include "qdeclarativegallerytype.h"
QML_DECLARE_TYPE(QTM_PREPEND_NAMESPACE(QAbstractGallery))
QML_DECLARE_TYPE(QTM_PREPEND_NAMESPACE(QDocumentGallery))
@@ -67,6 +68,7 @@ public:
qmlRegisterType<QDeclarativeGalleryFilterIntersection>(uri, 1, 1, "GalleryFilterIntersection");
qmlRegisterType<QDeclarativeGalleryItem>(uri, 1, 1, "GalleryItem");
qmlRegisterType<QDeclarativeGalleryQueryModel>(uri, 1, 1, "GalleryQueryModel");
+ qmlRegisterType<QDeclarativeGalleryType>(uri, 1, 1, "GalleryType");
qmlRegisterType<QAbstractGallery>();
qmlRegisterType<QDocumentGallery>(uri, 1, 1, "DocumentGallery");
}
diff --git a/plugins/declarative/gallery/qdeclarativegalleryitem.cpp b/plugins/declarative/gallery/qdeclarativegalleryitem.cpp
index 975408b545..b6178ff9d9 100644
--- a/plugins/declarative/gallery/qdeclarativegalleryitem.cpp
+++ b/plugins/declarative/gallery/qdeclarativegalleryitem.cpp
@@ -63,8 +63,6 @@ QDeclarativeGalleryItem::QDeclarativeGalleryItem(QObject *parent)
, m_metaData(0)
, m_complete(false)
{
- m_request.setScope(QGalleryAbstractRequest::RootItem);
-
connect(&m_request, SIGNAL(succeeded()), this, SIGNAL(succeeded()));
connect(&m_request, SIGNAL(cancelled()), this, SIGNAL(cancelled()));
connect(&m_request, SIGNAL(stateChanged(QGalleryAbstractRequest::State)),
@@ -298,7 +296,7 @@ void QDeclarativeGalleryItem::_q_resultSetChanged(QGalleryResultSet *resultSet)
void QDeclarativeGalleryItem::_q_itemsInserted(int index, int)
{
if (index == 0) {
- m_request.seek(0);
+ m_resultSet->seek(0, false);
typedef QHash<int, QString>::const_iterator iterator;
for (iterator it = m_propertyKeys.constBegin(); it != m_propertyKeys.constEnd(); ++it) {
diff --git a/plugins/declarative/gallery/qdeclarativegalleryitem.h b/plugins/declarative/gallery/qdeclarativegalleryitem.h
index 53444bebcf..091fd4e2a7 100644
--- a/plugins/declarative/gallery/qdeclarativegalleryitem.h
+++ b/plugins/declarative/gallery/qdeclarativegalleryitem.h
@@ -42,7 +42,7 @@
#ifndef QDECLARATIVEGALLERYITEM_H
#define QDECLARATIVEGALLERYITEM_H
-#include <qgalleryqueryrequest.h>
+#include <qgalleryitemrequest.h>
#include <QtCore/qpointer.h>
#include <QtCore/qurl.h>
@@ -65,10 +65,9 @@ class QDeclarativeGalleryItem : public QObject, public QDeclarativeParserStatus
Q_PROPERTY(QStringList properties READ propertyNames WRITE setPropertyNames)
Q_PROPERTY(bool live READ isLive WRITE setLive)
Q_PROPERTY(QVariant item READ itemId WRITE setItemId)
- Q_PROPERTY(bool available READ isAvailable NOTIFY availableChanged)
- Q_PROPERTY(QString itemType READ itemType NOTIFY availableChanged)
- Q_PROPERTY(QUrl itemUrl READ itemUrl NOTIFY availableChanged)
- Q_PROPERTY(QObject *metaData READ metaData NOTIFY metaDataChanged)
+// Q_PROPERTY(QString itemType READ itemType NOTIFY availableChanged)
+// Q_PROPERTY(QUrl itemUrl READ itemUrl NOTIFY availableChanged)
+// Q_PROPERTY(QObject *metaData READ metaData NOTIFY metaDataChanged)
public:
enum State
{
@@ -108,11 +107,9 @@ public:
bool isLive() const { return m_request.isLive(); }
void setLive(bool live) { m_request.setLive(live); }
- QVariant itemId() const { return m_request.rootItem(); }
+ QVariant itemId() const { return m_request.itemId(); }
void setItemId(const QVariant &itemId) {
- m_request.setRootItem(itemId); if (m_complete) m_request.execute(); }
-
- bool isAvailable() const { return m_request.currentIndex() >= 0; }
+ m_request.setItemId(itemId); if (m_complete) m_request.execute(); }
QString itemType() const { return m_request.itemType(); }
QUrl itemUrl() const { return m_request.itemUrl(); }
@@ -147,7 +144,7 @@ private Q_SLOTS:
m_request.setMetaData(key, value); }
private:
- QGalleryQueryRequest m_request;
+ QGalleryItemRequest m_request;
QGalleryResultSet *m_resultSet;
QDeclarativePropertyMap *m_metaData;
QHash<int, QString> m_propertyKeys;
diff --git a/plugins/declarative/gallery/qdeclarativegallerytype.cpp b/plugins/declarative/gallery/qdeclarativegallerytype.cpp
new file mode 100644
index 0000000000..880fe111bc
--- /dev/null
+++ b/plugins/declarative/gallery/qdeclarativegallerytype.cpp
@@ -0,0 +1,331 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the Qt Mobility Components.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, 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.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qdeclarativegallerytype.h"
+
+#include <qgalleryresultset.h>
+
+#include <QtDeclarative/qdeclarativepropertymap.h>
+
+QTM_BEGIN_NAMESPACE
+
+/*!
+ \qmlclass GalleryType QDeclarativeGalleryType
+ \brief The GalleryType element allows you to request information about a
+ single item from a gallery
+
+ This element is part of the \bold {QtMobility.gallery 1.0} module.
+
+ \sa GalleryQueryModel, GalleryQueryCount
+*/
+
+QDeclarativeGalleryType::QDeclarativeGalleryType(QObject *parent)
+ : QObject(parent)
+ , m_resultSet(0)
+ , m_metaData(0)
+ , m_complete(false)
+{
+ connect(&m_request, SIGNAL(succeeded()), this, SIGNAL(succeeded()));
+ connect(&m_request, SIGNAL(cancelled()), this, SIGNAL(cancelled()));
+ connect(&m_request, SIGNAL(stateChanged(QGalleryAbstractRequest::State)),
+ this, SIGNAL(stateChanged()));
+ connect(&m_request, SIGNAL(resultChanged()), this, SIGNAL(resultChanged()));
+ connect(&m_request, SIGNAL(progressChanged(int,int)), this, SIGNAL(progressChanged()));
+ connect(&m_request, SIGNAL(resultChanged()), this, SIGNAL(resultChanged()));
+ connect(&m_request, SIGNAL(failed(int)), this, SIGNAL(failed(int)));
+ connect(&m_request, SIGNAL(finished(int)), this, SIGNAL(finished(int)));
+
+ connect(&m_request, SIGNAL(resultSetChanged(QGalleryResultSet*)),
+ this, SLOT(_q_resultSetChanged(QGalleryResultSet*)));
+
+ m_metaData = new QDeclarativePropertyMap(this);
+
+ connect(m_metaData, SIGNAL(valueChanged(QString,QVariant)),
+ this, SLOT(_q_valueChanged(QString,QVariant)));
+}
+
+QDeclarativeGalleryType::~QDeclarativeGalleryType()
+{
+}
+
+/*!
+ \qmlproperty QAbstractGallery GalleryType::gallery
+
+ This property holds the gallery an item should be requested from.
+*/
+
+/*!
+ \qmlproperty enum GalleryType::state
+
+ This property holds the state of an item request. It can be one of:
+
+ \list
+ \o Inactive The request has finished.
+ \o Active The request is currently executing.
+ \o Cancelling The request has been cancelled, but has yet reached the
+ Inactive state.
+ \o Idle The request has finished and is monitoring its result set for
+ changes.
+ \endlist
+*/
+
+/*!
+ \qmlproperty enum GalleryType::result
+
+ The property holds the result of an item request. It can be one of:
+
+ \list
+ \o NoResult The request is still executing.
+ \o Succeeded The request finished successfully.
+ \o Cancelled The request was cancelled.
+ \o NoGallery No \l gallery was specified.
+ \o NotSupported Item requests are not supported by the \l gallery.
+ \o ConnectionError The request failed due to a connection error.
+ \o InvalidItemError The request failed because the value of \l item
+ is not a valid item ID.
+ \endlist
+*/
+
+/*!
+ \qmlproperty int GalleryType::currentProgress
+
+ This property holds the current progress value.
+*/
+
+/*!
+ \qmlproperty int GalleryType::maximumProgress
+
+ This property holds the maximum progress value.
+*/
+
+/*!
+ \qmlproperty QStringList GalleryType::properties
+
+ This property holds the item properties a request should return values for.
+*/
+
+/*!
+ \qmlproperty bool GalleryType::live
+
+ This property holds whether a request should refresh its results
+ automatically.
+*/
+
+/*!
+ \qmlproperty variant GalleryType::item
+
+ This property holds the id of the item to return information about.
+*/
+
+/*!
+ \qmlproperty string GalleryType::itemType
+
+ This property holds the type of a gallery item.
+*/
+
+/*!
+ \qmlproperty object GalleryType::metaData
+
+ This property holds the meta-data of a gallery item.
+*/
+
+/*!
+ \qmlmethod GalleryType::reload()
+
+ Re-queries the gallery.
+*/
+
+/*!
+ \qmlmethod GalleryType::cancel()
+
+ Cancels an executing request.
+*/
+
+/*!
+ \qmlmethod GalleryType::clear()
+
+ Clears the results of a request.
+*/
+
+/*!
+ \qmlsignal GalleryType::onSucceeded()
+
+ Signals that a request has finished successfully.
+*/
+
+/*!
+ \qmlsignal GalleryType::onCancelled()
+
+ Signals that a request was cancelled.
+*/
+
+/*!
+ \qmlsignal GalleryType::onFailed(error)
+
+ Signals that a request failed with the given \a error.
+*/
+
+/*!
+ \qmlsignal GalleryType::onFinished(result)
+
+ Signals that a request finished with the given \a result.
+*/
+
+void QDeclarativeGalleryType::classBegin()
+{
+}
+
+void QDeclarativeGalleryType::componentComplete()
+{
+ m_complete = true;
+
+ if (!m_request.itemType().isEmpty())
+ m_request.execute();
+}
+
+void QDeclarativeGalleryType::_q_resultSetChanged(QGalleryResultSet *resultSet)
+{
+ if (m_resultSet && m_resultSet->itemCount() > 0) {
+ typedef QHash<int, QString>::const_iterator iterator;
+ for (iterator it = m_propertyKeys.constBegin(); it != m_propertyKeys.constEnd(); ++it)
+ m_metaData->insert(it.value(), QVariant(m_resultSet->propertyType(it.key())));
+ }
+
+ m_resultSet = resultSet;
+ m_propertyKeys.clear();
+
+ if (m_resultSet) {
+ const QStringList propertyNames = m_request.propertyNames();
+
+ typedef QStringList::const_iterator iterator;
+ if (m_resultSet->itemCount() > 0) {
+ m_resultSet->seek(0, false);
+
+ for (iterator it = propertyNames.begin(); it != propertyNames.end(); ++it) {
+ const int key = m_resultSet->propertyKey(*it);
+
+ m_propertyKeys.insert(key, *it);
+
+ QVariant value = m_resultSet->metaData(key);
+ m_metaData->insert(*it, value.isNull()
+ ? QVariant(m_resultSet->propertyType(key))
+ : value);
+ }
+ } else {
+ for (iterator it = propertyNames.begin(); it != propertyNames.end(); ++it) {
+ const int key = m_resultSet->propertyKey(*it);
+ m_propertyKeys.insert(key, *it);
+
+ m_metaData->insert(*it, QVariant(m_resultSet->propertyType(key)));
+ }
+ }
+
+ connect(m_resultSet, SIGNAL(inserted(int,int)), this, SLOT(_q_itemsInserted(int,int)));
+ connect(m_resultSet, SIGNAL(removed(int,int)), this, SLOT(_q_itemsRemoved(int,int)));
+ connect(m_resultSet, SIGNAL(metaDataChanged(int,int,QList<int>)),
+ this, SLOT(_q_metaDataChanged(int,int,QList<int>)));
+ }
+
+ emit availableChanged();
+}
+
+void QDeclarativeGalleryType::_q_itemsInserted(int index, int)
+{
+ if (index == 0) {
+ m_resultSet->seek(0, false);
+
+ typedef QHash<int, QString>::const_iterator iterator;
+ for (iterator it = m_propertyKeys.constBegin(); it != m_propertyKeys.constEnd(); ++it) {
+ QVariant value = m_resultSet->metaData(it.key());
+ m_metaData->insert(it.value(), value.isNull()
+ ? QVariant(m_resultSet->propertyType(it.key()))
+ : value);
+ }
+
+ emit availableChanged();
+ }
+}
+
+void QDeclarativeGalleryType::_q_itemsRemoved(int index, int)
+{
+ if (index == 0) {
+ typedef QHash<int, QString>::const_iterator iterator;
+ for (iterator it = m_propertyKeys.constBegin(); it != m_propertyKeys.constEnd(); ++it)
+ m_metaData->insert(it.value(), QVariant(m_resultSet->propertyType(it.key())));
+
+ emit availableChanged();
+ }
+
+ if (m_resultSet->itemCount() == 0) {
+ typedef QHash<int, QString>::const_iterator iterator;
+ for (iterator it = m_propertyKeys.constBegin(); it != m_propertyKeys.constEnd(); ++it)
+ m_metaData->insert(it.value(), QVariant(m_resultSet->propertyType(it.key())));
+
+ emit availableChanged();
+ } else if (index == 0) {
+
+ }
+}
+
+void QDeclarativeGalleryType::_q_metaDataChanged(int index, int, const QList<int> &keys)
+{
+ if (index == 0 && keys.isEmpty()) {
+ typedef QHash<int, QString>::const_iterator iterator;
+ for (iterator it = m_propertyKeys.constBegin(); it != m_propertyKeys.constEnd(); ++it) {
+ QVariant value = m_resultSet->metaData(it.key());
+ m_metaData->insert(it.value(), value.isNull()
+ ? QVariant(m_resultSet->propertyType(it.key()))
+ : value);
+ }
+ } else if (index == 0) {
+ typedef QList<int>::const_iterator iterator;
+ for (iterator it = keys.begin(); it != keys.end(); ++it){
+ QVariant value = m_resultSet->metaData(*it);
+ m_metaData->insert(m_propertyKeys.value(*it), value.isNull()
+ ? QVariant(m_resultSet->propertyType(*it))
+ : value);
+ }
+ }
+}
+
+#include "moc_qdeclarativegallerytype.cpp"
+
+QTM_END_NAMESPACE
diff --git a/plugins/declarative/gallery/qdeclarativegallerytype.h b/plugins/declarative/gallery/qdeclarativegallerytype.h
new file mode 100644
index 0000000000..093f8b92f9
--- /dev/null
+++ b/plugins/declarative/gallery/qdeclarativegallerytype.h
@@ -0,0 +1,170 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the Qt Mobility Components.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, 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.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QDECLARATIVEGALLERYTYPE_H
+#define QDECLARATIVEGALLERYTYPE_H
+
+#include <qgallerytyperequest.h>
+
+#include <QtCore/qpointer.h>
+#include <QtCore/qurl.h>
+#include <QtDeclarative/qdeclarative.h>
+#include <QtDeclarative/qdeclarativepropertymap.h>
+
+#include "qdeclarativegalleryfilter.h"
+
+QTM_BEGIN_NAMESPACE
+
+class QDeclarativeGalleryType : public QObject, public QDeclarativeParserStatus
+{
+ Q_OBJECT
+ Q_INTERFACES(QDeclarativeParserStatus)
+ Q_ENUMS(State)
+ Q_ENUMS(Result)
+ Q_PROPERTY(QAbstractGallery* gallery READ gallery WRITE setGallery)
+ Q_PROPERTY(State state READ state NOTIFY stateChanged)
+ Q_PROPERTY(Result result READ result NOTIFY resultChanged)
+ Q_PROPERTY(int currentProgress READ currentProgress NOTIFY progressChanged)
+ Q_PROPERTY(int maximumProgress READ maximumProgress NOTIFY progressChanged)
+ Q_PROPERTY(QStringList properties READ propertyNames WRITE setPropertyNames)
+ Q_PROPERTY(bool live READ isLive WRITE setLive)
+public:
+ enum State
+ {
+ Inactive = QGalleryAbstractRequest::Inactive,
+ Active = QGalleryAbstractRequest::Active,
+ Cancelling = QGalleryAbstractRequest::Cancelling,
+ Idle = QGalleryAbstractRequest::Idle
+ };
+
+ enum Result
+ {
+ NoResult = QGalleryAbstractRequest::NoResult,
+ Succeeded = QGalleryAbstractRequest::NoResult,
+ Cancelled = QGalleryAbstractRequest::NoResult,
+ NoGallery = QGalleryAbstractRequest::NoResult,
+ NotSupported = QGalleryAbstractRequest::NoResult,
+ ConnectionError = QGalleryAbstractRequest::NoResult,
+ InvalidItemError = QGalleryAbstractRequest::NoResult
+ };
+
+ enum Scope
+ {
+ AllDescendants = QGalleryAbstractRequest::AllDescendants,
+ DirectDescendants = QGalleryAbstractRequest::DirectDescendants
+ };
+
+ QDeclarativeGalleryType(QObject *parent = 0);
+ ~QDeclarativeGalleryType();
+
+ QAbstractGallery *gallery() const { return m_request.gallery(); }
+ void setGallery(QAbstractGallery *gallery) { m_request.setGallery(gallery); }
+
+ State state() const { return State(m_request.state()); }
+ Result result() const { return Result(m_request.result()); }
+
+ int currentProgress() const { return m_request.currentProgress(); }
+ int maximumProgress() const { return m_request.maximumProgress(); }
+
+ QStringList propertyNames() { return m_request.propertyNames(); }
+ void setPropertyNames(const QStringList &names) {
+ if (!m_complete) m_request.setPropertyNames(names); }
+
+ bool isLive() const { return m_request.isLive(); }
+ void setLive(bool live) { m_request.setLive(live); }
+
+ QString itemType() const { return m_request.itemType(); }
+ void setItemType(const QString itemType) {
+ m_request.setItemType(itemType); if (m_complete) m_request.execute(); }
+
+ Scope scope() const { return Scope(m_request.scope()); }
+ void setScope(Scope scope) { m_request.setScope(QGalleryAbstractRequest::Scope(scope)); }
+
+ QVariant rootItem() const { return m_request.rootItem(); }
+ void setRootItem(const QVariant &itemId) {
+ m_request.setRootItem(itemId); emit rootItemChanged(); }
+
+ QDeclarativeGalleryFilterBase *filter() const { return m_filter; }
+ void setFilter(QDeclarativeGalleryFilterBase *filter) { m_filter = filter; filterChanged(); }
+
+ QObject *metaData() const { return m_metaData; }
+
+ void classBegin();
+ void componentComplete();
+
+public Q_SLOTS:
+ void reload() { m_request.execute(); }
+ void cancel() { m_request.cancel(); }
+ void clear() { m_request.clear(); }
+
+Q_SIGNALS:
+ void succeeded();
+ void cancelled();
+ void failed(int result);
+ void finished(int result);
+ void stateChanged();
+ void resultChanged();
+ void progressChanged();
+ void availableChanged();
+ void metaDataChanged();
+ void rootItemChanged();
+ void filterChanged();
+
+private Q_SLOTS:
+ void _q_resultSetChanged(QGalleryResultSet *resultSet);
+ void _q_itemsInserted(int index, int count);
+ void _q_itemsRemoved(int index, int count);
+ void _q_metaDataChanged(int index, int count, const QList<int> &keys);
+
+private:
+ QGalleryTypeRequest m_request;
+ QGalleryResultSet *m_resultSet;
+ QDeclarativePropertyMap *m_metaData;
+ QPointer<QDeclarativeGalleryFilterBase> m_filter;
+ QHash<int, QString> m_propertyKeys;
+ bool m_complete;
+};
+
+QTM_END_NAMESPACE
+
+QML_DECLARE_TYPE(QTM_PREPEND_NAMESPACE(QDeclarativeGalleryType))
+
+#endif
diff --git a/src/gallery/gallery.pro b/src/gallery/gallery.pro
index c5e8fc5a8d..042e98b565 100644
--- a/src/gallery/gallery.pro
+++ b/src/gallery/gallery.pro
@@ -12,6 +12,7 @@ PRIVATE_HEADERS = \
qabstractgallery_p.h \
qgalleryabstractrequest_p.h \
qgalleryabstractresponse_p.h \
+ qgallerynullresultset_p.h \
qgalleryresultset_p.h
PUBLIC_HEADERS = \
@@ -20,13 +21,15 @@ PUBLIC_HEADERS = \
qgalleryabstractrequest.h \
qgalleryabstractresponse.h \
qgalleryfilter.h \
+ qgalleryitemrequest.h \
qgalleryproperty.h \
qgalleryquerymodel.h \
qgalleryqueryrequest.h \
qgalleryremoverequest.h \
qgalleryresource.h \
qgalleryresultset.h \
- qgallerytype.h
+ qgallerytype.h \
+ qgallerytyperequest.h
SOURCES = \
qabstractgallery.cpp \
@@ -34,13 +37,15 @@ SOURCES = \
qgalleryabstractrequest.cpp \
qgalleryabstractresponse.cpp \
qgalleryfilter.cpp \
+ qgalleryitemrequest.cpp \
qgalleryproperty.cpp \
qgalleryquerymodel.cpp \
qgalleryqueryrequest.cpp \
qgalleryremoverequest.cpp \
qgalleryresource.cpp \
qgalleryresultset.cpp \
- qgallerytype.cpp
+ qgallerytype.cpp \
+ qgallerytyperequest.cpp
HEADERS = $$PUBLIC_HEADERS $$PRIVATE_HEADERS
diff --git a/src/gallery/maemo5/maemo5.pri b/src/gallery/maemo5/maemo5.pri
index 143fcd3e52..7420b83c5c 100644
--- a/src/gallery/maemo5/maemo5.pri
+++ b/src/gallery/maemo5/maemo5.pri
@@ -14,7 +14,8 @@ HEADERS += \
$$PWD/qgallerytrackerlistcolumn_p.h \
$$PWD/qgallerytrackermetadataedit_p.h \
$$PWD/qgallerytrackerremoveresponse_p.h \
- $$PWD/qgallerytrackerschema_p.h
+ $$PWD/qgallerytrackerschema_p.h \
+ $$PWD/qgallerytrackertyperesultset_p.h
SOURCES += \
$$PWD/qgallerydbusinterface.cpp \
@@ -25,4 +26,5 @@ SOURCES += \
$$PWD/qgallerytrackerlistcolumn.cpp \
$$PWD/qgallerytrackermetadataedit.cpp \
$$PWD/qgallerytrackerremoveresponse.cpp \
- $$PWD/qgallerytrackerschema.cpp
+ $$PWD/qgallerytrackerschema.cpp \
+ $$PWD/qgallerytrackertyperesultset.cpp
diff --git a/src/gallery/maemo5/qdocumentgallery_maemo5.cpp b/src/gallery/maemo5/qdocumentgallery_maemo5.cpp
index 63fad7d3f2..43872b3a10 100644
--- a/src/gallery/maemo5/qdocumentgallery_maemo5.cpp
+++ b/src/gallery/maemo5/qdocumentgallery_maemo5.cpp
@@ -43,13 +43,16 @@
#include "qabstractgallery_p.h"
+#include "qgalleryitemrequest.h"
#include "qgalleryqueryrequest.h"
#include "qgalleryremoverequest.h"
+#include "qgallerytyperequest.h"
#include "qgallerytrackerchangenotifier_p.h"
#include "qgallerytrackeritemresponse_p.h"
#include "qgallerytrackerremoveresponse_p.h"
#include "qgallerytrackerschema_p.h"
+#include "qgallerytrackertyperesultset_p.h"
#include <QtCore/qmetaobject.h>
#include <QtDBus/qdbusmetatype.h>
@@ -61,6 +64,8 @@ QTM_BEGIN_NAMESPACE
class QDocumentGalleryPrivate : public QAbstractGalleryPrivate, public QGalleryDBusInterfaceFactory
{
public:
+ QGalleryAbstractResponse *createItemResponse(QGalleryItemRequest *request);
+ QGalleryAbstractResponse *createTypeResponse(QGalleryTypeRequest *request);
QGalleryAbstractResponse *createFilterResponse(QGalleryQueryRequest *request);
QGalleryAbstractResponse *createRemoveResponse(QGalleryRemoveRequest *request);
@@ -158,6 +163,50 @@ QGalleryTrackerChangeNotifier *QDocumentGalleryPrivate::changeNotifier()
return notifier.data();
}
+QGalleryAbstractResponse *QDocumentGalleryPrivate::createItemResponse(QGalleryItemRequest *request)
+{
+ QGalleryTrackerSchema schema = QGalleryTrackerSchema::fromItemId(request->itemId().toString());
+
+ QGalleryTrackerItemListArguments arguments;
+
+ int result = schema.prepareIdResponse(
+ &arguments, this, request->itemId().toString(), request->propertyNames());
+
+ if (result != QGalleryAbstractRequest::Succeeded) {
+ return new QGalleryAbstractResponse(result);
+ } else {
+ return createItemListResponse(arguments, 0, 1, schema.isItemType(), request->isLive());
+ }
+}
+
+QGalleryAbstractResponse *QDocumentGalleryPrivate::createTypeResponse(QGalleryTypeRequest *request)
+{
+ QGalleryTrackerSchema schema(request->itemType());
+
+ QGalleryTrackerTypeResultSetArguments arguments;
+
+ int result = schema.prepareTypeResponse(
+ &arguments,
+ this,
+ request->scope(),
+ request->rootItem().toString(),
+ request->filter());
+
+ if (result != QGalleryAbstractRequest::Succeeded) {
+ return new QGalleryAbstractResponse(result);
+ } else {
+ QGalleryTrackerTypeResultSet *response = new QGalleryTrackerTypeResultSet(arguments);
+
+ if (request->isLive()) {
+ QObject::connect(
+ changeNotifier(), SIGNAL(itemsChanged(int)),
+ response, SLOT(refresh(int)));
+ }
+
+ return response;
+ }
+}
+
QGalleryAbstractResponse *QDocumentGalleryPrivate::createItemListResponse(
const QGalleryTrackerItemListArguments &arguments,
int offset,
@@ -239,11 +288,13 @@ QDocumentGallery::~QDocumentGallery()
{
}
-bool QDocumentGallery::isRequestSupported(QGalleryAbstractRequest::Type type) const
+bool QDocumentGallery::isRequestSupported(QGalleryAbstractRequest::RequestType type) const
{
switch (type) {
- case QGalleryAbstractRequest::Query:
- case QGalleryAbstractRequest::Remove:
+ case QGalleryAbstractRequest::QueryRequest:
+ case QGalleryAbstractRequest::ItemRequest:
+ case QGalleryAbstractRequest::TypeRequest:
+ case QGalleryAbstractRequest::RemoveRequest:
return true;
default:
return false;
@@ -266,9 +317,13 @@ QGalleryAbstractResponse *QDocumentGallery::createResponse(QGalleryAbstractReque
Q_D(QDocumentGallery);
switch (request->type()) {
- case QGalleryAbstractRequest::Query:
+ case QGalleryAbstractRequest::QueryRequest:
return d->createFilterResponse(static_cast<QGalleryQueryRequest *>(request));
- case QGalleryAbstractRequest::Remove:
+ 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;
diff --git a/src/gallery/maemo5/qgallerytrackerschema.cpp b/src/gallery/maemo5/qgallerytrackerschema.cpp
index 6fc6a39d8f..8aee84beab 100644
--- a/src/gallery/maemo5/qgallerytrackerschema.cpp
+++ b/src/gallery/maemo5/qgallerytrackerschema.cpp
@@ -46,6 +46,7 @@
#include "qgallerytrackercountresponse_p.h"
#include "qgallerytrackeritemlist_p.h"
#include "qgallerytrackerlistcolumn_p.h"
+#include "qgallerytrackertyperesultset_p.h"
#include <QtCore/qdatetime.h>
#include <QtCore/qmetatype.h>
@@ -1237,7 +1238,7 @@ int QGalleryTrackerSchema::prepareFilterResponse(
QGalleryTrackerItemListArguments *arguments,
QGalleryDBusInterfaceFactory *dbus,
QGalleryAbstractRequest::Scope scope,
- const QString &scopeItemId,
+ const QString &rootItemId,
const QGalleryFilter &filter,
const QStringList &propertyNames,
const QStringList &sortPropertyNames) const
@@ -1246,8 +1247,8 @@ int QGalleryTrackerSchema::prepareFilterResponse(
QString query;
- if (!scopeItemId.isEmpty() || filter.isValid())
- result = buildFilterQuery(&query, scope, scopeItemId, filter);
+ if (!rootItemId.isEmpty() || filter.isValid())
+ result = buildFilterQuery(&query, scope, rootItemId, filter);
if (result != QGalleryAbstractRequest::Succeeded) {
return result;
@@ -1264,19 +1265,19 @@ int QGalleryTrackerSchema::prepareFilterResponse(
}
}
-int QGalleryTrackerSchema::prepareCountResponse(
- QGalleryTrackerCountResponseArguments *arguments,
+int QGalleryTrackerSchema::prepareTypeResponse(
+ QGalleryTrackerTypeResultSetArguments *arguments,
QGalleryDBusInterfaceFactory *dbus,
QGalleryAbstractRequest::Scope scope,
- const QString &scopeItemId,
+ const QString &rootItemId,
const QGalleryFilter &filter) const
{
int result = QGalleryAbstractRequest::Succeeded;
QString query;
- if (!scopeItemId.isEmpty() || filter.isValid())
- result = buildFilterQuery(&query, scope, scopeItemId, filter);
+ if (!rootItemId.isEmpty() || filter.isValid())
+ result = buildFilterQuery(&query, scope, rootItemId, filter);
if (result != QGalleryAbstractRequest::Succeeded) {
return result;
@@ -1332,7 +1333,7 @@ int QGalleryTrackerSchema::prepareCountResponse(
int QGalleryTrackerSchema::buildFilterQuery(
QString *query,
QGalleryAbstractRequest::Scope scope,
- const QString &scopeItemId,
+ const QString &rootItemId,
const QGalleryFilter &filter) const
{
const QGalleryItemTypeList itemTypes(qt_galleryItemTypeList);
@@ -1343,29 +1344,29 @@ int QGalleryTrackerSchema::buildFilterQuery(
QXmlStreamWriter xml(query);
xml.writeStartElement(QLatin1String("rdfq:Condition"));
- if (!scopeItemId.isEmpty()) {
+ if (!rootItemId.isEmpty()) {
if (filter.isValid())
xml.writeStartElement(QLatin1String("rdfq:and"));
int index;
- if ((index = itemTypes.indexOfItemId(scopeItemId)) != -1) {
+ if ((index = itemTypes.indexOfItemId(rootItemId)) != -1) {
switch (scope) {
case QGalleryAbstractRequest::AllDescendants:
qt_writeFileScopeCondition(
- &result, &xml, itemTypes[index].prefix.strip(scopeItemId));
+ &result, &xml, itemTypes[index].prefix.strip(rootItemId));
break;
case QGalleryAbstractRequest::DirectDescendants:
qt_writeFileContainerCondition(
- &result, &xml, itemTypes[index].prefix.strip(scopeItemId));
+ &result, &xml, itemTypes[index].prefix.strip(rootItemId));
break;
default:
result = QGalleryAbstractRequest::InvalidPropertyError;
break;
}
- } else if ((index = aggregateTypes.indexOfItemId((scopeItemId))) != -1) {
+ } else if ((index = aggregateTypes.indexOfItemId((rootItemId))) != -1) {
aggregateTypes[index].writeIdCondition(
- &result, &xml, aggregateTypes[index].prefix.strip(scopeItemId));
+ &result, &xml, aggregateTypes[index].prefix.strip(rootItemId));
} else {
result = QGalleryAbstractRequest::InvalidItemError;
}
@@ -1389,7 +1390,7 @@ int QGalleryTrackerSchema::buildFilterQuery(
}
}
- if (!scopeItemId.isEmpty() && filter.isValid())
+ if (!rootItemId.isEmpty() && filter.isValid())
xml.writeEndElement();
xml.writeEndElement();
diff --git a/src/gallery/maemo5/qgallerytrackerschema_p.h b/src/gallery/maemo5/qgallerytrackerschema_p.h
index 2054cf84ce..e5667aa6aa 100644
--- a/src/gallery/maemo5/qgallerytrackerschema_p.h
+++ b/src/gallery/maemo5/qgallerytrackerschema_p.h
@@ -67,7 +67,7 @@ class QGalleryTrackerImageColumn;
class QGalleryTrackerValueColumn;
struct QGalleryTrackerItemListArguments;
-struct QGalleryTrackerCountResponseArguments;
+struct QGalleryTrackerTypeResultSetArguments;
class QGalleryTrackerSchema
{
@@ -106,8 +106,8 @@ public:
const QStringList &propertyNames,
const QStringList &sortPropertyNames) const;
- int prepareCountResponse(
- QGalleryTrackerCountResponseArguments *arguments,
+ int prepareTypeResponse(
+ QGalleryTrackerTypeResultSetArguments *arguments,
QGalleryDBusInterfaceFactory *dbus,
QGalleryAbstractRequest::Scope scope,
const QString &scopeItemId,
diff --git a/src/gallery/maemo5/qgallerytrackertyperesultset.cpp b/src/gallery/maemo5/qgallerytrackertyperesultset.cpp
new file mode 100644
index 0000000000..4b84a6c6d4
--- /dev/null
+++ b/src/gallery/maemo5/qgallerytrackertyperesultset.cpp
@@ -0,0 +1,308 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the Qt Mobility Components.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, 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.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qgallerytrackertyperesultset_p.h"
+
+#include "qgallerytrackerschema_p.h"
+
+#include <QtCore/qdatetime.h>
+#include <QtDBus/qdbuspendingreply.h>
+
+#include "qgalleryresultset_p.h"
+
+Q_DECLARE_METATYPE(QVector<QStringList>)
+
+QTM_BEGIN_NAMESPACE
+
+class QGalleryTrackerTypeResultSetPrivate : public QGalleryResultSetPrivate
+{
+ Q_DECLARE_PUBLIC(QGalleryTrackerTypeResultSet)
+public:
+ QGalleryTrackerTypeResultSetPrivate(const QGalleryTrackerTypeResultSetArguments &arguments)
+ : accumulative(arguments.accumulative)
+ , cancelled(false)
+ , refresh(false)
+ , updateMask(arguments.updateMask)
+ , currentIndex(-1)
+ , count(0)
+ , workingCount(0)
+ , currentOffset(0)
+ , queryWatcher(0)
+ , queryInterface(arguments.queryInterface)
+ , queryMethod(arguments.queryMethod)
+ , queryArguments(arguments.queryArguments)
+ {
+ }
+
+ void _q_queryFinished(QDBusPendingCallWatcher *watcher);
+ void queryFinished(const QDBusPendingCall &call);
+
+ void queryCount();
+
+ const bool accumulative;
+ bool cancelled;
+ bool refresh;
+ const int updateMask;
+ int currentIndex;
+ int count;
+ int workingCount;
+ int currentOffset;
+ QDBusPendingCallWatcher *queryWatcher;
+ const QGalleryDBusInterfacePointer queryInterface;
+ const QString queryMethod;
+ const QVariantList queryArguments;
+};
+
+void QGalleryTrackerTypeResultSetPrivate::_q_queryFinished(QDBusPendingCallWatcher *watcher)
+{
+ if (queryWatcher == watcher) {
+ queryWatcher->deleteLater();
+ queryWatcher = 0;
+
+ watcher->deleteLater();
+
+ queryFinished(*watcher);
+ }
+}
+
+void QGalleryTrackerTypeResultSetPrivate::queryFinished(const QDBusPendingCall &call)
+{
+ const int oldCount = count;
+
+ if (call.isError()) {
+ q_func()->finish(QGalleryAbstractRequest::ConnectionError);
+
+ return;
+ } else if (!accumulative) {
+ QDBusPendingReply<int> reply(call);
+
+ count = reply.value();
+
+ if (refresh) {
+ refresh = false;
+
+ queryCount();
+ }
+
+ } else {
+ QDBusPendingReply<QVector<QStringList> > reply(call);
+
+ const QVector<QStringList> counts = reply.value();
+
+ typedef QVector<QStringList>::const_iterator iterator;
+ for (iterator it = counts.begin(), end = counts.end(); it != end; ++it)
+ workingCount += it->value(1).toInt();
+
+ if (refresh) {
+ refresh = false;
+
+ currentOffset = 0;
+ workingCount = 0;
+
+ queryCount();
+ } else {
+ currentOffset += counts.count();
+
+ if (counts.count() != 0) {
+ if (count > workingCount)
+ count = workingCount;
+
+ if (cancelled)
+ q_func()->QGalleryAbstractResponse::cancel();
+ else
+ queryCount();
+ } else {
+ count = workingCount;
+ }
+ }
+ }
+
+ if (count != oldCount)
+ emit q_func()->metaDataChanged(0, 0, QList<int>() << 0);
+
+ if (!queryWatcher)
+ q_func()->finish(QGalleryAbstractRequest::Succeeded);
+}
+
+void QGalleryTrackerTypeResultSetPrivate::queryCount()
+{
+ QVariantList arguments = queryArguments;
+
+ if (accumulative)
+ arguments << currentOffset << int(0);
+
+ QDBusPendingCall call = queryInterface->asyncCallWithArgumentList(queryMethod, arguments);
+
+ if (call.isFinished()) {
+ queryFinished(call);
+ } else {
+ queryWatcher = new QDBusPendingCallWatcher(call, q_func());
+
+ QObject::connect(queryWatcher, SIGNAL(finished(QDBusPendingCallWatcher*)),
+ q_func(), SLOT(_q_queryFinished(QDBusPendingCallWatcher*)));
+ }
+}
+
+QGalleryTrackerTypeResultSet::QGalleryTrackerTypeResultSet(
+ const QGalleryTrackerTypeResultSetArguments &arguments,
+ QObject *parent)
+ : QGalleryResultSet(*new QGalleryTrackerTypeResultSetPrivate(arguments), parent)
+
+{
+ Q_D(QGalleryTrackerTypeResultSet);
+
+ d->queryCount();
+}
+
+QGalleryTrackerTypeResultSet::~QGalleryTrackerTypeResultSet()
+{
+}
+
+int QGalleryTrackerTypeResultSet::propertyKey(const QString &property) const
+{
+ return property == QLatin1String("count") ? 0 : -1;
+}
+
+QGalleryProperty::Attributes QGalleryTrackerTypeResultSet::propertyAttributes(int key) const
+{
+ return key == 0 ? QGalleryProperty::CanRead : QGalleryProperty::Attributes();
+}
+
+QVariant::Type QGalleryTrackerTypeResultSet::propertyType(int key) const
+{
+ return key == 0 ? QVariant::Int : QVariant::Invalid;
+}
+
+int QGalleryTrackerTypeResultSet::itemCount() const
+{
+ return 1;
+}
+
+QVariant QGalleryTrackerTypeResultSet::itemId() const
+{
+ return QVariant();
+}
+
+QUrl QGalleryTrackerTypeResultSet::itemUrl() const
+{
+ return QUrl();
+}
+
+QString QGalleryTrackerTypeResultSet::itemType() const
+{
+ return QString();
+}
+
+QVariant QGalleryTrackerTypeResultSet::metaData(int key) const
+{
+ return d_func()->currentIndex == 0 && key == 0
+ ? d_func()->count
+ : 0;
+}
+
+bool QGalleryTrackerTypeResultSet::setMetaData(int, const QVariant &)
+{
+ return false;
+}
+
+int QGalleryTrackerTypeResultSet::currentIndex() const
+{
+ return d_func()->currentIndex;
+}
+
+bool QGalleryTrackerTypeResultSet::seek(int index, bool relative)
+{
+ d_func()->currentIndex = relative ? d_func()->currentIndex + index : index;
+
+ return d_func()->currentIndex == 0;
+}
+
+void QGalleryTrackerTypeResultSet::cancel()
+{
+ d_func()->cancelled = true;
+ d_func()->refresh = false;
+
+ if (!d_func()->queryWatcher)
+ QGalleryAbstractResponse::cancel();
+}
+
+bool QGalleryTrackerTypeResultSet::waitForFinished(int msecs)
+{
+ Q_D(QGalleryTrackerTypeResultSet);
+
+ QTime timer;
+ timer.start();
+ do {
+ if (QDBusPendingCallWatcher *watcher = d->queryWatcher) {
+ d->queryWatcher = 0;
+
+ watcher->waitForFinished();
+
+ d->queryFinished(*watcher);
+
+ delete watcher;
+
+ if (d->result != QGalleryAbstractRequest::NoResult)
+ return true;
+ } else {
+ return true;
+ }
+ } while ((msecs -= timer.restart()) > 0);
+
+ return false;
+}
+
+void QGalleryTrackerTypeResultSet::refresh(int serviceId)
+{
+ Q_D(QGalleryTrackerTypeResultSet);
+
+ if (!d->cancelled && (d->updateMask & serviceId)) {
+ d->refresh = true;
+
+ if (!d->queryWatcher)
+ d->queryCount();
+
+ }
+}
+
+#include "moc_qgallerytrackertyperesultset_p.cpp"
+
+QTM_END_NAMESPACE
diff --git a/src/gallery/maemo5/qgallerytrackertyperesultset_p.h b/src/gallery/maemo5/qgallerytrackertyperesultset_p.h
new file mode 100644
index 0000000000..952ee501d4
--- /dev/null
+++ b/src/gallery/maemo5/qgallerytrackertyperesultset_p.h
@@ -0,0 +1,116 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the Qt Mobility Components.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, 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.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QGALLERYTRACKERTYPERESULTSET_P_H
+#define QGALLERYTRACKERTYPERESULTSET_P_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 "qgalleryresultset.h"
+
+#include "qgallerydbusinterface_p.h"
+
+#include <QtDBus/qdbusinterface.h>
+#include <QtDBus/qdbuspendingcall.h>
+
+QTM_BEGIN_NAMESPACE
+
+struct QGalleryTrackerTypeResultSetArguments
+{
+ QGalleryTrackerTypeResultSetArguments() : accumulative(false), updateMask(0) {}
+
+ bool accumulative;
+ int updateMask;
+ QGalleryDBusInterfacePointer queryInterface;
+ QString queryMethod;
+ QVariantList queryArguments;
+};
+
+class QGalleryTrackerTypeResultSetPrivate;
+
+class QGalleryTrackerTypeResultSet : public QGalleryResultSet
+{
+ Q_OBJECT
+public:
+ QGalleryTrackerTypeResultSet(
+ const QGalleryTrackerTypeResultSetArguments &arguments, QObject *parent = 0);
+ ~QGalleryTrackerTypeResultSet();
+
+ int propertyKey(const QString &property) const;
+ QGalleryProperty::Attributes propertyAttributes(int key) const;
+ QVariant::Type propertyType(int key) const;
+
+ int itemCount() const;
+
+ QVariant itemId() const;
+ QUrl itemUrl() const;
+ QString itemType() const;
+
+ QVariant metaData(int key) const;
+ bool setMetaData(int key, const QVariant &value);
+
+ int currentIndex() const;
+ bool seek(int index, bool relative);
+
+ bool waitForFinished(int msecs);
+
+ void cancel();
+
+public Q_SLOTS:
+ void refresh(int serviceId = -1);
+
+private:
+ Q_DECLARE_PRIVATE(QGalleryTrackerTypeResultSet)
+ Q_PRIVATE_SLOT(d_func(), void _q_queryFinished(QDBusPendingCallWatcher *))
+};
+
+QTM_END_NAMESPACE
+
+#endif
diff --git a/src/gallery/qabstractgallery.h b/src/gallery/qabstractgallery.h
index 6af1027f82..a3974d902d 100644
--- a/src/gallery/qabstractgallery.h
+++ b/src/gallery/qabstractgallery.h
@@ -55,7 +55,7 @@ public:
QAbstractGallery(QObject *parent = 0);
~QAbstractGallery();
- virtual bool isRequestSupported(QGalleryAbstractRequest::Type type) const = 0;
+ virtual bool isRequestSupported(QGalleryAbstractRequest::RequestType type) const = 0;
protected:
virtual QGalleryAbstractResponse *createResponse(QGalleryAbstractRequest *request) = 0;
diff --git a/src/gallery/qdocumentgallery.h b/src/gallery/qdocumentgallery.h
index 9218fdfde2..1630fa90b0 100644
--- a/src/gallery/qdocumentgallery.h
+++ b/src/gallery/qdocumentgallery.h
@@ -154,7 +154,7 @@ public:
QDocumentGallery(QObject *parent = 0);
~QDocumentGallery();
- bool isRequestSupported(QGalleryAbstractRequest::Type type) const;
+ bool isRequestSupported(QGalleryAbstractRequest::RequestType type) const;
QStringList itemTypePropertyNames(const QString &itemType) const;
QGalleryProperty::Attributes propertyAttributes(
diff --git a/src/gallery/qgalleryabstractrequest.cpp b/src/gallery/qgalleryabstractrequest.cpp
index 5d81c9b9f0..17a0821bc3 100644
--- a/src/gallery/qgalleryabstractrequest.cpp
+++ b/src/gallery/qgalleryabstractrequest.cpp
@@ -187,7 +187,7 @@ void QGalleryAbstractRequestPrivate::_q_progressChanged(int current, int maximum
The \a parent is passed to QObject.
*/
-QGalleryAbstractRequest::QGalleryAbstractRequest(Type type, QObject *parent)
+QGalleryAbstractRequest::QGalleryAbstractRequest(RequestType type, QObject *parent)
: QObject(parent)
, d_ptr(new QGalleryAbstractRequestPrivate(0, type))
{
@@ -201,7 +201,7 @@ QGalleryAbstractRequest::QGalleryAbstractRequest(Type type, QObject *parent)
*/
QGalleryAbstractRequest::QGalleryAbstractRequest(
- QAbstractGallery *gallery, Type type, QObject *parent)
+ QAbstractGallery *gallery, RequestType type, QObject *parent)
: QObject(parent)
, d_ptr(new QGalleryAbstractRequestPrivate(gallery, type))
{
@@ -277,7 +277,7 @@ bool QGalleryAbstractRequest::isSupported() const
/*!
Returns the type of a request.
*/
-QGalleryAbstractRequest::Type QGalleryAbstractRequest::type() const
+QGalleryAbstractRequest::RequestType QGalleryAbstractRequest::type() const
{
return d_ptr->type;
}
diff --git a/src/gallery/qgalleryabstractrequest.h b/src/gallery/qgalleryabstractrequest.h
index b148564f9c..e3a1cba534 100644
--- a/src/gallery/qgalleryabstractrequest.h
+++ b/src/gallery/qgalleryabstractrequest.h
@@ -66,7 +66,7 @@ class Q_GALLERY_EXPORT QGalleryAbstractRequest : public QObject
Q_PROPERTY(int maximumProgress READ maximumProgress NOTIFY progressChanged)
Q_ENUMS(State)
Q_ENUMS(Result)
- Q_ENUMS(Type)
+ Q_ENUMS(RequestType)
Q_ENUMS(Scope)
public:
enum State
@@ -97,10 +97,12 @@ public:
RequestError = 100
};
- enum Type
+ enum RequestType
{
- Query,
- Remove
+ QueryRequest,
+ ItemRequest,
+ TypeRequest,
+ RemoveRequest
};
enum Scope
@@ -110,8 +112,9 @@ public:
RootItem
};
- explicit QGalleryAbstractRequest(Type type, QObject *parent = 0);
- explicit QGalleryAbstractRequest(QAbstractGallery *gallery, Type type, QObject *parent = 0);
+ explicit QGalleryAbstractRequest(RequestType type, QObject *parent = 0);
+ explicit QGalleryAbstractRequest(
+ QAbstractGallery *gallery, RequestType type, QObject *parent = 0);
~QGalleryAbstractRequest();
QAbstractGallery *gallery() const;
@@ -119,7 +122,7 @@ public:
bool isSupported() const;
- Type type() const;
+ RequestType type() const;
State state() const;
int result() const;
diff --git a/src/gallery/qgalleryabstractrequest_p.h b/src/gallery/qgalleryabstractrequest_p.h
index d78b00adbc..a125064501 100644
--- a/src/gallery/qgalleryabstractrequest_p.h
+++ b/src/gallery/qgalleryabstractrequest_p.h
@@ -63,7 +63,8 @@ class QGalleryAbstractRequestPrivate
{
Q_DECLARE_PUBLIC(QGalleryAbstractRequest)
public:
- QGalleryAbstractRequestPrivate(QAbstractGallery *gallery, QGalleryAbstractRequest::Type type)
+ QGalleryAbstractRequestPrivate(
+ QAbstractGallery *gallery, QGalleryAbstractRequest::RequestType type)
: gallery(gallery)
, response(0)
, type(type)
@@ -86,7 +87,7 @@ public:
QGalleryAbstractRequest *q_ptr;
QAbstractGallery *gallery;
QGalleryAbstractResponse *response;
- QGalleryAbstractRequest::Type type;
+ QGalleryAbstractRequest::RequestType type;
QGalleryAbstractRequest::State state;
int result;
int currentProgress;
diff --git a/src/gallery/qgalleryitemrequest.cpp b/src/gallery/qgalleryitemrequest.cpp
new file mode 100644
index 0000000000..2136974077
--- /dev/null
+++ b/src/gallery/qgalleryitemrequest.cpp
@@ -0,0 +1,363 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the Qt Mobility Components.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, 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.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qgalleryitemrequest.h"
+#include "qgalleryabstractrequest_p.h"
+
+#include "qgallerynullresultset_p.h"
+#include "qgalleryresource.h"
+
+QTM_BEGIN_NAMESPACE
+
+class QGalleryItemRequestPrivate : public QGalleryAbstractRequestPrivate
+{
+ Q_DECLARE_PUBLIC(QGalleryItemRequest)
+public:
+ QGalleryItemRequestPrivate(QAbstractGallery *gallery)
+ : QGalleryAbstractRequestPrivate(gallery, QGalleryAbstractRequest::ItemRequest)
+ , live(false)
+ , resultSet(0)
+ , internalResultSet(0)
+ {
+ internalResultSet = &nullResultSet;
+ }
+
+ void _q_itemsInserted(int index, int)
+ {
+ if (index == 0)
+ resultSet->seek(0, false);
+ }
+
+ void _q_itemsRemoved(int index, int)
+ {
+ if (index == 0)
+ resultSet->seek(0, false);
+ }
+
+ void _q_itemsMoved(int from, int to, int)
+ {
+ if (from == 0 || to == 0)
+ resultSet->seek(0, false);
+ }
+
+ void _q_currentItemChanged()
+ {
+ emit q_func()->itemChanged();
+
+ if (!propertyKeys.isEmpty())
+ emit q_func()->metaDataChanged(propertyKeys);
+ }
+
+ void _q_metaDataChanged(int index, int, const QList<int> &keys)
+ {
+ if (index == 0)
+ emit q_func()->metaDataChanged(keys);
+ }
+
+ QGalleryAbstractRequest::Scope scope;
+ bool live;
+ QGalleryResultSet *resultSet;
+ QGalleryResultSet *internalResultSet;
+ QGalleryNullResultSet nullResultSet;
+ QStringList propertyNames;
+ QVariant itemId;
+ QList<int> propertyKeys;
+};
+
+/*!
+ \class QGalleryItemRequest
+
+ \ingroup gallery
+ \ingroup gallery-requests
+
+ \inmodule QtGallery
+
+ \brief The QGalleryItemRequest class provides a request for a set of
+ items from a gallery.
+
+*/
+/*!
+ Constructs a new gallery query request.
+
+ The \a parent is passed to QObject.
+*/
+
+
+QGalleryItemRequest::QGalleryItemRequest(QObject *parent)
+ : QGalleryAbstractRequest(*new QGalleryItemRequestPrivate(0), parent)
+{
+}
+/*!
+ Contructs a new query request for the given \a gallery.
+
+ The \a parent is passed to QObject.
+*/
+
+QGalleryItemRequest::QGalleryItemRequest(QAbstractGallery *gallery, QObject *parent)
+ : QGalleryAbstractRequest(*new QGalleryItemRequestPrivate(gallery), parent)
+{
+}
+
+/*!
+ Destroys a gallery query request.
+*/
+
+QGalleryItemRequest::~QGalleryItemRequest()
+{
+}
+/*!
+ \property QGalleryItemRequest::propertyNames
+
+ \brief A list of names of meta-data properties a request should return values for.
+*/
+
+
+QStringList QGalleryItemRequest::propertyNames() const
+{
+ return d_func()->propertyNames;
+}
+
+void QGalleryItemRequest::setPropertyNames(const QStringList &names)
+{
+ d_func()->propertyNames = names;
+}
+
+/*!
+ \property QGalleryItemRequest::live
+
+ \brief Whether a the results of a request should be updated after a request
+ has finished.
+
+ If this is true the request will go into the Idle state when the request has
+ finished rather than returning to Inactive.
+*/
+
+
+bool QGalleryItemRequest::isLive() const
+{
+ return d_func()->live;
+}
+
+void QGalleryItemRequest::setLive(bool live)
+{
+ d_func()->live = live;
+}
+
+/*!
+ \property QGalleryItemRequest::itemId
+
+ \brief the ID of an item the query should return the descendents of.
+*/
+
+QVariant QGalleryItemRequest::itemId() const
+{
+ return d_func()->itemId;
+}
+
+void QGalleryItemRequest::setItemId(const QVariant &itemId)
+{
+ d_func()->itemId = itemId;
+
+ emit itemIdChanged();
+}
+
+/*!
+ \property QGalleryItemRequest::resultSet
+*/
+
+QGalleryResultSet *QGalleryItemRequest::resultSet() const
+{
+ return d_func()->resultSet;
+}
+
+/*!
+ Returns the key of \a property.
+*/
+
+int QGalleryItemRequest::propertyKey(const QString &property) const
+{
+ return d_func()->internalResultSet->propertyKey(property);
+}
+
+/*!
+ Returns the attributes of the property identified by \a key.
+*/
+
+QGalleryProperty::Attributes QGalleryItemRequest::propertyAttributes(int key) const
+{
+ return d_func()->internalResultSet->propertyAttributes(key);
+}
+
+/*!
+ Returns the type of the property identified by \a key.
+*/
+
+QVariant::Type QGalleryItemRequest::propertyType(int key) const
+{
+ return d_func()->internalResultSet->propertyType(key);
+}
+
+/*!
+ \property QGalleryItemRequest::valid
+*/
+
+bool QGalleryItemRequest::isValid() const
+{
+ return d_func()->internalResultSet->isValid();
+}
+
+/*!
+ Returns the URL of the current item.
+*/
+
+QUrl QGalleryItemRequest::itemUrl() const
+{
+ return d_func()->internalResultSet->itemUrl();
+}
+
+/*!
+ Returns the type of the current item.
+*/
+
+QString QGalleryItemRequest::itemType() const
+{
+ return d_func()->internalResultSet->itemType();
+}
+
+/*!
+ Returns the resources of the current item.
+*/
+
+QList<QGalleryResource> QGalleryItemRequest::resources() const
+{
+ return d_func()->internalResultSet->resources();
+}
+
+/*!
+ Returns the value of a meta-data property identified by \a key for the
+ current item.
+*/
+
+
+QVariant QGalleryItemRequest::metaData(int key) const
+{
+ return d_func()->internalResultSet->metaData(key);
+}
+
+/*!
+ Sets the \a value of a meta-data property identified by \a key for the
+ current item.
+*/
+
+bool QGalleryItemRequest::setMetaData(int key, const QVariant &value)
+{
+ return d_func()->internalResultSet->setMetaData(key, value);
+}
+
+/*!
+ Returns the value of a meta-data \a property for the current item.
+*/
+
+
+QVariant QGalleryItemRequest::metaData(const QString &property) const
+{
+ return d_func()->internalResultSet->metaData(
+ d_func()->internalResultSet->propertyKey(property));
+}
+
+/*!
+ Sets the \value of a meta-data \a property for the current item.
+*/
+
+bool QGalleryItemRequest::setMetaData(const QString &property, const QVariant &value)
+{
+ return d_func()->internalResultSet->setMetaData(
+ d_func()->internalResultSet->propertyKey(property), value);
+}
+
+/*!
+ \reimp
+*/
+
+void QGalleryItemRequest::setResponse(QGalleryAbstractResponse *response)
+{
+ Q_D(QGalleryItemRequest);
+
+ const bool wasValid = d->internalResultSet->isValid();
+
+ d->resultSet = qobject_cast<QGalleryResultSet *>(response);
+ d->propertyKeys.clear();
+
+ if (d->resultSet) {
+ d->internalResultSet = d->resultSet;
+
+ connect(d->resultSet, SIGNAL(itemsInserted(int,int)), this, SLOT(_q_itemsInserted(int,int)));
+ connect(d->resultSet, SIGNAL(itemsRemoved(int,int)), this, SLOT(_q_itemsRemoved(int,int)));
+ connect(d->resultSet, SIGNAL(itemsMoved(int,int,int)),
+ this, SLOT(_q_itemsMoved(int,int,int)));
+ connect(d->resultSet, SIGNAL(metaDataChanged(int,int,QList<int>)),
+ this, SLOT(_q_metaDataChanged(int,int,QList<int>)));
+ connect(d->resultSet, SIGNAL(currentItemChanged()), this, SLOT(_q_currentItemChanged()));
+
+ typedef QStringList::const_iterator iterator;
+ for (iterator it = d->propertyNames.constBegin(), end = d->propertyNames.constEnd();
+ it != end;
+ ++it) {
+ const int propertyKey = d->resultSet->propertyKey(*it);
+
+ if (propertyKey != -1)
+ d->propertyKeys.append(propertyKey);
+ }
+ } else {
+ d->internalResultSet = &d->nullResultSet;
+ }
+
+ emit resultSetChanged(d->resultSet);
+
+ if (d->internalResultSet->itemCount() > 0)
+ d->internalResultSet->seek(0, false);
+ else if (wasValid)
+ emit itemChanged();
+}
+
+#include "moc_qgalleryitemrequest.cpp"
+
+QTM_END_NAMESPACE
diff --git a/src/gallery/qgalleryitemrequest.h b/src/gallery/qgalleryitemrequest.h
new file mode 100644
index 0000000000..f7b8580f6c
--- /dev/null
+++ b/src/gallery/qgalleryitemrequest.h
@@ -0,0 +1,119 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the Qt Mobility Components.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, 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.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QGALLERYITEMREQUEST_H
+#define QGALLERYITEMREQUEST_H
+
+#include "qgalleryabstractrequest.h"
+
+#include <qgalleryproperty.h>
+
+QTM_BEGIN_NAMESPACE
+
+class QGalleryFilter;
+class QGalleryResource;
+class QGalleryResultSet;
+
+class QGalleryItemRequestPrivate;
+
+class Q_GALLERY_EXPORT QGalleryItemRequest : public QGalleryAbstractRequest
+{
+ Q_OBJECT
+ Q_PROPERTY(QStringList propertyNames READ propertyNames WRITE setPropertyNames)
+ Q_PROPERTY(bool live READ isLive WRITE setLive)
+ Q_PROPERTY(QVariant itemId READ itemId WRITE setItemId NOTIFY itemIdChanged)
+ Q_PROPERTY(bool valid READ isValid NOTIFY itemChanged)
+ Q_PROPERTY(QString itemType READ itemType NOTIFY itemChanged)
+ Q_PROPERTY(QUrl itemUrl READ itemUrl NOTIFY itemChanged)
+ Q_PROPERTY(QList<QGalleryResource> resources READ resources NOTIFY itemChanged)
+public:
+ explicit QGalleryItemRequest(QObject *parent = 0);
+ explicit QGalleryItemRequest(QAbstractGallery *gallery, QObject *parent = 0);
+ ~QGalleryItemRequest();
+
+ QStringList propertyNames() const;
+ void setPropertyNames(const QStringList &names);
+
+ bool isLive() const;
+ void setLive(bool live);
+
+ QVariant itemId() const;
+ void setItemId(const QVariant &itemId);
+
+ QGalleryResultSet *resultSet() const;
+
+ int propertyKey(const QString &property) const;
+ QGalleryProperty::Attributes propertyAttributes(int key) const;
+ QVariant::Type propertyType(int key) const;
+
+ bool isValid() const;
+
+ QUrl itemUrl() const;
+ QString itemType() const;
+ QList<QGalleryResource> resources() const;
+
+ QVariant metaData(int key) const;
+ bool setMetaData(int key, const QVariant &value);
+
+ QVariant metaData(const QString &property) const;
+ bool setMetaData(const QString &property, const QVariant &value);
+
+Q_SIGNALS:
+ void itemIdChanged();
+ void resultSetChanged(QGalleryResultSet *resultSet);
+ void itemChanged();
+ void metaDataChanged(const QList<int> &keys);
+
+protected:
+ void setResponse(QGalleryAbstractResponse *response);
+
+private:
+ Q_DECLARE_PRIVATE(QGalleryItemRequest)
+ Q_PRIVATE_SLOT(d_func(), void _q_itemsInserted(int, int))
+ Q_PRIVATE_SLOT(d_func(), void _q_itemsRemoved(int, int))
+ Q_PRIVATE_SLOT(d_func(), void _q_itemsMoved(int, int, int))
+ Q_PRIVATE_SLOT(d_func(), void _q_currentItemChanged())
+ Q_PRIVATE_SLOT(d_func(), void _q_metaDataChanged(int, int, const QList<int> &))
+};
+
+QTM_END_NAMESPACE
+
+#endif
diff --git a/src/gallery/qgallerynullresultset_p.h b/src/gallery/qgallerynullresultset_p.h
new file mode 100644
index 0000000000..bd307db818
--- /dev/null
+++ b/src/gallery/qgallerynullresultset_p.h
@@ -0,0 +1,84 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the Qt Mobility Components.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, 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.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QGALLERYNULLRESULTSET_P_H
+#define QGALLERYNULLRESULTSET_P_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 "qgalleryresultset.h"
+
+QTM_BEGIN_NAMESPACE
+
+class QGalleryNullResultSet : public QGalleryResultSet
+{
+public:
+ int propertyKey(const QString &) const { return -1; }
+ QGalleryProperty::Attributes propertyAttributes(int) const {
+ return QGalleryProperty::Attributes(); }
+ QVariant::Type propertyType(int) const { return QVariant::Invalid; }
+
+ int itemCount() const { return 0; }
+
+ QVariant itemId() const { return QVariant(); }
+ QUrl itemUrl() const { return QUrl(); }
+ QString itemType() const { return QString(); }
+ QList<QGalleryResource> resources() const { return QList<QGalleryResource>(); }
+
+ QVariant metaData(int) const { return QVariant(); }
+ bool setMetaData(int, const QVariant &) { return false; }
+
+ int currentIndex() const { return -1; }
+ bool seek(int, bool) { return false; }
+};
+
+QTM_END_NAMESPACE
+
+#endif
diff --git a/src/gallery/qgalleryqueryrequest.cpp b/src/gallery/qgalleryqueryrequest.cpp
index d0037b3139..83d60bbb2d 100644
--- a/src/gallery/qgalleryqueryrequest.cpp
+++ b/src/gallery/qgalleryqueryrequest.cpp
@@ -73,7 +73,7 @@ class QGalleryQueryRequestPrivate : public QGalleryAbstractRequestPrivate
{
public:
QGalleryQueryRequestPrivate(QAbstractGallery *gallery)
- : QGalleryAbstractRequestPrivate(gallery, QGalleryAbstractRequest::Query)
+ : QGalleryAbstractRequestPrivate(gallery, QGalleryAbstractRequest::QueryRequest)
, offset(0)
, limit(0)
, scope(QGalleryAbstractRequest::AllDescendants)
@@ -463,6 +463,15 @@ bool QGalleryQueryRequest::previous()
}
/*!
+
+*/
+
+bool QGalleryQueryRequest::isValid() const
+{
+ return d_func()->internalResultSet->isValid();
+}
+
+/*!
\reimp
*/
@@ -474,6 +483,8 @@ void QGalleryQueryRequest::setResponse(QGalleryAbstractResponse *response)
if (d->resultSet) {
d->internalResultSet = d->resultSet;
+
+ connect(d->resultSet, SIGNAL(currentItemChanged()), this, SIGNAL(currentItemChanged()));
} else {
d->internalResultSet = &d->nullResultSet;
}
diff --git a/src/gallery/qgalleryqueryrequest.h b/src/gallery/qgalleryqueryrequest.h
index 586029ae05..84aabdbef9 100644
--- a/src/gallery/qgalleryqueryrequest.h
+++ b/src/gallery/qgalleryqueryrequest.h
@@ -67,6 +67,7 @@ class Q_GALLERY_EXPORT QGalleryQueryRequest : public QGalleryAbstractRequest
Q_PROPERTY(QVariant rootItem READ rootItem WRITE setRootItem)
Q_PROPERTY(QGalleryAbstractRequest::Scope scope READ scope WRITE setScope)
Q_PROPERTY(QGalleryFilter filter READ filter WRITE setFilter NOTIFY filterChanged)
+ Q_PROPERTY(bool valid READ isValid NOTIFY currentItemChanged)
Q_PROPERTY(QVariant itemId READ itemId NOTIFY currentItemChanged)
Q_PROPERTY(QString itemType READ itemType NOTIFY currentItemChanged)
Q_PROPERTY(QUrl itemUrl READ itemUrl NOTIFY currentItemChanged)
@@ -112,6 +113,8 @@ public:
int itemCount() const;
+ bool isValid() const;
+
QVariant itemId() const;
QUrl itemUrl() const;
QString itemType() const;
diff --git a/src/gallery/qgalleryremoverequest.cpp b/src/gallery/qgalleryremoverequest.cpp
index 42543c2f19..d4b1f81471 100644
--- a/src/gallery/qgalleryremoverequest.cpp
+++ b/src/gallery/qgalleryremoverequest.cpp
@@ -49,7 +49,7 @@ class QGalleryRemoveRequestPrivate : public QGalleryAbstractRequestPrivate
{
public:
QGalleryRemoveRequestPrivate(QAbstractGallery *gallery)
- : QGalleryAbstractRequestPrivate(gallery, QGalleryAbstractRequest::Remove)
+ : QGalleryAbstractRequestPrivate(gallery, QGalleryAbstractRequest::RemoveRequest)
{
}
diff --git a/src/gallery/qgalleryresultset.cpp b/src/gallery/qgalleryresultset.cpp
index 1735ddd370..a75da98aa8 100644
--- a/src/gallery/qgalleryresultset.cpp
+++ b/src/gallery/qgalleryresultset.cpp
@@ -98,6 +98,17 @@ QGalleryResultSet::~QGalleryResultSet()
*/
/*!
+
+*/
+
+bool QGalleryResultSet::isValid() const
+{
+ const int index = currentIndex();
+
+ return index >= 0 && index < itemCount();
+}
+
+/*!
\fn QGalleryResultSet::itemId() const
*/
diff --git a/src/gallery/qgalleryresultset.h b/src/gallery/qgalleryresultset.h
index a84930b570..5e967b51de 100644
--- a/src/gallery/qgalleryresultset.h
+++ b/src/gallery/qgalleryresultset.h
@@ -70,6 +70,8 @@ public:
virtual int itemCount() const = 0;
+ virtual bool isValid() const;
+
virtual QVariant itemId() const = 0;
virtual QUrl itemUrl() const = 0;
virtual QString itemType() const = 0;
@@ -82,6 +84,7 @@ public:
virtual bool seek(int index, bool relative) = 0;
Q_SIGNALS:
+ void currentItemChanged();
void currentIndexChanged(int index);
void itemsInserted(int index, int count);
void itemsRemoved(int index, int count);
diff --git a/src/gallery/qgallerytyperequest.cpp b/src/gallery/qgallerytyperequest.cpp
new file mode 100644
index 0000000000..93eafb4da4
--- /dev/null
+++ b/src/gallery/qgallerytyperequest.cpp
@@ -0,0 +1,372 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the Qt Mobility Components.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, 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.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qgallerytyperequest.h"
+#include "qgalleryabstractrequest_p.h"
+
+#include "qgallerynullresultset_p.h"
+#include "qgalleryresource.h"
+
+QTM_BEGIN_NAMESPACE
+
+class QGalleryTypeRequestPrivate : public QGalleryAbstractRequestPrivate
+{
+ Q_DECLARE_PUBLIC(QGalleryTypeRequest)
+public:
+ QGalleryTypeRequestPrivate(QAbstractGallery *gallery)
+ : QGalleryAbstractRequestPrivate(gallery, QGalleryAbstractRequest::TypeRequest)
+ , scope(QGalleryAbstractRequest::AllDescendants)
+ , live(false)
+ , resultSet(0)
+ , internalResultSet(0)
+ {
+ internalResultSet = &nullResultSet;
+ }
+
+ void _q_itemsInserted(int index, int)
+ {
+ if (index == 0)
+ resultSet->seek(0, false);
+ }
+
+ void _q_itemsRemoved(int index, int)
+ {
+ if (index == 0)
+ resultSet->seek(0, false);
+ }
+
+ void _q_itemsMoved(int from, int to, int)
+ {
+ if (from == 0 || to == 0)
+ resultSet->seek(0, false);
+ }
+
+ void _q_currentItemChanged()
+ {
+ emit q_func()->typeChanged();
+
+ if (!propertyKeys.isEmpty())
+ emit q_func()->metaDataChanged(propertyKeys);
+ }
+
+ void _q_metaDataChanged(int index, int, const QList<int> &keys)
+ {
+ if (index == 0)
+ emit q_func()->metaDataChanged(keys);
+ }
+
+ QGalleryAbstractRequest::Scope scope;
+ bool live;
+ QGalleryResultSet *resultSet;
+ QGalleryResultSet *internalResultSet;
+ QGalleryNullResultSet nullResultSet;
+ QStringList propertyNames;
+ QString itemType;
+ QVariant rootItem;
+ QGalleryFilter filter;
+ QList<int> propertyKeys;
+};
+
+/*!
+ \class QGalleryTypeRequest
+
+ \ingroup gallery
+ \ingroup gallery-requests
+
+ \inmodule QtGallery
+
+ \brief The QGalleryTypeRequest class provides a request for a set of
+ items from a gallery.
+
+*/
+/*!
+ Constructs a new gallery query request.
+
+ The \a parent is passed to QObject.
+*/
+
+
+QGalleryTypeRequest::QGalleryTypeRequest(QObject *parent)
+ : QGalleryAbstractRequest(*new QGalleryTypeRequestPrivate(0), parent)
+{
+}
+/*!
+ Contructs a new query request for the given \a gallery.
+
+ The \a parent is passed to QObject.
+*/
+
+QGalleryTypeRequest::QGalleryTypeRequest(QAbstractGallery *gallery, QObject *parent)
+ : QGalleryAbstractRequest(*new QGalleryTypeRequestPrivate(gallery), parent)
+{
+}
+
+/*!
+ Destroys a gallery query request.
+*/
+
+QGalleryTypeRequest::~QGalleryTypeRequest()
+{
+}
+/*!
+ \property QGalleryTypeRequest::propertyNames
+
+ \brief A list of names of meta-data properties a request should return values for.
+*/
+
+
+QStringList QGalleryTypeRequest::propertyNames() const
+{
+ return d_func()->propertyNames;
+}
+
+void QGalleryTypeRequest::setPropertyNames(const QStringList &names)
+{
+ d_func()->propertyNames = names;
+}
+
+/*!
+ \property QGalleryTypeRequest::live
+
+ \brief Whether a the results of a request should be updated after a request
+ has finished.
+
+ If this is true the request will go into the Idle state when the request has
+ finished rather than returning to Inactive.
+*/
+
+
+bool QGalleryTypeRequest::isLive() const
+{
+ return d_func()->live;
+}
+
+void QGalleryTypeRequest::setLive(bool live)
+{
+ d_func()->live = live;
+}
+
+/*!
+ \property QGalleryTypeRequest::itemType
+
+ \brief the root item type the results of a query should be restricted to.
+
+*/
+
+QString QGalleryTypeRequest::itemType() const
+{
+ return d_func()->itemType;
+}
+
+void QGalleryTypeRequest::setItemType(const QString &itemType)
+{
+ d_func()->itemType = itemType;
+
+ emit itemTypeChanged();
+}
+
+/*!
+ \property QGalleryTypeRequest::rootItem
+
+ \brief the ID of an item the query should return the descendents of.
+*/
+
+QVariant QGalleryTypeRequest::rootItem() const
+{
+ return d_func()->rootItem;
+}
+
+void QGalleryTypeRequest::setRootItem(const QVariant &itemId)
+{
+ d_func()->rootItem = itemId;
+}
+
+
+/*!
+ \property QGalleryTypeRequest::scope
+
+ \brief whether all descendants of the scopeItemId should be returned by
+ a request or just the direct descendants.
+*/
+
+QGalleryAbstractRequest::Scope QGalleryTypeRequest::scope() const
+{
+ return d_func()->scope;
+}
+
+void QGalleryTypeRequest::setScope(QGalleryAbstractRequest::Scope scope)
+{
+ d_func()->scope = scope;
+}
+
+/*!
+ \property QGalleryTypeRequest::filter
+
+ \brief A filter identifying the items a request should return.
+
+ If no filter is set the results of the request will be determined
+ by the \l itemType and \l scopeItemId properties.
+*/
+
+QGalleryFilter QGalleryTypeRequest::filter() const
+{
+ return d_func()->filter;
+}
+
+void QGalleryTypeRequest::setFilter(const QGalleryFilter &filter)
+{
+ d_func()->filter = filter;
+}
+
+/*!
+ \property QGalleryTypeRequest::resultSet
+*/
+
+QGalleryResultSet *QGalleryTypeRequest::resultSet() const
+{
+ return d_func()->resultSet;
+}
+
+/*!
+ Returns the key of \a property.
+*/
+
+int QGalleryTypeRequest::propertyKey(const QString &property) const
+{
+ return d_func()->internalResultSet->propertyKey(property);
+}
+
+/*!
+ Returns the attributes of the property identified by \a key.
+*/
+
+QGalleryProperty::Attributes QGalleryTypeRequest::propertyAttributes(int key) const
+{
+ return d_func()->internalResultSet->propertyAttributes(key);
+}
+
+/*!
+ Returns the type of the property identified by \a key.
+*/
+
+QVariant::Type QGalleryTypeRequest::propertyType(int key) const
+{
+ return d_func()->internalResultSet->propertyType(key);
+}
+
+/*!
+
+*/
+
+bool QGalleryTypeRequest::isValid() const
+{
+ return d_func()->internalResultSet->isValid();
+}
+
+/*!
+ Returns the value of a meta-data property identified by \a key for the
+ current item.
+*/
+
+
+QVariant QGalleryTypeRequest::metaData(int key) const
+{
+ return d_func()->internalResultSet->metaData(key);
+}
+
+/*!
+ Returns the value of a meta-data \a property for the current item.
+*/
+
+QVariant QGalleryTypeRequest::metaData(const QString &property) const
+{
+ return d_func()->internalResultSet->metaData(
+ d_func()->internalResultSet->propertyKey(property));
+}
+
+/*!
+ \reimp
+*/
+
+void QGalleryTypeRequest::setResponse(QGalleryAbstractResponse *response)
+{
+ Q_D(QGalleryTypeRequest);
+
+ const bool wasValid = d->internalResultSet->isValid();
+
+ d->resultSet = qobject_cast<QGalleryResultSet *>(response);
+ d->propertyKeys.clear();
+
+ if (d->resultSet) {
+ d->internalResultSet = d->resultSet;
+
+ connect(d->resultSet, SIGNAL(itemsInserted(int,int)), this, SLOT(_q_itemsInserted(int,int)));
+ connect(d->resultSet, SIGNAL(itemsRemoved(int,int)), this, SLOT(_q_itemsRemoved(int,int)));
+ connect(d->resultSet, SIGNAL(itemsMoved(int,int,int)),
+ this, SLOT(_q_itemsMoved(int,int,int)));
+ connect(d->resultSet, SIGNAL(metaDataChanged(int,int,QList<int>)),
+ this, SLOT(_q_metaDataChanged(int,int,QList<int>)));
+ connect(d->resultSet, SIGNAL(currentItemChanged()), this, SLOT(_q_currentItemChanged()));
+
+ typedef QStringList::const_iterator iterator;
+ for (iterator it = d->propertyNames.constBegin(), end = d->propertyNames.constEnd();
+ it != end;
+ ++it) {
+ const int propertyKey = d->resultSet->propertyKey(*it);
+
+ if (propertyKey != -1)
+ d->propertyKeys.append(propertyKey);
+ }
+ } else {
+ d->internalResultSet = &d->nullResultSet;
+ }
+
+ emit resultSetChanged(d->resultSet);
+
+ if (d->internalResultSet->itemCount() > 0)
+ d->internalResultSet->seek(0, false);
+ else if (wasValid)
+ emit typeChanged();
+}
+
+#include "moc_qgallerytyperequest.cpp"
+
+QTM_END_NAMESPACE
diff --git a/src/gallery/qgallerytyperequest.h b/src/gallery/qgallerytyperequest.h
new file mode 100644
index 0000000000..04381679e2
--- /dev/null
+++ b/src/gallery/qgallerytyperequest.h
@@ -0,0 +1,121 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the Qt Mobility Components.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, 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.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QGALLERYTYPEREQUEST_H
+#define QGALLERYTYPEREQUEST_H
+
+#include "qgalleryabstractrequest.h"
+
+#include <qgalleryproperty.h>
+
+QTM_BEGIN_NAMESPACE
+
+class QGalleryFilter;
+class QGalleryResource;
+class QGalleryResultSet;
+
+class QGalleryTypeRequestPrivate;
+
+class Q_GALLERY_EXPORT QGalleryTypeRequest : public QGalleryAbstractRequest
+{
+ Q_OBJECT
+ Q_PROPERTY(QStringList propertyNames READ propertyNames WRITE setPropertyNames)
+ Q_PROPERTY(bool live READ isLive WRITE setLive)
+ Q_PROPERTY(QString itemType READ itemType WRITE setItemType NOTIFY itemTypeChanged)
+ Q_PROPERTY(QVariant rootItem READ rootItem WRITE setRootItem)
+ Q_PROPERTY(QGalleryAbstractRequest::Scope scope READ scope WRITE setScope)
+ Q_PROPERTY(QGalleryFilter filter READ filter WRITE setFilter NOTIFY filterChanged)
+ Q_PROPERTY(bool valid READ isValid NOTIFY typeChanged)
+public:
+ explicit QGalleryTypeRequest(QObject *parent = 0);
+ explicit QGalleryTypeRequest(QAbstractGallery *gallery, QObject *parent = 0);
+ ~QGalleryTypeRequest();
+
+ QStringList propertyNames() const;
+ void setPropertyNames(const QStringList &names);
+
+ bool isLive() const;
+ void setLive(bool live);
+
+ QString itemType() const;
+ void setItemType(const QString &itemType);
+
+ QVariant rootItem() const;
+ void setRootItem(const QVariant &itemId);
+
+ QGalleryAbstractRequest::Scope scope() const;
+ void setScope(QGalleryAbstractRequest::Scope scope);
+
+ QGalleryFilter filter() const;
+ void setFilter(const QGalleryFilter &filter);
+
+ QGalleryResultSet *resultSet() const;
+
+ int propertyKey(const QString &property) const;
+ QGalleryProperty::Attributes propertyAttributes(int key) const;
+ QVariant::Type propertyType(int key) const;
+
+ bool isValid() const;
+
+ QVariant metaData(int key) const;
+ QVariant metaData(const QString &property) const;
+
+Q_SIGNALS:
+ void itemTypeChanged();
+ void resultSetChanged(QGalleryResultSet *resultSet);
+ void metaDataChanged(const QList<int> &keys);
+ void typeChanged();
+
+protected:
+ void setResponse(QGalleryAbstractResponse *response);
+
+private:
+ Q_DECLARE_PRIVATE(QGalleryTypeRequest)
+ Q_PRIVATE_SLOT(d_func(), void _q_itemsInserted(int, int))
+ Q_PRIVATE_SLOT(d_func(), void _q_itemsRemoved(int, int))
+ Q_PRIVATE_SLOT(d_func(), void _q_itemsMoved(int, int, int))
+ Q_PRIVATE_SLOT(d_func(), void _q_currentItemChanged())
+ Q_PRIVATE_SLOT(d_func(), void _q_metaDataChanged(int, int, const QList<int> &))
+};
+
+QTM_END_NAMESPACE
+
+#endif
diff --git a/tests/auto/auto.pro b/tests/auto/auto.pro
index c85ddc46e3..eb81056f0b 100644
--- a/tests/auto/auto.pro
+++ b/tests/auto/auto.pro
@@ -191,10 +191,12 @@ contains(mobility_modules,gallery) {
qdocumentgallery \
qgalleryabstractrequest \
qgalleryabstractresponse \
+ qgalleryitemrequest \
qgalleryquerymodel \
qgalleryqueryrequest \
qgalleryremoverequest \
- qgalleryresource
+ qgalleryresource \
+ qgallerytyperequest
!unix: SUBDIRS += qgalleryfilter
diff --git a/tests/auto/qdocumentgallery/tst_qdocumentgallery.cpp b/tests/auto/qdocumentgallery/tst_qdocumentgallery.cpp
index 3a81d9531f..155ce10414 100644
--- a/tests/auto/qdocumentgallery/tst_qdocumentgallery.cpp
+++ b/tests/auto/qdocumentgallery/tst_qdocumentgallery.cpp
@@ -71,9 +71,9 @@ void tst_QDocumentGallery::isRequestSupported()
const bool platformSupported = false;
#endif
- QCOMPARE(gallery.isRequestSupported(QGalleryAbstractRequest::Query), platformSupported);
- QCOMPARE(gallery.isRequestSupported(QGalleryAbstractRequest::Remove), platformSupported);
- QCOMPARE(gallery.isRequestSupported(QGalleryAbstractRequest::Type(1000)), false);
+ QCOMPARE(gallery.isRequestSupported(QGalleryAbstractRequest::QueryRequest), platformSupported);
+ QCOMPARE(gallery.isRequestSupported(QGalleryAbstractRequest::RemoveRequest), platformSupported);
+ QCOMPARE(gallery.isRequestSupported(QGalleryAbstractRequest::RequestType(1000)), false);
}
void tst_QDocumentGallery::itemTypeProperties_data()
diff --git a/tests/auto/qgalleryabstractrequest/tst_qgalleryabstractrequest.cpp b/tests/auto/qgalleryabstractrequest/tst_qgalleryabstractrequest.cpp
index 80d1633916..6b3cb9d379 100644
--- a/tests/auto/qgalleryabstractrequest/tst_qgalleryabstractrequest.cpp
+++ b/tests/auto/qgalleryabstractrequest/tst_qgalleryabstractrequest.cpp
@@ -114,14 +114,14 @@ private:
class QtGalleryTestRequest : public QGalleryAbstractRequest
{
public:
- QtGalleryTestRequest(QGalleryAbstractRequest::Type type)
+ QtGalleryTestRequest(QGalleryAbstractRequest::RequestType type)
: QGalleryAbstractRequest(type)
, m_response(0)
{
}
QtGalleryTestRequest(
- QAbstractGallery *gallery, QGalleryAbstractRequest::Type type)
+ QAbstractGallery *gallery, QGalleryAbstractRequest::RequestType type)
: QGalleryAbstractRequest(gallery, type)
, m_response(0)
{
@@ -142,13 +142,13 @@ class QtTestGallery : public QAbstractGallery
public:
QtTestGallery() : m_result(QGalleryAbstractRequest::NoResult), m_idle(false) {}
- bool isRequestSupported(QGalleryAbstractRequest::Type type) const {
+ bool isRequestSupported(QGalleryAbstractRequest::RequestType type) const {
return m_supportedRequests.contains(type); }
void setResult(int result) { m_result = result; }
void setIdle(bool idle) { m_idle = idle; }
- void setSupportedRequests(const QList<QGalleryAbstractRequest::Type> &requests) {
+ void setSupportedRequests(const QList<QGalleryAbstractRequest::RequestType> &requests) {
m_supportedRequests = requests; }
protected:
@@ -160,18 +160,18 @@ protected:
}
private:
- QList<QGalleryAbstractRequest::Type> m_supportedRequests;
+ QList<QGalleryAbstractRequest::RequestType> m_supportedRequests;
int m_result;
bool m_idle;
};
void tst_QGalleryAbstractRequest::type()
{
- QCOMPARE(QtGalleryTestRequest(QGalleryAbstractRequest::Query).type(),
- QGalleryAbstractRequest::Query);
+ QCOMPARE(QtGalleryTestRequest(QGalleryAbstractRequest::QueryRequest).type(),
+ QGalleryAbstractRequest::QueryRequest);
- QCOMPARE(QtGalleryTestRequest(QGalleryAbstractRequest::Remove).type(),
- QGalleryAbstractRequest::Remove);
+ QCOMPARE(QtGalleryTestRequest(QGalleryAbstractRequest::RemoveRequest).type(),
+ QGalleryAbstractRequest::RemoveRequest);
}
void tst_QGalleryAbstractRequest::initTestCase()
@@ -182,16 +182,16 @@ void tst_QGalleryAbstractRequest::initTestCase()
void tst_QGalleryAbstractRequest::isSupported()
{
QtTestGallery gallery;
- gallery.setSupportedRequests(QList<QGalleryAbstractRequest::Type>()
- << QGalleryAbstractRequest::Remove);
+ gallery.setSupportedRequests(QList<QGalleryAbstractRequest::RequestType>()
+ << QGalleryAbstractRequest::RemoveRequest);
- QCOMPARE(QtGalleryTestRequest(&gallery, QGalleryAbstractRequest::Query).isSupported(), false);
- QCOMPARE(QtGalleryTestRequest(&gallery, QGalleryAbstractRequest::Remove).isSupported(), true);
+ QCOMPARE(QtGalleryTestRequest(&gallery, QGalleryAbstractRequest::QueryRequest).isSupported(), false);
+ QCOMPARE(QtGalleryTestRequest(&gallery, QGalleryAbstractRequest::RemoveRequest).isSupported(), true);
}
void tst_QGalleryAbstractRequest::executeNoGallery()
{
- QtGalleryTestRequest request(QGalleryAbstractRequest::Remove);
+ QtGalleryTestRequest request(QGalleryAbstractRequest::RemoveRequest);
QSignalSpy succeededSpy(&request, SIGNAL(succeeded()));
QSignalSpy cancelledSpy(&request, SIGNAL(cancelled()));
@@ -216,7 +216,7 @@ void tst_QGalleryAbstractRequest::executeNoGallery()
void tst_QGalleryAbstractRequest::executeUnsupported()
{
QtTestGallery gallery;
- QtGalleryTestRequest request(&gallery, QGalleryAbstractRequest::Remove);
+ QtGalleryTestRequest request(&gallery, QGalleryAbstractRequest::RemoveRequest);
QSignalSpy succeededSpy(&request, SIGNAL(succeeded()));
QSignalSpy cancelledSpy(&request, SIGNAL(cancelled()));
@@ -241,10 +241,10 @@ void tst_QGalleryAbstractRequest::executeUnsupported()
void tst_QGalleryAbstractRequest::executeSync()
{
QtTestGallery gallery;
- gallery.setSupportedRequests(QList<QGalleryAbstractRequest::Type>()
- << QGalleryAbstractRequest::Remove);
+ gallery.setSupportedRequests(QList<QGalleryAbstractRequest::RequestType>()
+ << QGalleryAbstractRequest::RemoveRequest);
- QtGalleryTestRequest request(&gallery, QGalleryAbstractRequest::Remove);
+ QtGalleryTestRequest request(&gallery, QGalleryAbstractRequest::RemoveRequest);
QSignalSpy succeededSpy(&request, SIGNAL(succeeded()));
QSignalSpy cancelledSpy(&request, SIGNAL(cancelled()));
@@ -314,7 +314,7 @@ void tst_QGalleryAbstractRequest::executeSync()
QGalleryAbstractRequest::Idle);
// Execute unsupported.
- gallery.setSupportedRequests(QList<QGalleryAbstractRequest::Type>());
+ gallery.setSupportedRequests(QList<QGalleryAbstractRequest::RequestType>());
request.execute();
QVERIFY(request.response() == 0);
QCOMPARE(request.result(), int(QGalleryAbstractRequest::NotSupported));
@@ -335,10 +335,10 @@ void tst_QGalleryAbstractRequest::executeSync()
void tst_QGalleryAbstractRequest::executeAsync()
{
QtTestGallery gallery;
- gallery.setSupportedRequests(QList<QGalleryAbstractRequest::Type>()
- << QGalleryAbstractRequest::Remove);
+ gallery.setSupportedRequests(QList<QGalleryAbstractRequest::RequestType>()
+ << QGalleryAbstractRequest::RemoveRequest);
- QtGalleryTestRequest request(&gallery, QGalleryAbstractRequest::Remove);
+ QtGalleryTestRequest request(&gallery, QGalleryAbstractRequest::RemoveRequest);
QSignalSpy succeededSpy(&request, SIGNAL(succeeded()));
QSignalSpy cancelledSpy(&request, SIGNAL(cancelled()));
@@ -487,10 +487,10 @@ void tst_QGalleryAbstractRequest::executeAsync()
void tst_QGalleryAbstractRequest::cancelActive()
{
QtTestGallery gallery;
- gallery.setSupportedRequests(QList<QGalleryAbstractRequest::Type>()
- << QGalleryAbstractRequest::Remove);
+ gallery.setSupportedRequests(QList<QGalleryAbstractRequest::RequestType>()
+ << QGalleryAbstractRequest::RemoveRequest);
- QtGalleryTestRequest request(&gallery, QGalleryAbstractRequest::Remove);
+ QtGalleryTestRequest request(&gallery, QGalleryAbstractRequest::RemoveRequest);
QSignalSpy succeededSpy(&request, SIGNAL(succeeded()));
QSignalSpy cancelledSpy(&request, SIGNAL(cancelled()));
@@ -598,12 +598,12 @@ void tst_QGalleryAbstractRequest::cancelActive()
void tst_QGalleryAbstractRequest::cancelIdle()
{
QtTestGallery gallery;
- gallery.setSupportedRequests(QList<QGalleryAbstractRequest::Type>()
- << QGalleryAbstractRequest::Remove);
+ gallery.setSupportedRequests(QList<QGalleryAbstractRequest::RequestType>()
+ << QGalleryAbstractRequest::RemoveRequest);
gallery.setResult(QGalleryAbstractRequest::Succeeded);
gallery.setIdle(true);
- QtGalleryTestRequest request(&gallery, QGalleryAbstractRequest::Remove);
+ QtGalleryTestRequest request(&gallery, QGalleryAbstractRequest::RemoveRequest);
QSignalSpy succeededSpy(&request, SIGNAL(succeeded()));
QSignalSpy cancelledSpy(&request, SIGNAL(cancelled()));
@@ -685,10 +685,10 @@ void tst_QGalleryAbstractRequest::cancelIdle()
void tst_QGalleryAbstractRequest::clear()
{
QtTestGallery gallery;
- gallery.setSupportedRequests(QList<QGalleryAbstractRequest::Type>()
- << QGalleryAbstractRequest::Remove);
+ gallery.setSupportedRequests(QList<QGalleryAbstractRequest::RequestType>()
+ << QGalleryAbstractRequest::RemoveRequest);
- QtGalleryTestRequest request(&gallery, QGalleryAbstractRequest::Remove);
+ QtGalleryTestRequest request(&gallery, QGalleryAbstractRequest::RemoveRequest);
QSignalSpy succeededSpy(&request, SIGNAL(succeeded()));
QSignalSpy cancelledSpy(&request, SIGNAL(cancelled()));
@@ -820,10 +820,10 @@ void tst_QGalleryAbstractRequest::clear()
void tst_QGalleryAbstractRequest::waitForFinished()
{
QtTestGallery gallery;
- gallery.setSupportedRequests(QList<QGalleryAbstractRequest::Type>()
- << QGalleryAbstractRequest::Remove);
+ gallery.setSupportedRequests(QList<QGalleryAbstractRequest::RequestType>()
+ << QGalleryAbstractRequest::RemoveRequest);
- QtGalleryTestRequest request(&gallery, QGalleryAbstractRequest::Remove);
+ QtGalleryTestRequest request(&gallery, QGalleryAbstractRequest::RemoveRequest);
QSignalSpy succeededSpy(&request, SIGNAL(succeeded()));
QSignalSpy cancelledSpy(&request, SIGNAL(cancelled()));
@@ -919,10 +919,10 @@ void tst_QGalleryAbstractRequest::waitForFinished()
void tst_QGalleryAbstractRequest::progress()
{
QtTestGallery gallery;
- gallery.setSupportedRequests(QList<QGalleryAbstractRequest::Type>()
- << QGalleryAbstractRequest::Remove);
+ gallery.setSupportedRequests(QList<QGalleryAbstractRequest::RequestType>()
+ << QGalleryAbstractRequest::RemoveRequest);
- QtGalleryTestRequest request(&gallery, QGalleryAbstractRequest::Remove);
+ QtGalleryTestRequest request(&gallery, QGalleryAbstractRequest::RemoveRequest);
QSignalSpy spy(&request, SIGNAL(progressChanged(int,int)));
@@ -1011,15 +1011,15 @@ void tst_QGalleryAbstractRequest::progress()
void tst_QGalleryAbstractRequest::setGallery()
{
QtTestGallery copyGallery;
- copyGallery.setSupportedRequests(QList<QGalleryAbstractRequest::Type>()
- << QGalleryAbstractRequest::Remove);
+ copyGallery.setSupportedRequests(QList<QGalleryAbstractRequest::RequestType>()
+ << QGalleryAbstractRequest::RemoveRequest);
QtTestGallery moveGallery;
- moveGallery.setSupportedRequests(QList<QGalleryAbstractRequest::Type>()
- << QGalleryAbstractRequest::Query);
+ moveGallery.setSupportedRequests(QList<QGalleryAbstractRequest::RequestType>()
+ << QGalleryAbstractRequest::QueryRequest);
- QtGalleryTestRequest copyRequest(QGalleryAbstractRequest::Remove);
- QtGalleryTestRequest moveRequest(QGalleryAbstractRequest::Query);
+ QtGalleryTestRequest copyRequest(QGalleryAbstractRequest::RemoveRequest);
+ QtGalleryTestRequest moveRequest(QGalleryAbstractRequest::QueryRequest);
QSignalSpy copySpy(&copyRequest, SIGNAL(supportedChanged()));
QSignalSpy moveSpy(&moveRequest, SIGNAL(supportedChanged()));
@@ -1070,10 +1070,10 @@ void tst_QGalleryAbstractRequest::setGallery()
void tst_QGalleryAbstractRequest::clearGallery()
{
QtTestGallery gallery;
- gallery.setSupportedRequests(QList<QGalleryAbstractRequest::Type>()
- << QGalleryAbstractRequest::Remove);
+ gallery.setSupportedRequests(QList<QGalleryAbstractRequest::RequestType>()
+ << QGalleryAbstractRequest::RemoveRequest);
- QtGalleryTestRequest request(&gallery, QGalleryAbstractRequest::Remove);
+ QtGalleryTestRequest request(&gallery, QGalleryAbstractRequest::RemoveRequest);
QSignalSpy succeededSpy(&request, SIGNAL(succeeded()));
QSignalSpy cancelledSpy(&request, SIGNAL(cancelled()));
@@ -1176,7 +1176,7 @@ void tst_QGalleryAbstractRequest::deleteGallery()
{
QtTestGallery *gallery = 0;
- QtGalleryTestRequest request(QGalleryAbstractRequest::Remove);
+ QtGalleryTestRequest request(QGalleryAbstractRequest::RemoveRequest);
QSignalSpy succeededSpy(&request, SIGNAL(succeeded()));
QSignalSpy cancelledSpy(&request, SIGNAL(cancelled()));
@@ -1186,8 +1186,8 @@ void tst_QGalleryAbstractRequest::deleteGallery()
// No response.
gallery = new QtTestGallery;
- gallery->setSupportedRequests(QList<QGalleryAbstractRequest::Type>()
- << QGalleryAbstractRequest::Remove);
+ gallery->setSupportedRequests(QList<QGalleryAbstractRequest::RequestType>()
+ << QGalleryAbstractRequest::RemoveRequest);
request.setGallery(gallery);
delete gallery;
@@ -1202,8 +1202,8 @@ void tst_QGalleryAbstractRequest::deleteGallery()
// Finished response.
gallery = new QtTestGallery;
- gallery->setSupportedRequests(QList<QGalleryAbstractRequest::Type>()
- << QGalleryAbstractRequest::Remove);
+ gallery->setSupportedRequests(QList<QGalleryAbstractRequest::RequestType>()
+ << QGalleryAbstractRequest::RemoveRequest);
gallery->setResult(QGalleryAbstractRequest::Succeeded);
request.setGallery(gallery);
@@ -1228,8 +1228,8 @@ void tst_QGalleryAbstractRequest::deleteGallery()
// Idle response.
gallery = new QtTestGallery;
- gallery->setSupportedRequests(QList<QGalleryAbstractRequest::Type>()
- << QGalleryAbstractRequest::Remove);
+ gallery->setSupportedRequests(QList<QGalleryAbstractRequest::RequestType>()
+ << QGalleryAbstractRequest::RemoveRequest);
gallery->setResult(QGalleryAbstractRequest::Succeeded);
gallery->setIdle(true);
@@ -1255,8 +1255,8 @@ void tst_QGalleryAbstractRequest::deleteGallery()
// Clear active response.
gallery = new QtTestGallery;
- gallery->setSupportedRequests(QList<QGalleryAbstractRequest::Type>()
- << QGalleryAbstractRequest::Remove);
+ gallery->setSupportedRequests(QList<QGalleryAbstractRequest::RequestType>()
+ << QGalleryAbstractRequest::RemoveRequest);
request.setGallery(gallery);
request.execute();
diff --git a/tests/auto/qgalleryitemrequest/qgalleryitemrequest/qgalleryitemrequest.pro b/tests/auto/qgalleryitemrequest/qgalleryitemrequest/qgalleryitemrequest.pro
new file mode 100644
index 0000000000..bafa46c418
--- /dev/null
+++ b/tests/auto/qgalleryitemrequest/qgalleryitemrequest/qgalleryitemrequest.pro
@@ -0,0 +1,12 @@
+TARGET = tst_qgalleryitemrequest
+INCLUDEPATH += ../../../src/gallery
+DEPENDPATH += ../../src/gallery
+CONFIG += testcase
+
+include (../../../common.pri)
+
+SOURCES += tst_qgalleryitemrequest.cpp
+
+CONFIG += mobility
+MOBILITY = gallery
+
diff --git a/tests/auto/qgalleryitemrequest/qgalleryitemrequest/tst_qgalleryitemrequest.cpp b/tests/auto/qgalleryitemrequest/qgalleryitemrequest/tst_qgalleryitemrequest.cpp
new file mode 100644
index 0000000000..a4079d2206
--- /dev/null
+++ b/tests/auto/qgalleryitemrequest/qgalleryitemrequest/tst_qgalleryitemrequest.cpp
@@ -0,0 +1,222 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the Qt Mobility Components.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, 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.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+//TESTED_COMPONENT=src/documentgallery
+
+#include <QtTest/QtTest>
+
+#include <qgalleryitemrequest.h>
+
+#include <qabstractgallery.h>
+#include <qgalleryabstractresponse.h>
+
+QTM_USE_NAMESPACE
+
+Q_DECLARE_METATYPE(QGalleryItemList*)
+
+class tst_QGalleryItemRequest : public QObject
+{
+ Q_OBJECT
+public Q_SLOTS:
+ void initTestCase();
+
+private Q_SLOTS:
+ void properties();
+ void executeSynchronous();
+ void executeAsynchronous();
+};
+
+class QtGalleryTestResponse : public QGalleryAbstractResponse
+{
+ Q_OBJECT
+public:
+ QtGalleryTestResponse(int result, bool idle)
+ {
+ if (result != QGalleryAbstractRequest::NoResult)
+ finish(result, idle);
+ }
+
+ QStringList propertyNames() const { return QStringList(); }
+ int propertyKey(const QString &) const { return -1; }
+ QGalleryProperty::Attributes propertyAttributes(int) const {
+ return QGalleryProperty::Attributes(); }
+ QVariant::Type propertyType(int) const { return QVariant::Invalid; }
+
+ int count() const { return 0; }
+
+ QVariant id(int) const { return QVariant(); }
+ QUrl url(int) const { return QUrl(); }
+ QString type(int) const { return QString(); }
+ QString parentId(int) const { return QString(); }
+ QList<QGalleryResource> resources(int) const { return QList<QGalleryResource>(); }
+ ItemStatus status(int) const { return ItemStatus(); }
+
+ QVariant metaData(int, int) const { return QVariant(); }
+ void setMetaData(int, int, const QVariant &) {}
+
+ bool waitForFinished(int) { return false; }
+
+ void doFinish(int result, bool idle) { finish(result, idle); }
+
+private:
+};
+
+class QtTestGallery : public QAbstractGallery
+{
+public:
+ QtTestGallery() : m_result(QGalleryAbstractRequest::NoResult), m_idle(false) {}
+
+ bool isRequestSupported(QGalleryAbstractRequest::Type type) const {
+ return type == QGalleryAbstractRequest::Item; }
+
+ void setResult(int result) { m_result = result; }
+ void setIdle(bool idle) { m_idle = idle; }
+
+protected:
+ QGalleryAbstractResponse *createResponse(QGalleryAbstractRequest *request)
+ {
+ if (request->type() == QGalleryAbstractRequest::Item)
+ return new QtGalleryTestResponse(m_result, m_idle);
+ return 0;
+ }
+
+private:
+ int m_result;
+ bool m_idle;
+};
+
+void tst_QGalleryItemRequest::initTestCase()
+{
+ qRegisterMetaType<QGalleryItemList*>();
+}
+
+void tst_QGalleryItemRequest::properties()
+{
+ const QGalleryProperty titleProperty("title");
+ const QGalleryProperty artistProperty("artist");
+
+ QGalleryItemRequest request;
+
+ QCOMPARE(request.propertyNames(), QStringList());
+ QCOMPARE(request.isLive(), false);
+
+ request.setPropertyNames(QStringList()
+ << titleProperty
+ << artistProperty.name()
+ << QLatin1String("album")
+ << QString::fromLatin1("trackNumber"));
+ QCOMPARE(request.propertyNames(), QStringList()
+ << QLatin1String("title")
+ << QLatin1String("artist")
+ << QLatin1String("album")
+ << QLatin1String("trackNumber"));
+
+ request.setLive(true);
+ QCOMPARE(request.isLive(), true);
+
+ request.setItemId(QVariant(76));
+ QCOMPARE(request.itemId(), QVariant(76));
+
+ request.setItemId(QVariant(QLatin1String("65")));
+ QCOMPARE(request.itemId(), QVariant(QLatin1String("65")));
+}
+
+void tst_QGalleryItemRequest::executeSynchronous()
+{
+ QtTestGallery gallery;
+ gallery.setResult(QGalleryAbstractRequest::ConnectionError);
+
+ QGalleryItemRequest request(&gallery);
+ QVERIFY(request.item() == 0);
+
+ QSignalSpy spy(&request, SIGNAL(itemChanged(QGalleryItemList*)));
+
+ request.execute();
+ QCOMPARE(request.result(), int(QGalleryAbstractRequest::ConnectionError));
+ QCOMPARE(spy.count(), 0);
+ QVERIFY(qobject_cast<QtGalleryTestResponse *>(request.item()) == 0);
+
+ gallery.setResult(QGalleryAbstractRequest::Succeeded);
+ request.execute();
+ QCOMPARE(request.result(), int(QGalleryAbstractRequest::Succeeded));
+ QCOMPARE(spy.count(), 1);
+ QVERIFY(qobject_cast<QtGalleryTestResponse *>(request.item()) != 0);
+ QCOMPARE(spy.last().at(0).value<QGalleryItemList*>(), request.item());
+
+ request.clear();
+ QCOMPARE(request.result(), int(QGalleryAbstractRequest::NoResult));
+ QCOMPARE(spy.count(), 2);
+ QVERIFY(request.item() == 0);
+ QCOMPARE(spy.last().at(0).value<QGalleryItemList*>(), request.item());
+}
+
+void tst_QGalleryItemRequest::executeAsynchronous()
+{
+ QtTestGallery gallery;
+ gallery.setResult(QGalleryAbstractRequest::NoResult);
+
+ QGalleryItemRequest request(&gallery);
+ QVERIFY(request.item() == 0);
+
+ QSignalSpy spy(&request, SIGNAL(itemChanged(QGalleryItemList*)));
+
+ request.execute();
+ QCOMPARE(request.result(), int(QGalleryAbstractRequest::NoResult));
+ QCOMPARE(spy.count(), 1);
+ QVERIFY(qobject_cast<QtGalleryTestResponse *>(request.item()) != 0);
+ QCOMPARE(spy.last().at(0).value<QGalleryItemList*>(), request.item());
+
+ qobject_cast<QtGalleryTestResponse *>(request.item())->doFinish(
+ QGalleryAbstractRequest::Succeeded, false);
+ QCOMPARE(request.result(), int(QGalleryAbstractRequest::Succeeded));
+ QCOMPARE(spy.count(), 1);
+ QVERIFY(qobject_cast<QtGalleryTestResponse *>(request.item()) != 0);
+
+ request.clear();
+ QCOMPARE(request.result(), int(QGalleryAbstractRequest::NoResult));
+ QCOMPARE(spy.count(), 2);
+ QVERIFY(request.item() == 0);
+ QCOMPARE(spy.last().at(0).value<QGalleryItemList*>(), request.item());
+}
+
+QTEST_MAIN(tst_QGalleryItemRequest)
+
+#include "tst_qgalleryitemrequest.moc"
diff --git a/tests/auto/qgalleryitemrequest/tst_qgalleryitemrequest.cpp b/tests/auto/qgalleryitemrequest/tst_qgalleryitemrequest.cpp
index a4079d2206..db9a01f220 100644
--- a/tests/auto/qgalleryitemrequest/tst_qgalleryitemrequest.cpp
+++ b/tests/auto/qgalleryitemrequest/tst_qgalleryitemrequest.cpp
@@ -47,10 +47,14 @@
#include <qabstractgallery.h>
#include <qgalleryabstractresponse.h>
+#include <qgalleryresultset.h>
+#include <qgalleryresource.h>
+#include <qgallerytype.h>
QTM_USE_NAMESPACE
-Q_DECLARE_METATYPE(QGalleryItemList*)
+Q_DECLARE_METATYPE(QList<int>)
+Q_DECLARE_METATYPE(QGalleryResultSet*)
class tst_QGalleryItemRequest : public QObject
{
@@ -62,70 +66,111 @@ private Q_SLOTS:
void properties();
void executeSynchronous();
void executeAsynchronous();
+ void noResponse();
+ void multipleResults();
};
-class QtGalleryTestResponse : public QGalleryAbstractResponse
+class QtGalleryTestResponse : public QGalleryResultSet
{
Q_OBJECT
public:
- QtGalleryTestResponse(int result, bool idle)
+ QtGalleryTestResponse(const QStringList &propertyNames, int count, int result, bool idle)
+ : m_count(count)
+ , m_currentIndex(-1)
+ , m_propertyNames(propertyNames)
{
if (result != QGalleryAbstractRequest::NoResult)
finish(result, idle);
}
- QStringList propertyNames() const { return QStringList(); }
- int propertyKey(const QString &) const { return -1; }
+ int propertyKey(const QString &propertyName) const {
+ return m_propertyNames.indexOf(propertyName); }
QGalleryProperty::Attributes propertyAttributes(int) const {
- return QGalleryProperty::Attributes(); }
- QVariant::Type propertyType(int) const { return QVariant::Invalid; }
+ return QGalleryProperty::CanRead | QGalleryProperty::CanWrite; }
+ QVariant::Type propertyType(int) const { return QVariant::String; }
- int count() const { return 0; }
+ int itemCount() const { return m_count; }
- QVariant id(int) const { return QVariant(); }
- QUrl url(int) const { return QUrl(); }
- QString type(int) const { return QString(); }
- QString parentId(int) const { return QString(); }
- QList<QGalleryResource> resources(int) const { return QList<QGalleryResource>(); }
- ItemStatus status(int) const { return ItemStatus(); }
+ int currentIndex() const { return m_currentIndex; }
- QVariant metaData(int, int) const { return QVariant(); }
- void setMetaData(int, int, const QVariant &) {}
+ bool seek(int index, bool relative)
+ {
+ m_currentIndex = relative ? m_currentIndex + index : index;
+
+ emit currentIndexChanged(m_currentIndex);
+ emit currentItemChanged();
+
+ return isValid();
+ }
- bool waitForFinished(int) { return false; }
+ QVariant itemId() const { return isValid() ? QVariant(1) : QVariant(); }
+ QUrl itemUrl() const { return isValid() ? QUrl("http://example.com") : QUrl(); }
+ QString itemType() const { return isValid() ? QLatin1String("WebPage") : QString(); }
+
+ QVariant metaData(int key) const { return isValid() ? m_metaData.value(key) : QVariant(); }
+ bool setMetaData(int key, const QVariant &value)
+ {
+ if (isValid()) {
+ m_metaData.insert(key, value);
+ emit metaDataChanged(m_currentIndex, 1, QList<int>() << key);
+ return true;
+ } else {
+ return false;
+ }
+ }
void doFinish(int result, bool idle) { finish(result, idle); }
+ void setCount(int count) { m_count = count; }
+
+ using QGalleryResultSet::itemsInserted;
+ using QGalleryResultSet::itemsRemoved;
+ using QGalleryResultSet::itemsMoved;
+ using QGalleryResultSet::metaDataChanged;
+
private:
+ int m_count;
+ int m_currentIndex;
+ QStringList m_propertyNames;
+ QHash<int, QVariant> m_metaData;
};
class QtTestGallery : public QAbstractGallery
{
public:
- QtTestGallery() : m_result(QGalleryAbstractRequest::NoResult), m_idle(false) {}
+ QtTestGallery() : m_count(0), m_result(QGalleryAbstractRequest::NoResult), m_idle(false) {}
- bool isRequestSupported(QGalleryAbstractRequest::Type type) const {
- return type == QGalleryAbstractRequest::Item; }
+ bool isRequestSupported(QGalleryAbstractRequest::RequestType type) const {
+ return type == QGalleryAbstractRequest::QueryRequest; }
void setResult(int result) { m_result = result; }
void setIdle(bool idle) { m_idle = idle; }
+ void setCount(int count) { m_count = count; }
+
protected:
QGalleryAbstractResponse *createResponse(QGalleryAbstractRequest *request)
{
- if (request->type() == QGalleryAbstractRequest::Item)
- return new QtGalleryTestResponse(m_result, m_idle);
+ if (request->type() == QGalleryAbstractRequest::ItemRequest) {
+ return new QtGalleryTestResponse(
+ static_cast<QGalleryItemRequest *>(request)->propertyNames(),
+ m_count,
+ m_result,
+ m_idle);
+ }
return 0;
}
private:
+ int m_count;
int m_result;
bool m_idle;
};
void tst_QGalleryItemRequest::initTestCase()
{
- qRegisterMetaType<QGalleryItemList*>();
+ qRegisterMetaType<QGalleryResultSet*>();
+ qRegisterMetaType<QList<int> >();
}
void tst_QGalleryItemRequest::properties()
@@ -137,6 +182,7 @@ void tst_QGalleryItemRequest::properties()
QCOMPARE(request.propertyNames(), QStringList());
QCOMPARE(request.isLive(), false);
+ QCOMPARE(request.itemId(), QVariant());
request.setPropertyNames(QStringList()
<< titleProperty
@@ -162,30 +208,69 @@ void tst_QGalleryItemRequest::properties()
void tst_QGalleryItemRequest::executeSynchronous()
{
QtTestGallery gallery;
+ gallery.setCount(1);
gallery.setResult(QGalleryAbstractRequest::ConnectionError);
QGalleryItemRequest request(&gallery);
- QVERIFY(request.item() == 0);
+ QVERIFY(request.resultSet() == 0);
+
+ request.setPropertyNames(QStringList()
+ << QLatin1String("album")
+ << QLatin1String("trackNumber"));
- QSignalSpy spy(&request, SIGNAL(itemChanged(QGalleryItemList*)));
+ QSignalSpy resultSetSpy(&request, SIGNAL(resultSetChanged(QGalleryResultSet*)));
+ QSignalSpy itemChangedSpy(&request, SIGNAL(itemChanged()));
+ QSignalSpy metaDataSpy(&request, SIGNAL(metaDataChanged(QList<int>)));
request.execute();
+
QCOMPARE(request.result(), int(QGalleryAbstractRequest::ConnectionError));
- QCOMPARE(spy.count(), 0);
- QVERIFY(qobject_cast<QtGalleryTestResponse *>(request.item()) == 0);
+ QCOMPARE(resultSetSpy.count(), 0);
+ QVERIFY(qobject_cast<QtGalleryTestResponse *>(request.resultSet()) == 0);
gallery.setResult(QGalleryAbstractRequest::Succeeded);
request.execute();
QCOMPARE(request.result(), int(QGalleryAbstractRequest::Succeeded));
- QCOMPARE(spy.count(), 1);
- QVERIFY(qobject_cast<QtGalleryTestResponse *>(request.item()) != 0);
- QCOMPARE(spy.last().at(0).value<QGalleryItemList*>(), request.item());
+ QCOMPARE(resultSetSpy.count(), 1);
+ QVERIFY(qobject_cast<QtGalleryTestResponse *>(request.resultSet()) != 0);
+ QCOMPARE(resultSetSpy.last().at(0).value<QGalleryResultSet*>(), request.resultSet());
+
+ QCOMPARE(request.propertyKey(QLatin1String("title")), -1);
+ QCOMPARE(request.propertyKey(QLatin1String("album")), 0);
+ QCOMPARE(request.propertyKey(QLatin1String("trackNumber")), 1);
+
+ QCOMPARE(request.propertyAttributes(0), QGalleryProperty::CanRead | QGalleryProperty::CanWrite);
+ QCOMPARE(request.propertyType(0), QVariant::String);
+
+ const QList<int> propertyKeys = QList<int>()
+ << request.propertyKey(QLatin1String("album"))
+ << request.propertyKey(QLatin1String("trackNumber"));
+
+ QCOMPARE(itemChangedSpy.count(), 1);
+ QCOMPARE(metaDataSpy.count(), 1);
+ QCOMPARE(metaDataSpy.last().value(0).value<QList<int> >(), propertyKeys);
+
+ QCOMPARE(request.isValid(), true);
+ QCOMPARE(request.itemUrl(), QUrl(QLatin1String("http://example.com")));
+ QCOMPARE(request.itemType(), QLatin1String("WebPage"));
+ QCOMPARE(request.metaData(1), QVariant());
+ QCOMPARE(request.setMetaData(1, 12), true);
+ QCOMPARE(request.metaData(1), QVariant(12));
+ QCOMPARE(metaDataSpy.count(), 2);
+ QCOMPARE(request.metaData(QLatin1String("trackNumber")), QVariant(12));
+ QCOMPARE(request.setMetaData(QLatin1String("trackNumber"), 5), true);
+ QCOMPARE(metaDataSpy.count(), 3);
+ QCOMPARE(request.metaData(QLatin1String("trackNumber")), QVariant(5));
+ QCOMPARE(request.resources(), QList<QGalleryResource>()
+ << QGalleryResource(QUrl(QLatin1String("http://example.com"))));
request.clear();
QCOMPARE(request.result(), int(QGalleryAbstractRequest::NoResult));
- QCOMPARE(spy.count(), 2);
- QVERIFY(request.item() == 0);
- QCOMPARE(spy.last().at(0).value<QGalleryItemList*>(), request.item());
+ QCOMPARE(resultSetSpy.count(), 2);
+ QVERIFY(request.resultSet() == 0);
+ QCOMPARE(resultSetSpy.last().at(0).value<QGalleryResultSet*>(), request.resultSet());
+ QCOMPARE(itemChangedSpy.count(), 2);
+ QCOMPARE(metaDataSpy.count(), 3);
}
void tst_QGalleryItemRequest::executeAsynchronous()
@@ -194,27 +279,202 @@ void tst_QGalleryItemRequest::executeAsynchronous()
gallery.setResult(QGalleryAbstractRequest::NoResult);
QGalleryItemRequest request(&gallery);
- QVERIFY(request.item() == 0);
+ QVERIFY(request.resultSet() == 0);
- QSignalSpy spy(&request, SIGNAL(itemChanged(QGalleryItemList*)));
+ request.setPropertyNames(QStringList()
+ << QLatin1String("album")
+ << QLatin1String("trackNumber"));
+
+ QSignalSpy resultSetSpy(&request, SIGNAL(resultSetChanged(QGalleryResultSet*)));
+ QSignalSpy itemChangedSpy(&request, SIGNAL(itemChanged()));
+ QSignalSpy metaDataSpy(&request, SIGNAL(metaDataChanged(QList<int>)));
request.execute();
QCOMPARE(request.result(), int(QGalleryAbstractRequest::NoResult));
- QCOMPARE(spy.count(), 1);
- QVERIFY(qobject_cast<QtGalleryTestResponse *>(request.item()) != 0);
- QCOMPARE(spy.last().at(0).value<QGalleryItemList*>(), request.item());
+ QCOMPARE(resultSetSpy.count(), 1);
+ QVERIFY(qobject_cast<QtGalleryTestResponse *>(request.resultSet()) != 0);
+ QCOMPARE(resultSetSpy.last().at(0).value<QGalleryResultSet*>(), request.resultSet());
+
+ QCOMPARE(request.propertyKey(QLatin1String("title")), -1);
+ QCOMPARE(request.propertyKey(QLatin1String("album")), 0);
+ QCOMPARE(request.propertyKey(QLatin1String("trackNumber")), 1);
+
+ QCOMPARE(request.propertyAttributes(0), QGalleryProperty::CanRead | QGalleryProperty::CanWrite);
+ QCOMPARE(request.propertyType(0), QVariant::String);
+
+ const QList<int> propertyKeys = QList<int>()
+ << request.propertyKey(QLatin1String("album"))
+ << request.propertyKey(QLatin1String("trackNumber"));
+
+ QCOMPARE(itemChangedSpy.count(), 0);
+ QCOMPARE(metaDataSpy.count(), 0);
+
+ QCOMPARE(request.isValid(), false);
+ QCOMPARE(request.itemUrl(), QUrl());
+ QCOMPARE(request.itemType(), QString());
+ QCOMPARE(request.metaData(1), QVariant());
+ QCOMPARE(request.setMetaData(1, 12), false);
+ QCOMPARE(request.metaData(1), QVariant());
+ QCOMPARE(request.metaData(QLatin1String("trackNumber")), QVariant());
+ QCOMPARE(request.setMetaData(QLatin1String("trackNumber"), 12), false);
+ QCOMPARE(request.metaData(QLatin1String("trackNumber")), QVariant());
+ QCOMPARE(request.resources(), QList<QGalleryResource>());
+
+ {
+ QtGalleryTestResponse *resultSet = qobject_cast<QtGalleryTestResponse *>(
+ request.resultSet());
+ QVERIFY(resultSet != 0);
+
+ resultSet->setCount(1);
+ resultSet->itemsInserted(0, 1);
+ }
+
+ QCOMPARE(itemChangedSpy.count(), 1);
+ QCOMPARE(metaDataSpy.count(), 1);
+ QCOMPARE(metaDataSpy.last().value(0).value<QList<int> >(), propertyKeys);
+
+ QCOMPARE(request.isValid(), true);
+ QCOMPARE(request.itemUrl(), QUrl(QLatin1String("http://example.com")));
+ QCOMPARE(request.itemType(), QLatin1String("WebPage"));
+ QCOMPARE(request.metaData(1), QVariant());
+ QCOMPARE(request.setMetaData(1, 12), true);
+ QCOMPARE(metaDataSpy.count(), 2);
+ QCOMPARE(request.metaData(1), QVariant(12));
+ QCOMPARE(request.metaData(QLatin1String("trackNumber")), QVariant(12));
+ QCOMPARE(request.setMetaData(QLatin1String("trackNumber"), 5), true);
+ QCOMPARE(metaDataSpy.count(), 3);
+ QCOMPARE(request.metaData(QLatin1String("trackNumber")), QVariant(5));
+ QCOMPARE(request.resources(), QList<QGalleryResource>()
+ << QGalleryResource(QUrl(QLatin1String("http://example.com"))));
+
+ {
+ QtGalleryTestResponse *resultSet = qobject_cast<QtGalleryTestResponse *>(
+ request.resultSet());
+ QVERIFY(resultSet != 0);
+
+ resultSet->doFinish(QGalleryAbstractRequest::Succeeded, false);
+ }
- qobject_cast<QtGalleryTestResponse *>(request.item())->doFinish(
- QGalleryAbstractRequest::Succeeded, false);
QCOMPARE(request.result(), int(QGalleryAbstractRequest::Succeeded));
- QCOMPARE(spy.count(), 1);
- QVERIFY(qobject_cast<QtGalleryTestResponse *>(request.item()) != 0);
+ QCOMPARE(resultSetSpy.count(), 1);
+ QVERIFY(qobject_cast<QtGalleryTestResponse *>(request.resultSet()) != 0);
+
+ {
+ QtGalleryTestResponse *resultSet = qobject_cast<QtGalleryTestResponse *>(
+ request.resultSet());
+ QVERIFY(resultSet != 0);
+
+ resultSet->setCount(0);
+ resultSet->itemsRemoved(0, 1);
+ }
+
+ QCOMPARE(itemChangedSpy.count(), 2);
+ QCOMPARE(metaDataSpy.count(), 4);
+ QCOMPARE(metaDataSpy.last().value(0).value<QList<int> >(), propertyKeys);
+
+ QCOMPARE(request.isValid(), false);
+ QCOMPARE(request.itemUrl(), QUrl());
+ QCOMPARE(request.itemType(), QString());
+ QCOMPARE(request.metaData(1), QVariant());
+ QCOMPARE(request.setMetaData(1, 12), false);
+ QCOMPARE(request.metaData(1), QVariant());
+ QCOMPARE(request.metaData(QLatin1String("trackNumber")), QVariant());
+ QCOMPARE(request.setMetaData(QLatin1String("trackNumber"), 12), false);
+ QCOMPARE(request.metaData(QLatin1String("trackNumber")), QVariant());
+ QCOMPARE(request.resources(), QList<QGalleryResource>());
request.clear();
QCOMPARE(request.result(), int(QGalleryAbstractRequest::NoResult));
- QCOMPARE(spy.count(), 2);
- QVERIFY(request.item() == 0);
- QCOMPARE(spy.last().at(0).value<QGalleryItemList*>(), request.item());
+ QCOMPARE(resultSetSpy.count(), 2);
+ QVERIFY(request.resultSet() == 0);
+ QCOMPARE(resultSetSpy.last().at(0).value<QGalleryResultSet*>(), request.resultSet());
+
+ QCOMPARE(itemChangedSpy.count(), 2);
+ QCOMPARE(metaDataSpy.count(), 4);
+}
+
+void tst_QGalleryItemRequest::noResponse()
+{
+ QGalleryItemRequest request;
+
+ QCOMPARE(request.propertyKey(QLatin1String("title")), -1);
+ QCOMPARE(request.propertyKey(QLatin1String("album")), -1);
+ QCOMPARE(request.propertyKey(QLatin1String("trackNumber")), -1);
+
+ QCOMPARE(request.propertyAttributes(0), QGalleryProperty::Attributes());
+ QCOMPARE(request.propertyType(0), QVariant::Invalid);
+
+ QCOMPARE(request.isValid(), false);
+ QCOMPARE(request.itemUrl(), QUrl());
+ QCOMPARE(request.itemType(), QString());
+ QCOMPARE(request.metaData(1), QVariant());
+ QCOMPARE(request.setMetaData(1, QLatin1String("hello")), false);
+ QCOMPARE(request.metaData(1), QVariant());
+ QCOMPARE(request.metaData(QLatin1String("title")), QVariant());
+ QCOMPARE(request.setMetaData(QLatin1String("title"), QLatin1String("hello")), false);
+ QCOMPARE(request.metaData(QLatin1String("title")), QVariant());
+ QCOMPARE(request.resources(), QList<QGalleryResource>());
+}
+
+void tst_QGalleryItemRequest::multipleResults()
+{
+ const QList<int> propertyKeys = QList<int>() << 2 << 15;
+
+ QtTestGallery gallery;
+ gallery.setCount(1);
+
+ QGalleryItemRequest request(&gallery);
+
+ QSignalSpy itemChangedSpy(&request, SIGNAL(itemChanged()));
+ QSignalSpy metaDataSpy(&request, SIGNAL(metaDataChanged(QList<int>)));
+
+ gallery.setResult(QGalleryAbstractRequest::Succeeded);
+ request.execute();
+
+ QCOMPARE(request.isValid(), true);
+ QCOMPARE(itemChangedSpy.count(), 1);
+ QCOMPARE(metaDataSpy.count(), 0);
+
+ QtGalleryTestResponse *resultSet = qobject_cast<QtGalleryTestResponse *>(
+ request.resultSet());
+ QVERIFY(resultSet != 0);
+
+ resultSet->metaDataChanged(0, 1, propertyKeys);
+ QCOMPARE(metaDataSpy.count(), 1);
+ QCOMPARE(metaDataSpy.last().value(0).value<QList<int> >(), propertyKeys);
+
+ resultSet->setCount(3);
+ resultSet->itemsInserted(1, 2);
+
+ QCOMPARE(itemChangedSpy.count(), 1);
+ QCOMPARE(metaDataSpy.count(), 1);
+
+ resultSet->metaDataChanged(0, 1, propertyKeys);
+ QCOMPARE(metaDataSpy.count(), 2);
+ QCOMPARE(metaDataSpy.last().value(0).value<QList<int> >(), propertyKeys);
+
+ resultSet->itemsMoved(0, 1, 1);
+ QCOMPARE(request.isValid(), true);
+ QCOMPARE(itemChangedSpy.count(), 2);
+ QCOMPARE(metaDataSpy.count(), 2);
+
+ resultSet->itemsMoved(2, 0, 1);
+ QCOMPARE(request.isValid(), true);
+ QCOMPARE(itemChangedSpy.count(), 3);
+ QCOMPARE(metaDataSpy.count(), 2);
+
+ resultSet->itemsMoved(1, 2, 1);
+ QCOMPARE(request.isValid(), true);
+ QCOMPARE(itemChangedSpy.count(), 3);
+ QCOMPARE(metaDataSpy.count(), 2);
+
+ resultSet->setCount(1);
+ resultSet->itemsRemoved(1, 1);
+
+ QCOMPARE(request.isValid(), true);
+ QCOMPARE(itemChangedSpy.count(), 3);
+ QCOMPARE(metaDataSpy.count(), 2);
+
}
QTEST_MAIN(tst_QGalleryItemRequest)
diff --git a/tests/auto/qgalleryquerymodel/tst_qgalleryquerymodel.cpp b/tests/auto/qgalleryquerymodel/tst_qgalleryquerymodel.cpp
index faeedab77f..8968d5326e 100644
--- a/tests/auto/qgalleryquerymodel/tst_qgalleryquerymodel.cpp
+++ b/tests/auto/qgalleryquerymodel/tst_qgalleryquerymodel.cpp
@@ -211,7 +211,7 @@ public:
{
}
- bool isRequestSupported(QGalleryAbstractRequest::Type) const { return true; }
+ bool isRequestSupported(QGalleryAbstractRequest::RequestType) const { return true; }
void setPropertyAttributes(const QHash<QString, QGalleryProperty::Attributes> &attributes)
{
diff --git a/tests/auto/qgalleryqueryrequest/tst_qgalleryqueryrequest.cpp b/tests/auto/qgalleryqueryrequest/tst_qgalleryqueryrequest.cpp
index 410da989fe..1632b7b44b 100644
--- a/tests/auto/qgalleryqueryrequest/tst_qgalleryqueryrequest.cpp
+++ b/tests/auto/qgalleryqueryrequest/tst_qgalleryqueryrequest.cpp
@@ -122,8 +122,8 @@ class QtTestGallery : public QAbstractGallery
public:
QtTestGallery() : m_result(QGalleryAbstractRequest::NoResult), m_idle(false) {}
- bool isRequestSupported(QGalleryAbstractRequest::Type type) const {
- return type == QGalleryAbstractRequest::Query; }
+ bool isRequestSupported(QGalleryAbstractRequest::RequestType type) const {
+ return type == QGalleryAbstractRequest::QueryRequest; }
void setResult(int result) { m_result = result; }
void setIdle(bool idle) { m_idle = idle; }
@@ -131,7 +131,7 @@ public:
protected:
QGalleryAbstractResponse *createResponse(QGalleryAbstractRequest *request)
{
- if (request->type() == QGalleryAbstractRequest::Query) {
+ if (request->type() == QGalleryAbstractRequest::QueryRequest) {
return new QtGalleryTestResponse(
static_cast<QGalleryQueryRequest *>(request)->propertyNames(),
m_result,
diff --git a/tests/auto/qgalleryremoverequest/tst_qgalleryremoverequest.cpp b/tests/auto/qgalleryremoverequest/tst_qgalleryremoverequest.cpp
index cf932f5bbe..824ff638b4 100644
--- a/tests/auto/qgalleryremoverequest/tst_qgalleryremoverequest.cpp
+++ b/tests/auto/qgalleryremoverequest/tst_qgalleryremoverequest.cpp
@@ -84,8 +84,8 @@ class QtTestGallery : public QAbstractGallery
public:
QtTestGallery() : m_result(QGalleryAbstractRequest::NoResult), m_idle(false) {}
- bool isRequestSupported(QGalleryAbstractRequest::Type type) const {
- return type == QGalleryAbstractRequest::Remove; }
+ bool isRequestSupported(QGalleryAbstractRequest::RequestType type) const {
+ return type == QGalleryAbstractRequest::RemoveRequest; }
void setResult(int result) { m_result = result; }
void setIdle(bool idle) { m_idle = idle; }
@@ -98,7 +98,7 @@ Q_SIGNALS:
protected:
QGalleryAbstractResponse *createResponse(QGalleryAbstractRequest *request)
{
- if (request->type() == QGalleryAbstractRequest::Remove) {
+ if (request->type() == QGalleryAbstractRequest::RemoveRequest) {
QtGalleryTestResponse *response = new QtGalleryTestResponse(m_result, m_idle);
connect(this, SIGNAL(finish(int,bool)), response, SLOT(doFinish(int,bool)));