QtMvvm  1.0.0
A mvvm oriented library for Qt, to create Projects for Widgets and Quick in parallel
accountmodel.h
1 #ifndef QTMVVM_ACCOUNTMODEL_H
2 #define QTMVVM_ACCOUNTMODEL_H
3 
4 #include <QtCore/qabstractitemmodel.h>
5 #include <QtCore/qscopedpointer.h>
6 
7 #include <QtDataSync/accountmanager.h>
8 #include <QtDataSync/syncmanager.h>
9 
10 #include "QtMvvmDataSyncCore/qtmvvmdatasynccore_global.h"
11 
12 namespace QtMvvm {
13 
14 class AccountModelPrivate;
16 class Q_MVVMDATASYNCCORE_EXPORT AccountModel : public QAbstractListModel
17 {
18  Q_OBJECT
19 
20 public:
22  enum Roles {
23  NameRole = Qt::DisplayRole,
24  FingerPrintRole = Qt::UserRole + 1
25  };
26  Q_ENUM(Roles)
27 
28 
29  explicit AccountModel(QObject *parent = nullptr);
30  ~AccountModel();
31 
33  Q_INVOKABLE void setup(QtDataSync::AccountManager *accountManager,
34  QtDataSync::SyncManager *syncManager);
35 
37  QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const override;
39  int rowCount(const QModelIndex &parent = QModelIndex()) const override;
41  int columnCount(const QModelIndex &parent = QModelIndex()) const override;
43  QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;
45  QHash<int, QByteArray> roleNames() const override;
46 
48  Q_INVOKABLE bool removeDevice(const QModelIndex &index);
50  Q_INVOKABLE inline bool removeDevice(int row) {
51  return removeDevice(index(row));
52  }
53 
54 public Q_SLOTS:
56  void reload();
57 
58 private Q_SLOTS:
59  void accountDevices(const QList<QtDataSync::DeviceInfo> &devices);
60  void update(QtDataSync::SyncManager::SyncState state);
61 
62 private:
64 };
65 
66 }
67 
68 #endif // QTMVVM_ACCOUNTMODEL_H
A list model implementation for QtDataSync::DeviceInfo via a QtDataSync::AccountManager.
Definition: accountmodel.h:16
Q_INVOKABLE bool removeDevice(int row)
Removes the device with the given index from the account.
Definition: accountmodel.h:50
Roles
The model roles this model provides.
Definition: accountmodel.h:22
The primary namespace of the QtMvvm library.
Definition: binding.h:10