QGIS API Documentation
4.3.0-Master (52aa6503bed)
Toggle main menu visibility
Loading...
Searching...
No Matches
src
gui
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
18
#include "
qgsprojectstorageguiregistry.h
"
19
20
#include "
qgsprojectstorageguiprovider.h
"
21
#include "
qgsproviderguiregistry.h
"
22
23
QgsProjectStorageGuiRegistry::QgsProjectStorageGuiRegistry
() =
default
;
24
25
QgsProjectStorageGuiRegistry::~QgsProjectStorageGuiRegistry
()
26
{
27
qDeleteAll( mBackends );
28
}
29
30
QgsProjectStorageGuiProvider
*
QgsProjectStorageGuiRegistry::projectStorageFromType
(
const
QString &type )
31
{
32
return
mBackends.value( type,
nullptr
);
33
}
34
35
QgsProjectStorageGuiProvider
*
QgsProjectStorageGuiRegistry::projectStorageFromUri
(
const
QString &uri )
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
47
QList<QgsProjectStorageGuiProvider *>
QgsProjectStorageGuiRegistry::projectStorages
()
const
48
{
49
return
mBackends.values();
50
}
51
52
void
QgsProjectStorageGuiRegistry::registerProjectStorage
(
QgsProjectStorageGuiProvider
*storage )
53
{
54
mBackends.insert( storage->
type
(), storage );
55
}
56
57
void
QgsProjectStorageGuiRegistry::unregisterProjectStorage
(
QgsProjectStorageGuiProvider
*storage )
58
{
59
delete
mBackends.take( storage->
type
() );
60
}
61
62
void
QgsProjectStorageGuiRegistry::initializeFromProviderGuiRegistry
(
QgsProviderGuiRegistry
*providerGuiRegistry )
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
}
QgsProjectStorageGuiProvider
Abstract interface for project storage GUI - to be implemented by various backends and registered in ...
Definition
qgsprojectstorageguiprovider.h:32
QgsProjectStorageGuiProvider::type
virtual QString type()=0
Unique identifier of the project storage type.
QgsProjectStorageGuiRegistry::~QgsProjectStorageGuiRegistry
~QgsProjectStorageGuiRegistry()
Definition
qgsprojectstorageguiregistry.cpp:25
QgsProjectStorageGuiRegistry::projectStorageFromType
QgsProjectStorageGuiProvider * projectStorageFromType(const QString &type)
Returns storage implementation if the storage type matches one. Returns nullptr otherwise (it is a no...
Definition
qgsprojectstorageguiregistry.cpp:30
QgsProjectStorageGuiRegistry::unregisterProjectStorage
void unregisterProjectStorage(QgsProjectStorageGuiProvider *storage)
Unregisters a storage backend and destroys its instance.
Definition
qgsprojectstorageguiregistry.cpp:57
QgsProjectStorageGuiRegistry::projectStorages
QList< QgsProjectStorageGuiProvider * > projectStorages() const
Returns a list of registered project storage implementations.
Definition
qgsprojectstorageguiregistry.cpp:47
QgsProjectStorageGuiRegistry::registerProjectStorage
void registerProjectStorage(QgsProjectStorageGuiProvider *storage)
Registers a storage backend and takes ownership of it.
Definition
qgsprojectstorageguiregistry.cpp:52
QgsProjectStorageGuiRegistry::initializeFromProviderGuiRegistry
void initializeFromProviderGuiRegistry(QgsProviderGuiRegistry *providerGuiRegistry)
Initializes the registry.
Definition
qgsprojectstorageguiregistry.cpp:62
QgsProjectStorageGuiRegistry::projectStorageFromUri
QgsProjectStorageGuiProvider * projectStorageFromUri(const QString &uri)
Returns storage implementation if the URI matches one. Returns nullptr otherwise (it is a normal file...
Definition
qgsprojectstorageguiregistry.cpp:35
QgsProjectStorageGuiRegistry::QgsProjectStorageGuiRegistry
QgsProjectStorageGuiRegistry()
QgsProviderGuiRegistry
A registry / canonical manager of GUI parts of data providers.
Definition
qgsproviderguiregistry.h:54
QgsProviderGuiRegistry::projectStorageGuiProviders
virtual QList< QgsProjectStorageGuiProvider * > projectStorageGuiProviders(const QString &providerKey)
Returns all project storage gui providers registered in provider with providerKey.
Definition
qgsproviderguiregistry.cpp:260
QgsProviderGuiRegistry::providerList
QStringList providerList() const
Returns list of available providers by their keys.
Definition
qgsproviderguiregistry.cpp:299
qgsprojectstorageguiprovider.h
qgsprojectstorageguiregistry.h
qgsproviderguiregistry.h
Generated on
for QGIS API Documentation by
1.17.0