QtMvvm  1.1.0
A mvvm oriented library for Qt, to create Projects for Widgets and Quick in parallel
androidsettingsaccessor.h
1 #ifndef QTMVVM_ANDROIDSETTINGSACCESSOR_H
2 #define QTMVVM_ANDROIDSETTINGSACCESSOR_H
3 
4 #include <QtCore/qscopedpointer.h>
5 
6 #include "QtMvvmCore/qtmvvmcore_global.h"
7 #include "QtMvvmCore/isettingsaccessor.h"
8 
9 namespace QtMvvm {
10 
11 class AndroidSettingsAccessorPrivate;
13 class Q_MVVMCORE_EXPORT AndroidSettingsAccessor : public ISettingsAccessor
14 {
15  Q_OBJECT
16  Q_INTERFACES(QtMvvm::ISettingsAccessor)
17 
18 public:
20  enum ModeFlag {
21  Private = 0x00000000,
22  WorldReadable = 0x00000001,
23  MultiProcess = 0x00000004
24  };
25  Q_DECLARE_FLAGS(Mode, ModeFlag)
26  Q_FLAG(Mode)
27 
28 
29  Q_INVOKABLE explicit AndroidSettingsAccessor(QObject *parent = nullptr);
31  explicit AndroidSettingsAccessor(const QString &file, QObject *parent = nullptr);
33  explicit AndroidSettingsAccessor(const QString &file, Mode mode, QObject *parent = nullptr);
34  ~AndroidSettingsAccessor() override;
35 
36  bool contains(const QString &key) const override;
37  QVariant load(const QString &key, const QVariant &defaultValue = {}) const override;
38  void save(const QString &key, const QVariant &value) override;
39  void remove(const QString &key) override;
40 
41 public Q_SLOTS:
43  void sync() override;
44 
45 private Q_SLOTS:
46  void changeCallback(const QString &key);
47 
48 private:
50 };
51 
52 }
53 
54 Q_DECLARE_METATYPE(QtMvvm::AndroidSettingsAccessor*)
55 Q_DECLARE_OPERATORS_FOR_FLAGS(QtMvvm::AndroidSettingsAccessor::Mode)
56 
57 #endif // QTMVVM_ANDROIDSETTINGSACCESSOR_H
ModeFlag
Flags to specify how the shared preferences should be created.
An interface to provide a generic way to access settings of any origin.
A wrapper around the android SharedPreferences API.
The primary namespace of the QtMvvm library.