QGIS API Documentation  3.20.0-Odense (decaadbb31)
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 
31 {
32  return nullptr;
33 }
34 
36 {
37  return nullptr;
38 }
39 
41 {
42  reloadProviderData();
43  emit dataChanged();
44 }
45 
47 {
48  mProviderProperties.insert( property, value );
49 }
50 
51 void QgsDataProvider::setProviderProperty( int property, const QVariant &value )
52 {
53  mProviderProperties.insert( property, value );
54 }
55 
56 QVariant QgsDataProvider::providerProperty( QgsDataProvider::ProviderProperty property, const QVariant &defaultValue ) const
57 {
58  return mProviderProperties.value( property, defaultValue );
59 }
60 
61 QVariant QgsDataProvider::providerProperty( int property, const QVariant &defaultValue = QVariant() ) const
62 {
63  return mProviderProperties.value( property, defaultValue );
64 }
65 
66 void QgsDataProvider::setListening( bool isListening )
67 {
68  Q_UNUSED( isListening )
69 }
70 
72 {
73  return context.lastRenderingTimeMs <= context.maxRenderingTimeMs;
74 }
75 
77 {
78  QMutexLocker locker( &mOptionsMutex );
79  return mOptions.transformContext;
80 }
81 
83 {
84  QMutexLocker locker( &mOptionsMutex );
85  mOptions.transformContext = value;
86 }
87 
89 {
90  return SUBLAYER_SEPARATOR;
91 }
Contains information about the context in which a coordinate transform is executed.
Base class for handling properties relating to a data provider's temporal capabilities.
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...
void setProviderProperty(ProviderProperty property, const QVariant &value)
Allows setting arbitrary properties on the provider.
void dataChanged()
Emitted whenever a change is made to the data provider which may have caused changes in the provider'...
ProviderProperty
Properties are used to pass custom configuration options into data providers.
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.
virtual QgsDataProviderTemporalCapabilities * temporalCapabilities()
Returns the provider's temporal capabilities.
QgsDataProvider::ReadFlags mReadFlags
Read flags. It's up to the subclass to respect these when needed.
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 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
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.
QgsCoordinateTransformContext transformContext
Coordinate transform context.