QGIS API Documentation 3.32.0-Lima (311a8cb8a6)
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
qgssettingseditorwidgetregistry.cpp
Go to the documentation of this file.
1/***************************************************************************
2 qgssettingseditorwidgetregistry.cpp
3 ---------------------
4 begin : April 2023
5 copyright : (C) 2023 by Denis Rouzaud
6 email : denis@opengis.ch
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
18#include "qgslogger.h"
21#include "qgssettingsentry.h"
22
24{
30
31}
32
34{
35 qDeleteAll( mWrappers );
36}
37
39{
40 if ( mWrappers.contains( wrapper->id() ) )
41 return false;
42
43 mWrappers.insert( wrapper->id(), wrapper );
44 return true;
45}
46
48{
49 QgsSettingsEditorWidgetWrapper *wrapper = mWrappers.value( id );
50 if ( wrapper )
51 {
52 return wrapper->createWrapper( parent );
53 }
54 else
55 {
56 QgsDebugError( QStringLiteral( "Setting factory was not found for '%1', returning the default string factory" ).arg( id ) );
57 return nullptr;
58 }
59}
60
61QWidget *QgsSettingsEditorWidgetRegistry::createEditor( const QgsSettingsEntryBase *setting, const QStringList &dynamicKeyPartList, QWidget *parent ) const
62{
63 QgsSettingsEditorWidgetWrapper *eww = createWrapper( setting->typeId(), parent );
64 if ( eww )
65 return eww->createEditor( setting, dynamicKeyPartList, parent );
66 else
67 return nullptr;
68}
This class is a factory of editor for boolean settings.
This class is a factory of editor for color settings.
This class is a factory of editor for double settings.
QWidget * createEditor(const QgsSettingsEntryBase *setting, const QStringList &dynamicKeyPartList, QWidget *parent=nullptr) const
Creates an editor widget for the given setting using the corresponding registered wrapper.
bool addWrapper(QgsSettingsEditorWidgetWrapper *wrapper)
Adds an editor widget wrapper to the registry Returns false if an editor widget with same id already ...
QgsSettingsEditorWidgetWrapper * createWrapper(const QString &id, QObject *parent) const
Returns a new instance of the editor widget for the given id.
Base class for settings editor wrappers.
virtual QgsSettingsEditorWidgetWrapper * createWrapper(QObject *parent=nullptr) const =0
Creates a new instance of the editor wrapper so it can be configured for a widget and a setting.
QWidget * createEditor(const QgsSettingsEntryBase *setting, const QStringList &dynamicKeyPartList=QStringList(), QWidget *parent=nullptr)
Creates the editor widget for the given setting.
virtual QString id() const =0
This id of the type of settings it handles.
Represent settings entry and provides methods for reading and writing settings values.
virtual QString typeId() const
Returns the id of the type of settings This can be re-implemented in a custom implementation of a set...
This class is a factory of editor for integer settings.
This class is a factory of editor for string settings.
#define QgsDebugError(str)
Definition: qgslogger.h:38