KIdentityManagement

identitytreemodel.h
1// SPDX-FileCopyrightText: 2021 Carl Schwan <carlschwan@kde.org>
2// SPDX-FileCopyrightText: 2023 Claudio Cambra <claudio.cambra@kde.org>
3// SPDX-FileCopyrightText: 2024 Laurent Montel <montel@kde.org>
4// SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
5
6#pragma once
7
8#include "kidentitymanagementcore_export.h"
9
10#include <QAbstractListModel>
11
12#include "identitymanager.h"
13
14namespace KIdentityManagementCore
15{
16class IdentityManager;
17class KIDENTITYMANAGEMENTCORE_EXPORT IdentityTreeModel : public QAbstractListModel
18{
19 Q_OBJECT
20
21public:
22 enum IdentityRoles {
23 IdentityNameRole,
24 DisplayIdentityNameRole,
25 FullEmailRole,
26 EmailRole,
27 UoidRole,
28 DefaultRole,
29 ActivitiesRole,
30 EnabledActivitiesRole,
31 LastColumn = EnabledActivitiesRole,
32 };
33
34 explicit IdentityTreeModel(IdentityManager *manager, QObject *parent = nullptr);
35 ~IdentityTreeModel() override;
36
37 [[nodiscard]] QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;
38 [[nodiscard]] int rowCount(const QModelIndex &parent = QModelIndex()) const override;
39 [[nodiscard]] int columnCount(const QModelIndex &parent) const override;
40 [[nodiscard]] QVariant headerData(int section, Qt::Orientation orientation, int role) const override;
41
42 void setShowDefault(bool show);
43
44 [[nodiscard]] uint identityUoid(int index) const;
45 [[nodiscard]] int uoidIndex(int uoid) const;
46
47 [[nodiscard]] KIdentityManagementCore::IdentityManager *identityManager() const;
48
49 [[nodiscard]] Qt::ItemFlags flags(const QModelIndex &index) const override;
50 [[nodiscard]] bool setData(const QModelIndex &modelIndex, const QVariant &value, int role = Qt::DisplayRole) override;
51
52 void removeIdentities(const QStringList &identitiesName);
53
54private:
55 KIDENTITYMANAGEMENTCORE_NO_EXPORT void reloadUoidList();
56 KIDENTITYMANAGEMENTCORE_NO_EXPORT QString generateIdentityName(const KIdentityManagementCore::Identity &identity) const;
57 QList<int> mIdentitiesUoid;
58 bool mShowDefault = false;
59 KIdentityManagementCore::IdentityManager *const mIdentityManager;
60};
61}
Manages the list of identities.
User identity information.
Definition identity.h:74
DisplayRole
typedef ItemFlags
Orientation
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Sat Dec 21 2024 16:57:47 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.