2023-01-09 12:38:01 +03:00
|
|
|
#ifndef CLIENTMANAGEMENTMODEL_H
|
|
|
|
|
#define CLIENTMANAGEMENTMODEL_H
|
|
|
|
|
|
|
|
|
|
#include <QAbstractListModel>
|
2023-11-21 20:13:51 +07:00
|
|
|
#include <QJsonArray>
|
2023-01-09 12:38:01 +03:00
|
|
|
|
|
|
|
|
class ClientManagementModel : public QAbstractListModel
|
|
|
|
|
{
|
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
|
|
public:
|
2023-11-21 20:13:51 +07:00
|
|
|
enum Roles {
|
2023-11-23 00:03:43 +07:00
|
|
|
ClientNameRole = Qt::UserRole + 1,
|
2024-04-28 16:03:41 +03:00
|
|
|
CreationDateRole,
|
|
|
|
|
LatestHandshakeRole,
|
|
|
|
|
DataReceivedRole,
|
2024-09-17 08:28:44 +02:00
|
|
|
DataSentRole,
|
|
|
|
|
AllowedIpsRole
|
2024-04-28 16:03:41 +03:00
|
|
|
};
|
|
|
|
|
|
2026-04-30 14:53:03 +08:00
|
|
|
explicit ClientManagementModel(QObject *parent = nullptr);
|
2023-01-09 12:38:01 +03:00
|
|
|
|
|
|
|
|
int rowCount(const QModelIndex &parent = QModelIndex()) const override;
|
|
|
|
|
QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;
|
2023-11-21 20:13:51 +07:00
|
|
|
|
|
|
|
|
public slots:
|
2026-04-30 14:53:03 +08:00
|
|
|
void updateModel(const QJsonArray &clients);
|
|
|
|
|
void updateClientName(int row, const QString &newName);
|
2023-01-09 12:38:01 +03:00
|
|
|
|
|
|
|
|
protected:
|
|
|
|
|
QHash<int, QByteArray> roleNames() const override;
|
|
|
|
|
|
|
|
|
|
private:
|
2023-11-21 20:13:51 +07:00
|
|
|
QJsonArray m_clientsTable;
|
2023-01-09 12:38:01 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
#endif // CLIENTMANAGEMENTMODEL_H
|