QGIS API Documentation 4.1.0-Master (60fea48833c)
Loading...
Searching...
No Matches
qgsdataprovider.cpp
Go to the documentation of this file.
1/***************************************************************************
2 qgsdataprovider.cpp - DataProvider Interface
3 --------------------------------------
4 Date : May 2016
5 Copyright : (C) 2016 by Matthias Kuhn
7 ***************************************************************************
8 * *
9 * This program is free software; you can redistribute it and/or modify *
10 * it under the terms of the GNU General Public License as published by *
11 * the Free Software Foundation; either version 2 of the License, or *
12 * (at your option) any later version. *
13 * *
14 ***************************************************************************/
15
16#include "qgsdataprovider.h"
17
19#include "qgsthreadingutils.h"
20
21#include <QMutexLocker>
22#include <QString>
23
24#include "moc_qgsdataprovider.cpp"
25
26using namespace Qt::StringLiterals;
27
28#define SUBLAYER_SEPARATOR u"!!::!!"_s
29
31 : mDataSourceURI( uri )
32 , mOptions( providerOptions )
33{
35}
36
38{
40
41 return QString();
42}
43
50
57
64
71
78
80{
81 return QString();
82}
83
85{
86 return QString();
87}
88
89bool QgsDataProvider::setSubsetString( const QString &subset, bool updateFeatureCount )
90{
91 // NOP by default
92 Q_UNUSED( subset )
93 Q_UNUSED( updateFeatureCount )
94 return false;
95}
96
98{
99 return false;
100}
101
103{
104 return QString();
105}
106
108{
109 // Because QgsVirtualLayerTask is not thread safe:
111
112 reloadProviderData();
113 emit dataChanged();
114}
115
117{
119
120 mProviderProperties.insert( property, value );
121}
122
123void QgsDataProvider::setProviderProperty( int property, const QVariant &value )
124{
126
127 mProviderProperties.insert( property, value );
128}
129
130QVariant QgsDataProvider::providerProperty( QgsDataProvider::ProviderProperty property, const QVariant &defaultValue ) const
131{
133
134 return mProviderProperties.value( property, defaultValue );
135}
136
137QVariant QgsDataProvider::providerProperty( int property, const QVariant &defaultValue = QVariant() ) const
138{
140
141 return mProviderProperties.value( property, defaultValue );
142}
143
144void QgsDataProvider::setListening( bool isListening )
145{
147
148 Q_UNUSED( isListening )
149}
150
157
159{
161
162 const QMutexLocker locker( &mOptionsMutex );
163 return mOptions.transformContext;
164}
165
167{
169
170 const QMutexLocker locker( &mOptionsMutex );
171 mOptions.transformContext = value;
172}
173
178
QFlags< DataProviderFlag > DataProviderFlags
Data provider flags.
Definition qgis.h:2397
QFlags< DataProviderReadFlag > DataProviderReadFlags
Flags which control data provider construction.
Definition qgis.h:512
QFlags< ProviderStyleStorageCapability > ProviderStyleStorageCapabilities
Definition qgis.h:5783
Contains information about the context in which a coordinate transform is executed.
Base class for handling elevation related properties for a data provider.
Base class for handling properties relating to a data provider's temporal capabilities.
virtual QString subsetString() const
Returns the subset definition string currently in use by the layer and used by the provider to limit ...
QgsCoordinateTransformContext transformContext() const
Returns data provider coordinate transform context.
virtual void setListening(bool isListening)
Set whether the provider will listen to datasource notifications If set, the provider will issue noti...
virtual Qgis::DataProviderFlags flags() const
Returns the generic data provider flags.
void setProviderProperty(ProviderProperty property, const QVariant &value)
Allows setting arbitrary properties on the provider.
virtual bool supportsSubsetString() const
Returns true if the provider supports setting of subset strings.
void dataChanged()
Emitted whenever a change is made to the data provider which may have caused changes in the provider'...
virtual QString subsetStringHelpUrl() const
Returns a URL pointing to documentation describing the dialect which is supported for subset strings ...
virtual Qgis::ProviderStyleStorageCapabilities styleStorageCapabilities() const
Returns the style storage capabilities.
ProviderProperty
Properties are used to pass custom configuration options into data providers.
QgsDataProvider(const QString &uri=QString(), const QgsDataProvider::ProviderOptions &providerOptions=QgsDataProvider::ProviderOptions(), Qgis::DataProviderReadFlags flags=Qgis::DataProviderReadFlags())
Create a new dataprovider with the specified in the uri.
virtual QgsDataProviderTemporalCapabilities * temporalCapabilities()
Returns the provider's temporal capabilities.
virtual bool setSubsetString(const QString &subset, bool updateFeatureCount=true)
Set the subset string used to create a subset of features in the layer.
QgsDataSourceUri uri() const
Gets the data source specification.
static QString sublayerSeparator()
String sequence used for separating components of sublayers strings.
QVariant providerProperty(ProviderProperty property, const QVariant &defaultValue=QVariant()) const
Gets the current value of a certain provider property.
virtual QString subsetStringDialect() const
Returns a user-friendly string describing the dialect which is supported for subset strings by the pr...
Qgis::DataProviderReadFlags mReadFlags
Read flags. It's up to the subclass to respect these when needed.
virtual QString htmlMetadata() const
Obtain a formatted HTML string containing assorted metadata for this data provider.
virtual QgsDataProviderElevationProperties * elevationProperties()
Returns the provider's elevation properties.
virtual bool renderInPreview(const QgsDataProvider::PreviewContext &context)
Returns whether the layer must be rendered in preview jobs.
virtual void reloadData()
Reloads the data from the source for providers with data caches to synchronize, changes in the data s...
virtual void setTransformContext(const QgsCoordinateTransformContext &transformContext)
Sets data coordinate transform context to transformContext.
#define SUBLAYER_SEPARATOR
#define QGIS_PROTECT_QOBJECT_THREAD_ACCESS_NON_FATAL
#define QGIS_PROTECT_QOBJECT_THREAD_ACCESS
Stores settings related to the context in which a preview job runs.
double maxRenderingTimeMs
Default maximum allowable render time, in ms.
double lastRenderingTimeMs
Previous rendering time for the layer, in ms.
Setting options for creating vector data providers.