QGIS API Documentation  2.2.0-Valmiera
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
Public Types | Signals | Public Member Functions | Protected Member Functions | Protected Attributes | Private Attributes | List of all members
QgsDataProvider Class Reference

Abstract base class for spatial data provider implementations. More...

#include <qgsdataprovider.h>

Inheritance diagram for QgsDataProvider:
Inheritance graph
[legend]
Collaboration diagram for QgsDataProvider:
Collaboration graph
[legend]

Public Types

enum  DataCapability {
  NoDataCapabilities = 0, File = 1, Dir = 1 << 1, Database = 1 << 2,
  Net = 1 << 3
}

Signals

void fullExtentCalculated ()
 This is emitted whenever the worker thread has fully calculated the PostGIS extents for this layer, and its event has been received by this provider.
void dataChanged ()
 This is emitted whenever an asynchronous operation has finished and the data should be redrawn.
void dataChanged (int changed)
 This is emitted whenever data or metadata (e.g.

Public Member Functions

 QgsDataProvider (QString const &uri="")
virtual ~QgsDataProvider ()
 We need this so the subclass destructors get called.
virtual
QgsCoordinateReferenceSystem 
crs ()=0
virtual void setDataSourceUri (const QString &uri)
 Set the data source specification.
virtual QString dataSourceUri () const
 Get the data source specification.
virtual QgsRectangle extent ()=0
 Get the extent of the layer.
virtual bool isValid ()=0
 Returns true if this is a valid layer.
virtual void updateExtents ()
 Update the extents of the layer.
virtual bool setSubsetString (QString subset, bool updateFeatureCount=true)
 Set the subset string used to create a subset of features in the layer.
virtual bool supportsSubsetString ()
 provider supports setting of subset strings
virtual QString subsetString ()
 Returns the subset definition string (typically sql) currently in use by the layer and used by the provider to limit the feature set.
virtual QStringList subLayers () const
 Sub-layers handled by this provider, in order from bottom to top.
virtual QStringList subLayerStyles () const
 Sub-layer styles for each sub-layer handled by this provider, in order from bottom to top.
virtual uint subLayerCount () const
 return the number of layers for the current data source
virtual void setLayerOrder (const QStringList &layers)
 Reorder the list of layer names to be rendered by this provider (in order from bottom to top)
virtual void setSubLayerVisibility (const QString &name, bool vis)
 Set the visibility of the given sublayer name.
virtual QString name () const =0
 return a provider name
virtual QString description () const =0
 return description
virtual QString fileVectorFilters () const
 return vector file filter string
virtual QString fileRasterFilters () const
 return raster file filter string
virtual void reloadData ()
 Reloads the data from the source.
virtual QDateTime timestamp () const
 Time stamp of data source in the moment when data/metadata were loaded by provider.
virtual QDateTime dataTimestamp () const
 Current time stamp of data source.
virtual QgsError error () const
 Get current status error.

Protected Member Functions

void appendError (const QgsErrorMessage &theMessage)
 Add error message.
void setError (const QgsError &theError)
 Set error message.

Protected Attributes

QDateTime mTimestamp
 Timestamp of data in the moment when the data were loaded by provider.
QgsError mError
 Error.

Private Attributes

QString mDataSourceURI
 Universal Resource Identifier for source data.

Detailed Description

Abstract base class for spatial data provider implementations.

Author
Gary E.Sherman

This object needs to inherit from QObject to enable event processing in the Postgres/PostGIS provider (QgsPostgresProvider). It is called here so that this vtable and the vtable for QgsPostgresProvider don't get misaligned - the QgsVectorLayer class factory (which refers to generic QgsVectorDataProvider's) depends on it.

Definition at line 44 of file qgsdataprovider.h.

Member Enumeration Documentation

Enumerator:
NoDataCapabilities 
File 
Dir 
Database 
Net 

Definition at line 52 of file qgsdataprovider.h.

Constructor & Destructor Documentation

QgsDataProvider::QgsDataProvider ( QString const &  uri = "")
inline

Definition at line 61 of file qgsdataprovider.h.

virtual QgsDataProvider::~QgsDataProvider ( )
inlinevirtual

We need this so the subclass destructors get called.

Definition at line 68 of file qgsdataprovider.h.

Member Function Documentation

void QgsDataProvider::appendError ( const QgsErrorMessage theMessage)
inlineprotected

Add error message.

