QGIS API Documentation 4.0.0-Norrköping (1ddcee3d0e4)
Loading...
Searching...
No Matches
qgsrunnableprovidercreator.cpp
Go to the documentation of this file.
1/***************************************************************************
2 qgsrunnableprovidercreator.cpp - QgsRunnableProviderCreator
3
4 ---------------------
5 begin : 20.3.2023
6 copyright : (C) 2023 by Vincent Cloarec
7 email : vcloarec at gmail dot com
8 ***************************************************************************
9 * *
10 * This program is free software; you can redistribute it and/or modify *
11 * it under the terms of the GNU General Public License as published by *
12 * the Free Software Foundation; either version 2 of the License, or *
13 * (at your option) any later version. *
14 * *
15 ***************************************************************************/
17
18#include "qgsproviderregistry.h"
19#include "qgsruntimeprofiler.h"
20
21#include <QDebug>
22#include <QString>
23#include <QThread>
24
25#include "moc_qgsrunnableprovidercreator.cpp"
26
27using namespace Qt::StringLiterals;
28
30 const QString &layerId, const QString &providerKey, const QString &dataSource, const QgsDataProvider::ProviderOptions &options, Qgis::DataProviderReadFlags flags
31)
32 : mLayerId( layerId )
33 , mProviderKey( providerKey )
34 , mDataSource( dataSource )
35 , mOptions( options )
36 , mFlags( flags )
37{
38 setAutoDelete( false );
39}
40
42{
43 // should use thread-local profiler
44 QgsScopedRuntimeProfile profile( "Create data providers/" + mLayerId, u"projectload"_s );
45 mDataProvider.reset( QgsProviderRegistry::instance()->createProvider( mProviderKey, mDataSource, mOptions, mFlags ) );
46 mDataProvider->moveToThread( QObject::thread() );
47 emit providerCreated( mDataProvider->isValid(), mLayerId );
48}
49
51{
52 return mDataProvider.release();
53}
QFlags< DataProviderReadFlag > DataProviderReadFlags
Flags which control data provider construction.
Definition qgis.h:512
Abstract base class for spatial data provider implementations.
static QgsProviderRegistry * instance(const QString &pluginPath=QString())
Means of accessing canonical single instance.
void providerCreated(bool isValid, const QString &layerId)
Emitted when a provider is created with isValid set to True when the provider is valid.
QgsRunnableProviderCreator(const QString &layerId, QString const &providerKey, QString const &dataSource, const QgsDataProvider::ProviderOptions &options, Qgis::DataProviderReadFlags flags)
Constructor.
QgsDataProvider * dataProvider()
Returns the created data provider.
Scoped object for logging of the runtime for a single operation or group of operations.
Setting options for creating vector data providers.