Akonadi Calendar

calfilterproxymodel.cpp
1/*
2 SPDX-FileCopyrightText: 2009 KDAB
3 SPDX-FileContributor: Frank Osterfeld <osterfeld@kde.org>
4
5 SPDX-License-Identifier: LGPL-2.0-or-later
6*/
7
8#include "calfilterproxymodel.h"
9#include "calendarutils.h"
10
11#include <Akonadi/EntityTreeModel>
12#include <Akonadi/Item>
13
14#include <KCalendarCore/CalFilter>
15#include <KCalendarCore/Incidence>
16
17using namespace Akonadi;
18
19class Akonadi::CalFilterProxyModelPrivate
20{
21public:
22 explicit CalFilterProxyModelPrivate() = default;
23
24 KCalendarCore::CalFilter *filter = nullptr;
25};
26
27CalFilterProxyModel::CalFilterProxyModel(QObject *parent)
28 : QSortFilterProxyModel(parent)
29 , d(new CalFilterProxyModelPrivate)
30{
31 setFilterKeyColumn(0);
32}
33
34CalFilterProxyModel::~CalFilterProxyModel() = default;
35
36KCalendarCore::CalFilter *CalFilterProxyModel::filter() const
37{
38 return d->filter;
39}
40
41void CalFilterProxyModel::setFilter(KCalendarCore::CalFilter *filter)
42{
43 if (filter == d->filter) {
44 return;
45 }
46
47 d->filter = filter;
49}
50
51bool CalFilterProxyModel::filterAcceptsRow(int source_row, const QModelIndex &source_parent) const
52{
53 if (!d->filter) {
54 return true;
55 }
56
57 const QModelIndex idx = sourceModel()->index(source_row, 0, source_parent);
58 if (!idx.isValid()) {
59 return false;
60 }
61
63 if (!item.isValid()) {
64 return false;
65 }
66
68 if (!incidence) {
69 return false;
70 }
71
72 return d->filter->filterIncidence(incidence);
73}
74
75#include "moc_calfilterproxymodel.cpp"
AKONADI_CALENDAR_EXPORT KCalendarCore::Incidence::Ptr incidence(const Akonadi::Item &item)
Returns the incidence from an Akonadi item, or a null pointer if the item has no such payload.
FreeBusyManager::Singleton.
QVariant data(int role) const const
bool isValid() const const
QFuture< void > filter(QThreadPool *pool, Sequence &sequence, KeepFunctor &&filterFunction)
T value() const const
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Fri Nov 8 2024 12:03:45 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.