KIdentityManagement

identitytreeview.cpp
1// SPDX-FileCopyrightText: 2024 Laurent Montel <montel@kde.org>
2// SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
3
4#include "identitytreeview.h"
5#include "identitytreedelegate.h"
6#include "identitytreemodel.h"
7#include "identitytreesortproxymodel.h"
8
9#include <QHeaderView>
10
11using namespace KIdentityManagementWidgets;
12IdentityTreeView::IdentityTreeView(QWidget *parent)
13 : QTreeView(parent)
14 , mIdentityProxyModel(new KIdentityManagementCore::IdentityTreeSortProxyModel(this))
15{
16 setAlternatingRowColors(true);
17 setSelectionMode(ExtendedSelection);
18 setContextMenuPolicy(Qt::CustomContextMenu);
19 setSelectionBehavior(QAbstractItemView::SelectRows);
20 setRootIsDecorated(false);
21 setSortingEnabled(true);
22 setAllColumnsShowFocus(true);
23 setEditTriggers(QAbstractItemView::EditKeyPressed);
24 header()->setSectionsMovable(false);
25 header()->setSectionResizeMode(QHeaderView::ResizeToContents);
26
27 mIdentityModel = new KIdentityManagementCore::IdentityTreeModel(KIdentityManagementCore::IdentityManager::self(), this);
28 mIdentityModel->setShowDefault(true);
29
30 mIdentityProxyModel->setSourceModel(mIdentityModel);
31 setModel(mIdentityProxyModel);
32
33 setColumnHidden(KIdentityManagementCore::IdentityTreeModel::DefaultRole, true);
34 setColumnHidden(KIdentityManagementCore::IdentityTreeModel::UoidRole, true);
35 setColumnHidden(KIdentityManagementCore::IdentityTreeModel::EmailRole, true);
36 setColumnHidden(KIdentityManagementCore::IdentityTreeModel::IdentityNameRole, true);
37 setColumnHidden(KIdentityManagementCore::IdentityTreeModel::ActivitiesRole, true);
38 setColumnHidden(KIdentityManagementCore::IdentityTreeModel::EnabledActivitiesRole, true);
39 setItemDelegateForColumn(KIdentityManagementCore::IdentityTreeModel::DisplayIdentityNameRole, new IdentityTreeDelegate(this));
40}
41
42IdentityTreeView::~IdentityTreeView() = default;
43
44KIdentityManagementCore::IdentityActivitiesAbstract *IdentityTreeView::identityActivitiesAbstract() const
45{
46 return mIdentityProxyModel->identityActivitiesAbstract();
47}
48
49bool IdentityTreeView::enablePlasmaActivities() const
50{
51 return mIdentityProxyModel->enablePlasmaActivities();
52}
53
54void IdentityTreeView::setEnablePlasmaActivities(bool newEnablePlasmaActivities)
55{
56 mIdentityProxyModel->setEnablePlasmaActivities(newEnablePlasmaActivities);
57}
58
59KIdentityManagementCore::IdentityTreeSortProxyModel *IdentityTreeView::identityProxyModel() const
60{
61 return mIdentityProxyModel;
62}
63
64void IdentityTreeView::setIdentityActivitiesAbstract(KIdentityManagementCore::IdentityActivitiesAbstract *newIdentityActivitiesAbstract)
65{
66 mIdentityProxyModel->setIdentityActivitiesAbstract(newIdentityActivitiesAbstract);
67}
68
69KIdentityManagementCore::Identity &IdentityTreeView::modifyIdentityForUoid(uint uoid)
70{
71 return mIdentityModel->identityManager()->modifyIdentityForUoid(uoid);
72}
73
74KIdentityManagementCore::IdentityTreeModel *IdentityTreeView::identityTreeModel() const
75{
76 return mIdentityModel;
77}
78
79#include "moc_identitytreeview.cpp"
static IdentityManager * self()
Creates or reuses the identity manager instance for this process.
Identity & modifyIdentityForUoid(uint uoid)
User identity information.
Definition identity.h:74
CustomContextMenu
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Fri Nov 22 2024 12:04:54 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.