Add section in beginGroup and remove Setting.

This commit is contained in:
Ismail Sunni 2017-09-08 06:39:48 +07:00
parent f9f5aafaf4
commit 0c7c494831
No known key found for this signature in database
GPG Key ID: B1631436E69FA4D2
3 changed files with 13 additions and 11 deletions

View File

@ -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.
@ -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

View File

@ -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 );
}
}
@ -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

View File

@ -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.
@ -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