MailTransport

transportsortproxymodel.cpp
1/*
2 SPDX-FileCopyrightText: 2024 Laurent Montel <montel@kde.org>
3
4 SPDX-License-Identifier: LGPL-2.0-or-later
5*/
6
7#include "transportsortproxymodel.h"
8#include "transportactivitiesabstract.h"
9#include "transportmodel.h"
10
11using namespace MailTransport;
12TransportSortProxyModel::TransportSortProxyModel(QObject *parent)
13 : QSortFilterProxyModel{parent}
14{
15}
16
17TransportSortProxyModel::~TransportSortProxyModel() = default;
18
19bool TransportSortProxyModel::filterAcceptsRow(int source_row, const QModelIndex &source_parent) const
20{
21 if (mTransportActivitiesAbstract && mEnablePlasmaActivities) {
22 const bool enableActivities = sourceModel()->index(source_row, TransportModel::EnabledActivitiesRole).data().toBool();
23 if (enableActivities) {
24 const auto activities = sourceModel()->index(source_row, TransportModel::ActivitiesRole).data().toStringList();
25 const bool result = mTransportActivitiesAbstract->filterAcceptsRow(activities);
26 // qDebug() << " result " << result << " identity name : " << sourceModel()->index(source_row,
27 // IdentityTreeModel::IdentityNameRole).data().toString();
28 return result;
29 }
30 }
31 return QSortFilterProxyModel::filterAcceptsRow(source_row, source_parent);
32}
33
34bool TransportSortProxyModel::enablePlasmaActivities() const
35{
36 return mEnablePlasmaActivities;
37}
38
39void TransportSortProxyModel::setEnablePlasmaActivities(bool newEnablePlasmaActivities)
40{
41 if (mEnablePlasmaActivities != newEnablePlasmaActivities) {
42 mEnablePlasmaActivities = newEnablePlasmaActivities;
44 }
45}
46
47TransportActivitiesAbstract *TransportSortProxyModel::transportActivitiesAbstract() const
48{
49 return mTransportActivitiesAbstract;
50}
51
52void TransportSortProxyModel::setTransportActivitiesAbstract(TransportActivitiesAbstract *newTransportActivitiesAbstract)
53{
54 if (mTransportActivitiesAbstract != newTransportActivitiesAbstract) {
55 mTransportActivitiesAbstract = newTransportActivitiesAbstract;
56 connect(mTransportActivitiesAbstract, &TransportActivitiesAbstract::activitiesChanged, this, &TransportSortProxyModel::invalidateFilter);
58 }
59}
60
61#include "moc_transportsortproxymodel.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 Sat Dec 21 2024 16:56:10 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.