QGIS API Documentation  2.18.21-Las Palmas (9fba24a)
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 
17 
19 
20 
21 
23 {
25  return sInstance;
26 }
27 
29 {
30  // populate with default implementations
31  addProvider( new QgsLayerTreeTransparencyWidget::Provider() );
32 }
33 
35 {
37  {
38  removeProvider( provider->id() );
39  }
40 }
41 
43 {
44  return mProviders.keys();
45 }
46 
48 {
49  return mProviders.value( providerId );
50 }
51 
53 {
54  if ( mProviders.contains( provider->id() ) )
55  return false;
56 
57  mProviders.insert( provider->id(), provider );
58  return true;
59 }
60 
62 {
63  if ( !mProviders.contains( providerId ) )
64  return false;
65 
66  delete mProviders.take( providerId );
67  return true;
68 }
QMap< QString, QgsLayerTreeEmbeddedWidgetProvider * > mProviders
storage of all the providers
bool addProvider(QgsLayerTreeEmbeddedWidgetProvider *provider)
Register a provider, takes ownership of the object.
bool contains(const Key &key) const
virtual QString id() const =0
Unique name of the provider (among other providers)
QList< Key > keys() const
Provider interface to be implemented in order to introduce new kinds of embedded widgets for use in l...
QStringList providers() const
Return list of all registered providers.
Registry of widgets that may be embedded into layer tree view.
bool removeProvider(const QString &providerId)
Unregister a provider, the provider object is deleted.
static QgsLayerTreeEmbeddedWidgetRegistry * instance()
Means of accessing canonical single instance.
iterator insert(const Key &key, const T &value)
QgsLayerTreeEmbeddedWidgetProvider * provider(const QString &providerId) const
Get provider object from the provider&#39;s ID.
T take(const Key &key)
const T value(const Key &key) const
QgsLayerTreeEmbeddedWidgetRegistry()
Protected constructor - use instance() to access the registry.