File indexing completed on 2024-12-01 13:09:03

0001 /*
0002    SPDX-FileCopyrightText: 2022-2024 Laurent Montel <montel@kde.org>
0003 
0004    SPDX-License-Identifier: LGPL-2.0-or-later
0005 */
0006 
0007 #pragma once
0008 
0009 #include "custombasemodel.h"
0010 #include "libruqolacore_export.h"
0011 #include "managedevices/deviceinfos.h"
0012 
0013 class LIBRUQOLACORE_EXPORT DeviceInfoModel : public CustomBaseModel
0014 {
0015     Q_OBJECT
0016 public:
0017     enum DeviceInfoRoles {
0018         Os,
0019         Client,
0020         Host,
0021         Identifier,
0022         SessionId,
0023         Ip,
0024         UserId,
0025         LoginAt,
0026         LastColumn = LoginAt,
0027     };
0028     Q_ENUM(DeviceInfoRoles)
0029 
0030     explicit DeviceInfoModel(QObject *parent = nullptr);
0031     ~DeviceInfoModel() override;
0032 
0033     [[nodiscard]] int rowCount(const QModelIndex &parent = QModelIndex()) const override;
0034     [[nodiscard]] QVariant data(const QModelIndex &index, int role) const override;
0035     [[nodiscard]] QVariant headerData(int section, Qt::Orientation orientation, int role) const override;
0036     [[nodiscard]] int columnCount(const QModelIndex &parent = QModelIndex()) const override;
0037 
0038     [[nodiscard]] int total() const override;
0039     void parseElements(const QJsonObject &obj) override;
0040     void addMoreElements(const QJsonObject &obj) override;
0041     [[nodiscard]] QList<int> hideColumns() const override;
0042 
0043     void removeElement(const QString &identifier) override;
0044 
0045     [[nodiscard]] const DeviceInfos &deviceInfos() const;
0046     void setDeviceInfos(const DeviceInfos &newDeviceInfos);
0047 
0048 private:
0049     LIBRUQOLACORE_NO_EXPORT void clear();
0050     LIBRUQOLACORE_NO_EXPORT void checkFullList() override;
0051     DeviceInfos mDeviceInfos;
0052 };