libquentier 0.8.0
The library for rich desktop clients of Evernote service
Loading...
Searching...
No Matches
Classes | Public Member Functions | List of all members
quentier::ApplicationSettings Class Reference

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>

Inheritance diagram for quentier::ApplicationSettings:
Inheritance graph
[legend]
Collaboration diagram for quentier::ApplicationSettings:
Collaboration graph
[legend]

Classes

struct  ArrayCloser
 
struct  GroupCloser
 

Public Member Functions

 ApplicationSettings (const QString &settingsName={})
 
 ApplicationSettings (const Account &account, const QString &settingsName={})
 
 ApplicationSettings (const Account &account, const char *settingsName, int settingsNameSize=-1)
 
 ApplicationSettings (const Account &account, std::string_view settingsName)
 
 ~ApplicationSettings () override
 
void beginGroup (const QString &prefix)
 
void beginGroup (const char *prefix, int size=-1)
 
void beginGroup (std::string_view prefix)
 
int beginReadArray (const QString &prefix)
 
int beginReadArray (const char *prefix, int size=-1)
 
int beginReadArray (std::string_view prefix)
 
void beginWriteArray (const QString &prefix, int arraySize=-1)
 
void beginWriteArray (const char *prefix, int arraySize=-1, int prefixSize=-1)
 
void beginWriteArray (std::string_view prefix, int arraySize=-1)
 
bool contains (const QString &key) const
 
bool contains (const char *key, int size=-1) const
 
bool contains (std::string_view key) const
 
void remove (const QString &key)
 
void remove (const char *key, int size=-1)
 
void remove (std::string_view key)
 
void setValue (const QString &key, const QVariant &value)
 
void setValue (const char *key, const QVariant &value, int keySize=-1)
 
void setValue (std::string_view key, const QVariant &value)
 
QVariant value (const QString &key, const QVariant &defaultValue={}) const
 
QVariant value (const char *key, const QVariant &defaultValue={}, int keySize=-1) const
 
QVariant value (std::string_view key, const QVariant &defaultValue={}) const
 
QTextStreamprint (QTextStream &strm) const override
 
- Public Member Functions inherited from quentier::Printable
QString toString () const
 

Detailed Description

The ApplicationSettings class enhances the functionality of QSettings, in particular it simplifies the way of working with either application-wide or account-specific settings.

Constructor & Destructor Documentation

◆ ApplicationSettings() [1/4]

quentier::ApplicationSettings::ApplicationSettings ( const QString settingsName = {})
explicit

Constructor for application settings not being account-specific

Parameters
settingsNameIf 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/4]

quentier::ApplicationSettings::ApplicationSettings ( const Account account,
const QString settingsName = {} 
)
explicit

Constructor for application settings specific to the account

Parameters
accountThe account for which the settings are to be stored or read
settingsNameIf 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/4]

quentier::ApplicationSettings::ApplicationSettings ( const Account account,
const char settingsName,
int  settingsNameSize = -1 
)

Constructor for application settings specific to the account

Parameters
accountThe account for which the settings are to be stored or read
settingsNameIf 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
settingsNameSizeSize of the settingsName string. If negative (the default), the settingsName size is taken to be strlen(settingsName)

◆ ApplicationSettings() [4/4]

quentier::ApplicationSettings::ApplicationSettings ( const Account account,
std::string_view  settingsName 
)

Constructor for application settings specific to the account

Parameters
accountThe account for which the settings are to be stored or read
settingsNameIf 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. Must be UTF-8 encoded as internally it is converted to QString via QString::fromUtf8

◆ ~ApplicationSettings()

quentier::ApplicationSettings::~ApplicationSettings ( )
override

Destructor

Member Function Documentation

◆ beginGroup() [1/3]

void quentier::ApplicationSettings::beginGroup ( const char prefix,
int  size = -1 
)

Appends prefix to the current group. Overload of beginGroup accepting const char * and optionally the size of the string

Parameters
prefixString containing the prefix name. Must be UTF-8 encoded as internally it is converted to QString via QString::fromUtf8
sizeSize of the prefix sring. If negative (the default), the prefix size is taken to be stren(prefix).

◆ beginGroup() [2/3]

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
prefixString containing the prefix name

◆ beginGroup() [3/3]

void quentier::ApplicationSettings::beginGroup ( std::string_view  prefix)

Appends prefix to the current group. Overload of beginGroup accepting std::std::string_view

Parameters
prefixString containing the prefix name. Must be UTF-8 encoded as internally it is converted to QString via QString::fromUtf8
sizeSize of the prefix sring. If negative (the default), the prefix size is taken to be stren(prefix).

◆ beginReadArray() [1/3]

