QGIS API Documentation
3.41.0-Master (57ec4277f5e)
Loading...
Searching...
No Matches
src
gui
settings
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 :
[email protected]
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
16
#include "
qgssettingseditorwidgetregistry.h
"
17
18
#include "
qgis.h
"
19
#include "
qgslogger.h
"
20
#include "
qgssettingseditorwidgetwrapper.h
"
21
#include "
qgssettingseditorwidgetwrapperimpl.h
"
22
#include "
qgssettingsenumflageditorwidgetwrapper.h
"
23
#include "
qgssettingsentry.h
"
24
25
#if defined( HAVE_QTSERIALPORT )
26
#include <QSerialPort>
27
#endif
28
29
30
QgsSettingsEditorWidgetRegistry::QgsSettingsEditorWidgetRegistry
()
31
{
32
addWrapper
(
new
QgsSettingsStringLineEditWrapper
() );
33
addWrapper
(
new
QgsSettingsBoolCheckBoxWrapper
() );
34
addWrapper
(
new
QgsSettingsIntegerSpinBoxWrapper
() );
35
addWrapper
(
new
QgsSettingsDoubleSpinBoxWrapper
() );
36
addWrapper
(
new
QgsSettingsColorButtonWrapper
() );
37
38
// enum
39
#if defined( HAVE_QTSERIALPORT )
40
addWrapper
(
new
QgsSettingsEnumEditorWidgetWrapper<QSerialPort::DataBits>
() );
41
addWrapper
(
new
QgsSettingsEnumEditorWidgetWrapper<QSerialPort::FlowControl>
() );
42
addWrapper
(
new
QgsSettingsEnumEditorWidgetWrapper<QSerialPort::Parity>
() );
43
addWrapper
(
new
QgsSettingsEnumEditorWidgetWrapper<QSerialPort::StopBits>
() );
44
#endif
45
addWrapper
(
new
QgsSettingsEnumEditorWidgetWrapper<Qgis::CaptureTechnique>
() );
46
addWrapper
(
new
QgsSettingsEnumEditorWidgetWrapper<Qgis::DpiMode>
() );
47
addWrapper
(
new
QgsSettingsEnumEditorWidgetWrapper<Qgis::EndCapStyle>
() );
48
addWrapper
(
new
QgsSettingsEnumEditorWidgetWrapper<Qgis::GpsConnectionType>
() );
49
addWrapper
(
new
QgsSettingsEnumEditorWidgetWrapper<Qgis::GpsInformationComponent>
() );
50
addWrapper
(
new
QgsSettingsEnumEditorWidgetWrapper<Qgis::JoinStyle>
() );
51
addWrapper
(
new
QgsSettingsEnumEditorWidgetWrapper<Qgis::MapRecenteringMode>
() );
52
addWrapper
(
new
QgsSettingsEnumEditorWidgetWrapper<Qgis::MapToolUnit>
() );
53
addWrapper
(
new
QgsSettingsEnumEditorWidgetWrapper<Qgis::SnappingMode>
() );
54
addWrapper
(
new
QgsSettingsEnumEditorWidgetWrapper<Qgis::SnappingType>
() );
55
addWrapper
(
new
QgsSettingsEnumEditorWidgetWrapper<Qgis::TilePixelRatio>
() );
56
57
addWrapper
(
new
QgsSettingsEnumEditorWidgetWrapper<Qgis::VectorSimplificationAlgorithm>
() );
58
addWrapper
(
new
QgsSettingsEnumEditorWidgetWrapper<Qgis::VectorRenderingSimplificationFlags>
() );
59
addWrapper
(
new
QgsSettingsEnumEditorWidgetWrapper<Qt::TimeSpec>
() );
60
61
// flags
62
addWrapper
(
new
QgsSettingsFlagsEditorWidgetWrapper<Qgis::GpsInformationComponent, Qgis::GpsInformationComponents>
() );
63
}
64
65
QgsSettingsEditorWidgetRegistry::~QgsSettingsEditorWidgetRegistry
()
66
{
67
qDeleteAll( mWrappers );
68
}
69
70
bool
QgsSettingsEditorWidgetRegistry::addWrapper
(
QgsSettingsEditorWidgetWrapper
*wrapper )
71
{
72
if
( mWrappers.contains( wrapper->
id
() ) )
73
{
74
QgsDebugMsgLevel
( QString(
"Settings editor widget registry already contains a wrapper with id '%1'"
).arg( wrapper->
id
() ), 2 );
75
delete
wrapper;
76
return
false
;
77
}
78
79
mWrappers.insert( wrapper->
id
(), wrapper );
80
return
true
;
81
}
82
83
void
QgsSettingsEditorWidgetRegistry::addWrapperForSetting
(
QgsSettingsEditorWidgetWrapper
*wrapper,
const
QgsSettingsEntryBase
*setting )
84
{
85
mSpecificWrappers.insert( setting, wrapper );
86
}
87
88
QgsSettingsEditorWidgetWrapper
*
QgsSettingsEditorWidgetRegistry::createWrapper
(
const
QString &
id
, QObject *parent )
const
89
{
90
QgsSettingsEditorWidgetWrapper
*wrapper = mWrappers.value(
id
);
91
if
( wrapper )
92
{
93
return
wrapper->
createWrapper
( parent );
94
}
95
else
96
{
97
QgsDebugError
( QStringLiteral(
"Setting factory was not found for '%1', returning the default string factory"
).arg(
id
) );
98
return
nullptr
;
99
}
100
}
101
102
QWidget *
QgsSettingsEditorWidgetRegistry::createEditor
(
const
QgsSettingsEntryBase
*setting,
const
QStringList &dynamicKeyPartList, QWidget *parent )
const
103
{
104
if
( mSpecificWrappers.contains( setting ) )
105
{
106
return
mSpecificWrappers.value( setting )->createEditor( setting, dynamicKeyPartList, parent );
107
}
108
QgsSettingsEditorWidgetWrapper
*eww =
createWrapper
( setting->
typeId
(), parent );
109
if
( eww )
110
return
eww->
createEditor
( setting, dynamicKeyPartList, parent );
111
else
112
return
nullptr
;
113
}
QgsSettingsBoolCheckBoxWrapper
This class is a factory of editor for boolean settings with a checkbox.
Definition
qgssettingseditorwidgetwrapperimpl.h:205
QgsSettingsColorButtonWrapper
This class is a factory of editor for color settings with a color button.
Definition
qgssettingseditorwidgetwrapperimpl.h:300
QgsSettingsDoubleSpinBoxWrapper
This class is a factory of editor for double settings with a double spin box.
Definition
qgssettingseditorwidgetwrapperimpl.h:268
QgsSettingsEditorWidgetRegistry::QgsSettingsEditorWidgetRegistry
QgsSettingsEditorWidgetRegistry()
Constructor.
Definition
qgssettingseditorwidgetregistry.cpp:30
QgsSettingsEditorWidgetRegistry::addWrapperForSetting
void addWrapperForSetting(QgsSettingsEditorWidgetWrapper *wrapper, const QgsSettingsEntryBase *setting)
Adds an editor widget wrapper for a specific setting to the registry.
Definition
qgssettingseditorwidgetregistry.cpp:83
QgsSettingsEditorWidgetRegistry::createEditor
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.
Definition
qgssettingseditorwidgetregistry.cpp:102
QgsSettingsEditorWidgetRegistry::addWrapper
bool addWrapper(QgsSettingsEditorWidgetWrapper *wrapper)
Adds an editor widget wrapper to the registry If an editor widget with same id already exists,...
Definition
qgssettingseditorwidgetregistry.cpp:70
QgsSettingsEditorWidgetRegistry::createWrapper
QgsSettingsEditorWidgetWrapper * createWrapper(const QString &id, QObject *parent) const
Returns a new instance of the editor widget for the given id.
Definition
qgssettingseditorwidgetregistry.cpp:88
QgsSettingsEditorWidgetRegistry::~QgsSettingsEditorWidgetRegistry
~QgsSettingsEditorWidgetRegistry()
Definition
qgssettingseditorwidgetregistry.cpp:65
QgsSettingsEditorWidgetWrapper
Base class for settings editor wrappers.
Definition
qgssettingseditorwidgetwrapper.h:35
QgsSettingsEditorWidgetWrapper::createWrapper
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.
QgsSettingsEditorWidgetWrapper::createEditor
QWidget * createEditor(const QgsSettingsEntryBase *setting, const QStringList &dynamicKeyPartList=QStringList(), QWidget *parent=nullptr)
Creates the editor widget for the given setting.
Definition
qgssettingseditorwidgetwrapper.cpp:43
QgsSettingsEditorWidgetWrapper::id
virtual QString id() const =0
This id of the type of settings it handles.
QgsSettingsEntryBase
Represent settings entry and provides methods for reading and writing settings values.
Definition
qgssettingsentry.h:45
QgsSettingsEntryBase::typeId
virtual QString typeId() const
Returns the id of the type of settings This can be re-implemented in a custom implementation of a set...
Definition
qgssettingsentry.cpp:47
QgsSettingsEnumEditorWidgetWrapper
This class is a factory of editor for enum settings.
Definition
qgssettingsenumflageditorwidgetwrapper.h:147
QgsSettingsFlagsEditorWidgetWrapper
This class is a factory of editor for flags settings.
Definition
qgssettingsenumflageditorwidgetwrapper.h:39
QgsSettingsIntegerSpinBoxWrapper
This class is a factory of editor for integer settings with a spin box.
Definition
qgssettingseditorwidgetwrapperimpl.h:236
QgsSettingsStringLineEditWrapper
This class is a factory of editor for string settings with a line edit.
Definition
qgssettingseditorwidgetwrapperimpl.h:126
qgis.h
qgslogger.h
QgsDebugMsgLevel
#define QgsDebugMsgLevel(str, level)
Definition
qgslogger.h:39
QgsDebugError
#define QgsDebugError(str)
Definition
qgslogger.h:38
qgssettingseditorwidgetregistry.h
qgssettingseditorwidgetwrapper.h
qgssettingseditorwidgetwrapperimpl.h
qgssettingsentry.h
qgssettingsenumflageditorwidgetwrapper.h
Generated on Sun Dec 29 2024 04:59:01 for QGIS API Documentation by
1.9.8