Definition at line 333 of file qgsdataprovider.h.

virtual QgsCoordinateReferenceSystem QgsDataProvider::crs ( )
pure virtual

Get the QgsCoordinateReferenceSystem for this layer

Note
Must be reimplemented by each provider. If the provider isn't capable of returning its projection an empty srs will be return, ti will return 0

Referenced by QgsMapToolIdentify::identifyRasterLayer(), QgsVectorLayer::setCoordinateSystem(), and QgsRasterLayer::setDataProvider().

void QgsDataProvider::dataChanged ( )
signal

This is emitted whenever an asynchronous operation has finished and the data should be redrawn.

Note
added in 1.5
void QgsDataProvider::dataChanged ( int  changed)
signal

This is emitted whenever data or metadata (e.g.

color table, extent) has changed

Parameters
changedbinary combination of changes
Note
added in 1.7
virtual QString QgsDataProvider::dataSourceUri ( ) const
inlinevirtual

Get the data source specification.

This may be a path or database connection string

Returns
data source specification

Definition at line 94 of file qgsdataprovider.h.

Referenced by QgsRasterLayer::setDataProvider(), QgsVectorLayer::setDataProvider(), QgsVectorLayer::setSubsetString(), and QgsVectorFileWriter::writeAsVectorFormat().

virtual QDateTime QgsDataProvider::dataTimestamp ( ) const
inlinevirtual

Current time stamp of data source.

Reimplemented in QgsRasterDataProvider.

Definition at line 292 of file qgsdataprovider.h.

virtual QString QgsDataProvider::description ( ) const
pure virtual

return description

Return a terse string describing what the provider is.

Note

Instead of being pure virtual, might be better to generalize this behavior and presume that none of the sub-classes are going to do anything strange with regards to their name or description?

Referenced by QgsRasterLayer::metadata(), and QgsVectorLayer::metadata().

virtual QgsError QgsDataProvider::error ( ) const
inlinevirtual

Get current status error.

This error describes some principal problem for which provider cannot work and thus is not valid. It is not last error after accessing data by block(), identify() etc.

Definition at line 298 of file qgsdataprovider.h.

Referenced by QgsRasterLayer::setDataProvider().

virtual QgsRectangle QgsDataProvider::extent ( )
pure virtual

Get the extent of the layer.

Returns
QgsRectangle containing the extent of the layer

Implemented in QgsRasterDataProvider.

Referenced by QgsVectorLayer::extent().

virtual QString QgsDataProvider::fileRasterFilters ( ) const
inlinevirtual

return raster file filter string

Returns a string suitable for a QFileDialog of raster file formats supported by the data provider. Naturally this will be an empty string for those data providers that do not deal with plain files, such as databases and servers.

Note

It'd be nice to eventually be raster/vector neutral.

Definition at line 279 of file qgsdataprovider.h.

virtual QString QgsDataProvider::fileVectorFilters ( ) const
inlinevirtual

return vector file filter string

Returns a string suitable for a QFileDialog of vector file formats supported by the data provider. Naturally this will be an empty string for those data providers that do not deal with plain files, such as databases and servers.

Note

It'd be nice to eventually be raster/vector neutral.

Definition at line 262 of file qgsdataprovider.h.

void QgsDataProvider::fullExtentCalculated ( )
signal

This is emitted whenever the worker thread has fully calculated the PostGIS extents for this layer, and its event has been received by this provider.

virtual bool QgsDataProvider::isValid ( )
pure virtual

Returns true if this is a valid layer.

It is up to individual providers to determine what constitutes a valid layer

Referenced by QgsVectorLayerImport::QgsVectorLayerImport(), QgsRasterChecker::runTest(), QgsRasterLayer::setDataProvider(), and QgsVectorLayer::setDataProvider().

virtual QString QgsDataProvider::name ( ) const
pure virtual

return a provider name

Essentially just returns the provider key. Should be used to build file dialogs so that providers can be shown with their supported types. Thus if more than one provider supports a given format, the user is able to select a specific provider to open that file.

Note

Instead of being pure virtual, might be better to generalize this behavior and presume that none of the sub-classes are going to do anything strange with regards to their name or description?

Referenced by QgsComposerMap::containsWMSLayer(), QgsVectorDataProvider::fieldNameIndex(), QgsVectorDataProvider::fieldNameMap(), QgsRasterLayerSaveAsDialog::on_mFormatComboBox_currentIndexChanged(), QgsProviderRegistry::provider(), and QgsRasterLayerSaveAsDialog::QgsRasterLayerSaveAsDialog().

