KIdentityManagement

identitytreesortproxymodel.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 "identitytreesortproxymodel.h"
5#include "identityactivitiesabstract.h"
6#include "identitytreemodel.h"
7using namespace KIdentityManagementCore;
8IdentityTreeSortProxyModel::IdentityTreeSortProxyModel(QObject *parent)
10{
11}
12
13IdentityTreeSortProxyModel::~IdentityTreeSortProxyModel() = default;
14
15bool IdentityTreeSortProxyModel::filterAcceptsRow(int source_row, const QModelIndex &source_parent) const
16{
17 if (mIdentityActivitiesAbstract && mEnablePlasmaActivities) {
18 const bool enableActivities = sourceModel()->index(source_row, IdentityTreeModel::EnabledActivitiesRole).data().toBool();
19 if (enableActivities) {
20 const auto activities = sourceModel()->index(source_row, IdentityTreeModel::ActivitiesRole).data().toStringList();
21 const bool result = mIdentityActivitiesAbstract->filterAcceptsRow(activities);
22 // qDebug() << " result " << result << " identity name : " << sourceModel()->index(source_row,
23 // IdentityTreeModel::IdentityNameRole).data().toString();
24 return result;
25 }
26 }
27 return QSortFilterProxyModel::filterAcceptsRow(source_row, source_parent);
28}
29
30bool IdentityTreeSortProxyModel::enablePlasmaActivities() const
31{
32 return mEnablePlasmaActivities;
33}
34
35void IdentityTreeSortProxyModel::setEnablePlasmaActivities(bool newEnablePlasmaActivities)
36{
37 if (mEnablePlasmaActivities != newEnablePlasmaActivities) {
38 mEnablePlasmaActivities = newEnablePlasmaActivities;
40 }
41}
42
43IdentityActivitiesAbstract *IdentityTreeSortProxyModel::identityActivitiesAbstract() const
44{
45 return mIdentityActivitiesAbstract;
46}
47
48void IdentityTreeSortProxyModel::setIdentityActivitiesAbstract(IdentityActivitiesAbstract *newIdentityActivitiesAbstract)
49{
50 if (mIdentityActivitiesAbstract != newIdentityActivitiesAbstract) {
51 mIdentityActivitiesAbstract = newIdentityActivitiesAbstract;
52 connect(mIdentityActivitiesAbstract, &IdentityActivitiesAbstract::activitiesChanged, this, &IdentityTreeSortProxyModel::invalidateFilter);
54 }
55}
56
57#include "moc_identitytreesortproxymodel.cpp"
QMetaObject::Connection connect(const QObject *sender, PointerToMemberFunction signal, Functor functor)
virtual bool filterAcceptsRow(int source_row, const QModelIndex &source_parent) const const
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.