Skip to content

Commit 82d4e0e

Browse files
committedJan 16, 2023
add QgsSettingsEntryBase and implementation to support tree elements
1 parent 7bb250e commit 82d4e0e

File tree

4 files changed

+323
-42
lines changed

4 files changed

+323
-42
lines changed
 

‎src/core/settings/qgssettingsentry.cpp

Lines changed: 43 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,11 @@
1717
#include "qgslogger.h"
1818

1919
#include <QRegularExpression>
20+
#include <QDir>
2021

2122

2223

23-
24-
QgsSettingsEntryGroup::QgsSettingsEntryGroup( const QList<const QgsSettingsEntryBase *> settings, bool fatalErrorIfInvalid )
24+
QgsSettingsEntryGroup::QgsSettingsEntryGroup( QList<const QgsSettingsEntryBase *> settings, bool fatalErrorIfInvalid )
2525
: mSettings( settings )
2626
{
2727
for ( const auto *setting : std::as_const( mSettings ) )
@@ -106,6 +106,29 @@ bool QgsSettingsEntryGroup::hasDynamicKey() const
106106
}
107107

108108

109+
QgsSettingsEntryBase::QgsSettingsEntryBase( const QString &key, QgsSettingsTreeElement *parentTreeElement, const QVariant &defaultValue, const QString &description, Qgis::SettingsOptions options )
110+
: mParentTreeElement( parentTreeElement )
111+
, mDefaultValue( defaultValue )
112+
, mDescription( description )
113+
, mPluginName()
114+
, mOptions( options )
115+
{
116+
QgsDebugMsg( QString( "constructor with parent for %1" ).arg( key ) );
117+
mKey = QDir::cleanPath( QStringLiteral( "%1/%2" ).arg( parentTreeElement ? parentTreeElement->completeKey() : QString(), key ) );
118+
119+
if ( parentTreeElement )
120+
{
121+
parentTreeElement->registerChildSetting( this, key );
122+
}
123+
}
124+
125+
QgsSettingsEntryBase::~QgsSettingsEntryBase()
126+
{
127+
if ( mParentTreeElement )
128+
mParentTreeElement->unregisterChildSetting( this );
129+
}
130+
131+
109132
QString QgsSettingsEntryBase::key( const QString &dynamicKeyPart ) const
110133
{
111134
return key( dynamicKeyPartToList( dynamicKeyPart ) );
@@ -288,31 +311,40 @@ QVariant QgsSettingsEntryBase::formerValueAsVariant( const QStringList &dynamicK
288311
return QgsSettings().value( formerValuekey( dynamicKeyPartList ), defaultValueOverride );
289312
}
290313

291-
bool QgsSettingsEntryBase::migrateFromKey( const QString &oldKey, const QString &oldSection, const QString &dynamicKeyPart ) const
292-
{
293-
return migrateFromKey( oldKey, oldSection, dynamicKeyPartToList( dynamicKeyPart ) );
294-
}
295314

296-
bool QgsSettingsEntryBase::migrateFromKey( const QString &oldKey, const QString &oldSection, const QStringList &dynamicKeyPartList ) const
315+
bool QgsSettingsEntryBase::copyValueFromKey( const QString &key, const QStringList &dynamicKeyPartList, bool deleteOldKey ) const
297316
{
298317
if ( exists( dynamicKeyPartList ) )
299318
return false;
300319

301-
const QString oldCompleteKey = completeKeyPrivate( QStringLiteral( "%1/%2" ).arg( oldSection, oldKey ), dynamicKeyPartList );
320+
QgsSettings settings;
302321

303-
if ( QgsSettings().contains( oldCompleteKey ) )
322+
const QString oldCompleteKey = completeKeyPrivate( key, dynamicKeyPartList );
323+
324+
if ( settings.contains( oldCompleteKey ) )
304325
{
305-
QVariant oldValue = QgsSettings().value( oldCompleteKey, mDefaultValue );
306-
setVariantValuePrivate( oldValue );
326+
QVariant oldValue = settings.value( oldCompleteKey, mDefaultValue );
327+
setVariantValuePrivate( oldValue, dynamicKeyPartList );
328+
if ( deleteOldKey )
329+
settings.remove( oldCompleteKey );
307330
return true;
308331
}
309332
return false;
310333
}
311334

335+
void QgsSettingsEntryBase::copyValueToKey( const QString &key, const QStringList &dynamicKeyPartList ) const
336+
{
337+
QgsSettings settings;
338+
const QString completeKey = completeKeyPrivate( key, dynamicKeyPartList );
339+
QgsSettings().setValue( completeKey, valueAsVariant( dynamicKeyPartList ) );
340+
}
341+
312342
QString QgsSettingsEntryBase::formerValuekey( const QStringList &dynamicKeyPartList ) const
313343
{
314344
return key( dynamicKeyPartList ) + QStringLiteral( "_formervalue" );
315345
}
316346

317347

318348

349+
350+

‎src/core/settings/qgssettingsentry.h

Lines changed: 69 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
#include "qgssettings.h"
2727

2828
class QgsSettingsEntryBase;
29+
class QgsSettingsTreeElement;
2930

3031

3132
/**
@@ -39,7 +40,7 @@ class CORE_EXPORT QgsSettingsEntryGroup
3940
{
4041
public:
4142
//! Constructor
42-
QgsSettingsEntryGroup( const QList<const QgsSettingsEntryBase *> settings )
43+
QgsSettingsEntryGroup( QList<const QgsSettingsEntryBase *> settings )
4344
: QgsSettingsEntryGroup( settings, true )
4445
{}
4546
#ifdef SIP_RUN
@@ -52,7 +53,7 @@ class CORE_EXPORT QgsSettingsEntryGroup
5253
#endif
5354

5455
//! Constructor
55-
QgsSettingsEntryGroup( const QList<const QgsSettingsEntryBase *> settings, bool fatalErrorIfInvalid ) SIP_SKIP;
56+
QgsSettingsEntryGroup( QList<const QgsSettingsEntryBase *> settings, bool fatalErrorIfInvalid ) SIP_SKIP;
5657

5758
//! Returns if the group is valid (if settings share the same base key)
5859
bool isValid() const {return mIsValid;}
@@ -120,6 +121,8 @@ class CORE_EXPORT QgsSettingsEntryBase
120121
sipType = sipType_QgsSettingsEntryDouble;
121122
else if ( dynamic_cast< QgsSettingsEntryColor * >( sipCpp ) )
122123
sipType = sipType_QgsSettingsEntryColor;
124+
else if ( dynamic_cast< QgsSettingsEntryBase * >( sipCpp ) )
125+
sipType = sipType_QgsSettingsEntryBase;
123126
else
124127
sipType = NULL;
125128
SIP_END
@@ -133,7 +136,6 @@ class CORE_EXPORT QgsSettingsEntryBase
133136
*/
134137
static QStringList dynamicKeyPartToList( const QString &dynamicKeyPart );
135138

136-
137139
/**
138140
* Constructor for QgsSettingsEntryBase.
139141
*
@@ -155,10 +157,25 @@ class CORE_EXPORT QgsSettingsEntryBase
155157
, mOptions( options )
156158
{}
157159

160+
/**
161+
* Constructor for QgsSettingsEntryBase.
162+
*
163+
* The \a key argument specifies the key of the settings.
164+
* The \a parent argument specifies the parent in the tree of settings.
165+
* The \a defaultValue argument specifies the default value for the settings entry.
166+
* The \a description argument specifies a description for the settings entry.
167+
* The \a options argument specifies the options for the settings entry.
168+
*/
169+
QgsSettingsEntryBase( const QString &key,
170+
QgsSettingsTreeElement *parentTreeElement,
171+
const QVariant &defaultValue = QVariant(),
172+
const QString &description = QString(),
173+
Qgis::SettingsOptions options = Qgis::SettingsOptions() );
174+
158175
/**
159176
* Destructor for QgsSettingsEntryBase.
160177
*/
161-
virtual ~QgsSettingsEntryBase() {}
178+
virtual ~QgsSettingsEntryBase();
162179

163180
/**
164181
* Returns settings entry key.
@@ -297,7 +314,8 @@ class CORE_EXPORT QgsSettingsEntryBase
297314
/**
298315
* Returns the settings entry type.
299316
*/
300-
virtual Qgis::SettingsType settingsType() const = 0;
317+
virtual Qgis::SettingsType settingsType() const {return Qgis::SettingsType::Custom;}
318+
// This cannot be pure virtual otherwise SIP is failing
301319

302320
/**
303321
* Returns the settings entry description.
@@ -319,17 +337,26 @@ class CORE_EXPORT QgsSettingsEntryBase
319337
QVariant formerValueAsVariant( const QStringList &dynamicKeyPartList ) const;
320338

321339
/**
322-
* Check if the settings does not exist and try to set it from a given \a oldKey and \a oldSection
340+
* Checks if the settings does not exist and try to set it from a given \a oldKey.
341+
* \arg dynamicKeyPartList is the optional dynamic key part to determine the key. It must be the same for origin and destination keys.
342+
* If \a deleteOldKey, the setting with the old key will be removed
343+
* \returns TRUE if the key exists and the setting value could be copied
323344
* \since QGIS 3.30
324345
*/
325-
bool migrateFromKey( const QString &oldKey, const QString &oldSection = QString(), const QString &dynamicKeyPart = QString() ) const;
346+
bool copyValueFromKey( const QString &key, const QStringList &dynamicKeyPartList = QStringList(), bool deleteOldKey = false ) const;
326347

327348
/**
328-
* Check if the settings does not exist and try to set it from a given \a oldKey
329-
* \note The old key must contain its section (the section from the current setting will not be prepended)
349+
* Copies the settings to the given \a key
350+
* \arg dynamicKeyPartList is the optional dynamic key part to determine the key. It must be the same for origin and destination keys.
330351
* \since QGIS 3.30
331352
*/
332-
bool migrateFromKey( const QString &oldKey, const QString &oldSection, const QStringList &dynamicKeyPartList ) const;
353+
void copyValueToKey( const QString &key, const QStringList &dynamicKeyPartList = QStringList() ) const;
354+
355+
/**
356+
* Returns the parent tree element
357+
* \since QGIS 3.30
358+
*/
359+
QgsSettingsTreeElement *parent() const {return mParentTreeElement;}
333360

334361
protected:
335362

@@ -345,6 +372,7 @@ class CORE_EXPORT QgsSettingsEntryBase
345372

346373
QString completeKeyPrivate( const QString &key, const QStringList &dynamicKeyPartList ) const;
347374

375+
QgsSettingsTreeElement *mParentTreeElement = nullptr;
348376
QString mKey;
349377
QVariant mDefaultValue;
350378
QString mDescription;
@@ -372,6 +400,24 @@ class QgsSettingsEntryByReference : public QgsSettingsEntryBase
372400
* Constructor for QgsSettingsEntryByReference.
373401
*
374402
* The \a key argument specifies the key of the settings.
403+
* The \a parent argument specifies the parent in the tree of settings.
404+
* The \a defaultValue argument specifies the default value for the settings entry.
405+
* The \a description argument specifies a description for the settings entry.
406+
* The \a options arguments specifies the options for the settings entry.
407+
*/
408+
QgsSettingsEntryByReference( const QString &key,
409+
QgsSettingsTreeElement *parent,
410+
const T &defaultValue,
411+
const QString &description = QString(),
412+
Qgis::SettingsOptions options = Qgis::SettingsOptions() )
413+
: QgsSettingsEntryBase( key, parent, defaultValue, description, options )
414+
{}
415+
416+
/**
417+
* Constructor for QgsSettingsEntryByReference.
418+
*
419+
* The \a key argument specifies the key of the settings.
420+
* The \a section argument specifies the section.
375421
* The \a defaultValue argument specifies the default value for the settings entry.
376422
* The \a description argument specifies a description for the settings entry.
377423
* The \a options arguments specifies the options for the settings entry.
@@ -513,6 +559,19 @@ class QgsSettingsEntryByValue : public QgsSettingsEntryBase
513559
{
514560
public:
515561

562+
/**
563+
* Constructor for QgsSettingsEntryByValue.
564+
*
565+
* The \a key argument specifies the key of the settings.
566+
* The \a parent argument specifies the parent in the tree of settings.
567+
* The \a section argument specifies the section.
568+
* The \a defaultValue argument specifies the default value for the settings entry.
569+
* The \a description argument specifies a description for the settings entry.
570+
* The \a options arguments specifies the options for the settings entry.
571+
*/
572+
QgsSettingsEntryByValue( const QString &key, QgsSettingsTreeElement *parent, QVariant defaultValue, const QString &description = QString(), Qgis::SettingsOptions options = Qgis::SettingsOptions() )
573+
: QgsSettingsEntryBase( key, parent, defaultValue, description, options )
574+
{}
516575

517576
/**
518577
* Constructor for QgsSettingsEntryByValue.

‎src/core/settings/qgssettingsentryenumflag.h

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,31 @@ class QgsSettingsEntryEnumFlag : public QgsSettingsEntryByValue<T>
3939
* Constructor for QgsSettingsEntryEnumFlagBase.
4040
*
4141
* The \a key argument specifies the final part of the settings key.
42+
* The \a parent argument specifies the parent in the tree of settings.
43+
* The \a defaultValue argument specifies the default value for the settings entry.
44+
* The \a description argument specifies a description for the settings entry.
45+
*
46+
* \note The enum needs to be declared with Q_ENUM, and flags with Q_FLAG (not Q_FLAGS).
47+
* \note for Python bindings, a custom implementation is achieved in Python directly
48+
*/
49+
QgsSettingsEntryEnumFlag( const QString &key, QgsSettingsTreeElement *parent, T defaultValue, const QString &description = QString(), Qgis::SettingsOptions options = Qgis::SettingsOptions() )
50+
: QgsSettingsEntryByValue<T>( key,
51+
parent,
52+
QMetaEnum::fromType<T>().isFlag() ? qgsFlagValueToKeys( defaultValue ) : qgsEnumValueToKey( defaultValue ),
53+
description,
54+
options )
55+
{
56+
mMetaEnum = QMetaEnum::fromType<T>();
57+
Q_ASSERT( mMetaEnum.isValid() );
58+
if ( !mMetaEnum.isValid() )
59+
QgsDebugMsg( QStringLiteral( "Invalid metaenum. Enum/Flag probably misses Q_ENUM/Q_FLAG declaration. Settings key: '%1'" ).arg( this->key() ) );
60+
}
61+
62+
/**
63+
* Constructor for QgsSettingsEntryEnumFlagBase.
64+
*
65+
* The \a parent argument specifies the parent in the tree of settings.
66+
* The \a key argument specifies the final part of the settings key.
4267
* The \a section argument specifies the section.
4368
* The \a defaultValue argument specifies the default value for the settings entry.
4469
* The \a description argument specifies a description for the settings entry.

‎src/core/settings/qgssettingsentryimpl.h

Lines changed: 186 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,25 @@ class CORE_EXPORT QgsSettingsEntryVariant : public QgsSettingsEntryByReference<Q
3939
* The \a defaultValue argument specifies the default value for the settings entry.
4040
* The \a description argument specifies a description for the settings entry.
4141
* The \a options argument specifies the options for the settings entry.
42+
* \since QGIS 3.30
43+
*/
44+
QgsSettingsEntryVariant( const QString &key,
45+
QgsSettingsTreeElement *parent,
46+
const QVariant &defaultValue = QVariant(),
47+
const QString &description = QString(),
48+
Qgis::SettingsOptions options = Qgis::SettingsOptions() )
49+
: QgsSettingsEntryByReference( key, parent, defaultValue, description, options ) SIP_THROW( QgsSettingsException )
50+
{}
51+
52+
/**
53+
* Constructor for QgsSettingsEntryVariant.
54+
*
55+
* The \a key argument specifies the final part of the settings key.
56+
* The \a parent argument specifies the parent in the tree of settings.
57+
* The \a defaultValue argument specifies the default value for the settings entry.
58+
* The \a description argument specifies a description for the settings entry.
59+
* The \a options argument specifies the options for the settings entry.
60+
* \since QGIS 3.30
4261
*/
4362
QgsSettingsEntryVariant( const QString &key,
4463
const QString &section,
@@ -64,9 +83,9 @@ class CORE_EXPORT QgsSettingsEntryVariant : public QgsSettingsEntryByReference<Q
6483
const QString &pluginName,
6584
const QVariant &defaultValue = QVariant(),
6685
const QString &description = QString(),
67-
Qgis::SettingsOptions options = Qgis::SettingsOptions() );
86+
Qgis::SettingsOptions options = Qgis::SettingsOptions() ) SIP_THROW( QgsSettingsException ) SIP_TRANSFER;
6887
% MethodCode
69-
sipCpp = new sipQgsSettingsEntryVariant( QgsSettingsEntryVariant( *a0, QStringLiteral( "plugins/%1" ).arg( *a1 ), *a2, *a3, *a4 ) );
88+
sipCpp = new sipQgsSettingsEntryVariant( QgsSettingsEntryVariant( *a0, QgsSettings::createPluginTreeElement( *a1 ), *a2, *a3, *a4 ) );
7089
% End
7190
#endif
7291

