Index: sources/model/settings/MSettings.cpp =================================================================== diff -u -r94fc1cd187816ecbf176df26f9dc5601bf379f13 -r2216ac6ac7f77437a7c29ac8b4043be01bc4609e --- sources/model/settings/MSettings.cpp (.../MSettings.cpp) (revision 94fc1cd187816ecbf176df26f9dc5601bf379f13) +++ sources/model/settings/MSettings.cpp (.../MSettings.cpp) (revision 2216ac6ac7f77437a7c29ac8b4043be01bc4609e) @@ -52,6 +52,18 @@ return _settings[vGroup].keys; } +QString MSettings::key(const QString &vGroup, uint vIndex) +{ + QStringList mKeys = keys(vGroup); + QString mKey = "[Unknown %1]"; + if ( vIndex < (unsigned)mKeys.count() ) { + mKey = mKeys [vIndex]; + } else { + mKey = mKey.arg(vIndex); + } + return mKey; +} + /*! * \brief MSettings::values * \details returns all values in a group @@ -73,21 +85,50 @@ QString MSettings::location(const QString &vGroup) { QMutexLocker locker(&_mutex); - return _location[vGroup]; + return _settings[vGroup].location; } /*! + * \brief MSettings::groups + * \details The groups where have been read from the location vLocation + * \param vLocation - The location to look for the group(s) + * \return the groups in QString + */ +QStringList MSettings::groups(const QString &vCategory) +{ + QMutexLocker locker(&_mutex); + return _category[vCategory]; +} + +/*! + * \brief MSettings::categorys + * \details The list of all the categories in the setting + * \return the categories in QStringList + */ +QStringList MSettings::categorys() +{ + QMutexLocker locker(&_mutex); + return _category.keys(); +} + +/*! * \brief MSettings::add * \details The function to be used to add elements in the settings * \param vGroup - the group of the settings * \param vKey - the key to be added under the group vGroup * \param vValue - the value of the key to be added under group vGroup for the key vKey * \param vLocation - the location of the setting data if is different will be set. + * \param vLocation - the category of the setting data which by default is the base location if has extra folder + filename. */ -void MSettings::add(const QString &vGroup, const QString &vKey, const QVariant &vValue, const QString &vLocation) +void MSettings::add(const QString &vGroup, const QString &vKey, const QVariant &vValue, const QString &vLocation, const QString &vCategory) { QMutexLocker locker(&_mutex); - if ( ! _location.contains(vGroup) ) _location[vGroup] = vLocation; - _settings[vGroup].keys += vKey ; - _settings[vGroup].values += vValue; + if ( ! _category[vCategory].contains(vGroup) ) _category[vCategory] += vGroup; + + KeyValue mGroup = _settings[vGroup]; + if ( mGroup.location != vLocation ) mGroup.location = vLocation; + if ( mGroup.category != vCategory ) mGroup.category = vCategory; + mGroup.keys += vKey ; + mGroup.values += vValue ; + _settings[vGroup] = mGroup; }