LCOV - code coverage report
Current view: top level - core - qgsproviderregistry.h (source / functions) Hit Total Coverage
Test: coverage.info.cleaned Lines: 2 14 14.3 %
Date: 2021-04-10 08:29:14 Functions: 0 0 -
Branches: 0 0 -

           Branch data     Line data    Source code
       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                 :            : 
      33                 :            : #include <vector>
      34                 :            : #include <memory>
      35                 :            : 
      36                 :            : class QgsProviderMetadata;
      37                 :            : class QgsVectorLayer;
      38                 :            : class QgsCoordinateReferenceSystem;
      39                 :            : class QgsDataItemProvider;
      40                 :            : class QgsDataItem;
      41                 :            : class QgsRasterDataProvider;
      42                 :            : 
      43                 :            : /**
      44                 :            :  * \ingroup core
      45                 :            :   * \brief A registry / canonical manager of data providers.
      46                 :            :   *
      47                 :            :   * This is a Singleton class that manages data provider access.
      48                 :            :   *
      49                 :            :   * Providers can be either loaded via libraries or native providers that
      50                 :            :   * are included in the core QGIS installation and accessed through function pointers.
      51                 :            :   *
      52                 :            :   * Loaded providers may be restricted using QGIS_PROVIDER_FILE environment variable.
      53                 :            :   * QGIS_PROVIDER_FILE is regexp pattern applied to provider file name (not provider key).
      54                 :            :   * For example, if the variable is set to gdal|ogr|postgres it will load only providers gdal,
      55                 :            :   * ogr and postgres.
      56                 :            : */
      57                 :            : class CORE_EXPORT QgsProviderRegistry
      58                 :            : {
      59                 :            : 
      60                 :            :   public:
      61                 :            : 
      62                 :            :     // TODO QGIS 4 - either move to QgsAbstractDataSourceWidget or remove altogether
      63                 :            : 
      64                 :            :     /**
      65                 :            :      * Different ways a source select dialog can be used
      66                 :            :      */
      67                 :            :     enum WidgetMode
      68                 :            :     {
      69                 :            : 
      70                 :            :       /**
      71                 :            :        * Basic mode when the widget is used as a standalone dialog. Originally used
      72                 :            :        * as GUI for individual "Add XXX layer" buttons in the main window.
      73                 :            :        * Likely not used in live code anymore.
      74                 :            :        */
      75                 :            :       None,
      76                 :            : 
      77                 :            :       /**
      78                 :            :        * Used for the data source manager dialog where the widget is embedded as the main content
      79                 :            :        * for a particular tab.
      80                 :            :        */
      81                 :            :       Embedded,
      82                 :            : 
      83                 :            :       /**
      84                 :            :        * Used by data items for QgsDataItem::paramWidget(). Originally used by QGIS Browser,
      85                 :            :        * but does not seem to be in live code anymore. The mode was meant to avoid some actions
      86                 :            :        * to keep the browser interface simple (supposedly).
      87                 :            :        */
      88                 :            :       Manager,
      89                 :            :     };
      90                 :            : 
      91                 :            :     //! Means of accessing canonical single instance
      92                 :            :     static QgsProviderRegistry *instance( const QString &pluginPath = QString() );
      93                 :            : 
      94                 :            :     ~QgsProviderRegistry();
      95                 :            : 
      96                 :            :     /**
      97                 :            :      * Returns path for the library of the provider.
      98                 :            :      *
      99                 :            :      * If the provider uses direct provider function pointers instead of a library an empty string will
     100                 :            :      * be returned.
     101                 :            :      *
     102                 :            :      * \deprecated QGIS 3.10 - providers may not need to be loaded from a library (empty string returned)
     103                 :            :      */
     104                 :            :     Q_DECL_DEPRECATED QString library( const QString &providerKey ) const SIP_DEPRECATED;
     105                 :            : 
     106                 :            :     //! Returns list of provider plugins found
     107                 :            :     QString pluginList( bool asHtml = false ) const;
     108                 :            : 
     109                 :            :     /**
     110                 :            :      * Returns the library directory where plugins are found.
     111                 :            :      */
     112                 :            :     QDir libraryDirectory() const;
     113                 :            : 
     114                 :            :     //! Sets library directory where to search for plugins
     115                 :            :     void setLibraryDirectory( const QDir &path );
     116                 :            : 
     117                 :            :     /*
     118                 :            :      * IMPORTANT: While it seems like /Factory/ would be the correct annotation here, that's not
     119                 :            :      * the case.
     120                 :            :      * Paraphrasing Phil Thomson's advice on https://www.riverbankcomputing.com/pipermail/pyqt/2017-July/039450.html:
     121                 :            :      *
     122                 :            :      * "
     123                 :            :      * /Factory/ is used when the instance returned is guaranteed to be new to Python.
     124                 :            :      * In this case it isn't because it has already been seen when being returned by by the python function
     125                 :            :      * creating the provider subclass.
     126                 :            :      *
     127                 :            :      * (However for a different sub-class implemented in C++ then it would be the first time it was seen
     128                 :            :      * by Python so the /Factory/ on create() would be correct.)
     129                 :            :      *
     130                 :            :      * You might try using /TransferBack/ on createProvider() instead - that might be the best compromise.
     131                 :            :      * "
     132                 :            :      */
     133                 :            : 
     134                 :            :     /**
     135                 :            :      * Creates a new instance of a provider.
     136                 :            :      * \param providerKey identifier of the provider
     137                 :            :      * \param dataSource  string containing data source for the provider
     138                 :            :      * \param options provider options
     139                 :            :      * \param flags provider flags since QGIS 3.16
     140                 :            :      * \returns new instance of provider or NULLPTR on error
     141                 :            :      *
     142                 :            :      * \see createRasterDataProvider()
     143                 :            :      */
     144                 :            :     QgsDataProvider *createProvider( const QString &providerKey,
     145                 :            :                                      const QString &dataSource,
     146                 :            :                                      const QgsDataProvider::ProviderOptions &options = QgsDataProvider::ProviderOptions(),
     147                 :            :                                      QgsDataProvider::ReadFlags flags = QgsDataProvider::ReadFlags() ) SIP_TRANSFERBACK;
     148                 :            : 
     149                 :            :     /**
     150                 :            :      * Returns the provider capabilities
     151                 :            :      * \param providerKey identifier of the provider
     152                 :            :      * \since QGIS 2.6
     153                 :            :      * \deprecated QGIS 3.10 (use instead capabilities() method of individual data item provider)
     154                 :            :      */
     155                 :            :     Q_DECL_DEPRECATED int providerCapabilities( const QString &providerKey ) const SIP_DEPRECATED;
     156                 :            : 
     157                 :            :     /**
     158                 :            :      * Creates new empty vector layer
     159                 :            :      * \note not available in Python bindings
     160                 :            :      * \since QGIS 3.10
     161                 :            :      */
     162                 :            :     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 );
     163                 :            : 
     164                 :            :     /**
     165                 :            :      * Creates new instance of raster data provider
     166                 :            :      *
     167                 :            :      * \see createProvider()
     168                 :            :      * \since QGIS 3.10
     169                 :            :      */
     170                 :            :     QgsRasterDataProvider *createRasterDataProvider(
     171                 :            :       const QString &providerKey,
     172                 :            :       const QString &uri,
     173                 :            :       const QString &format,
     174                 :            :       int nBands,
     175                 :            :       Qgis::DataType type,
     176                 :            :       int width, int height,
     177                 :            :       double *geoTransform,
     178                 :            :       const QgsCoordinateReferenceSystem &crs,
     179                 :            :       const QStringList &createOptions = QStringList() ) SIP_FACTORY;
     180                 :            : 
     181                 :            :     /**
     182                 :            :      * Returns list of raster pyramid resampling methods
     183                 :            :      *
     184                 :            :      * \since QGIS 3.10
     185                 :            :      */
     186                 :            :     QList<QPair<QString, QString> > pyramidResamplingMethods( const QString &providerKey );
     187                 :            : 
     188                 :            :     /**
     189                 :            :      * Breaks a provider data source URI into its component paths (e.g. file path, layer name).
     190                 :            :      * \param providerKey identifier of the provider
     191                 :            :      * \param uri uri string
     192                 :            :      * \returns map containing components. Standard components include "path", "layerName", "url".
     193                 :            :      * \note this function may not be supported by all providers, an empty map will be returned in such case
     194                 :            :      * \since QGIS 3.4
     195                 :            :      */
     196                 :            :     QVariantMap decodeUri( const QString &providerKey, const QString &uri );
     197                 :            : 
     198                 :            :     /**
     199                 :            :      * Reassembles a provider data source URI from its component paths (e.g. file path, layer name).
     200                 :            :      * \param providerKey identifier of the provider
     201                 :            :      * \param parts parts as returned by decodeUri
     202                 :            :      * \returns datasource uri string
     203                 :            :      * \note this function may not be supported by all providers, an empty string will be returned in such case
     204                 :            :      * \see decodeUri()
     205                 :            :      * \since QGIS 3.12
     206                 :            :      */
     207                 :            :     QString encodeUri( const QString &providerKey, const QVariantMap &parts );
     208                 :            : 
     209                 :            :     /**
     210                 :            :      * Returns a new widget for selecting layers from a provider.
     211                 :            :      * Either the \a parent widget must be set or the caller becomes
     212                 :            :      * responsible for deleting the returned widget.
     213                 :            :      * \deprecated QGIS 3.10 - use QgsGui::sourceSelectProviderRegistry()->createDataSourceWidget() instead
     214                 :            :      */
     215                 :            :     Q_DECL_DEPRECATED QWidget *createSelectionWidget( const QString &providerKey, QWidget *parent = nullptr, Qt::WindowFlags fl = Qt::WindowFlags(), QgsProviderRegistry::WidgetMode widgetMode = QgsProviderRegistry::WidgetMode::None ) SIP_DEPRECATED;
     216                 :            : 
     217                 :            :     /**
     218                 :            :      * Returns list of data item providers of the provider
     219                 :            :      * \note Ownership of created data item providers is passed to the caller.
     220                 :            :      * \since QGIS 3.10
     221                 :            :      */
     222                 :            :     QList< QgsDataItemProvider * > dataItemProviders( const QString &providerKey ) const SIP_FACTORY;
     223                 :            : 
     224                 :            :     /**
     225                 :            :      * Lists stored layer styles in the provider defined by \a providerKey and \a uri
     226                 :            :      * \returns -1 if not implemented by provider, otherwise number of styles stored
     227                 :            :      * \since QGIS 3.10
     228                 :            :      */
     229                 :            :     int listStyles( const QString &providerKey,
     230                 :            :                     const QString &uri,
     231                 :            :                     QStringList &ids,
     232                 :            :                     QStringList &names,
     233                 :            :                     QStringList &descriptions,
     234                 :            :                     QString &errCause );
     235                 :            : 
     236                 :            :     /**
     237                 :            :      * Gets a layer style defined by \a styleId
     238                 :            :      *
     239                 :            :      * \since QGIS 3.10
     240                 :            :      */
     241                 :            :     QString getStyleById( const QString &providerKey,  const QString &uri, QString styleId, QString &errCause );
     242                 :            : 
     243                 :            :     /**
     244                 :            :      * Deletes a layer style defined by \a styleId
     245                 :            :      * \since QGIS 3.10
     246                 :            :      */
     247                 :            :     bool deleteStyleById( const QString &providerKey,  const QString &uri, QString styleId, QString &errCause );
     248                 :            : 
     249                 :            :     /**
     250                 :            :      * Saves a layer style to provider
     251                 :            :      *
     252                 :            :      * \since QGIS 3.10
     253                 :            :      */
     254                 :            :     bool saveStyle( const QString &providerKey,  const QString &uri, const QString &qmlStyle, const QString &sldStyle,
     255                 :            :                     const QString &styleName, const QString &styleDescription,
     256                 :            :                     const QString &uiFileContent, bool useAsDefault, QString &errCause );
     257                 :            : 
     258                 :            :     /**
     259                 :            :      * Loads a layer style defined by \a uri
     260                 :            :      * \since QGIS 3.10
     261                 :            :      */
     262                 :            :     QString loadStyle( const QString &providerKey,  const QString &uri, QString &errCause );
     263                 :            : 
     264                 :            :     /**
     265                 :            :      * Creates database by the provider on the path
     266                 :            :      * \since QGIS 3.10
     267                 :            :      */
     268                 :            :     bool createDb( const QString &providerKey, const QString &dbPath, QString &errCause );
     269                 :            : 
     270                 :            :     /**
     271                 :            :      * Returns new instance of transaction. Ownership is transferred to the caller
     272                 :            :      * \since QGIS 3.10
     273                 :            :      */
     274                 :            :     QgsTransaction *createTransaction( const QString &providerKey, const QString &connString ) SIP_FACTORY;
     275                 :            : 
     276                 :            :     /**
     277                 :            :      * Gets pointer to provider function
     278                 :            :      *
     279                 :            :      * \param providerKey identifier of the provider
     280                 :            :      * \param functionName name of function
     281                 :            :      * \returns pointer to function or NULLPTR on error. If the provider uses direct provider
     282                 :            :      * function pointers instead of a library NULLPTR will be returned.
     283                 :            :      *
     284                 :            :      * \deprecated QGIS 3.10 - any provider functionality should be accessed through QgsProviderMetadata
     285                 :            :      */
     286                 :            :     Q_DECL_DEPRECATED QFunctionPointer function( const QString &providerKey, const QString &functionName ) SIP_DEPRECATED;
     287                 :            : 
     288                 :            :     /**
     289                 :            :      * Returns a new QLibrary for the specified \a providerKey. Ownership of the returned
     290                 :            :      * object is transferred to the caller and the caller is responsible for deleting it.
     291                 :            :      *
     292                 :            :      * If the provider uses direct provider function pointers instead of a library NULLPTR will
     293                 :            :      * be returned.
     294                 :            :      *
     295                 :            :      * \deprecated QGIS 3.10 - providers may not need to be loaded from a library
     296                 :            :      */
     297                 :            :     Q_DECL_DEPRECATED QLibrary *createProviderLibrary( const QString &providerKey ) const SIP_FACTORY SIP_DEPRECATED;
     298                 :            : 
     299                 :            :     //! Returns list of available providers by their keys
     300                 :            :     QStringList providerList() const;
     301                 :            : 
     302                 :            :     //! Returns metadata of the provider or NULLPTR if not found
     303                 :            :     QgsProviderMetadata *providerMetadata( const QString &providerKey ) const;
     304                 :            : 
     305                 :            :     /**
     306                 :            :      * \ingroup core
     307                 :            :      *
     308                 :            :      * \brief Contains information pertaining to a candidate provider.
     309                 :            :      *
     310                 :            :      * \since QGIS 3.18
     311                 :            :      */
     312                 :          0 :     class CORE_EXPORT ProviderCandidateDetails
     313                 :            :     {
     314                 :            : 
     315                 :            :       public:
     316                 :            : 
     317                 :            :         /**
     318                 :            :          * Constructor for ProviderCandidateDetails, with the specified provider \a metadata and valid candidate \a layerTypes.
     319                 :            :          */
     320                 :          0 :         ProviderCandidateDetails( QgsProviderMetadata *metadata, const QList< QgsMapLayerType > &layerTypes )
     321                 :          0 :           : mMetadata( metadata )
     322                 :          0 :           , mLayerTypes( layerTypes )
     323                 :          0 :         {}
     324                 :            : 
     325                 :            :         /**
     326                 :            :          * Returns the candidate provider metadata.
     327                 :            :          */
     328                 :          0 :         QgsProviderMetadata *metadata() const { return mMetadata; }
     329                 :            : 
     330                 :            :         /**
     331                 :            :          * Returns a list of map layer types which are valid options for opening the
     332                 :            :          * target using this candidate provider.
     333                 :            :          */
     334                 :            :         QList<QgsMapLayerType> layerTypes() const { return mLayerTypes; }
     335                 :            : 
     336                 :            : #ifdef SIP_RUN
     337                 :            :         SIP_PYOBJECT __repr__();
     338                 :            :         % MethodCode
     339                 :            :         QString str = QStringLiteral( "<QgsProviderRegistry.ProviderCandidateDetails: %1>" ).arg( sipCpp->metadata()->key() );
     340                 :            :         sipRes = PyUnicode_FromString( str.toUtf8().constData() );
     341                 :            :         % End
     342                 :            : #endif
     343                 :            : 
     344                 :            :       private:
     345                 :            :         QgsProviderMetadata *mMetadata = nullptr;
     346                 :            : 
     347                 :            :         QList< QgsMapLayerType > mLayerTypes;
     348                 :            : 
     349                 :            :     };
     350                 :            : 
     351                 :            :     /**
     352                 :            :      * Returns the details for the preferred provider(s) for opening the specified \a uri.
     353                 :            :      *
     354                 :            :      * The preferred provider is determined by comparing the priority returned by
     355                 :            :      * QgsProviderMetadata::priorityForUri() for all registered providers, and selecting
     356                 :            :      * the provider with the largest non-zero priority.
     357                 :            :      *
     358                 :            :      * An empty list may be returned, which indicates that no providers are available which
     359                 :            :      * returned a non-zero priority for the specified URI.
     360                 :            :      *
     361                 :            :      * In the case that multiple providers returned the same priority for the URI then
     362                 :            :      * all of these providers will be returned.
     363                 :            :      *
     364                 :            :      * \see shouldDeferUriForOtherProviders()
     365                 :            :      * \since QGIS 3.18
     366                 :            :      */
     367                 :            :     QList< QgsProviderRegistry::ProviderCandidateDetails > preferredProvidersForUri( const QString &uri ) const;
     368                 :            : 
     369                 :            :     /**
     370                 :            :      * \ingroup core
     371                 :            :      *
     372                 :            :      * \brief Contains information about unusable URIs which aren't handled by any registered providers.
     373                 :            :      *
     374                 :            :      * For example, if a QGIS install is built without the PDAL library then las/laz files are unusable.
     375                 :            :      * This class can then be used to construct friendly warnings to users advising them why the las/laz
     376                 :            :      * files cannot be used on their QGIS build.
     377                 :            :      *
     378                 :            :      * \since QGIS 3.18.1
     379                 :            :      */
     380                 :          0 :     class CORE_EXPORT UnusableUriDetails
     381                 :            :     {
     382                 :            :       public:
     383                 :            : 
     384                 :            :         /**
     385                 :            :          * Constructor for UnusableUriDetails for the given \a uri, with the specified user-friendly, translated \a warning.
     386                 :            :          *
     387                 :            :          * The optional \a layerTypes argument can be used to specify layer types which are usually valid
     388                 :            :          * options for opening the URI.
     389                 :            :          */
     390                 :          0 :         UnusableUriDetails( const QString &uri = QString(), const QString &warning = QString(), const QList< QgsMapLayerType > &layerTypes = QList< QgsMapLayerType >() )
     391                 :          0 :           : uri( uri )
     392                 :          0 :           , warning( warning )
     393                 :          0 :           , layerTypes( layerTypes )
     394                 :          0 :         {}
     395                 :            : 
     396                 :            :         /**
     397                 :            :          * URI which could not be handled.
     398                 :            :          */
     399                 :            :         QString uri;
     400                 :            : 
     401                 :            :         /**
     402                 :            :          * Contains a short, user-friendly, translated message advising why the URI is not usable.
     403                 :            :          */
     404                 :            :         QString warning;
     405                 :            : 
     406                 :            :         /**
     407                 :            :          * Contains a longer, user-friendly, translated message advising why the URI is not usable.
     408                 :            :          */
     409                 :            :         QString detailedWarning;
     410                 :            : 
     411                 :            :         /**
     412                 :            :          * Contains a list of map layer types which are usually valid options for opening the
     413                 :            :          * target URI.
     414                 :            :          */
     415                 :            :         QList<QgsMapLayerType> layerTypes;
     416                 :            : 
     417                 :            : #ifdef SIP_RUN
     418                 :            :         SIP_PYOBJECT __repr__();
     419                 :            :         % MethodCode
     420                 :            :         QString str = QStringLiteral( "<QgsProviderRegistry.UnusableUriDetails: %1>" ).arg( sipCpp->warning );
     421                 :            :         sipRes = PyUnicode_FromString( str.toUtf8().constData() );
     422                 :            :         % End
     423                 :            : #endif
     424                 :            : 
     425                 :            :     };
     426                 :            : 
     427                 :            :     /**
     428                 :            :      * \ingroup core
     429                 :            :      *
     430                 :            :      * \brief An interface used to handle unusable URIs which aren't handled by any registered providers, and construct
     431                 :            :      * user-friendly warnings as to why the URI is unusable.
     432                 :            :      *
     433                 :            :      * For example, if a QGIS install is built without the PDAL library then las/laz files are unusable.
     434                 :            :      * This class can then be used to construct friendly warnings to users advising them why the las/laz
     435                 :            :      * files cannot be used on their QGIS build.
     436                 :            :      *
     437                 :            :      * \since QGIS 3.18.1
     438                 :            :      */
     439                 :          3 :     class CORE_EXPORT UnusableUriHandlerInterface
     440                 :            :     {
     441                 :            : 
     442                 :            :       public:
     443                 :            : 
     444                 :          3 :         virtual ~UnusableUriHandlerInterface() = default;
     445                 :            : 
     446                 :            :         /**
     447                 :            :          * Returns TRUE if the handle is an unusable URI handler for the specified \a uri.
     448                 :            :          */
     449                 :            :         virtual bool matchesUri( const QString &uri ) const = 0;
     450                 :            : 
     451                 :            :         /**
     452                 :            :          * Returns the details for advising the user why the \a uri is not usable.
     453                 :            :          */
     454                 :            :         virtual UnusableUriDetails details( const QString &uri ) const = 0;
     455                 :            : 
     456                 :            :     };
     457                 :            : 
     458                 :            :     /**
     459                 :            :      * \brief Registers an unusable URI \a handler, used to handle unusable URIs which aren't
     460                 :            :      * handled by any registered providers, and construct user-friendly warnings as to why the URI is unusable.
     461                 :            :      *
     462                 :            :      * \return TRUE on success
     463                 :            :      *
     464                 :            :      * \note ownership of the UnusableUriHandlerInterface instance is transferred to the registry
     465                 :            :      *
     466                 :            :      * \since QGIS 3.18.1
     467                 :            :      */
     468                 :            :     bool registerUnusableUriHandler( UnusableUriHandlerInterface *handler SIP_TRANSFER );
     469                 :            : 
     470                 :            :     /**
     471                 :            :      * Returns TRUE if the specified \a uri can potentially be handled by QGIS, if additional
     472                 :            :      * dependencies or build-time requirements are present.
     473                 :            :      *
     474                 :            :      * This can be used to show user-friendly warning messages advising them why a particular
     475                 :            :      * \a uri cannot be opened on their QGIS install. For example, if a QGIS install is built
     476                 :            :      * without the PDAL library then las/laz files are unusable, and this method can be used
     477                 :            :      * to retrieve a user-friendly warning as to why the las/laz files cannot be used on their
     478                 :            :      * QGIS build.
     479                 :            :      *
     480                 :            :      * \warning This method does not perform the test to actually determine if the given \a uri
     481                 :            :      * can be handled by any registered provider. It is assumed that prior to calling this method
     482                 :            :      * the caller has already determined in advance that the \a uri could not be handled.
     483                 :            :      *
     484                 :            :      * \param uri URI to test
     485                 :            :      * \param details will be populated with details allowing construction of a user-friendly
     486                 :            :      * warning message
     487                 :            :      *
     488                 :            :      * \returns TRUE if the \a uri was matched to a registered QgsProviderRegistry::UnusableUriHandlerInterface.
     489                 :            :      *
     490                 :            :      * \see registerUnusableUriHandler()
     491                 :            :      * \since QGIS 3.18.1
     492                 :            :      */
     493                 :            :     bool handleUnusableUri( const QString &uri, UnusableUriDetails &details SIP_OUT ) const;
     494                 :            : 
     495                 :            :     /**
     496                 :            :      * Returns TRUE if the provider with matching \a providerKey should defer handling of
     497                 :            :      * the specified \a uri to another provider.
     498                 :            :      *
     499                 :            :      * This method tests whether any providers are listed as the preferred provider for \a uri
     500                 :            :      * (see preferredProvidersForUri()), and if so tests whether the specified provider is
     501                 :            :      * included in that preferred providers list. Returns TRUE only if the specified provider
     502                 :            :      * is calculated as one of the preferred providers for the URI.
     503                 :            :      *
     504                 :            :      * In the case that there is no registered preferred provider for the URI then FALSE will be
     505                 :            :      * returned, and the provider must use another metric to determine whether it should
     506                 :            :      * handle the URI.
     507                 :            :      *
     508                 :            :      * \see preferredProvidersForUri()
     509                 :            :      * \since QGIS 3.18
     510                 :            :      */
     511                 :            :     bool shouldDeferUriForOtherProviders( const QString &uri, const QString &providerKey ) const;
     512                 :            : 
     513                 :            :     /**
     514                 :            :      * Returns TRUE if the specified \a uri is known by any registered provider to be something which should
     515                 :            :      * be blocklisted from the QGIS interface, e.g. an internal detail only.
     516                 :            :      *
     517                 :            :      * Specifically, this method can be utilized by the browser panel to hide noisy internal details
     518                 :            :      * for URIs which are known to be sidecar files only, such as ".aux.xml" files or ".shp.xml" files,
     519                 :            :      * or the "ept-build.json" files which sit alongside Entwine "ept.json" point cloud sources.
     520                 :            :      *
     521                 :            :      * This method tests whether any of the registered providers return TRUE for the their
     522                 :            :      * QgsProviderMetadata::uriIsBlocklisted() implementation for the specified URI.
     523                 :            :      *
     524                 :            :      * \since QGIS 3.18
     525                 :            :      */
     526                 :            :     bool uriIsBlocklisted( const QString &uri ) const;
     527                 :            : 
     528                 :            :     /**
     529                 :            :      * Returns a file filter string for supported vector files.
     530                 :            :      *
     531                 :            :      * Returns a string suitable for a QFileDialog of vector file formats
     532                 :            :      * supported by all data providers.
     533                 :            :      *
     534                 :            :      * \see fileRasterFilters()
     535                 :            :      * \see fileMeshFilters()
     536                 :            :      * \see filePointCloudFilters()
     537                 :            :      */
     538                 :            :     QString fileVectorFilters() const;
     539                 :            : 
     540                 :            :     /**
     541                 :            :      * Returns a file filter string for supported raster files.
     542                 :            :      *
     543                 :            :      * Returns a string suitable for a QFileDialog of raster file formats
     544                 :            :      * supported by all data providers.
     545                 :            :      *
     546                 :            :      * \note This replaces QgsRasterLayer::buildSupportedRasterFileFilter()
     547                 :            :      *
     548                 :            :      * \see fileVectorFilters()
     549                 :            :      * \see fileMeshFilters()
     550                 :            :      * \see filePointCloudFilters()
     551                 :            :      */
     552                 :            :     QString fileRasterFilters() const;
     553                 :            : 
     554                 :            :     /**
     555                 :            :      * Returns a file filter string for supported mesh files.
     556                 :            :      *
     557                 :            :      * Returns a string suitable for a QFileDialog of mesh file formats
     558                 :            :      * supported by all data providers.
     559                 :            :      *
     560                 :            :      * \see fileMeshDatasetFilters()
     561                 :            :      * \see fileRasterFilters()
     562                 :            :      * \see fileVectorFilters()
     563                 :            :      * \see filePointCloudFilters()
     564                 :            :      *
     565                 :            :      * \since QGIS 3.6
     566                 :            :      */
     567                 :            :     QString fileMeshFilters() const;
     568                 :            : 
     569                 :            :     /**
     570                 :            :      * Returns a file filter string for supported mesh dataset files.
     571                 :            :      *
     572                 :            :      * Returns a string suitable for a QFileDialog of mesh datasets file formats
     573                 :            :      * supported by all data providers.
     574                 :            :      *
     575                 :            :      * \see fileMeshFilters()
     576                 :            :      *
     577                 :            :      * \since QGIS 3.6
     578                 :            :      */
     579                 :            :     QString fileMeshDatasetFilters() const;
     580                 :            : 
     581                 :            :     /**
     582                 :            :      * Returns a file filter string for supported point clouds.
     583                 :            :      *
     584                 :            :      * Returns a string suitable for a QFileDialog of point cloud file formats
     585                 :            :      * supported by all data providers.
     586                 :            :      *
     587                 :            :      * \see fileMeshFilters()
     588                 :            :      * \see fileRasterFilters()
     589                 :            :      * \see fileVectorFilters()
     590                 :            :      *
     591                 :            :      * \since QGIS 3.18
     592                 :            :      */
     593                 :            :     QString filePointCloudFilters() const;
     594                 :            : 
     595                 :            :     //! Returns a string containing the available database drivers
     596                 :            :     QString databaseDrivers() const;
     597                 :            :     //! Returns a string containing the available directory drivers
     598                 :            :     QString directoryDrivers() const;
     599                 :            :     //! Returns a string containing the available protocol drivers
     600                 :            :     QString protocolDrivers() const;
     601                 :            : 
     602                 :            :     /**
     603                 :            :      * \deprecated since QGIS 3.10 - does nothing - use QgsGui::providerGuiRegistry()
     604                 :            :      */
     605                 :            :     Q_DECL_DEPRECATED void registerGuis( QWidget *widget ) SIP_DEPRECATED;
     606                 :            : 
     607                 :            :     /**
     608                 :            :      * \brief register a new vector data provider from its \a providerMetadata
     609                 :            :      * \return TRUE on success, FALSE if a provider with the same key was already registered
     610                 :            :      * \note ownership of the QgsProviderMetadata instance is transferred to the registry
     611                 :            :      * \since QGIS 3.2
     612                 :            :      */
     613                 :            :     bool registerProvider( QgsProviderMetadata *providerMetadata SIP_TRANSFER );
     614                 :            : 
     615                 :            :     //! Type for data provider metadata associative container
     616                 :            :     SIP_SKIP typedef std::map<QString, QgsProviderMetadata *> Providers;
     617                 :            : 
     618                 :            :   private:
     619                 :            :     //! Ctor private since instance() creates it
     620                 :            :     QgsProviderRegistry( const QString &pluginPath );
     621                 :            : 
     622                 :            : #ifdef SIP_RUN
     623                 :            :     QgsProviderRegistry( const QString &pluginPath );
     624                 :            : #endif
     625                 :            : 
     626                 :            :     void init();
     627                 :            :     void clean();
     628                 :            : 
     629                 :            :     //! Associative container of provider metadata handles
     630                 :            :     Providers mProviders;
     631                 :            : 
     632                 :            :     //! Directory in which provider plugins are installed
     633                 :            :     QDir mLibraryDirectory;
     634                 :            : 
     635                 :            :     /**
     636                 :            :      * File filter string for vector files
     637                 :            :      *
     638                 :            :      * Built once when registry is constructed by appending strings returned
     639                 :            :      * from iteratively calling vectorFileFilter() for each visited data
     640                 :            :      * provider.  The alternative would have been to do this each time
     641                 :            :      * fileVectorFilters was invoked; instead we only have to build it the
     642                 :            :      * one time.
     643                 :            :      */
     644                 :            :     QString mVectorFileFilters;
     645                 :            : 
     646                 :            :     /**
     647                 :            :      * File filter string for raster files
     648                 :            :      */
     649                 :            :     QString mRasterFileFilters;
     650                 :            : 
     651                 :            :     /**
     652                 :            :      * File filter string for raster files
     653                 :            :      */
     654                 :            :     QString mMeshFileFilters;
     655                 :            : 
     656                 :            :     /**
     657                 :            :      * File filter string for raster files
     658                 :            :      */
     659                 :            :     QString mMeshDatasetFileFilters;
     660                 :            : 
     661                 :            :     /**
     662                 :            :      * File filter string for point cloud files
     663                 :            :      */
     664                 :            :     QString mPointCloudFileFilters;
     665                 :            : 
     666                 :            :     /**
     667                 :            :      * Available database drivers string for vector databases
     668                 :            :      *
     669                 :            :      * This is a string of form:
     670                 :            :      * DriverNameToShow,DriverName;DriverNameToShow,DriverName;...
     671                 :            :      */
     672                 :            :     QString mDatabaseDrivers;
     673                 :            : 
     674                 :            :     /**
     675                 :            :      * Available directory drivers string for vector databases
     676                 :            :      * This is a string of form:
     677                 :            :      * DriverNameToShow,DriverName;DriverNameToShow,DriverName;...
     678                 :            :      */
     679                 :            :     QString mDirectoryDrivers;
     680                 :            : 
     681                 :            :     /**
     682                 :            :      * Available protocol drivers string for vector databases
     683                 :            :      *
     684                 :            :      * This is a string of form:
     685                 :            :      * DriverNameToShow,DriverName;DriverNameToShow,DriverName;...
     686                 :            :      */
     687                 :            :     QString mProtocolDrivers;
     688                 :            : 
     689                 :            :     QList< UnusableUriHandlerInterface * > mUnusableUriHandlers;
     690                 :            : 
     691                 :            :     /**
     692                 :            :      * Returns TRUE if registry instance exists.
     693                 :            :      */
     694                 :            :     static bool exists();
     695                 :            : 
     696                 :            :     friend class QgsApplication;
     697                 :            : 
     698                 :            : }; // class QgsProviderRegistry
     699                 :            : 
     700                 :            : #endif //QGSPROVIDERREGISTRY_H
     701                 :            : 

Generated by: LCOV version 1.14