libquentier 0.5.0
The library for rich desktop clients of Evernote service
Loading...
Searching...
No Matches
ApplicationSettings.h
1/*
2 * Copyright 2016-2020 Dmitry Ivanov
3 *
4 * This file is part of libquentier
5 *
6 * libquentier is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU Lesser General Public License as published by
8 * the Free Software Foundation, version 3 of the License.
9 *
10 * libquentier is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU Lesser General Public License for more details.
14 *
15 * You should have received a copy of the GNU Lesser General Public License
16 * along with libquentier. If not, see <http://www.gnu.org/licenses/>.
17 */
18
19#ifndef LIB_QUENTIER_UTILITY_APPLICATION_SETTINGS_H
20#define LIB_QUENTIER_UTILITY_APPLICATION_SETTINGS_H
21
22#include <quentier/types/Account.h>
23
24#include <QSettings>
25
26namespace quentier {
27
33class QUENTIER_EXPORT ApplicationSettings : public QSettings, public Printable
34{
35 Q_OBJECT
36public:
46 ApplicationSettings(const QString & settingsName = {});
47
60 const Account & account, const QString & settingsName = {});
61
79 const Account & account, const char * settingsName,
80 const int settingsNameSize = -1);
81
85 virtual ~ApplicationSettings() override;
86
87public:
93 {
94 ArrayCloser(ApplicationSettings & settings) : m_settings(settings) {}
95
97 {
98 m_settings.endArray();
99 m_settings.sync();
100 }
101
102 ApplicationSettings & m_settings;
103 };
104
110 {
111 GroupCloser(ApplicationSettings & settings) : m_settings(settings) {}
112
114 {
115 m_settings.endGroup();
116 m_settings.sync();
117 }
118
119 ApplicationSettings & m_settings;
120 };
121
122public:
129 void beginGroup(const QString & prefix);
130
141 void beginGroup(const char * prefix, const int size = -1);
142
150 int beginReadArray(const QString & prefix);
151
162 int beginReadArray(const char * prefix, const int size = -1);
163
174 void beginWriteArray(const QString & prefix, const int arraySize = -1);
175
191 const char * prefix, const int arraySize = -1,
192 const int prefixSize = -1);
193
201 bool contains(const QString & key) const;
202
214 bool contains(const char * key, const int size = -1) const;
215
222 void remove(const QString & key);
223
234 void remove(const char * key, const int size = -1);
235
243 void setValue(const QString & key, const QVariant & value);
244
257 const char * key, const QVariant & value, const int keySize = -1);
258
269 QVariant value(
270 const QString & key, const QVariant & defaultValue = {}) const;
271
286 QVariant value(
287 const char * key, const QVariant & defaultValue = {},
288 const int keySize = -1) const;
289
290public:
291 virtual QTextStream & print(QTextStream & strm) const override;
292
293private:
294 Q_DISABLE_COPY(ApplicationSettings)
295};
296
297} // namespace quentier
298
299#endif // LIB_QUENTIER_UTILITY_APPLICATION_SETTINGS_H
The Account class encapsulates some details about the account: its name, whether it is local or synch...
Definition Account.h:39
The ApplicationSettings class enhances the functionality of QSettings, in particular it simplifies th...
Definition ApplicationSettings.h:34
bool contains(const char *key, const int size=-1) const
QVariant value(const QString &key, const QVariant &defaultValue={}) const
int beginReadArray(const char *prefix, const int size=-1)
ApplicationSettings(const QString &settingsName={})
int beginReadArray(const QString &prefix)
ApplicationSettings(const Account &account, const QString &settingsName={})
bool contains(const QString &key) const
void beginGroup(const QString &prefix)
void remove(const QString &key)
QVariant value(const char *key, const QVariant &defaultValue={}, const int keySize=-1) const
virtual ~ApplicationSettings() override
void remove(const char *key, const int size=-1)
void beginGroup(const char *prefix, const int size=-1)
void setValue(const char *key, const QVariant &value, const int keySize=-1)
void beginWriteArray(const QString &prefix, const int arraySize=-1)
ApplicationSettings(const Account &account, const char *settingsName, const int settingsNameSize=-1)
void beginWriteArray(const char *prefix, const int arraySize=-1, const int prefixSize=-1)
void setValue(const QString &key, const QVariant &value)
The Printable class is the interface for Quentier's internal classes which should be able to write th...
Definition Printable.h:38
Definition ApplicationSettings.h:93
Definition ApplicationSettings.h:110