![]() |
Scanframe Modular Application 0.1.0
|
Class to store application configuration. Uses the global application settings or a given ini-file. More...
#include <ConfigStore.h>
Classes | |
class | Scope |
Begins and ends a scope of settings for a section. When create it calls beginGroup(...) and when out of scop it calls endGroup(). More... | |
class | Values |
Type to create a string list accessible by keys. More... | |
Public Member Functions | |
ConfigStore (bool app=false) | |
Constructor initializing the instance using ApplicationSettings::global().getNewSettings(). | |
ConfigStore (const ConfigStore &cs) | |
Copy constructor. Creates a duplicate instance of the passed config store. | |
ConfigStore (const QString &filepath, QSettings::Format format) | |
Constructor creating. | |
ConfigStore (const QSettings &settings) | |
Constructor creating a copy of a passed store. | |
ConfigStore (ConfigStore &&) noexcept | |
Move constructor. | |
ConfigStore & | operator= (const ConfigStore &) noexcept |
Copy operator. | |
ConfigStore & | operator= (ConfigStore &&) noexcept |
Move operator. | |
~ConfigStore () | |
Overridden destructor. | |
ConfigStore & | assign (const ConfigStore &cs) |
Initializes this store with the passed instance. | |
ConfigStore & | setPath (const QString &filepath) |
Initializes this store with the passed ini-filepath. | |
QSettings & | operator() () |
Operator to get access to underlying QSettings object of this instance. | |
QString | getPath () const |
Gets the path of the current instance. | |
QByteArray | getByteArray (QAnyStringView section, QAnyStringView key, QByteArray def={}) const |
Gets a section's byte array value from the store. | |
void | setByteArray (QAnyStringView section, QAnyStringView key, const QByteArray &value) |
Sets a section's byte array value in the store. | |
QString | getString (QAnyStringView section, QAnyStringView key, QAnyStringView def={}) const |
Gets a section's string value from the store. | |
void | setString (QAnyStringView section, QAnyStringView key, QAnyStringView value) |
Sets a section's string value in the store. | |
QStringList | getStringList (QAnyStringView section, QAnyStringView key, const QStringList &def={}) const |
Gets a section's string-list value from the store. | |
void | setStringList (QAnyStringView section, QAnyStringView key, const QStringList &value) |
Sets a section's string-list value in the store. | |
std::string | getStdString (const std::string §ion, const std::string &key, const std::string &def={}) const |
Gets a section's value from the store. | |
void | setStdString (const std::string §ion, const std::string &key, const std::string &value) |
Sets a section value in the store. | |
bool | getBool (QAnyStringView section, QAnyStringView key, bool def) const |
Gets a section value from the store. | |
void | setBool (QAnyStringView section, QAnyStringView key, bool value) |
Sets a section value in the store. | |
double | getFloat (QAnyStringView section, QAnyStringView key, double def) const |
Gets a section value from the store. | |
void | setFloat (QAnyStringView section, QAnyStringView key, double value) |
Sets a section value in the store. | |
int | getInt (QAnyStringView section, QAnyStringView key, int def=0) const |
Gets a section value from the store. | |
void | setInt (QAnyStringView section, QAnyStringView key, int value) |
Sets a section integer value in the store. | |
QVariant | getValue (QAnyStringView section, QAnyStringView key) const |
Gets a section value from the store. | |
QVariant | getValue (QAnyStringView section, QAnyStringView key, const QVariant &def) const |
Gets a section value from the store. | |
void | setValue (QAnyStringView section, QAnyStringView key, const QVariant &value) |
Sets a section QVariant value in the store. | |
void | storeWindow (QAnyStringView section, QAnyStringView key, QWidget *widget, bool rd) |
Stores or restores the window position and size from the settings file onto the passed widget. | |
void | storeTreeView (QAnyStringView section, QAnyStringView name, const QTreeView *tv, bool rd) |
Stores or restores column widths of a QTreeView. | |
void | getKeys (QAnyStringView section, QStringList &keys) const |
Gets all keys from the given section. | |
QStringList | getKeys (QAnyStringView section) const |
Gets all keys from the given section. | |
void | removeKeys (QAnyStringView section) |
Deletes the keys but keeps the group/section. | |
void | removeSection (QAnyStringView section) |
Deletes all keys including the section. | |
bool | isSection (QAnyStringView section) const |
Check if a section exists. | |
void | removeKey (QAnyStringView section, QAnyStringView key) |
Removes the given key from the store. | |
void | setSectionValues (QAnyStringView section, const Values &values) |
Replaces the section content with the given key-values. | |
void | getSectionValues (QAnyStringView section, Values &values) const |
Gets the section content as mapped key-values. | |
QStringList | getSections () const |
Gets all sections from the store in a list. | |
bool | exists () |
Checks if the path exists. | |
void | setSectionOffset (QAnyStringView section) |
Sets a section offset call QSettings::beginGroup(). | |
void | setSectionDefault (QAnyStringView section) |
Sets default section when the given section is empty '{}'. | |
QString | getSectionDefault () |
Gets default section when the given section is empty '{}'. | |
QSettings & | settings () |
Gets a reference to the settings currently used by this instance. | |
Scope | scope (QAnyStringView section) |
Adds a section onto the stack of section. | |
Class to store application configuration. Uses the global application settings or a given ini-file.
|
explicit |
Constructor initializing the instance using ApplicationSettings::global().getNewSettings().
|
explicit |
Copy constructor. Creates a duplicate instance of the passed config store.
|
explicit |
Constructor creating.
filepath | Path to the configuration file. |
format | Like QSettings::IniFormat |
|
explicit |
Constructor creating a copy of a passed store.
settings | Settings instance to initialize with. |
|
explicitnoexcept |
Move constructor.
sf::ConfigStore::~ConfigStore | ( | ) |
Overridden destructor.
ConfigStore & sf::ConfigStore::assign | ( | const ConfigStore & | cs | ) |
Initializes this store with the passed instance.
bool sf::ConfigStore::exists | ( | ) |
Checks if the path exists.
bool sf::ConfigStore::getBool | ( | QAnyStringView | section, |
QAnyStringView | key, | ||
bool | def | ||
) | const |
Gets a section value from the store.
section | When empty '{}' the default section is used. |
key | Name of the key to get. |
def | Default value when the key is not found in the store. |
QByteArray sf::ConfigStore::getByteArray | ( | QAnyStringView | section, |
QAnyStringView | key, | ||
QByteArray | def = {} |
||
) | const |
Gets a section's byte array value from the store.
section | When empty '{}' the default section is used. |
key | Name of the key to get. |
def | Default value when the key is not found in the store. |
double sf::ConfigStore::getFloat | ( | QAnyStringView | section, |
QAnyStringView | key, | ||
double | def | ||
) | const |
Gets a section value from the store.
section | When empty '{}' the default section is used. |
key | Name of the key to get. |
def | Default value when the key is not found in the store. |
int sf::ConfigStore::getInt | ( | QAnyStringView | section, |
QAnyStringView | key, | ||
int | def = 0 |
||
) | const |
Gets a section value from the store.
section | When empty '{}' the default section is used. |
key | Name of the key to get. |
def | Default value when the key is not found in the store. |
QStringList sf::ConfigStore::getKeys | ( | QAnyStringView | section | ) | const |
Gets all keys from the given section.
section | Section containing the keys. |
void sf::ConfigStore::getKeys | ( | QAnyStringView | section, |
QStringList & | keys | ||
) | const |
Gets all keys from the given section.
section | Section containing the keys. |
keys | Return value. |
QString sf::ConfigStore::getPath | ( | ) | const |
Gets the path of the current instance.
QString sf::ConfigStore::getSectionDefault | ( | ) |
Gets default section when the given section is empty '{}'.
QStringList sf::ConfigStore::getSections | ( | ) | const |
Gets all sections from the store in a list.
void sf::ConfigStore::getSectionValues | ( | QAnyStringView | section, |
Values & | values | ||
) | const |
Gets the section content as mapped key-values.
section | Name of the section. |
values | Key and value map. |
std::string sf::ConfigStore::getStdString | ( | const std::string & | section, |
const std::string & | key, | ||
const std::string & | def = {} |
||
) | const |
Gets a section's value from the store.
section | When empty '{}' the default section is used. |
key | Name of the key to get. |
def | Default value when the key is not found in the store. |
QString sf::ConfigStore::getString | ( | QAnyStringView | section, |
QAnyStringView | key, | ||
QAnyStringView | def = {} |
||
) | const |
Gets a section's string value from the store.
section | When empty '{}' the default section is used. |
key | Name of the key to get. |
def | Default value when the key is not found in the store. |
QStringList sf::ConfigStore::getStringList | ( | QAnyStringView | section, |
QAnyStringView | key, | ||
const QStringList & | def = {} |
||
) | const |
Gets a section's string-list value from the store.
section | When empty '{}' the default section is used. |
key | Name of the key to get. |
def | Default value when the key is not found in the store. |
QVariant sf::ConfigStore::getValue | ( | QAnyStringView | section, |
QAnyStringView | key | ||
) | const |
Gets a section value from the store.
section | When empty '{}' the default section is used. |
key | Name of the key to get. |
QVariant sf::ConfigStore::getValue | ( | QAnyStringView | section, |
QAnyStringView | key, | ||
const QVariant & | def | ||
) | const |
Gets a section value from the store.
section | When empty '{}' the default section is used. |
key | Name of the key to get. |
def | Default value when the key is not found in the store. |
bool sf::ConfigStore::isSection | ( | QAnyStringView | section | ) | const |
Check if a section exists.
section | Name of the section. |
QSettings & sf::ConfigStore::operator() | ( | ) |
Operator to get access to underlying QSettings object of this instance.
|
noexcept |
Move operator.
|
noexcept |
Copy operator.
void sf::ConfigStore::removeKey | ( | QAnyStringView | section, |
QAnyStringView | key | ||
) |
Removes the given key from the store.
section | |
key |
void sf::ConfigStore::removeKeys | ( | QAnyStringView | section | ) |
Deletes the keys but keeps the group/section.
section |
void sf::ConfigStore::removeSection | ( | QAnyStringView | section | ) |
Deletes all keys including the section.
section |
Scope sf::ConfigStore::scope | ( | QAnyStringView | section | ) |
Adds a section onto the stack of section.
section | Section or group name added. |
void sf::ConfigStore::setBool | ( | QAnyStringView | section, |
QAnyStringView | key, | ||
bool | value | ||
) |
Sets a section value in the store.
section | When empty '{}' the default section is used. |
key | Name of the key to set. |
value | Value to set. |
void sf::ConfigStore::setByteArray | ( | QAnyStringView | section, |
QAnyStringView | key, | ||
const QByteArray & | value | ||
) |
Sets a section's byte array value in the store.
section | When empty '{}' the default section is used. |
key | Name of the key to set. |
value | Value to set. |
void sf::ConfigStore::setFloat | ( | QAnyStringView | section, |
QAnyStringView | key, | ||
double | value | ||
) |
Sets a section value in the store.
section | When empty '{}' the default section is used. |
key | Name of the key to set. |
value | Value to set. |
void sf::ConfigStore::setInt | ( | QAnyStringView | section, |
QAnyStringView | key, | ||
int | value | ||
) |
Sets a section integer value in the store.
section | When empty '{}' the default section is used. |
key | Name of the key to set. |
value | Value to set. |
ConfigStore & sf::ConfigStore::setPath | ( | const QString & | filepath | ) |
Initializes this store with the passed ini-filepath.
void sf::ConfigStore::setSectionDefault | ( | QAnyStringView | section | ) |
Sets default section when the given section is empty '{}'.
section |
void sf::ConfigStore::setSectionOffset | ( | QAnyStringView | section | ) |
Sets a section offset call QSettings::beginGroup().
section | When empty the only QSettings::endGroup() is called. |
void sf::ConfigStore::setSectionValues | ( | QAnyStringView | section, |
const Values & | values | ||
) |
Replaces the section content with the given key-values.
section | Name of the section. |
values | Key and value map. |
void sf::ConfigStore::setStdString | ( | const std::string & | section, |
const std::string & | key, | ||
const std::string & | value | ||
) |
Sets a section value in the store.
section | When empty '{}' the default section is used. |
key | Name of the key to set. |
value | Value to set. |
void sf::ConfigStore::setString | ( | QAnyStringView | section, |
QAnyStringView | key, | ||
QAnyStringView | value | ||
) |
Sets a section's string value in the store.
section | When empty '{}' the default section is used. |
key | Name of the key to set. |
value | Value to set. |
void sf::ConfigStore::setStringList | ( | QAnyStringView | section, |
QAnyStringView | key, | ||
const QStringList & | value | ||
) |
Sets a section's string-list value in the store.
section | When empty '{}' the default section is used. |
key | Name of the key to set. |
value | Value to set. |
QSettings & sf::ConfigStore::settings | ( | ) |
Gets a reference to the settings currently used by this instance.
void sf::ConfigStore::setValue | ( | QAnyStringView | section, |
QAnyStringView | key, | ||
const QVariant & | value | ||
) |
Sets a section QVariant value in the store.
section | When empty '{}' the default section is used. |
key | Name of the key to set. |
value | Value to set. |
void sf::ConfigStore::storeTreeView | ( | QAnyStringView | section, |
QAnyStringView | name, | ||
const QTreeView * | tv, | ||
bool | rd | ||
) |
Stores or restores column widths of a QTreeView.
section | Section containing the keys. |
name | Name of the treeview to use as a key prefix. |
tv | Pointer to the tree view. |
rd | When true it reads and false it writes the storage location. |
void sf::ConfigStore::storeWindow | ( | QAnyStringView | section, |
QAnyStringView | key, | ||
QWidget * | widget, | ||
bool | rd | ||
) |
Stores or restores the window position and size from the settings file onto the passed widget.
section | Section containing the keys. |
key | Name of the window to use a key prefix. |
widget | Window widget. |
rd | When true it read from the storage location. |