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 * @short A proxy model for filtering AgentType or AgentInstance
19 *
20 * This filter proxy model works on top of a AgentTypeModel or AgentInstanceModel
21 * and can be used to show only AgentType or AgentInstance objects
22 * which provide a given mime type or capability.
23 *
24 * @code
25 *
26 * // Show only running agent instances that provide contacts
27 * Akonadi::AgentInstanceModel *model = new Akonadi::AgentInstanceModel( this );
28 *
29 * Akonadi::AgentFilterProxyModel *proxy = new Akonadi::AgentFilterProxyModel( this );
30 * proxy->addMimeTypeFilter( "text/directory" );
31 *
32 * proxy->setSourceModel( model );
33 *
34 * QListView *view = new QListView( this );
35 * view->setModel( proxy );
36 *
37 * @endcode
38 *
39 * @author Volker Krause <vkrause@kde.org>
40 */
41class AKONADICORE_EXPORT AgentFilterProxyModel : public QSortFilterProxyModel
42{
43 Q_OBJECT
44public:
45 /**
46 * Create a new agent filter proxy model.
47 * By default no filtering is done.
48 * @param parent parent object
49 */
50 explicit AgentFilterProxyModel(QObject *parent = nullptr);
51
52 /**
53 * Destroys the agent filter proxy model.
54 */
56
57 /**
58 * Accept agents supporting @p mimeType.
59 */
60 void addMimeTypeFilter(const QString &mimeType);
61
62 /**
63 * Accept agents with the given @p capability.
64 */
65 void addCapabilityFilter(const QString &capability);
66
67 /**
68 * Clear the filters ( mimeTypes & capabilities ).
69 */
70 void clearFilters();
71
72 /**
73 * Excludes agents with the given @p capability.
74 * @param capability undesired agent capability
75 * @since 4.6
76 */
77 void excludeCapabilities(const QString &capability);
78
79protected:
80 bool filterAcceptsRow(int row, const QModelIndex &parent) const override;
81
82private:
83 /// @cond PRIVATE
84 std::unique_ptr<AgentFilterProxyModelPrivate> const d;
85 /// @endcond
86};
87
88}
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 Fri Oct 11 2024 12:11:39 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.