23 #include "qgis_core.h"
90 static const inline char *APP_GEOREFERENCER =
"app/georeferencer";
91 static const inline char *CORE =
"core";
92 static const inline char *CORE_LAYOUT =
"core/Layout";
93 static const inline char *GEOMETRYVALIDATION =
"geometry_validation";
94 static const inline char *GPS =
"gps";
95 static const inline char *GUI_LOCATORFILTERS =
"gui/locator_filters";
96 static const inline char *GUI_QGIS =
"gui/qgis";
97 static const inline char *LOCALE =
"locale";
98 static const inline char *MAP =
"Map";
99 static const inline char *PLUGINS =
"plugins";
100 static const inline char *PROCESSING_CONFIGURATION =
"Processing/Configuration";
101 static const inline char *
QGIS =
"qgis";
102 static const inline char *QGIS_DIGITIZING =
"qgis/digitizing";
103 static const inline char *QGIS_DIGITIZING_SHAPEMAPTOOLS =
"qgis/digitizing/shape-map-tools";
104 static const inline char *QGIS_NETWORKANDPROXY =
"qgis/networkAndProxy";
105 static const inline char *SVG =
"svg";
106 static const inline char *ELEVATION_PROFILE =
"elevation-profile";
107 static const inline char *CORE_LAYERTREE =
"core/layer-tree";
108 static const inline char *STYLE_MANAGER =
"app/style-manager";
116 const QString &application = QString(), QObject *parent =
nullptr );
132 QgsSettings( QSettings::Scope scope,
const QString &organization,
133 const QString &application = QString(), QObject *parent =
nullptr );
149 QgsSettings( QSettings::Format format, QSettings::Scope scope,
const QString &organization,
150 const QString &application = QString(), QObject *parent =
nullptr );
172 QgsSettings(
const QString &fileName, QSettings::Format format, QObject *parent =
nullptr );
202 QString group()
const;
205 QStringList allKeys()
const;
207 QStringList childKeys()
const;
209 QStringList childGroups()
const;
211 QStringList globalChildGroups()
const;
213 static QString globalSettingsPath();
215 static bool setGlobalSettingsPath(
const QString &path );
217 int beginReadArray(
const QString &prefix );
224 void beginWriteArray(
const QString &prefix,
int size = -1 );
232 void setArrayIndex(
int i );
247 QVariant value(
const QString &key,
const QVariant &defaultValue = QVariant(),
248 Section section = NoSection )
const;
250 SIP_PYOBJECT value(
const QString &key,
const QVariant &defaultValue = QVariant(),
251 SIP_PYOBJECT type = 0,
254 typedef PyObject *( *pyqt5_from_qvariant_by_type )( QVariant &value, PyObject *type );
258 Py_BEGIN_ALLOW_THREADS
259 value = sipCpp->value( *a0, *a1, a3 );
262 pyqt5_from_qvariant_by_type f = ( pyqt5_from_qvariant_by_type ) sipImportSymbol(
"pyqt5_from_qvariant_by_type" );
263 sipRes = f( value, a2 );
283 const Section section = NoSection )
285 const QMetaEnum metaEnum = QMetaEnum::fromType<T>();
286 Q_ASSERT( metaEnum.isValid() );
287 if ( !metaEnum.isValid() )
289 QgsDebugMsg( QStringLiteral(
"Invalid metaenum. Enum probably misses Q_ENUM or Q_FLAG declaration." ) );
295 if ( metaEnum.isValid() )
298 QByteArray ba = value( key, metaEnum.valueToKey(
static_cast<const int>( defaultValue ) ), section ).toString().toUtf8();
299 const char *vs = ba.data();
300 v =
static_cast<T
>( metaEnum.keyToValue( vs, &ok ) );
308 v =
static_cast<T
>( value( key,
static_cast<const int>( defaultValue ), section ).toInt( &ok ) );
309 if ( metaEnum.isValid() )
311 if ( !ok || !metaEnum.valueToKey(
static_cast<int>( v ) ) )
319 setEnumValue( key, v, section );
335 const Section section = NoSection )
337 const QMetaEnum metaEnum = QMetaEnum::fromType<T>();
338 Q_ASSERT( metaEnum.isValid() );
339 if ( metaEnum.isValid() )
341 setValue( key, metaEnum.valueToKey(
static_cast<const int>( value ) ), section );
345 QgsDebugMsg( QStringLiteral(
"Invalid metaenum. Enum probably misses Q_ENUM or Q_FLAG declaration." ) );
361 const Section section = NoSection )
363 const QMetaEnum metaEnum = QMetaEnum::fromType<T>();
364 Q_ASSERT( metaEnum.isValid() );
365 if ( !metaEnum.isValid() )
367 QgsDebugMsg( QStringLiteral(
"Invalid metaenum. Enum probably misses Q_ENUM or Q_FLAG declaration." ) );
373 if ( metaEnum.isValid() )
376 QByteArray ba = value( key, metaEnum.valueToKeys(
static_cast< const int >( defaultValue ) ) ).toString().toUtf8();
377 const char *vs = ba.data();
378 v =
static_cast<T
>( metaEnum.keysToValue( vs, &ok ) );
383 const int intValue = value( key,
static_cast<const int>( defaultValue ), section ).toInt( &ok );
384 if ( metaEnum.isValid() )
390 const QByteArray keys = metaEnum.valueToKeys( intValue );
391 const int intValueCheck = metaEnum.keysToValue( keys );
392 if ( intValue != intValueCheck )
403 setFlagValue( key, v );
425 const Section section = NoSection )
427 const QMetaEnum metaEnum = QMetaEnum::fromType<T>();
428 Q_ASSERT( metaEnum.isValid() );
429 if ( metaEnum.isValid() )
431 setValue( key, metaEnum.valueToKeys(
static_cast< const int >( value ) ), section );
435 QgsDebugMsg( QStringLiteral(
"Invalid metaenum. Enum probably misses Q_ENUM or Q_FLAG declaration." ) );
446 QString fileName()
const;
464 QString sanitizeKey(
const QString &key )
const;
465 QSettings *mUserSettings =
nullptr;
466 QSettings *mGlobalSettings =
nullptr;
467 bool mUsingGlobalArray =
false;
472 #endif // QGSSETTINGS_H