int quentier::ApplicationSettings::beginReadArray ( const char prefix,
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
prefixString containing the prefix name. Must be UTF-8 encoded as internally it is converted to QString via QString::fromUtf8
sizeSize of the prefix sring. If negative (the default), the prefix size is taken to be stren(prefix)

◆ beginReadArray() [2/3]

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
prefixString containing the prefix name
Returns
The size of the array

◆ beginReadArray() [3/3]

int quentier::ApplicationSettings::beginReadArray ( std::string_view  prefix)

Adds prefix to the current group and starts reading from an array. Overload of beginReadArray accepting std::string_view

Parameters
prefixString containing the prefix name. Must be UTF-8 encoded as internally it is converted to QString via QString::fromUtf8

◆ beginWriteArray() [1/3]

void quentier::ApplicationSettings::beginWriteArray ( const char prefix,
int  arraySize = -1,
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
prefixString containing the prefix name. Must be UTF-8 encoded as internally it is converted to QString via QString::fromUtf8
arraySizeSize of the array to be written. If negative (the default), it is automatically determined based on the indexes of the entries written.
prefixSizeSize of the prefix sring. If negative (the default), the prefix size is taken to be stren(prefix)

◆ beginWriteArray() [2/3]

void quentier::ApplicationSettings::beginWriteArray ( const QString prefix,
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
prefixString containing the prefix name
arraySizeSize of the array to be written. If negative (the default), it is automatically determined based on the indexes of the entries written.

◆ beginWriteArray() [3/3]

void quentier::ApplicationSettings::beginWriteArray ( std::string_view  prefix,
int  arraySize = -1 
)

Adds prefix to the current group and starts writing an array of size arraySize. Overload of beginWriteArray accepting std::string_view

Parameters
prefixString containing the prefix name. Must be UTF-8 encoded as internally it is converted to QString via QString::fromUtf8
arraySizeSize of the array to be written. If negative (the default), it is automatically determined based on the indexes of the entries written.

◆ contains() [1/3]

bool quentier::ApplicationSettings::contains ( const char key,
int  size = -1 
) const

Overload of contains accepting const char * and optionally the size of the string

Parameters
keyString containing the setting name. Must be UTF-8 encoded as internally it is converted to QString via QString::fromUtf8
sizeSize 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/3]

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
keyThe key being checked for presence
Returns
True if there exists a setting called key; false otherwise

◆ contains() [3/3]

bool quentier::ApplicationSettings::contains ( std::string_view  key) const

Overload of contains accepting std::string_view

Parameters
keyString containing the setting name. Must be UTF-8 encoded as internally it is converted to QString via QString::fromUtf8
Returns
True if there exists a setting called key; false otherwise

◆ print()

QTextStream & quentier::ApplicationSettings::print ( QTextStream strm) const
overridevirtual

Implements quentier::Printable.

◆ remove() [1/3]

void quentier::ApplicationSettings::remove ( const char key,
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
keyString containing the setting name. Must be UTF-8 encoded as internally it is converted to QString via QString::fromUtf8
sizeSize of the key sring. If negative (the default), the key size is taken to be stren(key).

◆ remove() [2/3]

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
keyString containing the setting name

◆ remove() [3/3]

void quentier::ApplicationSettings::remove ( std::string_view  key)

Removes the setting key and any sub-settings of key. Overload of remove accepting std::string_view

Parameters
keyString containing the setting name. Must be UTF-8 encoded as internally it is converted to QString via QString::fromUtf8

◆ setValue() [1/3]

void quentier::ApplicationSettings::setValue ( const char key,
const QVariant value,
int  keySize = -1 
)

Sets the value of setting. Overload of setValue accepting const char * and optionally the size of the string

Parameters
keyString containing the setting name. Must be UTF-8 encoded as internally it is converted to QString via QString::fromUtf8
valueValue for setting key
keySizeSize of the key string. If negative (the default), the key size is taken to be strlen(key).

◆ setValue() [2/3]

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
keyString containing the setting name
valueValue for setting key

◆ setValue() [3/3]

void quentier::ApplicationSettings::setValue ( std::string_view  key,
const QVariant value 
)

Sets the value of setting. Overload of setValue accepting std::string_view

Parameters
keyString containing the setting name. Must be UTF-8 encoded as internally it is converted to QString via QString::fromUtf8
valueValue for setting key

◆ value() [1/3]

QVariant quentier::ApplicationSettings::value ( const char key,
const QVariant defaultValue = {},
int  keySize = -1 
) const

Fetches the value of setting. Overload of value accepting const char * and optionally the size of the string

Parameters
keyString containing the setting name. Must be UTF-8 encoded as internally it is converted to QString via QString::fromUtf8
defautValueDefault value returned if the setting doesn't exist
keySizeSize 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/3]

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
keyString containing the setting name
defautValueDefault 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.

◆ value() [3/3]

QVariant quentier::ApplicationSettings::value ( std::string_view  key,
const QVariant defaultValue = {} 
) const

Fetches the value of setting. Overload of value accepting std::string_view

Parameters
keyString containing the setting name. Must be UTF-8 encoded as internally it is converted to QString via QString::fromUtf8
defautValueDefault 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.