File indexing completed on 2024-12-22 05:16:05

0001 /*
0002     SPDX-FileCopyrightText: 2019 Nicolas Fella <nicolas.fella@gmx.de>
0003     SPDX-FileCopyrightText: 2020 Carson Black <uhhadd@gmail.com>
0004 
0005     SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
0006 */
0007 
0008 #pragma once
0009 
0010 #include <QAbstractListModel>
0011 
0012 #include "user.h"
0013 
0014 class OrgFreedesktopAccountsInterface;
0015 
0016 class UserModel : public QAbstractListModel
0017 {
0018     Q_OBJECT
0019 
0020 public:
0021     enum Roles {
0022         RealNameRole = Qt::DisplayRole,
0023         FaceRole = Qt::DecorationRole,
0024         UidRole = Qt::UserRole,
0025         NameRole,
0026         DisplayPrimaryNameRole,
0027         DisplaySecondaryNameRole,
0028         EmailRole,
0029         FaceValidRole,
0030         AdministratorRole,
0031         UserRole,
0032         LoggedInRole,
0033         SectionHeaderRole,
0034     };
0035     Q_ENUM(Roles)
0036 
0037     explicit UserModel(QObject *parent = nullptr);
0038     ~UserModel() override;
0039 
0040     QVariant data(const QModelIndex &index, int role) const override;
0041     int rowCount(const QModelIndex &parent = QModelIndex()) const override;
0042 
0043     Q_INVOKABLE User *getLoggedInUser() const;
0044 
0045     QHash<int, QByteArray> roleNames() const override;
0046 
0047 private:
0048     OrgFreedesktopAccountsInterface *m_dbusInterface;
0049     QList<User *> m_userList;
0050 };