The ApplicationSettings class enhances the functionality of QSettings, in particular it simplifies the way of working with either application-wide or account-specific settings.
More...
#include <ApplicationSettings.h>
|
| ApplicationSettings (const QString &settingsName={}) |
|
| ApplicationSettings (const Account &account, const QString &settingsName={}) |
|
| ApplicationSettings (const Account &account, const char *settingsName, const int settingsNameSize=-1) |
|
virtual | ~ApplicationSettings () override |
|
void | beginGroup (const QString &prefix) |
|
void | beginGroup (const char *prefix, const int size=-1) |
|
int | beginReadArray (const QString &prefix) |
|
int | beginReadArray (const char *prefix, const int size=-1) |
|
void | beginWriteArray (const QString &prefix, const int arraySize=-1) |
|
void | beginWriteArray (const char *prefix, const int arraySize=-1, const int prefixSize=-1) |
|
bool | contains (const QString &key) const |
|
bool | contains (const char *key, const int size=-1) const |
|
void | remove (const QString &key) |
|
void | remove (const char *key, const int size=-1) |
|
void | setValue (const QString &key, const QVariant &value) |
|
void | setValue (const char *key, const QVariant &value, const int keySize=-1) |
|
QVariant | value (const QString &key, const QVariant &defaultValue={}) const |
|
QVariant | value (const char *key, const QVariant &defaultValue={}, const int keySize=-1) const |
|
virtual QTextStream & | print (QTextStream &strm) const override |
|
virtual QTextStream & | print (QTextStream &strm) const =0 |
|
virtual const QString | toString () const |
|
The ApplicationSettings class enhances the functionality of QSettings, in particular it simplifies the way of working with either application-wide or account-specific settings.
◆ ApplicationSettings() [1/3]
quentier::ApplicationSettings::ApplicationSettings |
( |
const QString & |
settingsName = {} | ) |
|
Constructor for application settings not being account-specific
- Parameters
-
settingsName | If not empty, the created application settings would manage the settings stored in a file with a specific name within the common settings storage; otherwise they would be stored in the default settings file for the account |
◆ ApplicationSettings() [2/3]
quentier::ApplicationSettings::ApplicationSettings |
( |
const Account & |
account, |
|
|
const QString & |
settingsName = {} |
|
) |
| |
Constructor for application settings specific to the account
- Parameters
-
account | The account for which the settings are to be stored or read |
settingsName | If not empty, the created application settings would manage the settings stored in a file with a specific name within the account's settings storage; otherwise they would be stored in the default settings file for the account |
◆ ApplicationSettings() [3/3]
quentier::ApplicationSettings::ApplicationSettings |
( |
const Account & |
account, |
|
|
const char * |
settingsName, |
|
|
const int |
settingsNameSize = -1 |
|
) |
| |
Constructor for application settings specific to the account
- Parameters
-
account | The account for which the settings are to be stored or read |
settingsName | If not nullptr, the created application settings would manage the settings stored in a file with a specific name within the account's settings storage; otherwise they would be stored in the default settings file for the account. Must be UTF-8 encoded as internally it is converted to QString via QString::fromUtf8 |
settingsNameSize | Size of the settingsName string. If negative (the default), the settingsName size is taken to be strlen(settingsName) |
◆ ~ApplicationSettings()
virtual quentier::ApplicationSettings::~ApplicationSettings |
( |
| ) |
|
|
overridevirtual |
◆ beginGroup() [1/2]
void quentier::ApplicationSettings::beginGroup |
( |
const char * |
prefix, |
|
|
const int |
size = -1 |
|
) |
| |
Appends prefix to the current group. Overload of beginGroup accepting const char * and optionally the size of the string
- Parameters
-
prefix | String containing the prefix name. Must be UTF-8 encoded as internally it is converted to QString via QString::fromUtf8 |
size | Size of the prefix sring. If negative (the default), the prefix size is taken to be stren(prefix). |
◆ beginGroup() [2/2]
void quentier::ApplicationSettings::beginGroup |
( |
const QString & |
prefix | ) |
|
Appends prefix to the current group. The call is redirected to QSettings::beginGroup. It is required in this class only to workaround hiding QSettings method due to overloads
- Parameters
-
prefix | String containing the prefix name |
◆ beginReadArray() [1/2]
int quentier::ApplicationSettings::beginReadArray |
( |
const char * |
prefix, |
|
|
const int |
size = -1 |
|
) |
| |
Adds prefix to the current group and starts reading from an array. Overload of beginReadArray accepting const char * and optionally the size of the string
- Parameters
-
prefix | String containing the prefix name. Must be UTF-8 encoded as internally it is converted to QString via QString::fromUtf8 |
size | Size of the prefix sring. If negative (the default), the prefix size is taken to be stren(prefix) |
◆ beginReadArray() [2/2]
int quentier::ApplicationSettings::beginReadArray |
( |
const QString & |
prefix | ) |
|
Adds prefix to the current group and starts reading from an array. The call is redirected to QSettings::beginReadArray. It is required in this class only to workaround hiding QSettings method due to overloads
- Parameters
-
prefix | String containing the prefix name |
- Returns
- The size of the array
◆ beginWriteArray() [1/2]
void quentier::ApplicationSettings::beginWriteArray |
( |
const char * |
prefix, |
|
|
const int |
arraySize = -1 , |
|
|
const int |
prefixSize = -1 |
|
) |
| |
Adds prefix to the current group and starts writing an array of size arraySize. Overload of beginWriteArray accepting const char * and optionally the size of the string
- Parameters
-
prefix | String containing the prefix name. Must be UTF-8 encoded as internally it is converted to QString via QString::fromUtf8 |
arraySize | Size of the array to be written. If negative (the default), it is automatically determined based on the indexes of the entries written. |
prefixSize | Size of the prefix sring. If negative (the default), the prefix size is taken to be stren(prefix) |
◆ beginWriteArray() [2/2]
void quentier::ApplicationSettings::beginWriteArray |
( |
const QString & |
prefix, |
|
|
const int |
arraySize = -1 |
|
) |
| |
Adds prefix to the current group and starts writing an array of size arraySize. The call is redirected to QSettings::beginWriteArray. It is required in this class only to workaround hiding QSettings method due to overloads
- Parameters
-
prefix | String containing the prefix name |
arraySize | Size of the array to be written. If negative (the default), it is automatically determined based on the indexes of the entries written. |
◆ contains() [1/2]
bool quentier::ApplicationSettings::contains |
( |
const char * |
key, |
|
|
const int |
size = -1 |
|
) |
| const |
Overload of contains accepting const char * and optionally the size of the string
- Parameters
-
key | String containing the setting name. Must be UTF-8 encoded as internally it is converted to QString via QString::fromUtf8 |
size | Size of the key sring. If negative (the default), the key size is taken to be stren(key) |
- Returns
- True if there exists a setting called key; false otherwise
◆ contains() [2/2]
bool quentier::ApplicationSettings::contains |
( |
const QString & |
key | ) |
const |
The call is redirected to QSettings::contains. It is required in this class only to workaround hiding QSettings method due to overloads
- Parameters
-
key | The key being checked for presence |
- Returns
- True if there exists a setting called key; false otherwise
◆ print()
virtual QTextStream & quentier::ApplicationSettings::print |
( |
QTextStream & |
strm | ) |
const |
|
overridevirtual |
◆ remove() [1/2]
void quentier::ApplicationSettings::remove |
( |
const char * |
key, |
|
|
const int |
size = -1 |
|
) |
| |
Removes the setting key and any sub-settings of key. Overload of remove accepting const char * and optionally the size of the string
- Parameters
-
key | String containing the setting name. Must be UTF-8 encoded as internally it is converted to QString via QString::fromUtf8 |
size | Size of the key sring. If negative (the default), the key size is taken to be stren(key). |
◆ remove() [2/2]
void quentier::ApplicationSettings::remove |
( |
const QString & |
key | ) |
|
Removes the setting key and any sub-settings of key. The call is redirected to QSettings::remove. It is required in this class only to workaround hiding QSettings method due to overloads
- Parameters
-
key | String containing the setting name |
◆ setValue() [1/2]
void quentier::ApplicationSettings::setValue |
( |
const char * |
key, |
|
|
const QVariant & |
value, |
|
|
const int |
keySize = -1 |
|
) |
| |
Sets the value of setting. Overload of setValue accepting const char * and optionally the size of the string
- Parameters
-
key | String containing the setting name. Must be UTF-8 encoded as internally it is converted to QString via QString::fromUtf8 |
value | Value for setting key |
keySize | Size of the key string. If negative (the default), the key size is taken to be strlen(key). |
◆ setValue() [2/2]
void quentier::ApplicationSettings::setValue |
( |
const QString & |
key, |
|
|
const QVariant & |
value |
|
) |
| |
Sets the value of setting. The call is redirected to QSettings::setValue. It is required in this class only to workaround hiding QSettings method due to overloads
- Parameters
-
key | String containing the setting name |
value | Value for setting key |
◆ value() [1/2]
QVariant quentier::ApplicationSettings::value |
( |
const char * |
key, |
|
|
const QVariant & |
defaultValue = {} , |
|
|
const int |
keySize = -1 |
|
) |
| const |
Fetches the value of setting. Overload of value accepting const char * and optionally the size of the string
- Parameters
-
key | String containing the setting name. Must be UTF-8 encoded as internally it is converted to QString via QString::fromUtf8 |
defautValue | Default value returned if the setting doesn't exist |
keySize | Size of the key sring. If negative (the default), the key size is taken to be stren(key) |
- Returns
- The value for setting key. If the setting doesn't exist, returns defaultValue. If no default value is specified, a default QVariant is returned.
◆ value() [2/2]
QVariant quentier::ApplicationSettings::value |
( |
const QString & |
key, |
|
|
const QVariant & |
defaultValue = {} |
|
) |
| const |
Fetches the value of setting. The call is redirected to QSettings::value. It is required in this class only to workaround hiding QSettings method due to overloads
- Parameters
-
key | String containing the setting name |
defautValue | Default value returned if the setting doesn't exist |
- Returns
- The value for setting key. If the setting doesn't exist, returns defaultValue. If no default value is specified, a default QVariant is returned.