QGIS API Documentation  3.6.0-Noosa (5873452)
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 
22 {
23  // populate with default implementations
24  addProvider( new QgsLayerTreeOpacityWidget::Provider() );
25 }
26 
28 {
30  {
31  removeProvider( provider->id() );
32  }
33 }
34 
36 {
37  return mProviders.keys();
38 }
39 
41 {
42  return mProviders.value( providerId );
43 }
44 
46 {
47  if ( mProviders.contains( provider->id() ) )
48  return false;
49 
50  mProviders.insert( provider->id(), provider );
51  return true;
52 }
53 
54 bool QgsLayerTreeEmbeddedWidgetRegistry::removeProvider( const QString &providerId )
55 {
56  if ( !mProviders.contains( providerId ) )
57  return false;
58 
59  delete mProviders.take( providerId );
60  return true;
61 }
bool addProvider(QgsLayerTreeEmbeddedWidgetProvider *provider)
Register a provider, takes ownership of the object.
virtual QString id() const =0
Unique name of the provider (among other providers)
QMap< QString, QgsLayerTreeEmbeddedWidgetProvider * > mProviders
storage of all the providers
Provider interface to be implemented in order to introduce new kinds of embedded widgets for use in l...
QStringList providers() const
Returns list of all registered providers.
bool removeProvider(const QString &providerId)
Unregister a provider, the provider object is deleted.
QgsLayerTreeEmbeddedWidgetProvider * provider(const QString &providerId) const
Gets provider object from the provider&#39;s ID.
QgsLayerTreeEmbeddedWidgetRegistry()
Constructor for QgsLayerTreeEmbeddedWidgetRegistry/.