QGIS API Documentation  3.12.1-BucureČ™ti (121cc00ff0)
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"
18 
19 #define SUBLAYER_SEPARATOR QStringLiteral( "!!::!!" )
20 
21 QgsDataProvider::QgsDataProvider( const QString &uri, const QgsDataProvider::ProviderOptions &providerOptions )
22  : mDataSourceURI( uri ),
23  mOptions( providerOptions )
24 {
25 }
26 
28 {
29  reloadProviderData();
30  emit dataChanged();
31 }
32 
34 {
35  mProviderProperties.insert( property, value );
36 }
37 
38 void QgsDataProvider::setProviderProperty( int property, const QVariant &value )
39 {
40  mProviderProperties.insert( property, value );
41 }
42 
43 QVariant QgsDataProvider::providerProperty( QgsDataProvider::ProviderProperty property, const QVariant &defaultValue ) const
44 {
45  return mProviderProperties.value( property, defaultValue );
46 }
47 
48 QVariant QgsDataProvider::providerProperty( int property, const QVariant &defaultValue = QVariant() ) const
49 {
50  return mProviderProperties.value( property, defaultValue );
51 }
52 
53 void QgsDataProvider::setListening( bool isListening )
54 {
55  Q_UNUSED( isListening )
56 }
57 
59 {
60  return context.lastRenderingTimeMs <= context.maxRenderingTimeMs;
61 }
62 
64 {
65  QMutexLocker locker( &mOptionsMutex );
66  return mOptions.transformContext;
67 }
68 
70 {
71  QMutexLocker locker( &mOptionsMutex );
72  mOptions.transformContext = value;
73 }
74 
76 {
77  return SUBLAYER_SEPARATOR;
78 }
QVariant providerProperty(ProviderProperty property, const QVariant &defaultValue=QVariant()) const
Gets the current value of a certain provider property.
virtual void reloadData()
Reloads the data from the source by calling reloadProviderData() implemented by providers with data c...
QgsDataProvider(const QString &uri=QString(), const QgsDataProvider::ProviderOptions &providerOptions=QgsDataProvider::ProviderOptions())
Create a new dataprovider with the specified in the uri.
double maxRenderingTimeMs
Default maximum allowable render time, in ms.
void dataChanged()
Emitted whenever a change is made to the data provider which may have caused changes in the provider&#39;...
virtual void setListening(bool isListening)
Set whether the provider will listen to datasource notifications If set, the provider will issue noti...
Contains information about the context in which a coordinate transform is executed.
void setProviderProperty(ProviderProperty property, const QVariant &value)
Allows setting arbitrary properties on the provider.
virtual bool renderInPreview(const QgsDataProvider::PreviewContext &context)
Returns whether the layer must be rendered in preview jobs.
QgsCoordinateTransformContext transformContext
QgsCoordinateTransformContext transformContext() const
Returns data provider coordinate transform context.
Setting options for creating vector data providers.
static QString sublayerSeparator()
String sequence used for separating components of sublayers strings.
virtual void setTransformContext(const QgsCoordinateTransformContext &transformContext)
Sets data coordinate transform context to transformContext.
#define SUBLAYER_SEPARATOR
double lastRenderingTimeMs
Previous rendering time for the layer, in ms.
Stores settings related to the context in which a preview job runs.
ProviderProperty
Properties are used to pass custom configuration options into data providers.