QGIS API Documentation  3.2.0-Bonn (bc43194)
Public Types | Public Member Functions | Static Public Member Functions | List of all members
QgsProviderRegistry Class Reference

A registry / canonical manager of data providers. More...

#include <qgsproviderregistry.h>

Public Types

typedef std::map< QString, QgsProviderMetadata * > Providers
 Open the given vector data source. More...
 
enum  WidgetMode { None, Embedded, Manager }
 Different ways a source select dialog can be used (embedded is for the data source manager dialog) More...
 

Public Member Functions

virtual ~QgsProviderRegistry ()
 
QgsDataProvidercreateProvider (const QString &providerKey, const QString &dataSource, const QgsDataProvider::ProviderOptions &options=QgsDataProvider::ProviderOptions())
 Creates a new instance of a provider. More...
 
QLibrary * createProviderLibrary (const QString &providerKey) const
 Returns a new QLibrary for the specified providerKey. More...
 
QWidget * createSelectionWidget (const QString &providerKey, QWidget *parent=nullptr, Qt::WindowFlags fl=Qt::WindowFlags(), QgsProviderRegistry::WidgetMode widgetMode=QgsProviderRegistry::WidgetMode::None)
 Returns a new widget for selecting layers from a provider. More...
 
virtual QString databaseDrivers () const
 Returns a string containing the available database drivers. More...
 
virtual QString directoryDrivers () const
 Returns a string containing the available directory drivers. More...
 
virtual QString fileRasterFilters () const
 Returns raster file filter string. More...
 
virtual QString fileVectorFilters () const
 Returns vector file filter string. More...
 
QFunctionPointer function (const QString &providerKey, const QString &functionName)
 Gets pointer to provider function. More...
 
QString library (const QString &providerKey) const
 Returns path for the library of the provider. More...
 
QDir libraryDirectory () const
 Returns the library directory where plugins are found. More...
 
QString pluginList (bool asHtml=false) const
 Returns list of provider plugins found. More...
 
virtual QString protocolDrivers () const
 Returns a string containing the available protocol drivers. More...
 
int providerCapabilities (const QString &providerKey) const
 Returns the provider capabilities. More...
 
QStringList providerList () const
 Returns list of available providers by their keys. More...
 
const QgsProviderMetadataproviderMetadata (const QString &providerKey) const
 Returns metadata of the provider or NULL if not found. More...
 
void registerGuis (QWidget *widget)
 
bool registerProvider (QgsProviderMetadata *providerMetadata)
 register a new vector data provider from its providerMetadata More...
 
void setLibraryDirectory (const QDir &path)
 Sets library directory where to search for plugins. More...
 

Static Public Member Functions

static QgsProviderRegistryinstance (const QString &pluginPath=QString())
 Means of accessing canonical single instance. More...
 

Detailed Description

A registry / canonical manager of data providers.

This is a Singleton class that manages data provider access.

Providers can be either loaded via libraries or native providers that are included in the core QGIS installation and accessed through function pointers.

Loaded providers may be restricted using QGIS_PROVIDER_FILE environment variable. QGIS_PROVIDER_FILE is regexp pattern applied to provider file name (not provider key). For example, if the variable is set to gdal|ogr|postgres it will load only providers gdal, ogr and postgres.

Definition at line 52 of file qgsproviderregistry.h.

Member Typedef Documentation

◆ Providers

Open the given vector data source.

Similar to open(QString const &), except that the user specifies a data provider with which to open the data source instead of using the default data provider that QgsDataManager would figure out to use. This should be useful when (and if) there will exist more than one data provider that can handle a given data source. (E.g., use GDAL to open an SDTS file, or a different data provider that uses sdts++.)

Called by QgsDataManager::open().

Parameters
namecould be a file, URI
provideris the key for the dataprovider used to open name
Returns
NULL if unable to open vector data source

Temporarily always returns false until finished implementing.

Eventually would be nice if could make QgsDataManager smart enough to figure out whether the given name mapped to a vector, raster, or database source.Type for data provider metadata associative container

Definition at line 215 of file qgsproviderregistry.h.

Member Enumeration Documentation

◆ WidgetMode

Different ways a source select dialog can be used (embedded is for the data source manager dialog)

Enumerator
None 
Embedded 
Manager 

Definition at line 61 of file qgsproviderregistry.h.

Constructor & Destructor Documentation

◆ ~QgsProviderRegistry()

QgsProviderRegistry::~QgsProviderRegistry ( )
virtual

Definition at line 271 of file qgsproviderregistry.cpp.

Member Function Documentation

◆ createProvider()

QgsDataProvider * QgsProviderRegistry::createProvider ( const QString &  providerKey,
const QString &  dataSource,
const QgsDataProvider::ProviderOptions options = QgsDataProvider::ProviderOptions() 
)

Creates a new instance of a provider.

Parameters
providerKeyidentificator of the provider
dataSourcestring containing data source for the provider
optionsprovider options
Returns
new instance of provider or NULL on error

Definition at line 375 of file qgsproviderregistry.cpp.

◆ createProviderLibrary()

