QGIS API Documentation 3.32.0-Lima (311a8cb8a6)
qgssettingseditorwidgetwrapperimpl.cpp
Go to the documentation of this file.
1/***************************************************************************
2 qgssettingseditorwidgetwrapperimpl.cpp
3 --------------------------------------
4 Date : February 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
16
18#include "qgslogger.h"
20#include "qgscolorbutton.h"
21
22#include <QLineEdit>
23#include <QCheckBox>
24
25
26// *******
27// String
28// *******
29
31{
32 return QString::fromUtf8( sSettingsTypeMetaEnum.valueToKey( static_cast<int>( Qgis::SettingsType::String ) ) );
33}
34
36{
37 if ( mEditor )
38 {
39 mEditor->setText( value );
40 return true;
41 }
42 else
43 {
44 QgsDebugError( QStringLiteral( "Settings editor not set for %1" ).arg( mSetting->definitionKey() ) );
45 }
46 return false;
47}
48
50{
51 if ( mEditor )
52 {
54 return true;
55 }
56 else
57 {
58 QgsDebugError( QStringLiteral( "Settings editor not set for %1" ).arg( mSetting->definitionKey() ) );
59 }
60 return false;
61}
62
64{
65 if ( mEditor )
66 {
67 return mEditor->text();
68 }
69 else
70 {
71 QgsDebugError( QString( "editor is not set, returning a non-existing value" ) );
72 }
73 return QString();
74}
75
76// *******
77// Boolean
78// *******
79
81{
82 return QString::fromUtf8( sSettingsTypeMetaEnum.valueToKey( static_cast<int>( Qgis::SettingsType::Bool ) ) );
83}
84
86{
87 if ( mEditor )
88 {
89 mEditor->setChecked( value );
90 return true;
91 }
92 else
93 {
94 QgsDebugError( QStringLiteral( "Settings editor not set for %1" ).arg( mSetting->definitionKey() ) );
95 }
96 return false;
97}
98
100{
101 if ( mEditor )
102 {
104 return true;
105 }
106 else
107 {
108 QgsDebugError( QStringLiteral( "Settings editor not set for %1" ).arg( mSetting->definitionKey() ) );
109 }
110 return false;
111}
112
114{
115
116 if ( mEditor )
117 {
118 return mEditor->isChecked();
119 }
120 else
121 {
122 QgsDebugError( QString( "editor is not set, returning a non-existing value" ) );
123 }
124 return false;
125}
126
127
128// *******
129// Integer
130// *******
131
133{
134 return QString::fromUtf8( sSettingsTypeMetaEnum.valueToKey( static_cast<int>( Qgis::SettingsType::Integer ) ) );
135}
136
138{
139 if ( mEditor )
140 {
141 mEditor->setValue( value );
142 return true;
143 }
144 else
145 {
146 QgsDebugError( QStringLiteral( "Settings editor not set for %1" ).arg( mSetting->definitionKey() ) );
147 }
148 return false;
149}
150
152{
153 if ( mEditor )
154 {
156 return true;
157 }
158 else
159 {
160 QgsDebugError( QStringLiteral( "Settings editor not set for %1" ).arg( mSetting->definitionKey() ) );
161 }
162 return false;
163}
164
166{
167 if ( mEditor )
168 {
169 return mEditor->value();
170 }
171 else
172 {
173 QgsDebugError( QString( "editor is not set, returning a non-existing value" ) );
174 }
175 return std::numeric_limits<int>::quiet_NaN();
176}
177
178
179
180// *******
181// Double
182// *******
183
185{
186 return QString::fromUtf8( sSettingsTypeMetaEnum.valueToKey( static_cast<int>( Qgis::SettingsType::Double ) ) );
187}
188
190{
191 if ( mEditor )
192 {
193 mEditor->setValue( value );
194 return true;
195 }
196 else
197 {
198 QgsDebugError( QStringLiteral( "Settings editor not set for %1" ).arg( mSetting->definitionKey() ) );
199 }
200 return false;
201}
202
204{
205 if ( mEditor )
206 {
208 return true;
209 }
210 else
211 {
212 QgsDebugError( QStringLiteral( "Settings editor not set for %1" ).arg( mSetting->definitionKey() ) );
213 }
214 return false;
215}
216
218{
219 if ( mEditor )
220 {
221 return mEditor->value();
222 }
223 else
224 {
225 QgsDebugError( QString( "editor is not set, returning a non-existing value" ) );
226 }
227 return std::numeric_limits<double>::quiet_NaN();
228}
229
230// *******
231// Color
232// *******
233
235{
236 return QString::fromUtf8( sSettingsTypeMetaEnum.valueToKey( static_cast<int>( Qgis::SettingsType::Color ) ) );
237}
238
240{
241 if ( mEditor )
242 {
243 mEditor->setColor( value );
244 return true;
245 }
246 else
247 {
248 QgsDebugError( QStringLiteral( "Settings editor not set for %1" ).arg( mSetting->definitionKey() ) );
249 }
250 return false;
251}
252
254{
255 if ( mEditor )
256 {
258 }
259 else
260 {
261 QgsDebugError( QStringLiteral( "Settings editor not set for %1" ).arg( mSetting->definitionKey() ) );
262 }
263}
264
266{
267 if ( mEditor )
268 {
270 return true;
271 }
272 else
273 {
274 QgsDebugError( QStringLiteral( "Settings editor not set for %1" ).arg( mSetting->definitionKey() ) );
275 }
276 return false;
277}
278
280{
281 if ( mEditor )
282 {
283 return mEditor->color();
284 }
285 else
286 {
287 QgsDebugError( QString( "editor is not set, returning a non-existing value" ) );
288 }
289 return QColor();
290}
291
292// *******
293// StringList
294// *******
295
296//QString QgsSettingsStringListEditorWidgetWrapper::id() const
297//{
298// return QString::fromUtf8( sSettingsTypeMetaEnum.valueToKey( static_cast<int>( Qgis::SettingsType::StringList ) ) );
299//}
300
301//bool QgsSettingsStringListEditorWidgetWrapper::setWidgetFromSetting() const
302//{
303// if ( mEditor )
304// {
305// mEditor->setValue( mSetting->value( mDynamicKeyPartList ) );
306// return true;
307// }
308// else
309// {
310// QgsDebugError( QStringLiteral( "Settings editor not set for %1" ).arg( mSetting->definitionKey() ) );
311// }
312// return false;
313//}
314
315//bool QgsSettingsStringListEditorWidgetWrapper::setSettingFromWidget() const
316//{
317// if ( mEditor )
318// {
319// mSetting->setValue( mEditor->value(), mDynamicKeyPartList );
320// return true;
321// }
322// else
323// {
324// QgsDebugError( QStringLiteral( "Settings editor not set for %1" ).arg( mSetting->definitionKey() ) );
325// }
326// return false;
327//}
328
329//QVariant QgsSettingsStringListEditorWidgetWrapper::valueFromWidget() const
330//{
331// if ( mEditor )
332// {
333// return mEditor->value();
334// }
335// else
336// {
337// QgsDebugError(QString("editor is not set, returning a non-existing value"));
338// }
339// return QStringList();
340//}
@ Double
Double precision number.
void setAllowOpacity(bool allowOpacity)
Sets whether opacity modification (transparency) is permitted for the color.
void setColor(const QColor &color)
Sets the current color for the button.
bool valueFromWidget() const override
Returns the widget value.
bool setWidgetValue(const bool &value) const override
Sets the widget value.
bool setSettingFromWidget() const override
Sets the setting value from the widget value The wrapper must be configured before calling this medth...
QString id() const override
This id of the type of settings it handles.
QString id() const override
This id of the type of settings it handles.
bool setSettingFromWidget() const override
Sets the setting value from the widget value The wrapper must be configured before calling this medth...
QColor valueFromWidget() const override
Returns the widget value.
bool setWidgetValue(const QColor &value) const override
Sets the widget value.
void configureEditorPrivateImplementation() override
To be re-implemented to implemeent type specific configuration (e.g. opacity for colors)
bool setSettingFromWidget() const override
Sets the setting value from the widget value The wrapper must be configured before calling this medth...
bool setWidgetValue(const double &value) const override
Sets the widget value.
double valueFromWidget() const override
Returns the widget value.
QString id() const override
This id of the type of settings it handles.
bool setValue(const T &value, const QString &dynamicKeyPart=QString()) const
Set settings value.
QString definitionKey() const
Returns settings entry defining key.
bool allowAlpha() const
Returns true if transparency is allowed for the color.
QString id() const override
This id of the type of settings it handles.
bool setWidgetValue(const int &value) const override
Sets the widget value.
int valueFromWidget() const override
Returns the widget value.
bool setSettingFromWidget() const override
Sets the setting value from the widget value The wrapper must be configured before calling this medth...
bool setWidgetValue(const QString &value) const override
Sets the widget value.
QString valueFromWidget() const override
Returns the widget value.
QString id() const override
This id of the type of settings it handles.
bool setSettingFromWidget() const override
Sets the setting value from the widget value The wrapper must be configured before calling this medth...
#define QgsDebugError(str)
Definition: qgslogger.h:38