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