libquentier 0.5.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, 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
 
- Public Member Functions inherited from quentier::Printable
virtual QTextStream & print (QTextStream &strm) const =0
 
virtual const QString toString () const
 

Additional Inherited Members

- Protected Member Functions inherited from quentier::Printable
 Printable (const Printable &other)
 
Printableoperator= (const Printable &other)
 

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/3]

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

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/3]

quentier::ApplicationSettings::ApplicationSettings ( const Account account,
const QString &  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

◆ 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
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()

virtual quentier::ApplicationSettings::~ApplicationSettings ( )
overridevirtual

Destructor

Member Function Documentation

◆ 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
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/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
prefixString 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
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/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
prefixString 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
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/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
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.

◆ 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
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/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
keyThe 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

Implements quentier::Printable.

◆ 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
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/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
keyString 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
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/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
keyString containing the setting name
valueValue 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
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/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
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.