Messagelib

dkimmanagerkeyproxymodel.cpp
1/*
2 SPDX-FileCopyrightText: 2023-2024 Laurent Montel <montel.org>
3
4 SPDX-License-Identifier: LGPL-2.0-or-later
5*/
6
7#include "dkimmanagerkeyproxymodel.h"
8#include "dkimmanagerkeymodel.h"
9using namespace MessageViewer;
10DKIMManagerKeyProxyModel::DKIMManagerKeyProxyModel(QObject *parent)
11 : QSortFilterProxyModel{parent}
12{
13}
14
15DKIMManagerKeyProxyModel::~DKIMManagerKeyProxyModel() = default;
16
17bool DKIMManagerKeyProxyModel::lessThan(const QModelIndex &source_left, const QModelIndex &source_right) const
18{
19 // const auto leftData = source_left.data(MessageViewer::DKIMManagerKeyModel::StoredAtDateTimeRole).value<Akonadi::Collection>();
20 // const auto rightData = source_right.data(MessageViewer::DKIMManagerKeyModel::StoredAtDateTimeRole).value<Akonadi::Collection>();
21 return QSortFilterProxyModel::lessThan(source_left, source_right);
22}
23
24bool DKIMManagerKeyProxyModel::filterAcceptsRow(int source_row, const QModelIndex &source_parent) const
25{
26 if (mFilterText.isEmpty()) {
27 return true;
28 }
29 if (sourceModel()->index(source_row, MessageViewer::DKIMManagerKeyModel::DomainRole, source_parent).data().toString().contains(mFilterText)
30 || sourceModel()->index(source_row, MessageViewer::DKIMManagerKeyModel::SelectorRole, source_parent).data().toString().contains(mFilterText)
31 || sourceModel()->index(source_row, MessageViewer::DKIMManagerKeyModel::KeyRole, source_parent).data().toString().contains(mFilterText)) {
32 return true;
33 }
34 return false;
35}
36
37QString DKIMManagerKeyProxyModel::filterText() const
38{
39 return mFilterText;
40}
41
42void DKIMManagerKeyProxyModel::setFilterText(const QString &newFilterText)
43{
44 if (mFilterText != newFilterText) {
45 mFilterText = newFilterText;
47 }
48}
char * toString(const EngineQuery &query)
virtual QVariant data(const QModelIndex &index, int role) const const override
virtual QModelIndex index(int row, int column, const QModelIndex &parent) const const override
virtual bool lessThan(const QModelIndex &source_left, const QModelIndex &source_right) const const
bool isEmpty() const const
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Mon Nov 4 2024 16:33:26 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.