QLibrary * QgsProviderRegistry::createProviderLibrary ( const QString &  providerKey) const

Returns a new QLibrary for the specified providerKey.

Ownership of the returned object is transferred to the caller and the caller is responsible for deleting it.

If the provider uses direct provider function pointers instead of a library nullptr will be returned.

Definition at line 495 of file qgsproviderregistry.cpp.

◆ createSelectionWidget()

QWidget * QgsProviderRegistry::createSelectionWidget ( const QString &  providerKey,
QWidget *  parent = nullptr,
Qt::WindowFlags  fl = Qt::WindowFlags(),
QgsProviderRegistry::WidgetMode  widgetMode = QgsProviderRegistry::WidgetMode::None 
)

Returns a new widget for selecting layers from a provider.

Either the parent widget must be set or the caller becomes responsible for deleting the returned widget.

Definition at line 461 of file qgsproviderregistry.cpp.

◆ databaseDrivers()

QString QgsProviderRegistry::databaseDrivers ( ) const
virtual

Returns a string containing the available database drivers.

Definition at line 559 of file qgsproviderregistry.cpp.

◆ directoryDrivers()

QString QgsProviderRegistry::directoryDrivers ( ) const
virtual

Returns a string containing the available directory drivers.

Definition at line 564 of file qgsproviderregistry.cpp.

◆ fileRasterFilters()

QString QgsProviderRegistry::fileRasterFilters ( ) const
virtual

Returns raster file filter string.

Returns a string suitable for a QFileDialog of raster file formats supported by all data providers.

This walks through all data providers appending calls to their buildSupportedRasterFileFilter to a string, which is then returned.

Note
This replaces QgsRasterLayer::buildSupportedRasterFileFilter()

Definition at line 554 of file qgsproviderregistry.cpp.

◆ fileVectorFilters()

QString QgsProviderRegistry::fileVectorFilters ( ) const
virtual

Returns vector file filter string.

Returns a string suitable for a QFileDialog of vector file formats supported by all data providers.

This walks through all data providers appending calls to their fileVectorFilters to a string, which is then returned.

Note

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

Definition at line 549 of file qgsproviderregistry.cpp.

◆ function()

QFunctionPointer QgsProviderRegistry::function ( const QString &  providerKey,
const QString &  functionName 
)

Gets pointer to provider function.

Parameters
providerKeyidentificator of the provider
functionNamename of function
Returns
pointer to function or NULL on error. If the provider uses direct provider function pointers instead of a library nullptr will be returned.

Definition at line 473 of file qgsproviderregistry.cpp.

◆ instance()

QgsProviderRegistry * QgsProviderRegistry::instance ( const QString &  pluginPath = QString())
static

Means of accessing canonical single instance.

Definition at line 51 of file qgsproviderregistry.cpp.

◆ library()

QString QgsProviderRegistry::library ( const QString &  providerKey) const

Returns path for the library of the provider.

If the provider uses direct provider function pointers instead of a library an empty string will be returned.

Definition at line 304 of file qgsproviderregistry.cpp.

◆ libraryDirectory()

QDir QgsProviderRegistry::libraryDirectory ( ) const

Returns the library directory where plugins are found.

Definition at line 357 of file qgsproviderregistry.cpp.

◆ pluginList()

QString QgsProviderRegistry::pluginList ( bool  asHtml = false) const

Returns list of provider plugins found.

Definition at line 317 of file qgsproviderregistry.cpp.

◆ protocolDrivers()

QString QgsProviderRegistry::protocolDrivers ( ) const
virtual

Returns a string containing the available protocol drivers.

Definition at line 569 of file qgsproviderregistry.cpp.

◆ providerCapabilities()

int QgsProviderRegistry::providerCapabilities ( const QString &  providerKey) const

Returns the provider capabilities.

Parameters
providerKeyidentificator of the provider
Since
QGIS 2.6

Definition at line 441 of file qgsproviderregistry.cpp.

◆ providerList()

QStringList QgsProviderRegistry::providerList ( ) const

Returns list of available providers by their keys.

Definition at line 574 of file qgsproviderregistry.cpp.

◆ providerMetadata()

const QgsProviderMetadata * QgsProviderRegistry::providerMetadata ( const QString &  providerKey) const

Returns metadata of the provider or NULL if not found.

Definition at line 584 of file qgsproviderregistry.cpp.

◆ registerGuis()

void QgsProviderRegistry::registerGuis ( QWidget *  widget)

Definition at line 513 of file qgsproviderregistry.cpp.

◆ registerProvider()

bool QgsProviderRegistry::registerProvider ( QgsProviderMetadata providerMetadata)

register a new vector data provider from its providerMetadata

Returns
true on success, false if a provider with the same key was already registered
Note
ownership of the QgsProviderMetadata instance is transferred to the registry
Since
QGIS 3.2

Definition at line 528 of file qgsproviderregistry.cpp.

◆ setLibraryDirectory()

void QgsProviderRegistry::setLibraryDirectory ( const QDir &  path)

Sets library directory where to search for plugins.

Definition at line 350 of file qgsproviderregistry.cpp.


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