Akonadi

trashfilterproxymodel.cpp
1/*
2 SPDX-FileCopyrightText: 2011 Christian Mollekopf <chrigi_1@fastmail.fm>
3
4 SPDX-License-Identifier: LGPL-2.0-or-later
5*/
6#include "trashfilterproxymodel.h"
7#include "entitydeletedattribute.h"
8#include "entitytreemodel.h"
9#include "item.h"
10
11using namespace Akonadi;
12
13class Akonadi::TrashFilterProxyModelPrivate
14{
15public:
16 TrashFilterProxyModelPrivate()
17 {
18 }
19 bool mTrashIsShown = false;
20};
21
22TrashFilterProxyModel::TrashFilterProxyModel(QObject *parent)
23 : QSortFilterProxyModel(parent)
24 , d_ptr(new TrashFilterProxyModelPrivate())
25{
26 setRecursiveFilteringEnabled(true);
27}
28
29TrashFilterProxyModel::~TrashFilterProxyModel() = default;
30
31void TrashFilterProxyModel::showTrash(bool enable)
32{
34 d->mTrashIsShown = enable;
36}
37
38bool TrashFilterProxyModel::trashIsShown() const
39{
41 return d->mTrashIsShown;
42}
43
44bool TrashFilterProxyModel::filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const
45{
47 const QModelIndex &index = sourceModel()->index(sourceRow, 0, sourceParent);
49 if (item.isValid()) {
51 return d->mTrashIsShown;
52 }
53 }
55 if (collection.isValid()) {
56 if (collection.hasAttribute<EntityDeletedAttribute>()) {
57 return d->mTrashIsShown;
58 }
59 }
60 return !d->mTrashIsShown;
61}
62
63#include "moc_trashfilterproxymodel.cpp"
Represents a collection of PIM items.
Definition collection.h:62
bool hasAttribute(const QByteArray &name) const
Returns true if the collection has an attribute of the given type name, false otherwise.
An Attribute that marks that an entity was marked as deleted.
@ CollectionRole
The collection.
Represents a PIM item stored in Akonadi storage.
Definition item.h:100
bool hasAttribute(const QByteArray &name) const
Returns true if the item has an attribute of the given type name, false otherwise.
bool isValid() const
Returns whether the item is valid.
Definition item.cpp:88
Filter model which hides/shows entities marked as trash.
bool filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const override
Sort filter criteria, according to how expensive the operation is.
Helper integration between Akonadi and Qt.
QVariant data(int role) const const
virtual QModelIndex index(int row, int column, const QModelIndex &parent) const const override
T value() const const
Q_D(Todo)
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Mon Nov 18 2024 12:08:29 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.