QGIS API Documentation 3.28.0-Firenze (ed3ad0430f)
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 <QMutexLocker>
17#include "qgsdataprovider.h"
19
20#define SUBLAYER_SEPARATOR QStringLiteral( "!!::!!" )
21
22QgsDataProvider::QgsDataProvider( const QString &uri, const QgsDataProvider::ProviderOptions &providerOptions,
23 QgsDataProvider::ReadFlags flags )
24 : mDataSourceURI( uri ),
25 mOptions( providerOptions )
26{
28}
29
30Qgis::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
56void QgsDataProvider::setProviderProperty( int property, const QVariant &value )
57{
58 mProviderProperties.insert( property, value );
59}
60
61QVariant QgsDataProvider::providerProperty( QgsDataProvider::ProviderProperty property, const QVariant &defaultValue ) const
62{
63 return mProviderProperties.value( property, defaultValue );
64}
65
66QVariant QgsDataProvider::providerProperty( int property, const QVariant &defaultValue = QVariant() ) const
67{
68 return mProviderProperties.value( property, defaultValue );
69}
70
71void 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}
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...
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.
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.