QGIS API Documentation 3.99.0-Master (26c88405ac0)
Loading...
Searching...
No Matches
qgsprojectstorageguiregistry.cpp
Go to the documentation of this file.
1/***************************************************************************
2 qgsprojectstorageguiregistry.cpp
3 -------------------
4 begin : June 2019
5 copyright : (C) 2019 by Peter Petrik
6 email : zilolv at google dot com
7 ***************************************************************************/
8
9/***************************************************************************
10 * *
11 * This program is free software; you can redistribute it and/or modify *
12 * it under the terms of the GNU General Public License as published by *
13 * the Free Software Foundation; either version 2 of the License, or *
14 * (at your option) any later version. *
15 * *
16 ***************************************************************************/
17
19
22
24
29
31{
32 return mBackends.value( type, nullptr );
33}
34
36{
37 for ( auto it = mBackends.constBegin(); it != mBackends.constEnd(); ++it )
38 {
39 QgsProjectStorageGuiProvider *storage = it.value();
40 const QString scheme = storage->type() + ':';
41 if ( uri.startsWith( scheme ) )
42 return storage;
43 }
44 return nullptr;
45}
46
47QList<QgsProjectStorageGuiProvider *> QgsProjectStorageGuiRegistry::projectStorages() const
48{
49 return mBackends.values();
50}
51
53{
54 mBackends.insert( storage->type(), storage );
55}
56
58{
59 delete mBackends.take( storage->type() );
60}
61
63{
64 if ( !providerGuiRegistry )
65 return;
66
67 const QStringList providersList = providerGuiRegistry->providerList();
68 for ( const QString &key : providersList )
69 {
70 const QList<QgsProjectStorageGuiProvider *> providerList = providerGuiRegistry->projectStorageGuiProviders( key );
71 // the function is a factory - we keep ownership of the returned providers
72 for ( QgsProjectStorageGuiProvider *provider : providerList )
73 {
74 mBackends[key] = provider;
75 }
76 }
77}
Abstract interface for project storage GUI - to be implemented by various backends and registered in ...
virtual QString type()=0
Unique identifier of the project storage type.
QgsProjectStorageGuiProvider * projectStorageFromType(const QString &type)
Returns storage implementation if the storage type matches one. Returns nullptr otherwise (it is a no...
void unregisterProjectStorage(QgsProjectStorageGuiProvider *storage)
Unregisters a storage backend and destroys its instance.
QList< QgsProjectStorageGuiProvider * > projectStorages() const
Returns a list of registered project storage implementations.
void registerProjectStorage(QgsProjectStorageGuiProvider *storage)
Registers a storage backend and takes ownership of it.
void initializeFromProviderGuiRegistry(QgsProviderGuiRegistry *providerGuiRegistry)
Initializes the registry.
QgsProjectStorageGuiProvider * projectStorageFromUri(const QString &uri)
Returns storage implementation if the URI matches one. Returns nullptr otherwise (it is a normal file...
A registry / canonical manager of GUI parts of data providers.
virtual QList< QgsProjectStorageGuiProvider * > projectStorageGuiProviders(const QString &providerKey)
Returns all project storage gui providers registered in provider with providerKey.
QStringList providerList() const
Returns list of available providers by their keys.