22#include <QRegularExpression> 
   27  : mParentTreeElement( parent )
 
   29  , mDefaultValue( defaultValue )
 
   30  , mDescription( description )
 
 
   43  if ( mParentTreeElement )
 
 
   49  return QString::fromUtf8( sSettingsTypeMetaEnum.valueToKey( 
static_cast<int>( 
settingsType() ) ) );
 
 
   60  return completeKeyPrivate( mKey, dynamicKeyPartList );
 
 
   63QString QgsSettingsEntryBase::completeKeyPrivate( 
const QString &key, 
const QStringList &dynamicKeyPartList )
 const 
   65  QString completeKey = 
key;
 
   67  if ( dynamicKeyPartList.isEmpty() )
 
   70      QgsDebugError( QStringLiteral( 
"Settings '%1' have a dynamic key but the dynamic key part was not provided" ).arg( completeKey ) );
 
   78      QgsDebugError( QStringLiteral( 
"Settings '%1' don't have a dynamic key, the provided dynamic key part will be ignored" ).arg( completeKey ) );
 
   82    for ( 
int i = 0; i < dynamicKeyPartList.size(); i++ )
 
   84      completeKey.replace( QStringLiteral( 
"%" ).append( QString::number( i + 1 ) ), dynamicKeyPartList.at( i ) );
 
  100  const thread_local QRegularExpression digitRx( QStringLiteral( 
"%\\d+" ) );
 
  101  const QRegularExpression regularExpression( 
definitionKey().replace( digitRx, QStringLiteral( 
".*" ) ) );
 
  102  const QRegularExpressionMatch regularExpressionMatch = regularExpression.match( 
key );
 
  103  return regularExpressionMatch.hasMatch();
 
 
  113  const thread_local QRegularExpression regularExpression( QStringLiteral( 
"%\\d+" ) );
 
  114  return mKey.contains( regularExpression );
 
 
  158    if ( 
exists( dynamicKeyPartList ) )
 
  161      if ( value != currentValue )
 
  163        settings->setValue( formerValuekey( dynamicKeyPartList ), currentValue );
 
  167  settings->setValue( 
key( dynamicKeyPartList ), value );
 
 
  173  QStringList dynamicKeyPartList;
 
  174  if ( !dynamicKeyPart.isNull() )
 
  175    dynamicKeyPartList.append( dynamicKeyPart );
 
  176  return dynamicKeyPartList;
 
 
  198  if ( useDefaultValueOverride )
 
 
  216  return mDefaultValue;
 
 
  240  const QString oldCompleteKey = completeKeyPrivate( 
key, dynamicKeyPartList );
 
  242  if ( settings->contains( oldCompleteKey ) )
 
  244    if ( !
exists( dynamicKeyPartList ) )
 
  246      QVariant oldValue = settings->value( oldCompleteKey, mDefaultValue );
 
  251    if ( removeSettingAtKey )
 
  252      settings->remove( oldCompleteKey );
 
 
  261  const QString completeKey = completeKeyPrivate( 
key, dynamicKeyPartList );
 
 
  273QString QgsSettingsEntryBase::formerValuekey( 
const QStringList &dynamicKeyPartList )
 const 
  275  return key( dynamicKeyPartList ) + QStringLiteral( 
"_formervalue" );
 
@ SaveFormerValue
Save the former value of the settings.
 
QFlags< SettingsOption > SettingsOptions
 
SettingsOrigin
The setting origin describes where a setting is stored.
 
virtual QString typeId() const
Returns the id of the type of settings This can be re-implemented in a custom implementation of a set...
 
bool copyValueFromKey(const QString &key, bool removeSettingAtKey=false) const
Copies the value from a given key if it exists.
 
bool exists(const QString &dynamicKeyPart=QString()) const
Returns true if the settings is contained in the underlying QSettings.
 
bool hasChanged() const
Returns true if the setting was changed during the current QGIS session.
 
QVariant defaultValueAsVariant() const
Returns settings default value.
 
bool keyIsValid(const QString &key) const
Returns true if the provided key match the settings entry.
 
QString description() const
Returns the settings entry description.
 
QgsSettingsTreeNode * parent() const
Returns the parent tree element.
 
void copyValueToKeyIfChanged(const QString &key, const QStringList &dynamicKeyPartList=QStringList()) const
Copies the settings to the given key, if it has changed during the current QGIS session (see hasChang...
 
virtual ~QgsSettingsEntryBase()
 
Q_DECL_DEPRECATED int section() const
Returns settings section.
 
Qgis::SettingsOrigin origin(const QStringList &dynamicKeyPartList) const
Returns the origin of the setting if it exists.
 
bool hasDynamicKey() const
Returns true if a part of the settings key is built dynamically.
 
void remove(const QString &dynamicKeyPart=QString()) const
Removes the settings from the underlying QSettings.
 
bool setVariantValue(const QVariant &value, const QString &dynamicKeyPart=QString()) const
Set settings value.
 
QString definitionKey() const
Returns settings entry defining key.
 
QVariant formerValueAsVariant(const QString &dynamicKeyPart) const
Returns the former value of the settings if it has been enabled in the options.
 
QVariant valueAsVariant(const QString &dynamicKeyPart=QString()) const
Returns settings value with.
 
void copyValueToKey(const QString &key, const QStringList &dynamicKeyPartList=QStringList()) const
Copies the settings to the given key.
 
QString key(const QString &dynamicKeyPart=QString()) const
Returns settings entry key.
 
static QStringList dynamicKeyPartToList(const QString &dynamicKeyPart)
Transforms a dynamic key part string to list.
 
QVariant valueAsVariantWithDefaultOverride(const QVariant &defaultValueOverride, const QString &dynamicKeyPart=QString()) const
Returns settings value with a defaultValueOverride.
 
virtual Qgis::SettingsType settingsType() const
Returns the settings entry type.
 
QgsSettingsEntryBase(const QString &key, const QString §ion, const QVariant &defaultValue=QVariant(), const QString &description=QString(), Qgis::SettingsOptions options=Qgis::SettingsOptions())
Constructor for QgsSettingsEntryBase.
 
A tree node for the settings tree to help organizing and introspecting the tree.
 
QString completeKey() const
Returns the complete key of the node (including its parents)
 
void unregisterChildSetting(const QgsSettingsEntryBase *setting, bool deleteSettingValues=false, const QStringList &parentsNamedItems=QStringList())
Unregisters the child setting.
 
void registerChildSetting(const QgsSettingsEntryBase *setting, const QString &key)
Registers a child setting.
 
Qgis::SettingsOrigin origin(const QString &key) const
Returns the origin of the setting if it exists at the given key.
 
QVariant value(const QString &key, const QVariant &defaultValue=QVariant(), Section section=NoSection) const
Returns the value for setting key.
 
bool contains(const QString &key, QgsSettings::Section section=QgsSettings::NoSection) const
Returns true if there exists a setting called key; returns false otherwise.
 
void remove(const QString &key, QgsSettings::Section section=QgsSettings::NoSection)
Removes the setting key and any sub-settings of key in a section.
 
void setValue(const QString &key, const QVariant &value, QgsSettings::Section section=QgsSettings::NoSection)
Sets the value of setting key to value.
 
static QgsSettingsProxy get()
Returns a proxy for a QgsSettings object.
 
#define Q_NOWARN_DEPRECATED_POP
 
#define Q_NOWARN_DEPRECATED_PUSH
 
#define QgsDebugError(str)