diff options
Diffstat (limited to 'src/location/landmarks')
81 files changed, 13173 insertions, 0 deletions
diff --git a/src/location/landmarks/landmarks.pri b/src/location/landmarks/landmarks.pri new file mode 100644 index 00000000..061cdc51 --- /dev/null +++ b/src/location/landmarks/landmarks.pri @@ -0,0 +1,88 @@ + +INCLUDEPATH += landmarks + +PUBLIC_HEADERS += \ + landmarks/qlandmark.h \ + landmarks/qlandmarkabstractrequest.h \ + landmarks/qlandmarkattributefilter.h \ + landmarks/qlandmarkboxfilter.h \ + landmarks/qlandmarkcategory.h \ + landmarks/qlandmarkcategoryfetchrequest.h \ + landmarks/qlandmarkcategoryfetchbyidrequest.h \ + landmarks/qlandmarkcategoryfilter.h \ + landmarks/qlandmarkcategoryid.h \ + landmarks/qlandmarkcategoryidfetchrequest.h \ + landmarks/qlandmarkcategoryremoverequest.h \ + landmarks/qlandmarkcategorysaverequest.h \ + landmarks/qlandmarkexportrequest.h \ + landmarks/qlandmarkfetchrequest.h \ + landmarks/qlandmarkfetchbyidrequest.h \ + landmarks/qlandmarkfilter.h \ + landmarks/qlandmarkid.h \ + landmarks/qlandmarkidfetchrequest.h \ + landmarks/qlandmarkidfilter.h \ + landmarks/qlandmarkimportrequest.h \ + landmarks/qlandmarkintersectionfilter.h \ + landmarks/qlandmarkmanager.h \ + landmarks/qlandmarkmanagerengine.h \ + landmarks/qlandmarkmanagerenginefactory.h \ + landmarks/qlandmarknamefilter.h \ + landmarks/qlandmarknamesort.h \ + landmarks/qlandmarkproximityfilter.h \ + landmarks/qlandmarkremoverequest.h \ + landmarks/qlandmarksaverequest.h \ + landmarks/qlandmarksortorder.h \ + landmarks/qlandmarkunionfilter.h + +PRIVATE_HEADERS += \ + landmarks/qlandmark_p.h \ + landmarks/qlandmarkabstractrequest_p.h \ + landmarks/qlandmarkboxfilter_p.h \ + landmarks/qlandmarkcategory_p.h \ + landmarks/qlandmarkcategoryfilter_p.h \ + landmarks/qlandmarkcategoryid_p.h \ + landmarks/qlandmarkfilter_p.h \ + landmarks/qlandmarkid_p.h \ + landmarks/qlandmarkidfilter_p.h \ + landmarks/qlandmarkintersectionfilter_p.h \ + landmarks/qlandmarkmanager_p.h \ + landmarks/qlandmarknamefilter_p.h \ + landmarks/qlandmarkproximityfilter_p.h \ + landmarks/qlandmarkrequests_p.h \ + landmarks/qlandmarksortorder_p.h \ + landmarks/qlandmarkunionfilter_p.h + +SOURCES += \ + landmarks/qlandmark.cpp \ + landmarks/qlandmarkabstractrequest.cpp \ + landmarks/qlandmarkattributefilter.cpp \ + landmarks/qlandmarkboxfilter.cpp \ + landmarks/qlandmarkcategory.cpp \ + landmarks/qlandmarkcategoryfetchrequest.cpp \ + landmarks/qlandmarkcategoryfetchbyidrequest.cpp \ + landmarks/qlandmarkcategoryfilter.cpp \ + landmarks/qlandmarkcategoryid.cpp \ + landmarks/qlandmarkcategoryidfetchrequest.cpp \ + landmarks/qlandmarkcategoryremoverequest.cpp \ + landmarks/qlandmarkcategorysaverequest.cpp \ + landmarks/qlandmarkexportrequest.cpp \ + landmarks/qlandmarkfetchrequest.cpp \ + landmarks/qlandmarkfetchbyidrequest.cpp \ + landmarks/qlandmarkfilter.cpp \ + landmarks/qlandmarkid.cpp \ + landmarks/qlandmarkidfetchrequest.cpp \ + landmarks/qlandmarkidfilter.cpp \ + landmarks/qlandmarkimportrequest.cpp \ + landmarks/qlandmarkintersectionfilter.cpp \ + landmarks/qlandmarkmanager.cpp \ + landmarks/qlandmarkmanager_p.cpp \ + landmarks/qlandmarkmanagerengine.cpp \ + landmarks/qlandmarkmanagerenginefactory.cpp \ + landmarks/qlandmarknamefilter.cpp \ + landmarks/qlandmarknamesort.cpp \ + landmarks/qlandmarkproximityfilter.cpp \ + landmarks/qlandmarkremoverequest.cpp \ + landmarks/qlandmarksaverequest.cpp \ + landmarks/qlandmarksortorder.cpp \ + landmarks/qlandmarkunionfilter.cpp + diff --git a/src/location/landmarks/qlandmark.cpp b/src/location/landmarks/qlandmark.cpp new file mode 100644 index 00000000..ff503ea1 --- /dev/null +++ b/src/location/landmarks/qlandmark.cpp @@ -0,0 +1,500 @@ +/**************************************************************************** +** +** Copyright (C) 2009 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 "qlandmark.h" +#include "qlandmark_p.h" + +#include "qlandmarkcategory_p.h" +#include "qlandmarkcategoryid.h" +#include "qlandmarkid.h" +#include "qlandmarkid_p.h" + +#include "qgeoaddress.h" +#include "qgeocoordinate.h" + +#include "qgeoplace.h" +#include "qgeoplace_p.h" + +#include <QVariant> +#include <QStringList> +#include <QSet> +#include <qnumeric.h> + +#ifdef LANDMARKPRIVATE_DEBUG +#include <QDebug> +#endif + +QTM_BEGIN_NAMESPACE +uint qHash(const QLandmarkCategoryId& key) { + return qHash(key.localId()) + qHash(key.managerUri()); +} +QTM_END_NAMESPACE + +QTM_USE_NAMESPACE + +// ----- QLandmarkPrivate ----- + +QLandmarkPrivate::QLandmarkPrivate() + : QGeoPlacePrivate() +{ + type = QGeoPlacePrivate::LandmarkType; + radius = 0.0; +} + +QLandmarkPrivate::QLandmarkPrivate(const QGeoPlacePrivate &other) + : QGeoPlacePrivate(other) +{ + type = QGeoPlacePrivate::LandmarkType; + radius = 0.0; +} + +QLandmarkPrivate::QLandmarkPrivate(const QLandmarkPrivate &other) + : QGeoPlacePrivate(other), + name(other.name), + categoryIds(other.categoryIds), + description(other.description), + iconUrl(other.iconUrl), + radius(other.radius), + phoneNumber(other.phoneNumber), + url(other.url), + id(other.id) +{ +} + +QLandmarkPrivate::~QLandmarkPrivate() {} + +QLandmarkPrivate& QLandmarkPrivate::operator= (const QLandmarkPrivate & other) +{ + QGeoPlacePrivate::operator =(other); + name = other.name; + description = other.description; + iconUrl = other.iconUrl; + radius = other.radius; + phoneNumber = other.phoneNumber; + url = other.url; + categoryIds = other.categoryIds; + id = other.id; + + return *this; +} + +bool QLandmarkPrivate::operator== (const QLandmarkPrivate &other) const +{ + bool radiusIsMatch = false; + if (qIsNaN(radius) && qIsNaN(other.radius)) + radiusIsMatch = true; + else if (qFuzzyCompare(1 +radius, 1 + other.radius)) + radiusIsMatch = true; + else + radiusIsMatch = false; + +#ifdef LANDMARKPRIVATE_DEBUG + qDebug() << "==" << (QGeoPlacePrivate::operator== (other)); + qDebug() << "name:" << (name == other.name); + qDebug() << "description:" << (description == other.description); + qDebug() << "iconUrl:" << (iconUrl == other.iconUrl); + qDebug() << "radius:" << radiusIsMatch; + qDebug() << "phoneNumber:" << (phoneNumber == other.phoneNumber); + qDebug() << "url:" << (url == other.url); + qDebug() << "categoryIds:" << (categoryIds.toSet() == other.categoryIds.toSet()); + qDebug() << "id" << (id == other.id); +#endif + + return (QGeoPlacePrivate::operator== (other) + && (name == other.name) + && (description == other.description) + && (iconUrl == other.iconUrl) + && radiusIsMatch + && (phoneNumber == other.phoneNumber) + && (url == other.url) + && (categoryIds.toSet() == other.categoryIds.toSet()) + && (id == other.id)); +} + +/*! + \class QLandmark + + \inmodule QtLocation + + \ingroup landmarks-main + \since 1.1 + + \brief The QLandmark class represents a point of interest. + + + Each QLandmark represents a location with a number of attributes or properties + such as name, description, phone number etc. Each QLandmark may also be associated with zero or more categories. + A category defines a type of landmark such as restaurant or + cinema. To set the category that a landmark belongs to, use + the setCategoryIds() or addCategoryId() functions. A landmark may + be removed from a category by using the removeCategoryId() function. + + Some landmarks may be designated as read-only, e.g. a publically accessible + landmark server may not want some of its content to be editable. + Note, localization is only possible for landmarks that are read-only. + + Each QLandmark is an in memory representation of a landmark; + it does not reflect the actual landmark state in persistent + storage until the appropriate synchronization method is called + on the QLandmarkManager(e.g. \l {QLandmarkManager::saveLandmark()} {saveLandmark()}, + \l {QLandmarkManager::removeLandmark()} {removeLandmark()}). + + Note that QLandmark inherits from QGeoPlace and thus has a viewport data field. + Most managers usually however ignore this field when saving the landmark. +*/ + +/*! + Constructs an new landmark. + + A new landmark will be assigned with invalid QLandmarkId. +*/ +QLandmark::QLandmark() + : QGeoPlace(new QLandmarkPrivate) +{ +} + +/*! + Constructs a new landmark from \a other. + + If \a other is not a landmark, the coordinates, address and viewport + get copied into the newly created landmark. + + If \a other is a landmark, this function is equivalent to calling + QLandmark(const QLandmark &other). + + This constructor allows (1) and c to take place. + /code + QGeoPlace geoPlace = lm1; //lm1 is a QLandmark + ... + QLandmark lm2 = geoPlace; //(1)lm2 is equivalent to lm1 + + QGeoPlace ordinaryPlace; + QLandmark lm3 = ordinarPlace; //(2)lm3 has the details of ordinaryPlace's coordinate, address and viewport. + /endcode +*/ +QLandmark::QLandmark(const QGeoPlace &other) + : QGeoPlace(other) +{ + switch (other.d_ptr->type) { + case QGeoPlacePrivate::GeoPlaceType: + d_ptr = new QLandmarkPrivate(*(other.d_ptr.constData())); + break; + case QGeoPlacePrivate::LandmarkType: + // nothing extra to do here + break; + default: + d_ptr = new QLandmarkPrivate(); + break; + } +} + +/*! + Constructs a copy of \a other. +*/ +QLandmark::QLandmark(const QLandmark &other) + : QGeoPlace(other) +{ +} + +/*! + Destroys the landmark. +*/ +QLandmark::~QLandmark() +{ +} + +/*! + Assigns \a other to this landmark and returns a reference to this landmark. +*/ +QLandmark &QLandmark::operator= (const QLandmark & other) +{ + d_ptr = other.d_ptr; + return *this; +} + +inline QLandmarkPrivate* QLandmark::d_func() +{ + return reinterpret_cast<QLandmarkPrivate*>(d_ptr.data()); +} + +inline const QLandmarkPrivate* QLandmark::d_func() const +{ + return reinterpret_cast<const QLandmarkPrivate*>(d_ptr.constData()); +} + +/*! + Returns true if this landmark is equal to \a other, otherwise + returns false. + + Two landmarks are considered equal if both the landmark details + and identifiers are equal. + + \sa operator!=() +*/ +bool QLandmark::operator== (const QLandmark &other) const +{ + Q_D(const QLandmark); + return *d == *(other.d_func()); +} + +/*! + \fn bool QLandmark::operator!= (const QLandmark &other) const + + Returns true if this landmark not is equal to \a other, otherwise + returns false. + + \sa operator==() +*/ + +/*! + Returns the name of the landmark. +*/ +QString QLandmark::name() const +{ + Q_D(const QLandmark); + return d->name; +} + +/*! + Sets the \a name of the landmark. + + Using the default manager on the Symbian platform, the name is restricted to a length of 256 characters. +*/ +void QLandmark::setName(const QString &name) +{ + Q_D(QLandmark); + d->name = name; +} + +/*! + Returns a of list identifiers of categories that this landmark + belongs to. + + \sa setCategoryIds() +*/ +QList<QLandmarkCategoryId> QLandmark::categoryIds() const +{ + Q_D(const QLandmark); + return d->categoryIds; +} + +/*! + Sets the categories that this landmark belongs to via + a list of \a categoryIds. + + \sa addCategoryId(), removeCategoryId() + +*/ +void QLandmark::setCategoryIds(const QList<QLandmarkCategoryId> &categoryIds) +{ + Q_D(QLandmark); + d->categoryIds.clear(); + + // remove duplicates + for (int i = 0; i < categoryIds.size(); ++i) { + if (!d->categoryIds.contains(categoryIds.at(i))) + d->categoryIds.append(categoryIds.at(i)); + } +} + +/*! + Adds another category that this landmark will be associated + with via its \a categoryId. + + \sa setCategoryIds(), removeCategoryId() +*/ +void QLandmark::addCategoryId(const QLandmarkCategoryId &categoryId) +{ + Q_D(QLandmark); + if (!d->categoryIds.contains(categoryId)) + d->categoryIds.append(categoryId); +} + +/*! + Removes a category from a landmark, by using its \a categoryId. + + \sa addCategoryId(), categoryIds() +*/ +void QLandmark::removeCategoryId(const QLandmarkCategoryId &categoryId) +{ + Q_D(QLandmark); + d->categoryIds.removeAll(categoryId); +} + +/*! + Returns a description of the landmark. +*/ +QString QLandmark::description() const +{ + Q_D(const QLandmark); + return d->description; +} + +/*! + Sets the \a description of the landmark. + + Using the default manager on the Symbian platform, the description is restricted to a length of 4096 characters. +*/ +void QLandmark::setDescription(const QString &description) +{ + Q_D(QLandmark); + d->description = description; +} + +/*! + Returns the url of the landmark's icon. +*/ +QUrl QLandmark::iconUrl() const +{ + Q_D(const QLandmark); + return d->iconUrl; +} + +/*! + Sets the \a url of the landmark's icon. +*/ +void QLandmark::setIconUrl(const QUrl &url) +{ + Q_D(QLandmark); + d->iconUrl = url; +} + +/*! + Returns the coverage radius of the landmark. The unit of the radius is meters. + + The coverage radius is relevant for large landmarks + such as cities. Note that landmark searches over a given area + do not factor in the coverage radius. +*/ +qreal QLandmark::radius() const +{ + Q_D(const QLandmark); + return d->radius; +} + +/*! + Sets the coverage \a radius of the landmark. The unit of the \a radius + is meters. +*/ +void QLandmark::setRadius(qreal radius) +{ + Q_D(QLandmark); + if (!qIsNaN(radius) && radius >= 0.0) + d->radius = radius; + else + d->radius = 0.0; +} + +/*! + Returns the phone number of the landmark. +*/ +QString QLandmark::phoneNumber() const +{ + Q_D(const QLandmark); + return d->phoneNumber; +} + +/*! + Sets the \a phoneNumber of the landmark. +*/ +void QLandmark::setPhoneNumber(const QString &phoneNumber) +{ + Q_D(QLandmark); + d->phoneNumber = phoneNumber; +} +/*! + Returns the url of the landmark. +*/ +QUrl QLandmark::url() const +{ + Q_D(const QLandmark); + return d->url; +} + +/*! + Sets the \a url of the landmark. +*/ +void QLandmark::setUrl(const QUrl &url) +{ + Q_D(QLandmark); + d->url = url; +} + +/*! + Returns the identifier of the landmark. +*/ +QLandmarkId QLandmark::landmarkId() const +{ + Q_D(const QLandmark); + return d->id; +} + +/*! + Sets the \a id of the landmark. + + Note that saving a new landmark using a QLandmarkManager + will automatically assign the landmark a valid identifier. +*/ +void QLandmark::setLandmarkId(const QLandmarkId &id) +{ + Q_D(QLandmark); + d->id = id; +} + +/*! + Clears all the data fields of the landmark. +*/ +void QLandmark::clear() +{ + Q_D(QLandmark); + d->address.clear(); + d->coordinate = QGeoCoordinate(); + d->viewport = QGeoBoundingBox(); + d->name.clear(); + d->categoryIds.clear(); + d->description.clear(); + d->iconUrl.clear(); + d->radius = 0.0; + d->phoneNumber.clear(); + d->url.clear(); + d->id = QLandmarkId(); +} + diff --git a/src/location/landmarks/qlandmark.h b/src/location/landmarks/qlandmark.h new file mode 100644 index 00000000..a66898e9 --- /dev/null +++ b/src/location/landmarks/qlandmark.h @@ -0,0 +1,115 @@ +/**************************************************************************** +** +** Copyright (C) 2009 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 QLANDMARK_H +#define QLANDMARK_H + +#include "qmobilityglobal.h" + +#include <QObject> +#include <QSharedDataPointer> +#include <QVariant> +#include <QStringList> +#include <QUrl> +#include "qgeoplace.h" +#include "qlandmarkid.h" +#include "qlandmarkcategoryid.h" + +QT_BEGIN_HEADER + +QTM_BEGIN_NAMESPACE + +class QLandmarkPrivate; +class Q_LOCATION_EXPORT QLandmark : public QGeoPlace +{ +public: + QLandmark(); + QLandmark(const QGeoPlace &other); + QLandmark(const QLandmark &other); + ~QLandmark(); + + QLandmark &operator= (const QLandmark &other); + bool operator== (const QLandmark &other) const; + bool operator!= (const QLandmark &other) const { + return !(*this == other); + } + + QString name() const; + void setName(const QString &name); + + QList<QLandmarkCategoryId> categoryIds() const; + void setCategoryIds(const QList<QLandmarkCategoryId> &categoryIds); + void addCategoryId(const QLandmarkCategoryId &categoryId); + void removeCategoryId(const QLandmarkCategoryId &categoryId); + + QString description() const; + void setDescription(const QString &description); + + QUrl iconUrl() const; + void setIconUrl(const QUrl &iconUrl); + + qreal radius() const; + void setRadius(qreal radius); + + QString phoneNumber() const; + void setPhoneNumber(const QString &phoneNumber); + + QUrl url() const; + void setUrl(const QUrl &url); + + QLandmarkId landmarkId() const; + void setLandmarkId(const QLandmarkId &id); + + void clear(); +private: + QLandmarkPrivate* d_func(); + const QLandmarkPrivate* d_func() const; +}; + +QTM_END_NAMESPACE + +Q_DECLARE_METATYPE(QTM_PREPEND_NAMESPACE(QLandmark)) + +Q_DECLARE_TYPEINFO(QTM_PREPEND_NAMESPACE(QLandmark), Q_MOVABLE_TYPE); + +QT_END_HEADER + +#endif diff --git a/src/location/landmarks/qlandmark_p.h b/src/location/landmarks/qlandmark_p.h new file mode 100644 index 00000000..698b8b1a --- /dev/null +++ b/src/location/landmarks/qlandmark_p.h @@ -0,0 +1,91 @@ +/**************************************************************************** +** +** Copyright (C) 2009 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 QLANDMARK_P_H +#define QLANDMARK_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 "qlandmark.h" +#include "qlandmarkid.h" +#include "qgeoplace_p.h" +#include <QList> +#include <QHash> +#include <QSharedData> +#include <QUrl> + +QTM_BEGIN_NAMESPACE + +class QLandmarkPrivate : public QGeoPlacePrivate +{ +public: + QLandmarkPrivate(); + QLandmarkPrivate(const QGeoPlacePrivate &other); + QLandmarkPrivate(const QLandmarkPrivate &other); + ~QLandmarkPrivate(); + + QLandmarkPrivate& operator= (const QLandmarkPrivate &other); + + bool operator== (const QLandmarkPrivate &other) const; + virtual QGeoPlacePrivate* clone() const { return new QLandmarkPrivate(*this); } + + QString name; + QList<QLandmarkCategoryId> categoryIds; + QString description; + QUrl iconUrl; + qreal radius; + QString phoneNumber; + QUrl url; + QLandmarkId id; + static QStringList commonKeys; +}; + +QTM_END_NAMESPACE + +#endif diff --git a/src/location/landmarks/qlandmarkabstractrequest.cpp b/src/location/landmarks/qlandmarkabstractrequest.cpp new file mode 100644 index 00000000..afc97f43 --- /dev/null +++ b/src/location/landmarks/qlandmarkabstractrequest.cpp @@ -0,0 +1,428 @@ +/**************************************************************************** +** +** Copyright (C) 2009 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 "qlandmarkabstractrequest.h" +#include "qlandmarkabstractrequest_p.h" +#include "qlandmarkmanagerengine.h" +#include "qlandmarkmanager_p.h" +#include <QDebug> +#include <QMutexLocker> + +QTM_USE_NAMESPACE + +QLandmarkAbstractRequestPrivate::QLandmarkAbstractRequestPrivate(QLandmarkManager *mgr) + : type(QLandmarkAbstractRequest::InvalidRequest), + state(QLandmarkAbstractRequest::InactiveState), + error(QLandmarkManager::NoError), + errorString(QString()), + manager(mgr) +{ +} + +/*! + \class QLandmarkAbstractRequest + \brief The QLandmarkAbstractRequest class provides the interface + from which all asynchronous request classes inherit. + + + \inmodule QtLocation + \since 1.1 + + \ingroup landmarks-request + + It allows a client to asynchronously request some functionality of a + particular QLandmarkManager. Instances of the class will emit signals when + the state of the request changes, or when more results become available. + + Clients should not attempt to create instances of this class directly, but + should instead use the use-case-specific classes derived from this class. + + All such request classes have a similar interface: clients set the + parameters of the asynchronous call, then call the start() slot of the request. The manager + will then enqueue or begin to process the request, at which point the + request's state will transition from the \c InactiveState to \c ActiveState. + After any state transition, the request will emit the stateChanged() + signal. The manager may (if it supports it) + periodically update the request with results, at + which point the request will emit the resultsAvailable() signal. These + results are not guaranteed to have a stable ordering. Error information is + considered a result, so some requests will emit the resultsAvailable() + signal even if no results are possible from the request (for example, a + landmark remove request) when the manager updates the request with + information about any errors which may have occurred. + + Clients can choose which signals they wish to handle from a request. If the + client is not interested in interim results, they can choose to handle only + the stateChanged() signal, and in the slot to which that signal is + connected, check whether the state has changed to the \c FinishedState + (which signifies that the manager has finished handling the request, and + that the request will not be updated with any more results). If the client + is not interested in any results (including error information), they may + choose to delete the request after calling \l start(), or simply may not + connect the the request's signals to any slots. (Please see the note + below if you are working on Symbian with QtMobility 1.1.0) + + If the request is allocated via operator new, the client must delete the + request when they are no longer using it in order to avoid leaking memory. + That is, the client retains ownership of the request. + + The client may delete a heap-allocated request in various ways: by deleting + it directly (but not within a slot connected to a signal emitted by the + request), or by using the deleteLater() slot to schedule the request for + deletion when control returns to the event loop (from within a slot + connected to a signal emitted by the request, for example \l + stateChanged()). + + An active request may be deleted by the client, but the client will + not receive notifications about whether the request succeeded or not, + nor the results of the request. + + Because clients retain ownership of any request object, and may delete a + request object at any time, the manager engine, implementers must be + careful to ensue that they do not assume that a request has not been + deleted at some time point during processing of a request, particularly + if the engine has a multithreaded implementation. +*/ + +QLandmarkAbstractRequestPrivate::~QLandmarkAbstractRequestPrivate() +{ +} + +void QLandmarkAbstractRequestPrivate::notifyEngine(QLandmarkAbstractRequest* request) +{ + Q_ASSERT(request); + QLandmarkAbstractRequestPrivate* d = request->d_ptr; + if (d) { + QMutexLocker ml(&d->mutex); + QLandmarkManagerEngine *engine = QLandmarkManagerPrivate::getEngine(d->manager); + ml.unlock(); + if (engine) { + engine->requestDestroyed(request); + } + } +} + +/*! + \enum QLandmarkAbstractRequest::RequestType + Defines the possible types of asynchronous requests. + \value InvalidRequest An invalid request + \value LandmarkIdFetchRequest A request to fetch a list of landmark + identifiers. + \value CategoryIdFetchRequest A request to fetch a list of catgory + identifiers. + + \value LandmarkFetchRequest A request to fetch a list of landmarks + \value LandmarkFetchByIdRequest A request to fetch a list of landmarks by id. + \value CategoryFetchRequest A request to fetch a list of categories + \value CategoryFetchByIdRequest A request to fetch a list of categories by id + \value LandmarkSaveRequest A request to save a list of landmarks. + \value LandmarkRemoveRequest A request to remove a list of landmarks. + \value CategorySaveRequest A request to save a list of categories. + \value CategoryRemoveRequest A request to remove a list of categories. + \value ImportRequest A request import landmarks. + \value ExportRequest A request export landmarks. +*/ + +/*! + \enum QLandmarkAbstractRequest::State + Defines the possible states of asynchronous requests. + \value InactiveState Operation not yet started. + \value ActiveState Operation started, not yet finished. + \value FinishedState Operation completed. (Can be mean either successful or + unsuccessful completion). +*/ + +/*! + Constructs a new, invalid asynchronous request with the given \a manager and \a parent. +*/ +QLandmarkAbstractRequest::QLandmarkAbstractRequest(QLandmarkManager *manager, QObject *parent) + : QObject(parent), + d_ptr(new QLandmarkAbstractRequestPrivate(manager)) +{ +} + +/*! + \internal +*/ +QLandmarkAbstractRequest::QLandmarkAbstractRequest(QLandmarkAbstractRequestPrivate *dd, QObject *parent) + : QObject(parent), + d_ptr(dd) +{ +} + +/*! + Destroys the asynchronous request. Because the request object is effectiely a handle to a + request operation, the operation may continue or it may just be canceled, depending upon + the enine implementation, even though the request itself has been destroyed. + The sqlite engine continues the operation behind the scenes if the + request is destroyed whilst active. For the symbian engine see the note below. +*/ +QLandmarkAbstractRequest::~QLandmarkAbstractRequest() +{ + QLandmarkAbstractRequestPrivate::notifyEngine(this); + delete d_ptr; +} + +/*! + Returns the type of this asynchronous request. +*/ +QLandmarkAbstractRequest::RequestType QLandmarkAbstractRequest::type() const +{ + QMutexLocker ml(&d_ptr->mutex); + return d_ptr->type; +} + +/*! + Returns the state of the request +*/ +QLandmarkAbstractRequest::State QLandmarkAbstractRequest::state() +{ + QMutexLocker ml(&d_ptr->mutex); + return d_ptr->state; +} + +/*! + Returns true if the request is in the \c QLandmarkAbstractRequest::Inactive state; + otherwise, returns false. + \sa state() +*/ +bool QLandmarkAbstractRequest::isInactive() const +{ + QMutexLocker ml(&d_ptr->mutex); + return d_ptr->state == QLandmarkAbstractRequest::InactiveState; +} + +/*! + Returns true if the request is in the \c QLandmarkAbstractRequest::Active state; + otherwise, returns false. + \sa state() +*/ +bool QLandmarkAbstractRequest::isActive() const +{ + QMutexLocker ml(&d_ptr->mutex); + return d_ptr->state == QLandmarkAbstractRequest::ActiveState; +} + +/*! + Returns true if the request is in the \c QLandmarkAbstractRequest::Finished state; + otherwise, returns false. + \sa state() +*/ +bool QLandmarkAbstractRequest::isFinished() const +{ + QMutexLocker ml(&d_ptr->mutex); + return d_ptr->state == QLandmarkAbstractRequest::FinishedState; +} + +/*! + Returns the overall error of the most recent asynchronous operation. + \sa errorString() +*/ +QLandmarkManager::Error QLandmarkAbstractRequest::error() const +{ + QMutexLocker ml(&d_ptr->mutex); + return d_ptr->error; +} + +/*! + Returns a human readable string of the last error + that occurred. This error string is intended to be used + by developers only and should not be seen by end users. + \sa error() +*/ +QString QLandmarkAbstractRequest::errorString() const +{ + QMutexLocker ml(&d_ptr->mutex); + return d_ptr->errorString; +} + +/*! + Returns a pointer to the landmark manager which + this request operates on. +*/ +QLandmarkManager *QLandmarkAbstractRequest::manager() const +{ + QMutexLocker ml(&d_ptr->mutex); + return d_ptr->manager; +} + +/*! + Sets the \a manager which this request operates on. + + Note that if a NULL manager is set, the functions + start(), cancel() and waitForFinished() will return false and + error will be set to QLandmarkManager::InvalidManagerError. + + A manager cannot be assigned while the request is in the + QLandmarkAbstractRequest::ActiveState. +*/ +void QLandmarkAbstractRequest::setManager(QLandmarkManager *manager) +{ + QMutexLocker ml(&d_ptr->mutex); + if (d_ptr->state == QLandmarkAbstractRequest::ActiveState && d_ptr->manager) + return; + d_ptr->manager = manager; +} + +/*! + Attempts to start the request. + + Returns true if the request was started, otherwise false. Trying to start a + request that is already active returns false. + \sa cancel(). +*/ +bool QLandmarkAbstractRequest::start() +{ + QMutexLocker ml(&d_ptr->mutex); + if (!d_ptr->manager) { + d_ptr->error = QLandmarkManager::BadArgumentError; + d_ptr->errorString = "No manager assigned to landmark request object"; + qWarning() << d_ptr->errorString; + return false; + } + QLandmarkManagerEngine *engine = d_ptr->manager->engine(); + if (!engine) { + d_ptr->error = QLandmarkManager::InvalidManagerError; + d_ptr->errorString = "The manager is invalid"; + return false; + } + + if (d_ptr->state != QLandmarkAbstractRequest::ActiveState) { + ml.unlock(); + return engine->startRequest(this); + } + else { + return false; + } +} + +/*! + Notifies the request that it should be canceled. + + Returns true if the request was successfully notified + that it should be canceled. The request may or may not honor + the cancel notification. Returns false if the notification + could not be made or the request is not in the + QLandmarkManager::Active state. + + \sa start() +*/ +bool QLandmarkAbstractRequest::cancel() +{ + QMutexLocker ml(&d_ptr->mutex); + if (!d_ptr->manager) { + d_ptr->error = QLandmarkManager::BadArgumentError; + d_ptr->errorString = "No manager assigned to landmark request object"; + qWarning() << d_ptr->errorString; + return false; + } + QLandmarkManagerEngine *engine = d_ptr->manager->engine(); + + if(d_ptr->state == QLandmarkAbstractRequest::ActiveState) { + ml.unlock(); + return engine->cancelRequest(this); + } + else + return false; +} + +/*! + Blocks until the request has been completed or until \a msecs milliseconds + has elapsed. If \a msecs is zero or negative, this function will block indefinitely. + + Returns true if the request was canceled or completed + within the given period, otherwise returns false. Some backends may be unable + to support this operation safely and will return false immediately. + + (Note: This function is not supported for an import request + with the symbian manager which always returns false. As of + Qt Mobility 1.1.1 waitForFinished() is supported using the sqlite manager). + + Note that any signals generated while waiting for the request to be complete + may be queued and delivered sometime after this function has returned, when + the calling thread's event loop is dispatched. If your code depends on + your slots being invoked, you may need to process events after calling + this function. +*/ +bool QLandmarkAbstractRequest::waitForFinished(int msecs) +{ + + QMutexLocker ml(&d_ptr->mutex); + if (!d_ptr->manager) { + d_ptr->error = QLandmarkManager::BadArgumentError; + d_ptr->errorString = "No manager assigned to landmark request object"; + qWarning() << d_ptr->errorString; + return false; + } + QLandmarkManagerEngine *engine = d_ptr->manager->engine(); + + switch(d_ptr->state) { + case QLandmarkAbstractRequest::ActiveState: + ml.unlock(); + return engine->waitForRequestFinished(this, msecs); + case QLandmarkAbstractRequest::FinishedState: + return true; + default: + return false; + } +} + +/*! + \fn void QLandmarkAbstractRequest::resultsAvailable() + This signal is emitted when new results are available. Results + can include the operation error which may be accessed via error(), + or derived-class specific results which are accessible through + the derived class API. + + \sa error() +*/ + +/*! + \fn void QLandmarkAbstractRequest::stateChanged(QLandmarkAbstractRequest::State newState) + This signal is emitted when the state of the request is changed. The new state of + the request will be contained in \a newState. +*/ + +#include "moc_qlandmarkabstractrequest.cpp" + + + + + diff --git a/src/location/landmarks/qlandmarkabstractrequest.h b/src/location/landmarks/qlandmarkabstractrequest.h new file mode 100644 index 00000000..bd84e6d0 --- /dev/null +++ b/src/location/landmarks/qlandmarkabstractrequest.h @@ -0,0 +1,113 @@ +/**************************************************************************** +** +** Copyright (C) 2009 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 QLANDMARKABSTRACTREQUEST_H +#define QLANDMARKABSTRACTREQUEST_H + +#include "qlandmarkmanager.h" +#include <QObject> + +QTM_BEGIN_NAMESPACE + +class QLandmarkAbstractRequestPrivate; +class Q_LOCATION_EXPORT QLandmarkAbstractRequest : public QObject +{ + Q_OBJECT + +public: + enum State { + InactiveState = 0, + ActiveState, + FinishedState + }; + + enum RequestType { + InvalidRequest = 0, + LandmarkIdFetchRequest, + CategoryIdFetchRequest, + LandmarkFetchRequest, + LandmarkFetchByIdRequest, + CategoryFetchRequest, + CategoryFetchByIdRequest, + LandmarkSaveRequest, + LandmarkRemoveRequest, + CategorySaveRequest, + CategoryRemoveRequest, + ImportRequest, + ExportRequest + }; + + QLandmarkAbstractRequest(QLandmarkManager *manager, QObject *parent = 0); + virtual ~QLandmarkAbstractRequest(); + + RequestType type() const; + + State state(); + bool isInactive()const; + bool isActive() const; + bool isFinished() const; + + QLandmarkManager::Error error() const; + QString errorString() const; + + QLandmarkManager * manager() const; + void setManager(QLandmarkManager *manager); + +public Q_SLOTS: + bool start(); + bool cancel(); + bool waitForFinished(int msecs = 0); + +Q_SIGNALS: + void resultsAvailable(); + void stateChanged(QLandmarkAbstractRequest::State newState); +protected: + QLandmarkAbstractRequest(QLandmarkAbstractRequestPrivate *otherd, QObject *parent = 0); + QLandmarkAbstractRequestPrivate *d_ptr; +private: + Q_DISABLE_COPY(QLandmarkAbstractRequest) + friend class QLandmarkManagerEngine; + friend class QLandmarkAbstractRequestPrivate; +}; + +QTM_END_NAMESPACE + +#endif diff --git a/src/location/landmarks/qlandmarkabstractrequest_p.h b/src/location/landmarks/qlandmarkabstractrequest_p.h new file mode 100644 index 00000000..e1a56411 --- /dev/null +++ b/src/location/landmarks/qlandmarkabstractrequest_p.h @@ -0,0 +1,81 @@ +/**************************************************************************** +** +** 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 QLANDMARKABSTRACTREQUEST_P_H +#define QLANDMARKABSTRACTREQUEST_P_H + +#include <QMutex> +#include <QPointer> + +// +// 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 "qlandmarkabstractrequest.h" + +QTM_BEGIN_NAMESPACE + +class QLandmarkAbstractRequestPrivate +{ +public: + QLandmarkAbstractRequestPrivate(QLandmarkManager *mgr); + + virtual ~QLandmarkAbstractRequestPrivate(); + static void notifyEngine(QLandmarkAbstractRequest* request); + + QLandmarkAbstractRequest::RequestType type; + QLandmarkAbstractRequest::State state; + QLandmarkManager::Error error; + QString errorString; + QPointer<QLandmarkManager> manager; + mutable QMutex mutex; +}; + +QTM_END_NAMESPACE + +#endif diff --git a/src/location/landmarks/qlandmarkattributefilter.cpp b/src/location/landmarks/qlandmarkattributefilter.cpp new file mode 100644 index 00000000..5023bb14 --- /dev/null +++ b/src/location/landmarks/qlandmarkattributefilter.cpp @@ -0,0 +1,270 @@ +/**************************************************************************** +** +** Copyright (C) 2009 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 "qlandmarkattributefilter.h" +#include "qlandmarkfilter_p.h" +#include <QHash> + +QTM_BEGIN_NAMESPACE + +class QLandmarkAttributeFilterPrivate : public QLandmarkFilterPrivate +{ +public: + QLandmarkAttributeFilterPrivate(); + QLandmarkAttributeFilterPrivate(const QLandmarkAttributeFilterPrivate &other); + + virtual ~QLandmarkAttributeFilterPrivate(); + + virtual bool compare(const QLandmarkFilterPrivate *other) const + { + //it is assumed that the types and superclass member variables already match + const QLandmarkAttributeFilterPrivate *od = static_cast<const QLandmarkAttributeFilterPrivate*>(other); + return (attributes == od->attributes) + && (flags == od->flags) + && (operationType == od->operationType); + } + + Q_IMPLEMENT_LANDMARKFILTER_VIRTUALCTORS(QLandmarkAttributeFilter, QLandmarkFilter::AttributeFilter) + + QHash<QString, QVariant> attributes; + QHash<QString, QLandmarkFilter::MatchFlags> flags; + QLandmarkAttributeFilter::OperationType operationType; +}; + +QLandmarkAttributeFilterPrivate::QLandmarkAttributeFilterPrivate() + : QLandmarkFilterPrivate(), + attributes(QHash<QString, QVariant>()), + flags(QHash<QString, QLandmarkFilter::MatchFlags>()), + operationType(QLandmarkAttributeFilter::AndOperation) + +{ + type = QLandmarkFilter::AttributeFilter; +} + +QLandmarkAttributeFilterPrivate::QLandmarkAttributeFilterPrivate(const QLandmarkAttributeFilterPrivate &other) + : QLandmarkFilterPrivate(other), + attributes(other.attributes), + flags(other.flags), + operationType(other.operationType) +{ +} + +QLandmarkAttributeFilterPrivate::~QLandmarkAttributeFilterPrivate() +{ +} + +/*! + \class QLandmarkAttributeFilter + \brief The QLandmarkAttributeFilter class provides filtering on various landmark attributes. + + \inmodule QtLocation + + \ingroup landmarks-filter + \since 1.1 + + You can provide various keys which describe the attribute(s) to search. + Precisely which keys may be used depends on the manager + and these can be retrieved by using QLandmarkManager::searchableLandmarkAttributeKeys(). + The table below outlines some keys that may be used with the default managers on the + currently supported platforms. The match flags may be used for attributes which are + of string type (typically most, if not all searchable attributes are string types). + + \table + \header + \o {3,1} Searchable attributes + \row + \o "city" + \o "country + \o "countryCode" + \row + \o "county" + \o "description" + \o "district" + \row + \o "name" + \o "state" + \o "phoneNumber" + \row + \o "postcode" + \o "street" + \o + \endtable + + Please note that different platforms support different capabilities with the attribute filter. + \list + \o The S60 3.1, 3.2 and 5.0 platforms do not support an OR type attribute filter. + \o The S60 3.1, 3.2, 5.0 and Symbian platforms do not support the MatchContains flag. + \o The S60 3.1, 3.2, 5.0 and Symbian platforms do not support multiple attributes with an + AND type attribute filter(using a single attribute however is supported). + \endlist +*/ +Q_IMPLEMENT_LANDMARKFILTER_PRIVATE(QLandmarkAttributeFilter); + +/*! + \enum QLandmarkAttributeFilter::OperationType + Defines how the attribute criteria are combined if more than one attribute is defined. + \value AndOperation Landmarks must match all the attributes provided by the filter. + \value OrOperation Landmarks must match at least one attribute provided by the filter. +*/ + +/*! + Creates an attribute filter. +*/ +QLandmarkAttributeFilter::QLandmarkAttributeFilter() + : QLandmarkFilter(new QLandmarkAttributeFilterPrivate) +{ +} + +/*! + \fn QLandmarkAttributeFilter::QLandmarkAttributeFilter(const QLandmarkFilter &other) + Constructs a copy of \a other if possible, otherwise constructs a new attribute filter. +*/ + +/*! + Destroys the filter. +*/ +QLandmarkAttributeFilter::~QLandmarkAttributeFilter() +{ +} + +/*! + Returns the value of the attribute corresponding to \a key. + + If the attribute isn't set an invalid QVariant is returned. +*/ +QVariant QLandmarkAttributeFilter::attribute(const QString &key) const +{ + Q_D(const QLandmarkAttributeFilter); + return d->attributes.value(key); +} + +/*! + Sets the \a value of the attribute corresponding to \a key. + + For string based attributes a set of matching \a flags can be provided + to define how the string values should be matched. + For non-string based attributes the \a flags are ignored. + The beahviour of the filter is undefined if an invalid QVariant is used as a \a value +*/ +void QLandmarkAttributeFilter::setAttribute(const QString &key, const QVariant &value, QLandmarkFilter::MatchFlags flags) +{ + Q_D(QLandmarkAttributeFilter); + d->attributes[key] = value; + d->flags[key] = flags; +} + +/*! + Sets the \a value of all the attributes correponding to those in \a keys. + + For string based attributes a + set of matching \a flags can be provided to define how the string values should be matched. + For non-string based attributes the \a flags are ignored. + The behaviour of the filter is undefined if an invalid QVariant is used as \a value. +*/ +void QLandmarkAttributeFilter::setAttributes(const QStringList &keys, const QVariant &value, QLandmarkFilter::MatchFlags flags) +{ + Q_D(QLandmarkAttributeFilter); + foreach(const QString &key, keys) { + d->attributes[key] = value; + d->flags[key] = flags; + } +} + +/*! + Removes the attribute corresponding to \a key from the filter. +*/ +void QLandmarkAttributeFilter::removeAttribute(const QString &key) +{ + Q_D(QLandmarkAttributeFilter); + d->attributes.remove(key); + d->flags.remove(key); +} + +/*! + Clears all attributes from the filter. +*/ +void QLandmarkAttributeFilter::clearAttributes() +{ + Q_D(QLandmarkAttributeFilter); + d->attributes.clear(); + d->flags.clear(); +} + +/*! + Returns the keys of all attributes set in the filter. +*/ +QStringList QLandmarkAttributeFilter::attributeKeys() const +{ + Q_D(const QLandmarkAttributeFilter); + return d->attributes.keys(); +} + +/*! + Returns the operation to be used by the filter when multiple attributes + are provided. +*/ +QLandmarkAttributeFilter::OperationType QLandmarkAttributeFilter::operationType() const +{ + Q_D(const QLandmarkAttributeFilter); + return d->operationType; +} + +/*! + Sets the operation to be used by the filter when multiple attributes + are provided to \a operationType. +*/ +void QLandmarkAttributeFilter::setOperationType(QLandmarkAttributeFilter::OperationType operationType) +{ + Q_D(QLandmarkAttributeFilter); + d->operationType = operationType; +} + +/*! + Returns the match flags for a particular \a key. The match flags are only take into consideration + when the attribute for a particular key is a string. In all other cases the match flags are ignored. +*/ +QLandmarkFilter::MatchFlags QLandmarkAttributeFilter::matchFlags(const QString &key) const +{ + Q_D(const QLandmarkAttributeFilter); + return d->flags.value(key); +} + +QTM_END_NAMESPACE diff --git a/src/location/landmarks/qlandmarkattributefilter.h b/src/location/landmarks/qlandmarkattributefilter.h new file mode 100644 index 00000000..df519955 --- /dev/null +++ b/src/location/landmarks/qlandmarkattributefilter.h @@ -0,0 +1,81 @@ +/**************************************************************************** +** +** Copyright (C) 2009 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 QLANDMARKATTRIBUTEFILTER_H +#define QLANDMARKATTRIBUTEFILTER_H + +#include "qlandmarkfilter.h" +#include <QVariant> +#include <QString> +#include <QStringList> + +QTM_BEGIN_NAMESPACE +class QLandmark; + +class QLandmarkAttributeFilterPrivate; +class Q_LOCATION_EXPORT QLandmarkAttributeFilter : public QLandmarkFilter +{ +public: + QLandmarkAttributeFilter(); + QLandmarkAttributeFilter(const QLandmarkFilter &other); + virtual ~QLandmarkAttributeFilter(); + + enum OperationType{AndOperation, OrOperation}; + + QVariant attribute(const QString &key) const; + void setAttribute(const QString &key, const QVariant &value, QLandmarkFilter::MatchFlags flags =0); + void setAttributes(const QStringList &key, const QVariant &value, QLandmarkFilter::MatchFlags flags=0); + void removeAttribute(const QString &key); + void clearAttributes(); + QStringList attributeKeys() const; + + QLandmarkFilter::MatchFlags matchFlags(const QString &key) const; + + OperationType operationType() const; + void setOperationType(OperationType operationType); + +private: + Q_DECLARE_LANDMARKFILTER_PRIVATE(QLandmarkAttributeFilter) +}; + +QTM_END_NAMESPACE + +#endif diff --git a/src/location/landmarks/qlandmarkboxfilter.cpp b/src/location/landmarks/qlandmarkboxfilter.cpp new file mode 100644 index 00000000..d135ab11 --- /dev/null +++ b/src/location/landmarks/qlandmarkboxfilter.cpp @@ -0,0 +1,164 @@ +/**************************************************************************** +** +** Copyright (C) 2009 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 "qlandmarkboxfilter.h" +#include "qlandmarkboxfilter_p.h" +#include "qgeocoordinate.h" + +QTM_BEGIN_NAMESPACE + +/*! + \class QLandmarkBoxFilter + \brief The QLandmarkBoxFilter class is used to search for landmarks within a given bounding box. + + \inmodule QtLocation + + \ingroup landmarks-filter + \since 1.1 + + In order to be a valid filter, the region covered by the box filter must not cover one of the poles. +*/ + +Q_IMPLEMENT_LANDMARKFILTER_PRIVATE(QLandmarkBoxFilter); + +/*! + Creates a filter that will search for landmarks within a bounding + box defined by the \a topLeft and \a bottomRight coordinates. +*/ +QLandmarkBoxFilter::QLandmarkBoxFilter(const QGeoCoordinate &topLeft, + const QGeoCoordinate &bottomRight) + : QLandmarkFilter(new QLandmarkBoxFilterPrivate(QGeoBoundingBox(topLeft, bottomRight))) +{ +} + +/*! + Creates a filter that will search for landmarks within the \a boundingBox. +*/ +QLandmarkBoxFilter::QLandmarkBoxFilter(const QGeoBoundingBox &boundingBox) + : QLandmarkFilter(new QLandmarkBoxFilterPrivate(boundingBox)) +{ +} + +/*! + \fn QLandmarkBoxFilter::QLandmarkBoxFilter(const QLandmarkFilter &other) + Constructs a copy of \a other if possible, otherwise constructs a new box filter. +*/ + +/*! + Destroys the filter. +*/ +QLandmarkBoxFilter::~QLandmarkBoxFilter() +{ + // pointer deleted in superclass destructor +} + +/*! + Returns the filter's bounding box. +*/ +QGeoBoundingBox QLandmarkBoxFilter::boundingBox() const +{ + Q_D(const QLandmarkBoxFilter); + return d->boundingBox; +} + +/*! + Sets the \a boundingBox of the filter. +*/ +void QLandmarkBoxFilter::setBoundingBox(const QGeoBoundingBox &boundingBox) +{ + Q_D(QLandmarkBoxFilter); + d->boundingBox = boundingBox; +} + +/*! + Returns the top left coordinate of the box filter. +*/ +QGeoCoordinate QLandmarkBoxFilter::topLeft() +{ + Q_D(const QLandmarkBoxFilter); + return d->boundingBox.topLeft(); +} + +/*! + Sets the \a topLeft coordinate of the box filter. +*/ +void QLandmarkBoxFilter::setTopLeft(const QGeoCoordinate &topLeft) +{ + Q_D(QLandmarkBoxFilter); + d->boundingBox.setTopLeft(topLeft); +} + + +/*! + Returns the bottom right coordinate of the box filter. +*/ +QGeoCoordinate QLandmarkBoxFilter::bottomRight() +{ + Q_D(const QLandmarkBoxFilter); + return d->boundingBox.bottomRight(); +} + +/*! + Sets the \a bottomRight coordinate of the box filter. +*/ +void QLandmarkBoxFilter::setBottomRight(const QGeoCoordinate &bottomRight) +{ + Q_D(QLandmarkBoxFilter); + return d->boundingBox.setBottomRight(bottomRight); +} + +/******************************************************************************* +*******************************************************************************/ + +QLandmarkBoxFilterPrivate::QLandmarkBoxFilterPrivate(const QGeoBoundingBox &box) + : QLandmarkFilterPrivate(), + boundingBox(box) +{ + type = QLandmarkFilter::BoxFilter; +} + +QLandmarkBoxFilterPrivate::QLandmarkBoxFilterPrivate(const QLandmarkBoxFilterPrivate &other) + : QLandmarkFilterPrivate(other), + boundingBox(other.boundingBox) {} + +QLandmarkBoxFilterPrivate::~QLandmarkBoxFilterPrivate() {} + +QTM_END_NAMESPACE diff --git a/src/location/landmarks/qlandmarkboxfilter.h b/src/location/landmarks/qlandmarkboxfilter.h new file mode 100644 index 00000000..852dbf63 --- /dev/null +++ b/src/location/landmarks/qlandmarkboxfilter.h @@ -0,0 +1,81 @@ +/**************************************************************************** +** +** Copyright (C) 2009 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 QLANDMARKBOXFILTER_H +#define QLANDMARKBOXFILTER_H + +#include "qlandmarkfilter.h" +#include "qgeocoordinate.h" +#include "qgeoboundingbox.h" + +QT_BEGIN_HEADER + +QTM_BEGIN_NAMESPACE + +class QLandmarkBoxFilterPrivate; +class Q_LOCATION_EXPORT QLandmarkBoxFilter : public QLandmarkFilter +{ +public: + + QLandmarkBoxFilter(const QGeoBoundingBox &boundingBox = QGeoBoundingBox()); + QLandmarkBoxFilter(const QGeoCoordinate &topLeft, + const QGeoCoordinate &bottomRight); + QLandmarkBoxFilter(const QLandmarkFilter &other); + virtual ~QLandmarkBoxFilter(); + + QGeoBoundingBox boundingBox() const; + void setBoundingBox(const QGeoBoundingBox &boundingBox); + + QGeoCoordinate topLeft(); + void setTopLeft(const QGeoCoordinate &topLeft); + + QGeoCoordinate bottomRight(); + void setBottomRight(const QGeoCoordinate &bottomRight); + +private: + Q_DECLARE_LANDMARKFILTER_PRIVATE(QLandmarkBoxFilter) +}; + +QTM_END_NAMESPACE + +QT_END_HEADER + +#endif diff --git a/src/location/landmarks/qlandmarkboxfilter_p.h b/src/location/landmarks/qlandmarkboxfilter_p.h new file mode 100644 index 00000000..ed68dc85 --- /dev/null +++ b/src/location/landmarks/qlandmarkboxfilter_p.h @@ -0,0 +1,83 @@ +/**************************************************************************** +** +** Copyright (C) 2009 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 QLANDMARKBOXFILTER_P_H +#define QLANDMARKBOXFILTER_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 "qlandmarkfilter_p.h" +#include "qgeoboundingbox.h" + +QTM_BEGIN_NAMESPACE + +class QGeoCoordinate; + +class QLandmarkBoxFilterPrivate : public QLandmarkFilterPrivate +{ +public: + QLandmarkBoxFilterPrivate(const QGeoBoundingBox &boundingBox = QGeoBoundingBox()); + QLandmarkBoxFilterPrivate(const QLandmarkBoxFilterPrivate &other); + virtual ~QLandmarkBoxFilterPrivate(); + + virtual bool compare(const QLandmarkFilterPrivate* other) const + { + const QLandmarkBoxFilterPrivate *od = static_cast<const QLandmarkBoxFilterPrivate*>(other); + return (boundingBox == od->boundingBox); + } + + Q_IMPLEMENT_LANDMARKFILTER_VIRTUALCTORS(QLandmarkBoxFilter, QLandmarkFilter::BoxFilter); + + QGeoBoundingBox boundingBox; +}; + +QTM_END_NAMESPACE + +#endif diff --git a/src/location/landmarks/qlandmarkcategory.cpp b/src/location/landmarks/qlandmarkcategory.cpp new file mode 100644 index 00000000..d8d69075 --- /dev/null +++ b/src/location/landmarks/qlandmarkcategory.cpp @@ -0,0 +1,246 @@ +/**************************************************************************** +** +** Copyright (C) 2009 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 "qlandmarkcategory.h" +#include "qlandmarkcategory_p.h" +#include "qlandmarkcategoryid.h" + +#include <QStringList> +#include <QVariant> + +#ifdef CATEGORYPRIVATE_DEBUG +#include <QDebug> +#endif + +QTM_USE_NAMESPACE + +// ----- QLandmarkCategoryPrivate ----- + +QLandmarkCategoryPrivate::QLandmarkCategoryPrivate() + : QSharedData(), + name(QString()), + iconUrl(QUrl()), + id(QLandmarkCategoryId()) +{ +} + +QLandmarkCategoryPrivate::QLandmarkCategoryPrivate(const QLandmarkCategoryPrivate &other) + : QSharedData(other), + name(other.name), + iconUrl(other.iconUrl), + id(other.id) +{ +} + +QLandmarkCategoryPrivate::~QLandmarkCategoryPrivate() +{ +} + +QLandmarkCategoryPrivate& QLandmarkCategoryPrivate::operator= (const QLandmarkCategoryPrivate & other) +{ + name = other.name; + iconUrl = other.iconUrl; + id = other.id; + + return *this; +} + +bool QLandmarkCategoryPrivate::operator == (const QLandmarkCategoryPrivate &other) const +{ + +#ifdef CATEGORYPRIVATE_DEBUG + qDebug() << "name: " << (name == other.name); + qDebug() << "id:" << (id == other.id); +#endif + return ((name == other.name) + && (iconUrl == other.iconUrl) + && (id == other.id)); +} + +/*! + \class QLandmarkCategory + + \brief The QLandmarkCategory class designates a grouping of + landmarks of similar type. + + \inmodule QtLocation + + \ingroup landmarks-main + \since 1.1 + + Landmarks of similar type may be grouped together into categories, + e.g. restaurants, accommodation etc, a QLandmarkCategory object + represents one of these. + + More than one category can be assigned to a landmark. Assignment + of a category to a landmark is achieved by using the QLandmark::setCategoryIds() + or QLandmark::addCategoryId() functions. + + Some categories may be considered read-only by a manager and cannot + be saved. To see if a category is read only, the id of the cateory must be passed + into the QLandmarkManager::isReadOnly() function. Localization is only possible for categories that + are read-only. + + A QLandmarkCategory instance is an in memory representation and may + not reflect the state of the category found in persistent storage, + until the appropriate synchronization method is called on the + QLandmarkManager(e.g.\l {QLandmarkManager::saveCategory()} {saveCategory()}, + \l {QLandmarkManager::removeCategory()} {removeCategory()}). +*/ + +/*! + Constructs an empty category. + + A new category will be assigned an invalid QLandmarkCategoryId. +*/ +QLandmarkCategory::QLandmarkCategory() + : d(new QLandmarkCategoryPrivate) +{ +} + +/*! + Constructs a copy of \a other. +*/ +QLandmarkCategory::QLandmarkCategory(const QLandmarkCategory &other) + : d(other.d) +{ +} + +/*! + Destroys the category. +*/ +QLandmarkCategory::~QLandmarkCategory() +{ +} +/*! + Assigns \a other to this category and returns a reference to this category. +*/ +QLandmarkCategory& QLandmarkCategory::operator= (const QLandmarkCategory & other) +{ + *d = *(other.d); + return *this; +} + +/*! + Returns true if this category is equal to \a other, otherwise + returns false. + + \sa operator!=() +*/ +bool QLandmarkCategory::operator== (const QLandmarkCategory &other) const +{ + return (*d == *(other.d)); +} + +/*! + Returns true if this category is not equal to \a other, otherwise + returns false. + + \sa operator==() +*/ +bool QLandmarkCategory::operator!= (const QLandmarkCategory &other) const +{ + return !(*this == other); +} + +/*! + Returns the name of the category. +*/ +QString QLandmarkCategory::name() const +{ + return d->name; +} + +/*! + Sets the \a name of the category. + + Using the default manager on the Symbian platform, the catgory name is retricted to a length of 124 characters. +*/ +void QLandmarkCategory::setName(const QString &name) +{ + d->name = name; +} + +/*! + Returns the url of the category's icon. +*/ +QUrl QLandmarkCategory::iconUrl() const +{ + return d->iconUrl; +} + +/*! + Sets the \a url of the category's icon +*/ +void QLandmarkCategory::setIconUrl(const QUrl &url) +{ + d->iconUrl = url; +} + + +/*! + Returns the identifier of the category. +*/ +QLandmarkCategoryId QLandmarkCategory::categoryId() const +{ + return d->id; +} + +/*! + Sets the \a id of the category. + + Note that saving a new category using a QLandmarkManager + will automatically assign the category a valid identifier. +*/ +void QLandmarkCategory::setCategoryId(const QLandmarkCategoryId &id) +{ + d->id = id; +} + +/*! + Clears all the data fields of the category. +*/ +void QLandmarkCategory::clear() +{ + d->name.clear(); + d->iconUrl.clear(); + d->id = QLandmarkCategoryId(); +} diff --git a/src/location/landmarks/qlandmarkcategory.h b/src/location/landmarks/qlandmarkcategory.h new file mode 100644 index 00000000..c694e0c8 --- /dev/null +++ b/src/location/landmarks/qlandmarkcategory.h @@ -0,0 +1,93 @@ +/**************************************************************************** +** +** Copyright (C) 2009 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 QLANDMARKCATEGORY_H +#define QLANDMARKCATEGORY_H + +#include "qmobilityglobal.h" +#include <QVariant> +#include <QSharedDataPointer> + + +class QStringList; +class QUrl; + +QT_BEGIN_HEADER + +QTM_BEGIN_NAMESPACE +class QLandmarkCategoryId; + +class QLandmarkCategoryPrivate; +class Q_LOCATION_EXPORT QLandmarkCategory +{ +public: + QLandmarkCategory(); + QLandmarkCategory(const QLandmarkCategory &other); + ~QLandmarkCategory(); + + QLandmarkCategory& operator= (const QLandmarkCategory &other); + + bool operator==(const QLandmarkCategory &other) const; + bool operator!=(const QLandmarkCategory &other) const; + + QString name() const; + void setName(const QString &name); + + QUrl iconUrl() const; + void setIconUrl(const QUrl &url); + + QLandmarkCategoryId categoryId() const; + void setCategoryId(const QLandmarkCategoryId &id); + + void clear(); +private: + QSharedDataPointer<QLandmarkCategoryPrivate> d; +}; + +QTM_END_NAMESPACE + +Q_DECLARE_METATYPE(QTM_PREPEND_NAMESPACE(QLandmarkCategory)) + +Q_DECLARE_TYPEINFO(QTM_PREPEND_NAMESPACE(QLandmarkCategory), Q_MOVABLE_TYPE); + +QT_END_HEADER + +#endif diff --git a/src/location/landmarks/qlandmarkcategory_p.h b/src/location/landmarks/qlandmarkcategory_p.h new file mode 100644 index 00000000..a11bcac3 --- /dev/null +++ b/src/location/landmarks/qlandmarkcategory_p.h @@ -0,0 +1,84 @@ +/**************************************************************************** +** +** Copyright (C) 2009 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 QLANDMARKCATEGORY_P_H +#define QLANDMARKCATEGORY_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 "qlandmarkcategoryid.h" +#include <QString> +#include <QUrl> +#include <QSharedData> + +QTM_BEGIN_NAMESPACE + +class QLandmarkCategoryPrivate : public QSharedData +{ +public: + QLandmarkCategoryPrivate(); + QLandmarkCategoryPrivate(const QLandmarkCategoryPrivate &other); + ~QLandmarkCategoryPrivate(); + + QLandmarkCategoryPrivate& operator= (const QLandmarkCategoryPrivate &other); + + bool operator== (const QLandmarkCategoryPrivate &other) const; + // consider inline != in terms of ==? + + QString name; + QUrl iconUrl; + QLandmarkCategoryId id; + static QStringList commonKeys; +}; + + +QTM_END_NAMESPACE + +#endif diff --git a/src/location/landmarks/qlandmarkcategoryfetchbyidrequest.cpp b/src/location/landmarks/qlandmarkcategoryfetchbyidrequest.cpp new file mode 100644 index 00000000..3801b6dd --- /dev/null +++ b/src/location/landmarks/qlandmarkcategoryfetchbyidrequest.cpp @@ -0,0 +1,144 @@ +/**************************************************************************** +** +** Copyright (C) 2009 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 "qlandmarkcategoryfetchbyidrequest.h" +#include "qlandmarkrequests_p.h" +#include "qlandmarkcategory.h" + +QTM_BEGIN_NAMESPACE + +/*! + \class QLandmarkCategoryFetchByIdRequest + \brief The QLandmarkCategoryFetchByIdRequest class allows a client to asynchronously + request a list of categories by ID from a landmark manager. + + The categories fetched by the manager should have a one-to-one correspondence to the + IDs passed into this class. That is, the nth category in the returned list should + have an ID which is equal to the nth ID in the list of IDs. Any invalid ID should + correspond to an empty QLandmarkCategory. + + For a QLandmarkCategoryFetchByIdRequest, the resultsAvailable() signal will be emitted + as resultant categories are found (these are retrievable by calling categories()), + whenever individual items error out(individual errors may be retrieved by calling errorMap()), + as well as if an overall operation error occurred(which may be retrieved by calling + QLandmarkAbstractRequest::error()). + + Please see the class documentation for QLandmarkAbstractRequest for more information + about he usage of request classes and ownership semantics. + + + \inmodule QtLocation + + \ingroup landmarks-request + \since 1.2 +*/ + +/*! + Creates a new a request object with the given \a manager and \a parent. +*/ +QLandmarkCategoryFetchByIdRequest::QLandmarkCategoryFetchByIdRequest(QLandmarkManager *manager, QObject *parent) + :QLandmarkAbstractRequest(new QLandmarkCategoryFetchByIdRequestPrivate(manager), parent) +{ +} + +/*! + Destroys the request object. +*/ +QLandmarkCategoryFetchByIdRequest::~QLandmarkCategoryFetchByIdRequest() +{ +} + +/*! + Returns a list of identifiers of categories which are to be retrieved by this request. +*/ +QList<QLandmarkCategoryId> QLandmarkCategoryFetchByIdRequest::categoryIds() const +{ + Q_D(const QLandmarkCategoryFetchByIdRequest); + QMutexLocker ml(&d->mutex); + return d->categoryIds; +} + +/*! + Sets this request to retrieve a list of categories identified by \a categoryIds. +*/ +void QLandmarkCategoryFetchByIdRequest::setCategoryIds(const QList<QLandmarkCategoryId> &categoryIds) +{ + Q_D(QLandmarkCategoryFetchByIdRequest); + QMutexLocker ml(&d->mutex); + d->categoryIds = categoryIds; +} + +/*! + Convenience function that sets a single category, specified by \a categoryId, + to be retrieved by this request. +*/ +void QLandmarkCategoryFetchByIdRequest::setCategoryId(const QLandmarkCategoryId &categoryId) +{ + Q_D(QLandmarkCategoryFetchByIdRequest); + QMutexLocker ml(&d->mutex); + d->categoryIds.clear(); + d->categoryIds.append(categoryId); +} + +/*! + Returns the list of categories fetched by this request +*/ +QList<QLandmarkCategory> QLandmarkCategoryFetchByIdRequest::categories() const +{ + Q_D(const QLandmarkCategoryFetchByIdRequest); + QMutexLocker ml(&d->mutex); + return d->categories; +} + +/*! + Returns the mapping of input category id list indices + to the errors which occurred. +*/ +QMap<int, QLandmarkManager::Error> QLandmarkCategoryFetchByIdRequest::errorMap() const +{ + Q_D(const QLandmarkCategoryFetchByIdRequest); + QMutexLocker ml(&d->mutex); + return d->errorMap; +} + +#include "moc_qlandmarkcategoryfetchbyidrequest.cpp" + +QTM_END_NAMESPACE diff --git a/src/location/landmarks/qlandmarkcategoryfetchbyidrequest.h b/src/location/landmarks/qlandmarkcategoryfetchbyidrequest.h new file mode 100644 index 00000000..802717aa --- /dev/null +++ b/src/location/landmarks/qlandmarkcategoryfetchbyidrequest.h @@ -0,0 +1,73 @@ +/**************************************************************************** +** +** Copyright (C) 2009 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 QLANDMARKCATEGORYFETCHBYIDREQUEST_H +#define QLANDMARKCATEGORYFETCHBYIDREQUEST_H + +#include "qlandmarkabstractrequest.h" +#include "qlandmarkcategoryid.h" + +QTM_BEGIN_NAMESPACE + +class QLandmarkCategoryFetchByIdRequestPrivate; +class Q_LOCATION_EXPORT QLandmarkCategoryFetchByIdRequest : public QLandmarkAbstractRequest +{ + Q_OBJECT +public: + QLandmarkCategoryFetchByIdRequest(QLandmarkManager *manager, QObject *parent=0); + ~QLandmarkCategoryFetchByIdRequest(); + + QList<QLandmarkCategoryId> categoryIds() const; + void setCategoryIds(const QList<QLandmarkCategoryId> &categoryIds); + void setCategoryId(const QLandmarkCategoryId &categoryId); + + QList<QLandmarkCategory> categories() const; + QMap<int, QLandmarkManager::Error> errorMap() const; + +private: + Q_DISABLE_COPY(QLandmarkCategoryFetchByIdRequest) + Q_DECLARE_PRIVATE(QLandmarkCategoryFetchByIdRequest) + friend class QLandmarkManagerEngine; +}; + +QTM_END_NAMESPACE + +#endif diff --git a/src/location/landmarks/qlandmarkcategoryfetchrequest.cpp b/src/location/landmarks/qlandmarkcategoryfetchrequest.cpp new file mode 100644 index 00000000..9406594b --- /dev/null +++ b/src/location/landmarks/qlandmarkcategoryfetchrequest.cpp @@ -0,0 +1,166 @@ +/**************************************************************************** +** +** Copyright (C) 2009 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 "qlandmarkcategoryfetchrequest.h" +#include "qlandmarkrequests_p.h" +#include "qlandmarkcategory.h" + +QTM_BEGIN_NAMESPACE + +/*! + \class QLandmarkCategoryFetchRequest + \brief The QLandmarkCategoryFetchRequest class allows a client to asynchronously + request a list of categories from a landmark manager. + + For a QLandmarkCategoryFetchRequest, the resultsAvailable() signal will be emitted + as resultant categories are found (these are retrievable by calling categories()), + as well as if an overall operation error occurred(which may be retrieved by calling + QLandmarkAbstractRequest::error()). + + Please see the class documentation for QLandmarkAbstractRequest for more information about + the usage of request classes and ownership semantics. + + \inmodule QtLocation + \since 1.1 + + \ingroup landmarks-request +*/ + +/*! + Creates a new category fetch request object with the given \a manager and \a parent. +*/ +QLandmarkCategoryFetchRequest::QLandmarkCategoryFetchRequest(QLandmarkManager *manager, QObject *parent) + :QLandmarkAbstractRequest(new QLandmarkCategoryFetchRequestPrivate(manager), parent) +{ +} + +/*! + Destroys the request object. +*/ +QLandmarkCategoryFetchRequest::~QLandmarkCategoryFetchRequest() +{ +} + +/*! + Returns the list of categories that have been found during the + request. +*/ +QList<QLandmarkCategory> QLandmarkCategoryFetchRequest::categories() const +{ + Q_D(const QLandmarkCategoryFetchRequest); + QMutexLocker ml(&d->mutex); + return d->categories; +} + +/*! + Returns the sorting of the categories. + By default the sorting is case insensitive and in ascending order + according to the category name. +*/ +QLandmarkNameSort QLandmarkCategoryFetchRequest::sorting() const +{ + Q_D(const QLandmarkCategoryFetchRequest); + QMutexLocker ml(&d->mutex); + return d->sorting; +} + +/*! + Sets \a nameSort to specify the sorting of the returned categories. +*/ +void QLandmarkCategoryFetchRequest::setSorting(const QLandmarkNameSort &nameSort) +{ + Q_D(QLandmarkCategoryFetchRequest); + QMutexLocker ml(&d->mutex); + d->sorting = nameSort; +} + +/*! + Returns the maximum number of categories to be returned. By default the limit + is -1 indicating that all categories should be retrieved. +*/ +int QLandmarkCategoryFetchRequest::limit() const +{ + Q_D(const QLandmarkCategoryFetchRequest); + QMutexLocker ml(&d->mutex); + return d->limit; +} + +/*! + Sets the maximum number of categories to be returned to \a limit. + A limit of -1 will retrieve all categories. + + (A limit of 0 will retrieve no categories.) + */ +void QLandmarkCategoryFetchRequest::setLimit(int limit) +{ + Q_D(QLandmarkCategoryFetchRequest); + QMutexLocker ml(&d->mutex); + d->limit = limit; +} + +/*! + Returns the index offset for the request. By default the offset is 0. + The offset determines the first index which is retrieved, it is generally + used in conjunction with limit() to facilitate paging. + + For example, if there are 10 categories in the landmark store, setting the offset + to 2 and limit to 5 will retrieve the 3rd to 7th categories inclusively. (The order of categories + is specified by the sorting field). +*/ +int QLandmarkCategoryFetchRequest::offset() const +{ + Q_D(const QLandmarkCategoryFetchRequest); + QMutexLocker ml(&d->mutex); + return d->offset; +} + +/*! + Sets the index \a offset for the request. +*/ +void QLandmarkCategoryFetchRequest::setOffset(int offset) { + Q_D(QLandmarkCategoryFetchRequest); + QMutexLocker ml(&d->mutex); + d->offset = offset; +} + +#include "moc_qlandmarkcategoryfetchrequest.cpp" + +QTM_END_NAMESPACE diff --git a/src/location/landmarks/qlandmarkcategoryfetchrequest.h b/src/location/landmarks/qlandmarkcategoryfetchrequest.h new file mode 100644 index 00000000..0b77bc11 --- /dev/null +++ b/src/location/landmarks/qlandmarkcategoryfetchrequest.h @@ -0,0 +1,78 @@ +/**************************************************************************** +** +** Copyright (C) 2009 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 QLANDMARKCATEGORYFETCHREQUEST_H +#define QLANDMARKCATEGORYFETCHREQUEST_H + +#include "qlandmarkabstractrequest.h" +#include "qlandmarkcategoryid.h" +#include "qlandmarknamesort.h" + +QTM_BEGIN_NAMESPACE + +class QLandmarkCategoryFetchRequestPrivate; +class Q_LOCATION_EXPORT QLandmarkCategoryFetchRequest : public QLandmarkAbstractRequest +{ + Q_OBJECT +public: + QLandmarkCategoryFetchRequest(QLandmarkManager *manager, QObject *parent=0); + ~QLandmarkCategoryFetchRequest(); + + QList<QLandmarkCategory> categories() const; + + QLandmarkNameSort sorting() const; + void setSorting(const QLandmarkNameSort &nameSort); + + int limit() const; + void setLimit(int limit); + + int offset() const; + void setOffset(int offset); + +private: + Q_DISABLE_COPY(QLandmarkCategoryFetchRequest) + Q_DECLARE_PRIVATE(QLandmarkCategoryFetchRequest) + friend class QLandmarkManagerEngine; +}; + +QTM_END_NAMESPACE + +#endif diff --git a/src/location/landmarks/qlandmarkcategoryfilter.cpp b/src/location/landmarks/qlandmarkcategoryfilter.cpp new file mode 100644 index 00000000..0bfeae5f --- /dev/null +++ b/src/location/landmarks/qlandmarkcategoryfilter.cpp @@ -0,0 +1,127 @@ +/**************************************************************************** +** +** Copyright (C) 2009 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 "qlandmarkcategoryfilter.h" +#include "qlandmarkcategoryfilter_p.h" +#include "qlandmarkcategoryid.h" + +QTM_BEGIN_NAMESPACE + +/*! + \class QLandmarkCategoryFilter + \brief The QLandmarkCategoryFilter class is used to search for landmarks that + belong to a certain category. + + \inmodule QtLocation + \since 1.1 + + \ingroup landmarks-filter +*/ + +Q_IMPLEMENT_LANDMARKFILTER_PRIVATE(QLandmarkCategoryFilter) + +/*! + Creates a filter that searches for landmarks that belong to the category + identified by \a categoryId. +*/ +QLandmarkCategoryFilter::QLandmarkCategoryFilter(const QLandmarkCategoryId &categoryId) + : QLandmarkFilter(new QLandmarkCategoryFilterPrivate(categoryId)) +{ +} + +/*! + \fn QLandmarkCategoryFilter::QLandmarkCategoryFilter(const QLandmarkFilter &other) + Constructs a copy of \a other if possible, otherwise constructs a new category filter. +*/ + +/*! + Destroys the filter. +*/ +QLandmarkCategoryFilter::~QLandmarkCategoryFilter() +{ + // pointer deleted in superclass destructor +} + +/*! + Returns the category identifier that this filter matches by. +*/ +QLandmarkCategoryId QLandmarkCategoryFilter::categoryId() const +{ + Q_D(const QLandmarkCategoryFilter); + return d->id; +} + +/*! + Sets the category identifier that this filter matches by + to \a categoryId. +*/ +void QLandmarkCategoryFilter::setCategoryId(const QLandmarkCategoryId &categoryId) +{ + Q_D(QLandmarkCategoryFilter); + d->id = categoryId; +} + +/*! + Convenience function to set the \a category that this filter matches by. + It is equivalent to calling setCategory(category.categoryId()). +*/ +void QLandmarkCategoryFilter::setCategory(const QLandmarkCategory &category) +{ + Q_D(QLandmarkCategoryFilter); + d->id = category.categoryId(); +} + +/******************************************************************************* +*******************************************************************************/ + +QLandmarkCategoryFilterPrivate::QLandmarkCategoryFilterPrivate(const QLandmarkCategoryId &id) + : id(id) +{ + type = QLandmarkFilter::CategoryFilter; +} + +QLandmarkCategoryFilterPrivate::QLandmarkCategoryFilterPrivate(const QLandmarkCategoryFilterPrivate &other) + : QLandmarkFilterPrivate(other), + id(other.id) {} + +QLandmarkCategoryFilterPrivate::~QLandmarkCategoryFilterPrivate() {} + +QTM_END_NAMESPACE diff --git a/src/location/landmarks/qlandmarkcategoryfilter.h b/src/location/landmarks/qlandmarkcategoryfilter.h new file mode 100644 index 00000000..88df8700 --- /dev/null +++ b/src/location/landmarks/qlandmarkcategoryfilter.h @@ -0,0 +1,75 @@ +/**************************************************************************** +** +** Copyright (C) 2009 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 QLANDMARKCATEGORYFILTER_H +#define QLANDMARKCATEGORYFILTER_H + +#include "qlandmarkfilter.h" +#include "qlandmarkcategoryid.h" +#include "qlandmarkcategory.h" + +QT_BEGIN_HEADER + +QTM_BEGIN_NAMESPACE + +class QLandmarkCategoryId; + +class QLandmarkCategoryFilterPrivate; +class Q_LOCATION_EXPORT QLandmarkCategoryFilter : public QLandmarkFilter +{ +public: + QLandmarkCategoryFilter(const QLandmarkCategoryId &categoryId = QLandmarkCategoryId()); + QLandmarkCategoryFilter(const QLandmarkFilter &other); + virtual ~QLandmarkCategoryFilter(); + + QLandmarkCategoryId categoryId() const; + void setCategoryId(const QLandmarkCategoryId &categoryId); + void setCategory(const QLandmarkCategory &category); + +private: + Q_DECLARE_LANDMARKFILTER_PRIVATE(QLandmarkCategoryFilter) +}; + +QTM_END_NAMESPACE + +QT_END_HEADER + +#endif diff --git a/src/location/landmarks/qlandmarkcategoryfilter_p.h b/src/location/landmarks/qlandmarkcategoryfilter_p.h new file mode 100644 index 00000000..49b1b925 --- /dev/null +++ b/src/location/landmarks/qlandmarkcategoryfilter_p.h @@ -0,0 +1,82 @@ +/**************************************************************************** +** +** Copyright (C) 2009 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 QLANDMARKCATEGORYFILTER_P_H +#define QLANDMARKCATEGORYFILTER_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 "qlandmarkfilter_p.h" + +QTM_BEGIN_NAMESPACE + +class QLandmarkCategoryId; + +class QLandmarkCategoryFilterPrivate : public QLandmarkFilterPrivate +{ +public: + QLandmarkCategoryFilterPrivate(const QLandmarkCategoryId &id = QLandmarkCategoryId()); + QLandmarkCategoryFilterPrivate(const QLandmarkCategoryFilterPrivate &other); + virtual ~QLandmarkCategoryFilterPrivate(); + + virtual bool compare(const QLandmarkFilterPrivate *other) const + { + const QLandmarkCategoryFilterPrivate *od = static_cast<const QLandmarkCategoryFilterPrivate*>(other); + return id == od->id; + } + + QLandmarkCategoryId id; + + Q_IMPLEMENT_LANDMARKFILTER_VIRTUALCTORS(QLandmarkCategoryFilter, QLandmarkFilter::CategoryFilter) +}; + +QTM_END_NAMESPACE + +#endif diff --git a/src/location/landmarks/qlandmarkcategoryid.cpp b/src/location/landmarks/qlandmarkcategoryid.cpp new file mode 100644 index 00000000..ba08fba6 --- /dev/null +++ b/src/location/landmarks/qlandmarkcategoryid.cpp @@ -0,0 +1,171 @@ +/**************************************************************************** +** +** Copyright (C) 2009 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 "qlandmarkcategoryid.h" +#include "qlandmarkcategoryid_p.h" +#include <QString> + +QTM_USE_NAMESPACE + +/*! + \class QLandmarkCategoryId + + \inmodule QtLocation + + \ingroup landmarks-main + \since 1.1 + + \brief The QLandmarkCategoryId class provides a unique identifier for + a category. + + It consists of a manager URI which identifies the manager which contains + the category, and a manager specific local id for that category. +*/ + +/*! + + Creates an invalid identifier. + + The local id and manager URI are empty strings. +*/ +QLandmarkCategoryId::QLandmarkCategoryId() + : d(new QLandmarkCategoryIdPrivate) +{ +} + +/*! + Constructs a copy of \a other. +*/ +QLandmarkCategoryId::QLandmarkCategoryId(const QLandmarkCategoryId &other) + : d(other.d) +{ +} + +/*! + Destroys the identifier. +*/ +QLandmarkCategoryId::~QLandmarkCategoryId() +{ +} + +/*! + Returns true if the identifier is valid, meaning that both + a manager URI and local id have been set +*/ +bool QLandmarkCategoryId::isValid() const +{ + return (!d->m_uri.isEmpty() && !d->m_localId.isEmpty()); +} + +/*! + Returns the local id of the category identifier. + + This id is specific to a particular landmark manager. +*/ +QString QLandmarkCategoryId::localId() const +{ + return d->m_localId; +} + +/*! + Sets the local \a id of the category identifier. +*/ +void QLandmarkCategoryId::setLocalId(const QString &id) +{ + d->m_localId = id; +} + +/*! + Returns the URI of the manager which this category identifer + belongs to. +*/ +QString QLandmarkCategoryId::managerUri() const +{ + return d->m_uri; +} + +/*! + Sets the manager \a uri which this category identifier + belongs to. +*/ +void QLandmarkCategoryId::setManagerUri(const QString &uri) +{ + d->m_uri = uri; +} + +/*! + Assigns \a other to this category identifier and returns a reference + to this category identifier. +*/ +QLandmarkCategoryId &QLandmarkCategoryId::operator=(const QLandmarkCategoryId & other) +{ + d = other.d; + return *this; +} + +/*! + Returns true if this category identifer is equal to \a other, otherwise + returns false. + + Two QLandmarkCategoryIds are considered equal if both have the same + manager URI and local id. + + \sa operator!=() +*/ +bool QLandmarkCategoryId::operator==(const QLandmarkCategoryId &other) const +{ + return ((d->m_localId == other.d->m_localId) + && (d->m_uri == other.d->m_uri)); +} + +/*! + Returns true if this category identifier is not equal to \a other, + otherwise returns false. + + If either the manager URIs or local ids differ, then the + QLandmarkCategoryIds are not considered equal. + + \sa operator==() +*/ +bool QLandmarkCategoryId::operator!=(const QLandmarkCategoryId &other) const +{ + return !this->operator ==(other); +} diff --git a/src/location/landmarks/qlandmarkcategoryid.h b/src/location/landmarks/qlandmarkcategoryid.h new file mode 100644 index 00000000..90e811d9 --- /dev/null +++ b/src/location/landmarks/qlandmarkcategoryid.h @@ -0,0 +1,83 @@ +/**************************************************************************** +** +** Copyright (C) 2009 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 QLANDMARKCATEGORYID_H +#define QLANDMARKCATEGORYID_H + +#include "qmobilityglobal.h" +#include <QMetaType> +#include <QSharedDataPointer> + +QT_BEGIN_HEADER + +QTM_BEGIN_NAMESPACE + +class QLandmarkCategoryIdPrivate; +class Q_LOCATION_EXPORT QLandmarkCategoryId +{ +public: + QLandmarkCategoryId(); + QLandmarkCategoryId(const QLandmarkCategoryId &other); + ~QLandmarkCategoryId(); + + bool isValid() const; + QString localId() const; + void setLocalId(const QString &id); + + QString managerUri() const; + void setManagerUri(const QString &uri); + + QLandmarkCategoryId &operator=(const QLandmarkCategoryId &other); + bool operator==(const QLandmarkCategoryId &other) const; + bool operator!=(const QLandmarkCategoryId &other) const; + +private: + QSharedDataPointer<QLandmarkCategoryIdPrivate> d; +}; + +QTM_END_NAMESPACE + +QT_END_HEADER + +Q_DECLARE_METATYPE(QTM_PREPEND_NAMESPACE(QLandmarkCategoryId)) + +Q_DECLARE_TYPEINFO(QTM_PREPEND_NAMESPACE(QLandmarkCategoryId), Q_MOVABLE_TYPE); +#endif diff --git a/src/location/landmarks/qlandmarkcategoryid_p.h b/src/location/landmarks/qlandmarkcategoryid_p.h new file mode 100644 index 00000000..0542b3e3 --- /dev/null +++ b/src/location/landmarks/qlandmarkcategoryid_p.h @@ -0,0 +1,84 @@ +/**************************************************************************** +** +** Copyright (C) 2009 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 QLANDMARKCATEGORYID_P_H +#define QLANDMARKCATEGORYID_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 "qmobilityglobal.h" +#include <QSharedData> +#include <QString> + +QTM_BEGIN_NAMESPACE + +class QLandmarkCategoryIdPrivate : public QSharedData +{ +public: + QLandmarkCategoryIdPrivate() + : QSharedData() { + } + + QLandmarkCategoryIdPrivate(const QLandmarkCategoryIdPrivate &other) + : QSharedData(other), + m_localId(other.m_localId), + m_uri(other.m_uri) { + } + + ~QLandmarkCategoryIdPrivate() { + } + + QString m_localId; + QString m_uri; +}; + +QTM_END_NAMESPACE + +#endif diff --git a/src/location/landmarks/qlandmarkcategoryidfetchrequest.cpp b/src/location/landmarks/qlandmarkcategoryidfetchrequest.cpp new file mode 100644 index 00000000..ddff967a --- /dev/null +++ b/src/location/landmarks/qlandmarkcategoryidfetchrequest.cpp @@ -0,0 +1,179 @@ +/**************************************************************************** +** +** Copyright (C) 2009 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 "qlandmarkcategoryidfetchrequest.h" +#include "qlandmarkrequests_p.h" +#include "qlandmarkcategoryid.h" + +QTM_BEGIN_NAMESPACE + +/*! + \class QLandmarkCategoryIdFetchRequest + \brief The QLandmarkCategoryIdFetchRequest class allows a client to asynchronously + request a list of category identifiers from a landmark manager. + + For a QLandmarkCategoryIdFetchRequest, the resultsAvailable() signal will be emitted + as resultant category identifiers are found (these are retrievable by calling categoryIds()), + as well as if an overall operation error occurred(which may be retrieved by calling + QLandmarkAbstractRequest::error()). + + Please see the class documentation for QLandmarkAbstractRequest for more information about + the usage of request classes and ownership semantics. + + \inmodule QtLocation + \since 1.1 + + \ingroup landmarks-request +*/ + +/*! + Creates a new category identifier fetch request object with the given \a manager + aand \a parent. +*/ +QLandmarkCategoryIdFetchRequest::QLandmarkCategoryIdFetchRequest(QLandmarkManager * manager, QObject *parent) + : QLandmarkAbstractRequest(new QLandmarkCategoryIdFetchRequestPrivate(manager), parent) +{ +} + +/*! + Destroys the request object. +*/ +QLandmarkCategoryIdFetchRequest::~QLandmarkCategoryIdFetchRequest() +{ +} + +/*! + Returns the list of category identifiers that have been found during the + request. +*/ +QList<QLandmarkCategoryId> QLandmarkCategoryIdFetchRequest::categoryIds() const +{ + Q_D(const QLandmarkCategoryIdFetchRequest); + QMutexLocker ml(&d->mutex); + return d->categoryIds; +} + +/*! + Returns the sorting of the categories. + By default the sorting is case insensitive and in ascending order + according to the category name. +*/ +QLandmarkNameSort QLandmarkCategoryIdFetchRequest::sorting() const +{ + Q_D(const QLandmarkCategoryIdFetchRequest); + QMutexLocker ml(&d->mutex); + return d->sorting; +} + +/*! + Sets \a nameSort to specify the sorting of the returned category ids. +*/ +void QLandmarkCategoryIdFetchRequest::setSorting(const QLandmarkNameSort &nameSort) +{ + Q_D(QLandmarkCategoryIdFetchRequest); + QMutexLocker ml(&d->mutex); + d->sorting = nameSort; +} + +/*! + Returns the maximum number of category IDs to be returned. By default the limit is set to -1 + indicating that IDs of all categories should be retrieved. +*/ +int QLandmarkCategoryIdFetchRequest::limit() const +{ + Q_D(const QLandmarkCategoryIdFetchRequest); + QMutexLocker ml(&d->mutex); + return d->limit; +} + +/*! + Sets the maximum number of category IDs to be returned to \a limit. + + A limit of -1 indicates that IDs of all categories are to be retrieved. + + (A limit of 0 will retrieve no categories.) + */ +void QLandmarkCategoryIdFetchRequest::setLimit(int limit) +{ + Q_D(QLandmarkCategoryIdFetchRequest); + QMutexLocker ml(&d->mutex); + d->limit = limit; +} + +/*! + Returns the index offset for the request. By default the offset is set to 0. + The offset determines the first index which is retrieved. it is generally + used in conjunction with limit() to facilitate paging. + + For example, if there are 10 categories in the landmark store, setting the offset + to 2 and limit to 5 will retrieve the 3rd to 7th category ids inclusively. (The order + of category ids is specified by the sorting field). +*/ +int QLandmarkCategoryIdFetchRequest::offset() const +{ + Q_D(const QLandmarkCategoryIdFetchRequest); + QMutexLocker ml(&d->mutex); + return d->offset; +} + +/*! + Sets the index \a offset for the request. +*/ +void QLandmarkCategoryIdFetchRequest::setOffset(int offset) { + Q_D(QLandmarkCategoryIdFetchRequest); + QMutexLocker ml(&d->mutex); + d->offset = offset; +} + +#include "moc_qlandmarkcategoryidfetchrequest.cpp" + +QTM_END_NAMESPACE + + + + + + + + + + + diff --git a/src/location/landmarks/qlandmarkcategoryidfetchrequest.h b/src/location/landmarks/qlandmarkcategoryidfetchrequest.h new file mode 100644 index 00000000..b1615ae8 --- /dev/null +++ b/src/location/landmarks/qlandmarkcategoryidfetchrequest.h @@ -0,0 +1,77 @@ +/**************************************************************************** +** +** Copyright (C) 2009 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 QLANDMARKCATEGORYIDFETCHREQUEST_H +#define QLANDMARKCATEGORYIDFETCHREQUEST_H + +#include "qlandmarkabstractrequest.h" +#include "qlandmarknamesort.h" + +QTM_BEGIN_NAMESPACE + +class QLandmarkCategoryIdFetchRequestPrivate; +class Q_LOCATION_EXPORT QLandmarkCategoryIdFetchRequest : public QLandmarkAbstractRequest +{ + Q_OBJECT +public: + QLandmarkCategoryIdFetchRequest(QLandmarkManager *manager, QObject *parent = 0); + ~QLandmarkCategoryIdFetchRequest(); + + QList<QLandmarkCategoryId> categoryIds() const; + + void setSorting(const QLandmarkNameSort &nameSort); + QLandmarkNameSort sorting() const; + + int limit() const; + void setLimit(int limit); + + int offset() const; + void setOffset(int offset); + +private: + Q_DISABLE_COPY(QLandmarkCategoryIdFetchRequest) + Q_DECLARE_PRIVATE(QLandmarkCategoryIdFetchRequest) + friend class QLandmarkManagerEngine; +}; + +QTM_END_NAMESPACE + +#endif diff --git a/src/location/landmarks/qlandmarkcategoryremoverequest.cpp b/src/location/landmarks/qlandmarkcategoryremoverequest.cpp new file mode 100644 index 00000000..a310b109 --- /dev/null +++ b/src/location/landmarks/qlandmarkcategoryremoverequest.cpp @@ -0,0 +1,166 @@ +/**************************************************************************** +** +** Copyright (C) 2009 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 "qlandmarkcategoryremoverequest.h" +#include "qlandmarkrequests_p.h" +#include "qlandmarkcategoryid.h" +#include <QMap> + + +QTM_BEGIN_NAMESPACE + +/*! + \class QLandmarkCategoryRemoveRequest + \brief The QLandmarkCategoryRemoveRequest class allows a client to asynchronously + request that certain categories be removed from a landmark manager. + + For a QLandmarkCategoryRemoveRequest, the resultsAvailable() signal will be emitted + when either an individual items error out (individaul errors may be retrieved + by calling errorMap()) or an overall operation error occurs(which may be + retrieved by calling QLandmarkAbstractRequest::error()). + + Please see the class documentation for QLandmarkAbstractRequest for more information about + the usage of request classes and ownership semantics. + + \inmodule QtLocation + + \ingroup landmarks-request + \since 1.1 +*/ + +/*! + Constructs a category remove request with the given \a manager and \a parent. +*/ +QLandmarkCategoryRemoveRequest::QLandmarkCategoryRemoveRequest(QLandmarkManager *manager, QObject *parent) + : QLandmarkAbstractRequest(new QLandmarkCategoryRemoveRequestPrivate(manager), parent) +{ +} + +/*! + Destroys the request object. +*/ +QLandmarkCategoryRemoveRequest::~QLandmarkCategoryRemoveRequest() +{ +} + +/*! + Returns the list of identifiers of categories which will be removed. +*/ +QList<QLandmarkCategoryId> QLandmarkCategoryRemoveRequest::categoryIds() const +{ + Q_D(const QLandmarkCategoryRemoveRequest); + QMutexLocker ml(&d->mutex); + return d->categoryIds; +} + +/*! + Sets the list of \a categoryIds of categories which will be removed. + + \sa setCategories(), setCategoryId() +*/ +void QLandmarkCategoryRemoveRequest::setCategoryIds(const QList<QLandmarkCategoryId> &categoryIds) +{ + Q_D(QLandmarkCategoryRemoveRequest); + QMutexLocker ml(&d->mutex); + d->categoryIds = categoryIds; +} + +/*! + Convenience function to set the \a categoryId of a single category to be removed. + It is the equivalent of calling setCategoryIds() with a single \a categoryId + in the ID list. + + \sa setCategory(), setCategoryIds() +*/ +void QLandmarkCategoryRemoveRequest::setCategoryId(const QLandmarkCategoryId &categoryId) +{ + Q_D(QLandmarkCategoryRemoveRequest); + QMutexLocker ml(&d->mutex); + d->categoryIds.clear(); + d->categoryIds.append(categoryId); +} + +/*! + Convenience function to set the list of \a categories which will be removed. + This function effectively calls setCategoryIds() with the IDs of the + \a categories. + + \sa setCategory(), setCategoryIds() +*/ +void QLandmarkCategoryRemoveRequest::setCategories(const QList<QLandmarkCategory> &categories) +{ + Q_D(QLandmarkCategoryRemoveRequest); + QMutexLocker ml(&d->mutex); + d->categoryIds.clear(); + for (int i=0; i < categories.count(); ++i) + d->categoryIds.append(categories.at(i).categoryId()); +} + +/*! + Convenience function that sets a single \a category to be removed. + This function effectively calls setCategoryIds() with the ID of \a category. + + \sa setCategories(), setCategoryId() +*/ +void QLandmarkCategoryRemoveRequest::setCategory(const QLandmarkCategory &category) +{ + Q_D(QLandmarkCategoryRemoveRequest); + QMutexLocker ml(&d->mutex); + d->categoryIds.clear(); + d->categoryIds.append(category.categoryId()); +} + +/*! + Returns the mapping of input category ID list indices + to the errors which occurred. +*/ +QMap<int, QLandmarkManager::Error> QLandmarkCategoryRemoveRequest::errorMap() const +{ + Q_D(const QLandmarkCategoryRemoveRequest); + QMutexLocker ml(&d->mutex); + return d->errorMap; +} + +#include "moc_qlandmarkcategoryremoverequest.cpp" + +QTM_END_NAMESPACE + + diff --git a/src/location/landmarks/qlandmarkcategoryremoverequest.h b/src/location/landmarks/qlandmarkcategoryremoverequest.h new file mode 100644 index 00000000..ef571ee0 --- /dev/null +++ b/src/location/landmarks/qlandmarkcategoryremoverequest.h @@ -0,0 +1,74 @@ +/**************************************************************************** +** +** Copyright (C) 2009 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 QLANDMARKCATEGORYREMOVEREQUEST_H +#define QLANDMARKCATEGORYREMOVEREQUEST_H + +#include "qlandmarkabstractrequest.h" + +QTM_BEGIN_NAMESPACE + +class QLandmarkCategoryRemoveRequestPrivate; +class Q_LOCATION_EXPORT QLandmarkCategoryRemoveRequest : public QLandmarkAbstractRequest +{ + Q_OBJECT +public: + QLandmarkCategoryRemoveRequest(QLandmarkManager *manager, QObject *parent = 0); + ~QLandmarkCategoryRemoveRequest(); + + QList<QLandmarkCategoryId> categoryIds() const; + void setCategoryIds(const QList<QLandmarkCategoryId> &categoryIds); + void setCategoryId(const QLandmarkCategoryId &categoryId); + + void setCategories(const QList<QLandmarkCategory> &categories); + void setCategory(const QLandmarkCategory &category); + + QMap<int, QLandmarkManager::Error> errorMap() const; +private: + Q_DISABLE_COPY(QLandmarkCategoryRemoveRequest) + Q_DECLARE_PRIVATE(QLandmarkCategoryRemoveRequest) + friend class QLandmarkManagerEngine; +}; + +QTM_END_NAMESPACE + +#endif + diff --git a/src/location/landmarks/qlandmarkcategorysaverequest.cpp b/src/location/landmarks/qlandmarkcategorysaverequest.cpp new file mode 100644 index 00000000..3e27fb64 --- /dev/null +++ b/src/location/landmarks/qlandmarkcategorysaverequest.cpp @@ -0,0 +1,135 @@ +/**************************************************************************** +** +** Copyright (C) 2009 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 "qlandmarkcategorysaverequest.h" +#include "qlandmarkrequests_p.h" +#include "qlandmarkcategory.h" + +QTM_BEGIN_NAMESPACE + +/*! + \class QLandmarkCategorySaveRequest + \brief The QLandmarkCategorySaveRequest class allows a client to asynchronously + request that certain categories be saved by a landmark manager. + + For a QLandmarkCategorySaveRequest, the resultsAvailable() signal will be emitted + when either an individual items error out (individaul errors may be retrieved + by calling errorMap()), or an overall operation error occurs(which may be + retrieved by calling error()). + + Please see the class documentation for QLandmarkAbstractRequest for more information about + the usage of request classes and ownership semantics. + + \inmodule QtLocation + + \ingroup landmarks-request + \since 1.1 +*/ + +/*! + Constructs a category save request with the given \a manager and \a parent. +*/ +QLandmarkCategorySaveRequest::QLandmarkCategorySaveRequest(QLandmarkManager *manager, QObject *parent) + : QLandmarkAbstractRequest(new QLandmarkCategorySaveRequestPrivate(manager), parent) +{ +} + +/*! + Destroys the request object. +*/ +QLandmarkCategorySaveRequest::~QLandmarkCategorySaveRequest() +{ +} + +/*! + Returns the list of categories to be saved. If called after the save operation has + finished, any new categories saved will have had their QLandmarkCategoryId set. + (Categories which were updated or failed to save will remain unchanged, use the + errorMap() function to determine which particular categories failed to save.) +*/ +QList<QLandmarkCategory> QLandmarkCategorySaveRequest::categories() const +{ + Q_D(const QLandmarkCategorySaveRequest); + QMutexLocker ml(&d->mutex); + return d->categories; +} + +/*! + Sets the list of \a categories to be saved. + \sa setCategory() +*/ +void QLandmarkCategorySaveRequest::setCategories(const QList<QLandmarkCategory> &categories) +{ + Q_D(QLandmarkCategorySaveRequest); + QMutexLocker ml(&d->mutex); + d->categories = categories; +} + +/*! + Convenience function to set a single \a category to be saved. This function + is the equivalent of calling setCategories() with a single \a category. + + \sa setCategories() +*/ +void QLandmarkCategorySaveRequest::setCategory(const QLandmarkCategory& category) +{ + Q_D(QLandmarkCategorySaveRequest); + QMutexLocker ml(&d->mutex); + d->categories.clear(); + d->categories.append(category); +} + +/*! + Returns the mapping of the input category list indices to the + errors which occurred. +*/ +QMap<int, QLandmarkManager::Error> QLandmarkCategorySaveRequest::errorMap() const +{ + Q_D(const QLandmarkCategorySaveRequest); + QMutexLocker ml(&d->mutex); + return d->errorMap; +} + +#include "moc_qlandmarkcategorysaverequest.cpp" + +QTM_END_NAMESPACE + + diff --git a/src/location/landmarks/qlandmarkcategorysaverequest.h b/src/location/landmarks/qlandmarkcategorysaverequest.h new file mode 100644 index 00000000..8a508f9c --- /dev/null +++ b/src/location/landmarks/qlandmarkcategorysaverequest.h @@ -0,0 +1,73 @@ +/**************************************************************************** +** +** Copyright (C) 2009 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 QLANDMARKCATEGORYSAVEREQUEST_H +#define QLANDMARKCATEGORYSAVEREQUEST_H + +#include "qlandmarkabstractrequest.h" + +QTM_BEGIN_NAMESPACE + +class QLandmarkCategory; + +class QLandmarkCategorySaveRequestPrivate; +class Q_LOCATION_EXPORT QLandmarkCategorySaveRequest : public QLandmarkAbstractRequest +{ + Q_OBJECT +public: + QLandmarkCategorySaveRequest(QLandmarkManager *manager, QObject *parent = 0); + ~QLandmarkCategorySaveRequest(); + + QList<QLandmarkCategory> categories() const; + void setCategories(const QList<QLandmarkCategory> &categories); + void setCategory(const QLandmarkCategory &category); + + QMap<int, QLandmarkManager::Error> errorMap() const; +private: + Q_DISABLE_COPY(QLandmarkCategorySaveRequest) + Q_DECLARE_PRIVATE(QLandmarkCategorySaveRequest) + friend class QLandmarkManagerEngine; +}; + +QTM_END_NAMESPACE + +#endif + diff --git a/src/location/landmarks/qlandmarkexportrequest.cpp b/src/location/landmarks/qlandmarkexportrequest.cpp new file mode 100644 index 00000000..025f0a22 --- /dev/null +++ b/src/location/landmarks/qlandmarkexportrequest.cpp @@ -0,0 +1,208 @@ +/**************************************************************************** +** +** Copyright (C) 2009 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 "qlandmarkexportrequest.h" +#include "qlandmarkrequests_p.h" +#include <QIODevice> +#include <QFile> + + +QTM_BEGIN_NAMESPACE + +/*! + \class QLandmarkExportRequest + \brief The QLandmarkExportRequest class allows a client to asynchronously + request that a landmark manager export a set of landmarks. + + For a QLandmarkExportRequest, the QLandmarkAbstractRequest::stateChanged() + signal will be emitted when the request is complete. The resultsAvailable() signal + will be emitted if an overall operational error occurs. + + If no landmarks identifiers are set using setLandmarkIds() or + an empty list is passed in, then all the landmarks will be exported. + + Please see the class documentation for QLandmarkAbstractRequest for more information about + the usage of request classes and ownership semantics. + + \inmodule QtLocation + + \ingroup landmarks-request + \since 1.1 +*/ + +/*! + Constructs a landmark export request with the given \a manager and \a parent. +*/ +QLandmarkExportRequest::QLandmarkExportRequest(QLandmarkManager *manager, QObject *parent) + : QLandmarkAbstractRequest(new QLandmarkExportRequestPrivate(manager), parent) +{ +} + +/*! + Destroys the request object. +*/ +QLandmarkExportRequest::~QLandmarkExportRequest() +{ +} + +/*! + Returns the device to which landmarks are written. +*/ +QIODevice *QLandmarkExportRequest::device() const +{ + Q_D(const QLandmarkExportRequest); + QMutexLocker ml(&d->mutex); + return d->device; +} + +/*! + Sets the \a device to which landmarks are written. +*/ +void QLandmarkExportRequest::setDevice(QIODevice *device) +{ + Q_D(QLandmarkExportRequest); + QMutexLocker ml(&d->mutex); + d->device = device; +} + +/*! + If the currently assigned device is a QFile, or if setFileName() has + been called, this function returns the name of the file to be + written to. In all other cases, it returns an empty string. + + \sa setFileName(), setDevice() +*/ +QString QLandmarkExportRequest::fileName() const +{ + Q_D(const QLandmarkExportRequest); + QMutexLocker ml(&d->mutex); + QFile *file = qobject_cast<QFile *>(d->device); + return file ? file->fileName() : QString(); +} + +/*! + Sets the name of the file to be written to \a fileName. Internally, + QLandmarkExportRequest will create a QFile use this as the + device to export to. + + \sa fileName(), setDevice() +*/ +void QLandmarkExportRequest::setFileName(const QString &fileName) +{ + Q_D(QLandmarkExportRequest); + QMutexLocker ml(&d->mutex); + d->device = new QFile(fileName); +} + +/*! + Returns the data format for the export operation. +*/ +QString QLandmarkExportRequest::format() const +{ + Q_D(const QLandmarkExportRequest); + QMutexLocker ml(&d->mutex); + return d->format; +} + +/*! + Sets the data \a format for the export operation. +*/ +void QLandmarkExportRequest::setFormat(const QString &format) +{ + Q_D(QLandmarkExportRequest); + QMutexLocker ml(&d->mutex); + d->format = format; +} + +/*! + Returns the transfer option of the export request. + The transfer option defines how categories are treated + during the export operation. The default option is + QLandmarkManager::IncludeCategoryData. + +*/ +QLandmarkManager::TransferOption QLandmarkExportRequest::transferOption() const +{ + Q_D(const QLandmarkExportRequest); + QMutexLocker ml(&d->mutex); + return d->option; +} + +/*! + Sets the transfer \a option of the export request. + The transfer \a option defines how categories are treated + during the export operation. +*/ +void QLandmarkExportRequest::setTransferOption(QLandmarkManager::TransferOption option) +{ + Q_D(QLandmarkExportRequest); + QMutexLocker ml(&d->mutex); + d->option = option; +} + +/*! + Returns the list of identifiers of landmarks that will be exported. + By default the list of identifiers is empty, indicating that all + landmarks should be exported. +*/ +QList<QLandmarkId> QLandmarkExportRequest::landmarkIds() const +{ + Q_D(const QLandmarkExportRequest); + QMutexLocker ml(&d->mutex); + return d->landmarkIds; +} + +/*! + Sets the landmarks to be exported by specifying a list of + \a landmarkIds. +*/ +void QLandmarkExportRequest::setLandmarkIds(const QList<QLandmarkId> &landmarkIds) +{ + Q_D(QLandmarkExportRequest); + QMutexLocker ml(&d->mutex); + d->landmarkIds = landmarkIds; +} + +#include "moc_qlandmarkexportrequest.cpp" + +QTM_END_NAMESPACE + + diff --git a/src/location/landmarks/qlandmarkexportrequest.h b/src/location/landmarks/qlandmarkexportrequest.h new file mode 100644 index 00000000..cfaa544d --- /dev/null +++ b/src/location/landmarks/qlandmarkexportrequest.h @@ -0,0 +1,80 @@ +/**************************************************************************** +** +** Copyright (C) 2009 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 QLANDMARKEXPORTREQUEST_H +#define QLANDMARKEXPORTREQUEST_H + +#include "qlandmarkabstractrequest.h" +class QIODevice; +QTM_BEGIN_NAMESPACE + +class QLandmarkExportRequestPrivate; +class Q_LOCATION_EXPORT QLandmarkExportRequest : public QLandmarkAbstractRequest +{ + Q_OBJECT +public: + QLandmarkExportRequest(QLandmarkManager *manager, QObject *parent = 0); + ~QLandmarkExportRequest(); + + QIODevice *device() const; + void setDevice(QIODevice *device); + + QString fileName() const; + void setFileName(const QString &fileName); + + QString format() const; + void setFormat(const QString &format); + + QLandmarkManager::TransferOption transferOption() const; + void setTransferOption(QLandmarkManager::TransferOption option); + + QList<QLandmarkId> landmarkIds() const; + void setLandmarkIds(const QList<QLandmarkId> &landmarkIds); +private: + Q_DISABLE_COPY(QLandmarkExportRequest) + Q_DECLARE_PRIVATE(QLandmarkExportRequest) + friend class QLandmarkManagerEngine; +}; + +QTM_END_NAMESPACE + +#endif + diff --git a/src/location/landmarks/qlandmarkfetchbyidrequest.cpp b/src/location/landmarks/qlandmarkfetchbyidrequest.cpp new file mode 100644 index 00000000..5a6c88dc --- /dev/null +++ b/src/location/landmarks/qlandmarkfetchbyidrequest.cpp @@ -0,0 +1,140 @@ +/**************************************************************************** +** +** Copyright (C) 2009 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 "qlandmarkfetchbyidrequest.h" +#include "qlandmarkrequests_p.h" +#include "qlandmark.h" + +QTM_BEGIN_NAMESPACE + +/*! + \class QLandmarkFetchByIdRequest + \brief The QLandmarkFetchByIdRequest class allows a client to asynchronously + request a list of landmarks by id from a landmark manager. + + For a QLandmarkFetchByIdRequest, the resultsAvailable() signal will be emitted when the resultant + landmarks (which may be retrieved by calling landmarks()) are updated, + whenever indiviual items error out(individual errors may be retrieved by + calling errorMap()), or when an overall operation error occurs(which may be + retrieved by calling error()). + + Please see the class documentation for QLandmarkAbstractRequest for more information about + the usage of request classes and ownership semantics. + + \inmodule QtLocation + + \ingroup landmarks-request + \since 1.1 +*/ + +/*! + Creates a new request object with the given \a manager \a parent. +*/ +QLandmarkFetchByIdRequest::QLandmarkFetchByIdRequest(QLandmarkManager *manager, QObject *parent) + : QLandmarkAbstractRequest(new QLandmarkFetchByIdRequestPrivate(manager), parent) +{ +} + +/*! + Destroys the request object. +*/ +QLandmarkFetchByIdRequest::~QLandmarkFetchByIdRequest() +{ +} + +/*! + Returns a list of identifiers of landmarks which are to be retrieved by this request. +*/ +QList<QLandmarkId> QLandmarkFetchByIdRequest::landmarkIds() const +{ + Q_D(const QLandmarkFetchByIdRequest); + QMutexLocker ml(&d->mutex); + return d->landmarkIds; +} + +/*! + Sets the \a landmarkIds to be retrieved by this request. +*/ +void QLandmarkFetchByIdRequest::setLandmarkIds(const QList<QLandmarkId> &landmarkIds) +{ + Q_D(QLandmarkFetchByIdRequest); + QMutexLocker ml(&d->mutex); + d->landmarkIds = landmarkIds; +} + +/*! + Convenience function that sets a single landmark, specified by \a landmarkId, + to be retrieved by this request. + +*/ +void QLandmarkFetchByIdRequest::setLandmarkId(const QLandmarkId &landmarkId) +{ + Q_D(QLandmarkFetchByIdRequest); + QMutexLocker ml(&d->mutex); + d->landmarkIds.clear(); + d->landmarkIds.append(landmarkId); +} + +/*! + Returns the list of landmarks fetched by this request. + +*/ +QList<QLandmark> QLandmarkFetchByIdRequest::landmarks() const +{ + Q_D(const QLandmarkFetchByIdRequest); + QMutexLocker ml(&d->mutex); + return d->landmarks; +} + +/*! + Returns the mapping of input landmark ID list indices + to the errors which occurred. +*/ +QMap<int, QLandmarkManager::Error> QLandmarkFetchByIdRequest::errorMap() const +{ + Q_D(const QLandmarkFetchByIdRequest); + QMutexLocker ml(&d->mutex); + return d->errorMap; +} + +#include "moc_qlandmarkfetchbyidrequest.cpp" + +QTM_END_NAMESPACE diff --git a/src/location/landmarks/qlandmarkfetchbyidrequest.h b/src/location/landmarks/qlandmarkfetchbyidrequest.h new file mode 100644 index 00000000..ec745aab --- /dev/null +++ b/src/location/landmarks/qlandmarkfetchbyidrequest.h @@ -0,0 +1,71 @@ +/**************************************************************************** +** +** Copyright (C) 2009 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 QLANDMARKFETCHBYIDREQUEST_H +#define QLANDMARKFETCHBYIDREQUEST_H + +#include "qlandmarkabstractrequest.h" + +QTM_BEGIN_NAMESPACE + +class QLandmarkFetchByIdRequestPrivate; +class Q_LOCATION_EXPORT QLandmarkFetchByIdRequest : public QLandmarkAbstractRequest +{ + Q_OBJECT +public: + QLandmarkFetchByIdRequest(QLandmarkManager *manager, QObject *parent = 0); + ~QLandmarkFetchByIdRequest(); + + QList<QLandmarkId> landmarkIds() const; + void setLandmarkIds(const QList<QLandmarkId> &ids); + void setLandmarkId(const QLandmarkId &id); + + QList<QLandmark> landmarks() const; + QMap<int, QLandmarkManager::Error> errorMap() const; +private: + Q_DISABLE_COPY(QLandmarkFetchByIdRequest) + Q_DECLARE_PRIVATE(QLandmarkFetchByIdRequest) + friend class QLandmarkManagerEngine; +}; + +QTM_END_NAMESPACE + +#endif diff --git a/src/location/landmarks/qlandmarkfetchrequest.cpp b/src/location/landmarks/qlandmarkfetchrequest.cpp new file mode 100644 index 00000000..3e8c7d5a --- /dev/null +++ b/src/location/landmarks/qlandmarkfetchrequest.cpp @@ -0,0 +1,206 @@ +/**************************************************************************** +** +** Copyright (C) 2009 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 "qlandmarkfetchrequest.h" +#include "qlandmarkrequests_p.h" +#include "qlandmarkfilter.h" +#include "qlandmarkidfilter.h" +#include "qlandmarksortorder.h" +#include "qlandmark.h" + +QTM_BEGIN_NAMESPACE + +/*! + \class QLandmarkFetchRequest + \brief The QLandmarkFetchRequest class allows a client to asynchronously + request a list of landmarks from a landmark manager. + + For a QLandmarkFetchRequest, the resultsAvailable() signal will be emitted when the resultant + landmarks (which may be retrieved by calling landmarks()) are updated, as well as if + the overall operation error (which may be retrieved by calling error()) is updated. + + Please see the class documentation for QLandmarkAbstractRequest for more information about + the usage of request classes and ownership semantics. + + \inmodule QtLocation + + \ingroup landmarks-request + \since 1.1 +*/ + +/*! + Creates a new landmark fetch request object with the given \a manager \a parent. +*/ +QLandmarkFetchRequest::QLandmarkFetchRequest(QLandmarkManager *manager, QObject *parent) + : QLandmarkAbstractRequest(new QLandmarkFetchRequestPrivate(manager), parent) +{ +} + +/*! + Destroys the request object. +*/ +QLandmarkFetchRequest::~QLandmarkFetchRequest() +{ +} + +/*! + Returns the filter which will be used to select the landmarks. + + By default, the filter's type will be a QLandmarkFilter::DefaultFilter + and thus match all landmarks. +*/ +QLandmarkFilter QLandmarkFetchRequest::filter() const +{ + Q_D(const QLandmarkFetchRequest); + QMutexLocker ml(&d->mutex); + return d->filter; +} + +/*! + Sets the \a filter which will be used to select landmarks. +*/ +void QLandmarkFetchRequest::setFilter(const QLandmarkFilter &filter) +{ + Q_D(QLandmarkFetchRequest); + QMutexLocker ml(&d->mutex); + d->filter = filter; +} + +/*! + Returns the sort ordering which is used to sort the result. By default + the sort order list is empty, thus no sorting will take place. +*/ +QList<QLandmarkSortOrder> QLandmarkFetchRequest::sorting() const +{ + Q_D(const QLandmarkFetchRequest); + QMutexLocker ml(&d->mutex); + return d->sorting; +} + +/*! + Sets the sort ordering of the request to \a sorting. This + function will only have an effect on the results if invoked + prior to calling \l QLandmarkAbstractRequest::start(). +*/ +void QLandmarkFetchRequest::setSorting(const QList<QLandmarkSortOrder> &sorting) +{ + Q_D(QLandmarkFetchRequest); + QMutexLocker ml(&d->mutex); + d->sorting = sorting; +} + +/*! + Convenience function which sets the sort ordering of the request to a single \a sorting. This function + will only have an effect on results if invoked prior to calling + \l QLandmarkAbstractRequest::start(). +*/ +void QLandmarkFetchRequest::setSorting(const QLandmarkSortOrder &sorting) +{ + Q_D(QLandmarkFetchRequest); + QMutexLocker ml(&d->mutex); + d->sorting.clear(); + d->sorting.append(sorting); +} + +/*! + Returns the maximum number of landmarks to be returned. By default the limit + is -1 indicating that all landmarks matching the filter sould be retrieved. +*/ +int QLandmarkFetchRequest::limit() const +{ + Q_D(const QLandmarkFetchRequest); + QMutexLocker ml(&d->mutex); + return d->limit; +} + +/*! + Sets the maximum number of landmarks to be returned to \a limit. + + A limit of -1 will retrieve all landmarks that match the filter. + + (A limit of 0 will retrieve no landmarks.) + */ +void QLandmarkFetchRequest::setLimit(int limit) +{ + Q_D(QLandmarkFetchRequest); + QMutexLocker ml(&d->mutex); + d->limit = limit; +} + +/*! + Returns the index offset for the request. By default the offset is set to 0. + The offset determines the first index which is retrieved, it is generally + used in conjunction with limit() to facilitate paging. + + For example, if there are 10 landmarks in the landmark store, setting the offset + to 2 and limit to 5 will retrieve the 3rd to 7th landmarks inclusively. (The order + of the landmarks is specified by the sorting field). +*/ +int QLandmarkFetchRequest::offset() const +{ + Q_D(const QLandmarkFetchRequest); + QMutexLocker ml(&d->mutex); + return d->offset; +} + +/*! + Sets the index \a offset for the request. +*/ +void QLandmarkFetchRequest::setOffset(int offset) { + Q_D(QLandmarkFetchRequest); + QMutexLocker ml(&d->mutex); + d->offset = offset; +} + +/*! + Returns the list of landmarks which matched the + filter. +*/ +QList<QLandmark> QLandmarkFetchRequest::landmarks() const +{ + Q_D(const QLandmarkFetchRequest); + QMutexLocker ml(&d->mutex); + return d->landmarks; +} + +#include "moc_qlandmarkfetchrequest.cpp" + +QTM_END_NAMESPACE diff --git a/src/location/landmarks/qlandmarkfetchrequest.h b/src/location/landmarks/qlandmarkfetchrequest.h new file mode 100644 index 00000000..5a996217 --- /dev/null +++ b/src/location/landmarks/qlandmarkfetchrequest.h @@ -0,0 +1,79 @@ +/**************************************************************************** +** +** Copyright (C) 2009 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 QLANDMARKFETCHREQUEST_H +#define QLANDMARKFETCHREQUEST_H + +#include "qlandmarkabstractrequest.h" + +QTM_BEGIN_NAMESPACE + +class QLandmarkFetchRequestPrivate; +class Q_LOCATION_EXPORT QLandmarkFetchRequest : public QLandmarkAbstractRequest +{ + Q_OBJECT +public: + QLandmarkFetchRequest(QLandmarkManager *manager, QObject *parent = 0); + ~QLandmarkFetchRequest(); + + QLandmarkFilter filter() const; + void setFilter(const QLandmarkFilter &filter); + + QList<QLandmarkSortOrder> sorting() const; + void setSorting(const QList<QLandmarkSortOrder> &sorting); + void setSorting(const QLandmarkSortOrder &sorting); + + int limit() const; + void setLimit(int limit); + + int offset() const; + void setOffset(int offset); + + QList<QLandmark> landmarks() const; +private: + Q_DISABLE_COPY(QLandmarkFetchRequest) + Q_DECLARE_PRIVATE(QLandmarkFetchRequest) + friend class QLandmarkManagerEngine; +}; + +QTM_END_NAMESPACE + +#endif diff --git a/src/location/landmarks/qlandmarkfilter.cpp b/src/location/landmarks/qlandmarkfilter.cpp new file mode 100644 index 00000000..9e5566a0 --- /dev/null +++ b/src/location/landmarks/qlandmarkfilter.cpp @@ -0,0 +1,227 @@ +/**************************************************************************** +** +** Copyright (C) 2009 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 "qlandmarkfilter.h" +#include "qlandmarkfilter_p.h" + +#include "qlandmarkintersectionfilter.h" +#include "qlandmarkunionfilter.h" + +#include "qlandmarkcategoryid.h" +#include "qlandmarkid.h" +#include "qgeocoordinate.h" + +#if !defined(Q_CC_MWERKS) +template<> QTM_PREPEND_NAMESPACE(QLandmarkFilterPrivate) *QSharedDataPointer<QTM_PREPEND_NAMESPACE(QLandmarkFilterPrivate)>::clone() +{ + return d->clone(); +} +#endif + +QTM_BEGIN_NAMESPACE + +QLandmarkFilterPrivate::QLandmarkFilterPrivate() + : QSharedData(), + type(QLandmarkFilter::DefaultFilter) +{ +} + +QLandmarkFilterPrivate::QLandmarkFilterPrivate(const QLandmarkFilterPrivate &other) + : QSharedData(), + type(other.type) +{ +} + +QLandmarkFilterPrivate::~QLandmarkFilterPrivate() +{ +} + +/*! + \class QLandmarkFilter + \brief The QLandmarkFilter class serves as the base class for all filter classes. + Also serves as the default filter which retrieves all landmarks. + + \inmodule QtLocation + + \ingroup landmarks-filter + \since 1.1 + + This class is used as a parameter to search for landmarks, it allows selection of + landmarks which meet certain criteria. It is used with QLandmarkManager + for synchronous searches or the appropriate request classes for asynchronous + searches. + + The QLandmarkFilter is primarily intended to serve as the base class + for all filter types. However it also has the type of a QLandmark::DefaultFilter, + and may thus be used as a filter to match all landmarks. + +*/ + +/*! + \enum QLandmarkFilter::FilterType + Describes the type of the filter + \value InvalidFilter An invalid filter which matches nothing + \value DefaultFilter A filter which matches all landmarks. + \value IntersectionFilter A filter which performs an AND operation with its + constituent filters + \value UnionFilter A filter which performs an OR operation with its constiuent filters. + \value NameFilter A filter which matches landmarks based on name + \value ProximityFilter A filter which matches landmarks within a certain range of a given + coordinate. + \value CategoryFilter A filter which matches landmarks that belong to a given category + \value BoxFilter A filter which matches landmarks within a given bounding box. + \value AttributeFilter A filter which matches landmarks based on generic attributes. + \value LandmarkIdFilter A filter which matches landmarks based on a list of landmark ids. +*/ + +/*! + \enum QLandmarkFilter::MatchFlag + Describes the semantics of matching followed by the filter. + \value MatchExactly Performs QVariant-based matching. (For the Symbian and S60 platforms MatchExactly has the same semantics as MatchFixedString) + \value MatchContains The search term is contained in the item. (For the Symbian and S60 platforms, MatchContains is not supported) + \value MatchStartsWith The search term matches the start of the item. + \value MatchEndsWith The search term matches the end of the item. + \value MatchFixedString Performs string-based matching. String-based comparisons are case-insensitive unless the MatchCaseSensitive flag is also specified. + \value MatchCaseSensitive The search is case sensitive. +*/ + +/*! + Constructs an default landmark filter. +*/ +QLandmarkFilter::QLandmarkFilter() + : d_ptr(new QLandmarkFilterPrivate) +{ +} +/*! + \internal +*/ +QLandmarkFilter::QLandmarkFilter(QLandmarkFilterPrivate *dd) + : d_ptr(dd) +{ +} + +/*! + Constructs a copy of \a other. +*/ +QLandmarkFilter::QLandmarkFilter(const QLandmarkFilter &other) + : d_ptr(other.d_ptr) +{ +} + +/*! + Assigns \a other to this filter and returns a reference to this filter. +*/ +QLandmarkFilter &QLandmarkFilter::operator=(const QLandmarkFilter & other) +{ + if (this != &other) + d_ptr = (other.d_ptr); + return *this; +} + + +/*! + Destroys the filter. +*/ +QLandmarkFilter::~QLandmarkFilter() +{ +} + +/*! + Returns the type of the filter. +*/ +QLandmarkFilter::FilterType QLandmarkFilter::type() const +{ + return d_ptr->type; +} + +/*! + \fn QLandmarkFilter::operator!=(const QLandmarkFilter &other) const + Returns true if this filter is not identical to \a other. + + \sa operator==() +*/ + +/*! + Returns true if the filter has the same type and criteria as \a other. + \sa operator!=() +*/ +bool QLandmarkFilter::operator==(const QLandmarkFilter& other) const +{ + /* Different types can't be equal */ + if (other.type() != type()) + return false; + + /* Otherwise, use the virtual op == */ + return d_ptr->compare(other.d_ptr); +} + +/*! + \relates QLandmarkFilter + Returns a filter which is the intersection of the \a left and \a right filters + \sa QLandmarkIntersectionFilter + */ +const QLandmarkFilter operator&(const QLandmarkFilter &left, const QLandmarkFilter &right) +{ + /* TODO implement better handling when left or right is an intersection filter */ + + /* usual fallback case */ + + QLandmarkIntersectionFilter nif; + nif << left << right; + return nif; +} + +/*! + \relates QLandmarkFilter + Returns a filter which is the union of the \a left and \a right filters + \sa QLandmarkUnionFilter + */ +const QLandmarkFilter operator|(const QLandmarkFilter &left, const QLandmarkFilter &right) +{ + /* TODO implement better handling when left or right is a union filter */ + /* usual fallback case */ + + QLandmarkUnionFilter nuf; + nuf << left << right; + return nuf; +} + +QTM_END_NAMESPACE diff --git a/src/location/landmarks/qlandmarkfilter.h b/src/location/landmarks/qlandmarkfilter.h new file mode 100644 index 00000000..29059569 --- /dev/null +++ b/src/location/landmarks/qlandmarkfilter.h @@ -0,0 +1,108 @@ +/**************************************************************************** +** +** Copyright (C) 2009 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 QLANDMARKFILTER_H +#define QLANDMARKFILTER_H + +#include "qmobilityglobal.h" +#include <QSharedData> +#include <Qt> + +QTM_BEGIN_NAMESPACE + +#define Q_DECLARE_LANDMARKFILTER_PRIVATE(Class) \ + inline Class##Private* d_func(); \ + inline const Class##Private* d_func() const; \ + friend class Class##Private; + +class QLandmarkFilterPrivate; +class Q_LOCATION_EXPORT QLandmarkFilter +{ + +friend class QLandmarkFilterPrivate; + +public: + enum FilterType {InvalidFilter, DefaultFilter, + NameFilter, ProximityFilter, + CategoryFilter, BoxFilter, IntersectionFilter, + UnionFilter, AttributeFilter, + LandmarkIdFilter + }; + + enum MatchFlag { + MatchExactly = Qt::MatchExactly, //0 + MatchContains = Qt::MatchContains, //1 + MatchStartsWith = Qt::MatchStartsWith, //2 + MatchEndsWith = Qt::MatchEndsWith, //3 + MatchFixedString = Qt::MatchFixedString, //8 + MatchCaseSensitive = Qt::MatchCaseSensitive //16 + }; + + Q_DECLARE_FLAGS(MatchFlags, MatchFlag) + + QLandmarkFilter(); + QLandmarkFilter(const QLandmarkFilter &other); + QLandmarkFilter &operator=(const QLandmarkFilter &other); + virtual ~QLandmarkFilter(); + + FilterType type() const; + + bool operator==(const QLandmarkFilter &other) const; + bool operator!=(const QLandmarkFilter &other) const { + return !(*this == other); + } + +protected: + QLandmarkFilter(QLandmarkFilterPrivate *dd); + QSharedDataPointer<QLandmarkFilterPrivate> d_ptr; +}; + +Q_DECLARE_OPERATORS_FOR_FLAGS(QLandmarkFilter::MatchFlags); + +const Q_LOCATION_EXPORT QLandmarkFilter operator&(const QLandmarkFilter &left, const QLandmarkFilter &right); +const Q_LOCATION_EXPORT QLandmarkFilter operator|(const QLandmarkFilter &left, const QLandmarkFilter &right); + +QTM_END_NAMESPACE + +Q_DECLARE_TYPEINFO(QTM_PREPEND_NAMESPACE(QLandmarkFilter), Q_MOVABLE_TYPE); + + +#endif diff --git a/src/location/landmarks/qlandmarkfilter_p.h b/src/location/landmarks/qlandmarkfilter_p.h new file mode 100644 index 00000000..a1780c1b --- /dev/null +++ b/src/location/landmarks/qlandmarkfilter_p.h @@ -0,0 +1,110 @@ +/**************************************************************************** +** +** Copyright (C) 2009 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 QLANDMARKFILTER_P_H +#define QLANDMARKFILTER_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 "qlandmarkfilter.h" +#include <QSharedData> + +#define Q_IMPLEMENT_LANDMARKFILTER_PRIVATE(Class) \ + Class##Private* Class::d_func() { return reinterpret_cast<Class##Private *>(d_ptr.data()); } \ + const Class##Private* Class::d_func() const { return reinterpret_cast<const Class##Private *>(d_ptr.constData()); } \ + Class::Class(const QLandmarkFilter& other) : QLandmarkFilter() { Class##Private::copyIfPossible(d_ptr, other); } + +#define Q_IMPLEMENT_LANDMARKFILTER_VIRTUALCTORS(Class, Type) \ + virtual QLandmarkFilterPrivate* clone() const { return new Class##Private(*this); } \ + static void copyIfPossible(QSharedDataPointer<QLandmarkFilterPrivate>& d_ptr, const QLandmarkFilter& other) \ + { \ + if (other.type() == Type) \ + d_ptr = extract_d(other); \ + else \ + d_ptr = new Class##Private(); \ + } + +QTM_BEGIN_NAMESPACE +class QLandmarkFilterPrivate : public QSharedData +{ +public: + QLandmarkFilterPrivate(); + QLandmarkFilterPrivate(const QLandmarkFilterPrivate &other); + virtual ~QLandmarkFilterPrivate(); + + virtual bool compare(const QLandmarkFilterPrivate* other) const { + return type == other->type; + } + + /* Helper functions for C++ protection rules */ + static const QSharedDataPointer<QLandmarkFilterPrivate>& extract_d(const QLandmarkFilter& other) {return other.d_ptr;} + + Q_IMPLEMENT_LANDMARKFILTER_VIRTUALCTORS(QLandmarkFilter, QLandmarkFilter::DefaultFilter) + + QLandmarkFilter::FilterType type; +}; + +QTM_END_NAMESPACE + +QT_BEGIN_NAMESPACE +#if defined(Q_CC_MWERKS) +// This results in multiple symbol definition errors on all other compilers +// but not having a definition here results in an attempt to use the unspecialized +// clone (which fails because of the pure virtuals above) +template<> QTM_PREPEND_NAMESPACE(QLandmarkFilterPrivate) *QSharedDataPointer<QTM_PREPEND_NAMESPACE(QLandmarkFilterPrivate)>::clone() +{ + return d->clone(); +} +#else +template<> QTM_PREPEND_NAMESPACE(QLandmarkFilterPrivate) *QSharedDataPointer<QTM_PREPEND_NAMESPACE(QLandmarkFilterPrivate)>::clone(); +#endif +QT_END_NAMESPACE + +#endif diff --git a/src/location/landmarks/qlandmarkid.cpp b/src/location/landmarks/qlandmarkid.cpp new file mode 100644 index 00000000..f857a3b4 --- /dev/null +++ b/src/location/landmarks/qlandmarkid.cpp @@ -0,0 +1,174 @@ +/**************************************************************************** +** +** Copyright (C) 2009 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 "qlandmarkid.h" +#include "qlandmarkid_p.h" +#include <QString> + +QTM_USE_NAMESPACE + +/*! + \class QLandmarkId + + \inmodule QtLocation + + \ingroup landmarks-main + \since 1.1 + + \brief The QLandmarkId class provides a unique identifier for + a landmark. + + It consists of a manager URI which identifies the manager which contains + the landmark, and a manager specific local id for that landmark. +*/ + +/*! + + Creates an invalid identifier. + + The local id and manager uri are empty strings. +*/ +QLandmarkId::QLandmarkId() + : d(new QLandmarkIdPrivate) +{ +} + +/*! + Constructs a copy of \a other. +*/ +QLandmarkId::QLandmarkId(const QLandmarkId &other) + : d(other.d) +{ +} + +/*! + Destroys the identifier. +*/ +QLandmarkId::~QLandmarkId() +{ +} + +/*! + Returns true if the identifier is valid, meaning that both + a manager URI and local id have been set. +*/ +bool QLandmarkId::isValid() const +{ + return (!d->m_uri.isEmpty() && !d->m_localId.isEmpty()); +} + +/*! + Returns the local id of the landmark identifier. + + This id is specific to a particular landmark manager. +*/ +QString QLandmarkId::localId() const +{ + return d->m_localId; +} + +/*! + Sets the local \a id of the landmark identifier. +*/ +void QLandmarkId::setLocalId(const QString &id) +{ + d->m_localId = id; +} + +/*! + Returns the URI of the manager which this landmark identifer + belongs to. +*/ +QString QLandmarkId::managerUri() const +{ + return d->m_uri; +} + +/*! + Sets the manager \a uri which this landmark identifier + belongs to. +*/ +void QLandmarkId::setManagerUri(const QString &uri) +{ + d->m_uri = uri; +} + +/*! + Assigns \a other to this landmark identifier and returns a reference + to this landmark identifier. +*/ +QLandmarkId &QLandmarkId::operator=(const QLandmarkId & other) +{ + if (this != &other) + d = other.d; + return *this; +} + +/*! + Returns true if this landmark identifer is equal to \a other, otherwise + returns false. + + Two QLandmarkIds are considered equal if both have the same + manager URI and local id. + + \sa operator!=() +*/ +bool QLandmarkId::operator==(const QLandmarkId &other) const +{ + return ((d->m_localId == other.d->m_localId) + && (d->m_uri == other.d->m_uri)); +} + +/*! + Returns true if this landmark identifier is not equal to \a other, + otherwise returns false. + + If either the manager URIs or local ids differ, then the + QLandmarkIds are not considered equal. + + \sa operator==() +*/ +bool QLandmarkId::operator!=(const QLandmarkId &other) const +{ + return !this->operator ==(other); +} + + diff --git a/src/location/landmarks/qlandmarkid.h b/src/location/landmarks/qlandmarkid.h new file mode 100644 index 00000000..248bec23 --- /dev/null +++ b/src/location/landmarks/qlandmarkid.h @@ -0,0 +1,83 @@ +/**************************************************************************** +** +** Copyright (C) 2009 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 QLANDMARKID_H +#define QLANDMARKID_H + +#include "qmobilityglobal.h" +#include <QMetaType> +#include <QSharedDataPointer> + +QT_BEGIN_HEADER + +QTM_BEGIN_NAMESPACE + +class QLandmarkIdPrivate; +class Q_LOCATION_EXPORT QLandmarkId +{ +public: + QLandmarkId(); + QLandmarkId(const QLandmarkId &other); + ~QLandmarkId(); + + bool isValid() const; + void setLocalId(const QString &id); + QString localId() const; + + QString managerUri() const; + void setManagerUri(const QString &managerUri); + + QLandmarkId &operator=(const QLandmarkId &other); + bool operator==(const QLandmarkId &other) const; + bool operator!=(const QLandmarkId &other) const; +private: + QSharedDataPointer<QLandmarkIdPrivate> d; +}; + +QTM_END_NAMESPACE + +QT_END_HEADER + +Q_DECLARE_METATYPE(QTM_PREPEND_NAMESPACE(QLandmarkId)) + +Q_DECLARE_TYPEINFO(QTM_PREPEND_NAMESPACE(QLandmarkId), Q_MOVABLE_TYPE); + +#endif diff --git a/src/location/landmarks/qlandmarkid_p.h b/src/location/landmarks/qlandmarkid_p.h new file mode 100644 index 00000000..de4345b7 --- /dev/null +++ b/src/location/landmarks/qlandmarkid_p.h @@ -0,0 +1,86 @@ +/**************************************************************************** +** +** Copyright (C) 2009 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 QLANDMARKID_P_H +#define QLANDMARKID_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 "qmobilityglobal.h" +#include <QSharedData> +#include <QString> +QTM_BEGIN_NAMESPACE + +class QLandmarkIdPrivate : public QSharedData +{ +public: + QLandmarkIdPrivate() + : QSharedData(), + m_localId(QString()), + m_uri(QString()){ + } + + QLandmarkIdPrivate(const QLandmarkIdPrivate &other) + : QSharedData(other), + m_localId(other.m_localId), + m_uri(other.m_uri) { + } + + ~QLandmarkIdPrivate() { + } + + QString m_localId; + QString m_uri; +}; + + +QTM_END_NAMESPACE + +#endif diff --git a/src/location/landmarks/qlandmarkidfetchrequest.cpp b/src/location/landmarks/qlandmarkidfetchrequest.cpp new file mode 100644 index 00000000..5353d403 --- /dev/null +++ b/src/location/landmarks/qlandmarkidfetchrequest.cpp @@ -0,0 +1,218 @@ +/**************************************************************************** +** +** Copyright (C) 2009 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 "qlandmarkidfetchrequest.h" +#include "qlandmarkfilter.h" +#include "qlandmarksortorder.h" +#include "qlandmarkrequests_p.h" + + +QTM_BEGIN_NAMESPACE + +/*! + \class QLandmarkIdFetchRequest + \brief The QLandmarkIdFetchRequest class allows a client to asynchronously + request a list of landmark identifiers from a landmark manager. + + For a QLandmarkIdFetchRequest, the resultsAvailable() signal will be emitted when the resultant + identifiers (which may be retrieved by calling landmarkIds()), are updated, as well as if + the overall operation error (which may be retrieved by calling error()) is updated. + + Please see the class documentation for QLandmarkAbstractRequest for more information about + the usage of request classes and ownership semantics. + + \inmodule QtLocation + \since 1.1 + + \ingroup landmarks-request +*/ + +/*! + Creates a new landmark id fetch request object with the given \a manager and \a parent. +*/ +QLandmarkIdFetchRequest::QLandmarkIdFetchRequest(QLandmarkManager *manager, QObject *parent) + : QLandmarkAbstractRequest(new QLandmarkIdFetchRequestPrivate(manager), parent) +{ +} + +/*! + Destroys the request object. +*/ +QLandmarkIdFetchRequest::~QLandmarkIdFetchRequest() +{ +} + +/*! + Returns the filter which will be used to select the landmarks whose identifiers + will be returned. + + By default, the filter's type will be a QLandmarkFilter::DefaultFilter + and thus match all landmarks. +*/ +QLandmarkFilter QLandmarkIdFetchRequest::filter() const +{ + Q_D(const QLandmarkIdFetchRequest); + QMutexLocker ml(&d->mutex); + return d->filter; +} + +/*! + Sets the \a filter which will be used to select landmark identifiers. + +*/ +void QLandmarkIdFetchRequest::setFilter(const QLandmarkFilter &filter) +{ + Q_D(QLandmarkIdFetchRequest); + QMutexLocker ml(&d->mutex); + d->filter = filter; +} + +/*! + Returns the sort ordering which is used to sort the result. By default the + sort order list is empty, thus no sorting will take place. +*/ +QList<QLandmarkSortOrder> QLandmarkIdFetchRequest::sorting() const +{ + Q_D(const QLandmarkIdFetchRequest); + QMutexLocker ml(&d->mutex); + return d->sorting; +} + +/*! + Sets the sort ordering of the request to \a sorting. This + function will only have an effect on the results if invoked + prior to calling QLandmarkAbstractRequest::start(). +*/ +void QLandmarkIdFetchRequest::setSorting(const QList<QLandmarkSortOrder> &sorting) +{ + Q_D(QLandmarkIdFetchRequest); + QMutexLocker ml(&d->mutex); + d->sorting = sorting; +} + +/*! + Convenience function to set the sort ordering of the request to a single \a sorting. This + function will only have an effect on the results if invoked + prior to calling QLandmarkAbstractRequest::start(). +*/ +void QLandmarkIdFetchRequest::setSorting(const QLandmarkSortOrder &sorting) +{ + Q_D(QLandmarkIdFetchRequest); + QMutexLocker ml(&d->mutex); + d->sorting.clear(); + d->sorting.append(sorting); +} + +/*! + Returns the maximum number of landmark IDs to be returned. By default + the limit is set to -1 indicating that IDs of all landmarks are to be retrieved. +*/ +int QLandmarkIdFetchRequest::limit() const +{ + Q_D(const QLandmarkIdFetchRequest); + QMutexLocker ml(&d->mutex); + return d->limit; +} + +/*! + Sets the maximum number of landmarks to be returned to \a limit. + + A limit of -1 indicates that IDs of all landmarks are to be retrieved. + + (A limit of 0 will retrieve no landmark IDs.) + */ +void QLandmarkIdFetchRequest::setLimit(int limit) +{ + Q_D(QLandmarkIdFetchRequest); + QMutexLocker ml(&d->mutex); + d->limit = limit; +} + +/*! + Returns the index offset for the request. By default the offset is set to 0. + The offset determines the first index which is retrieved, it is generally used + in conjunction with limit() to facilitate paging. + + For example, if there are 10 landmarks in the landmark store, setting the offset + to 2 and limit to 5 will retrieve the 3rd and 7th landmark ids inclusively. (The order + of the landmark ids is sepecified by the sorting field). +*/ +int QLandmarkIdFetchRequest::offset() const +{ + Q_D(const QLandmarkIdFetchRequest); + QMutexLocker ml(&d->mutex); + return d->offset; +} + +/*! + Sets the index \a offset for the request. +*/ +void QLandmarkIdFetchRequest::setOffset(int offset) { + Q_D(QLandmarkIdFetchRequest); + QMutexLocker ml(&d->mutex); + d->offset = offset; +} + +/*! + Returns the list of identifiers of landmarks which matched the + filter. +*/ +QList<QLandmarkId> QLandmarkIdFetchRequest::landmarkIds() const +{ + Q_D(const QLandmarkIdFetchRequest); + QMutexLocker ml(&d->mutex); + return d->landmarkIds; +} + +#include "moc_qlandmarkidfetchrequest.cpp" + +QTM_END_NAMESPACE + + + + + + + + + + + diff --git a/src/location/landmarks/qlandmarkidfetchrequest.h b/src/location/landmarks/qlandmarkidfetchrequest.h new file mode 100644 index 00000000..6d1ed48a --- /dev/null +++ b/src/location/landmarks/qlandmarkidfetchrequest.h @@ -0,0 +1,80 @@ +/**************************************************************************** +** +** Copyright (C) 2009 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 QLANDMARKIDFETCHREQUEST_H +#define QLANDMARKIDFETCHREQUEST_H + +#include "qlandmarkabstractrequest.h" + +QTM_BEGIN_NAMESPACE + +class QLandmarkIdFetchRequestPrivate; +class Q_LOCATION_EXPORT QLandmarkIdFetchRequest : public QLandmarkAbstractRequest +{ + Q_OBJECT + +public: + QLandmarkIdFetchRequest(QLandmarkManager *manager, QObject *parent = 0); + ~QLandmarkIdFetchRequest(); + + QLandmarkFilter filter() const; + void setFilter(const QLandmarkFilter &filter); + + QList<QLandmarkSortOrder> sorting() const; + void setSorting(const QList<QLandmarkSortOrder> &sorting); + void setSorting(const QLandmarkSortOrder &sorting); + + int limit() const; + void setLimit(int limit); + + int offset() const; + void setOffset(int offset); + + QList<QLandmarkId> landmarkIds() const; +private: + Q_DISABLE_COPY(QLandmarkIdFetchRequest) + Q_DECLARE_PRIVATE(QLandmarkIdFetchRequest) + friend class QLandmarkManagerEngine; +}; + +QTM_END_NAMESPACE + +#endif diff --git a/src/location/landmarks/qlandmarkidfilter.cpp b/src/location/landmarks/qlandmarkidfilter.cpp new file mode 100644 index 00000000..35f9d203 --- /dev/null +++ b/src/location/landmarks/qlandmarkidfilter.cpp @@ -0,0 +1,153 @@ +/**************************************************************************** +** +** Copyright (C) 2009 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 "qlandmarkidfilter.h" +#include "qlandmarkidfilter_p.h" + +QTM_BEGIN_NAMESPACE + +/*! + \class QLandmarkIdFilter + \brief The QLandmarkIdFilter class is used to search for landmarks based + on a list of landmark identifiers. + + \inmodule QtLocation + + \ingroup landmarks-filter + \since 1.1 +*/ + +Q_IMPLEMENT_LANDMARKFILTER_PRIVATE(QLandmarkIdFilter) + +/*! + Creates a filter that selects landmarks using a list of landmark \a ids. +*/ +QLandmarkIdFilter::QLandmarkIdFilter(const QList<QLandmarkId> &ids) + : QLandmarkFilter(new QLandmarkIdFilterPrivate(ids)) {} + +/*! + \fn QLandmarkIdFilter::QLandmarkIdFilter(const QLandmarkFilter &other) + Constructs a copy of \a other if possible, otherwise constructs a new id filter. +*/ + +/*! + Destroys the filter. +*/ +QLandmarkIdFilter::~QLandmarkIdFilter() +{ + // pointer deleted in superclass destructor +} + +/*! + Returns the list of landmark identifiers that the filter will use to determine matches. +*/ +QList<QLandmarkId> QLandmarkIdFilter::landmarkIds() const +{ + Q_D(const QLandmarkIdFilter); + return d->landmarkIds; +} + +/*! + Sets the \a ids that the filter will use to determine matches. +*/ +void QLandmarkIdFilter::setLandmarkIds(const QList<QLandmarkId> &ids) +{ + Q_D(QLandmarkIdFilter); + d->landmarkIds = ids; +} + +/*! + Adds \a id to the list of landmark ids this filter searches for. +*/ +void QLandmarkIdFilter::append(const QLandmarkId &id) +{ + Q_D(QLandmarkIdFilter); + d->landmarkIds.append(id); +} + +/*! + Removes \a id to the list of landmark ids this filter searches for. +*/ +void QLandmarkIdFilter::remove(const QLandmarkId &id) +{ + Q_D(QLandmarkIdFilter); + d->landmarkIds.removeAll(id); +} + +/*! + Removes all identifiers from the filter. +*/ +void QLandmarkIdFilter::clear() +{ + Q_D(QLandmarkIdFilter); + d->landmarkIds.clear(); +} + +/*! + Appends the given \a id to the list of landmark identifiers + this filter searches for. +*/ +QLandmarkIdFilter &QLandmarkIdFilter::operator<<(const QLandmarkId &id) +{ + Q_D(QLandmarkIdFilter); + d->landmarkIds.append(id); + return *this; +} + + +/******************************************************************************* +*******************************************************************************/ + +QLandmarkIdFilterPrivate::QLandmarkIdFilterPrivate(const QList<QLandmarkId> &ids) + : landmarkIds(ids) +{ + type = QLandmarkFilter::LandmarkIdFilter; +} + +QLandmarkIdFilterPrivate::QLandmarkIdFilterPrivate(const QLandmarkIdFilterPrivate &other) + : QLandmarkFilterPrivate(other), + landmarkIds(other.landmarkIds) +{ +} + +QLandmarkIdFilterPrivate::~QLandmarkIdFilterPrivate() {} + +QTM_END_NAMESPACE diff --git a/src/location/landmarks/qlandmarkidfilter.h b/src/location/landmarks/qlandmarkidfilter.h new file mode 100644 index 00000000..ea10bbf9 --- /dev/null +++ b/src/location/landmarks/qlandmarkidfilter.h @@ -0,0 +1,73 @@ +/**************************************************************************** +** +** Copyright (C) 2009 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 QLANDMARKIDFILTER_H +#define QLANDMARKIDFILTER_H + +#include "qlandmarkid.h" +#include "qlandmarkfilter.h" +#include <QList> + +QTM_BEGIN_NAMESPACE + +class QLandmarkIdFilterPrivate; +class Q_LOCATION_EXPORT QLandmarkIdFilter : public QLandmarkFilter +{ +public: + QLandmarkIdFilter(const QList<QLandmarkId> &ids = QList<QLandmarkId>()); + QLandmarkIdFilter(const QLandmarkFilter &other); + virtual ~QLandmarkIdFilter(); + + QList<QLandmarkId> landmarkIds() const; + void setLandmarkIds(const QList<QLandmarkId> &ids); + void append(const QLandmarkId &id); + void remove(const QLandmarkId &id); + void clear(); + + QLandmarkIdFilter &operator<<(const QLandmarkId &); + +private: + Q_DECLARE_LANDMARKFILTER_PRIVATE(QLandmarkIdFilter) +}; + +QTM_END_NAMESPACE + +#endif diff --git a/src/location/landmarks/qlandmarkidfilter_p.h b/src/location/landmarks/qlandmarkidfilter_p.h new file mode 100644 index 00000000..98ab9700 --- /dev/null +++ b/src/location/landmarks/qlandmarkidfilter_p.h @@ -0,0 +1,82 @@ +/**************************************************************************** +** +** Copyright (C) 2009 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 QLANDMARKIDFILTER_P_H +#define QLANDMARKIDFILTER_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 "qlandmarkfilter_p.h" +#include "qlandmarkid.h" +#include "qlandmarkidfilter.h" + +QTM_BEGIN_NAMESPACE + +class QLandmarkIdFilterPrivate : public QLandmarkFilterPrivate +{ +public: + QLandmarkIdFilterPrivate(const QList<QLandmarkId> &ids =QList<QLandmarkId>()); + QLandmarkIdFilterPrivate(const QLandmarkIdFilterPrivate &other); + virtual ~QLandmarkIdFilterPrivate(); + + virtual bool compare(const QLandmarkFilterPrivate *other) const + { + const QLandmarkIdFilterPrivate *od = static_cast<const QLandmarkIdFilterPrivate*>(other); + return landmarkIds == od->landmarkIds; + } + + Q_IMPLEMENT_LANDMARKFILTER_VIRTUALCTORS(QLandmarkIdFilter, QLandmarkFilter::LandmarkIdFilter) + + QList<QLandmarkId> landmarkIds; +}; + +QTM_END_NAMESPACE + +#endif diff --git a/src/location/landmarks/qlandmarkimportrequest.cpp b/src/location/landmarks/qlandmarkimportrequest.cpp new file mode 100644 index 00000000..39d7efe3 --- /dev/null +++ b/src/location/landmarks/qlandmarkimportrequest.cpp @@ -0,0 +1,222 @@ +/**************************************************************************** +** +** Copyright (C) 2009 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 "qlandmarkimportrequest.h" +#include "qlandmarkrequests_p.h" +#include <QFile> + +QTM_BEGIN_NAMESPACE + +/*! + \class QLandmarkImportRequest + \brief The QLandmarkImportRequest class allows a client to asynchronously + request that a landmark manager import a set of landmarks. + + For a QLandmarkImportRequest, the resultsAvailable() signal will be emitted + when landmarks have been successfully imported by the manager. The list + of added landmarks may be retrieved by the landmarkIds() function. The resultsAvailable() + signal may also be emitted if an overall operational error occurs. + + Please see the class documentation for QLandmarkAbstractRequest for more information about + the usage of request classes and ownership semantics. + + Note that for S60 and Symbian platforms, the waitForFinished() function is not + supported for import requests and will always return false. + + \inmodule QtLocation + \since 1.1 + + \ingroup landmarks-request +*/ + +/*! + Constructs a landmark import request with the given \a manager \a parent. +*/ +QLandmarkImportRequest::QLandmarkImportRequest(QLandmarkManager *manager, QObject *parent) + : QLandmarkAbstractRequest(new QLandmarkImportRequestPrivate(manager), parent) +{ +} + +/*! + Destroys the request object. +*/ +QLandmarkImportRequest::~QLandmarkImportRequest() +{ +} + +/*! + Returns the device from which landmarks are read. +*/ +QIODevice *QLandmarkImportRequest::device() const +{ + Q_D(const QLandmarkImportRequest); + QMutexLocker ml(&d->mutex); + return d->device; +} + +/*! + Sets the \a device from which landmarks are read. +*/ +void QLandmarkImportRequest::setDevice(QIODevice *device) +{ + Q_D(QLandmarkImportRequest); + QMutexLocker ml(&d->mutex); + d->device = device; +} + +/*! + If the currently assigned device is a QFile, or if setFileName() has + been called, this function returns the name of the file to be + read from. In all other cases, it returns an empty string. + + \sa setFileName(), setDevice() +*/ +QString QLandmarkImportRequest::fileName() const +{ + Q_D(const QLandmarkImportRequest); + QMutexLocker ml(&d->mutex); + QFile *file = qobject_cast<QFile *>(d->device); + return file ? file->fileName() : QString(); +} + +/*! + Sets the name of the file to be read from to \a fileName. Internally, + QLandmarkImportRequest will create a QFile and use this as the + device to import from. + + \sa fileName(), setDevice() +*/ +void QLandmarkImportRequest::setFileName(const QString &fileName) +{ + Q_D(QLandmarkImportRequest); + QMutexLocker ml(&d->mutex); + d->device = new QFile(fileName); +} + +/*! + Returns the expected data format for the import operation. + By default no format is set, indicating that the manager + will try to automatically detect the format of the import file. +*/ +QString QLandmarkImportRequest::format() const +{ + Q_D(const QLandmarkImportRequest); + QMutexLocker ml(&d->mutex); + return d->format; +} + +/*! + Sets the expected data \a format for the import operation. + If an empty string is set, then during the import, + an attempt is made to auto detect the format. +*/ +void QLandmarkImportRequest::setFormat(const QString &format) +{ + Q_D(QLandmarkImportRequest); + QMutexLocker ml(&d->mutex); + d->format = format; +} + +/*! + Returns the transfer option of the import request. + The transfer option defines how categories are treated + during the import operation. The default option is + QLandmarkManager::IncludeCategoryData. + +*/ +QLandmarkManager::TransferOption QLandmarkImportRequest::transferOption() const +{ + Q_D(const QLandmarkImportRequest); + QMutexLocker ml(&d->mutex); + return d->option; +} + +/*! + Sets the transfer \a option of the import request. + The transfer \a option defines how categories are treated + during the import operation. +*/ +void QLandmarkImportRequest::setTransferOption(QLandmarkManager::TransferOption option) +{ + Q_D(QLandmarkImportRequest); + QMutexLocker ml(&d->mutex); + d->option = option; +} + +/*! + Returns identifier of the category which all landmarks are assigned to if + QLandmarkManager::AttachSingleCategory is used + as the import option. +*/ +QLandmarkCategoryId QLandmarkImportRequest::categoryId() const +{ + Q_D(const QLandmarkImportRequest); + QMutexLocker ml(&d->mutex); + return d->categoryId; +} + +/*! + Sets the identifier of the category to which all landmarks are assigned to, + if QLandmarkManager::AttachSingleCategory is used as the import option, to + \a categoryId. +*/ +void QLandmarkImportRequest::setCategoryId(const QLandmarkCategoryId &categoryId) +{ + Q_D(QLandmarkImportRequest); + QMutexLocker ml(&d->mutex); + d->categoryId = categoryId; +} + +/*! + Returns a list of identifiers of landmarks that have been imported. +*/ +QList<QLandmarkId> QLandmarkImportRequest::landmarkIds() const +{ + Q_D(const QLandmarkImportRequest); + QMutexLocker ml(&d->mutex); + return d->landmarkIds; +} + +#include "moc_qlandmarkimportrequest.cpp" + +QTM_END_NAMESPACE + + diff --git a/src/location/landmarks/qlandmarkimportrequest.h b/src/location/landmarks/qlandmarkimportrequest.h new file mode 100644 index 00000000..a5018b0e --- /dev/null +++ b/src/location/landmarks/qlandmarkimportrequest.h @@ -0,0 +1,82 @@ +/**************************************************************************** +** +** Copyright (C) 2009 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 QLANDMARKIMPORTREQUEST_H +#define QLANDMARKIMPORTREQUEST_H + +#include "qlandmarkabstractrequest.h" +class QIODevice; +QTM_BEGIN_NAMESPACE + +class QLandmarkImportRequestPrivate; +class Q_LOCATION_EXPORT QLandmarkImportRequest : public QLandmarkAbstractRequest +{ + Q_OBJECT +public: + QLandmarkImportRequest(QLandmarkManager *manager, QObject *parent = 0); + ~QLandmarkImportRequest(); + + QIODevice *device() const; + void setDevice(QIODevice *device); + + QString fileName() const; + void setFileName(const QString &fileName); + + QString format() const; + void setFormat(const QString &format); + + QLandmarkManager::TransferOption transferOption() const; + void setTransferOption(QLandmarkManager::TransferOption option); + + QLandmarkCategoryId categoryId() const; + void setCategoryId(const QLandmarkCategoryId &categoryId); + + QList<QLandmarkId> landmarkIds() const; +private: + Q_DISABLE_COPY(QLandmarkImportRequest) + Q_DECLARE_PRIVATE(QLandmarkImportRequest) + friend class QLandmarkManagerEngine; +}; + +QTM_END_NAMESPACE + +#endif + diff --git a/src/location/landmarks/qlandmarkintersectionfilter.cpp b/src/location/landmarks/qlandmarkintersectionfilter.cpp new file mode 100644 index 00000000..faeffb72 --- /dev/null +++ b/src/location/landmarks/qlandmarkintersectionfilter.cpp @@ -0,0 +1,176 @@ +/**************************************************************************** +** +** Copyright (C) 2009 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 "qlandmarkintersectionfilter.h" +#include "qlandmarkintersectionfilter_p.h" + +QTM_BEGIN_NAMESPACE + +/*! + \class QLandmarkIntersectionFilter + \brief The QLandmarkIntersectionFilter class provides a filter which intersects the results + of its constituent filters. + + \inmodule QtLocation + + \ingroup landmarks-filter + \since 1.1 + + Conceptually it performs an AND operation and thus may be used to + select landmarks which match all of it's constituent filters. + If the intersection filter contains a proximity filter at the top level (i.e. which is not nested + inside another filter) then the landmarks will be sorted by distance according to that filter. + Note that a using sort order other than QLandmarkSortOrder (i.e. no sort) will override the + sorting by distance). + + Whether an intersection filter can be comprised of + compound filters (i.e. union or intersection filters) is backend specific. + Even if this is supported the performance of such a filter is likely to be poor. +*/ + +Q_IMPLEMENT_LANDMARKFILTER_PRIVATE(QLandmarkIntersectionFilter); + +/*! + Constructs an intersection filter. +*/ +QLandmarkIntersectionFilter::QLandmarkIntersectionFilter() + : QLandmarkFilter(new QLandmarkIntersectionFilterPrivate()) +{ +} + +/*! + \fn QLandmarkIntersectionFilter::QLandmarkIntersectionFilter(const QLandmarkFilter &other) + Constructs a copy of \a other if possible, otherwise constructs a new intersection filter. +*/ + +/*! + Destroys the filter. +*/ +QLandmarkIntersectionFilter::~QLandmarkIntersectionFilter() +{ + // pointer deleted in superclass destructor +} + +/*! + Sets the \a filters whose criteria will be intersected. + \sa filters() + */ +void QLandmarkIntersectionFilter::setFilters(const QList<QLandmarkFilter> &filters) +{ + Q_D(QLandmarkIntersectionFilter); + d->filters = filters; +} + +/*! + Prepends the given \a filter to the list of intersected filters + \sa append(), filters() +*/ +void QLandmarkIntersectionFilter::prepend(const QLandmarkFilter &filter) +{ + Q_D(QLandmarkIntersectionFilter); + d->filters.prepend(filter); +} + +/*! + Appends the given \a filter to the list of intersected filters + \sa operator<<(), prepend(), filters() +*/ +void QLandmarkIntersectionFilter::append(const QLandmarkFilter &filter) +{ + Q_D(QLandmarkIntersectionFilter); + d->filters.append(filter); +} + +/*! + Removes the given \a filter from the list of intersected filters. + \sa filters(), append(), prepend() +*/ +void QLandmarkIntersectionFilter::remove(const QLandmarkFilter &filter) +{ + Q_D(QLandmarkIntersectionFilter); + d->filters.removeAll(filter); +} + +/*! + Removes all filters from the list of intersected filters. +*/ +void QLandmarkIntersectionFilter::clear() +{ + Q_D(QLandmarkIntersectionFilter); + d->filters.clear(); +} + +/*! + Appends the given \a filter to the list of intersected filters + \sa append() + */ +QLandmarkIntersectionFilter& QLandmarkIntersectionFilter::operator<<(const QLandmarkFilter &filter) +{ + Q_D(QLandmarkIntersectionFilter); + d->filters.append(filter); + return *this; +} + +/*! + Returns the list of filters which form the intersection filter + \sa setFilters(), prepend(), append(), remove() + */ +QList<QLandmarkFilter> QLandmarkIntersectionFilter::filters() const +{ + Q_D(const QLandmarkIntersectionFilter); + return d->filters; +} + +/******************************************************************************* +*******************************************************************************/ + +QLandmarkIntersectionFilterPrivate::QLandmarkIntersectionFilterPrivate() +{ + type = QLandmarkFilter::IntersectionFilter; +} + +QLandmarkIntersectionFilterPrivate::QLandmarkIntersectionFilterPrivate(const QLandmarkIntersectionFilterPrivate &other) + : QLandmarkFilterPrivate(other), + filters(other.filters) {} + +QLandmarkIntersectionFilterPrivate::~QLandmarkIntersectionFilterPrivate() {} + +QTM_END_NAMESPACE diff --git a/src/location/landmarks/qlandmarkintersectionfilter.h b/src/location/landmarks/qlandmarkintersectionfilter.h new file mode 100644 index 00000000..750775e8 --- /dev/null +++ b/src/location/landmarks/qlandmarkintersectionfilter.h @@ -0,0 +1,74 @@ +/**************************************************************************** +** +** Copyright (C) 2009 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 QLANDMARKINTERSECTIONFILTER_H +#define QLANDMARKINTERSECTIONFILTER_H + +#include "qlandmarkfilter.h" +#include <QList> + +QTM_BEGIN_NAMESPACE + +class QLandmarkIntersectionFilterPrivate; +class Q_LOCATION_EXPORT QLandmarkIntersectionFilter : public QLandmarkFilter +{ +public: + QLandmarkIntersectionFilter(); + QLandmarkIntersectionFilter(const QLandmarkFilter &other); + virtual ~QLandmarkIntersectionFilter(); + + void setFilters(const QList<QLandmarkFilter>& filters); + + void prepend(const QLandmarkFilter &filter); + void append(const QLandmarkFilter &filter); + void remove(const QLandmarkFilter &filter); + void clear(); + + QLandmarkIntersectionFilter& operator<<(const QLandmarkFilter& filter); + QList<QLandmarkFilter> filters() const; + +private: + Q_DECLARE_LANDMARKFILTER_PRIVATE(QLandmarkIntersectionFilter) +}; + +QTM_END_NAMESPACE + +#endif diff --git a/src/location/landmarks/qlandmarkintersectionfilter_p.h b/src/location/landmarks/qlandmarkintersectionfilter_p.h new file mode 100644 index 00000000..3920f3e6 --- /dev/null +++ b/src/location/landmarks/qlandmarkintersectionfilter_p.h @@ -0,0 +1,82 @@ +/**************************************************************************** +** +** Copyright (C) 2009 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 QLANDMARKINTERSECTIONFILTER_P_H +#define QLANDMARKINTERSECTIONFILTER_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 "qlandmarkfilter_p.h" + +#include <QList> + +QTM_BEGIN_NAMESPACE + +class QLandmarkIntersectionFilterPrivate : public QLandmarkFilterPrivate +{ +public: + QLandmarkIntersectionFilterPrivate(); + QLandmarkIntersectionFilterPrivate(const QLandmarkIntersectionFilterPrivate &other); + virtual ~QLandmarkIntersectionFilterPrivate(); + + virtual bool compare(const QLandmarkFilterPrivate* other) const + { + const QLandmarkIntersectionFilterPrivate *od = static_cast<const QLandmarkIntersectionFilterPrivate*>(other); + return filters == od->filters; + } + + Q_IMPLEMENT_LANDMARKFILTER_VIRTUALCTORS(QLandmarkIntersectionFilter, QLandmarkFilter::IntersectionFilter) + + QList<QLandmarkFilter> filters; +}; + +QTM_END_NAMESPACE + +#endif diff --git a/src/location/landmarks/qlandmarkmanager.cpp b/src/location/landmarks/qlandmarkmanager.cpp new file mode 100644 index 00000000..1a2f21db --- /dev/null +++ b/src/location/landmarks/qlandmarkmanager.cpp @@ -0,0 +1,1473 @@ +/**************************************************************************** +** +** Copyright (C) 2009 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 "qlandmarkmanager.h" +#include "qlandmarkmanager_p.h" + +#include <QStringList> +#include <QString> +#include <QIODevice> +#include <QFile> +#include <QUrl> +#include <QPluginLoader> +#include <QDebug> +#include "qlandmarkcategoryid.h" +#include "qlandmarkcategory.h" +#include "qlandmark.h" +#include "qlandmarkmanagerengine.h" +#include "qlandmarkmanagerenginefactory.h" +#include "qlandmarkidfilter.h" + +QTM_USE_NAMESPACE + +/*! + \variable QLandmarkManager::Gpx + The format constant to define using the gpx format in the import and export functions. + \sa importLandmarks(), exportLandmarks() +*/ +Q_DEFINE_LATIN1_CONSTANT(QLandmarkManager::Gpx, "Gpx"); + +/*! + \variable QLandmarkManager::Lmx + The format constant to define using the lmx format in the import and export functions. + \sa importLandmarks(), exportLandmarks() +*/ +Q_DEFINE_LATIN1_CONSTANT(QLandmarkManager::Lmx, "Lmx"); + +/*! + \variable QLandmarkManager::Kml + The format constant to define using the kml format in the import and export functions. + \sa importLandmarks(), exportLandmarks() +*/ +Q_DEFINE_LATIN1_CONSTANT(QLandmarkManager::Kml, "Kml"); + +/*! + \variable QLandmarkManager::Kmz + The format constant to define using the kmz format in the import and export functions. + \sa importLandmarks(), exportLandmarks() +*/ +Q_DEFINE_LATIN1_CONSTANT(QLandmarkManager::Kmz, "Kmz"); + +/*! + \class QLandmarkManager + \brief The QLandmarkManager class provides an interface for storage + and retrieval of landmarks from a landmark store. + + \inmodule QtLocation + + \ingroup landmarks-main + + The QLandmarkManager is the starting class to use when working with landmarks. + It effectively represents a landmark datastore and it provides the synchronous operations for the + creation, retrieval, updating and deletion of both landmarks and categories. For asynchronous operations + use the \l {Asynchronous Landmark Requests} {request classes} which use the manager as a parameter. + The manager provides notifications whenever landmarks or categories are added, updated or removed. + + Each manager is identified by a manager name which typically takes the form of a reverse domain string + such as \c com.nokia.qt.landmarks.engines.sqlite. However every supported platform provides a default + manager which may be instantiated without having to provide a name like so: + \snippet doc/src/snippets/qtlandmarksdocsample/qtlandmarksdocsample.cpp Instantiate default QLandmarkManager + + \section1 Retrieval Operations + + To retrieve a set of landmarks we provide may provide a QLandmarkFilter, QLandmarkSortOrder and limit and offset as necessary. + The QLandmarkFilter defines the criteria for selecting landmarks; for example, a QLandmarkCategoryFilter may be used + to choose landmarks that belong to a certain category. A QLandmarkSortOrder order defines how the results should + be sorted. (Note that if you wish to sort by distance, you should use a proxmity filter, see QLandmarkProximityFilter). + The limit allows specification of the maximum number of items to + return and the offset defines the index of the first item. The following demonstrates how to search for the first 100 + landmarks belonging to a given category, sorted by name. + + \snippet doc/src/snippets/qtlandmarksdocsample/qtlandmarksdocsample.cpp Retrieve landmarks by category synchronously + + The set of parameters described above are not always necessary as defaults are provided, if we wanted to retrieve + all landmarks, then the appropriate call is: + + \snippet doc/src/snippets/qtlandmarksdocsample/qtlandmarksdocsample.cpp Retrieve all landmarks synchronously + \note Landmark retrieval is potentially a long operation, the synchronous API provided by the manager + is subject to blocking. It is generally recommended that the QLandmarkFetchRequest be used because + it behaves asynchronously. + + Categories may be retrieved in a similar manner: + \snippet doc/src/snippets/qtlandmarksdocsample/qtlandmarksdocsample.cpp Retrieve categories synchronously simple + + \section1 Saving and Deleting + + Saving and deleting landmarks and categories are fairly straightforward. To add a new landmark or category + simply instantiate a QLandmark or QLandmarkCategory, set its data fields (e.g., name, coordinate, etc.) and pass + a pointer to the appropriate save operation. For example: + + \snippet doc/src/snippets/qtlandmarksdocsample/qtlandmarksdocsample.cpp Add landmark synchronously simple + + We pass the landmark by pointer bcause it will be assigned a new QLandmarkId when the function call is done. + Saving a landmark with a valid id already set will update the existing landmark. + + Removal of landmark may be done as follows: + \snippet doc/src/snippets/qtlandmarksdocsample/qtlandmarksdocsample.cpp Remove landmark synchronously simple + + \section1 Importing and Exporting + + Import and export are potentially long operations, to perform these operations asynchronously + see QLandmarkImportRequest and QLandmarkExportRequest. The simplest way to perform an import + is to supply a file name while an export will need both a file name and format. + + \snippet doc/src/snippets/qtlandmarksdocsample/qtlandmarksdocsample.cpp ImportExport landmark simple + + The formats supported for import and export can be found by calling the + supportedFormats() function with the type of operation to be performed, + either ImportOperation or ExportOperation. +*/ + +/*! + \enum QLandmarkManager::Error + Defines the possible errors for the landmark manager. + \value NoError No error occurred + \value DoesNotExistError The most recent operation failed due to an item not being found, usually an import file. + \value LandmarkDoesNotExistError The most recent operation failed due to a specified landmark not being found. + \value CategoryDoesNotExistError The most recent operation faied due to a specified category not being found. + \value AlreadyExistsError The most recent operation failed because the specified landmark or category already exists. + \value LockedError The most recent operation failed because the datastore specified is currently locked. + \value PermissionsError The most recent operation failed because the caller does not have permission to perform the operation. + \value OutOfMemoryError The most recent operation failed due to running out of memory. + \value VersionMismatchError The most recent operation failed because the backend of the manager is not of the required version. + \value NotSupportedError The most recent operation failed because the requested operation is not supported by the manager. + \value BadArgumentError The most recent operation failed because one or more of the parameters to the operation were invalid. + \value InvalidManagerError The most recent operation failed because the manager failed to initialize correctly and is invalid. + This could be due using a manager name that is not recognised/available. A landmark request object will return this error if + if is assigned a null manager pointer. + \value ParsingError The most recent operation failed because the imported file could not be parsed. + \value CancelError The most recent operation failed to complete due to user cancelation. + \value UnknownError The most recent operation failed for an unknown reason. +*/ + +/*! + \enum QLandmarkManager::TransferOption + Defines the possible options when transferring landmarks during import or export. + \value IncludeCategoryData During an import, category data is included. If an imported category doesn't exist + the category is created. If the imported category name matches an existing + category name, then the landmark is added to that category. For exports, categories + are included in the exported file if the file format allows it. + \value ExcludeCategoryData Landmarks are imported or exported without any categories assigned to the landmarks. + \value AttachSingleCategory Only relevant for import operations. When landmarks are imported they are + all assigned to a given category. +*/ + +/*! + \enum QLandmarkManager::ManagerFeature + Defines the possible features the landmark manager can support. + \value ImportExportFeature The manager supports import and/or export operations + \value NotificationsFeature The manager will emit notification signals when landmarks/categories have + been added/modified/removed from the datastore it manages. +*/ + +/*! + \enum QLandmarkManager::SupportLevel + Defines the possible support levels the manager can provide for a given filter or sort order list. + \value NativeSupport The manager natively supports the filter or sort order list. + \value EmulatedSupport The manager emulates the behaviour of the filter or sort order list. + Emulated behaviour will inherently be slower than a natively supported implementation. + \value NoSupport The manager does not support the filter or sort order list at all. +*/ + +/*! + \enum QLandmarkManager::TransferOperation + Defines the type of transfer. + \value ImportOperation Landmarks are being copied from a file to the device. + \value ExportOperation Landmarks are being copied from the device to a file. +*/ + +/*! + Constructs a QLandmarkManager. The default manager implementation for the platform will be used. + + The \a parent QObject will be used as the parent of this QLandmarkManager. +*/ +QLandmarkManager::QLandmarkManager(QObject *parent) + : QObject(parent), + d_ptr(new QLandmarkManagerPrivate()) +{ + Q_D(QLandmarkManager); + d->q_ptr = this; + QString managerName; + +#ifdef Q_OS_SYMBIAN + managerName = "com.nokia.qt.landmarks.engines.symbian"; +#elif defined(Q_WS_MAEMO_6) || defined(Q_WS_MEEGO) + managerName = "com.nokia.qt.landmarks.engines.qsparql"; +#else + managerName = "com.nokia.qt.landmarks.engines.sqlite"; +#endif + + d->createEngine(managerName); +} + +/*! + Constructs a QLandmarkManager whose implementation is identified by \a managerName with the given + \a parameters. + + The \a parent QObject will be used as the parent of this QLandmarkManager. + + If an empty \a managerName is specified, the default manager implementation for the platform will be used. +*/ +QLandmarkManager::QLandmarkManager(const QString &managerName, const QMap<QString, QString> ¶meters, QObject *parent) + : QObject(parent), + d_ptr(new QLandmarkManagerPrivate()) +{ + Q_D(QLandmarkManager); + d->q_ptr = this; + d->createEngine(managerName, parameters); +} + +/*! + Frees the memory used by the QLandmarkManager +*/ +QLandmarkManager::~QLandmarkManager() +{ + Q_D(QLandmarkManager); + + if (d->engine) + delete d->engine; + + delete d; +} + +/*! + Adds the given \a landmark to the database if \a landmark has a + default-constructed identifer, or an identifier with the manager + URI set to the URI of this manager and an empty id. + + If the manager URI of the identifier of the \a landmark is neither + empty nor equal to the URI of this manager, or the id member of the + identifier is not empty, but does not exist in the manager, + the operation will fail and calling error() will return + \c QLandmarkManager::LandmarkDoesNotExistError. + + Alternatively, the function will update the existing landmark in the + database if \a landmark has a non-empty id and currently exists + within the database. + + Returns false on failure or true on success. On successful save + of a landmark with an empty id, it will be assigned a valid + id and have its manager URI set to the URI of this manager. +*/ +bool QLandmarkManager::saveLandmark(QLandmark *landmark) +{ + Q_D(QLandmarkManager); + + if (!d->engine) { + return false; + } + + d->errorCode = QLandmarkManager::NoError; + d->errorString = ""; + d->errorMap.clear(); + + return d->engine->saveLandmark(landmark, + &(d->errorCode), + &(d->errorString)); +} + +/*! + Adds the list of \a landmarks to the database. + Returns true if the landmarks were saved successfully, otherwise returns + false. + + This function will set per-input errors in the QLandmarkManager::errorMap(). + + The QLandmarkManager::error() function will only return \c + QLandmarkManager::NoError if all landmarks were saved successfully. + + For each new landmark that was successfully saved, a landmark identifier + is assigned to that landmark. +*/ +bool QLandmarkManager::saveLandmarks(QList<QLandmark> *landmarks) +{ + Q_D(QLandmarkManager); + + if (!d->engine) { + return false; + } + + d->errorCode = QLandmarkManager::NoError; + d->errorString = ""; + d->errorMap.clear(); + + return d->engine->saveLandmarks(landmarks, + &(d->errorMap), + &(d->errorCode), + &(d->errorString)); +} + +/*! + Remove the landmark identified by \a landmarkId from the database. + + Returns true if the landmark was removed successfully, otherwise + returnse false. +*/ +bool QLandmarkManager::removeLandmark(const QLandmarkId &landmarkId) +{ + Q_D(QLandmarkManager); + + if (!d->engine) { + return false; + } + + d->errorCode = QLandmarkManager::NoError; + d->errorString = ""; + d->errorMap.clear(); + + return d->engine->removeLandmark(landmarkId, + &(d->errorCode), + &(d->errorString)); +} + + +/*! + Removes the \a landmark from the database. + + Returns true if the landmark was removed successfully, + otherwise returns false. +*/ +bool QLandmarkManager::removeLandmark(const QLandmark &landmark) +{ + Q_D(QLandmarkManager); + + if (!d->engine) { + return false; + } + + d->errorCode = QLandmarkManager::NoError; + d->errorString = ""; + d->errorMap.clear(); + + return d->engine->removeLandmark(landmark.landmarkId(), + &(d->errorCode), + &(d->errorString)); + +} + +/*! + Removes every landmark whose identifier is contained in the list + of \a landmarkIds. Returns true if all landmarks were removed + successfully, otherwise false. + + This batch function will set per-input errors in the QLandmarkManager::errorMap(). + + The QLandmarkManager::error() function will only return + \c QLandmarkManager::NoError if all landmarks were removed successfully. + + \sa QLandmarkManager::removeLandmark() +*/ +bool QLandmarkManager::removeLandmarks(const QList<QLandmarkId> &landmarkIds) +{ + Q_D(QLandmarkManager); + + if (!d->engine) { + return false; + } + + d->errorCode = QLandmarkManager::NoError; + d->errorString = ""; + d->errorMap.clear(); + + + return d->engine->removeLandmarks(landmarkIds, + &(d->errorMap), + &(d->errorCode), + &(d->errorString)); +} + +/*! + Convenience function to remove the given \a landmarks from the database. + Returns true if all landmarks were removed + successfully, otherwise false. + + This batch function will set per input errors in the QLandmarkManager::errorMap(). + + The QLandmarkManager::error() function will only return + \c QLandmarkManager::NoError if all landmarks were removed successfully. + + + + \sa QLandmarkManager::removeLandmark() +*/ +bool QLandmarkManager::removeLandmarks(const QList<QLandmark> &landmarks) +{ + Q_D(QLandmarkManager); + + if (!d->engine) { + return false; + } + + d->errorCode = QLandmarkManager::NoError; + d->errorString = ""; + d->errorMap.clear(); + + QList<QLandmarkId> landmarkIds; + for (int i=0; i < landmarks.count(); ++i) { + landmarkIds << landmarks.at(i).landmarkId(); + } + + return d->engine->removeLandmarks(landmarkIds, + &(d->errorMap), + &(d->errorCode), + &(d->errorString)); +} + + + +/*! + Adds the given \a category to the database if \a category has a + default-constructed identifier, or an identifier with the manager + URI set to the URI of this manager and an empty id. + + If the manager URI of the identifier of the \a category is neither + empty nor equal to the URI of this manager, or the id member of the + identifier is not empty, but does not exist in the manager, + the operation will fail and calling error() will return + \c QLandmarkManager::CategoryDoesNotExistError. + + Alternatively, the function will update the existing category in the + database if \a category has a non-empty id and currently exists + within the database. + + Returns false on failure or true on success. On successful save + of a category with an invalid id, it will be assigned a valid + id and have its manager URI set to the URI of this manager. +*/ +bool QLandmarkManager::saveCategory(QLandmarkCategory *category) +{ + Q_D(QLandmarkManager); + + if (!d->engine) { + return false; + } + + d->errorCode = QLandmarkManager::NoError; + d->errorString = ""; + d->errorMap.clear(); + + return d->engine->saveCategory(category, + &(d->errorCode), + &(d->errorString)); +} + +/*! + Remove the category identified by \a categoryId from the database. + + Returns true if the category was removed successfully, otherwise + returnse false. +*/ +bool QLandmarkManager::removeCategory(const QLandmarkCategoryId &categoryId) +{ + Q_D(QLandmarkManager); + + if (!d->engine) { + return false; + } + + d->errorCode = QLandmarkManager::NoError; + d->errorString = ""; + d->errorMap.clear(); + + return d->engine->removeCategory(categoryId, + &(d->errorCode), + &(d->errorString)); +} + +/*! + Remove the given \a category from the database + + Returns true if the category was removed successfully, otherwise + returnse false. +*/ +bool QLandmarkManager::removeCategory(const QLandmarkCategory &category) +{ + Q_D(QLandmarkManager); + + if (!d->engine) { + return false; + } + + d->errorCode = QLandmarkManager::NoError; + d->errorString = ""; + d->errorMap.clear(); + + return d->engine->removeCategory(category.categoryId(), + &(d->errorCode), + &(d->errorString)); +} + +/*! + Returns the cateory in the database identified by \a categoryId. +*/ +QLandmarkCategory QLandmarkManager::category(const QLandmarkCategoryId &categoryId) const +{ + Q_D(const QLandmarkManager); + + if (!d->engine) { + return QLandmarkCategory(); + } + + d->errorCode = QLandmarkManager::NoError; + d->errorString = ""; + d->errorMap.clear(); + + QLandmarkCategory cat = d->engine->category(categoryId, + &(d->errorCode), + &(d->errorString)); + + if (d->errorCode != NoError) + return QLandmarkCategory(); + + return cat; +} + +/*! + Returns a list of categories which match the given \a categoryIds. + + This batch function will set per-input errors in the QLandmarkManager::errorMap(); + + The QLandmarkManager::error() function will only return \c QLandmarkManager::NoError if + all categories were successfully retrieved. + */ +QList<QLandmarkCategory> QLandmarkManager::categories(const QList<QLandmarkCategoryId> &categoryIds) const +{ + Q_D(const QLandmarkManager); + + if (!d->engine) { + return QList<QLandmarkCategory>(); + } + + d->errorCode = QLandmarkManager::NoError; + d->errorString = ""; + d->errorMap.clear(); + + QList<QLandmarkCategory> cats = d->engine->categories(categoryIds, + &(d->errorMap), + &(d->errorCode), + &(d->errorString)); + + return cats; +} + +/*! + Returns a list of categories.The \a limit defines the maximum number of categories + to return and the \a offset defines the index offset of the first category. + A \a limit of -1 means all categories should be returned(a limit of 0 means zero + categories are returned). The categories + are returned in the order as designated by \a nameSort. +*/ +QList<QLandmarkCategory> QLandmarkManager::categories(int limit, int offset, const QLandmarkNameSort &nameSort) const +{ + Q_D(const QLandmarkManager); + + if (!d->engine) { + return QList<QLandmarkCategory>(); + } + + d->errorCode = QLandmarkManager::NoError; + d->errorString = ""; + d->errorMap.clear(); + + QList<QLandmarkCategory> cats = d->engine->categories(limit, offset, nameSort, + &(d->errorCode), + &(d->errorString)); + + if (d->errorCode != NoError) + return QList<QLandmarkCategory>(); + + return cats; +} + +/*! + Returns a list of category identifiers. + The \a limit defines the maximum number of ids to return and the \a offset defines the index offset + of the first id. A \a limit of -1 means ids for all categories should be returned. + The identifiers are returned in order as designed by \a nameSort. Note that a limit + of 0 will return zero category ids. +*/ +QList<QLandmarkCategoryId> QLandmarkManager::categoryIds(int limit, int offset, const QLandmarkNameSort &nameSort) const +{ + Q_D(const QLandmarkManager); + + if (!d->engine) { + return QList<QLandmarkCategoryId>(); + } + + d->errorCode = QLandmarkManager::NoError; + d->errorString = ""; + d->errorMap.clear(); + + QList<QLandmarkCategoryId> ids = d->engine->categoryIds(limit, offset, nameSort, + &(d->errorCode), + &(d->errorString)); + + if (d->errorCode != NoError) + return QList<QLandmarkCategoryId>(); + + return ids; +} + +/*! + Returns the landmark in the database identified by \a landmarkId +*/ +QLandmark QLandmarkManager::landmark(const QLandmarkId &landmarkId) const +{ + Q_D(const QLandmarkManager); + + if (!d->engine) { + return QLandmark(); + } + + d->errorCode = QLandmarkManager::NoError; + d->errorString = ""; + d->errorMap.clear(); + + QLandmark lm = d->engine->landmark(landmarkId, + &(d->errorCode), + &(d->errorString)); + + if (d->errorCode != NoError) + return QLandmark(); + + return lm; +} + +/*! + Returns a list of landmarks which match the given \a filter and are sorted according to the \a sortOrders. + The \a limit defines the maximum number of landmarks to return and the \a offset defines the index offset + of the first landmark. A \a limit of -1 means all matching landmarks should be returned. +*/ +QList<QLandmark> QLandmarkManager::landmarks(const QLandmarkFilter &filter, int limit, int offset, + const QList<QLandmarkSortOrder> &sortOrders) const +{ + Q_D(const QLandmarkManager); + + if (!d->engine) { + return QList<QLandmark>(); + } + + d->errorCode = QLandmarkManager::NoError; + d->errorString = ""; + d->errorMap.clear(); + + QList<QLandmark> lms = d->engine->landmarks(filter, + limit, + offset, + sortOrders, + &(d->errorCode), + &(d->errorString)); + + if (d->errorCode != NoError) + return QList<QLandmark>(); + + return lms; +} + +/*! + Returns a list of landmarks which match the given \a filter and are sorted according to the \a sortOrder. + The \a limit defines the maximum number of landmarks to return and the \a offset defines the index offset + of the first landmark. A \a limit of -1 means all matching landmarks should be returned and that + a limit of 0 will return zero landmarks. +*/ +QList<QLandmark> QLandmarkManager::landmarks(const QLandmarkFilter &filter, int limit, int offset, + const QLandmarkSortOrder &sortOrder) const +{ + Q_D(const QLandmarkManager); + + if (!d->engine) { + return QList<QLandmark>(); + } + + d->errorCode = QLandmarkManager::NoError; + d->errorString = ""; + d->errorMap.clear(); + + QList<QLandmarkSortOrder> sortOrders; + if (sortOrder.type() != QLandmarkSortOrder::NoSort) + sortOrders.append(sortOrder); + + QList<QLandmark> lms = d->engine->landmarks(filter, + limit, + offset, + sortOrders, + &(d->errorCode), + &(d->errorString)); + + if (d->errorCode != NoError) + return QList<QLandmark>(); + + return lms; +} + +/*! + Returns a list of landmarks which match the given \a landmarkIds. + + This batch function will set per-input errors in the QLandmarkManager::errorMap(). + + The QLandmarkManager::error() function will only return \c QLandmarkManager::NoError if + all landmarks were successfully retrieved. + +*/ +QList<QLandmark> QLandmarkManager::landmarks(const QList<QLandmarkId> &landmarkIds) const +{ + Q_D(const QLandmarkManager); + + if (!d->engine) { + return QList<QLandmark>(); + } + + d->errorCode = QLandmarkManager::NoError; + d->errorString = ""; + d->errorMap.clear(); + + QList<QLandmark> lms = d->engine->landmarks(landmarkIds, + &(d->errorMap), + &(d->errorCode), + &(d->errorString)); + return lms; +} + +/*! + Returns a list of landmark identifiers which match the given \a filter and are sorted according to + the given \a sortOrders. The \a limit defines the maximum number of landmark ids to return and the + \a offset defines the index offset of the first landmark id. + A \a limit of -1 means that ids of all matching landmarks should be returned. Note that + a limit of 0 will return zero landmark ids. +*/ +QList<QLandmarkId> QLandmarkManager::landmarkIds(const QLandmarkFilter &filter, + int limit, int offset, + const QList<QLandmarkSortOrder> &sortOrders) const +{ + Q_D(const QLandmarkManager); + + if (!d->engine) { + return QList<QLandmarkId>(); + } + + d->errorCode = QLandmarkManager::NoError; + d->errorString = ""; + d->errorMap.clear(); + + QList<QLandmarkId> ids = d->engine->landmarkIds(filter, + limit, + offset, + sortOrders, + &(d->errorCode), + &(d->errorString)); + + if (d->errorCode != NoError) + return QList<QLandmarkId>(); + + return ids; +} + +/*! + Convenience function to returns a list of landmark identifiers which match the given \a filter and are sorted according to + the given \a sortOrder. The \a limit defines the maximum number of landmark ids to return and the + \a offset defines the index offset of the first landmark id. + A \a limit of -1 means that ids of all matching landmarks should be returned. Note + that a limit of 0 will return zero landmark ids. + + +*/ +QList<QLandmarkId> QLandmarkManager::landmarkIds(const QLandmarkFilter &filter, + int limit, int offset, + const QLandmarkSortOrder &sortOrder) const +{ + Q_D(const QLandmarkManager); + + if (!d->engine) { + return QList<QLandmarkId>(); + } + + d->errorCode = QLandmarkManager::NoError; + d->errorString = ""; + d->errorMap.clear(); + + QList<QLandmarkSortOrder> sortOrders; + sortOrders.append(sortOrder); + + QList<QLandmarkId> ids = d->engine->landmarkIds(filter, + limit, + offset, + sortOrders, + &(d->errorCode), + &(d->errorString)); + + if (d->errorCode != NoError) + return QList<QLandmarkId>(); + + return ids; +} + +/*! + Reads landmarks from the given \a device and saves them. The data from the \a device + is expected to adhere to the provided \a format. If no \a format is provided, + the manager tries to auto detect the \a format. + + The \a option can be used to control whether categories in the imported + file will be added during the import. If the \c AttachSingleCategory option is used, then + all the landmarks in the import file are assigned to the category identified by + \a categoryId, in all other circumstances \a categoryId is ignored. If \a categoryId + doesn't exist when using \c AttachSingleCategory, QLandmarkManager::CategoryDoesNotExistError is set. Note that + some file formats may not support categories at all. + + Returns true if all landmarks could be imported, otherwise + returns false. + +*/ +bool QLandmarkManager::importLandmarks(QIODevice *device, const QString &format, QLandmarkManager::TransferOption option, const QLandmarkCategoryId &categoryId) +{ + Q_D(QLandmarkManager); + + if (!d->engine) { + return false; + } + + d->errorCode = QLandmarkManager::NoError; + d->errorString = ""; + d->errorMap.clear(); + + return d->engine->importLandmarks(device, + format, + option, + categoryId, + &(d->errorCode), + &(d->errorString)); +} + +/*! + Convenience function that will read landmarks from \a fileName in + the expected \a format. If no \a format is provided, the manager tries + to auto detect the \a format. Internally a QFile is opened with + QIODevice::ReadOnly permissions. + + The \a option can be used to control whether categories in the imported + file will be added during the import. If the \c AttachSingleCategory option is used, then + all the landmarks in the import file are assigned to the category identified by + \a categoryId, in all other circumstances \a categoryId is ignored. If \a categoryId + doesn't exist when using \c AttachSingleCategory, QLandmarkManager::CategoryDoesNotExistError is set. Note that + some file formats may not support categories at all. + + Returns true if all landmarks could be imported, otherwise + returns false. +*/ +bool QLandmarkManager::importLandmarks(const QString &fileName, const QString &format, QLandmarkManager::TransferOption option, const QLandmarkCategoryId &categoryId) +{ + QFile file(fileName); + return importLandmarks(&file, format,option,categoryId); +} + +/*! + Writes landmarks to the given \a device. The landmarks will be written + according to the specified \a format. If \a landmarkIds is empty, then + all landmarks will be exported, otherwise only those landmarks that + match \a landmarkIds will be exported. + + The \a option can be used to control whether categories will be exported or not. + Note that the \c AttachSingleCategory option has no meaning during + export and the manager will export as if \a option was \c IncludeCategoryData. + Also, be aware that some file formats may not support categories at all and for + these formats, the \a option is always treated as if it was \c ExcludeCategoryData. + + Returns true if all specified landmarks were successfully exported, + otherwise returns false. It may be possible that only a subset + of landmarks are exported. +*/ +bool QLandmarkManager::exportLandmarks(QIODevice *device, const QString &format, const QList<QLandmarkId> &landmarkIds, QLandmarkManager::TransferOption option) const +{ + Q_D(const QLandmarkManager); + + if (!d->engine) { + return false; + } + + d->errorCode = QLandmarkManager::NoError; + d->errorString = ""; + d->errorMap.clear(); + + return d->engine->exportLandmarks(device, + format, + landmarkIds, + option, + &(d->errorCode), + &(d->errorString)); +} + +/*! + Convenience function that will write landmarks to \a fileName in the expected + \a format. Internally a QFile is opened with QIODevice::WriteOnly permissions. + If \a landmarkIds is empty, then all landmarks will be exported, otherwise + only those landmarks that match \a landmarkIds will be exported. + + The \a option can be used to control whether categories will be exported or not. + Note that the \c AttachSingleCategory option has no meaning during + export and the manager will export as if \a option was \c IncludeCategoryData. + Also, be aware that some file formats may not support categories at all and for + these formats, the \a option is always treated as if it was \c ExcludeCategoryData. + + Returns true if all specified landmarks were successfully exported, + otherwise returns false. It may be possible that only a subset + of landmarks are exported. +*/ +bool QLandmarkManager::exportLandmarks(const QString &fileName, const QString &format, const QList<QLandmarkId> &landmarkIds, QLandmarkManager::TransferOption option) const +{ + QFile file(fileName); + + return exportLandmarks(&file, format,landmarkIds, option); +} + +/*! + Returns the file formats supported for the given transfer \a operation. ie import or export. +*/ +QStringList QLandmarkManager::supportedFormats(QLandmarkManager::TransferOperation operation) const +{ + Q_D(const QLandmarkManager); + + if (!d->engine) { + return QStringList(); + } + + d->errorCode = QLandmarkManager::NoError; + d->errorString = ""; + d->errorMap.clear(); + + return d->engine->supportedFormats(operation, &(d->errorCode), &(d->errorString)); +} + +/*! + Returns the error code of the most recent operation. All functions will modify the error based on whether the + operation successfully or not. +*/ +QLandmarkManager::Error QLandmarkManager::error() const +{ + Q_D(const QLandmarkManager); + return d->errorCode; +} + +/*! + Returns a short human-readable description of the error that occurred + in the most recent operation. The error string is intended to be used + by developers and is not suitable for showing to end users. +*/ +QString QLandmarkManager::errorString() const +{ + Q_D(const QLandmarkManager); + return d->errorString; +} + +/*! +Returns per-input error codes for the most recent operation. This function only +returns meaningful information if the most recent operation was a batch +operation. The keys in the map correspond to the index of the input list. +The error map is only populated for indexes at which an error occurred. +Eg If we saved 5 landmarks and an error occurred at index 3, the error map +will have only a single key for index 3. + +\sa error(), categories(), landmarks(), saveLandmarks(), removeCategory(), removeLandmarks() +*/ +QMap<int, QLandmarkManager::Error> QLandmarkManager::errorMap() const +{ + Q_D(const QLandmarkManager); + return d->errorMap; +} + +/*! + Returns whether the manager supports the given \a feature. +*/ +bool QLandmarkManager::isFeatureSupported(QLandmarkManager::ManagerFeature feature) const +{ + Q_D(const QLandmarkManager); + + if (!d->engine) { + return false; + } + + d->errorCode = QLandmarkManager::NoError; + d->errorString = ""; + d->errorMap.clear(); + + return d->engine->isFeatureSupported(feature, &(d->errorCode), &(d->errorString)); +} + +/*! + Returns the support level the manager provides for the given \a filter. For the case + of intersection and union filters, whether the elements will be individually processed + is dependent on the particular manager implementation. +*/ +QLandmarkManager::SupportLevel QLandmarkManager::filterSupportLevel(const QLandmarkFilter &filter) const +{ + Q_D(const QLandmarkManager); + + if (!d->engine) { + return QLandmarkManager::NoSupport; + } + + d->errorCode = QLandmarkManager::NoError; + d->errorString = ""; + d->errorMap.clear(); + + return d->engine->filterSupportLevel(filter, &(d->errorCode), &(d->errorString)); +} + +/*! + Returns the support level the manager provides for the given \a sortOrder. +*/ +QLandmarkManager::SupportLevel QLandmarkManager::sortOrderSupportLevel(const QLandmarkSortOrder &sortOrder) const +{ + Q_D(const QLandmarkManager); + + if (!d->engine) { + return QLandmarkManager::NoSupport; + } + + d->errorCode = QLandmarkManager::NoError; + d->errorString = ""; + d->errorMap.clear(); + + return d->engine->sortOrderSupportLevel(sortOrder, &(d->errorCode), &(d->errorString)); +} + +/*! + Returns true if the manager is entirely read-only. Meaning + landmarks and categories cannot be added, modified or removed. +*/ +bool QLandmarkManager::isReadOnly() const +{ + Q_D(const QLandmarkManager); + if (!d->engine) { + return true; + } + + d->errorCode = QLandmarkManager::NoError; + d->errorString = ""; + d->errorMap.clear(); + + return d->engine->isReadOnly(&(d->errorCode), &(d->errorString)); +} + +/*! + Returns true if the landmark identified by \a landmarkId + considered read-only by the manager. + + If the \a landmarkId does not refer to an existing landmark, + it is considered writable unless the manager is exclusively read-only. +*/ +bool QLandmarkManager::isReadOnly(const QLandmarkId &landmarkId) const +{ + Q_D(const QLandmarkManager); + if (!d->engine) { + return true; + } + + d->errorCode = QLandmarkManager::NoError; + d->errorString = ""; + d->errorMap.clear(); + + return d->engine->isReadOnly(landmarkId, &(d->errorCode), &(d->errorString)); +} + +/*! + Returns true if the category identified by \a categoryId is + considered read-only by the manager. + + If \a categoryId does not refer to an existing category, + it is considered writable unless the manager is exclusively read-only. +*/ +bool QLandmarkManager::isReadOnly(const QLandmarkCategoryId &categoryId) const +{ + Q_D(const QLandmarkManager); + if (!d->engine) { + return true; + } + + d->errorCode = QLandmarkManager::NoError; + d->errorString = ""; + d->errorMap.clear(); + + return d->engine->isReadOnly(categoryId, &(d->errorCode), &(d->errorString)); +} + +/*! + Returns a list of landmark attribute keys that may be used in a + QLandmarkAttributeFilter. +*/ +QStringList QLandmarkManager::searchableLandmarkAttributeKeys() const +{ + Q_D(const QLandmarkManager); + if (!d->engine) { + return QStringList(); + } + + d->errorCode = QLandmarkManager::NoError; + d->errorString = ""; + d->errorMap.clear(); + + return d->engine->searchableLandmarkAttributeKeys(&(d->errorCode), &(d->errorString)); +} + +/*! + Returns the manager name for this QLandmarkManager. + + The manager name usually takes the format of a reverse domain string. An example + of a manager name is \c com.nokia.qt.landmarks.engines.sqlite +*/ +QString QLandmarkManager::managerName() const +{ + Q_D(const QLandmarkManager); + + if (!d->engine) { + return QString(); + } + + d->errorCode = QLandmarkManager::NoError; + d->errorString = ""; + d->errorMap.clear(); + return d->engine->managerName(); +} + +/*! + Return the parameters relevant to the creation of this QLandmarkManager. + + The parameters may be viewed as a set of key-value pairs. Each manager + may have a different set of parameters depending upon its backend implementation. +*/ +QMap<QString, QString> QLandmarkManager::managerParameters() const +{ + Q_D(const QLandmarkManager); + + if (!d->engine) { + return QMap<QString, QString>(); + } + + d->errorCode = QLandmarkManager::NoError; + d->errorString = ""; + d->errorMap.clear(); + return d->engine->managerParameters(); +} + +/*! + Return the uri describing this QLandmarkManager, consisting of the manager name and any parameters. + */ +QString QLandmarkManager::managerUri() const +{ + Q_D(const QLandmarkManager); + + if (!d->engine) { + return QString(); + } + + d->errorCode = QLandmarkManager::NoError; + d->errorString = ""; + d->errorMap.clear(); + return d->engine->managerUri(); +} + +/*! + Returns the engine backend implementation version number. +*/ +int QLandmarkManager::managerVersion() const +{ + Q_D(const QLandmarkManager); + + if (!d->engine) { + return 0; + } + + d->errorCode = QLandmarkManager::NoError; + d->errorString = ""; + d->errorMap.clear(); + return d->engine->managerVersion(); +} + +/*! + Returns a list of available manager names that can + be used when constructing a QLandmarkManager +*/ +QStringList QLandmarkManager::availableManagers() +{ + return QLandmarkManagerPrivate::factories().keys(); +} + +/*! Returns a URI that completely describes a manager implementation/datastore, + and the parameters with which to instantiate the manager, + from the given \a managerName, \a params and an optional \a implementationVersion */ +QString QLandmarkManager::buildUri(const QString& managerName, const QMap<QString, QString>& params, int implementationVersion) +{ + QString ret(QLatin1String("qtlandmarks:%1:%2")); + // we have to escape each param + QStringList escapedParams; + QStringList keys = params.keys(); + for (int i=0; i < keys.size(); i++) { + QString key = keys.at(i); + QString arg = params.value(key); + arg = arg.replace(QLatin1Char('&'), QLatin1String("&")); + arg = arg.replace(QLatin1Char('='), QLatin1String("&equ;")); + key = key.replace(QLatin1Char('&'), QLatin1String("&")); + key = key.replace(QLatin1Char('='), QLatin1String("&equ;")); + key = key + QLatin1Char('=') + arg; + escapedParams.append(key); + } + + if (implementationVersion != -1) { + QString versionString = QString(QLatin1String(QTLANDMARKS_IMPLEMENTATION_VERSION_NAME)); + versionString += QString::fromAscii("="); + versionString += QString::number(implementationVersion); + escapedParams.append(versionString); + } + + return ret.arg(managerName, escapedParams.join(QLatin1String("&"))); +} + +/*! + Constructs a QLandmarkManager whose implementation, store and parameters are specified in the given \a storeUri, + and whose parent object is \a parent. + */ +QLandmarkManager* QLandmarkManager::fromUri(const QString& storeUri, QObject* parent) +{ + if (storeUri.isEmpty()) { + return new QLandmarkManager(QString(), QMap<QString, QString>(), parent); + } else { + QString id; + QMap<QString, QString> parameters; + if (parseUri(storeUri, &id, ¶meters)) { + return new QLandmarkManager(id, parameters, parent); + } else { + // invalid + return NULL; + } + } +} + +/*! + Splits the given \a uri into the manager name and parameters that it describes, and places the information + into the memory addressed by \a pManagerName and \a pParams respectively. Returns true if \a uri could be split successfully, + otherwise returns false + */ +bool QLandmarkManager::parseUri(const QString& uri, QString* pManagerName, QMap<QString, QString>* pParams) +{ + // Format: qtlandmarks:<managerid>:<key>=<value>&<key>=<value> + // - it is assumed the prefix(qtlandmarks) and managerid cannot contain ':' + // - it is assumed keys and values do not contain '=' or '&' + // but can contain & and &equ; + QStringList colonSplit = uri.split(QLatin1Char(':')); + QString prefix = colonSplit.value(0); + + if (prefix != QLatin1String("qtlandmarks")) + return false; + + QString managerName = colonSplit.value(1); + + if (managerName.trimmed().isEmpty()) + return false; + + QString firstParts = prefix + QLatin1Char(':') + managerName + QLatin1Char(':'); + QString paramString = uri.mid(firstParts.length()); + + QMap<QString, QString> outParams; + + // Now we have to decode each parameter + if (!paramString.isEmpty()) { + QStringList params = paramString.split(QRegExp(QLatin1String("&(?!(amp;|equ;))")), QString::KeepEmptyParts); + // If we have an empty string for paramstring, we get one entry in params, + // so skip that case. + for(int i = 0; i < params.count(); i++) { + /* This should be something like "foo&bar&equ;=grob&" */ + QStringList paramChunk = params.value(i).split(QLatin1String("="), QString::KeepEmptyParts); + + if (paramChunk.count() != 2) + return false; + + QString arg = paramChunk.value(0); + QString param = paramChunk.value(1); + arg.replace(QLatin1String("&equ;"), QLatin1String("=")); + arg.replace(QLatin1String("&"), QLatin1String("&")); + param.replace(QLatin1String("&equ;"), QLatin1String("=")); + param.replace(QLatin1String("&"), QLatin1String("&")); + if (arg.isEmpty()) + return false; + outParams.insert(arg, param); + } + } + + if (pParams) + *pParams = outParams; + if (pManagerName) + *pManagerName = managerName; + return true; +} + +/*! + \internal +*/ +void QLandmarkManager::connectNotify(const char *signal) +{ + + if (!d_ptr->isConnected) { + if (d_ptr->engine) { + if (QLatin1String(signal) == SIGNAL(landmarksAdded(QList<QLandmarkId>)) + || (QLatin1String(signal) == SIGNAL(landmarksChanged(QList<QLandmarkId>))) + || (QLatin1String(signal) == SIGNAL(landmarksRemoved(QList<QLandmarkId>))) + || (QLatin1String(signal) == SIGNAL(landmarksChanged(QList<QLandmarkId>))) + || (QLatin1String(signal) == SIGNAL(categoriesAdded(QList<QLandmarkCategoryId>))) + || (QLatin1String(signal) == SIGNAL(categoriesChanged(QList<QLandmarkCategoryId>))) + || (QLatin1String(signal) == SIGNAL(categoriesRemoved(QList<QLandmarkCategoryId>))) + || (QLatin1String(signal) == SIGNAL(dataChanged()))) { + connect(d_ptr->engine,SIGNAL(landmarksAdded(QList<QLandmarkId>)), + this, SIGNAL(landmarksAdded(QList<QLandmarkId>))); + connect(d_ptr->engine,SIGNAL(landmarksChanged(QList<QLandmarkId>)), + this, SIGNAL(landmarksChanged(QList<QLandmarkId>))); + connect(d_ptr->engine,SIGNAL(landmarksRemoved(QList<QLandmarkId>)), + this, SIGNAL(landmarksRemoved(QList<QLandmarkId>))); + connect(d_ptr->engine,SIGNAL(categoriesAdded(QList<QLandmarkCategoryId>)), + this, SIGNAL(categoriesAdded(QList<QLandmarkCategoryId>))); + connect(d_ptr->engine,SIGNAL(categoriesChanged(QList<QLandmarkCategoryId>)), + this, SIGNAL(categoriesChanged(QList<QLandmarkCategoryId>))); + connect(d_ptr->engine,SIGNAL(categoriesRemoved(QList<QLandmarkCategoryId>)), + this, SIGNAL(categoriesRemoved(QList<QLandmarkCategoryId>))); + connect(d_ptr->engine,SIGNAL(dataChanged()), + this, SIGNAL(dataChanged())); + d_ptr->isConnected = true; + } + } + } + QObject::connectNotify(signal); +} + +/*! + \internal +*/ +void QLandmarkManager::disconnectNotify(const char *signal) +{ + if (d_ptr->isConnected) { + if (d_ptr->engine) { + if ((QLatin1String(signal) == SIGNAL(landmarksAdded(QList<QLandmarkId>))) + || (QLatin1String(signal) == SIGNAL(landmarksChanged(QList<QLandmarkId>))) + || (QLatin1String(signal) == SIGNAL(landmarksRemoved(QList<QLandmarkId>))) + || (QLatin1String(signal) == SIGNAL(categoriesAdded(QList<QLandmarkCategoryId>))) + || (QLatin1String(signal) == SIGNAL(categoriesChanged(QList<QLandmarkCategoryId>))) + || (QLatin1String(signal) == SIGNAL(categoriesRemoved(QList<QLandmarkCategoryId>))) + || (QLatin1String(signal) == SIGNAL(dataChanged()))) { + disconnect(d_ptr->engine,SIGNAL(landmarksAdded(QList<QLandmarkId>)), + this, SIGNAL(landmarksAdded(QList<QLandmarkId>))); + disconnect(d_ptr->engine,SIGNAL(landmarksChanged(QList<QLandmarkId>)), + this, SIGNAL(landmarksChanged(QList<QLandmarkId>))); + disconnect(d_ptr->engine,SIGNAL(landmarksRemoved(QList<QLandmarkId>)), + this, SIGNAL(landmarksRemoved(QList<QLandmarkId>))); + disconnect(d_ptr->engine,SIGNAL(categoriesAdded(QList<QLandmarkCategoryId>)), + this, SIGNAL(categoriesAdded(QList<QLandmarkCategoryId>))); + disconnect(d_ptr->engine,SIGNAL(categoriesChanged(QList<QLandmarkCategoryId>)), + this, SIGNAL(categoriesChanged(QList<QLandmarkCategoryId>))); + disconnect(d_ptr->engine,SIGNAL(categoriesRemoved(QList<QLandmarkCategoryId>)), + this, SIGNAL(categoriesRemoved(QList<QLandmarkCategoryId>))); + disconnect(d_ptr->engine,SIGNAL(dataChanged()), + this, SIGNAL(dataChanged())); + d_ptr->isConnected = false; + } + } + } + QObject::disconnectNotify(signal); +} + +QLandmarkManagerEngine *QLandmarkManager::engine() +{ + return d_ptr->engine; +} + +/*! + \fn QLandmarkManager::dataChanged() + This signal is emitted by the manager if its internal state changes and it is unable to precisely determine + the changes which occurred, or if the manager considers the changes to be radical enough to require clients to reload + all data. If the signal is emitted, no other signals will be emitted for the associated changes. +*/ + +/*! + \fn void QLandmarkManager::landmarksAdded(const QList<QLandmarkId> &landmarkIds) + + This signal is emitted when landmarks (identified by \a landmarkIds) have been added to the datastore managed by this manager. + This signal is not emitted if the dataChanged() signal was previously emitted for these changes. + \sa landmarksChanged(), landmarksRemoved() +*/ + +/*! + \fn void QLandmarkManager::landmarksChanged(const QList<QLandmarkId> &landmarkIds) + + This signal is emitted when landmarks (identified by \a landmarkIds) have been modified in the datastore managed by this manager. + This signal is not emitted if the dataChanged() signal was previously emitted for these changes. Note that removal + of a category will not trigger a \c landmarksChanged signal for landmarks belonging to that category. + + \sa landmarksAdded(), landmarksRemoved() +*/ + +/*! + \fn void QLandmarkManager::landmarksRemoved(const QList<QLandmarkId> &landmarkIds) + + This signal is emitted when landmarks (identified by \a landmarkIds) have been removed from the datastore managed by this manager. + This signal is not emitted if the dataChanged() signal was previously emitted for these changes. + \sa landmarksAdded(), landmarksChanged() +*/ + +/*! + \fn void QLandmarkManager::categoriesAdded(const QList<QLandmarkCategoryId> &categoryIds) + + This signal is emitted when categories (identified by \a categoryIds) have been added to the datastore managed by this manager. + This signal is not emitted if the dataChanged() signal was previously emitted for these changes. + \sa categoriesChanged(), categoriesRemoved() +*/ + +/*! + \fn void QLandmarkManager::categoriesChanged(const QList<QLandmarkCategoryId> &categoryIds) + + This signal is emitted when categories (identified by \a categoryIds) have been modified in the datastore managed by this manager. + This signal is not emitted if the dataChanged() signal was previously emitted for these changes. + \sa categoriesAdded(), categoriesRemoved() +*/ + +/*! + \fn void QLandmarkManager::categoriesRemoved(const QList<QLandmarkCategoryId> &categoryIds) + + This signal is emitted when categories (identified by \a categoryIds) have been removed from the datastore managed by this manager. + This signal is not emitted if the dataChanged() signal was previously emitted for these changes. + \sa categoriesAdded(), categoriesChanged() +*/ + +#include "moc_qlandmarkmanager.cpp" diff --git a/src/location/landmarks/qlandmarkmanager.h b/src/location/landmarks/qlandmarkmanager.h new file mode 100644 index 00000000..13a9f08f --- /dev/null +++ b/src/location/landmarks/qlandmarkmanager.h @@ -0,0 +1,220 @@ +/**************************************************************************** +** +** Copyright (C) 2009 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 QLANDMARKMANAGER_H +#define QLANDMARKMANAGER_H + +#include "qmobilityglobal.h" +#include "qlandmarkid.h" +#include "qlandmarkfilter.h" +#include "qlandmarksortorder.h" +#include "qlandmarkcategoryid.h" +#include "qlandmarknamesort.h" +#include "qlandmarkfilter.h" +#include "qlandmarkcategory.h" +#include "qlandmark.h" + +#include <qlatin1constant.h> +#include <QObject> +#include <QMap> +class QIODevice; +class QStringList; + +QTM_BEGIN_NAMESPACE +class QLandmarkManagerPrivate; +class QLandmarkManagerEngine; + +class Q_LOCATION_EXPORT QLandmarkManager: public QObject +{ + Q_OBJECT +public: + enum Error { + NoError = 0, + DoesNotExistError, + LandmarkDoesNotExistError, + CategoryDoesNotExistError, + AlreadyExistsError, + LockedError, + PermissionsError, + OutOfMemoryError, + VersionMismatchError, + NotSupportedError, + BadArgumentError, + InvalidManagerError, + ParsingError, + CancelError, + UnknownError, + }; + + enum SupportLevel { + NativeSupport, + EmulatedSupport, + NoSupport + }; + + enum ManagerFeature { + ImportExportFeature, + NotificationsFeature + }; + + + enum TransferOption { + IncludeCategoryData, + ExcludeCategoryData, + AttachSingleCategory + }; + + enum TransferOperation { + ImportOperation, + ExportOperation + }; + +#ifdef Q_QDOC + static const QLatin1Constant Gpx; + static const QLatin1Constant Lmx; + static const QLatin1Constant Kml; + static const QLatin1Constant Kmz; +#else + Q_DECLARE_LATIN1_CONSTANT(Gpx, "Gpx"); + Q_DECLARE_LATIN1_CONSTANT(Lmx, "Lmx"); + Q_DECLARE_LATIN1_CONSTANT(Kml, "Kml"); + Q_DECLARE_LATIN1_CONSTANT(Kmz, "Kmz"); +#endif + +#ifdef Q_QDOC + QLandmarkManager(QObject *parent = 0); + QLandmarkManager(const QString &managerName, const QMap<QString, QString> ¶meters = 0, QObject *parent = 0); +#else + QLandmarkManager(QObject *parent = 0); + QLandmarkManager(const QString &managerName, const QMap<QString, QString>& parameters = (QMap<QString, QString>()), QObject *parent = 0); +#endif + virtual ~QLandmarkManager(); + + bool saveLandmark(QLandmark *landmark); + bool saveLandmarks(QList<QLandmark> *landmarks); + + bool removeLandmark(const QLandmarkId &landmarkId); + bool removeLandmark(const QLandmark &landmark); + + bool removeLandmarks(const QList<QLandmarkId> &landmarksIds); + bool removeLandmarks(const QList<QLandmark> &landmarks); + + bool saveCategory(QLandmarkCategory *category); + bool removeCategory(const QLandmarkCategoryId &categoryId); + bool removeCategory(const QLandmarkCategory &category); + + QLandmarkCategory category(const QLandmarkCategoryId &categoryId) const; + QList<QLandmarkCategory> categories(const QList<QLandmarkCategoryId> &categoryIds) const; + + QList<QLandmarkCategory> categories( int limit=-1, int offset=0, const QLandmarkNameSort &nameSort = QLandmarkNameSort()) const; + QList<QLandmarkCategoryId> categoryIds(int limit =-1, int offset=0, const QLandmarkNameSort &nameSort = QLandmarkNameSort()) const; + + QLandmark landmark(const QLandmarkId &landmarkId) const; + QList<QLandmark> landmarks(const QLandmarkFilter &filter, + int limit, int offset, + const QList<QLandmarkSortOrder>& sortOrders) const; + QList<QLandmark> landmarks(const QLandmarkFilter &filter = QLandmarkFilter(), + int limit=-1, int offset=0, + const QLandmarkSortOrder &sortOrder = QLandmarkSortOrder()) const; + + QList<QLandmark> landmarks(const QList<QLandmarkId> &landmarkIds) const; + QList<QLandmarkId> landmarkIds(const QLandmarkFilter &filter, + int limit, int offset, + const QList<QLandmarkSortOrder> &sortOrders)const; + QList<QLandmarkId> landmarkIds(const QLandmarkFilter &filter = QLandmarkFilter(), + int limit=-1, int offset =0, + const QLandmarkSortOrder &sortOrder = QLandmarkSortOrder()) const; + + bool importLandmarks(QIODevice *device, const QString &format= QString() ,QLandmarkManager::TransferOption option = IncludeCategoryData, const QLandmarkCategoryId& = QLandmarkCategoryId()); + bool importLandmarks(const QString &fileName, const QString &format = QString(),QLandmarkManager::TransferOption option = IncludeCategoryData, const QLandmarkCategoryId& = QLandmarkCategoryId()); + bool exportLandmarks(QIODevice *device, const QString &format, const QList<QLandmarkId> &landmarkIds = QList<QLandmarkId>(), QLandmarkManager::TransferOption option = IncludeCategoryData) const; + bool exportLandmarks(const QString &, const QString &format, const QList<QLandmarkId> &landmarkIds = QList<QLandmarkId>(), QLandmarkManager::TransferOption option = IncludeCategoryData) const; + + QStringList supportedFormats(TransferOperation operation) const; + + Error error() const; + QString errorString() const; + QMap<int, QLandmarkManager::Error> errorMap() const; + + bool isFeatureSupported(ManagerFeature feature) const; + SupportLevel filterSupportLevel(const QLandmarkFilter &filter) const; + SupportLevel sortOrderSupportLevel(const QLandmarkSortOrder &sortOrder) const; + + bool isReadOnly() const; + bool isReadOnly(const QLandmarkId &id) const; + bool isReadOnly(const QLandmarkCategoryId &id) const; + + QStringList searchableLandmarkAttributeKeys() const; + + QString managerName() const; + QMap<QString, QString> managerParameters() const; + QString managerUri() const; + int managerVersion() const; + + static QStringList availableManagers(); + static QString buildUri(const QString& managerName, const QMap<QString, QString>& params,int implementationVersion = -1); + static QLandmarkManager* fromUri(const QString& uri, QObject* parent = 0); + static bool parseUri(const QString& uri, QString* managerName, QMap<QString, QString>* params); + +Q_SIGNALS: + void dataChanged(); + void landmarksAdded(const QList<QLandmarkId> &landmarkIds); + void landmarksChanged(const QList<QLandmarkId> &landmarkIds); + void landmarksRemoved(const QList<QLandmarkId> &landmarkIds); + + void categoriesAdded(const QList<QLandmarkCategoryId> &categoryIds); + void categoriesChanged(const QList<QLandmarkCategoryId> &categoryIds); + void categoriesRemoved(const QList<QLandmarkCategoryId> &categoryIds); + +protected: + void connectNotify(const char *signal); + void disconnectNotify(const char *signal); + +private: + QLandmarkManagerPrivate *d_ptr; + Q_DECLARE_PRIVATE(QLandmarkManager) + friend class QLandmarkAbstractRequest; + QLandmarkManagerEngine *engine(); +}; + +QTM_END_NAMESPACE + +#endif diff --git a/src/location/landmarks/qlandmarkmanager_p.cpp b/src/location/landmarks/qlandmarkmanager_p.cpp new file mode 100644 index 00000000..1b9bb613 --- /dev/null +++ b/src/location/landmarks/qlandmarkmanager_p.cpp @@ -0,0 +1,171 @@ +/**************************************************************************** +** +** Copyright (C) 2009 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 "qlandmarkmanager_p.h" +#include "qlandmarkmanagerengine.h" +#include "qlandmarkmanagerenginefactory.h" +#include <QPluginLoader> +#include <QDebug> +#include <QStringList> +#include <QCoreApplication> +#include <QObject> +#include <QProcess> +#include <QEventLoop> + +#include "qmobilitypluginsearch.h" + +QTM_USE_NAMESPACE + +QLandmarkManagerPrivate::QLandmarkManagerPrivate() + : engine(0), + errorCode(QLandmarkManager::NoError), + isConnected(false), + q_ptr(0) +{ +} + +void QLandmarkManagerPrivate::createEngine(const QString &managerName, const QMap<QString,QString> ¶meters) +{ + Q_Q(QLandmarkManager); + + if (!q->availableManagers().contains(managerName)) { + errorCode = QLandmarkManager::InvalidManagerError; + errorString = QString("The landmark manager, %1, was not found").arg(managerName); + qWarning() << errorString; + engine = 0; + return; + } + + QList<QLandmarkManagerEngineFactory *> factories = QLandmarkManagerPrivate::factories().values(managerName); + + bool ok; + int implementationVersion = parameters.value(QTLANDMARKS_IMPLEMENTATION_VERSION_NAME).toInt(&ok); + if (!ok) + implementationVersion = -1; + + foreach(QLandmarkManagerEngineFactory *f, factories) + { + QList<int> versions = f->supportedImplementationVersions(); + if (implementationVersion == -1 //no given implementation version required + || versions.isEmpty() //manager engine factory does not report any versions + || versions.contains(implementationVersion)) { + engine = f->engine(parameters, &errorCode, &errorString); + break; + } + } + + if (!engine) { + if (errorCode == QLandmarkManager::NoError) { + errorCode = QLandmarkManager::InvalidManagerError; + errorString = "The landmark manager could not return the requested engine instance"; + } + } +} + +QLandmarkManagerEngine* QLandmarkManagerPrivate::getEngine(const QLandmarkManager* manager) +{ + if (manager) + return manager->d_ptr->engine; + return 0; +} + + QHash<QString, QLandmarkManagerEngineFactory*> QLandmarkManagerPrivate::factories(bool reload) + { + static QHash<QString, QLandmarkManagerEngineFactory*> factories; + static bool alreadyDiscovered = false; + + if (reload == true) + alreadyDiscovered = false; + + if (!alreadyDiscovered) { + loadStaticFactories(&factories); + loadDynamicFactories(&factories); + alreadyDiscovered = true; + } + return factories; + } + +void QLandmarkManagerPrivate::loadDynamicFactories(QHash<QString, QLandmarkManagerEngineFactory*> *factories) +{ + QStringList paths; + paths << mobilityPlugins(QLatin1String("landmarks")); + + QPluginLoader qpl; + for (int i=0;i < paths.count(); ++i) { + qpl.setFileName(paths.at(i)); + + QLandmarkManagerEngineFactory *f = qobject_cast<QLandmarkManagerEngineFactory*>(qpl.instance()); + if (f) { + QString name = f->managerName(); + +#if !defined QT_NO_DEBUG + const bool showDebug = qgetenv("QT_DEBUG_PLUGINS").toInt() > 0; + if (showDebug) + qDebug() << "Dynamic: found an engine plugin with name" << name; +#endif + factories->insertMulti(name,f); + } + } +} + +void QLandmarkManagerPrivate::loadStaticFactories(QHash<QString, QLandmarkManagerEngineFactory*> *factories) +{ +#if !defined QT_NO_DEBUG + const bool showDebug = qgetenv("QT_DEBUG_PLUGINS").toInt() > 0; +#endif + + QObjectList staticPlugins = QPluginLoader::staticInstances(); + for(int i=0; i < staticPlugins.count(); ++i) { + QLandmarkManagerEngineFactory *f = qobject_cast<QLandmarkManagerEngineFactory*>(staticPlugins.at(i)); + if (f){ + QString name = f->managerName(); + +#if !defined QT_NO_DEBUG + if (showDebug) + qDebug() << "Static: found an engine plugin with name" << name; +#endif + if(!name.isEmpty()) { + factories->insertMulti(name, f); + } + } + + } +} diff --git a/src/location/landmarks/qlandmarkmanager_p.h b/src/location/landmarks/qlandmarkmanager_p.h new file mode 100644 index 00000000..8d4b3d01 --- /dev/null +++ b/src/location/landmarks/qlandmarkmanager_p.h @@ -0,0 +1,92 @@ +/**************************************************************************** +** +** Copyright (C) 2009 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 QLANDMARKMANAGER_P_H +#define QLANDMARKMANAGER_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 "qmobilityglobal.h" +#include "qlandmarkmanager.h" +#include <QHash> +#include <QString> +#include <QMap> + +#define QTLANDMARKS_IMPLEMENTATION_VERSION_NAME "com.nokia.qtmobility.landmarks.implementation.version" + +QTM_BEGIN_NAMESPACE + +class QLandmarkManagerEngine; +class QLandmarkManagerEngineFactory; + +class QLandmarkManagerPrivate +{ +public: + QLandmarkManagerPrivate(); + void createEngine(const QString &managerName, const QMap<QString,QString> ¶meters = (QMap<QString, QString>())); + + QLandmarkManagerEngine *engine; + mutable QLandmarkManager::Error errorCode; + mutable QString errorString; + mutable QMap<int, QLandmarkManager::Error> errorMap; + static QLandmarkManagerEngine *getEngine(const QLandmarkManager* manager); + static void loadFactories(); + static QHash<QString, QLandmarkManagerEngineFactory*> factories(bool reload = false); + static void loadDynamicFactories (QHash<QString, QLandmarkManagerEngineFactory*> *factories); + static void loadStaticFactories (QHash<QString, QLandmarkManagerEngineFactory*> *factories); + bool isConnected;//identifies whether connections have been made to the notification signals + + QLandmarkManager *q_ptr; + Q_DECLARE_PUBLIC(QLandmarkManager) +}; + +QTM_END_NAMESPACE + +#endif // QLANDMARKMANAGER_P_H diff --git a/src/location/landmarks/qlandmarkmanagerengine.cpp b/src/location/landmarks/qlandmarkmanagerengine.cpp new file mode 100644 index 00000000..41bb7dbe --- /dev/null +++ b/src/location/landmarks/qlandmarkmanagerengine.cpp @@ -0,0 +1,1389 @@ +/**************************************************************************** +** +** Copyright (C) 2009 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 "qlandmarkmanagerengine.h" +#include "qlandmark.h" +#include "qlandmarkcategory.h" +#include "qlandmarkid.h" +#include "qlandmarkcategoryid.h" + +#include "qlandmarkrequests_p.h" +#include "qlandmark_p.h" +#include "qlandmarkcategory_p.h" + +#include "qlandmarkabstractrequest.h" +#include "qlandmarkidfetchrequest.h" +#include "qlandmarkfetchrequest.h" +#include "qlandmarkfetchbyidrequest.h" +#include "qlandmarkremoverequest.h" +#include "qlandmarksaverequest.h" +#include "qlandmarkcategoryidfetchrequest.h" +#include "qlandmarkcategoryfetchrequest.h" +#include "qlandmarkcategoryfetchbyidrequest.h" +#include "qlandmarkcategoryremoverequest.h" +#include "qlandmarkcategorysaverequest.h" +#include "qlandmarkimportrequest.h" +#include "qlandmarkexportrequest.h" + +#include "qlandmarknamesort.h" + +#include "qlandmarkattributefilter.h" +#include "qlandmarkboxfilter.h" +#include "qlandmarkcategoryfilter.h" +#include "qlandmarkintersectionfilter.h" +#include "qlandmarkidfilter.h" +#include "qlandmarknamefilter.h" +#include "qlandmarkproximityfilter.h" +#include "qlandmarkunionfilter.h" + +#include "qgeocoordinate.h" + +#include <QWeakPointer> + +QTM_BEGIN_NAMESPACE + +bool matchString(const QString &sourceString, const QString &matchString, QLandmarkFilter::MatchFlags matchFlags ) +{ + Qt::CaseSensitivity cs; + if (matchFlags & QLandmarkFilter::MatchCaseSensitive) + cs = Qt::CaseSensitive; + else + cs = Qt::CaseInsensitive; + if ((matchFlags & 3) == QLandmarkFilter::MatchEndsWith) { + return sourceString.endsWith(matchString, cs); + } else if ((matchFlags & 3) == QLandmarkFilter::MatchStartsWith) { + return sourceString.startsWith(matchString, cs); + } else if ((matchFlags & 3) == QLandmarkFilter::MatchContains) { + return sourceString.contains(matchString,cs); + } else if (matchFlags & QLandmarkFilter::MatchFixedString) { + return sourceString.compare(matchString,cs) == 0; + } else { + return QVariant(sourceString) == QVariant(matchString); + } +} + +QVariant getLandmarkAttribute(const QString key, const QLandmark &landmark) +{ + if (key == "name") { + return landmark.name(); + } else if (key == "description") { + return landmark.description(); + } else if (key == "countryCode") { + return landmark.address().countryCode(); + } else if (key == "country") { + return landmark.address().country(); + } else if (key == "state") { + return landmark.address().state(); + } else if (key == "city") { + return landmark.address().city(); + } else if (key == "district") { + return landmark.address().district(); + } else if (key == "district") { + return landmark.address().district(); + } else if (key == "street") { + return landmark.address().street(); + } else if (key == "postcode") { + return landmark.address().postcode(); + } else if (key == "phoneNumber") { + return landmark.phoneNumber(); + } else { + return QVariant(); // shouldn't be possible + } +} + +QStringList commonLandmarkKeys = QStringList() << "name" + << "description" + << "countryCode" + << "country" + << "state" + << "county" + << "city" + << "district" + << "street" + << "postcode" + << "phoneNumber"; + +/*! + \class QLandmarkManagerEngine + \brief The QLandmarkManagerEngine class provides the interface for all implementations + of the landmark manager backend functionality. + + \inmodule QtLocation + \since 1.1 + + \ingroup landmarks-backend + + Instances of this class are usually provided by \l QLandmarkManagerEngineFactory, which is loaded + from a plugin. +*/ + +/*! + Constructs a landmark manager engine. +*/ +QLandmarkManagerEngine::QLandmarkManagerEngine() +{ +} + +/*! + Destructor. +*/ +QLandmarkManagerEngine::~QLandmarkManagerEngine() +{ +} + +/*! Returns the manager name for this QLandmarkManagerEngine */ +QString QLandmarkManagerEngine::managerName() const +{ + return QString(QLatin1String("base")); +} + +/*! + Returns the parameters with which this engine was constructed. Note that + the engine may have discarded unused or invalid parameters at the time of + construction, and these will not be returned. + */ +QMap<QString, QString> QLandmarkManagerEngine::managerParameters() const +{ + return QMap<QString, QString>(); // default implementation requires no parameters. +} + +/*! + Returns the unique URI of this manager, which is built from the manager name and the parameters + used to construct it. + */ +QString QLandmarkManagerEngine::managerUri() const +{ + return QLandmarkManager::buildUri(managerName(), managerParameters(), managerVersion()); +} + +/*! + Returns the engine backend implementation version number + */ +int QLandmarkManagerEngine::managerVersion() const +{ + return 0; +} + +/*! + Returns a list of landmark identifiers which match the given \a filter and are sorted according to + the given \a sortOrders. The \a limit defines the maximum number of landmark IDs to return and the + \a offset defines the index offset of the first landmark ID. + A \a limit of -1 means that IDs of all matching landmarks should be returned. + + Any error which occurs will be saved in \a error and \a errorString. + */ +QList<QLandmarkId> QLandmarkManagerEngine::landmarkIds(const QLandmarkFilter& /*filter*/, + int /*limit*/, int /*offset*/, const QList<QLandmarkSortOrder>& /*sortOrders*/, QLandmarkManager::Error* /*error*/, + QString */* errorString */) const +{ + return QList<QLandmarkId>(); +} + +/*! + Returns a list of category identifiers + The \a limit defines the maximum number of IDs to return and the \a offset defines the index offset + of the first ID. A \a limit of -1 means IDs for all categories should be returned. + Any error which occurs will be saved in \a error and \a errorString. + The identifiers are returned in order according to the given \a nameSort. +*/ +QList<QLandmarkCategoryId> QLandmarkManagerEngine::categoryIds(int /*limit*/, int /*offset*/, const QLandmarkNameSort& /*nameSort*/, QLandmarkManager::Error* /*error*/, + QString* /*errorString*/) const +{ + return QList<QLandmarkCategoryId>(); +} + +/*! + Returns the landmark in the datastore identified by \a landmarkId. + + Any errors encountered are:stored in \a error and \a errorString. + The \a error is set to QLandmarkManager::LandmarkDoesNotExistError if the landmark could not be found. +*/ +QLandmark QLandmarkManagerEngine::landmark(const QLandmarkId &/*landmarkId*/, QLandmarkManager::Error * /*error*/, + QString* /*errorString*/) const +{ + return QLandmark(); +} + +/*! + Returns a list of landmarks which match the given \a landmarkIds. The engine will populate \a errorMap + (the map of indices of the \a landmarkIds list to errors) for the indexes where the landmark could not + be retrieved. + + Overall operation errors are stored in \a error and + \a errorString. \a error is set to QLandmarkManager::NoError, + all landmarks were successfully retrieved. +*/ +QList<QLandmark> QLandmarkManagerEngine::landmarks(const QList<QLandmarkId>& /*landmarkIds*/, QMap<int, QLandmarkManager::Error>* /*errorMap*/, + QLandmarkManager::Error* /*error*/, QString* /*errorString*/) const +{ + return QList<QLandmark>(); +} + +/*! + Returns a list of landmarks which match the given \a filter and are sorted according to the \a sortOrders. + The \a limit defines the maximum number of landmarks to return and the \a offset defines the index offset + of the first landmark. A \a limit of -1 means all matching landmarks should be returned. + + Overall operation errors are stored in \a error and \a errorString. +*/ +QList<QLandmark> QLandmarkManagerEngine::landmarks(const QLandmarkFilter& /*filter*/, int /*limit*/, int /*offset*/, + const QList<QLandmarkSortOrder>& /*sortOrders*/, QLandmarkManager::Error* /*error*/, QString* /*errorString*/) const +{ + return QList<QLandmark>(); +} + +/*! + Returns the category in the datastore identified by \a categoryId. + + Any errors encountered are stored in \a error and \a errorString. + A QLandmarkManager::CategoryDoesNotExist error is set if the category could not be found. +*/ +QLandmarkCategory QLandmarkManagerEngine::category(const QLandmarkCategoryId& /*categoryId*/, + QLandmarkManager::Error* /*error*/, QString* /*errorString*/) const +{ + return QLandmarkCategory(); +} + +/*! + Returns a list of categories which match the given \a categoryIds. The engine will populate \a errorMap + (the map of indices of the \a categoryIds list to errors) for the indexes where the category could not + be retrieved. + + Overall operation errors are stored in \a error and + \a errorString. \a error is set to QLandmarkManager::NoError, if + all categories were successfully retrieved. +*/ +QList<QLandmarkCategory> QLandmarkManagerEngine::categories(const QList<QLandmarkCategoryId>& /*categoryIds*/, + QMap<int, QLandmarkManager::Error>* /*errorMap*/, + QLandmarkManager::Error* /*error*/, QString* /*errorString*/) const +{ + return QList<QLandmarkCategory>(); +} + +/*! + Returns a list of categories. + The \a limit defines the maximum number of categories to return and the \a offset defines the index offset + of the first category. A \a limit of -1 means all categories should be returned. + The returned categories ordered according to the gien \a nameSort. +*/ +QList<QLandmarkCategory> QLandmarkManagerEngine::categories(int /*limit*/, int /*offset*/, const QLandmarkNameSort& /*nameSort*/, + QLandmarkManager::Error* /*error*/, QString* /*errorString*/) const +{ + return QList<QLandmarkCategory>(); +} + +/*! + Adds the given \a landmark to the datastore if \a landmark has a + default-constructed identifer, or an identifier with the manager + URI set to the URI of this manager and an empty id. + + If the manager URI of the identifier of the \a landmark is neither + empty nor equal to the URI of this manager, or the id member of the + identifier is not empty, but does not exist in the manager, + the operation will fail and and \a error will be set to + \c QLandmarkManager::LandmarkDoesNotExistError. + + Alternatively, the function will update the existing landmark in the + datastore if \a landmark has a non-empty id and currently exists + within the datastore. + + Returns false on failure or true on success. On successful save + of a landmark with an empty id, it will be assigned a valid + id and have its manager URI set to the URI of this manager. + + The engine must emit the appropriate signals to inform clients of changes + to the datastore resulting from this operation. + + Any errors encountered during this operation should be stored in + \a error and \a errorString. +*/ +bool QLandmarkManagerEngine::saveLandmark(QLandmark* /*landmark*/, + QLandmarkManager::Error* /*error*/, QString* /*errorString*/) +{ + return false; +} + +/*! + Adds the list of \a landmarks to the datastore. + Returns true if the landmarks were saved successfully, otherwise returns + false. + + The engine will populate \a errorMap (the map of indices of the + \a landmarks list to errors) for every index for which the landmark could not be + saved. + + + For each newly saved landmark that was successful, the identifier + of the landmark will be updated with a new value. + + The engine emits the appropriate signals to inform clients of changes + to the datastore resulting from this operation. + + Overall operation errors are stored in \a error and + \a errorString. \a error is set to QLandmarkManager::NoError, + if all \a landmarks were successfully saved. + + \sa QLandmarkManagerEngine::saveLandmark() +*/ +bool QLandmarkManagerEngine::saveLandmarks(QList<QLandmark> * /*landmarks*/, QMap<int, QLandmarkManager::Error>* /*errorMap*/, + QLandmarkManager::Error* /*error*/, QString* /*errorString*/) +{ + return false; +} + +/*! + Remove the landmark identified by \a landmarkId from the datastore. + + Returns true if the landmark was removed successfully, otherwise + returnse false. + + The engine emits the appropriate signals to inform clients of changes + to the datastore resulting from this operation. + + Any errors encountered during this operation should be stored to + \a error and \a errorString. +*/ +bool QLandmarkManagerEngine::removeLandmark(const QLandmarkId& /*landmarkId*/, QLandmarkManager::Error* /*error*/, QString* /*errorString*/) +{ + return false; +} + +/*! + Removes every landmark whose identifier is contained in the list + of \a landmarkIds. Returns true if all landmarks were removed + successfully, otherwise false. + + The engine populates \a errorMap (the map of indices of the + \a landmarkIds list to errors) for every index for which the landmark could not be + removed. + + The engine also emits the appropriate signals to inform clients of changes + to the datastore resulting from this operation. + + Overall operation errors are stored in \a error and + \a errorString. \a error is set to QLandmarkManager::NoError, if + all landmarks were successfully removed. + + \sa QLandmarkManagerEngine::removeLandmark() +*/ +bool QLandmarkManagerEngine::removeLandmarks(const QList<QLandmarkId>& /*landmarkIds*/, QMap<int, QLandmarkManager::Error>* /*errorMap*/, + QLandmarkManager::Error* /*error*/, QString* /*errorString*/) +{ + return false; +} + +/*! + Adds the given \a category to the datastore if \a category has a + default-constructed identifier, or an identifier with the manager + URI set to the URI of this manager and an empty id. + + If the manager URI of the identifier of the \a category is neither + empty nor equal to the URI of this manager, or the id member of the + identifier is not empty, but does not exist in the manager, + the operation should fail and \a error should be set to + \c QLandmarkManager::CategoryDoesNotExistError. + + Alternatively, the function should update the existing category in the + datastore if \a category has a non-empty id and currently exists + within the datastore. + + Returns false on failure or true on success. On successful save + of a category with an invalid id, it should be assigned a valid + id and have its manager URI set to the URI of this manager. + + The engine returns the appropriate signals to inform clients of changes + to the datastore resulting from this operation. + + Overall operations errors should be stored in \a error and + \a errorString. +*/ +bool QLandmarkManagerEngine::saveCategory(QLandmarkCategory* /*category*/, + QLandmarkManager::Error* /*error*/, QString* /*errorString*/) +{ + return false; +} + +/*! + Removes the category identified by \a categoryId from the datastore. + + Returns true if the category was removed successfully, otherwise + returnse false. + + The engine emits the appropriate signals to inform clients of changes + to the datastore resulting from this operation + + Overall operational errors are stored in \a error and + \a errorString. +*/ +bool QLandmarkManagerEngine::removeCategory(const QLandmarkCategoryId& /*categoryId*/, + QLandmarkManager::Error* /*error*/, QString* /*errorString*/) +{ + return false; +} + +/*! + Reads landmarks from the given \a device and saves them. The data from the \a device + is expected to adhere to the provided \a format. If no \a format is provided, + the manager engine tries to autodetect the \a format. + + The \a option can be used to control whether categories in the imported + file will be added during the import. If the \c AttachSingleCategory option is used, then + all the landmarks in the import file are assigned to the category identified by + \a categoryId, in all other circumstances \a categoryId is ignored. If \a categoryId + doesn't exist when using \c AttachSingleCategory, QLandmarkManager::CategoryDoesNotExist error is returned. Note that + some file formats may not support categories at all. + + Returns true if all landmarks could be imported, otherwise returns false. + + Overall operational errors are stored in \a error and + \a errorString. +*/ +bool QLandmarkManagerEngine::importLandmarks(QIODevice* /*device*/, const QString& /*format*/, QLandmarkManager::TransferOption /*option*/, const QLandmarkCategoryId& /*categoryId*/, + QLandmarkManager::Error *error, QString *errorString) +{ + Q_ASSERT(error); + Q_ASSERT(errorString); + *error = QLandmarkManager::NotSupportedError; + *errorString ="Not supported"; + return false; +} + +/*! + Writes landmarks to the given \a device. The landmarks will be written + according to the specified \a format. If \a landmarkIds is empty, then + all landmarks will be exported, otherwise only those landmarks that + match \a landmarkIds will be exported. + + The \a option can be used to control whether categories will be exported or not. + Note that the \c AttachSingleCategory option has no meaning during + export and the manager will export as if \a option was \c IncludeCategoryData. + Also, be aware that some file formats may not support categories at all and for + these formats, the \a option is always treated as if it was \c ExcludeCategoryData. + + Returns true if all specified landmarks were successfully exported, + otherwise returns false. + + Overall operation errors are stored in \a error and + \a errorString. +*/ +bool QLandmarkManagerEngine::exportLandmarks(QIODevice * /*device*/, const QString& /*format*/, const QList<QLandmarkId> &/*landmarkIds*/, QLandmarkManager::TransferOption /*option*/, + QLandmarkManager::Error *error, QString *errorString) const +{ + Q_ASSERT(error); + Q_ASSERT(errorString); + *error = QLandmarkManager::NotSupportedError; + *errorString = "Not supported"; + return false; +} + +/*! + Returns the supported file formats for the given transfer \a operation, i.e. import or export. + Errors are stored in \a error and \a errorString. +*/ +QStringList QLandmarkManagerEngine::supportedFormats(QLandmarkManager::TransferOperation /*operation*/ , QLandmarkManager::Error *error, QString *errorString) const +{ + Q_ASSERT(error); + Q_ASSERT(errorString); + *error = QLandmarkManager::NoError; + *errorString = ""; + return QStringList(); +} + +/*! + \fn QLandmarkManager::SupportLevel QLandmarkManagerEngine::filterSupportLevel(const QLandmarkFilter &filter, + QLandmarkManager::Error *error, QString *errorString) const + + Returns the support level the manager engine provides for the given \a filter. Errors are stored in \a error + and \a errorString. +*/ + +/*! + \fn QLandmarkManager::SupportLevel QLandmarkManagerEngine::sortOrderSupportLevel(const QLandmarkSortOrder &sortOrder, + QLandmarkManager::Error *error, QString *errorString) const + + Returns the support level the manager engine provides for the given \a sortOrder. Errors are stored in \a error + and \a errorString. +*/ + +/*! + \fn bool QLandmarkManagerEngine::isFeatureSupported(QLandmarkManager::ManagerFeature feature, QLandmarkManager::Error *error, QString *errorString) const + + Returns true if the manager engine supports the given \a feature, otherwise returns false; Errors are stored in + \a error and \a errorString. +*/ + +/*! + \fn bool QLandmarkManagerEngine::isReadOnly(QLandmarkManager::Error *error, QString *errorString) const + + Returns true if the manager engine is exclusively read only. Meaning + landmarks and categories cannot be added, modified or removed. Errors are stored in \a error and \a errorString. +*/ + +/*! + \fn bool QLandmarkManagerEngine::isReadOnly(const QLandmarkId &landmarkId, + QLandmarkManager::Error *error, QString *errorString) const + + Returns true if the landmark identified by \a landmarkId + considered read-only by the manager engine. + + If the \a landmarkId does not refer to an existing landmark, + it is considered writable unless the manager engine is exclusively read-only. + Errors are stored in \a error and \a errorString. + */ + + /*! + \fn bool QLandmarkManagerEngine::isReadOnly(const QLandmarkCategoryId &categoryId, + QLandmarkManager::Error *error, QString *errorString) const + + Returns true if the category identified by \a categoryId is + considered read-only by the manager engine. + + If \a categoryId does not refer to an existing category, + it is considered writable unless the manager engine is exclusively read-only. + Errors are stored in \a error and \a errorString. +*/ + +/*! + \fn QStringList QLandmarkManagerEngine::searchableLandmarkAttributeKeys(QLandmarkManager::Error *error, QString *errorString) const + Returns the list of landmark attribute keys that may be used in a QLandmarkAttributeFilter. + Errors are stored in \a error and \a errorString. +*/ + +/*! + Notifies the manager engine that the given \a request has been destroyed. +*/ +void QLandmarkManagerEngine::requestDestroyed(QLandmarkAbstractRequest* request) +{ + Q_UNUSED(request); +} + +/*! + Asks the manager engine to begin the given \a request + which is currently in a re(startable) state. + + Returns true if the request was started successfully, + else returns false. + + \sa QLandmarkAbstractRequest::start() +*/ +bool QLandmarkManagerEngine::startRequest(QLandmarkAbstractRequest* request) +{ + Q_UNUSED(request); + return false; +} + +/*! + Asks the manager engine to cancel the given \a request which was + previously started and is currently in a cancellable state. + Returns true if cancelation of the request was started successfully, + otherwise returns false. + + \sa startRequest(), QLandmarkAbstractRequest::cancel() + */ +bool QLandmarkManagerEngine::cancelRequest(QLandmarkAbstractRequest* request) +{ + Q_UNUSED(request); + return false; +} + +/*! + Blocks until the manager engine has completed the given \a request + which was previously started, or until \a msecs milliseconds have passed. + Returns true if the request was completed, and false if the request was not in the + \c QLandmarkAbstractRequest::Active state, no progress could be reported or + if the engine does not support waitForFinished functionality. + + \sa startRequest() + */ +bool QLandmarkManagerEngine::waitForRequestFinished(QLandmarkAbstractRequest* request, int msecs) +{ + Q_UNUSED(request); + Q_UNUSED(msecs); + return false; +} + +/*! + \fn QLandmarkManagerEngine::dataChanged() + + This signal is emitted some time after changes occur to the datastore managed by this + engine, and the engine is unable to precisely determine which changes occurred, or if the + engine considers the changes to be radical enough to require clients to reload all data. + + If this signal is emitted, no other signals may be emitted for the associated changes. + + As it is possible that other processes (or other devices) may have caused the + changes, the timing can not be determined. + + \sa landmarksAdded(), landmarksChanged(), landmarksRemoved(), categoriesAdded(), + categoriesChanged(), categoriesRemoved() +*/ + +/*! + \fn QLandmarkManagerEngine::landmarksAdded(const QList<QLandmarkId> &landmarkIds) + + This signal is emitted some time after a set of landmarks has been added to + the datastore managed by the engine and where the \l dataChanged() signal was not emitted for those changes. + As it is possible that other processes(or other devices) may + have added the landmarks, the exact timing cannot be determined. + + There may be one or more landmark identifiers in the \a landmarkIds list. + + \sa dataChanged(), landmarksChanged(), landmarksRemoved() +*/ + +/*! + \fn QLandmarkManagerEngine::landmarksChanged(const QList<QLandmarkId> &landmarkIds) + + This signal is emitted some time after a set of landmarks have been modified in + the datastore managed by this engine and where the \l dataChanged() signal was not emitted for those changes. + As it is possible that other processes(or other devices) may have modified the landmarks, + the timing cannot be determined. + + Note that removal of a category will not trigger a \c landmarksChanged signal for landmarks belonging to that category. + + There may be one ore more landmark identifiers in the \a landmarkIds list. + \sa dataChanged(), landmarksAdded(), landmarksRemoved() +*/ + + +/*! + \fn QLandmarkManagerEngine::landmarksRemoved(const QList<QLandmarkId> &landmarkIds) + + This signal is emitted some time after a set of landmarks have been removed from the + datastore managed by this engine and where the \l dataChanged() signal was not emitted for those changes. + As it is possible that other processes(or other devices) may have removed the landmarks, + the timing cannot be determined. + + There may be one ore more landmark identifiers in the \a landmarkIds list. + \sa dataChanged(), landmarksAdded(), landmarksChanged() +*/ + +/*! + \fn QLandmarkManagerEngine::categoriesAdded(const QList<QLandmarkCategoryId> &categoryIds) + + This signal is emitted some time after a set of categories has been added to the datastore + managed by this engine and where the \l dataChanged() signal was not emitted for those changes. + As it is possible that other processes(or other devices) may + have added the landmarks, the exact timing cannot be determined. + + There may be one or more category identifiers in the \a categoryIds list. + + \sa dataChanged(), categoriesChanged(), categoriesRemoved() +*/ + +/*! + \fn QLandmarkManagerEngine::categoriesChanged(const QList<QLandmarkCategoryId> &categoryIds) + + This signal is emitted some time after a set of categories have been modified in the datastore + managed by the engine and where the \l dataChanged() signal was not emitted for those changes. + As it is possible that other processes(or other devices) may have modified the categories, + the timing cannot be determined. + + There may be one ore more category identifiers in the \a categoryIds list. + + \sa dataChanged(), categoriesAdded(), categoriesRemoved() +*/ + +/*! + \fn QLandmarkManagerEngine::categoriesRemoved(const QList<QLandmarkCategoryId> &categoryIds) + + This signal is emitted some time after a set of categories have been removed from the datastore + managed by this engine and where the \l dataChanged() signal was not emitted for those changes. + As it is possible that other processes(or other devices) may have removed the categories, + the timing cannot be determined. + + There may be one ore more category identifiers in the \a categoryIds list. + + \sa dataChanged(), categoriesAdded(), categoriesChanged() +*/ + +/*! + Updates the given asynchronous request \a req by setting the new \a state + of the request. If the new state is different, the stateChanged() signal will be emitted + by the request. + +*/ +void QLandmarkManagerEngine::updateRequestState(QLandmarkAbstractRequest *req, QLandmarkAbstractRequest::State state) +{ + if (req) { + QMutexLocker ml(&req->d_ptr->mutex); + if (req->d_ptr->state != state) { + req->d_ptr->state = state; + ml.unlock(); + emit req->stateChanged(state); + } + } +} + +/*! + Updates the given QLandmarkIdFetchRequest \a req with the latest \a result, + and operation \a error and \a errorString. In addition, the state of the request + will be changed to \a newState. + + It then causes the request to emit its resultsAvailable() signal to notify clients of the + request progress. + + If the new request state is different from the previous state, the stateChanged() signal will + also be emitted from the request. + */ +void QLandmarkManagerEngine::updateLandmarkIdFetchRequest(QLandmarkIdFetchRequest* req, const QList<QLandmarkId>& result, + QLandmarkManager::Error error, const QString &errorString, + QLandmarkAbstractRequest::State newState) +{ + if (req) { + QWeakPointer<QLandmarkIdFetchRequest> ireq(req); //Take this in case the first emit delete us + QLandmarkIdFetchRequestPrivate * rd = static_cast<QLandmarkIdFetchRequestPrivate*>(ireq.data()->d_ptr); + QMutexLocker ml(&rd->mutex); + rd->error = error; + rd->errorString = errorString; + rd->landmarkIds = result; + bool emitState = rd->state != newState; + rd->state =newState; + ml.unlock(); + emit req->resultsAvailable(); + if (emitState && ireq) + emit ireq.data()->stateChanged(newState); + } +} + +/*! + Updates the given QLandmarkFetchRequest \a req with the latest \a result, + and operation \a error and \a errorString. In addition, the state of the request + will be changed to \a newState. + + It then causes the request to emit its resultsAvailable() signal to notify clients of the + request progress. + + If the new request state is different from the previous state, the stateChanged() signal will + also be emitted from the request. + */ +void QLandmarkManagerEngine::updateLandmarkFetchRequest(QLandmarkFetchRequest* req, const QList<QLandmark>& result, + QLandmarkManager::Error error, const QString &errorString, + QLandmarkAbstractRequest::State newState) +{ + if (req) { + QWeakPointer<QLandmarkFetchRequest> ireq(req); //Take this incase the first emit deletes us. + QLandmarkFetchRequestPrivate * rd = static_cast<QLandmarkFetchRequestPrivate*>(ireq.data()->d_ptr); + + QMutexLocker ml(&rd->mutex); + rd->error = error; + rd->errorString = errorString; + rd->landmarks = result; + bool emitState = rd->state != newState; + rd->state =newState; + ml.unlock(); + emit req->resultsAvailable(); + if (emitState && ireq) + emit req->stateChanged(newState); + } +} + +/*! + Updates the given QLandmarkFetchByIdRequest \a req with the latest \a result, + operation \a error and \a errorString and map of input index to individual errors, \a errorMap. + In addition, the state of the request + will be changed to \a newState. + + It then causes the request to emit its resultsAvailable() signal to notify clients of the + request progress. + + If the new request state is different from the previous state, the stateChanged() signal will + also be emitted from the request. + */ +void QLandmarkManagerEngine::updateLandmarkFetchByIdRequest(QLandmarkFetchByIdRequest* req, const QList<QLandmark>& result, QLandmarkManager::Error error, + const QString &errorString, const QMap<int, QLandmarkManager::Error>& errorMap, QLandmarkAbstractRequest::State newState) +{ + if (req) { + QWeakPointer<QLandmarkFetchByIdRequest> ireq(req); //Take this in case the first emit delete us + QLandmarkFetchByIdRequestPrivate* rd = static_cast<QLandmarkFetchByIdRequestPrivate*>(ireq.data()->d_ptr); + QMutexLocker ml(&rd->mutex); + rd->error = error; + rd->errorString = errorString; + rd->errorMap = errorMap; + rd->landmarks = result; + bool emitState = rd->state != newState; + rd->state = newState; + ml.unlock(); + emit req->resultsAvailable(); + if (emitState && req) + emit req->stateChanged(newState); + } +} + +/*! + Updates the given QLandmarkRemoveRequest \a req with the operation \a error and + \a errorString and map of input index to individual errors, \a errorMap. In addition, + the state of the request will be changed to \a newState. + + It then causes the request to emit its resultsAvailable() signal to notify clients of the request + progress. + + If the new request state is different from the previous state, the stateChanged() signal will + also be emitted from the request. + */ +void QLandmarkManagerEngine::updateLandmarkRemoveRequest(QLandmarkRemoveRequest* req, QLandmarkManager::Error error, const QString &errorString, + const QMap<int, QLandmarkManager::Error>& errorMap, QLandmarkAbstractRequest::State newState) +{ + if (req) { + QWeakPointer<QLandmarkRemoveRequest>ireq(req);//Take this in case the first emit delete us + QLandmarkRemoveRequestPrivate* rd = static_cast<QLandmarkRemoveRequestPrivate*>(ireq.data()->d_ptr); + QMutexLocker ml(&rd->mutex); + rd->error = error; + rd->errorString = errorString; + rd->errorMap = errorMap; + bool emitState = rd->state != newState; + rd->state = newState; + ml.unlock(); + emit req->resultsAvailable(); + if (emitState && ireq) + emit req->stateChanged(newState); + } + +} + +/*! + Updates the given QLandmarkSaveRequest \a req with the latest \a result, operation \a error + and \a errorString, and map of input index to individual errors, \a errorMap. + In addition, the state of the request will be changed to \a newState. + + It then causes the request to emit its resultsAvailable() signal to notify clients of the request + progress. + + If the new request state is different from the previous state, the stateChanged() signal will + also be emitted from the request. + */ +void QLandmarkManagerEngine::updateLandmarkSaveRequest(QLandmarkSaveRequest* req, const QList<QLandmark>& result, QLandmarkManager::Error error, + const QString &errorString, const QMap<int, QLandmarkManager::Error>& errorMap, QLandmarkAbstractRequest::State newState) +{ + if (req) { + QWeakPointer<QLandmarkSaveRequest> ireq(req); //Take this in case the first emit delete us + QLandmarkSaveRequestPrivate* rd = static_cast<QLandmarkSaveRequestPrivate*>(ireq.data()->d_ptr); + QMutexLocker ml(&rd->mutex); + rd->error = error; + rd->errorString = errorString; + rd->errorMap = errorMap; + rd->landmarks = result; + bool emitState = rd->state != newState; + rd->state = newState; + ml.unlock(); + emit req->resultsAvailable(); + if (emitState && ireq) + emit req->stateChanged(newState); + } +} + +/*! + Updates the given QLandmarkCategoryIdFetchRequest \a req with the latest \a result, + and operation \a error and \a errorString. In addition, the state of the request + will be changed to \a newState. + + It then causes the request to emit its resultsAvailable() signal to notify clients of the + request progress. + + If the new request state is different from the previous state, the stateChanged() signal will + also be emitted from the request. + */ +void QLandmarkManagerEngine::updateLandmarkCategoryIdFetchRequest(QLandmarkCategoryIdFetchRequest* req, const QList<QLandmarkCategoryId>& result, + QLandmarkManager::Error error, const QString &errorString, + QLandmarkAbstractRequest::State newState) + +{ + if (req) { + QWeakPointer<QLandmarkCategoryIdFetchRequest> ireq(req); //Take this in case the first emit delete us + QLandmarkCategoryIdFetchRequestPrivate* rd = static_cast<QLandmarkCategoryIdFetchRequestPrivate*>(ireq.data()->d_ptr); + QMutexLocker ml(&rd->mutex); + rd->error = error; + rd->errorString = errorString; + rd->categoryIds = result; + bool emitState = rd->state != newState; + rd->state = newState; + ml.unlock(); + emit req->resultsAvailable(); + if (emitState && ireq) + emit req->stateChanged(newState); + } +} + +/*! + Updates the given QLandmarkCategoryFetchRequest \a req with the latest \a result, + and operation \a error and \a errorString. In addition, the state of the request + will be changed to \a newState. + + It then causes the request to emit its resultsAvailable() signal to notify clients of the + request progress. + + If the new request state is different from the previous state, the stateChanged() signal will + also be emitted from the request. + */ +void QLandmarkManagerEngine::updateLandmarkCategoryFetchRequest(QLandmarkCategoryFetchRequest* req, const QList<QLandmarkCategory>& result, + QLandmarkManager::Error error, const QString &errorString, + QLandmarkAbstractRequest::State newState) + +{ + if (req) { + QWeakPointer<QLandmarkCategoryFetchRequest> ireq(req); //Take this in case the first emit delete us + QLandmarkCategoryFetchRequestPrivate* rd = static_cast<QLandmarkCategoryFetchRequestPrivate*>(ireq.data()->d_ptr); + QMutexLocker ml(&rd->mutex); + rd->error = error; + rd->errorString = errorString; + rd->categories = result; + bool emitState = rd->state != newState; + rd->state = newState; + ml.unlock(); + emit req->resultsAvailable(); + if (emitState && ireq) + emit req->stateChanged(newState); + } +} + +/*! + Updates the given QLandmarkCategoryFetchByIdRequest \a req with the latest \a result, + and operation \a error and \a errorString, and map of input index to individual errors, \a errorMap. + In addition, the state of the request will be changed to \a newState. + + It then causes the request to emit its resultsAvailable() signal to notify clients of the + request progress. + + If the new request state is different from the previous state, the stateChanged() signal will + also be emitted from the request. + */ +void QLandmarkManagerEngine::updateLandmarkCategoryFetchByIdRequest(QLandmarkCategoryFetchByIdRequest* req, const QList<QLandmarkCategory>& result, QLandmarkManager::Error error, + const QString &errorString, const QMap<int, QLandmarkManager::Error>& errorMap, QLandmarkAbstractRequest::State newState) +{ + if (req) { + QWeakPointer<QLandmarkCategoryFetchByIdRequest> ireq(req); //Take this in case the first emit delete us + QLandmarkCategoryFetchByIdRequestPrivate* rd = static_cast<QLandmarkCategoryFetchByIdRequestPrivate*>(ireq.data()->d_ptr); + QMutexLocker ml(&rd->mutex); + rd->error = error; + rd->errorString = errorString; + rd->errorMap = errorMap; + rd->categories = result; + bool emitState = rd->state != newState; + rd->state = newState; + ml.unlock(); + emit req->resultsAvailable(); + if (emitState && ireq) + emit req->stateChanged(newState); + } +} + +/*! + Updates the given QLandmarkCategoryRemoveRequest \a req with the operation \a error and + \a errorString and map of input index to individual errors, \a errorMap. In addition, + the state of the request will be changed to \a newState. + + It then causes the request to emit its resultsAvailable() signal to notify clients of the request + progress. + + If the new request state is different from the previous state, the stateChanged() signal will + also be emitted from the request. + */ +void QLandmarkManagerEngine::updateLandmarkCategoryRemoveRequest(QLandmarkCategoryRemoveRequest* req, QLandmarkManager::Error error, const QString &errorString, + const QMap<int, QLandmarkManager::Error>& errorMap, QLandmarkAbstractRequest::State newState) +{ + if (req) { + QWeakPointer<QLandmarkCategoryRemoveRequest> ireq(req); //Take this in case the first emit delete us + QLandmarkRemoveRequestPrivate* rd = static_cast<QLandmarkRemoveRequestPrivate*>(ireq.data()->d_ptr); + QMutexLocker ml(&rd->mutex); + rd->error = error; + rd->errorString = errorString; + rd->errorMap = errorMap; + bool emitState = rd->state != newState; + rd->state = newState; + ml.unlock(); + emit req->resultsAvailable(); + if (emitState && ireq) + emit req->stateChanged(newState); + } +} + +/*! + Updates the given QLandmarkSaveCategoryRequest \a req with the latest \a result, operation error \a error + and \a errorString, and map of input index to individual errors, \a errorMap. + In addition, the state of the request will be changed to \a newState. + + It then causes the request to emit its resultsAvailable() signal to notify clients of the request + progress. + + If the new request state is different from the previous state, the stateChanged() signal will + also be emitted from the request. + */ +void QLandmarkManagerEngine::updateLandmarkCategorySaveRequest(QLandmarkCategorySaveRequest* req, const QList<QLandmarkCategory>& result, QLandmarkManager::Error error, + const QString &errorString, const QMap<int, QLandmarkManager::Error>& errorMap, QLandmarkAbstractRequest::State newState) +{ + if (req) { + QWeakPointer<QLandmarkCategorySaveRequest> ireq(req); //Take this in case the first emit delete us + QLandmarkCategorySaveRequestPrivate* rd = static_cast<QLandmarkCategorySaveRequestPrivate*>(ireq.data()->d_ptr); + QMutexLocker ml(&rd->mutex); + rd->error = error; + rd->errorString = errorString; + rd->errorMap = errorMap; + rd->categories = result; + bool emitState = rd->state != newState; + rd->state = newState; + ml.unlock(); + emit req->resultsAvailable(); + if (emitState && ireq) + emit req->stateChanged(newState); + } +} + +/*! + Updates the given QLandmarkImportRequest \a req with the operation \a error and \a errorString. + In addition the state of the request is changed to \a newState. This function may also be used + to update the \a ids of the landmarks which have been imported. + + It then causes the request to emit its resultsAvailable() signal to notify the clients of the request + progress. + + If the new request state is different from the previous state, the stateChanged() signal will + also be emitted from the request. +*/ +void QLandmarkManagerEngine::updateLandmarkImportRequest(QLandmarkImportRequest *req, const QList<QLandmarkId> &ids, QLandmarkManager::Error error, const QString &errorString, + QLandmarkAbstractRequest::State newState) +{ + if (req) { + QWeakPointer<QLandmarkImportRequest> ireq(req); //Take this in case the first emit delete us + QLandmarkImportRequestPrivate* rd = static_cast<QLandmarkImportRequestPrivate*>(ireq.data()->d_ptr); + QMutexLocker ml(&rd->mutex); + rd->error = error; + rd->errorString = errorString; + rd->landmarkIds = ids; + bool emitState = rd->state != newState; + rd->state = newState; + ml.unlock(); + emit req->resultsAvailable(); + if (emitState && ireq) + emit req->stateChanged(newState); + } +} + +/*! + Updates the given QLandmarkExportRequest \a req with the operation \a error and \a errorString. + In addition the state of the request is changed to \a newState. + + It then causes the request to emit its resultsAvailable() signal to notify the clients of the request + progress. + + If the new request state is different from the previous state, the stateChanged() signal will + also be emitted from the request. +*/ +void QLandmarkManagerEngine::updateLandmarkExportRequest(QLandmarkExportRequest *req, QLandmarkManager::Error error, const QString &errorString, + QLandmarkAbstractRequest::State newState) +{ + if (req) { + QWeakPointer<QLandmarkExportRequest> ireq(req); //Take this in case the first emit delete us + QLandmarkExportRequestPrivate* rd = static_cast<QLandmarkExportRequestPrivate*>(ireq.data()->d_ptr); + QMutexLocker ml(&rd->mutex); + rd->error = error; + rd->errorString = errorString; + bool emitState = rd->state != newState; + rd->state = newState; + ml.unlock(); + emit req->resultsAvailable(); + if (emitState && req) + emit req->stateChanged(newState); + } +} + +/*! + Compares two landmarks (\a a and \a b) using the given list of \a sortOrders. Returns a negative number if \a a should appear + before \a b according to the sort order, a positive number if \a a should appear after \a b according to the sort order, + and zero if the two are unable to be sorted. + */ +int QLandmarkManagerEngine::compareLandmark(const QLandmark& a, const QLandmark& b, const QList<QLandmarkSortOrder>& sortOrders) +{ + int comparison = 0; + for(int i=0; i < sortOrders.count(); ++i) { + + switch (sortOrders.at(i).type()) + { + case (QLandmarkSortOrder::NameSort): + { + const QLandmarkNameSort nameSort = sortOrders.at(i); + comparison = compareName(a, b, nameSort); + break; + } + default: + comparison =0; + } + + if (comparison != 0) + break; + } + return comparison; +} + + +/*! + Compares two landmarks (\a a and \a b) by name. + + Returns a negative number if \a a should appear before \a b according to the \a nameSort, + a positive number if \a a should appear after \a b according to the \a nameSort, + and zero if the two are unable to be sorted. + + Assuming an ascending order sort, an integer less than, equal to, or greater than zero + is returned if \a a is less than, equal to or greater than \a b. + + \a nameSort specifies whether an ascending or descending order is used and whether + the sort is case sensitive or not. + */ +int QLandmarkManagerEngine::compareName(const QLandmark &a, const QLandmark &b, const QLandmarkNameSort &nameSort) +{ + int result = QString::compare(a.name(), b.name(), nameSort.caseSensitivity()); + + if (nameSort.direction() == Qt::DescendingOrder) + result *= -1; + + return result; +} + +/*! + Performs an insertion sort \a landmark into the \a sorted list, according to the provided \a sortOrders list. + The first QLandmarkSortOrder in the list has the highest priority; if the \a landmark is deemed equal to another + in the \a sorted list, the second QLandmarkSortOrder in the list is used (and so on until either the landmark is inserted + or there are no more sort order objects in the list). + */ +void QLandmarkManagerEngine::addSorted(QList<QLandmark>* sorted, const QLandmark& landmark, const QList<QLandmarkSortOrder>& sortOrders) +{ + if (sortOrders.count() > 0) { + for (int i = 0; i < sorted->size(); i++) { + // check to see if the new landmark should be inserted here + int comparison = compareLandmark(sorted->at(i), landmark, sortOrders); + if (comparison > 0) { + sorted->insert(i, landmark); + return; + } + } + } + + // hasn't been inserted yet? append to the list. + sorted->append(landmark); +} + +/*! + Returns true if the supplied \a landmark matches the supplied \a filter. + */ +bool QLandmarkManagerEngine::testFilter(const QLandmarkFilter& filter, const QLandmark& landmark) +{ + switch(filter.type()) { + case QLandmarkFilter::DefaultFilter: + return true; + + case QLandmarkFilter::AttributeFilter: + { + const QLandmarkAttributeFilter attribFilter(filter); + QStringList filterKeys = attribFilter.attributeKeys(); + + if (attribFilter.operationType() == QLandmarkAttributeFilter::AndOperation) { + QVariant lmAttributeValue; + foreach(const QString filterKey, filterKeys) + { + if (commonLandmarkKeys.contains(filterKey)) { + lmAttributeValue = getLandmarkAttribute(filterKey, landmark); + + if (lmAttributeValue.type() == QVariant::String) { + QString lmString = lmAttributeValue.toString(); + QString attribString = attribFilter.attribute(filterKey).toString(); + if (matchString(lmString, attribString, attribFilter.matchFlags(filterKey))) + continue; + } else if (attribFilter.attribute(filterKey) == lmAttributeValue) { + continue; + } + + return false; + } else { + return false; + } + } + return true; + } else {//must be OR operation + QVariant lmAttributeValue; + foreach(const QString filterKey, filterKeys) { + if (commonLandmarkKeys.contains(filterKey)) { + + lmAttributeValue = getLandmarkAttribute(filterKey, landmark); + + if (lmAttributeValue.type() == QVariant::String) { + QString lmString = lmAttributeValue.toString(); + QString attribString = attribFilter.attribute(filterKey).toString(); + if (matchString(lmString, attribString, attribFilter.matchFlags(filterKey))) + return true; + } + + if (attribFilter.attribute(filterKey) == lmAttributeValue) { + return true; + } + } + } + return false; + } + } + case QLandmarkFilter::BoxFilter: + { + const QLandmarkBoxFilter boxFilter(filter); + + if (!boxFilter.boundingBox().isValid()) + return false; + + double tly = boxFilter.boundingBox().topLeft().latitude(); + double bry = boxFilter.boundingBox().bottomRight().latitude(); + double tlx = boxFilter.boundingBox().topLeft().longitude(); + double brx = boxFilter.boundingBox().bottomRight().longitude(); + + bool latWrap = (tly < bry); + bool longWrap = (tlx > brx); + + if (latWrap) + return false; + + //check if landmark is outside the box's latitudes + if ( landmark.coordinate().latitude() < bry && landmark.coordinate().latitude() > tly) + return false; + + double lmx = landmark.coordinate().longitude(); + if (longWrap) { + //if (landmark.coordinate().longitude() <= tlx || landmark.coordinate().longitude() >= brx) + if ( ((lmx > 0.0) && (lmx<= tlx)) || ((lmx < 0.0) && (lmx >= brx))) + return false; + } else { + if (lmx < tlx || lmx > brx) + return false; + } + + //landmark must be within the bounds to reach here. + return true; + } + case QLandmarkFilter::CategoryFilter: + { + const QLandmarkCategoryFilter categoryFilter(filter); + QList<QLandmarkCategoryId> categories = landmark.categoryIds(); + foreach(const QLandmarkCategoryId id, categories) + { + if (id == categoryFilter.categoryId()) + return true; + } + return false; + } + case QLandmarkFilter::IntersectionFilter: + { + const QLandmarkIntersectionFilter andFilter(filter); + const QList<QLandmarkFilter>& terms = andFilter.filters(); + if (terms.count() ==0) + return false; + + for(int i=0; i < terms.count();i++) { + if (!testFilter(terms.at(i), landmark)) + return false; + } + return true; + } + case QLandmarkFilter::LandmarkIdFilter: + { + QLandmarkIdFilter idFilter(filter); + const QList<QLandmarkId> &ids = idFilter.landmarkIds(); + foreach(const QLandmarkId id, ids) { + if (id == landmark.landmarkId()) + return true; + } + return false; + } + case QLandmarkFilter::InvalidFilter: + { + return false; + } + case QLandmarkFilter::NameFilter: + { + QLandmarkNameFilter nameFilter(filter); + return matchString(landmark.name(), nameFilter.name(), nameFilter.matchFlags()); + } + case QLandmarkFilter::ProximityFilter: + { + QLandmarkProximityFilter proximityFilter(filter); + + qreal distance = proximityFilter.center().distanceTo(landmark.coordinate()); + if (distance < proximityFilter.radius() || qFuzzyCompare(distance, proximityFilter.radius())) + return true; + else + return false; + } + case QLandmarkFilter::UnionFilter: + { + const QLandmarkUnionFilter orFilter(filter); + const QList<QLandmarkFilter>& terms = orFilter.filters(); + if (terms.count() == 0) + return false; + else { + for (int i=0; i < terms.count(); i++) { + if (testFilter(terms.at(i), landmark)) + return true; + } + return false; + } + } + } + return false; +} + +/*! Sorts the given list of \a landmarks according to the provided \a sortOrders */ +QList<QLandmarkId> QLandmarkManagerEngine::sortLandmarks(const QList<QLandmark>& landmarks, const QList<QLandmarkSortOrder>& sortOrders) +{ + QList<QLandmarkId> landmarkIds; + QList<QLandmark> sortedLandmarks; + if(!sortOrders.isEmpty()) { + foreach (const QLandmark& landmark, landmarks) { + QLandmarkManagerEngine::addSorted(&sortedLandmarks, landmark, sortOrders); + } + + foreach (const QLandmark& landmark, sortedLandmarks) { + landmarkIds.append(landmark.landmarkId()); + } + } else { + foreach(const QLandmark& landmark, landmarks) { + landmarkIds.append(landmark.landmarkId()); + } + } + return landmarkIds; +} + +#include "moc_qlandmarkmanagerengine.cpp" + +QTM_END_NAMESPACE diff --git a/src/location/landmarks/qlandmarkmanagerengine.h b/src/location/landmarks/qlandmarkmanagerengine.h new file mode 100644 index 00000000..e4d1e4bc --- /dev/null +++ b/src/location/landmarks/qlandmarkmanagerengine.h @@ -0,0 +1,199 @@ +/**************************************************************************** +** +** Copyright (C) 2009 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 Q_LANDMARKMANAGERENGINE_H +#define Q_LANDMARKMANAGERENGINE_H +#include <QObject> +#include <QMap> +#include "qmobilityglobal.h" + +#include "qlandmarkmanager.h" +#include "qlandmarkabstractrequest.h" + + +class QIODevice; + +QTM_BEGIN_NAMESPACE +class QLandmarkCategory; +class QLandmarkCategoryId; +class QLandmark; +class QLandmarkId; +class QLandmarkSortOrder; +class QLandmarkIdFetchRequest; +class QLandmarkFetchRequest; +class QLandmarkFetchByIdRequest; +class QLandmarkRemoveRequest; +class QLandmarkSaveRequest; +class QLandmarkCategoryIdFetchRequest; +class QLandmarkCategoryFetchRequest; +class QLandmarkCategoryFetchByIdRequest; +class QLandmarkCategoryRemoveRequest; +class QLandmarkCategorySaveRequest; +class QLandmarkImportRequest; +class QLandmarkExportRequest; + +class QLandmarkFilter; +class QLandmarkNameFilter; +class QLandmarkProximityFilter; +class QLandmarkCategoryFilter; +class QLandmarkBoxFilter; +class QLandmarkUnionFilter; +class QLandmarkIntersectionFilter; +class QLandmarkAttributeFilter; + +class QLandmarkNameSort; +class QLandmarkDistanceSort; + +class Q_LOCATION_EXPORT QLandmarkManagerEngine : public QObject +{ + Q_OBJECT +public: + QLandmarkManagerEngine(); + virtual ~QLandmarkManagerEngine(); + + /* URI reporting */ + virtual QString managerName() const = 0; // e.g. "com.nokia.qt.landmarks.engines.s60" + virtual QMap<QString, QString> managerParameters() const = 0; // e.g. "filename=private.db" + virtual int managerVersion() const = 0; + + QString managerUri() const; + + /* Filtering */ + virtual QList<QLandmarkId> landmarkIds(const QLandmarkFilter &filter, int limit, int offset, const QList<QLandmarkSortOrder>& sortOrders, + QLandmarkManager::Error *error, QString *errorString) const = 0; + virtual QList<QLandmarkCategoryId> categoryIds(int limit, int offset, const QLandmarkNameSort &nameSort, QLandmarkManager::Error *error, + QString *errorString) const = 0; + + /* Retrieval */ + virtual QLandmark landmark(const QLandmarkId &landmarkId, QLandmarkManager::Error *error, + QString *errorString) const =0; + virtual QList<QLandmark> landmarks(const QList<QLandmarkId> &landmarkIds,QMap<int, QLandmarkManager::Error> *errorMap, + QLandmarkManager::Error *error, QString *errorString) const = 0; + virtual QList<QLandmark> landmarks(const QLandmarkFilter &filter, int limit, int offset, const QList<QLandmarkSortOrder>& sortOrders, + QLandmarkManager::Error *error, QString *errorString) const = 0; + virtual QLandmarkCategory category(const QLandmarkCategoryId &landmarkCategoryId, QLandmarkManager::Error *error, + QString *errorString) const = 0; + virtual QList<QLandmarkCategory> categories(const QList<QLandmarkCategoryId> &landmarkCategoryIds, QMap<int, QLandmarkManager::Error> *errorMap, + QLandmarkManager::Error *error, QString *errorString) const = 0; + virtual QList<QLandmarkCategory> categories(int limit, int offset, const QLandmarkNameSort &nameSort, QLandmarkManager::Error *error, + QString *errorString) const = 0; + + /*saving and removing*/ + virtual bool saveLandmark(QLandmark* landmark, QLandmarkManager::Error *error, QString *errorString) = 0; + virtual bool saveLandmarks(QList<QLandmark> * landmark, QMap<int, QLandmarkManager::Error> *errorMap, + QLandmarkManager::Error *error, QString *errorString) = 0; + virtual bool removeLandmark(const QLandmarkId &landmarkId, QLandmarkManager::Error *error, QString *errorString) = 0; + virtual bool removeLandmarks(const QList<QLandmarkId> &landmarkId, QMap<int, QLandmarkManager::Error> *errorMap, QLandmarkManager::Error *error, + QString *errorString) = 0; + + virtual bool saveCategory(QLandmarkCategory* category, QLandmarkManager::Error *error, QString *errorString) = 0; + virtual bool removeCategory(const QLandmarkCategoryId &categoryId, QLandmarkManager::Error *error, QString *errorString) = 0; + + virtual bool importLandmarks(QIODevice *device, const QString& format, QLandmarkManager::TransferOption option, const QLandmarkCategoryId& id, + QLandmarkManager::Error *error, QString *errorString) = 0; + virtual bool exportLandmarks(QIODevice *device, const QString& format, const QList<QLandmarkId> &landmarkIds, QLandmarkManager::TransferOption option, + QLandmarkManager::Error *error, QString *errorString) const = 0; + virtual QStringList supportedFormats(QLandmarkManager::TransferOperation operation, QLandmarkManager::Error *error, QString *errorString) const; + + virtual QLandmarkManager::SupportLevel filterSupportLevel(const QLandmarkFilter &filter, QLandmarkManager::Error *error, QString *errorString) const = 0; + virtual QLandmarkManager::SupportLevel sortOrderSupportLevel(const QLandmarkSortOrder &sortOrder, QLandmarkManager::Error *error, QString *errorString) const = 0; + virtual bool isFeatureSupported(QLandmarkManager::ManagerFeature feature, QLandmarkManager::Error *error, QString *errorString) const = 0; + + virtual bool isReadOnly(QLandmarkManager::Error *error, QString *errorString) const = 0; + virtual bool isReadOnly(const QLandmarkId &landmarkId, QLandmarkManager::Error *error, QString *errorString) const = 0; + virtual bool isReadOnly(const QLandmarkCategoryId &categoryId, QLandmarkManager::Error *error, QString *errorString) const = 0; + + virtual QStringList searchableLandmarkAttributeKeys(QLandmarkManager::Error *error, QString *errorString) const = 0; + + /* Asynchronous Request Support */ + virtual void requestDestroyed(QLandmarkAbstractRequest* request) = 0; + virtual bool startRequest(QLandmarkAbstractRequest* request) = 0; + virtual bool cancelRequest(QLandmarkAbstractRequest* request) = 0; + virtual bool waitForRequestFinished(QLandmarkAbstractRequest* request, int msecs) = 0; + +Q_SIGNALS: + void dataChanged(); + void landmarksAdded(const QList<QLandmarkId> &landmarkIds); + void landmarksChanged(const QList<QLandmarkId> &landmarkIds); + void landmarksRemoved(const QList<QLandmarkId> &landmarkIds); + + void categoriesAdded(const QList<QLandmarkCategoryId> &categoryIds); + void categoriesChanged(const QList<QLandmarkCategoryId> &categoryIds); + void categoriesRemoved(const QList<QLandmarkCategoryId> &categoryIds); + +public: + static void updateRequestState(QLandmarkAbstractRequest *req, QLandmarkAbstractRequest::State state); + static void updateLandmarkIdFetchRequest(QLandmarkIdFetchRequest* req, const QList<QLandmarkId>& result, + QLandmarkManager::Error error, const QString &errorString, QLandmarkAbstractRequest::State newState); + static void updateLandmarkFetchRequest(QLandmarkFetchRequest* req, const QList<QLandmark>& result, + QLandmarkManager::Error error, const QString &errorString, QLandmarkAbstractRequest::State newState); + static void updateLandmarkFetchByIdRequest(QLandmarkFetchByIdRequest* req, const QList<QLandmark>& result, QLandmarkManager::Error error, + const QString &errorString, const QMap<int, QLandmarkManager::Error>& errorMap, QLandmarkAbstractRequest::State newState); + static void updateLandmarkRemoveRequest(QLandmarkRemoveRequest* req, QLandmarkManager::Error error, const QString &errorString, + const QMap<int, QLandmarkManager::Error>& errorMap, QLandmarkAbstractRequest::State newState); + static void updateLandmarkSaveRequest(QLandmarkSaveRequest* req, const QList<QLandmark>& result, QLandmarkManager::Error error, + const QString &errorString, const QMap<int, QLandmarkManager::Error>& errorMap, QLandmarkAbstractRequest::State newState); + static void updateLandmarkCategoryIdFetchRequest(QLandmarkCategoryIdFetchRequest *req, const QList<QLandmarkCategoryId>& result, + QLandmarkManager::Error error, const QString &errorString, QLandmarkAbstractRequest::State newState); + static void updateLandmarkCategoryFetchRequest(QLandmarkCategoryFetchRequest *req, const QList<QLandmarkCategory>& result, + QLandmarkManager::Error error, const QString &errorString, QLandmarkAbstractRequest::State newState); + static void updateLandmarkCategoryFetchByIdRequest(QLandmarkCategoryFetchByIdRequest *req, const QList<QLandmarkCategory>& result, QLandmarkManager::Error error, + const QString &errorString, const QMap<int, QLandmarkManager::Error>& errorMap, QLandmarkAbstractRequest::State newState); + static void updateLandmarkCategoryRemoveRequest(QLandmarkCategoryRemoveRequest *req, QLandmarkManager::Error error, const QString &errorString, + const QMap<int, QLandmarkManager::Error>& errorMap, QLandmarkAbstractRequest::State newState); + static void updateLandmarkCategorySaveRequest(QLandmarkCategorySaveRequest *req, const QList<QLandmarkCategory>& result, QLandmarkManager::Error error, + const QString &errorString, const QMap<int, QLandmarkManager::Error>& errorMap, QLandmarkAbstractRequest::State newState); + static void updateLandmarkImportRequest(QLandmarkImportRequest *req, const QList<QLandmarkId> &ids, QLandmarkManager::Error error, const QString &errorString, + QLandmarkAbstractRequest::State newState); + static void updateLandmarkExportRequest(QLandmarkExportRequest *req, QLandmarkManager::Error error, const QString &errorString, + QLandmarkAbstractRequest::State newState); + + static int compareLandmark(const QLandmark& a, const QLandmark& b, const QList<QLandmarkSortOrder>& sortOrders); + static int compareName(const QLandmark &a, const QLandmark &b, const QLandmarkNameSort &nameSort); + + static void addSorted(QList<QLandmark>* sorted, const QLandmark& landmark, const QList<QLandmarkSortOrder>& sortOrders); + static bool testFilter(const QLandmarkFilter& filter, const QLandmark& landmark); + static QList<QLandmarkId> sortLandmarks(const QList<QLandmark>& landmarks, const QList<QLandmarkSortOrder>& sortOrders); +}; + +QTM_END_NAMESPACE + +#endif diff --git a/src/location/landmarks/qlandmarkmanagerenginefactory.cpp b/src/location/landmarks/qlandmarkmanagerenginefactory.cpp new file mode 100644 index 00000000..e4d2a402 --- /dev/null +++ b/src/location/landmarks/qlandmarkmanagerenginefactory.cpp @@ -0,0 +1,105 @@ +/**************************************************************************** +** +** Copyright (C) 2009 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 "qlandmarkmanagerenginefactory.h" +#include <QList> + +QTM_BEGIN_NAMESPACE + +/*! + \class QLandmarkManagerEngineFactory + \brief The QLandmarkManagerEngineFactory class provides the interface for + plugins that implement QLandmarkManagerEngine functionality. + + \inmodule QtLocation + + \ingroup landmarks-backend + + This class provides a simple interface for the creation of + landmark manager engine instances. Each factory has a specific id + associated with it, which forms the \c managerName parameter + when creating \l QLandmarkManager objects. + + \sa QLandmarkManager, QLandmarkManagerEngine + */ + +/*! + Destroys the engine factory. + */ +QLandmarkManagerEngineFactory::~QLandmarkManagerEngineFactory() +{ +} + +/*! + This function returns a list of versions of the engine which this factory can instantiate. + */ +QList<int> QLandmarkManagerEngineFactory::supportedImplementationVersions() const +{ + return QList<int>(); +} + +/*! + \fn QLandmarkManagerEngineFactory::managerName() const + + This function returns a unique string that identifies + the engine provided by this factory. + + Typically this would be of the form "com.nokia.qt.landmarks.engines.sqlite", with + the appropriate domain and engine name substituted. + */ + +/*! + \fn QLandmarkManagerEngineFactory::engine(const QMap<QString, QString>& parameters, QLandmarkManager::Error *error, + QString *errorString) + + This function is called by the QLandmarkManager implementation to + create an instance of the engine provided by this factory. + + The \a parameters supplied can be ignored or interpreted as desired. + + If a supplied parameter results in an unfulfillable request, or some other error + occurs, this function may return a null pointer, and the client developer will get an + invalid QLandmarkManager in return. Errors are stored in \a error and \a errorString. + */ + +QTM_END_NAMESPACE + + diff --git a/src/location/landmarks/qlandmarkmanagerenginefactory.h b/src/location/landmarks/qlandmarkmanagerenginefactory.h new file mode 100644 index 00000000..e5419a9b --- /dev/null +++ b/src/location/landmarks/qlandmarkmanagerenginefactory.h @@ -0,0 +1,70 @@ +/**************************************************************************** +** +** Copyright (C) 2009 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 QLANDMARKMANAGERENGINEFACTORY_H +#define QLANDMARKMANAGERENGINEFACTORY_H + +#include "qmobilityglobal.h" +#include "qlandmarkmanager.h" +#include <QList> + +QTM_BEGIN_NAMESPACE + +class QLandmarkManagerEngine; +class Q_LOCATION_EXPORT QLandmarkManagerEngineFactory +{ +public: + virtual QList<int> supportedImplementationVersions() const; + virtual ~QLandmarkManagerEngineFactory(); + virtual QLandmarkManagerEngine *engine(const QMap<QString, QString> ¶meters, + QLandmarkManager::Error *error, + QString *errorString) = 0; + virtual QString managerName() const = 0; +}; + +QTM_END_NAMESPACE + +QT_BEGIN_NAMESPACE +#define QT_LANDMARKS_BACKEND_INTERFACE "com.nokia.qt.mobility.landmarks.enginefactory/1.0" +Q_DECLARE_INTERFACE(QtMobility::QLandmarkManagerEngineFactory, QT_LANDMARKS_BACKEND_INTERFACE); +QT_END_NAMESPACE + +#endif diff --git a/src/location/landmarks/qlandmarknamefilter.cpp b/src/location/landmarks/qlandmarknamefilter.cpp new file mode 100644 index 00000000..4c16a716 --- /dev/null +++ b/src/location/landmarks/qlandmarknamefilter.cpp @@ -0,0 +1,138 @@ +/**************************************************************************** +** +** Copyright (C) 2009 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 "qlandmarknamefilter.h" +#include "qlandmarknamefilter_p.h" + +QTM_BEGIN_NAMESPACE + +/*! + \class QLandmarkNameFilter + \brief The QLandmarkNameFilter class is used to search for landmarks by name. + + \inmodule QtLocation + \since 1.1 + + \ingroup landmarks-filter + + Please note that different platforms support different capabilities with the attribute filter. + \list + \o The S60 3.1, 3.2 and 5.0 platforms do not support the MatchContains flag while the Symbian + platform does. + \o Note also that MatchContains is supported using the sparql and sqlite \l {Landmark Managers and Plugins} {managers}. + \endlist +*/ + +Q_IMPLEMENT_LANDMARKFILTER_PRIVATE(QLandmarkNameFilter) + +/*! + Creates a filter that selects landmarks by \a name. +*/ +QLandmarkNameFilter::QLandmarkNameFilter(const QString &name) + : QLandmarkFilter(new QLandmarkNameFilterPrivate(name)) {} + +/*! + \fn QLandmarkNameFilter::QLandmarkNameFilter(const QLandmarkFilter &other) + Constructs a copy of \a other if possible, otherwise constructs a new name filter. +*/ + +/*! + Destroys the filter. +*/ +QLandmarkNameFilter::~QLandmarkNameFilter() +{ + // pointer deleted in superclass destructor +} + +/*! + Returns the name that the filter will use to determine matches. +*/ +QString QLandmarkNameFilter::name() const +{ + Q_D(const QLandmarkNameFilter); + return d->name; +} + +/*! + Sets the \a name that the filter will use to determine matches. +*/ +void QLandmarkNameFilter::setName(const QString &name) +{ + Q_D(QLandmarkNameFilter); + d->name = name; +} + +/*! + Returns the matching criteria of the filter. +*/ +QLandmarkFilter::MatchFlags QLandmarkNameFilter::matchFlags() const +{ + Q_D(const QLandmarkNameFilter); + return d->flags; +} + +/*! + Sets the matching criteria to those defined in \a flags. +*/ +void QLandmarkNameFilter::setMatchFlags(QLandmarkFilter::MatchFlags flags) +{ + Q_D(QLandmarkNameFilter); + d->flags = flags; +} + +/******************************************************************************* +*******************************************************************************/ + +QLandmarkNameFilterPrivate::QLandmarkNameFilterPrivate(const QString &name) + : name(name), + flags(0) +{ + type = QLandmarkFilter::NameFilter; +} + +QLandmarkNameFilterPrivate::QLandmarkNameFilterPrivate(const QLandmarkNameFilterPrivate &other) + : QLandmarkFilterPrivate(other), + name(other.name), + flags(other.flags) {} + +QLandmarkNameFilterPrivate::~QLandmarkNameFilterPrivate() {} + +QTM_END_NAMESPACE diff --git a/src/location/landmarks/qlandmarknamefilter.h b/src/location/landmarks/qlandmarknamefilter.h new file mode 100644 index 00000000..1fa03f68 --- /dev/null +++ b/src/location/landmarks/qlandmarknamefilter.h @@ -0,0 +1,72 @@ +/**************************************************************************** +** +** Copyright (C) 2009 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 QLANDMARKNAMEFILTER_H +#define QLANDMARKNAMEFILTER_H + +#include "qlandmarkfilter.h" +#include "qnamespace.h" + +#include <QString> + +QTM_BEGIN_NAMESPACE + +class QLandmarkNameFilterPrivate; +class Q_LOCATION_EXPORT QLandmarkNameFilter : public QLandmarkFilter +{ +public: + QLandmarkNameFilter(const QString &name = QString()); + QLandmarkNameFilter(const QLandmarkFilter &other); + virtual ~QLandmarkNameFilter(); + + QString name() const; + void setName(const QString &name); + + QLandmarkFilter::MatchFlags matchFlags() const; + void setMatchFlags(QLandmarkFilter::MatchFlags flags); + +private: + Q_DECLARE_LANDMARKFILTER_PRIVATE(QLandmarkNameFilter) +}; + +QTM_END_NAMESPACE + +#endif diff --git a/src/location/landmarks/qlandmarknamefilter_p.h b/src/location/landmarks/qlandmarknamefilter_p.h new file mode 100644 index 00000000..b10c4daa --- /dev/null +++ b/src/location/landmarks/qlandmarknamefilter_p.h @@ -0,0 +1,85 @@ +/**************************************************************************** +** +** Copyright (C) 2009 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 QLANDMARKNAMEFILTER_P_H +#define QLANDMARKNAMEFILTER_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 "qlandmarkfilter_p.h" + +#include "qnamespace.h" +#include <QString> + +QTM_BEGIN_NAMESPACE + +class QLandmarkNameFilterPrivate : public QLandmarkFilterPrivate +{ +public: + QLandmarkNameFilterPrivate(const QString &name = QString()); + QLandmarkNameFilterPrivate(const QLandmarkNameFilterPrivate &other); + virtual ~QLandmarkNameFilterPrivate(); + + virtual bool compare(const QLandmarkFilterPrivate *other) const + { + const QLandmarkNameFilterPrivate *od = static_cast<const QLandmarkNameFilterPrivate*>(other); + return (name == od->name) + && (flags == od->flags); + } + + Q_IMPLEMENT_LANDMARKFILTER_VIRTUALCTORS(QLandmarkNameFilter, QLandmarkFilter::NameFilter) + + QString name; + QLandmarkFilter::MatchFlags flags; +}; + +QTM_END_NAMESPACE + +#endif diff --git a/src/location/landmarks/qlandmarknamesort.cpp b/src/location/landmarks/qlandmarknamesort.cpp new file mode 100644 index 00000000..29ef3209 --- /dev/null +++ b/src/location/landmarks/qlandmarknamesort.cpp @@ -0,0 +1,119 @@ +/**************************************************************************** +** +** Copyright (C) 2009 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 "qlandmarknamesort.h" +#include "qlandmarknamesort_p.h" + +QTM_BEGIN_NAMESPACE + +/*! + \class QLandmarkNameSort + \brief The QLandmarkNameSort class is used to sort landmarks by name. + + \inmodule QtLocation + + \ingroup landmarks-sort + \since 1.1 + + Note that some manager's may not support case sensitive sorting. +*/ + +Q_IMPLEMENT_LANDMARKSORTORDER_PRIVATE(QLandmarkNameSort) + +/*! + Creates a sort order that sorts by name according to the given \a direction and + case \a sensitivity. +*/ +QLandmarkNameSort::QLandmarkNameSort(Qt::SortOrder direction, Qt::CaseSensitivity sensitivity) + : QLandmarkSortOrder(new QLandmarkNameSortPrivate()) +{ + Q_D(QLandmarkNameSort); + d->order = direction; + d->sensitivity = sensitivity; +} + +/*! + \fn QLandmarkNameSort::QLandmarkNameSort(const QLandmarkSortOrder &other) + Constructs a copy of \a other if possible, otherwise constructs a new name sort order. +*/ + +/*! + Destroys the sort order. +*/ +QLandmarkNameSort::~QLandmarkNameSort() +{ +} + +/*! + Returns the case sensitivity of the sort order. +*/ +Qt::CaseSensitivity QLandmarkNameSort::caseSensitivity() const +{ + Q_D(const QLandmarkNameSort); + return d->sensitivity; +} + +/*! + Sets the the \a caseSensitivity of the sort order. +*/ +void QLandmarkNameSort::setCaseSensitivity(Qt::CaseSensitivity caseSensitivity) +{ + Q_D(QLandmarkNameSort); + d->sensitivity = caseSensitivity; +} + +/******************************************************************************* +*******************************************************************************/ +QLandmarkNameSortPrivate::QLandmarkNameSortPrivate() + : QLandmarkSortOrderPrivate(), + sensitivity(Qt::CaseInsensitive) +{ + type = QLandmarkSortOrder::NameSort; +} + +QLandmarkNameSortPrivate::QLandmarkNameSortPrivate(const QLandmarkNameSortPrivate &other) + : QLandmarkSortOrderPrivate(other), + sensitivity(other.sensitivity) {} + +QLandmarkNameSortPrivate::~QLandmarkNameSortPrivate() {} + + +QTM_END_NAMESPACE diff --git a/src/location/landmarks/qlandmarknamesort.h b/src/location/landmarks/qlandmarknamesort.h new file mode 100644 index 00000000..0b2a1d69 --- /dev/null +++ b/src/location/landmarks/qlandmarknamesort.h @@ -0,0 +1,69 @@ +/**************************************************************************** +** +** Copyright (C) 2009 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 QLANDMARKNAMESORT_H +#define QLANDMARKNAMESORT_H + +#include "qlandmarksortorder.h" + +QT_BEGIN_HEADER + +QTM_BEGIN_NAMESPACE + +class QLandmarkNameSortPrivate; +class Q_LOCATION_EXPORT QLandmarkNameSort : public QLandmarkSortOrder +{ +public: + QLandmarkNameSort(Qt::SortOrder direction = Qt::AscendingOrder, Qt::CaseSensitivity = Qt::CaseInsensitive); + QLandmarkNameSort(const QLandmarkSortOrder &other); + virtual ~QLandmarkNameSort(); + + Qt::CaseSensitivity caseSensitivity() const; + void setCaseSensitivity(Qt::CaseSensitivity sensitivity); +private: + Q_DECLARE_LANDMARKSORTORDER_PRIVATE(QLandmarkNameSort) +}; + +QTM_END_NAMESPACE + +QT_END_HEADER + +#endif diff --git a/src/location/landmarks/qlandmarknamesort_p.h b/src/location/landmarks/qlandmarknamesort_p.h new file mode 100644 index 00000000..84638fb8 --- /dev/null +++ b/src/location/landmarks/qlandmarknamesort_p.h @@ -0,0 +1,81 @@ +/**************************************************************************** +** +** Copyright (C) 2009 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 QLANDMARKNAMESORT_P_H +#define QLANDMARKNAMESORT_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 "qlandmarksortorder_p.h" + +QTM_BEGIN_NAMESPACE + +class QLandmarkNameSortPrivate : public QLandmarkSortOrderPrivate +{ +public: + QLandmarkNameSortPrivate(); + QLandmarkNameSortPrivate(const QLandmarkNameSortPrivate &other); + virtual ~QLandmarkNameSortPrivate(); + + virtual bool compare(const QLandmarkSortOrderPrivate *other) const + { + //it is assumed that the types and superclass member variables already match + const QLandmarkNameSortPrivate *od = static_cast<const QLandmarkNameSortPrivate*>(other); + return sensitivity == od->sensitivity; + } + + Q_IMPLEMENT_LANDMARKSORTORDER_VIRTUALCTORS(QLandmarkNameSort, QLandmarkSortOrder::NameSort) + + Qt::CaseSensitivity sensitivity; +}; + +QTM_END_NAMESPACE + +#endif diff --git a/src/location/landmarks/qlandmarkproximityfilter.cpp b/src/location/landmarks/qlandmarkproximityfilter.cpp new file mode 100644 index 00000000..cfe32e29 --- /dev/null +++ b/src/location/landmarks/qlandmarkproximityfilter.cpp @@ -0,0 +1,171 @@ +/**************************************************************************** +** +** Copyright (C) 2009 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 "qlandmarkproximityfilter.h" +#include "qlandmarkproximityfilter_p.h" +#include "qgeocoordinate.h" + +QTM_BEGIN_NAMESPACE + +/*! + \class QLandmarkProximityFilter + \brief The QLandmarkProximityFilter class is used to search for landmarks based on the radius + around a given coordinate and perform sorting by distance. + + \inmodule QtLocation + + \ingroup landmarks-filter + \since 1.1 + + In order to be a valid filter, the region covered by the proximity filter must not cover one of the poles. + The landmarks are returned in ascending order of distance. A proximity filter may + be used inside an intersection filter to sort landmarks by distance in combination with other + criteria such as categories. (Note that a using sort order other than QLandmarkSortOrder (i.e. no sort) + will override the sorting by distance). + +*/ + +Q_IMPLEMENT_LANDMARKFILTER_PRIVATE(QLandmarkProximityFilter) + +/*! + Creates a filter that will select landmarks within a given \a radius around + a \a center coordinate. +*/ +QLandmarkProximityFilter::QLandmarkProximityFilter(const QGeoCoordinate ¢er, qreal radius) + : QLandmarkFilter(new QLandmarkProximityFilterPrivate(QGeoBoundingCircle(center, radius))) +{ +} + +/*! + Creates a filter that will select landmarks withiin a given bounding \a circle. + */ +QLandmarkProximityFilter::QLandmarkProximityFilter(const QGeoBoundingCircle &circle) + : QLandmarkFilter(new QLandmarkProximityFilterPrivate(circle)) +{ +} + +/*! + \fn QLandmarkProximityFilter::QLandmarkProximityFilter(const QLandmarkFilter &other) + Constructs a copy of \a other if possible, otherwise constructs a new proximity filter. +*/ + +/*! + Destroys the filter. +*/ +QLandmarkProximityFilter::~QLandmarkProximityFilter() +{ + // pointer deleted in superclass destructor +} + +/*! + Returns the center coordinate of the filter. +*/ +QGeoCoordinate QLandmarkProximityFilter::center() const +{ + Q_D(const QLandmarkProximityFilter); + return d->circle.center(); +} + +/*! + Sets the \a center coordinate of the filter. +*/ +void QLandmarkProximityFilter::setCenter(const QGeoCoordinate ¢er) +{ + Q_D(QLandmarkProximityFilter); + d->circle.setCenter(center); +} + +/*! + Returns the radius of the filter. The unit of the radius is meters. +*/ +qreal QLandmarkProximityFilter::radius() const +{ + Q_D(const QLandmarkProximityFilter); + return d->circle.radius(); +} + +/*! + Sets the \a radius of the filter. The unit of the radius is meters. +*/ +void QLandmarkProximityFilter::setRadius(qreal radius) +{ + Q_D(QLandmarkProximityFilter); + d->circle.setRadius(radius); +} + +/*! + Sets the bounding circle for the proximity filter. +*/ +QGeoBoundingCircle QLandmarkProximityFilter::boundingCircle() +{ + Q_D(const QLandmarkProximityFilter); + return d->circle; +} + +/*! + Sets the bounding \a circle for the proximity filter +*/ +void QLandmarkProximityFilter::setBoundingCircle(const QGeoBoundingCircle &circle) +{ + Q_D(QLandmarkProximityFilter); + d->circle = circle; +} + +/******************************************************************************* +*******************************************************************************/ + +QLandmarkProximityFilterPrivate::QLandmarkProximityFilterPrivate(const QGeoBoundingCircle &circle) + : QLandmarkFilterPrivate(), + circle(circle) +{ + type = QLandmarkFilter::ProximityFilter; +} + +QLandmarkProximityFilterPrivate::QLandmarkProximityFilterPrivate(const QLandmarkProximityFilterPrivate &other) + : QLandmarkFilterPrivate(other) +{ + circle.setCenter(other.circle.center()); + circle.setRadius(other.circle.radius()); +} + +QLandmarkProximityFilterPrivate::~QLandmarkProximityFilterPrivate() {} + +QTM_END_NAMESPACE diff --git a/src/location/landmarks/qlandmarkproximityfilter.h b/src/location/landmarks/qlandmarkproximityfilter.h new file mode 100644 index 00000000..ed59558f --- /dev/null +++ b/src/location/landmarks/qlandmarkproximityfilter.h @@ -0,0 +1,79 @@ +/**************************************************************************** +** +** Copyright (C) 2009 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 QLANDMARKPROXIMITY_H +#define QLANDMARKPROXIMITY_H + +#include "qlandmarkfilter.h" +#include "qgeocoordinate.h" +#include "qgeoboundingcircle.h" + +QT_BEGIN_HEADER + +QTM_BEGIN_NAMESPACE + +class QLandmarkProximityFilterPrivate; +class Q_LOCATION_EXPORT QLandmarkProximityFilter : public QLandmarkFilter +{ +public: + QLandmarkProximityFilter(const QGeoCoordinate ¢er = QGeoCoordinate(), qreal radius = -1); + QLandmarkProximityFilter(const QGeoBoundingCircle &circle); + QLandmarkProximityFilter(const QLandmarkFilter &other); + virtual ~QLandmarkProximityFilter(); + + QGeoCoordinate center() const; + void setCenter(const QGeoCoordinate ¢er); + + qreal radius() const; + void setRadius(qreal radius); + + QGeoBoundingCircle boundingCircle(); + void setBoundingCircle(const QGeoBoundingCircle &circle); + +private: + Q_DECLARE_LANDMARKFILTER_PRIVATE(QLandmarkProximityFilter) +}; + +QTM_END_NAMESPACE + +QT_END_HEADER + +#endif diff --git a/src/location/landmarks/qlandmarkproximityfilter_p.h b/src/location/landmarks/qlandmarkproximityfilter_p.h new file mode 100644 index 00000000..7b77e1f7 --- /dev/null +++ b/src/location/landmarks/qlandmarkproximityfilter_p.h @@ -0,0 +1,84 @@ +/**************************************************************************** +** +** Copyright (C) 2009 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 QLANDMARKPROXIMITYFILTER_P_H +#define QLANDMARKPROXIMITYFILTER_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 "qlandmarkfilter_p.h" +#include "qlandmarkproximityfilter.h" + +QTM_BEGIN_NAMESPACE + +class QGeoCoordinate; + +class QLandmarkProximityFilterPrivate : public QLandmarkFilterPrivate +{ +public: + QLandmarkProximityFilterPrivate(const QGeoBoundingCircle &circle = QGeoBoundingCircle()); + QLandmarkProximityFilterPrivate(const QLandmarkProximityFilterPrivate &other); + virtual ~QLandmarkProximityFilterPrivate(); + + virtual bool compare(const QLandmarkFilterPrivate *other) const + { + //it is assumed that the types and superclass member variables already match + const QLandmarkProximityFilterPrivate *od = static_cast<const QLandmarkProximityFilterPrivate*>(other); + return (circle == od->circle); + } + + Q_IMPLEMENT_LANDMARKFILTER_VIRTUALCTORS(QLandmarkProximityFilter, QLandmarkFilter::ProximityFilter) + + QGeoBoundingCircle circle; +}; + +QTM_END_NAMESPACE + +#endif diff --git a/src/location/landmarks/qlandmarkremoverequest.cpp b/src/location/landmarks/qlandmarkremoverequest.cpp new file mode 100644 index 00000000..6ef90ecf --- /dev/null +++ b/src/location/landmarks/qlandmarkremoverequest.cpp @@ -0,0 +1,163 @@ +/**************************************************************************** +** +** Copyright (C) 2009 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 "qlandmarkremoverequest.h" +#include "qlandmarkrequests_p.h" +#include <QMap> + +QTM_BEGIN_NAMESPACE + +/*! + \class QLandmarkRemoveRequest + \brief The QLandmarkRemoveRequest class allows a client to asynchronously + request that certain landmarks be removed from a landmark manager. + + For a QLandmarkRemoveRequest, the resultsAvailable() signal will be emitted + when either an individual items error out (individaul errors may be retrieved + by calling errorMap()), or when an overall operation error occurs(which may be + retrieved by calling error()). + + Please see the class documentation for QLandmarkAbstractRequest for more information about + the usage of request classes and ownership semantics. + + \inmodule QtLocation + + \ingroup landmarks-request + \since 1.1 +*/ + +/*! + Constructs a landmark remove request with the given \a manager and \a parent. +*/ +QLandmarkRemoveRequest::QLandmarkRemoveRequest(QLandmarkManager *manager, QObject *parent) + : QLandmarkAbstractRequest(new QLandmarkRemoveRequestPrivate(manager), parent) +{ +} + +/*! + Destroys the request object. +*/ +QLandmarkRemoveRequest::~QLandmarkRemoveRequest() +{ +} + +/*! + Returns the list of identifiers of landmarks which will be removed. +*/ +QList<QLandmarkId> QLandmarkRemoveRequest::landmarkIds() const +{ + Q_D(const QLandmarkRemoveRequest); + QMutexLocker ml(&d->mutex); + return d->landmarkIds; +} + +/*! + Sets the list of \a landmarkIds of landmarks which will be removed. + + \sa setLandmarkId() +*/ +void QLandmarkRemoveRequest::setLandmarkIds(const QList<QLandmarkId> &landmarkIds) +{ + Q_D(QLandmarkRemoveRequest); + QMutexLocker ml(&d->mutex); + d->landmarkIds = landmarkIds; +} + +/*! + Convenience function to set the \a landmarkId of a single landmark to be removed. + It is the equivalent of calling setLandmarkIds() with a single \a landmarkId + in the ID list. + + \sa setLandmarkIds() +*/ +void QLandmarkRemoveRequest::setLandmarkId(const QLandmarkId &landmarkId) +{ + Q_D(QLandmarkRemoveRequest); + QMutexLocker ml(&d->mutex); + d->landmarkIds.clear(); + d->landmarkIds.append((landmarkId)); +} + +/*! + Convenience function to set the list of \a landmarks which will be removed. + This function is the equivalent of calling setLandmarkIds() with the IDs of + the \a landmarks. + + \sa setLandmarkIds() +*/ +void QLandmarkRemoveRequest::setLandmarks(const QList<QLandmark> &landmarks) +{ + Q_D(QLandmarkRemoveRequest); + QMutexLocker ml(&d->mutex); + d->landmarkIds.clear(); + for (int i=0; i < landmarks.count(); ++i) + d->landmarkIds.append(landmarks.at(i).landmarkId()); +} + +/*! + Convenience function that sets a single \a landmark to be removed. + This function is the equivalent of calling setLandmarkIds() + with the ID of \a landmark. +*/ +void QLandmarkRemoveRequest::setLandmark(const QLandmark &landmark) +{ + Q_D(QLandmarkRemoveRequest); + QMutexLocker ml(&d->mutex); + d->landmarkIds.clear(); + d->landmarkIds.append(landmark.landmarkId()); +} + +/*! + Returns the mapping of input landmark ID list indices + to the errors which occurred. +*/ +QMap<int, QLandmarkManager::Error> QLandmarkRemoveRequest::errorMap() const +{ + Q_D(const QLandmarkRemoveRequest); + QMutexLocker ml(&d->mutex); + return d->errorMap; +} + +#include "moc_qlandmarkremoverequest.cpp" + +QTM_END_NAMESPACE + + diff --git a/src/location/landmarks/qlandmarkremoverequest.h b/src/location/landmarks/qlandmarkremoverequest.h new file mode 100644 index 00000000..12ba70bc --- /dev/null +++ b/src/location/landmarks/qlandmarkremoverequest.h @@ -0,0 +1,74 @@ +/**************************************************************************** +** +** Copyright (C) 2009 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 QLANDMARKREMOVEREQUEST_H +#define QLANDMARKREMOVEREQUEST_H + +#include "qlandmarkabstractrequest.h" + +QTM_BEGIN_NAMESPACE + +class QLandmarkRemoveRequestPrivate; +class Q_LOCATION_EXPORT QLandmarkRemoveRequest : public QLandmarkAbstractRequest +{ + Q_OBJECT +public: + QLandmarkRemoveRequest(QLandmarkManager *manager, QObject *parent = 0); + ~QLandmarkRemoveRequest(); + + QList<QLandmarkId> landmarkIds() const; + void setLandmarkIds(const QList<QLandmarkId> &landmarkIds); + void setLandmarkId(const QLandmarkId &landmarkId); + + void setLandmarks(const QList<QLandmark> &landmark); + void setLandmark(const QLandmark &landmark); + + QMap<int, QLandmarkManager::Error> errorMap() const; +private: + Q_DISABLE_COPY(QLandmarkRemoveRequest) + Q_DECLARE_PRIVATE(QLandmarkRemoveRequest) + friend class QLandmarkManagerEngine; +}; + +QTM_END_NAMESPACE + +#endif + diff --git a/src/location/landmarks/qlandmarkrequests_p.h b/src/location/landmarks/qlandmarkrequests_p.h new file mode 100644 index 00000000..99c1fdd9 --- /dev/null +++ b/src/location/landmarks/qlandmarkrequests_p.h @@ -0,0 +1,257 @@ +/**************************************************************************** +** +** Copyright (C) 2009 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 QLANDMARKREQUESTS_P_H +#define QLANDMARKREQUESTS_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 "qlandmarkabstractrequest_p.h" +#include "qlandmark.h" +#include "qlandmarkcategory.h" +#include "qlandmarkcategoryfetchrequest.h" +#include "qlandmarknamesort.h" + +QTM_BEGIN_NAMESPACE + +class QLandmarkIdFetchRequestPrivate : public QLandmarkAbstractRequestPrivate +{ +public: + QLandmarkIdFetchRequestPrivate(QLandmarkManager *mgr) + : QLandmarkAbstractRequestPrivate(mgr), + limit(-1), offset(0) + { + type = QLandmarkAbstractRequest::LandmarkIdFetchRequest; + } + + QLandmarkFilter filter; + QList<QLandmarkSortOrder>sorting; + int limit; + int offset; + QList<QLandmarkId> landmarkIds; +}; + +class QLandmarkFetchRequestPrivate : public QLandmarkAbstractRequestPrivate +{ +public: + QLandmarkFetchRequestPrivate(QLandmarkManager *mgr) + : QLandmarkAbstractRequestPrivate(mgr), + limit(-1), offset(0) + { + type = QLandmarkAbstractRequest::LandmarkFetchRequest; + } + QLandmarkFilter filter; + QList<QLandmarkSortOrder> sorting; + int limit; + int offset; + QList<QLandmark> landmarks; +}; + +class QLandmarkFetchByIdRequestPrivate : public QLandmarkAbstractRequestPrivate +{ +public: + QLandmarkFetchByIdRequestPrivate(QLandmarkManager *mgr) + : QLandmarkAbstractRequestPrivate(mgr) + { + type = QLandmarkAbstractRequest::LandmarkFetchByIdRequest; + } + + QList<QLandmarkId> landmarkIds; + QList<QLandmark> landmarks; + QMap<int, QLandmarkManager::Error> errorMap; +}; + +class QLandmarkRemoveRequestPrivate : public QLandmarkAbstractRequestPrivate +{ +public: + QLandmarkRemoveRequestPrivate(QLandmarkManager *manager) + : QLandmarkAbstractRequestPrivate(manager) + { + type = QLandmarkAbstractRequest::LandmarkRemoveRequest; + } + + QList<QLandmarkId> landmarkIds; + QMap<int, QLandmarkManager::Error> errorMap; +}; + + +class QLandmarkSaveRequestPrivate : public QLandmarkAbstractRequestPrivate +{ +public: + QLandmarkSaveRequestPrivate(QLandmarkManager *mgr) + : QLandmarkAbstractRequestPrivate(mgr) + { + type = QLandmarkAbstractRequest::LandmarkSaveRequest; + } + + QList<QLandmark> landmarks; + QMap<int, QLandmarkManager::Error> errorMap; +}; + +class QLandmarkCategoryIdFetchRequestPrivate: public QLandmarkAbstractRequestPrivate +{ +public: + QLandmarkCategoryIdFetchRequestPrivate(QLandmarkManager *mgr) + : QLandmarkAbstractRequestPrivate(mgr), + limit(-1), offset(0) + { + type = QLandmarkAbstractRequest::CategoryIdFetchRequest; + } + + QList<QLandmarkCategoryId> categoryIds; + QLandmarkNameSort sorting; + int limit; + int offset; +}; + +class QLandmarkCategoryFetchRequestPrivate : public QLandmarkAbstractRequestPrivate +{ +public: + QLandmarkCategoryFetchRequestPrivate(QLandmarkManager *mgr) + :QLandmarkAbstractRequestPrivate(mgr), + limit(-1), offset(0) + { + type = QLandmarkAbstractRequest::CategoryFetchRequest; + } + + QList<QLandmarkCategory> categories; + QLandmarkNameSort sorting; + int limit; + int offset; +}; + +class QLandmarkCategoryFetchByIdRequestPrivate : public QLandmarkAbstractRequestPrivate +{ +public: + QLandmarkCategoryFetchByIdRequestPrivate(QLandmarkManager *mgr) + :QLandmarkAbstractRequestPrivate(mgr) + { + type = QLandmarkAbstractRequest::CategoryFetchByIdRequest; + } + + QList<QLandmarkCategoryId> categoryIds; + QList<QLandmarkCategory> categories; + QMap<int, QLandmarkManager::Error> errorMap; +}; + +class QLandmarkCategoryRemoveRequestPrivate : public QLandmarkAbstractRequestPrivate +{ +public: + QLandmarkCategoryRemoveRequestPrivate(QLandmarkManager *mgr) + : QLandmarkAbstractRequestPrivate(mgr) + { + type = QLandmarkAbstractRequest::CategoryRemoveRequest; + } + + + QList<QLandmarkCategoryId> categoryIds; + QMap<int, QLandmarkManager::Error> errorMap; +}; + +class QLandmarkCategorySaveRequestPrivate : public QLandmarkAbstractRequestPrivate +{ +public: + QLandmarkCategorySaveRequestPrivate(QLandmarkManager *mgr) + : QLandmarkAbstractRequestPrivate(mgr) + { + type = QLandmarkAbstractRequest::CategorySaveRequest; + } + + QList<QLandmarkCategory> categories; + QMap<int, QLandmarkManager::Error> errorMap; +}; + +class QLandmarkImportRequestPrivate : public QLandmarkAbstractRequestPrivate +{ +public: + QLandmarkImportRequestPrivate(QLandmarkManager *mgr) + : QLandmarkAbstractRequestPrivate(mgr), + device(0), + fileName(QString()), + format(QString()), + option(QLandmarkManager::IncludeCategoryData), + categoryId(QLandmarkCategoryId()), + landmarkIds(QList<QLandmarkId>()) + { + type = QLandmarkAbstractRequest::ImportRequest; + } + + QIODevice *device; + QString fileName; + QString format; + QLandmarkManager::TransferOption option; + QLandmarkCategoryId categoryId; + QList<QLandmarkId> landmarkIds; +}; + +class QLandmarkExportRequestPrivate : public QLandmarkAbstractRequestPrivate +{ +public: + QLandmarkExportRequestPrivate(QLandmarkManager *mgr) + : QLandmarkAbstractRequestPrivate(mgr), + device(0), + fileName(QString()), + format(QString()), + option(QLandmarkManager::IncludeCategoryData), + landmarkIds(QList<QLandmarkId>()) + { + type = QLandmarkAbstractRequest::ExportRequest; + } + + QIODevice *device; + QString fileName; + QString format; + QLandmarkManager::TransferOption option; + QList<QLandmarkId> landmarkIds; +}; + +QTM_END_NAMESPACE + +#endif diff --git a/src/location/landmarks/qlandmarksaverequest.cpp b/src/location/landmarks/qlandmarksaverequest.cpp new file mode 100644 index 00000000..8c521495 --- /dev/null +++ b/src/location/landmarks/qlandmarksaverequest.cpp @@ -0,0 +1,137 @@ +/**************************************************************************** +** +** Copyright (C) 2009 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 "qlandmarksaverequest.h" +#include "qlandmarkrequests_p.h" +#include "qlandmark.h" + + +QTM_BEGIN_NAMESPACE + +/*! + \class QLandmarkSaveRequest + \brief The QLandmarkSaveRequest class allows a client to asynchronously + request that certain landmarks be saved by a landmark manager. + + \inmodule QtLocation + + \ingroup landmarks-request + \since 1.1 + + For a QLandmarkSaveRequest, the resultsAvailable() signal will be emitted + when either an individual items error out (individaul errors may be retrieved + by calling errorMap()), or when an overall operation error occurs(which may be + retrieved by calling error()). + + Please see the class documentation for QLandmarkAbstractRequest for more information about + the usage of request classes and ownership semantics. +*/ + +/*! + Constructs a landmark save request with the given \a manager and \a parent. +*/ +QLandmarkSaveRequest::QLandmarkSaveRequest(QLandmarkManager *manager, QObject *parent) + : QLandmarkAbstractRequest(new QLandmarkSaveRequestPrivate(manager), parent) +{ +} + +/*! + Destroys the request object. +*/ +QLandmarkSaveRequest::~QLandmarkSaveRequest() +{ +} + +/*! + Returns the list of landmarks to be saved. If called after the save operation has + finished, any new landmarks will have had their QLandmarkId set. + (Landmarks which were updated or failed to save will remain unchanged, use the + errorMap() function to determine which particular landmarks failed to save.) +*/ +QList<QLandmark> QLandmarkSaveRequest::landmarks() const +{ + Q_D(const QLandmarkSaveRequest); + QMutexLocker ml(&d->mutex); + return d->landmarks; +} + +/*! + Sets the list of \a landmarks to be saved. + + \sa setLandmark() +*/ +void QLandmarkSaveRequest::setLandmarks(const QList<QLandmark> &landmarks) +{ + Q_D(QLandmarkSaveRequest); + QMutexLocker ml(&d->mutex); + d->landmarks = landmarks; +} + +/*! + Convenience function to set a single \a landmark to be saved. This + function is the equivalent of calling setLandmarks() with a single + \a landmark. + + \sa setLandmarks() +*/ +void QLandmarkSaveRequest::setLandmark(const QLandmark &landmark) +{ + Q_D(QLandmarkSaveRequest); + QMutexLocker ml(&d->mutex); + d->landmarks.clear(); + d->landmarks.append(landmark); +} + +/*! + Returns the mapping of input landmark list indices to errors which occurred. +*/ +QMap<int, QLandmarkManager::Error> QLandmarkSaveRequest::errorMap() const +{ + Q_D(const QLandmarkSaveRequest); + QMutexLocker ml(&d->mutex); + return d->errorMap; +} + +#include "moc_qlandmarksaverequest.cpp" + +QTM_END_NAMESPACE + + diff --git a/src/location/landmarks/qlandmarksaverequest.h b/src/location/landmarks/qlandmarksaverequest.h new file mode 100644 index 00000000..db672b86 --- /dev/null +++ b/src/location/landmarks/qlandmarksaverequest.h @@ -0,0 +1,71 @@ +/**************************************************************************** +** +** Copyright (C) 2009 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 QLANDMARKSAVEREQUEST_H +#define QLANDMARKSAVEREQUEST_H + +#include "qlandmarkabstractrequest.h" + +QTM_BEGIN_NAMESPACE + +class QLandmarkSaveRequestPrivate; +class Q_LOCATION_EXPORT QLandmarkSaveRequest : public QLandmarkAbstractRequest +{ + Q_OBJECT +public: + QLandmarkSaveRequest(QLandmarkManager *manager, QObject *parent = 0); + ~QLandmarkSaveRequest(); + + QList<QLandmark> landmarks() const; + void setLandmarks(const QList<QLandmark> &landmarks); + void setLandmark(const QLandmark &landmark); + + QMap<int, QLandmarkManager::Error> errorMap() const; +private: + Q_DISABLE_COPY(QLandmarkSaveRequest) + Q_DECLARE_PRIVATE(QLandmarkSaveRequest) + friend class QLandmarkManagerEngine; +}; + +QTM_END_NAMESPACE + +#endif + diff --git a/src/location/landmarks/qlandmarksortorder.cpp b/src/location/landmarks/qlandmarksortorder.cpp new file mode 100644 index 00000000..74901d57 --- /dev/null +++ b/src/location/landmarks/qlandmarksortorder.cpp @@ -0,0 +1,193 @@ +/**************************************************************************** +** +** Copyright (C) 2009 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 "qlandmarksortorder.h" +#include "qlandmarksortorder_p.h" +#include "qlandmarkid.h" + +#if !defined(Q_CC_MWERKS) +template<> QTM_PREPEND_NAMESPACE(QLandmarkSortOrderPrivate) *QSharedDataPointer<QTM_PREPEND_NAMESPACE(QLandmarkSortOrderPrivate)>::clone() +{ + return d->clone(); +} +#endif + +QTM_BEGIN_NAMESPACE + +/*! + \class QLandmarkSortOrder + \brief The QLandmarkSortOrder class serves as a base class + for the different sort order types and by itself represents + no sorting. + + \inmodule QtLocation + \since 1.1 + + \ingroup landmarks-sort + + The sort orders define how a list of landmarks should be ordered + when they searched using a QLandmarkManager or one of the + landmark request classes. (For sorting by distance + see the QLandmarkProximityFilter). +*/ + +/*! + \enum QLandmarkSortOrder::SortType + Defines the type of sort order. + \value NoSort No sorting is applied + \value NameSort Sorts landmarks by name. +*/ + +/*! + Constructs a landmark sort order. + + The type of the sort order is NoSort. +*/ +QLandmarkSortOrder::QLandmarkSortOrder() + : d_ptr(new QLandmarkSortOrderPrivate()) +{ +} + +/*! + \internal +*/ +QLandmarkSortOrder::QLandmarkSortOrder(QLandmarkSortOrderPrivate *d_ptr) + : d_ptr(d_ptr) +{ +} + +/*! + Constructs a copy of \a other. +*/ +QLandmarkSortOrder::QLandmarkSortOrder(const QLandmarkSortOrder &other) + : d_ptr(other.d_ptr) +{ +} + +/*! + Assigns \a other to this sort order and returns a reference to this + sort order. +*/ +QLandmarkSortOrder &QLandmarkSortOrder::operator=(const QLandmarkSortOrder & other) +{ + d_ptr = other.d_ptr; + return *this; +} + +/*! + Destroys the sort order +*/ +QLandmarkSortOrder::~QLandmarkSortOrder() +{ +} + +/*! + Returns the type of sort. +*/ +QLandmarkSortOrder::SortType QLandmarkSortOrder::type() const +{ + return d_ptr->type; +} + +/*! + Returns the direction of the sort order. +*/ +Qt::SortOrder QLandmarkSortOrder::direction() const +{ + return d_ptr->order; +} + +/*! + Sets the \a direction of the sort order. +*/ +void QLandmarkSortOrder::setDirection(Qt::SortOrder direction) +{ + d_ptr->order = direction; +} + +/*! + \fn QLandmarkSortOrder::operator==(const QLandmarkSortOrder& other) const + Returns true if this sort order is identical to \a other. + \sa operator!=() +*/ +bool QLandmarkSortOrder::operator==(const QLandmarkSortOrder& other) const +{ + + if(!d_ptr->QLandmarkSortOrderPrivate::compare(other.d_ptr)) + return false; + + /* Different types can't be equal */ + if (other.type() != type()) + return false; + + /* Otherwise, use the virtual op == */ + return d_ptr->compare(other.d_ptr); +} + +/*! + \fn QLandmarkSortOrder::operator!=(const QLandmarkSortOrder &other) const + Returns true if this sort order is not identical to \a other. + + \sa operator==() +*/ + +/******************************************************************************* +*******************************************************************************/ + +QLandmarkSortOrderPrivate::QLandmarkSortOrderPrivate() + : QSharedData(), + type(QLandmarkSortOrder::NoSort), + order(Qt::AscendingOrder) +{ +} + +QLandmarkSortOrderPrivate::QLandmarkSortOrderPrivate(const QLandmarkSortOrderPrivate &other) + : QSharedData(), + type(other.type), + order(other.order) +{ +} + +QLandmarkSortOrderPrivate::~QLandmarkSortOrderPrivate() +{ +} + +QTM_END_NAMESPACE diff --git a/src/location/landmarks/qlandmarksortorder.h b/src/location/landmarks/qlandmarksortorder.h new file mode 100644 index 00000000..bb7d0f46 --- /dev/null +++ b/src/location/landmarks/qlandmarksortorder.h @@ -0,0 +1,94 @@ +/**************************************************************************** +** +** Copyright (C) 2009 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 QLANDMARKSORTORDER_H +#define QLANDMARKSORTORDER_H + +#include "qmobilityglobal.h" +#include "qnamespace.h" + +#include <QSharedDataPointer> +#include <QList> + +QT_BEGIN_HEADER + +QTM_BEGIN_NAMESPACE + +#define Q_DECLARE_LANDMARKSORTORDER_PRIVATE(Class) \ + inline Class##Private* d_func(); \ + inline const Class##Private* d_func() const; \ + friend class Class##Private; + +class QLandmarkId; +class QLandmark; + +class QLandmarkSortOrderPrivate; +class Q_LOCATION_EXPORT QLandmarkSortOrder +{ + +friend class QLandmarkSortOrderPrivate; + +public: + enum SortType {NoSort, NameSort}; + + QLandmarkSortOrder(); + QLandmarkSortOrder(const QLandmarkSortOrder &other); + QLandmarkSortOrder& operator = (const QLandmarkSortOrder &other); + virtual ~QLandmarkSortOrder(); + + SortType type() const; + Qt::SortOrder direction() const; + void setDirection(Qt::SortOrder direction); + + bool operator==(const QLandmarkSortOrder &other) const; + bool operator!=(const QLandmarkSortOrder &other) const { + return !(*this == other); + } +protected: + QLandmarkSortOrder(QLandmarkSortOrderPrivate *dd); + QSharedDataPointer<QLandmarkSortOrderPrivate> d_ptr; +}; + +QTM_END_NAMESPACE + +QT_END_HEADER + +#endif diff --git a/src/location/landmarks/qlandmarksortorder_p.h b/src/location/landmarks/qlandmarksortorder_p.h new file mode 100644 index 00000000..0deb04c7 --- /dev/null +++ b/src/location/landmarks/qlandmarksortorder_p.h @@ -0,0 +1,112 @@ +/**************************************************************************** +** +** Copyright (C) 2009 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 QLANDMARKSORTORDER_P_H +#define QLANDMARKSORTORDER_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 "qlandmarksortorder.h" +#include <QSharedData> + +QTM_BEGIN_NAMESPACE + +#define Q_IMPLEMENT_LANDMARKSORTORDER_PRIVATE(Class) \ + Class##Private* Class::d_func() { return reinterpret_cast<Class##Private *>(d_ptr.data()); } \ + const Class##Private* Class::d_func() const { return reinterpret_cast<const Class##Private *>(d_ptr.constData()); } \ + Class::Class(const QLandmarkSortOrder& other) : QLandmarkSortOrder() { Class##Private::copyIfPossible(d_ptr, other); } + +#define Q_IMPLEMENT_LANDMARKSORTORDER_VIRTUALCTORS(Class, Type) \ + virtual QLandmarkSortOrderPrivate* clone() const { return new Class##Private(*this); } \ + static void copyIfPossible(QSharedDataPointer<QLandmarkSortOrderPrivate>& d_ptr, const QLandmarkSortOrder& other) \ + { \ + if (other.type() == Type) \ + d_ptr = extract_d(other); \ + else \ + d_ptr = new Class##Private(); \ + } + +class QLandmarkSortOrderPrivate : public QSharedData +{ +public: + QLandmarkSortOrderPrivate(); + QLandmarkSortOrderPrivate(const QLandmarkSortOrderPrivate &); + virtual ~QLandmarkSortOrderPrivate(); + + virtual bool compare(const QLandmarkSortOrderPrivate *other) const { + return order == other->order; + } + + /* Helper functions for C++ protection rules */ + static const QSharedDataPointer<QLandmarkSortOrderPrivate>& extract_d(const QLandmarkSortOrder& other) {return other.d_ptr;} + + Q_IMPLEMENT_LANDMARKSORTORDER_VIRTUALCTORS(QLandmarkSortOrder, QLandmarkSortOrder::NoSort) + + QLandmarkSortOrder::SortType type; + Qt::SortOrder order; +}; + +QTM_END_NAMESPACE + +#if defined(Q_CC_MWERKS) +// This results in multiple symbol definition errors on all other compilers +// but not having a definition here results in an attempt to use the unspecialized +// clone (which fails because of the pure virtuals above) +template<> QTM_PREPEND_NAMESPACE(QLandmarkSortOrderPrivate) *QSharedDataPointer<QTM_PREPEND_NAMESPACE(QLandmarkSortOrderPrivate)>::clone() +{ + return d->clone(); +} +#else +template<> QTM_PREPEND_NAMESPACE(QLandmarkSortOrderPrivate) *QSharedDataPointer<QTM_PREPEND_NAMESPACE(QLandmarkSortOrderPrivate)>::clone(); +#endif + +QT_END_NAMESPACE + +#endif diff --git a/src/location/landmarks/qlandmarkunionfilter.cpp b/src/location/landmarks/qlandmarkunionfilter.cpp new file mode 100644 index 00000000..8d792e4a --- /dev/null +++ b/src/location/landmarks/qlandmarkunionfilter.cpp @@ -0,0 +1,178 @@ +/**************************************************************************** +** +** Copyright (C) 2009 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 "qlandmarkunionfilter.h" +#include "qlandmarkunionfilter_p.h" + +QTM_BEGIN_NAMESPACE + +/*! + \class QLandmarkUnionFilter + \brief The QLandmarkUnionFilter class provides a filter which unions the results + of its constituent filters. + + \inmodule QtLocation + + \ingroup landmarks-filter + \since 1.1 + + Conceptually it performs an OR operation and may thus be used + to select landmarks which match any one of it's constituent filters. + + Whether a union filter can be comprised of + compound filters (i.e. union or intersection filters) is backend specific. + Even if this is supported the performance of such a filter is likely to be poor. +*/ + +Q_IMPLEMENT_LANDMARKFILTER_PRIVATE(QLandmarkUnionFilter); + +/*! + Constructs a new union filter. +*/ +QLandmarkUnionFilter::QLandmarkUnionFilter() + : QLandmarkFilter(new QLandmarkUnionFilterPrivate) +{ +} + +/*! + \fn QLandmarkUnionFilter::QLandmarkUnionFilter(const QLandmarkFilter &other) + Constructs a copy of \a other if possible, otherwise constructs a new union filter. +*/ + +/*! + Destroys the filter. +*/ +QLandmarkUnionFilter::~QLandmarkUnionFilter() +{ + // pointer deleted in superclass destructor +} + +/*! + Sets the \a filters whose criteria will be unioned. + \sa filters() +*/ +void QLandmarkUnionFilter::setFilters(const QList<QLandmarkFilter>& filters) +{ + Q_D(QLandmarkUnionFilter); + d->filters = filters; +} + +/*! + Prepends the given \a filter to the list of unioned filters. + + \sa append(), filters() +*/ +void QLandmarkUnionFilter::prepend(const QLandmarkFilter &filter) +{ + Q_D(QLandmarkUnionFilter); + d->filters.prepend(filter); +} + +/*! + Appends the given \a filter to the list of unioned filters. + + \sa operator<<(), prepend(), filters() +*/ +void QLandmarkUnionFilter::append(const QLandmarkFilter &filter) +{ + Q_D(QLandmarkUnionFilter); + d->filters.append(filter); +} + +/*! + Removes the given \a filter from the union list. + \sa filters(), append(), prepend() +*/ +void QLandmarkUnionFilter::remove(const QLandmarkFilter &filter) +{ + Q_D(QLandmarkUnionFilter); + d->filters.removeAll(filter); +} + +/*! + Removes all filters from the union list. + \sa remove() +*/ +void QLandmarkUnionFilter::clear() +{ + Q_D(QLandmarkUnionFilter); + d->filters.clear(); +} + +/*! + Appends the given \a filter to the list of unioned filters. + + \sa append() + */ +QLandmarkUnionFilter& QLandmarkUnionFilter::operator<<(const QLandmarkFilter &filter) +{ + Q_D(QLandmarkUnionFilter); + d->filters.append(filter); + return *this; +} + +/*! + Returns the list of filters which form the union filter. + + \sa setFilters(), prepend(), append(), remove() + */ +QList<QLandmarkFilter> QLandmarkUnionFilter::filters() const +{ + Q_D(const QLandmarkUnionFilter); + return d->filters; +} + +/******************************************************************************* +*******************************************************************************/ + +QLandmarkUnionFilterPrivate::QLandmarkUnionFilterPrivate() + : QLandmarkFilterPrivate() +{ + type = QLandmarkFilter::UnionFilter; +} + +QLandmarkUnionFilterPrivate::QLandmarkUnionFilterPrivate(const QLandmarkUnionFilterPrivate &other) + : QLandmarkFilterPrivate(other), + filters(other.filters) {} + +QLandmarkUnionFilterPrivate::~QLandmarkUnionFilterPrivate() {} + +QTM_END_NAMESPACE diff --git a/src/location/landmarks/qlandmarkunionfilter.h b/src/location/landmarks/qlandmarkunionfilter.h new file mode 100644 index 00000000..9ba8abb8 --- /dev/null +++ b/src/location/landmarks/qlandmarkunionfilter.h @@ -0,0 +1,75 @@ +/**************************************************************************** +** +** Copyright (C) 2009 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 QLANDMARKUNIONFILTER_H +#define QLANDMARKUNIONFILTER_H + +#include "qlandmarkfilter.h" +#include <QList> + +QTM_BEGIN_NAMESPACE + +class QLandmarkUnionFilterPrivate; +class Q_LOCATION_EXPORT QLandmarkUnionFilter : public QLandmarkFilter +{ +public: + QLandmarkUnionFilter(); + QLandmarkUnionFilter(const QLandmarkFilter &other); + virtual ~QLandmarkUnionFilter(); + + void setFilters(const QList<QLandmarkFilter> &filters); + + void prepend(const QLandmarkFilter &filter); + void append(const QLandmarkFilter &filter); + void remove(const QLandmarkFilter &filter); + void clear(); + + QLandmarkUnionFilter& operator<<(const QLandmarkFilter &filter); + QList<QLandmarkFilter> filters() const; + +private: + Q_DECLARE_LANDMARKFILTER_PRIVATE(QLandmarkUnionFilter) +}; + +QTM_END_NAMESPACE + +#endif + diff --git a/src/location/landmarks/qlandmarkunionfilter_p.h b/src/location/landmarks/qlandmarkunionfilter_p.h new file mode 100644 index 00000000..93563e35 --- /dev/null +++ b/src/location/landmarks/qlandmarkunionfilter_p.h @@ -0,0 +1,83 @@ +/**************************************************************************** +** +** Copyright (C) 2009 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 QLANDMARKUNIONFILTER_P_H +#define QLANDMARKUNIONFILTER_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 "qlandmarkfilter_p.h" + +#include <QList> + +QTM_BEGIN_NAMESPACE + +class QLandmarkUnionFilterPrivate : public QLandmarkFilterPrivate +{ +public: + QLandmarkUnionFilterPrivate(); + QLandmarkUnionFilterPrivate(const QLandmarkUnionFilterPrivate &other); + virtual ~QLandmarkUnionFilterPrivate(); + + virtual bool compare(const QLandmarkFilterPrivate* other) const + { + //it is assumed that the types and superclass member variables already match + const QLandmarkUnionFilterPrivate *od = static_cast<const QLandmarkUnionFilterPrivate*>(other); + return filters == od->filters; + } + + Q_IMPLEMENT_LANDMARKFILTER_VIRTUALCTORS(QLandmarkUnionFilter, QLandmarkFilter::UnionFilter) + + QList<QLandmarkFilter> filters; +}; + +QTM_END_NAMESPACE + +#endif |