QGIS API Documentation  3.14.0-Pi (9f7028fd23)
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 
184  QString encodeUri( const QString &providerKey, const QVariantMap &parts );
185 
192  Q_DECL_DEPRECATED QWidget *createSelectionWidget( const QString &providerKey, QWidget *parent = nullptr, Qt::WindowFlags fl = Qt::WindowFlags(), QgsProviderRegistry::WidgetMode widgetMode = QgsProviderRegistry::WidgetMode::None ) SIP_DEPRECATED;
193 
199  QList< QgsDataItemProvider * > dataItemProviders( const QString &providerKey ) const SIP_FACTORY;
200 
206  int listStyles( const QString &providerKey,
207  const QString &uri,
208  QStringList &ids,
209  QStringList &names,
210  QStringList &descriptions,
211  QString &errCause );
212 
218  QString getStyleById( const QString &providerKey, const QString &uri, QString styleId, QString &errCause );
219 
224  bool deleteStyleById( const QString &providerKey, const QString &uri, QString styleId, QString &errCause );
225 
231  bool saveStyle( const QString &providerKey, const QString &uri, const QString &qmlStyle, const QString &sldStyle,
232  const QString &styleName, const QString &styleDescription,
233  const QString &uiFileContent, bool useAsDefault, QString &errCause );
234 
239  QString loadStyle( const QString &providerKey, const QString &uri, QString &errCause );
240 
245  bool createDb( const QString &providerKey, const QString &dbPath, QString &errCause );
246 
251  QgsTransaction *createTransaction( const QString &providerKey, const QString &connString ) SIP_FACTORY;
252 
263  Q_DECL_DEPRECATED QFunctionPointer function( const QString &providerKey, const QString &functionName ) SIP_DEPRECATED;
264 
274  Q_DECL_DEPRECATED QLibrary *createProviderLibrary( const QString &providerKey ) const SIP_FACTORY SIP_DEPRECATED;
275 
277  QStringList providerList() const;
278 
280  QgsProviderMetadata *providerMetadata( const QString &providerKey ) const;
281 
295  virtual QString fileVectorFilters() const;
296 
308  virtual QString fileRasterFilters() const;
309 
323  virtual QString fileMeshFilters() const;
324 
338  virtual QString fileMeshDatasetFilters() const;
339 
341  virtual QString databaseDrivers() const;
343  virtual QString directoryDrivers() const;
345  virtual QString protocolDrivers() const;
346 
350  Q_DECL_DEPRECATED void registerGuis( QWidget *widget ) SIP_DEPRECATED;
351 
358  bool registerProvider( QgsProviderMetadata *providerMetadata SIP_TRANSFER );
359 
361  SIP_SKIP typedef std::map<QString, QgsProviderMetadata *> Providers;
362 
363  private:
365  QgsProviderRegistry( const QString &pluginPath );
366 
367 #ifdef SIP_RUN
368  QgsProviderRegistry( const QString &pluginPath );
369 #endif
370 
371  void init();
372  void clean();
373 
375  Providers mProviders;
376 
378  QDir mLibraryDirectory;
379 
389  QString mVectorFileFilters;
390 
394  QString mRasterFileFilters;
395 
399  QString mMeshFileFilters;
400 
404  QString mMeshDatasetFileFilters;
405 
412  QString mDatabaseDrivers;
413 
419  QString mDirectoryDrivers;
420 
427  QString mProtocolDrivers;
428 
432  static bool exists();
433 
434  friend class QgsApplication;
435 
436 }; // class QgsProviderRegistry
437 
438 #endif //QGSPROVIDERREGISTRY_H
439 
QgsProviderRegistry::Embedded
@ Embedded
Used for the data source manager dialog where the widget is embedded as the main content for a partic...
Definition: qgsproviderregistry.h:77
QgsDataProvider::ProviderOptions
Setting options for creating vector data providers.
Definition: qgsdataprovider.h:104
QgsDataProvider
Definition: qgsdataprovider.h:41
QgsProviderRegistry::None
@ None
Basic mode when the widget is used as a standalone dialog.
Definition: qgsproviderregistry.h:71
QgsProviderRegistry
Definition: qgsproviderregistry.h:54
crs
const QgsCoordinateReferenceSystem & crs
Definition: qgswfsgetfeature.cpp:105
QgsFields
Definition: qgsfields.h:44
QgsTransaction
Definition: qgstransaction.h:56
QgsProviderRegistry::Providers
std::map< QString, QgsProviderMetadata * > Providers
Type for data provider metadata associative container.
Definition: qgsproviderregistry.h:361
SIP_FACTORY
#define SIP_FACTORY
Definition: qgis_sip.h:76
SIP_DEPRECATED
#define SIP_DEPRECATED
Definition: qgis_sip.h:106
QgsProviderRegistry::WidgetMode
WidgetMode
Different ways a source select dialog can be used.
Definition: qgsproviderregistry.h:63
SIP_SKIP
#define SIP_SKIP
Definition: qgis_sip.h:126
QgsDataItemProvider
Definition: qgsdataitemprovider.h:45
qgis_sip.h
SIP_TRANSFER
#define SIP_TRANSFER
Definition: qgis_sip.h:36
QgsApplication
Definition: qgsapplication.h:78
QgsCoordinateReferenceSystem
Definition: qgscoordinatereferencesystem.h:206
QgsProviderMetadata
Definition: qgsprovidermetadata.h:126
QgsProviderRegistry::Manager
@ Manager
Used by data items for QgsDataItem::paramWidget().
Definition: qgsproviderregistry.h:84
QgsVectorLayer
Definition: qgsvectorlayer.h:385
qgsvectorlayerexporter.h
qgsdataprovider.h
QgsVectorLayerExporter
Definition: qgsvectorlayerexporter.h:46
Qgis
Definition: qgis.h:45
QgsWkbTypes
Handles storage of information regarding WKB types and their properties.
Definition: qgswkbtypes.h:40
QgsDataItem
Definition: qgsdataitem.h:49
QgsRasterDataProvider
Definition: qgsrasterdataprovider.h:88