Skip to content

Commit

Permalink
Add section in beginGroup and remove Setting.
Browse files Browse the repository at this point in the history
  • Loading branch information
ismailsunni committed Sep 28, 2017
1 parent f9f5aaf commit 0c7c494
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 11 deletions.
6 changes: 3 additions & 3 deletions python/core/qgssettings.sip
Expand Up @@ -130,7 +130,7 @@ class QgsSettings : QObject
%End
~QgsSettings();

void beginGroup( const QString &prefix );
void beginGroup( const QString &prefix, const QgsSettings::Section section = QgsSettings::NoSection );
%Docstring
Appends prefix to the current group.
The current group is automatically prepended to all keys specified to QSettings.
Expand Down Expand Up @@ -245,9 +245,9 @@ Returns the path where settings written using this QSettings object are stored.
This function is called automatically from QSettings's destructor and by the event
loop at regular intervals, so you normally don't need to call it yourself.
%End
void remove( const QString &key );
void remove( const QString &key, const QgsSettings::Section section = QgsSettings::NoSection );
%Docstring
Removes the setting key and any sub-settings of key.
Removes the setting key and any sub-settings of key in a section.
%End
QString prefixedKey( const QString &key, const QgsSettings::Section section ) const;
%Docstring
Expand Down
12 changes: 7 additions & 5 deletions src/core/qgssettings.cpp
Expand Up @@ -83,12 +83,13 @@ QgsSettings::~QgsSettings()
}


void QgsSettings::beginGroup( const QString &prefix )
void QgsSettings::beginGroup( const QString &prefix, const QgsSettings::Section section )
{
mUserSettings->beginGroup( sanitizeKey( prefix ) );
QString pKey = prefixedKey( prefix, section );
mUserSettings->beginGroup( pKey );
if ( mGlobalSettings )
{
mGlobalSettings->beginGroup( sanitizeKey( prefix ) );
mGlobalSettings->beginGroup( pKey );
}
}

Expand Down Expand Up @@ -191,9 +192,10 @@ void QgsSettings::sync()
return mUserSettings->sync();
}

void QgsSettings::remove( const QString &key )
void QgsSettings::remove( const QString &key, const QgsSettings::Section section )
{
mUserSettings->remove( sanitizeKey( key ) );
QString pKey = prefixedKey( key, section );
mUserSettings->remove( pKey );
}

QString QgsSettings::prefixedKey( const QString &key, const Section section ) const
Expand Down
6 changes: 3 additions & 3 deletions src/core/qgssettings.h
Expand Up @@ -141,7 +141,7 @@ class CORE_EXPORT QgsSettings : public QObject
* In addition, query functions such as childGroups(), childKeys(), and allKeys()
* are based on the group. By default, no group is set.
*/
void beginGroup( const QString &prefix );
void beginGroup( const QString &prefix, const QgsSettings::Section section = QgsSettings::NoSection );
//! Resets the group to what it was before the corresponding beginGroup() call.
void endGroup();
//! Returns a list of all keys, including subkeys, that can be read using the QSettings object.
Expand Down Expand Up @@ -218,8 +218,8 @@ class CORE_EXPORT QgsSettings : public QObject
* loop at regular intervals, so you normally don't need to call it yourself.
*/
void sync();
//! Removes the setting key and any sub-settings of key.
void remove( const QString &key );
//! Removes the setting key and any sub-settings of key in a section.
void remove( const QString &key, const QgsSettings::Section section = QgsSettings::NoSection );
//! Return the sanitized and prefixed key
QString prefixedKey( const QString &key, const QgsSettings::Section section ) const;
//! Removes all entries in the user settings
Expand Down

0 comments on commit 0c7c494

Please sign in to comment.