QGIS API Documentation  3.22.4-Białowieża (ce8e65e95e)
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 {
29  const auto constMProviders = mProviders;
30  for ( QgsLayerTreeEmbeddedWidgetProvider *provider : constMProviders )
31  {
33  }
34 }
35 
37 {
38  return mProviders.keys();
39 }
40 
42 {
43  return mProviders.value( providerId );
44 }
45 
47 {
48  if ( mProviders.contains( provider->id() ) )
49  return false;
50 
51  mProviders.insert( provider->id(), provider );
52  return true;
53 }
54 
55 bool QgsLayerTreeEmbeddedWidgetRegistry::removeProvider( const QString &providerId )
56 {
57  if ( !mProviders.contains( providerId ) )
58  return false;
59 
60  delete mProviders.take( providerId );
61  return true;
62 }
Provider interface to be implemented in order to introduce new kinds of embedded widgets for use in l...
virtual QString id() const =0
Unique name of the provider (among other providers)
QStringList providers() const
Returns list of all registered providers.
bool addProvider(QgsLayerTreeEmbeddedWidgetProvider *provider)
Register a provider, takes ownership of the object.
bool removeProvider(const QString &providerId)
Unregister a provider, the provider object is deleted.
QMap< QString, QgsLayerTreeEmbeddedWidgetProvider * > mProviders
storage of all the providers
QgsLayerTreeEmbeddedWidgetProvider * provider(const QString &providerId) const
Gets provider object from the provider's ID.
QgsLayerTreeEmbeddedWidgetRegistry()
Constructor for QgsLayerTreeEmbeddedWidgetRegistry/.