Debian Codegraph @

maz-db/src/MazDBSettings.h

raw symbols SCIP
1 /* Copyright (C) 2017 Dan Chapman <[email protected]>
2
3 This file is part of Dekko email client for Ubuntu devices
4
5 This program is free software; you can redistribute it and/or
6 modify it under the terms of the GNU General Public License as
7 published by the Free Software Foundation; either version 2 of
8 the License or (at your option) version 3
9
10 This program 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 General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>.
17 */
18 #ifndef MAZDBSETTINGS_H
19 #define MAZDBSETTINGS_H
20
21 #include <QObject>
22 #include <QMetaObject>
23 #include <QMetaProperty>
24 #include <QHash>
25 #include <QQmlParserStatus>
26
27 class MazDB;
28
29 typedef QList<QMetaObject::Connection> ConnectionList;
30
31 class MazDBSettings : public QObject, public QQmlParserStatus
32 {
33 Q_OBJECT
34 Q_INTERFACES(QQmlParserStatus)
35 // Emulates the category property from qt.labs.Settings but internally
36 // it creates a new leveldb for the given category.
37 Q_PROPERTY(QString category MEMBER m_category)
38 public:
39 explicit MazDBSettings(QObject *parent = 0);
40
41 QStringList allKeys();
42 bool contains(const QString &key);
43 Q_INVOKABLE QString fileName() const;
44 void remove(const QString &key);
45 Q_INVOKABLE void setValue(const QString &key, const QVariant &value);
46 Q_INVOKABLE QVariant value(const QString &key, const QVariant &defaultValue = QVariant());
47 Q_INVOKABLE void close();
48
49 protected:
50 virtual void classBegin() override;
51 virtual void componentComplete() override;
52
53 private slots:
54 void handlePropertyChanged();
55 void handleKeyValueChanged(const QString &key, const QVariant &value);
56 void init();
57 private:
58 Q_DISABLE_COPY(MazDBSettings)
59
60 MazDB *m_db;
61 ConnectionList m_connections;
62 QHash<int, QMetaProperty> m_propertyHash;
63 QString m_category;
64 };
65
66 #endif // MAZDBSETTINGS_H