QGIS API Documentation 3.41.0-Master (af5edcb665c)
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#include "moc_qgsrunnableprovidercreator.cpp"
18
19#include <QDebug>
20#include <QThread>
21
22#include "qgsproviderregistry.h"
23#include "qgsruntimeprofiler.h"
24
25QgsRunnableProviderCreator::QgsRunnableProviderCreator( const QString &layerId, const QString &providerKey, const QString &dataSource, const QgsDataProvider::ProviderOptions &options, Qgis::DataProviderReadFlags flags )
26 : mLayerId( layerId )
27 , mProviderKey( providerKey )
28 , mDataSource( dataSource )
29 , mOptions( options )
30 , mFlags( flags )
31{
32 setAutoDelete( false );
33}
34
36{
37 // should use thread-local profiler
38 QgsScopedRuntimeProfile profile( "Create data providers/" + mLayerId, QStringLiteral( "projectload" ) );
39 mDataProvider.reset( QgsProviderRegistry::instance()->createProvider( mProviderKey, mDataSource, mOptions, mFlags ) );
40 mDataProvider->moveToThread( QObject::thread() );
41 emit providerCreated( mDataProvider->isValid(), mLayerId );
42}
43
45{
46 return mDataProvider.release();
47}
QFlags< DataProviderReadFlag > DataProviderReadFlags
Flags which control data provider construction.
Definition qgis.h:450
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.