Akonadi

agentfilterproxymodel.h
1/*
2 SPDX-FileCopyrightText: 2007 Volker Krause <vkrause@kde.org>
3
4 SPDX-License-Identifier: LGPL-2.0-or-later
5*/
6
7#pragma once
8
9#include "akonadicore_export.h"
10#include <QSortFilterProxyModel>
11
12#include <memory>
13
14namespace Akonadi
15{
16class AgentFilterProxyModelPrivate;
17
18/**
19 * @short A proxy model for filtering AgentType or AgentInstance
20 *
21 * This filter proxy model works on top of a AgentTypeModel or AgentInstanceModel
22 * and can be used to show only AgentType or AgentInstance objects
23 * which provide a given mime type or capability.
24 *
25 * @code
26 *
27 * // Show only running agent instances that provide contacts
28 * Akonadi::AgentInstanceModel *model = new Akonadi::AgentInstanceModel( this );
29 *
30 * Akonadi::AgentFilterProxyModel *proxy = new Akonadi::AgentFilterProxyModel( this );
31 * proxy->addMimeTypeFilter( "text/directory" );
32 *
33 * proxy->setSourceModel( model );
34 *
35 * QListView *view = new QListView( this );
36 * view->setModel( proxy );
37 *
38 * @endcode
39 *
40 * @author Volker Krause <vkrause@kde.org>
41 */
42class AKONADICORE_EXPORT AgentFilterProxyModel : public QSortFilterProxyModel
43{
44 Q_OBJECT
45public:
46 /**
47 * Create a new agent filter proxy model.
48 * By default no filtering is done.
49 * @param parent parent object
50 */
51 explicit AgentFilterProxyModel(QObject *parent = nullptr);
52
53 /**
54 * Destroys the agent filter proxy model.
55 */
57
58 /**
59 * Accept agents supporting @p mimeType.
60 */
61 void addMimeTypeFilter(const QString &mimeType);
62
63 /**
64 * Accept agents with the given @p capability.
65 */
66 void addCapabilityFilter(const QString &capability);
67
68 /**
69 * Clear the filters ( mimeTypes & capabilities ).
70 */
71 void clearFilters();
72
73 /**
74 * Excludes agents with the given @p capability.
75 * @param capability undesired agent capability
76 * @since 4.6
77 */
78 void excludeCapabilities(const QString &capability);
79
80protected:
81 bool filterAcceptsRow(int row, const QModelIndex &parent) const override;
82
83private:
84 /// @cond PRIVATE
85 std::unique_ptr<AgentFilterProxyModelPrivate> const d;
86 /// @endcond
87};
88
89}
A proxy model for filtering AgentType or AgentInstance.
~AgentFilterProxyModel() override
Destroys the agent filter proxy model.
Helper integration between Akonadi and Qt.
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Tue Mar 26 2024 11:13:38 by doxygen 1.10.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.