AusweisApp2
ChatModel.h
gehe zur Dokumentation dieser Datei
1 
7 #pragma once
8 
9 #include <QAbstractListModel>
10 #include <QList>
11 #include <QSet>
12 #include <QSharedPointer>
13 #include <QSortFilterProxyModel>
14 
15 #include "context/AuthContext.h"
16 
17 class test_ChatModel;
18 
19 namespace governikus
20 {
21 
22 struct cvcertificate_st;
23 
24 class ChatModel
25  : public QAbstractListModel
26 {
27  Q_OBJECT
28  Q_PROPERTY(QSortFilterProxyModel * optional READ getFilterOptionalModel CONSTANT)
29  Q_PROPERTY(QSortFilterProxyModel * required READ getFilterRequiredModel CONSTANT)
30 
31  QSharedPointer<AuthContext> mAuthContext;
32  QList<AccessRight> mAllRights;
33  QSet<AccessRight> mOptionalRights, mSelectedRights;
34  QSortFilterProxyModel mFilterOptionalModel;
35  QSortFilterProxyModel mFilterRequiredModel;
36 
37  enum ChatRoles
38  {
39  NAME_ROLE = Qt::UserRole + 1,
40  OPTIONAL_ROLE,
41  SELECTED_ROLE,
42  WRITE_RIGHT,
43  };
44 
45  private:
46  friend class ::test_ChatModel;
47  void initFilterModel(QSortFilterProxyModel& pModel, const QString& pFilter);
48  void setOrderedAllRights(const QSet<AccessRight>& pAllRights);
49 
50  private Q_SLOTS:
51  void onAuthenticationDataChanged();
52 
53  public:
54  ChatModel(QObject* pParent = nullptr);
55 
56  void resetContext(const QSharedPointer<AuthContext>& pContext = QSharedPointer<AuthContext>());
57 
58  int rowCount(const QModelIndex& = QModelIndex()) const override;
59  QVariant data(const QModelIndex& pIndex, int pRole = Qt::DisplayRole) const override;
60  bool setData(const QModelIndex& pIndex, const QVariant& pValue, int pRole) override;
61  QHash<int, QByteArray> roleNames() const override;
62 
63  Q_INVOKABLE void transferAccessRights();
64  Q_INVOKABLE QSortFilterProxyModel* getFilterOptionalModel();
65  Q_INVOKABLE QSortFilterProxyModel* getFilterRequiredModel();
66 };
67 
68 
69 } // namespace governikus
Definition: ChatModel.h:26
Q_INVOKABLE QSortFilterProxyModel * getFilterRequiredModel()
Definition: ChatModel.cpp:196
int rowCount(const QModelIndex &=QModelIndex()) const override
Definition: ChatModel.cpp:104
void resetContext(const QSharedPointer< AuthContext > &pContext=QSharedPointer< AuthContext >())
Definition: ChatModel.cpp:48
ChatModel(QObject *pParent=nullptr)
Definition: ChatModel.cpp:18
QSortFilterProxyModel * optional
Definition: ChatModel.h:28
QSortFilterProxyModel * required
Definition: ChatModel.h:29
Q_INVOKABLE void transferAccessRights()
Definition: ChatModel.cpp:182
Q_INVOKABLE QSortFilterProxyModel * getFilterOptionalModel()
Definition: ChatModel.cpp:190
QHash< int, QByteArray > roleNames() const override
Definition: ChatModel.cpp:141
bool setData(const QModelIndex &pIndex, const QVariant &pValue, int pRole) override
Definition: ChatModel.cpp:152
QVariant data(const QModelIndex &pIndex, int pRole=Qt::DisplayRole) const override
Definition: ChatModel.cpp:110
Implementation of ActivationContext for Intent based activation on Android systems.
Definition: ActivationContext.h:15