libquentier 0.8.0
The library for rich desktop clients of Evernote service
Loading...
Searching...
No Matches
ApplicationSettings.h
1/*
2 * Copyright 2016-2024 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#pragma once
20
21#include <quentier/types/Account.h>
22
23#include <QSettings>
24
25#include <string_view>
26
27namespace quentier {
28
34class QUENTIER_EXPORT ApplicationSettings : public QSettings, public Printable
35{
37public:
48
61 const Account & account, const QString & settingsName = {});
62
80 const Account & account, const char * settingsName,
81 int settingsNameSize = -1);
82
96 ApplicationSettings(const Account & account, std::string_view settingsName);
97
102
103public:
109 {
111
113 {
114 m_settings.endArray();
115 m_settings.sync();
116 }
117
118 ApplicationSettings & m_settings;
119 };
120
126 {
128
130 {
131 m_settings.endGroup();
132 m_settings.sync();
133 }
134
135 ApplicationSettings & m_settings;
136 };
137
138public:
145 void beginGroup(const QString & prefix);
146
157 void beginGroup(const char * prefix, int size = -1);
158
168 void beginGroup(std::string_view prefix);
169
178
189 [[nodiscard]] int beginReadArray(const char * prefix, int size = -1);
190
198 [[nodiscard]] int beginReadArray(std::string_view prefix);
199
210 void beginWriteArray(const QString & prefix, int arraySize = -1);
211
227 const char * prefix, int arraySize = -1, int prefixSize = -1);
228
240 void beginWriteArray(std::string_view prefix, int arraySize = -1);
241
249 [[nodiscard]] bool contains(const QString & key) const;
250
262 [[nodiscard]] bool contains(const char * key, int size = -1) const;
263
272 [[nodiscard]] bool contains(std::string_view key) const;
273
280 void remove(const QString & key);
281
292 void remove(const char * key, int size = -1);
293
301 void remove(std::string_view key);
302
310 void setValue(const QString & key, const QVariant & value);
311
323 void setValue(const char * key, const QVariant & value, int keySize = -1);
324
333 void setValue(std::string_view key, const QVariant & value);
334
346 const QString & key, const QVariant & defaultValue = {}) const;
347
363 const char * key, const QVariant & defaultValue = {},
364 int keySize = -1) const;
365
378 std::string_view key, const QVariant & defaultValue = {}) const;
379
380public:
381 QTextStream & print(QTextStream & strm) const override;
382
383private:
385};
386
387} // namespace quentier
The Account class encapsulates some details about the account: its name, whether it is local or synch...
Definition Account.h:38
The ApplicationSettings class enhances the functionality of QSettings, in particular it simplifies th...
Definition ApplicationSettings.h:35
bool contains(std::string_view key) const
int beginReadArray(std::string_view prefix)
QVariant value(const QString &key, const QVariant &defaultValue={}) const
ApplicationSettings(const QString &settingsName={})
int beginReadArray(const QString &prefix)
ApplicationSettings(const Account &account, const QString &settingsName={})
void remove(std::string_view key)
bool contains(const QString &key) const
void setValue(std::string_view key, const QVariant &value)
void beginWriteArray(std::string_view prefix, int arraySize=-1)
void beginGroup(const QString &prefix)
void beginGroup(const char *prefix, int size=-1)
void remove(const QString &key)
void beginGroup(std::string_view prefix)
void beginWriteArray(const char *prefix, int arraySize=-1, int prefixSize=-1)
QVariant value(const char *key, const QVariant &defaultValue={}, int keySize=-1) const
void beginWriteArray(const QString &prefix, int arraySize=-1)
QVariant value(std::string_view key, const QVariant &defaultValue={}) const
bool contains(const char *key, int size=-1) const
ApplicationSettings(const Account &account, const char *settingsName, int settingsNameSize=-1)
void remove(const char *key, int size=-1)
int beginReadArray(const char *prefix, int size=-1)
void setValue(const char *key, const QVariant &value, int keySize=-1)
ApplicationSettings(const Account &account, std::string_view settingsName)
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
The Result template class represents the bare bones result monad implementation which either contains...
Definition Result.h:38
Definition ApplicationSettings.h:109
Definition ApplicationSettings.h:126