Akonadi

trashfilterproxymodel.h
1 /*
2  SPDX-FileCopyrightText: 2011 Christian Mollekopf <[email protected]>
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 
15 namespace Akonadi
16 {
17 class 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 <[email protected]>
43  * @since 4.8
44  */
45 class AKONADICORE_EXPORT TrashFilterProxyModel : public QSortFilterProxyModel
46 {
47  Q_OBJECT
48 
49 public:
50  explicit TrashFilterProxyModel(QObject *parent = nullptr);
51  ~TrashFilterProxyModel() override;
52 
53  void showTrash(bool enable);
54  Q_REQUIRED_RESULT bool trashIsShown() const;
55 
56 protected:
57  /**
58  * Sort filter criteria, according to how expensive the operation is
59  */
60  bool filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const override;
61 
62 private:
63  /// @cond PRIVATE
64  std::unique_ptr<TrashFilterProxyModelPrivate> const d_ptr;
65  Q_DECLARE_PRIVATE(TrashFilterProxyModel)
66  /// @endcond
67 };
68 
69 }
70 
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-2022 The KDE developers.
Generated on Mon Jun 27 2022 04:01:08 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.