QGIS API Documentation 3.34.0-Prizren (ffbdd678812)
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 <QDebug>
19#include <QThread>
20
21#include "qgsproviderregistry.h"
22#include "qgsruntimeprofiler.h"
23
24QgsRunnableProviderCreator::QgsRunnableProviderCreator( const QString &layerId, const QString &providerKey, const QString &dataSource, const QgsDataProvider::ProviderOptions &options, QgsDataProvider::ReadFlags flags )
25 : mLayerId( layerId )
26 , mProviderKey( providerKey )
27 , mDataSource( dataSource )
28 , mOptions( options )
29 , mFlags( flags )
30{
31 setAutoDelete( false );
32}
33
35{
36 // should use thread-local profiler
37 QgsScopedRuntimeProfile profile( "Create data providers/" + mLayerId, QStringLiteral( "projectload" ) );
38 mDataProvider.reset( QgsProviderRegistry::instance()->createProvider( mProviderKey, mDataSource, mOptions, mFlags ) );
39 mDataProvider->moveToThread( QObject::thread() );
40 emit providerCreated( mDataProvider->isValid(), mLayerId );
41}
42
44{
45 return mDataProvider.release();
46}
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, QgsDataProvider::ReadFlags 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.