virtual void QgsDataProvider::reloadData ( )
inlinevirtual

Reloads the data from the source.

Needs to be implemented by providers with data caches to synchronize with changes in the data source

Definition at line 286 of file qgsdataprovider.h.

Referenced by QgsRasterLayer::reload(), and QgsVectorLayer::reload().

virtual void QgsDataProvider::setDataSourceUri ( const QString &  uri)
inlinevirtual

Set the data source specification.

This may be a path or database connection string

Parameters
urisource specification

Definition at line 84 of file qgsdataprovider.h.

void QgsDataProvider::setError ( const QgsError theError)
inlineprotected

Set error message.

Definition at line 336 of file qgsdataprovider.h.

virtual void QgsDataProvider::setLayerOrder ( const QStringList &  layers)
inlinevirtual

Reorder the list of layer names to be rendered by this provider (in order from bottom to top)

Note
layers must have been previously added.

Definition at line 195 of file qgsdataprovider.h.

Referenced by QgsRasterLayer::setLayerOrder().

virtual void QgsDataProvider::setSubLayerVisibility ( const QString &  name,
bool  vis 
)
inlinevirtual

Set the visibility of the given sublayer name.

Definition at line 209 of file qgsdataprovider.h.

Referenced by QgsRasterLayer::setSubLayerVisibility().

virtual bool QgsDataProvider::setSubsetString ( QString  subset,
bool  updateFeatureCount = true 
)
inlinevirtual

Set the subset string used to create a subset of features in the layer.

This may be a sql where clause or any other string that can be used by the data provider to create a subset. Must be implemented in the dataprovider.

Definition at line 129 of file qgsdataprovider.h.

Referenced by QgsVectorLayer::setSubsetString().

virtual uint QgsDataProvider::subLayerCount ( ) const
inlinevirtual

return the number of layers for the current data source

Definition at line 184 of file qgsdataprovider.h.

virtual QStringList QgsDataProvider::subLayers ( ) const
inlinevirtual

Sub-layers handled by this provider, in order from bottom to top.

Sub-layers are used when the provider's source can combine layers it knows about in some way before it hands them off to the provider.

Reimplemented in QgsRasterDataProvider.

Definition at line 162 of file qgsdataprovider.h.

virtual QStringList QgsDataProvider::subLayerStyles ( ) const
inlinevirtual

Sub-layer styles for each sub-layer handled by this provider, in order from bottom to top.

Sub-layer styles are used to abstract the way the provider's source can symbolise layers in some way at the server, before it serves them to the provider.

Definition at line 175 of file qgsdataprovider.h.

virtual QString QgsDataProvider::subsetString ( )
inlinevirtual

Returns the subset definition string (typically sql) currently in use by the layer and used by the provider to limit the feature set.

Must be overridden in the dataprovider, otherwise returns a null QString.

Definition at line 150 of file qgsdataprovider.h.

Referenced by QgsVectorLayer::subsetString().

virtual bool QgsDataProvider::supportsSubsetString ( )
inlinevirtual

provider supports setting of subset strings

Note
added in 1.4

Definition at line 142 of file qgsdataprovider.h.

virtual QDateTime QgsDataProvider::timestamp ( ) const
inlinevirtual

Time stamp of data source in the moment when data/metadata were loaded by provider.

Reimplemented in QgsRasterDataProvider.

Definition at line 289 of file qgsdataprovider.h.

virtual void QgsDataProvider::updateExtents ( )
inlinevirtual

Update the extents of the layer.

Not implemented by default

Definition at line 117 of file qgsdataprovider.h.

Referenced by QgsVectorLayer::commitChanges(), and QgsVectorLayer::extent().

Member Data Documentation

QString QgsDataProvider::mDataSourceURI
private

Universal Resource Identifier for source data.

This could be a file, database, or server address.

Definition at line 344 of file qgsdataprovider.h.

QgsError QgsDataProvider::mError
protected

Error.

Definition at line 330 of file qgsdataprovider.h.

QDateTime QgsDataProvider::mTimestamp
protected

Timestamp of data in the moment when the data were loaded by provider.

Definition at line 327 of file qgsdataprovider.h.

Referenced by QgsRasterDataProvider::timestamp().


The documentation for this class was generated from the following file: