QGIS API Documentation 3.38.0-Grenoble (exported)
Loading...
Searching...
No Matches
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
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 "qgis.h"
19#include "qgslogger.h"
23#include "qgssettingsentry.h"
24
25#if defined( HAVE_QTSERIALPORT )
26#include <QSerialPort>
27#endif
28
29
31{
37
38 // enum
39#if defined( HAVE_QTSERIALPORT )
44#endif
56
60
61 // flags
63
64}
65
70
72{
73 if ( mWrappers.contains( wrapper->id() ) )
74 {
75 QgsDebugMsgLevel( QString( "Settings editor widget registry already contains a wrapper with id '%1'" ).arg( wrapper->id() ), 2 );
76 delete wrapper;
77 return false;
78 }
79
80 mWrappers.insert( wrapper->id(), wrapper );
81 return true;
82}
83
85{
86 QgsSettingsEditorWidgetWrapper *wrapper = mWrappers.value( id );
87 if ( wrapper )
88 {
89 return wrapper->createWrapper( parent );
90 }
91 else
92 {
93 QgsDebugError( QStringLiteral( "Setting factory was not found for '%1', returning the default string factory" ).arg( id ) );
94 return nullptr;
95 }
96}
97
98QWidget *QgsSettingsEditorWidgetRegistry::createEditor( const QgsSettingsEntryBase *setting, const QStringList &dynamicKeyPartList, QWidget *parent ) const
99{
100 QgsSettingsEditorWidgetWrapper *eww = createWrapper( setting->typeId(), parent );
101 if ( eww )
102 return eww->createEditor( setting, dynamicKeyPartList, parent );
103 else
104 return nullptr;
105}
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 If an editor widget with same id already exists,...
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 enum settings.
This class is a factory of editor for flags settings.
This class is a factory of editor for integer settings.
This class is a factory of editor for string settings.
#define QgsDebugMsgLevel(str, level)
Definition qgslogger.h:39
#define QgsDebugError(str)
Definition qgslogger.h:38