Akonadi

trashfilterproxymodel.h
1/*
2 SPDX-FileCopyrightText: 2011 Christian Mollekopf <chrigi_1@fastmail.fm>
3
4 SPDX-License-Identifier: LGPL-2.0-or-later
5*/
6
7#pragma once
8
9#include "akonadicore_export.h"
10
11#include <QSortFilterProxyModel>
12
13#include <memory>
14
15namespace Akonadi
16{
17class TrashFilterProxyModelPrivate;
18
19/**
20 * @short Filter model which hides/shows entities marked as trash
21 *
22 * Filter model which either hides all entities marked as trash, or the ones not marked.
23 * Subentities of collections marked as trash are also shown in the trash.
24 *
25 * The Base model must be an EntityTreeModel and the EntityDeletedAttribute must be available.
26 *
27 * Example:
28 *
29 * @code
30 *
31 * ChangeRecorder *monitor = new Akonadi::ChangeRecorder( this );
32 * monitor->itemFetchScope().fetchAttribute<Akonadi::EntityDisplayAttribute>(true);
33 *
34 * Akonadi::EntityTreeModel *sourcemodel = new Akonadi::EntityTreeModel(monitor, this);
35 *
36 * TrashFilterProxyModel *model = new TrashFilterProxyModel(this);
37 * model->setDynamicSortFilter(true);
38 * model->setSourceModel(sourcemodel);
39 *
40 * @endcode
41 *
42 * @author Christian Mollekopf <chrigi_1@fastmail.fm>
43 * @since 4.8
44 */
45class AKONADICORE_EXPORT TrashFilterProxyModel : public QSortFilterProxyModel
46{
47 Q_OBJECT
48
49public:
50 explicit TrashFilterProxyModel(QObject *parent = nullptr);
51 ~TrashFilterProxyModel() override;
52
53 void showTrash(bool enable);
54 [[nodiscard]] bool trashIsShown() const;
55
56protected:
57 /**
58 * Sort filter criteria, according to how expensive the operation is
59 */
60 bool filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const override;
61
62private:
63 /// @cond PRIVATE
64 std::unique_ptr<TrashFilterProxyModelPrivate> const d_ptr;
65 Q_DECLARE_PRIVATE(TrashFilterProxyModel)
66 /// @endcond
67};
68
69}
Filter model which hides/shows entities marked as trash.
Helper integration between Akonadi and Qt.
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Fri Jul 26 2024 11:52:52 by doxygen 1.11.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.