QtMvvm  1.1.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 isActive 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);
49  ~NetworkExchangeViewModel() override;
50 
52  QtDataSync::UserExchangeManager* userExchangeManager() const;
54  quint16 port() const;
56  QString deviceName() const;
58  bool isActive() const;
59  Q_DECL_DEPRECATED bool active() const;
61  ExchangeDevicesModel* deviceModel() const;
63  QSortFilterProxyModel* sortedModel() const;
64 
65 public Q_SLOTS:
67  void exportTo(int sortedIndex);
68 
70  void setPort(quint16 port);
72  void setDeviceName(QString deviceName);
74  void setActive(bool active);
75 
76 Q_SIGNALS:
78  void ready(QPrivateSignal);
79 
81  void userExchangeManagerChanged(QtDataSync::UserExchangeManager* userExchangeManager, QPrivateSignal);
83  void portChanged(quint16 port, QPrivateSignal);
85  void deviceNameChanged(QString deviceName, QPrivateSignal);
87  void activeChanged(bool active, QPrivateSignal);
88 
89 protected:
90  void onInit(const QVariantHash &params) override;
91  void onResult(quint32 requestCode, const QVariant &result) override;
92 
93 private Q_SLOTS:
94  void exchangeError(const QString &errorString);
95  void newUserData(const QtDataSync::UserInfo &userInfo, bool trusted);
96 
97 private:
98  QScopedPointer<NetworkExchangeViewModelPrivate> d;
99 };
100 
101 }
102 
103 #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:21
The primary namespace of the QtMvvm library.
A viewmodel to show a dialog to exchange account data via the QtDataSync::UserExchangeManager.