QtDataSync  4.2.0
A simple offline-first synchronisation framework, to synchronize data of Qt applications between devices
qqmlaccountmanager.h
1 #ifndef QQMLACCOUNTMANAGER_H
2 #define QQMLACCOUNTMANAGER_H
3 
4 #include <QtCore/QObject>
5 
6 #include <QtQml/QJSValue>
7 #include <QtQml/QQmlParserStatus>
8 
9 #include <QtDataSync/accountmanager.h>
10 
11 #ifdef DOXYGEN_RUN
13 
21 #else
22 namespace QtDataSync {
23 
24 class QQmlAccountManager : public AccountManager, public QQmlParserStatus
25 #endif
26 {
27  Q_OBJECT
28  Q_DISABLE_COPY(QQmlAccountManager)
29  Q_INTERFACES(QQmlParserStatus)
30 
31 
47  Q_PROPERTY(QString setupName READ setupName WRITE setSetupName NOTIFY setupNameChanged)
64  Q_PROPERTY(QRemoteObjectNode* node READ node WRITE setNode NOTIFY nodeChanged)
80  Q_PROPERTY(bool valid READ valid NOTIFY validChanged)
81 
82 public:
84  explicit QQmlAccountManager(QObject *parent = nullptr);
85 
87  void classBegin() override;
89  void componentComplete() override;
90 
92  QString setupName() const;
94  QRemoteObjectNode* node() const;
96  bool valid() const;
97 
99  Q_INVOKABLE bool isTrustedImport(const QJsonObject &importData) const;
100 
102  Q_INVOKABLE void exportAccount(bool includeServer, const QJSValue &completedFn, const QJSValue &errorFn = {});
104  Q_INVOKABLE void exportAccountTrusted(bool includeServer, const QString &password, const QJSValue &completedFn, const QJSValue &errorFn = {});
106  Q_INVOKABLE void importAccount(const QJsonObject &importData, const QJSValue &completedFn, bool keepData = false);
108  Q_INVOKABLE void importAccountTrusted(const QJsonObject &importData, const QString &password, const QJSValue &completedFn, bool keepData = false);
109 
110 public Q_SLOTS:
112  void setSetupName(QString setupName);
114  void setNode(QRemoteObjectNode* node);
115 
116 Q_SIGNALS:
118  void setupNameChanged(const QString &setupName);
120  void nodeChanged(QRemoteObjectNode* node);
122  void validChanged(bool valid);
123 
124 private:
125  QString _setupName;
126  QRemoteObjectNode* _node;
127  bool _valid;
128 };
129 
130 }
131 
132 #endif // QQMLACCOUNTMANAGER_H
void validChanged(bool valid)
NOTIFY accessor for AccountManager::valid.
The QML import for the QtDataSync QML module.
Q_INVOKABLE void exportAccountTrusted(bool includeServer, const QString &password, const QJSValue &completedFn, const QJSValue &errorFn={})
Export the current account data as trusted export.
Q_INVOKABLE void exportAccount(bool includeServer, const QJSValue &completedFn, const QJSValue &errorFn={})
Export the current account data as untrusted export.
void nodeChanged(QRemoteObjectNode *node)
NOTIFY accessor for AccountManager::node.
Q_INVOKABLE void importAccount(const QJsonObject &importData, const QJSValue &completedFn, bool keepData=false)
Import an account from the given untrusted export data.
Q_INVOKABLE void importAccountTrusted(const QJsonObject &importData, const QString &password, const QJSValue &completedFn, bool keepData=false)
Import an account from the given trusted export data.
The primary namespace of the QtDataSync library.
Q_INVOKABLE bool isTrustedImport(const QJsonObject &importData) const
Checks if the given data is trusted or not.
The QML binding of QtDataSync::AccountManager.
void setupNameChanged(const QString &setupName)
NOTIFY accessor for AccountManager::setupName.
QObject * parent() const const