23 #include "qgis_core.h"
86 const QString &application = QString(), QObject *parent =
nullptr );
102 QgsSettings( QSettings::Scope scope,
const QString &organization,
103 const QString &application = QString(), QObject *parent =
nullptr );
119 QgsSettings( QSettings::Format format, QSettings::Scope scope,
const QString &organization,
120 const QString &application = QString(), QObject *parent =
nullptr );
142 QgsSettings(
const QString &fileName, QSettings::Format format, QObject *parent =
nullptr );
172 QString group()
const;
175 QStringList allKeys()
const;
177 QStringList childKeys()
const;
179 QStringList childGroups()
const;
181 QStringList globalChildGroups()
const;
183 static QString globalSettingsPath();
185 static bool setGlobalSettingsPath(
const QString &path );
187 int beginReadArray(
const QString &prefix );
194 void beginWriteArray(
const QString &prefix,
int size = -1 );
202 void setArrayIndex(
int i );
217 QVariant value(
const QString &key,
const QVariant &defaultValue = QVariant(),
218 Section section = NoSection )
const;
220 SIP_PYOBJECT value(
const QString &key,
const QVariant &defaultValue = QVariant(),
221 SIP_PYOBJECT type = 0,
224 typedef PyObject *( *pyqt5_from_qvariant_by_type )( QVariant &value, PyObject *type );
228 Py_BEGIN_ALLOW_THREADS
229 value = sipCpp->value( *a0, *a1, a3 );
232 pyqt5_from_qvariant_by_type f = ( pyqt5_from_qvariant_by_type ) sipImportSymbol(
"pyqt5_from_qvariant_by_type" );
233 sipRes = f( value, a2 );
253 const Section section = NoSection )
255 QMetaEnum metaEnum = QMetaEnum::fromType<T>();
256 Q_ASSERT( metaEnum.isValid() );
257 if ( !metaEnum.isValid() )
259 QgsDebugMsg( QStringLiteral(
"Invalid metaenum. Enum probably misses Q_ENUM or Q_FLAG declaration." ) );
265 if ( metaEnum.isValid() )
268 QByteArray ba = value( key, metaEnum.valueToKey(
static_cast<int>( defaultValue ) ), section ).toString().toUtf8();
269 const char *vs = ba.data();
270 v =
static_cast<T
>( metaEnum.keyToValue( vs, &ok ) );
278 v =
static_cast<T
>( value( key,
static_cast<int>( defaultValue ), section ).toInt( &ok ) );
279 if ( metaEnum.isValid() )
281 if ( !ok || !metaEnum.valueToKey(
static_cast<int>( v ) ) )
289 setEnumValue( key, v, section );
305 const Section section = NoSection )
307 QMetaEnum metaEnum = QMetaEnum::fromType<T>();
308 Q_ASSERT( metaEnum.isValid() );
309 if ( metaEnum.isValid() )
311 setValue( key, metaEnum.valueToKey(
static_cast<int>( value ) ), section );
315 QgsDebugMsg( QStringLiteral(
"Invalid metaenum. Enum probably misses Q_ENUM or Q_FLAG declaration." ) );
331 const Section section = NoSection )
333 QMetaEnum metaEnum = QMetaEnum::fromType<T>();
334 Q_ASSERT( metaEnum.isValid() );
335 if ( !metaEnum.isValid() )
337 QgsDebugMsg( QStringLiteral(
"Invalid metaenum. Enum probably misses Q_ENUM or Q_FLAG declaration." ) );
343 if ( metaEnum.isValid() )
346 QByteArray ba = value( key, metaEnum.valueToKeys( defaultValue ) ).toString().toUtf8();
347 const char *vs = ba.data();
348 v =
static_cast<T
>( metaEnum.keysToValue( vs, &ok ) );
355 v = T( value( key,
static_cast<int>( defaultValue ), section ).toInt( &ok ) );
356 if ( metaEnum.isValid() )
358 if ( !ok || metaEnum.valueToKeys(
static_cast<int>( v ) ).isEmpty() )
366 setFlagValue( key, v, section );
383 const Section section = NoSection )
385 QMetaEnum metaEnum = QMetaEnum::fromType<T>();
386 Q_ASSERT( metaEnum.isValid() );
387 if ( metaEnum.isValid() )
389 setValue( key, metaEnum.valueToKeys( value ), section );
393 QgsDebugMsg( QStringLiteral(
"Invalid metaenum. Enum probably misses Q_ENUM or Q_FLAG declaration." ) );
404 QString fileName()
const;
422 QString sanitizeKey(
const QString &key )
const;
423 QSettings *mUserSettings =
nullptr;
424 QSettings *mGlobalSettings =
nullptr;
425 bool mUsingGlobalArray =
false;
430 #endif // QGSSETTINGS_H