QGIS API Documentation
2.18.21-Las Palmas (9fba24a)
src
gui
layertree
qgslayertreeembeddedwidgetregistry.cpp
Go to the documentation of this file.
1
/***************************************************************************
2
qgslayertreeembeddedwidgetregistry.cpp
3
--------------------------------------
4
Date : May 2016
5
Copyright : (C) 2016 by Martin Dobias
6
Email : wonder dot sk at gmail dot com
7
***************************************************************************
8
* *
9
* This program is free software; you can redistribute it and/or modify *
10
* it under the terms of the GNU General Public License as published by *
11
* the Free Software Foundation; either version 2 of the License, or *
12
* (at your option) any later version. *
13
* *
14
***************************************************************************/
15
16
#include "
qgslayertreeembeddedwidgetregistry.h
"
17
18
#include "
qgslayertreeembeddedwidgetsimpl.h
"
19
20
21
22
QgsLayerTreeEmbeddedWidgetRegistry
*
QgsLayerTreeEmbeddedWidgetRegistry::instance
()
23
{
24
static
QgsLayerTreeEmbeddedWidgetRegistry
* sInstance(
new
QgsLayerTreeEmbeddedWidgetRegistry
() );
25
return
sInstance;
26
}
27
28
QgsLayerTreeEmbeddedWidgetRegistry::QgsLayerTreeEmbeddedWidgetRegistry
()
29
{
30
// populate with default implementations
31
addProvider
(
new
QgsLayerTreeTransparencyWidget::Provider() );
32
}
33
34
QgsLayerTreeEmbeddedWidgetRegistry::~QgsLayerTreeEmbeddedWidgetRegistry
()
35
{
36
Q_FOREACH (
QgsLayerTreeEmbeddedWidgetProvider
*
provider
,
mProviders
)
37
{
38
removeProvider
( provider->
id
() );
39
}
40
}
41
42
QStringList
QgsLayerTreeEmbeddedWidgetRegistry::providers
()
const
43
{
44
return
mProviders
.
keys
();
45
}
46
47
QgsLayerTreeEmbeddedWidgetProvider
*
QgsLayerTreeEmbeddedWidgetRegistry::provider
(
const
QString
& providerId )
const
48
{
49
return
mProviders
.
value
( providerId );
50
}
51
52
bool
QgsLayerTreeEmbeddedWidgetRegistry::addProvider
(
QgsLayerTreeEmbeddedWidgetProvider
*
provider
)
53
{
54
if
(
mProviders
.
contains
( provider->
id
() ) )
55
return
false
;
56
57
mProviders
.
insert
( provider->
id
(),
provider
);
58
return
true
;
59
}
60
61
bool
QgsLayerTreeEmbeddedWidgetRegistry::removeProvider
(
const
QString
& providerId )
62
{
63
if
( !
mProviders
.
contains
( providerId ) )
64
return
false
;
65
66
delete
mProviders
.
take
( providerId );
67
return
true
;
68
}
QgsLayerTreeEmbeddedWidgetRegistry::mProviders
QMap< QString, QgsLayerTreeEmbeddedWidgetProvider * > mProviders
storage of all the providers
Definition:
qgslayertreeembeddedwidgetregistry.h:89
QgsLayerTreeEmbeddedWidgetRegistry::addProvider
bool addProvider(QgsLayerTreeEmbeddedWidgetProvider *provider)
Register a provider, takes ownership of the object.
Definition:
qgslayertreeembeddedwidgetregistry.cpp:52
QgsLayerTreeEmbeddedWidgetRegistry::~QgsLayerTreeEmbeddedWidgetRegistry
~QgsLayerTreeEmbeddedWidgetRegistry()
Definition:
qgslayertreeembeddedwidgetregistry.cpp:34
QMap::contains
bool contains(const Key &key) const
QgsLayerTreeEmbeddedWidgetProvider::id
virtual QString id() const =0
Unique name of the provider (among other providers)
qgslayertreeembeddedwidgetsimpl.h
QMap::keys
QList< Key > keys() const
QgsLayerTreeEmbeddedWidgetProvider
Provider interface to be implemented in order to introduce new kinds of embedded widgets for use in l...
Definition:
qgslayertreeembeddedwidgetregistry.h:32
QgsLayerTreeEmbeddedWidgetRegistry::providers
QStringList providers() const
Return list of all registered providers.
Definition:
qgslayertreeembeddedwidgetregistry.cpp:42
QString
QgsLayerTreeEmbeddedWidgetRegistry
Registry of widgets that may be embedded into layer tree view.
Definition:
qgslayertreeembeddedwidgetregistry.h:61
QStringList
QgsLayerTreeEmbeddedWidgetRegistry::removeProvider
bool removeProvider(const QString &providerId)
Unregister a provider, the provider object is deleted.
Definition:
qgslayertreeembeddedwidgetregistry.cpp:61
QgsLayerTreeEmbeddedWidgetRegistry::instance
static QgsLayerTreeEmbeddedWidgetRegistry * instance()
Means of accessing canonical single instance.
Definition:
qgslayertreeembeddedwidgetregistry.cpp:22
qgslayertreeembeddedwidgetregistry.h
QMap::insert
iterator insert(const Key &key, const T &value)
QgsLayerTreeEmbeddedWidgetRegistry::provider
QgsLayerTreeEmbeddedWidgetProvider * provider(const QString &providerId) const
Get provider object from the provider's ID.
Definition:
qgslayertreeembeddedwidgetregistry.cpp:47
QMap::take
T take(const Key &key)
QMap::value
const T value(const Key &key) const
QgsLayerTreeEmbeddedWidgetRegistry::QgsLayerTreeEmbeddedWidgetRegistry
QgsLayerTreeEmbeddedWidgetRegistry()
Protected constructor - use instance() to access the registry.
Definition:
qgslayertreeembeddedwidgetregistry.cpp:28
Generated on Sun Jun 24 2018 11:42:48 for QGIS API Documentation by
1.8.13