QGIS API Documentation 3.28.0-Firenze (ed3ad0430f)
qgssettingsentryimpl.h
Go to the documentation of this file.
1/***************************************************************************
2 qgssettingsentryimpl.h
3 --------------------------------------
4 Date : February 2022
5 Copyright : (C) 2022 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#ifndef QGSSETTINGSENTRYIMPL_H
17#define QGSSETTINGSENTRYIMPL_H
18
19#include "qgssettingsentry.h"
20
21
29class CORE_EXPORT QgsSettingsEntryVariant : public QgsSettingsEntryByReference<QVariant>
30{
31 public:
32
33
43 QgsSettingsEntryVariant( const QString &key,
44 const QString &section,
45 const QVariant &defaultValue = QVariant(),
46 const QString &description = QString(),
47 Qgis::SettingsOptions options = Qgis::SettingsOptions() ) SIP_MAKE_PRIVATE
48 : QgsSettingsEntryByReference( key, section, defaultValue, description, options )
49 {}
50
51#ifdef SIP_RUN
52
63 QgsSettingsEntryVariant( const QString &key,
64 const QString &pluginName,
65 const QVariant &defaultValue = QVariant(),
66 const QString &description = QString(),
67 Qgis::SettingsOptions options = Qgis::SettingsOptions() );
68 % MethodCode
69 sipCpp = new sipQgsSettingsEntryVariant( QgsSettingsEntryVariant( *a0, QStringLiteral( "plugins/%1" ).arg( *a1 ), *a2, *a3, *a4 ) );
70 % End
71#endif
72
73
74 virtual Qgis::SettingsType settingsType() const override;
75
76 private:
77 QVariant convertFromVariant( const QVariant &value ) const override SIP_FORCE {return value;}
78};
79
87class CORE_EXPORT QgsSettingsEntryString : public QgsSettingsEntryByReference<QString>
88{
89 public:
90
102 QgsSettingsEntryString( const QString &key,
103 const QString &section,
104 const QString &defaultValue = QString(),
105 const QString &description = QString(),
106 Qgis::SettingsOptions options = Qgis::SettingsOptions(),
107 int minLength = 0,
108 int maxLength = -1 ) SIP_MAKE_PRIVATE
109 : QgsSettingsEntryByReference<QString>( key, section, defaultValue, description, options )
110 , mMinLength( minLength )
111 , mMaxLength( maxLength )
112 {
113 }
114
115#ifdef SIP_RUN
116
127 QgsSettingsEntryString( const QString &key,
128 const QString &pluginName,
129 const QString &defaultValue = QString(),
130 const QString &description = QString(),
131 Qgis::SettingsOptions options = Qgis::SettingsOptions(),
132 int minLength = 0,
133 int maxLength = -1 );
134 % MethodCode
135 sipCpp = new sipQgsSettingsEntryString( QgsSettingsEntryString( *a0, QStringLiteral( "plugins/%1" ).arg( *a1 ), *a2, *a3, *a4 ) );
136 % End
137#endif
138
139 virtual Qgis::SettingsType settingsType() const override;
140
146 void setMinLength( int minLength );
147
151 int minLength() const;
152
158 void setMaxLength( int maxLength );
159
163 int maxLength() const;
164
165 private:
166 bool checkValue( const QString &value ) const override SIP_FORCE;
167 QString convertFromVariant( const QVariant &value ) const override SIP_FORCE;
168
169 int mMinLength;
170 int mMaxLength;
171
172};
173
174
182class CORE_EXPORT QgsSettingsEntryStringList : public QgsSettingsEntryByReference<QStringList>
183{
184 public:
185
195 QgsSettingsEntryStringList( const QString &key,
196 const QString &section,
197 const QStringList &defaultValue = QStringList(),
198 const QString &description = QString(),
199 Qgis::SettingsOptions options = Qgis::SettingsOptions() ) SIP_MAKE_PRIVATE
200 : QgsSettingsEntryByReference( key, section, defaultValue, description, options )
201 {
202 }
203
204#ifdef SIP_RUN
205
216 QgsSettingsEntryStringList( const QString &key,
217 const QString &pluginName,
218 const QStringList &defaultValue = QStringList(),
219 const QString &description = QString(),
220 Qgis::SettingsOptions options = Qgis::SettingsOptions() );
221 % MethodCode
222 sipCpp = new sipQgsSettingsEntryStringList( QgsSettingsEntryStringList( *a0, QStringLiteral( "plugins/%1" ).arg( *a1 ), *a2, *a3, *a4 ) );
223 % End
224#endif
225
226 virtual Qgis::SettingsType settingsType() const override;
227
228 private:
229 QStringList convertFromVariant( const QVariant &value ) const override SIP_FORCE;
230
231};
232
233
241class CORE_EXPORT QgsSettingsEntryBool : public QgsSettingsEntryByValue<bool>
242{
243 public:
244
254 QgsSettingsEntryBool( const QString &key,
255 const QString &section,
256 bool defaultValue = false,
257 const QString &description = QString(),
258 Qgis::SettingsOptions options = Qgis::SettingsOptions() ) SIP_MAKE_PRIVATE
259 : QgsSettingsEntryByValue( key, section, defaultValue, description, options )
260 {}
261
262#ifdef SIP_RUN
263
274 QgsSettingsEntryBool( const QString &key,
275 const QString &pluginName,
276 bool defaultValue = false,
277 const QString &description = QString(),
278 Qgis::SettingsOptions options = Qgis::SettingsOptions() );
279 % MethodCode
280 sipCpp = new sipQgsSettingsEntryBool( QgsSettingsEntryBool( *a0, QStringLiteral( "plugins/%1" ).arg( *a1 ), a2, *a3, *a4 ) );
281 % End
282#endif
283
284
285 virtual Qgis::SettingsType settingsType() const override;
286
287 private:
288 bool convertFromVariant( const QVariant &value ) const override SIP_FORCE;
289};
290
291
299class CORE_EXPORT QgsSettingsEntryInteger : public QgsSettingsEntryByValue<qlonglong>
300{
301 public:
302
314 QgsSettingsEntryInteger( const QString &key,
315 const QString &section,
316 qlonglong defaultValue = 0,
317 const QString &description = QString(),
318 Qgis::SettingsOptions options = Qgis::SettingsOptions(),
319 qlonglong minValue = std::numeric_limits<qlonglong>::min(),
320 qlonglong maxValue = std::numeric_limits<qlonglong>::max() ) SIP_MAKE_PRIVATE
321 : QgsSettingsEntryByValue( key, section, defaultValue, description, options )
322 , mMinValue( minValue )
323 , mMaxValue( maxValue )
324 { }
325
326#ifdef SIP_RUN
327
340 QgsSettingsEntryInteger( const QString &key,
341 const QString &pluginName,
342 qlonglong defaultValue = 0,
343 const QString &description = QString(),
344 Qgis::SettingsOptions options = Qgis::SettingsOptions(),
345 qlonglong minValue = std::numeric_limits<qlonglong>::min(),
346 qlonglong maxValue = std::numeric_limits<qlonglong>::max() );
347 % MethodCode
348 sipCpp = new sipQgsSettingsEntryInteger( QgsSettingsEntryInteger( *a0, QStringLiteral( "plugins/%1" ).arg( *a1 ), a2, *a3, *a4, a5, a6 ) );
349 % End
350#endif
351
352 virtual Qgis::SettingsType settingsType() const override;
353
359 void setMinValue( qlonglong minValue );
360
364 qlonglong minValue() const;
365
371 void setMaxValue( qlonglong maxValue );
372
376 qlonglong maxValue() const;
377
378 private:
379 bool checkValue( qlonglong value ) const override SIP_FORCE;
380 qlonglong convertFromVariant( const QVariant &value ) const override SIP_FORCE;
381 qlonglong mMinValue;
382 qlonglong mMaxValue;
383
384};
385
386
394class CORE_EXPORT QgsSettingsEntryDouble : public QgsSettingsEntryByValue<double>
395{
396 public:
397
411 QgsSettingsEntryDouble( const QString &key,
412 const QString &section,
413 double defaultValue = 0.0,
414 const QString &description = QString(),
415 Qgis::SettingsOptions options = Qgis::SettingsOptions(),
416 double minValue = std::numeric_limits<double>::lowest(),
417 double maxValue = std::numeric_limits<double>::max(),
418 int displayDecimals = 1 ) SIP_MAKE_PRIVATE
419 : QgsSettingsEntryByValue( key, section, defaultValue, description, options )
420 , mMinValue( minValue )
421 , mMaxValue( maxValue )
422 , mDisplayHintDecimals( displayDecimals )
423 {}
424
425#ifdef SIP_RUN
426
440 QgsSettingsEntryDouble( const QString &key,
441 const QString &pluginName,
442 double defaultValue,
443 const QString &description = QString(),
444 Qgis::SettingsOptions options = Qgis::SettingsOptions(),
445 double minValue = std::numeric_limits<double>::lowest(),
446 double maxValue = std::numeric_limits<double>::max(),
447 int displayDecimals = 1 );
448 % MethodCode
449 sipCpp = new sipQgsSettingsEntryDouble( QgsSettingsEntryDouble( *a0, QStringLiteral( "plugins/%1" ).arg( *a1 ), a2, *a3, *a4, a5, a6, a7 ) );
450 % End
451#endif
452
453
454 virtual Qgis::SettingsType settingsType() const override;
455
461 void setMinValue( double minValue );
462
466 double minValue() const;
467
473 void setMaxValue( double maxValue );
474
478 double maxValue() const;
479
485 void setDisplayHintDecimals( int displayHintDecimals );
486
490 int displayHintDecimals() const;
491
492 private:
493 bool checkValue( double value ) const override SIP_FORCE;
494 double convertFromVariant( const QVariant &value ) const override SIP_FORCE;
495 double mMinValue;
496 double mMaxValue;
497
498 int mDisplayHintDecimals;
499
500};
501
502
503
511class CORE_EXPORT QgsSettingsEntryColor : public QgsSettingsEntryByReference<QColor>
512{
513 public:
514
524 QgsSettingsEntryColor( const QString &key,
525 const QString &section,
526 const QColor &defaultValue = QColor(),
527 const QString &description = QString(),
528 Qgis::SettingsOptions options = Qgis::SettingsOptions() ) SIP_MAKE_PRIVATE
529 : QgsSettingsEntryByReference( key, section, defaultValue, description, options )
530 {}
531
532#ifdef SIP_RUN
533
544 QgsSettingsEntryColor( const QString &key,
545 const QString &pluginName,
546 const QColor &defaultValue = QColor(),
547 const QString &description = QString(),
548 Qgis::SettingsOptions options = Qgis::SettingsOptions() );
549 % MethodCode
550 sipCpp = new sipQgsSettingsEntryColor( QgsSettingsEntryColor( *a0, QStringLiteral( "plugins/%1" ).arg( *a1 ), *a2, *a3, *a4 ) );
551 % End
552#endif
553
554 virtual Qgis::SettingsType settingsType() const override;
555
556 private:
557 QColor convertFromVariant( const QVariant &value ) const override SIP_FORCE;
558
559};
560
561#endif // QGSSETTINGSENTRYIMPL_H
SettingsType
Types of settings entries.
Definition: qgis.h:231
A boolean settings entry.
QgsSettingsEntryBool(const QString &key, const QString &section, bool defaultValue=false, const QString &description=QString(), Qgis::SettingsOptions options=Qgis::SettingsOptions()) SIP_MAKE_PRIVATE
Constructor for QgsSettingsEntryBool.
Base abstract class for settings entry which are passed by reference.
virtual Qgis::SettingsType settingsType() const override=0
Returns the settings entry type.
virtual T convertFromVariant(const QVariant &value) const =0
Converts the variant value to the value type of the setting.
virtual bool checkValue(const T &value) const
Check if the value is valid.
T value(const QString &dynamicKeyPart=QString()) const
Returns settings value.
Base abstract class for settings entry which are passed by value.
A color settings entry.
QgsSettingsEntryColor(const QString &key, const QString &section, const QColor &defaultValue=QColor(), const QString &description=QString(), Qgis::SettingsOptions options=Qgis::SettingsOptions()) SIP_MAKE_PRIVATE
Constructor for QgsSettingsEntryColor.
A double settings entry.
QgsSettingsEntryDouble(const QString &key, const QString &section, double defaultValue=0.0, const QString &description=QString(), Qgis::SettingsOptions options=Qgis::SettingsOptions(), double minValue=std::numeric_limits< double >::lowest(), double maxValue=std::numeric_limits< double >::max(), int displayDecimals=1) SIP_MAKE_PRIVATE
Constructor for QgsSettingsEntryDouble.
An integer settings entry.
QgsSettingsEntryInteger(const QString &key, const QString &section, qlonglong defaultValue=0, const QString &description=QString(), Qgis::SettingsOptions options=Qgis::SettingsOptions(), qlonglong minValue=std::numeric_limits< qlonglong >::min(), qlonglong maxValue=std::numeric_limits< qlonglong >::max()) SIP_MAKE_PRIVATE
Constructor for QgsSettingsEntryInteger.
A string list settings entry.
QgsSettingsEntryStringList(const QString &key, const QString &section, const QStringList &defaultValue=QStringList(), const QString &description=QString(), Qgis::SettingsOptions options=Qgis::SettingsOptions()) SIP_MAKE_PRIVATE
Constructor for QgsSettingsEntryStringList.
A string settings entry.
QgsSettingsEntryString(const QString &key, const QString &section, const QString &defaultValue=QString(), const QString &description=QString(), Qgis::SettingsOptions options=Qgis::SettingsOptions(), int minLength=0, int maxLength=-1) SIP_MAKE_PRIVATE
Constructor for QgsSettingsEntryString.
A variant settings entry.
QgsSettingsEntryVariant(const QString &key, const QString &section, const QVariant &defaultValue=QVariant(), const QString &description=QString(), Qgis::SettingsOptions options=Qgis::SettingsOptions()) SIP_MAKE_PRIVATE
Constructor for QgsSettingsEntryVariant.
#define SIP_FORCE
Definition: qgis_sip.h:131
#define SIP_MAKE_PRIVATE
Definition: qgis_sip.h:136