summaryrefslogtreecommitdiff
path: root/src/location
diff options
context:
space:
mode:
authorPaolo Angelelli <paolo.angelelli@qt.io>2019-04-10 22:57:45 +0200
committerpaolo <paolo.angelelli@qt.io>2019-06-21 22:56:05 +0200
commit6ddffc8a4eb50164389c55c2ddad9239dab07b8c (patch)
treec0208a549f972e514a0987849f123394048694ef /src/location
parentac899dcc40bb3ad09307583fb7e6befd45a77b33 (diff)
downloadqtlocation-6ddffc8a4eb50164389c55c2ddad9239dab07b8c.tar.gz
Move PluginParameter into PositioningQuick, expose also in QtPositioning
With this patch the QDeclarativeGeoServiceProviderParameter in the location-private module becomes QDeclarativePluginParameter in the positioningquick-private module. This renamed class is then registered, under the same QML typename "PluginParameter" both in QtPositioning and QtLocation qml plugins. In this way it will become possible to use the same type both inside QtLocation "Plugin" and inside QtPositioning "PositionSource", and regardless of which is the QML plugin that provides "PluginParameter", this will translate into the same cpp type. [ChangeLog][QtPositioning] Exposed PluginParameter also from QtPositioning qml plugin, to be used in PositionSource as replacement of environment variables. Task-number: QTBUG-66304 Change-Id: I1d982ff689130ae896c616480567aa12d9b49c3a Reviewed-by: Alex Blasche <alexander.blasche@qt.io>
Diffstat (limited to 'src/location')
-rw-r--r--src/location/declarativemaps/qdeclarativegeoserviceprovider.cpp81
-rw-r--r--src/location/declarativemaps/qdeclarativegeoserviceprovider_p.h45
2 files changed, 30 insertions, 96 deletions
diff --git a/src/location/declarativemaps/qdeclarativegeoserviceprovider.cpp b/src/location/declarativemaps/qdeclarativegeoserviceprovider.cpp
index aa1db493..7810dc74 100644
--- a/src/location/declarativemaps/qdeclarativegeoserviceprovider.cpp
+++ b/src/location/declarativemaps/qdeclarativegeoserviceprovider.cpp
@@ -124,7 +124,7 @@ void QDeclarativeGeoServiceProvider::setName(const QString &name)
\internal
*/
bool QDeclarativeGeoServiceProvider::parametersReady() {
- for (const QDeclarativeGeoServiceProviderParameter *p: qAsConst(parameters_)) {
+ for (const QDeclarativePluginParameter *p: qAsConst(parameters_)) {
if (!p->isInitialized())
return false;
}
@@ -179,9 +179,9 @@ void QDeclarativeGeoServiceProvider::componentComplete()
{
complete_ = true;
- for (QDeclarativeGeoServiceProviderParameter *p: qAsConst(parameters_)) {
+ for (QDeclarativePluginParameter *p: qAsConst(parameters_)) {
if (!p->isInitialized()) {
- connect(p, &QDeclarativeGeoServiceProviderParameter::initialized,
+ connect(p, &QDeclarativePluginParameter::initialized,
this, &QDeclarativeGeoServiceProvider::tryAttach);
}
}
@@ -603,9 +603,9 @@ void QDeclarativeGeoServiceProvider::setLocales(const QStringList &locales)
This property holds the list of plugin parameters.
*/
-QQmlListProperty<QDeclarativeGeoServiceProviderParameter> QDeclarativeGeoServiceProvider::parameters()
+QQmlListProperty<QDeclarativePluginParameter> QDeclarativeGeoServiceProvider::parameters()
{
- return QQmlListProperty<QDeclarativeGeoServiceProviderParameter>(this,
+ return QQmlListProperty<QDeclarativePluginParameter>(this,
0,
parameter_append,
parameter_count,
@@ -616,7 +616,7 @@ QQmlListProperty<QDeclarativeGeoServiceProviderParameter> QDeclarativeGeoService
/*!
\internal
*/
-void QDeclarativeGeoServiceProvider::parameter_append(QQmlListProperty<QDeclarativeGeoServiceProviderParameter> *prop, QDeclarativeGeoServiceProviderParameter *parameter)
+void QDeclarativeGeoServiceProvider::parameter_append(QQmlListProperty<QDeclarativePluginParameter> *prop, QDeclarativePluginParameter *parameter)
{
QDeclarativeGeoServiceProvider *p = static_cast<QDeclarativeGeoServiceProvider *>(prop->object);
p->parameters_.append(parameter);
@@ -627,7 +627,7 @@ void QDeclarativeGeoServiceProvider::parameter_append(QQmlListProperty<QDeclarat
/*!
\internal
*/
-int QDeclarativeGeoServiceProvider::parameter_count(QQmlListProperty<QDeclarativeGeoServiceProviderParameter> *prop)
+int QDeclarativeGeoServiceProvider::parameter_count(QQmlListProperty<QDeclarativePluginParameter> *prop)
{
return static_cast<QDeclarativeGeoServiceProvider *>(prop->object)->parameters_.count();
}
@@ -635,7 +635,7 @@ int QDeclarativeGeoServiceProvider::parameter_count(QQmlListProperty<QDeclarativ
/*!
\internal
*/
-QDeclarativeGeoServiceProviderParameter *QDeclarativeGeoServiceProvider::parameter_at(QQmlListProperty<QDeclarativeGeoServiceProviderParameter> *prop, int index)
+QDeclarativePluginParameter *QDeclarativeGeoServiceProvider::parameter_at(QQmlListProperty<QDeclarativePluginParameter> *prop, int index)
{
return static_cast<QDeclarativeGeoServiceProvider *>(prop->object)->parameters_[index];
}
@@ -643,7 +643,7 @@ QDeclarativeGeoServiceProviderParameter *QDeclarativeGeoServiceProvider::paramet
/*!
\internal
*/
-void QDeclarativeGeoServiceProvider::parameter_clear(QQmlListProperty<QDeclarativeGeoServiceProviderParameter> *prop)
+void QDeclarativeGeoServiceProvider::parameter_clear(QQmlListProperty<QDeclarativePluginParameter> *prop)
{
QDeclarativeGeoServiceProvider *p = static_cast<QDeclarativeGeoServiceProvider *>(prop->object);
p->parameters_.clear();
@@ -659,7 +659,7 @@ QVariantMap QDeclarativeGeoServiceProvider::parameterMap() const
QVariantMap map;
for (int i = 0; i < parameters_.size(); ++i) {
- QDeclarativeGeoServiceProviderParameter *parameter = parameters_.at(i);
+ QDeclarativePluginParameter *parameter = parameters_.at(i);
map.insert(parameter->name(), parameter->value());
}
@@ -866,21 +866,25 @@ bool QDeclarativeGeoServiceProviderRequirements::operator == (const QDeclarative
/*!
\qmltype PluginParameter
- \instantiates QDeclarativeGeoServiceProviderParameter
+ \instantiates QDeclarativePluginParameter
\inqmlmodule QtLocation
\ingroup qml-QtLocation5-common
\since QtLocation 5.5
- \brief The PluginParameter type describes a parameter to a \l Plugin.
+ \brief The PluginParameter type describes a parameter for a plugin, either
+ geo service \l Plugin, or \l{Qt Positioning plugins}{position Plugin}.
The PluginParameter object is used to provide a parameter of some kind
- to a Plugin. Typically these parameters contain details like an application
- token for access to a service, or a proxy server to use for network access.
+ to a plugin. Typically these parameters contain details like an application
+ token for access to a service, or a proxy server to use for network access,
+ or the serial port to which a serial GPS receiver is connected.
- To set such a parameter, declare a PluginParameter inside a \l Plugin
- object, and give it \l{name} and \l{value} properties. A list of valid
+ To set such a parameter, declare a PluginParameter inside an element that accepts
+ plugin parameters as configuration objects, such as a \l Plugin object, or a
+ \l PositionSource object, and give it \l{name} and \l{value} properties. A list of valid
parameter names for each plugin is available from the
- \l {Qt Location#Plugin References and Parameters}{plugin reference pages}.
+ \l {Qt Location#Plugin References and Parameters}{plugin reference pages} for geoservice plugins,
+ and \l {Qt Positioning plugins#Default plugins} for position plugins.
\section2 Example Usage
@@ -896,33 +900,12 @@ bool QDeclarativeGeoServiceProviderRequirements::operator == (const QDeclarative
\endcode
*/
-QDeclarativeGeoServiceProviderParameter::QDeclarativeGeoServiceProviderParameter(QObject *parent)
- : QObject(parent) {}
-
-QDeclarativeGeoServiceProviderParameter::~QDeclarativeGeoServiceProviderParameter() {}
-
/*!
\qmlproperty string PluginParameter::name
This property holds the name of the plugin parameter as a single formatted string.
This property is a write-once property.
*/
-void QDeclarativeGeoServiceProviderParameter::setName(const QString &name)
-{
- if (!name_.isEmpty() || name.isEmpty())
- return;
-
- name_ = name;
-
- emit nameChanged(name_);
- if (value_.isValid())
- emit initialized();
-}
-
-QString QDeclarativeGeoServiceProviderParameter::name() const
-{
- return name_;
-}
/*!
\qmlproperty QVariant PluginParameter::value
@@ -930,29 +913,9 @@ QString QDeclarativeGeoServiceProviderParameter::name() const
This property holds the value of the plugin parameter which support different types of values (variant).
This property is a write-once property.
*/
-void QDeclarativeGeoServiceProviderParameter::setValue(const QVariant &value)
-{
- if (value_.isValid() || !value.isValid() || value.isNull())
- return;
-
- value_ = value;
-
- emit valueChanged(value_);
- if (!name_.isEmpty())
- emit initialized();
-}
-
-QVariant QDeclarativeGeoServiceProviderParameter::value() const
-{
- return value_;
-}
-
-bool QDeclarativeGeoServiceProviderParameter::isInitialized() const
-{
- return !name_.isEmpty() && value_.isValid();
-}
/*******************************************************************************
+ * Implementation now in positioningquick
*******************************************************************************/
QT_END_NAMESPACE
diff --git a/src/location/declarativemaps/qdeclarativegeoserviceprovider_p.h b/src/location/declarativemaps/qdeclarativegeoserviceprovider_p.h
index 3d5592c0..165f7ba4 100644
--- a/src/location/declarativemaps/qdeclarativegeoserviceprovider_p.h
+++ b/src/location/declarativemaps/qdeclarativegeoserviceprovider_p.h
@@ -58,38 +58,10 @@
#include <QtQml/QQmlParserStatus>
#include <QtQml/QQmlListProperty>
#include <QtLocation/QGeoServiceProvider>
+#include <QtPositioningQuick/private/qdeclarativepluginparameter_p.h>
QT_BEGIN_NAMESPACE
-class Q_LOCATION_PRIVATE_EXPORT QDeclarativeGeoServiceProviderParameter : public QObject
-{
- Q_OBJECT
-
- Q_PROPERTY(QString name READ name WRITE setName NOTIFY nameChanged)
- Q_PROPERTY(QVariant value READ value WRITE setValue NOTIFY valueChanged)
-
-public:
- explicit QDeclarativeGeoServiceProviderParameter(QObject *parent = 0);
- ~QDeclarativeGeoServiceProviderParameter();
-
- void setName(const QString &name);
- QString name() const;
-
- void setValue(const QVariant &value);
- QVariant value() const;
-
- bool isInitialized() const;
-
-Q_SIGNALS:
- void nameChanged(const QString &name);
- void valueChanged(const QVariant &value);
- void initialized();
-
-private:
- QString name_;
- QVariant value_;
-};
-
class QDeclarativeGeoServiceProviderRequirements;
class Q_LOCATION_PRIVATE_EXPORT QDeclarativeGeoServiceProvider : public QObject, public QQmlParserStatus
@@ -102,7 +74,7 @@ class Q_LOCATION_PRIVATE_EXPORT QDeclarativeGeoServiceProvider : public QObject,
Q_PROPERTY(QString name READ name WRITE setName NOTIFY nameChanged)
Q_PROPERTY(QStringList availableServiceProviders READ availableServiceProviders CONSTANT)
- Q_PROPERTY(QQmlListProperty<QDeclarativeGeoServiceProviderParameter> parameters READ parameters)
+ Q_PROPERTY(QQmlListProperty<QDeclarativePluginParameter> parameters READ parameters)
Q_PROPERTY(QDeclarativeGeoServiceProviderRequirements *required READ requirements WRITE setRequirements)
Q_PROPERTY(QStringList locales READ locales WRITE setLocales NOTIFY localesChanged)
Q_PROPERTY(QStringList preferred READ preferred WRITE setPreferred NOTIFY preferredChanged)
@@ -189,7 +161,7 @@ public:
void setName(const QString &name);
QString name() const;
- QQmlListProperty<QDeclarativeGeoServiceProviderParameter> parameters();
+ QQmlListProperty<QDeclarativePluginParameter> parameters();
QVariantMap parameterMap() const;
QStringList availableServiceProviders();
@@ -226,14 +198,14 @@ Q_SIGNALS:
private:
bool parametersReady();
void tryAttach();
- static void parameter_append(QQmlListProperty<QDeclarativeGeoServiceProviderParameter> *prop, QDeclarativeGeoServiceProviderParameter *mapObject);
- static int parameter_count(QQmlListProperty<QDeclarativeGeoServiceProviderParameter> *prop);
- static QDeclarativeGeoServiceProviderParameter *parameter_at(QQmlListProperty<QDeclarativeGeoServiceProviderParameter> *prop, int index);
- static void parameter_clear(QQmlListProperty<QDeclarativeGeoServiceProviderParameter> *prop);
+ static void parameter_append(QQmlListProperty<QDeclarativePluginParameter> *prop, QDeclarativePluginParameter *mapObject);
+ static int parameter_count(QQmlListProperty<QDeclarativePluginParameter> *prop);
+ static QDeclarativePluginParameter *parameter_at(QQmlListProperty<QDeclarativePluginParameter> *prop, int index);
+ static void parameter_clear(QQmlListProperty<QDeclarativePluginParameter> *prop);
QGeoServiceProvider *sharedProvider_;
QString name_;
- QList<QDeclarativeGeoServiceProviderParameter *> parameters_;
+ QList<QDeclarativePluginParameter *> parameters_;
QDeclarativeGeoServiceProviderRequirements *required_;
bool complete_;
bool experimental_;
@@ -303,7 +275,6 @@ private:
QT_END_NAMESPACE
-QML_DECLARE_TYPE(QDeclarativeGeoServiceProviderParameter)
QML_DECLARE_TYPE(QDeclarativeGeoServiceProviderRequirements)
QML_DECLARE_TYPE(QDeclarativeGeoServiceProvider)