QtMvvm  1.1.0
A mvvm oriented library for Qt, to create Projects for Widgets and Quick in parallel
exchangedevicesmodel.h
1 #ifndef QTMVVM_EXCHANGEDEVICESMODEL_H
2 #define QTMVVM_EXCHANGEDEVICESMODEL_H
3 
4 #include <QtCore/qabstractitemmodel.h>
5 #include <QtCore/qscopedpointer.h>
6 
7 #include <QtDataSync/userexchangemanager.h>
8 
9 #include "QtMvvmDataSyncCore/qtmvvmdatasynccore_global.h"
10 
11 namespace QtMvvm {
12 
13 class ExchangeDevicesModelPrivate;
15 class Q_MVVMDATASYNCCORE_EXPORT ExchangeDevicesModel : public QAbstractListModel
16 {
17  Q_OBJECT
18 
19 public:
21  enum Roles {
22  NameRole = Qt::DisplayRole,
23  HostRole = Qt::UserRole + 1,
25  AddressRole
26  };
27  Q_ENUM(Roles)
28 
29 
30  explicit ExchangeDevicesModel(QObject *parent = nullptr);
31  ~ExchangeDevicesModel() override;
32 
34  Q_INVOKABLE void setup(QtDataSync::UserExchangeManager *exchangeManager);
35 
37  Q_INVOKABLE QtDataSync::UserInfo infoAt(const QModelIndex &index) const;
39  Q_INVOKABLE inline QtDataSync::UserInfo infoAt(int row) const {
40  return infoAt(index(row));
41  }
42 
44  QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const override;
46  int rowCount(const QModelIndex &parent = QModelIndex()) const override;
48  int columnCount(const QModelIndex &parent) const override;
50  QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;
52  QHash<int, QByteArray> roleNames() const override;
53 
55  static QString fullAddress(const QtDataSync::UserInfo &userInfo);
56 
57 private Q_SLOTS:
58  void updateDevices(const QList<QtDataSync::UserInfo> &devices);
59 
60 private:
62 };
63 
64 }
65 
66 #endif // QTMVVM_EXCHANGEDEVICESMODEL_H
The port the device is bound to. The role name is port
Roles
The model roles this model provides.
A list model implementation to show all devices available by the QtDataSync::UserExchangeManager.
Q_INVOKABLE QtDataSync::UserInfo infoAt(int row) const
Returns the user info at the given index.
The primary namespace of the QtMvvm library.