QtMvvm  1.0.0
A mvvm oriented library for Qt, to create Projects for Widgets and Quick in parallel
networkexchangeviewmodel.h
1 #ifndef QTMVVM_NETWORKEXCHANGEVIEWMODEL_H
2 #define QTMVVM_NETWORKEXCHANGEVIEWMODEL_H
3 
4 #include <QtCore/qscopedpointer.h>
5 #include <QtCore/qsortfilterproxymodel.h>
6 
7 #include <QtMvvmCore/viewmodel.h>
8 
9 #include <QtDataSync/userexchangemanager.h>
10 
11 #include "QtMvvmDataSyncCore/qtmvvmdatasynccore_global.h"
12 #include "QtMvvmDataSyncCore/exchangedevicesmodel.h"
13 
14 namespace QtMvvm {
15 
16 class NetworkExchangeViewModelPrivate;
18 class Q_MVVMDATASYNCCORE_EXPORT NetworkExchangeViewModel : public ViewModel
19 {
20  Q_OBJECT
21 
23  Q_PROPERTY(QtDataSync::UserExchangeManager* userExchangeManager READ userExchangeManager NOTIFY userExchangeManagerChanged)
25  Q_PROPERTY(quint16 port READ port WRITE setPort NOTIFY portChanged)
27  Q_PROPERTY(QString deviceName READ deviceName WRITE setDeviceName NOTIFY deviceNameChanged)
29  Q_PROPERTY(bool active READ active WRITE setActive NOTIFY activeChanged)
30 
32  Q_PROPERTY(ExchangeDevicesModel* deviceModel READ deviceModel CONSTANT)
34  Q_PROPERTY(QSortFilterProxyModel* sortedModel READ sortedModel CONSTANT)
35 
36 public:
38  static const QString paramSetup;
40  static const QString paramAccountManager;
41 
43  static QVariantHash showParams(const QString &setup);
45  static QVariantHash showParams(QtDataSync::AccountManager *accountManager);
46 
48  Q_INVOKABLE explicit NetworkExchangeViewModel(QObject *parent = nullptr);
50 
52  QtDataSync::UserExchangeManager* userExchangeManager() const;
54  quint16 port() const;
56  QString deviceName() const;
58  bool active() const;
60  ExchangeDevicesModel* deviceModel() const;
62  QSortFilterProxyModel* sortedModel() const;
63 
64 public Q_SLOTS:
66  void exportTo(int sortedIndex);
67 
69  void setPort(quint16 port);
71  void setDeviceName(QString deviceName);
73  void setActive(bool active);
74 
75 Q_SIGNALS:
77  void ready(QPrivateSignal);
78 
80  void userExchangeManagerChanged(QtDataSync::UserExchangeManager* userExchangeManager, QPrivateSignal);
82  void portChanged(quint16 port, QPrivateSignal);
84  void deviceNameChanged(QString deviceName, QPrivateSignal);
86  void activeChanged(bool active, QPrivateSignal);
87 
88 protected:
89  void onInit(const QVariantHash &params) override;
90  void onResult(quint32 requestCode, const QVariant &result) override;
91 
92 private Q_SLOTS:
93  void exchangeError(const QString &errorString);
94  void newUserData(const QtDataSync::UserInfo &userInfo, bool trusted);
95 
96 private:
97  QScopedPointer<NetworkExchangeViewModelPrivate> d;
98 };
99 
100 }
101 
102 #endif // QTMVVM_NETWORKEXCHANGEVIEWMODEL_H
A list model implementation to show all devices available by the QtDataSync::UserExchangeManager.
The base class for all viewmodels.
Definition: viewmodel.h:20
The primary namespace of the QtMvvm library.
Definition: binding.h:10
A viewmodel to show a dialog to exchange account data via the QtDataSync::UserExchangeManager.