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"
9 using namespace MessageViewer;
10 DKIMManagerKeyProxyModel::DKIMManagerKeyProxyModel(QObject *parent)
12 {
13 }
14 
15 DKIMManagerKeyProxyModel::~DKIMManagerKeyProxyModel() = default;
16 
17 bool 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 
24 bool 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 
37 QString DKIMManagerKeyProxyModel::filterText() const
38 {
39  return mFilterText;
40 }
41 
42 void DKIMManagerKeyProxyModel::setFilterText(const QString &newFilterText)
43 {
44  if (mFilterText != newFilterText) {
45  mFilterText = newFilterText;
46  invalidateFilter();
47  }
48 }
virtual bool lessThan(const QModelIndex &source_left, const QModelIndex &source_right) const const
QObject * parent() const const
char * toString(const EngineQuery &query)
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Thu Feb 15 2024 03:55:20 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.