Akonadi

agentinstancefilterproxymodel.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 AgentInstanceFilterProxyModelPrivate;
17class AccountActivitiesAbstract;
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::AgentInstanceFilterProxyModel *proxy = new Akonadi::AgentInstanceFilterProxyModel( 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 */
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 AgentInstanceFilterProxyModel(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
80 [[nodiscard]] bool enablePlasmaActivities() const;
81 void setEnablePlasmaActivities(bool newEnablePlasmaActivities);
82
83 [[nodiscard]] AccountActivitiesAbstract *accountActivitiesAbstract() const;
84 void setAccountActivitiesAbstract(AccountActivitiesAbstract *abstract);
85
86protected:
87 bool filterAcceptsRow(int row, const QModelIndex &parent) const override;
88
89private:
90 /// @cond PRIVATE
91 std::unique_ptr<AgentInstanceFilterProxyModelPrivate> const d;
92 /// @endcond
93};
94
95}
A proxy model for filtering AgentType or AgentInstance.
~AgentInstanceFilterProxyModel() 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.