@@ -88,6 +107,29 @@ class CORE_EXPORT QgsSettingsEntryString : public QgsSettingsEntryByReference<QS
88107
{
89108
public:
90109

110+
/**
111+
* Constructor for QgsSettingsEntryString.
112+
*
113+
* The \a key argument specifies the final part of the settings key.
114+
* The \a parent argument specifies the parent in the tree of settings.
115+
* The \a defaultValue argument specifies the default value for the settings entry.
116+
* The \a description argument specifies a description for the settings entry.
117+
* The \a options arguments specifies the options for the settings entry.
118+
* The \a minLength argument specifies the minimal length of the string value. 0 means no limit.
119+
* The \a maxLength argument specifies the maximal length of the string value. -1 means no limit.
120+
*/
121+
QgsSettingsEntryString( const QString &key,
122+
QgsSettingsTreeElement *parent,
123+
const QString &defaultValue = QString(),
124+
const QString &description = QString(),
125+
Qgis::SettingsOptions options = Qgis::SettingsOptions(),
126+
int minLength = 0,
127+
int maxLength = -1 ) SIP_THROW( QgsSettingsException )
128+
: QgsSettingsEntryByReference<QString>( key, parent, defaultValue, description, options )
129+
, mMinLength( minLength )
130+
, mMaxLength( maxLength )
131+
{}
132+
91133
/**
92134
* Constructor for QgsSettingsEntryString.
93135
*
@@ -106,11 +148,10 @@ class CORE_EXPORT QgsSettingsEntryString : public QgsSettingsEntryByReference<QS
106148
Qgis::SettingsOptions options = Qgis::SettingsOptions(),
107149
int minLength = 0,
108150
int maxLength = -1 ) SIP_MAKE_PRIVATE
109-
: QgsSettingsEntryByReference<QString>( key, section, defaultValue, description, options )
151+
: QgsSettingsEntryByReference<QString>( key, section, defaultValue, description, options ) SIP_MAKE_PRIVATE
110152
, mMinLength( minLength )
111153
, mMaxLength( maxLength )
112-
{
113-
}
154+
{}
114155

115156
#ifdef SIP_RUN
116157

@@ -130,9 +171,9 @@ class CORE_EXPORT QgsSettingsEntryString : public QgsSettingsEntryByReference<QS
130171
const QString &description = QString(),
131172
Qgis::SettingsOptions options = Qgis::SettingsOptions(),
132173
int minLength = 0,
133-
int maxLength = -1 );
174+
int maxLength = -1 ) SIP_THROW( QgsSettingsException ) SIP_TRANSFER;
134175
% MethodCode
135-
sipCpp = new sipQgsSettingsEntryString( QgsSettingsEntryString( *a0, QStringLiteral( "plugins/%1" ).arg( *a1 ), *a2, *a3, *a4 ) );
176+
sipCpp = new sipQgsSettingsEntryString( QgsSettingsEntryString( *a0, QgsSettings::createPluginTreeElement( *a1 ), *a2, *a3, *a4 ) );
136177
% End
137178
#endif
138179

@@ -183,6 +224,23 @@ class CORE_EXPORT QgsSettingsEntryStringList : public QgsSettingsEntryByReferenc
183224
{
184225
public:
185226

227+
/**
228+
* Constructor for QgsSettingsEntryStringList.
229+
*
230+
* The \a key argument specifies the final part of the settings key.
231+
* The \a parent argument specifies the parent in the tree of settings.
232+
* The \a defaultValue argument specifies the default value for the settings entry.
233+
* The \a description argument specifies a description for the settings entry.
234+
* The \a options arguments specifies the options for the settings entry.
235+
*/
236+
QgsSettingsEntryStringList( const QString &key,
237+
QgsSettingsTreeElement *parent,
238+
const QStringList &defaultValue = QStringList(),
239+
const QString &description = QString(),
240+
Qgis::SettingsOptions options = Qgis::SettingsOptions() )
241+
: QgsSettingsEntryByReference( key, parent, defaultValue, description, options ) SIP_THROW( QgsSettingsException )
242+
{}
243+
186244
/**
187245
* Constructor for QgsSettingsEntryStringList.
188246
*
@@ -198,8 +256,8 @@ class CORE_EXPORT QgsSettingsEntryStringList : public QgsSettingsEntryByReferenc
198256
const QString &description = QString(),
199257
Qgis::SettingsOptions options = Qgis::SettingsOptions() ) SIP_MAKE_PRIVATE
200258
: QgsSettingsEntryByReference( key, section, defaultValue, description, options )
201-
{
202-
}
259+
{}
260+
203261

204262
#ifdef SIP_RUN
205263

@@ -217,9 +275,9 @@ class CORE_EXPORT QgsSettingsEntryStringList : public QgsSettingsEntryByReferenc
217275
const QString &pluginName,
218276
const QStringList &defaultValue = QStringList(),
219277
const QString &description = QString(),
220-
Qgis::SettingsOptions options = Qgis::SettingsOptions() );
278+
Qgis::SettingsOptions options = Qgis::SettingsOptions() ) SIP_THROW( QgsSettingsException ) SIP_TRANSFER;
221279
% MethodCode
222-
sipCpp = new sipQgsSettingsEntryStringList( QgsSettingsEntryStringList( *a0, QStringLiteral( "plugins/%1" ).arg( *a1 ), *a2, *a3, *a4 ) );
280+
sipCpp = new sipQgsSettingsEntryStringList( QgsSettingsEntryStringList( *a0, QgsSettings::createPluginTreeElement( *a1 ), *a2, *a3, *a4 ) );
223281
% End
224282
#endif
225283

@@ -242,6 +300,23 @@ class CORE_EXPORT QgsSettingsEntryBool : public QgsSettingsEntryByValue<bool>
242300
{
243301
public:
244302

303+
/**
304+
* Constructor for QgsSettingsEntryBool.
305+
*
306+
* The \a key argument specifies the final part of the settings key.
307+
* The \a parent argument specifies the parent in the tree of settings.
308+
* The \a defaultValue argument specifies the default value for the settings entry.
309+
* The \a description argument specifies a description for the settings entry.
310+
* The \a options arguments specifies the options for the settings entry.
311+
*/
312+
QgsSettingsEntryBool( const QString &key,
313+
QgsSettingsTreeElement *parent,
314+
bool defaultValue = false,
315+
const QString &description = QString(),
316+
Qgis::SettingsOptions options = Qgis::SettingsOptions() ) SIP_THROW( QgsSettingsException )
317+
: QgsSettingsEntryByValue( key, parent, defaultValue, description, options )
318+
{}
319+
245320
/**
246321
* Constructor for QgsSettingsEntryBool.
247322
*
@@ -275,9 +350,9 @@ class CORE_EXPORT QgsSettingsEntryBool : public QgsSettingsEntryByValue<bool>
275350
const QString &pluginName,
276351
bool defaultValue = false,
277352
const QString &description = QString(),
278-
Qgis::SettingsOptions options = Qgis::SettingsOptions() );
353+
Qgis::SettingsOptions options = Qgis::SettingsOptions() ) SIP_THROW( QgsSettingsException ) SIP_TRANSFER;
279354
% MethodCode
280-
sipCpp = new sipQgsSettingsEntryBool( QgsSettingsEntryBool( *a0, QStringLiteral( "plugins/%1" ).arg( *a1 ), a2, *a3, *a4 ) );
355+
sipCpp = new sipQgsSettingsEntryBool( QgsSettingsEntryBool( *a0, QgsSettings::createPluginTreeElement( *a1 ), a2, *a3, *a4 ) );
281356
% End
282357
#endif
283358

@@ -304,6 +379,30 @@ class CORE_EXPORT QgsSettingsEntryInteger : public QgsSettingsEntryByValue<qlong
304379
* Constructor for QgsSettingsEntryInteger.
305380
*
306381
* The \a key argument specifies the final part of the settings key.
382+
* The \a parent argument specifies the parent in the tree of settings.
383+
* The \a defaultValue argument specifies the default value for the settings entry.
384+
* The \a description argument specifies a description for the settings entry.
385+
* The \a options arguments specifies the options for the settings entry.
386+
* The \a minValue argument specifies the minimal value.
387+
* The \a maxValue argument specifies the maximal value.
388+
*/
389+
QgsSettingsEntryInteger( const QString &key,
390+
QgsSettingsTreeElement *parent,
391+
qlonglong defaultValue = 0,
392+
const QString &description = QString(),
393+
Qgis::SettingsOptions options = Qgis::SettingsOptions(),
394+
qlonglong minValue = std::numeric_limits<qlonglong>::min(),
395+
qlonglong maxValue = std::numeric_limits<qlonglong>::max() ) SIP_THROW( QgsSettingsException )
396+
: QgsSettingsEntryByValue( key, parent, defaultValue, description, options )
397+
, mMinValue( minValue )
398+
, mMaxValue( maxValue )
399+
{ }
400+
401+
/**
402+
* Constructor for QgsSettingsEntryInteger.
403+
*
404+
* The \a parent argument specifies the parent in the tree of settings.
405+
* The \a key argument specifies the final part of the settings key.
307406
* The \a section argument specifies the section.
308407
* The \a defaultValue argument specifies the default value for the settings entry.
309408
* The \a description argument specifies a description for the settings entry.
@@ -343,9 +442,9 @@ class CORE_EXPORT QgsSettingsEntryInteger : public QgsSettingsEntryByValue<qlong
343442
const QString &description = QString(),
344443
Qgis::SettingsOptions options = Qgis::SettingsOptions(),
345444
qlonglong minValue = std::numeric_limits<qlonglong>::min(),
346-
qlonglong maxValue = std::numeric_limits<qlonglong>::max() );
445+
qlonglong maxValue = std::numeric_limits<qlonglong>::max() ) SIP_THROW( QgsSettingsException ) SIP_TRANSFER;
347446
% MethodCode
348-
sipCpp = new sipQgsSettingsEntryInteger( QgsSettingsEntryInteger( *a0, QStringLiteral( "plugins/%1" ).arg( *a1 ), a2, *a3, *a4, a5, a6 ) );
447+
sipCpp = new sipQgsSettingsEntryInteger( QgsSettingsEntryInteger( *a0, QgsSettings::createPluginTreeElement( *a1 ), a2, *a3, *a4, a5, a6 ) );
349448
% End
350449
#endif
351450

@@ -398,6 +497,35 @@ class CORE_EXPORT QgsSettingsEntryDouble : public QgsSettingsEntryByValue<double
398497
/**
399498
* Constructor for QgsSettingsEntryDouble.
400499
*
500+
* The \a parent argument specifies the parent in the tree of settings.
501+
* The \a key argument specifies the final part of the settings key.
502+
* The \a section argument specifies the section.
503+
* The \a defaultValue argument specifies the default value for the settings entry.
504+
* The \a description argument specifies a description for the settings entry.
505+
* The \a options arguments specifies the options for the settings entry.
506+
* The \a minValue argument specifies the minimal value.
507+
* The \a maxValue argument specifies the maximal value.
508+
* The \a displayDecimals specifies an hint for the gui about how much decimals to show
509+
* for example for a QDoubleSpinBox.
510+
*/
511+
QgsSettingsEntryDouble( const QString &key,
512+
QgsSettingsTreeElement *parent,
513+
double defaultValue = 0.0,
514+
const QString &description = QString(),
515+
Qgis::SettingsOptions options = Qgis::SettingsOptions(),
516+
double minValue = std::numeric_limits<double>::lowest(),
517+
double maxValue = std::numeric_limits<double>::max(),
518+
int displayDecimals = 1 ) SIP_THROW( QgsSettingsException )
519+
: QgsSettingsEntryByValue( key, parent, defaultValue, description, options )
520+
, mMinValue( minValue )
521+
, mMaxValue( maxValue )
522+
, mDisplayHintDecimals( displayDecimals )
523+
{}
524+
525+
/**
526+
* Constructor for QgsSettingsEntryDouble.
527+
*
528+
* The \a parent argument specifies the parent in the tree of settings.
401529
* The \a key argument specifies the final part of the settings key.
402530
* The \a section argument specifies the section.
403531
* The \a defaultValue argument specifies the default value for the settings entry.
@@ -444,9 +572,9 @@ class CORE_EXPORT QgsSettingsEntryDouble : public QgsSettingsEntryByValue<double
444572
Qgis::SettingsOptions options = Qgis::SettingsOptions(),
445573
double minValue = std::numeric_limits<double>::lowest(),
446574
double maxValue = std::numeric_limits<double>::max(),
447-
int displayDecimals = 1 );
575+
int displayDecimals = 1 ) SIP_THROW( QgsSettingsException ) SIP_TRANSFER;
448576
% MethodCode
449-
sipCpp = new sipQgsSettingsEntryDouble( QgsSettingsEntryDouble( *a0, QStringLiteral( "plugins/%1" ).arg( *a1 ), a2, *a3, *a4, a5, a6, a7 ) );
577+
sipCpp = new sipQgsSettingsEntryDouble( QgsSettingsEntryDouble( *a0, QgsSettings::createPluginTreeElement( *a1 ), a2, *a3, *a4, a5, a6, a7 ) );
450578
% End
451579
#endif
452580

@@ -512,6 +640,23 @@ class CORE_EXPORT QgsSettingsEntryColor : public QgsSettingsEntryByReference<QCo
512640
{
513641
public:
514642

643+
/**
644+
* Constructor for QgsSettingsEntryColor.
645+
*
646+
* The \a key argument specifies the final part of the settings key.
647+
* The \a parent argument specifies the parent in the tree of settings.
648+
* The \a defaultValue argument specifies the default value for the settings entry.
649+
* The \a description argument specifies a description for the settings entry.
650+
* The \a options arguments specifies the options for the settings entry.
651+
*/
652+
QgsSettingsEntryColor( const QString &key,
653+
QgsSettingsTreeElement *parent,
654+
const QColor &defaultValue = QColor(),
655+
const QString &description = QString(),
656+
Qgis::SettingsOptions options = Qgis::SettingsOptions() ) SIP_THROW( QgsSettingsException )
657+
: QgsSettingsEntryByReference( key, parent, defaultValue, description, options )
658+
{}
659+
515660
/**
516661
* Constructor for QgsSettingsEntryColor.
517662
*
@@ -545,9 +690,9 @@ class CORE_EXPORT QgsSettingsEntryColor : public QgsSettingsEntryByReference<QCo
545690
const QString &pluginName,
546691
const QColor &defaultValue = QColor(),
547692
const QString &description = QString(),
548-
Qgis::SettingsOptions options = Qgis::SettingsOptions() );
693+
Qgis::SettingsOptions options = Qgis::SettingsOptions() ) SIP_THROW( QgsSettingsException ) SIP_TRANSFER;
549694
% MethodCode
550-
sipCpp = new sipQgsSettingsEntryColor( QgsSettingsEntryColor( *a0, QStringLiteral( "plugins/%1" ).arg( *a1 ), *a2, *a3, *a4 ) );
695+
sipCpp = new sipQgsSettingsEntryColor( QgsSettingsEntryColor( *a0, QgsSettings::createPluginTreeElement( *a1 ), *a2, *a3, *a4 ) );
551696
% End
552697
#endif
553698

@@ -569,9 +714,29 @@ class CORE_EXPORT QgsSettingsEntryVariantMap : public QgsSettingsEntryByReferenc
569714
{
570715
public:
571716

717+
718+
/**
719+
* Constructor for QgsSettingsEntryVariantMap.
720+
*
721+
* The \a key argument specifies the final part of the settings key.
722+
* The \a parent argument specifies the parent in the tree of settings.
723+
* The \a defaultValue argument specifies the default value for the settings entry.
724+
* The \a description argument specifies a description for the settings entry.
725+
* The \a options arguments specifies the options for the settings entry.
726+
*/
727+
QgsSettingsEntryVariantMap( const QString &key,
728+
QgsSettingsTreeElement *parent,
729+
const QVariantMap &defaultValue = QVariantMap(),
730+
const QString &description = QString(),
731+
Qgis::SettingsOptions options = Qgis::SettingsOptions() ) SIP_THROW( QgsSettingsException )
732+
: QgsSettingsEntryByReference( key, parent, defaultValue, description, options )
733+
{
734+
}
735+
572736
/**
573737
* Constructor for QgsSettingsEntryVariantMap.
574738
*
739+
* The \a parent argument specifies the parent in the tree of settings.
575740
* The \a key argument specifies the final part of the settings key.
576741
* The \a section argument specifies the section.
577742
* The \a defaultValue argument specifies the default value for the settings entry.
@@ -603,9 +768,9 @@ class CORE_EXPORT QgsSettingsEntryVariantMap : public QgsSettingsEntryByReferenc
603768
const QString &pluginName,
604769
const QVariantMap &defaultValue = QVariantMap(),
605770
const QString &description = QString(),
606-
Qgis::SettingsOptions options = Qgis::SettingsOptions() );
771+
Qgis::SettingsOptions options = Qgis::SettingsOptions() ) SIP_THROW( QgsSettingsException ) SIP_TRANSFER;
607772
% MethodCode
608-
sipCpp = new sipQgsSettingsEntryVariantMap( QgsSettingsEntryVariantMap( *a0, QStringLiteral( "plugins/%1" ).arg( *a1 ), *a2, *a3, *a4 ) );
773+
sipCpp = new sipQgsSettingsEntryVariantMap( QgsSettingsEntryVariantMap( *a0, QgsSettings::createPluginTreeElement( *a1 ), *a2, *a3, *a4 ) );
609774
% End
610775
#endif
611776

0 commit comments

Comments
 (0)
Please sign in to comment.