QGIS API Documentation  3.10.0-A Coruña (6c816b4204)
qgsproviderregistry.h
Go to the documentation of this file.
1 /***************************************************************************
2  qgsproviderregistry.h - Singleton class for
3  registering data providers.
4  -------------------
5  begin : Sat Jan 10 2004
6  copyright : (C) 2004 by Gary E.Sherman
7  email : sherman at mrcc.com
8  ***************************************************************************/
9 
10 /***************************************************************************
11  * *
12  * This program is free software; you can redistribute it and/or modify *
13  * it under the terms of the GNU General Public License as published by *
14  * the Free Software Foundation; either version 2 of the License, or *
15  * (at your option) any later version. *
16  * *
17  ***************************************************************************/
18 
19 #ifndef QGSPROVIDERREGISTRY_H
20 #define QGSPROVIDERREGISTRY_H
21 
22 #include <map>
23 
24 #include <QDir>
25 #include <QLibrary>
26 #include <QString>
27 
28 #include "qgsvectorlayerexporter.h"
29 #include "qgsdataprovider.h"
30 #include "qgis_core.h"
31 #include "qgis_sip.h"
32 
34 class QgsVectorLayer;
37 class QgsDataItem;
39 
54 class CORE_EXPORT QgsProviderRegistry
55 {
56 
57  public:
58 
62  // TODO QGIS 4 - either move to QgsAbstractDataSourceWidget or remove altogether
64  {
65 
72 
78 
85  };
86 
88  static QgsProviderRegistry *instance( const QString &pluginPath = QString() );
89 
90  virtual ~QgsProviderRegistry();
91 
100  Q_DECL_DEPRECATED QString library( const QString &providerKey ) const SIP_DEPRECATED;
101 
103  QString pluginList( bool asHtml = false ) const;
104 
108  QDir libraryDirectory() const;
109 
111  void setLibraryDirectory( const QDir &path );
112 
122  QgsDataProvider *createProvider( const QString &providerKey,
123  const QString &dataSource,
125 
132  Q_DECL_DEPRECATED int providerCapabilities( const QString &providerKey ) const SIP_DEPRECATED;
133 
139  SIP_SKIP QgsVectorLayerExporter::ExportError createEmptyLayer( const QString &providerKey, const QString &uri, const QgsFields &fields, QgsWkbTypes::Type wkbType, const QgsCoordinateReferenceSystem &srs, bool overwrite, QMap<int, int> &oldToNewAttrIdxMap, QString &errorMessage, const QMap<QString, QVariant> *options );
140 
147  virtual QgsRasterDataProvider *createRasterDataProvider(
148  const QString &providerKey,
149  const QString &uri,
150  const QString &format,
151  int nBands,
152  Qgis::DataType type,
153  int width, int height,
154  double *geoTransform,
156  const QStringList &createOptions = QStringList() ) SIP_FACTORY;
157 
163  QList<QPair<QString, QString> > pyramidResamplingMethods( const QString &providerKey );
164 
173  QVariantMap decodeUri( const QString &providerKey, const QString &uri );
174 
181  Q_DECL_DEPRECATED QWidget *createSelectionWidget( const QString &providerKey, QWidget *parent = nullptr, Qt::WindowFlags fl = Qt::WindowFlags(), QgsProviderRegistry::WidgetMode widgetMode = QgsProviderRegistry::WidgetMode::None ) SIP_DEPRECATED;
182 
188  QList< QgsDataItemProvider * > dataItemProviders( const QString &providerKey ) const SIP_FACTORY;
189 
195  int listStyles( const QString &providerKey,
196  const QString &uri,
197  QStringList &ids,
198  QStringList &names,
199  QStringList &descriptions,
200  QString &errCause );
201 
207  QString getStyleById( const QString &providerKey, const QString &uri, QString styleId, QString &errCause );
208 
213  bool deleteStyleById( const QString &providerKey, const QString &uri, QString styleId, QString &errCause );
214 
220  bool saveStyle( const QString &providerKey, const QString &uri, const QString &qmlStyle, const QString &sldStyle,
221  const QString &styleName, const QString &styleDescription,
222  const QString &uiFileContent, bool useAsDefault, QString &errCause );
223 
228  QString loadStyle( const QString &providerKey, const QString &uri, QString &errCause );
229 
234  bool createDb( const QString &providerKey, const QString &dbPath, QString &errCause );
235 
240  QgsTransaction *createTransaction( const QString &providerKey, const QString &connString ) SIP_FACTORY;
241 
252  Q_DECL_DEPRECATED QFunctionPointer function( const QString &providerKey, const QString &functionName ) SIP_DEPRECATED;
253 
263  Q_DECL_DEPRECATED QLibrary *createProviderLibrary( const QString &providerKey ) const SIP_FACTORY SIP_DEPRECATED;
264 
266  QStringList providerList() const;
267 
269  QgsProviderMetadata *providerMetadata( const QString &providerKey ) const;
270 
284  virtual QString fileVectorFilters() const;
285 
297  virtual QString fileRasterFilters() const;
298 
312  virtual QString fileMeshFilters() const;
313 
327  virtual QString fileMeshDatasetFilters() const;
328 
330  virtual QString databaseDrivers() const;
332  virtual QString directoryDrivers() const;
334  virtual QString protocolDrivers() const;
335 
339  Q_DECL_DEPRECATED void registerGuis( QWidget *widget ) SIP_DEPRECATED;
340 
347  bool registerProvider( QgsProviderMetadata *providerMetadata SIP_TRANSFER );
348 
350  SIP_SKIP typedef std::map<QString, QgsProviderMetadata *> Providers;
351 
352  private:
354  QgsProviderRegistry( const QString &pluginPath );
355 
356 #ifdef SIP_RUN
357  QgsProviderRegistry( const QString &pluginPath );
358 #endif
359 
360  void init();
361  void clean();
362 
364  Providers mProviders;
365 
367  QDir mLibraryDirectory;
368 
378  QString mVectorFileFilters;
379 
383  QString mRasterFileFilters;
384 
388  QString mMeshFileFilters;
389 
393  QString mMeshDatasetFileFilters;
394 
401  QString mDatabaseDrivers;
402 
408  QString mDirectoryDrivers;
409 
416  QString mProtocolDrivers;
417 
421  static bool exists();
422 
423  friend class QgsApplication;
424 
425 }; // class QgsProviderRegistry
426 
427 #endif //QGSPROVIDERREGISTRY_H
428 
WidgetMode
Different ways a source select dialog can be used.
Extends QApplication to provide access to QGIS specific resources such as theme paths, database paths etc.
Handles storage of information regarding WKB types and their properties.
Definition: qgswkbtypes.h:40
Used by data items for QgsDataItem::paramWidget().
Container of fields for a vector layer.
Definition: qgsfields.h:42
Abstract base class for spatial data provider implementations.
const QgsCoordinateReferenceSystem & crs
The Qgis class provides global constants for use throughout the application.
Definition: qgis.h:45
#define SIP_SKIP
Definition: qgis_sip.h:126
#define SIP_TRANSFER
Definition: qgis_sip.h:36
#define SIP_FACTORY
Definition: qgis_sip.h:76
#define SIP_DEPRECATED
Definition: qgis_sip.h:106
Basic mode when the widget is used as a standalone dialog.
Base class for all items in the model.
Definition: qgsdataitem.h:49
A convenience class for exporting vector layers to a destination data provider.
A registry / canonical manager of data providers.
Setting options for creating vector data providers.
Used for the data source manager dialog where the widget is embedded as the main content for a partic...
Holds data provider key, description, and associated shared library file or function pointer informat...
This class allows including a set of layers in a database-side transaction, provided the layer data p...
std::map< QString, QgsProviderMetadata * > Providers
Type for data provider metadata associative container.
This class represents a coordinate reference system (CRS).
Represents a vector layer which manages a vector based data sets.
This is the interface for those who want to add custom data items to the browser tree.
Base class for raster data providers.