File indexing completed on 2024-05-19 05:17:28
0001 // SPDX-FileCopyrightText: 2021 Carl Schwan <carlschwan@kde.org> 0002 // SPDX-FileCopyrightText: 2023 Claudio Cambra <claudio.cambra@kde.org> 0003 // SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL 0004 0005 #pragma once 0006 0007 #include "kidentitymanagementcore_export.h" 0008 0009 #include <QAbstractListModel> 0010 0011 #include "identitymanager.h" 0012 0013 namespace KIdentityManagementCore 0014 { 0015 0016 class IdentityManager; 0017 0018 class KIDENTITYMANAGEMENTCORE_EXPORT IdentityModel : public QAbstractListModel 0019 { 0020 Q_OBJECT 0021 0022 public: 0023 enum Roles { 0024 EmailRole = Qt::UserRole, 0025 UoidRole, 0026 IdentityNameRole, 0027 DisplayNameRole, 0028 }; 0029 0030 IdentityModel(QObject *parent = nullptr); 0031 ~IdentityModel(); 0032 0033 QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override; 0034 int rowCount(const QModelIndex &parent = QModelIndex()) const override; 0035 QHash<int, QByteArray> roleNames() const override; 0036 0037 /** 0038 * @return the email address of the identity with the given uoid. 0039 * @param uiod for the identity in question 0040 */ 0041 Q_INVOKABLE QString email(uint uoid); 0042 0043 private Q_SLOTS: 0044 void reloadUoidList(); 0045 0046 private: 0047 QList<int> m_identitiesUoid; 0048 IdentityManager *const m_identityManager; 0049 }; 0050 }