| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 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 |
|
| 36 |
|
| 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 |