QtDataSync  4.2.0
A simple offline-first synchronisation framework, to synchronize data of Qt applications between devices
androidsynccontrol.h
1 #ifndef QTDATASYNC_ANDROIDSYNCCONTROL_H
2 #define QTDATASYNC_ANDROIDSYNCCONTROL_H
3 
4 #include <chrono>
5 
6 #include <QtCore/qobject.h>
7 #include <QtCore/qscopedpointer.h>
8 
9 #include "QtDataSyncAndroid/qtdatasyncandroid_global.h"
10 
11 namespace QtDataSync {
12 
13 class AndroidSyncControlPrivate;
15 class Q_DATASYNCANDROID_EXPORT AndroidSyncControl : public QObject
16 {
17  Q_OBJECT
18 
20  Q_PROPERTY(bool valid READ isValid NOTIFY validChanged)
21 
22 
23  Q_PROPERTY(QString serviceId READ serviceId WRITE setServiceId NOTIFY serviceIdChanged)
25  Q_PROPERTY(qint64 interval READ interval WRITE setInterval NOTIFY intervalChanged)
26 
28  Q_PROPERTY(bool enabled READ isEnabled WRITE setEnabled)
29 
30 public:
32  explicit AndroidSyncControl(QObject *parent = nullptr);
34  AndroidSyncControl(QString serviceId, QObject *parent = nullptr);
35  ~AndroidSyncControl() override;
36 
38  bool isValid() const;
39 
41  QString serviceId() const;
43  qint64 interval() const;
45  std::chrono::minutes intervalMinutes() const;
47  bool isEnabled() const;
48 
50  template <typename TRep, typename TPeriod>
51  void setInterval(const std::chrono::duration<TRep, TPeriod> &interval);
53  void setInterval(std::chrono::minutes interval);
54 
55 public Q_SLOTS:
57  void setServiceId(QString serviceId);
59  void setInterval(qint64 interval);
61  void setEnabled(bool enabled);
62 
64  bool triggerSyncNow();
65 
66 Q_SIGNALS:
68  void validChanged(QPrivateSignal);
70  void serviceIdChanged(const QString &serviceId, QPrivateSignal);
72  void intervalChanged(qint64 interval, QPrivateSignal);
73 
74 private:
75  QScopedPointer<AndroidSyncControlPrivate> d;
76 };
77 
78 template<typename TRep, typename TPeriod>
79 void AndroidSyncControl::setInterval(const std::chrono::duration<TRep, TPeriod> &interval)
80 {
81  setInterval(std::chrono::duration_cast<std::chrono::minutes>(interval));
82 }
83 
84 }
85 
86 #endif // QTDATASYNC_ANDROIDSYNCCONTROL_H
A class to manage background synchronization for android.
STL namespace.
The primary namespace of the QtDataSync library.