QGIS API Documentation  3.26.3-Buenos Aires (65e4edfdad)
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
6  email : [email protected]
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 <QMutexLocker>
17 #include "qgsdataprovider.h"
19 
20 #define SUBLAYER_SEPARATOR QStringLiteral( "!!::!!" )
21 
22 QgsDataProvider::QgsDataProvider( const QString &uri, const QgsDataProvider::ProviderOptions &providerOptions,
23  QgsDataProvider::ReadFlags flags )
24  : mDataSourceURI( uri ),
25  mOptions( providerOptions )
26 {
27  mReadFlags = flags;
28 }
29 
30 Qgis::DataProviderFlags QgsDataProvider::flags() const
31 {
32  return Qgis::DataProviderFlags();
33 }
34 
36 {
37  return nullptr;
38 }
39 
41 {
42  return nullptr;
43 }
44 
46 {
47  reloadProviderData();
48  emit dataChanged();
49 }
50 
52 {
53  mProviderProperties.insert( property, value );
54 }
55 
56 void QgsDataProvider::setProviderProperty( int property, const QVariant &value )
57 {
58  mProviderProperties.insert( property, value );
59 }
60 
61 QVariant QgsDataProvider::providerProperty( QgsDataProvider::ProviderProperty property, const QVariant &defaultValue ) const
62 {
63  return mProviderProperties.value( property, defaultValue );
64 }
65 
66 QVariant QgsDataProvider::providerProperty( int property, const QVariant &defaultValue = QVariant() ) const
67 {
68  return mProviderProperties.value( property, defaultValue );
69 }
70 
71 void QgsDataProvider::setListening( bool isListening )
72 {
73  Q_UNUSED( isListening )
74 }
75 
77 {
78  return context.lastRenderingTimeMs <= context.maxRenderingTimeMs;
79 }
80 
82 {
83  const QMutexLocker locker( &mOptionsMutex );
84  return mOptions.transformContext;
85 }
86 
88 {
89  const QMutexLocker locker( &mOptionsMutex );
90  mOptions.transformContext = value;
91 }
92 
94 {
95  return SUBLAYER_SEPARATOR;
96 }
QgsCoordinateTransformContext
Contains information about the context in which a coordinate transform is executed.
Definition: qgscoordinatetransformcontext.h:57
QgsDataProvider::flags
virtual Qgis::DataProviderFlags flags() const
Returns the generic data provider flags.
Definition: qgsdataprovider.cpp:30
QgsDataProvider::ProviderOptions
Setting options for creating vector data providers.
Definition: qgsdataprovider.h:107
qgsdataprovidertemporalcapabilities.h
QgsDataProvider::QgsDataProvider
QgsDataProvider(const QString &uri=QString(), const QgsDataProvider::ProviderOptions &providerOptions=QgsDataProvider::ProviderOptions(), QgsDataProvider::ReadFlags flags=QgsDataProvider::ReadFlags())
Create a new dataprovider with the specified in the uri.
Definition: qgsdataprovider.cpp:22
QgsDataProvider::dataChanged
void dataChanged()
Emitted whenever a change is made to the data provider which may have caused changes in the provider'...
QgsDataProvider::ProviderProperty
ProviderProperty
Properties are used to pass custom configuration options into data providers.
Definition: qgsdataprovider.h:93
QgsDataProvider::transformContext
QgsCoordinateTransformContext transformContext() const
Returns data provider coordinate transform context.
Definition: qgsdataprovider.cpp:81
QgsDataProviderTemporalCapabilities
Base class for handling properties relating to a data provider's temporal capabilities.
Definition: qgsdataprovidertemporalcapabilities.h:33
QgsDataProvider::reloadData
virtual void reloadData()
Reloads the data from the source for providers with data caches to synchronize, changes in the data s...
Definition: qgsdataprovider.cpp:45
QgsDataProvider::PreviewContext
Stores settings related to the context in which a preview job runs.
Definition: qgsdataprovider.h:541
SUBLAYER_SEPARATOR
#define SUBLAYER_SEPARATOR
Definition: qgsdataprovider.cpp:20
QgsDataProvider::PreviewContext::maxRenderingTimeMs
double maxRenderingTimeMs
Default maximum allowable render time, in ms.
Definition: qgsdataprovider.h:547
QgsDataProvider::renderInPreview
virtual bool renderInPreview(const QgsDataProvider::PreviewContext &context)
Returns whether the layer must be rendered in preview jobs.
Definition: qgsdataprovider.cpp:76
QgsDataProvider::temporalCapabilities
virtual QgsDataProviderTemporalCapabilities * temporalCapabilities()
Returns the provider's temporal capabilities.
Definition: qgsdataprovider.cpp:35
QgsDataProvider::mReadFlags
QgsDataProvider::ReadFlags mReadFlags
Read flags. It's up to the subclass to respect these when needed.
Definition: qgsdataprovider.h:665
QgsDataProvider::setTransformContext
virtual void setTransformContext(const QgsCoordinateTransformContext &transformContext)
Sets data coordinate transform context to transformContext.
Definition: qgsdataprovider.cpp:87
QgsDataProvider::sublayerSeparator
static QString sublayerSeparator()
String sequence used for separating components of sublayers strings.
Definition: qgsdataprovider.cpp:93
QgsDataProvider::setProviderProperty
void setProviderProperty(ProviderProperty property, const QVariant &value)
Allows setting arbitrary properties on the provider.
Definition: qgsdataprovider.cpp:51
QgsDataProvider::ProviderOptions::transformContext
QgsCoordinateTransformContext transformContext
Coordinate transform context.
Definition: qgsdataprovider.h:113
qgsdataprovider.h
QgsDataProvider::PreviewContext::lastRenderingTimeMs
double lastRenderingTimeMs
Previous rendering time for the layer, in ms.
Definition: qgsdataprovider.h:544
QgsDataProvider::providerProperty
QVariant providerProperty(ProviderProperty property, const QVariant &defaultValue=QVariant()) const
Gets the current value of a certain provider property.
Definition: qgsdataprovider.cpp:61
QgsDataProvider::setListening
virtual void setListening(bool isListening)
Set whether the provider will listen to datasource notifications If set, the provider will issue noti...
Definition: qgsdataprovider.cpp:71