Akonadi

agentinstancemodel.h
1/*
2 SPDX-FileCopyrightText: 2006-2008 Tobias Koenig <tokoe@kde.org>
3
4 SPDX-License-Identifier: LGPL-2.0-or-later
5*/
6
7#pragma once
8
9#include "akonadicore_export.h"
10
11#include <QAbstractItemModel>
12
13#include <memory>
14
15namespace Akonadi
16{
17class AgentInstanceModelPrivate;
18
19/**
20 * @short Provides a data model for agent instances.
21 *
22 * This class provides the interface of a QAbstractItemModel to
23 * access all available agent instances: their name, identifier,
24 * supported mimetypes and capabilities.
25 *
26 * @code
27 *
28 * Akonadi::AgentInstanceModel *model = new Akonadi::AgentInstanceModel( this );
29 *
30 * QListView *view = new QListView( this );
31 * view->setModel( model );
32 *
33 * @endcode
34 *
35 * To show only agent instances that match a given mime type or special
36 * capabilities, use the AgentFilterProxyModel on top of this model.
37 *
38 * @author Tobias Koenig <tokoe@kde.org>
39 */
40class AKONADICORE_EXPORT AgentInstanceModel : public QAbstractItemModel
41{
42 Q_OBJECT
43
44public:
45 /**
46 * Describes the roles of this model.
47 */
48 enum Roles {
49 TypeRole = Qt::UserRole + 1, ///< The agent type itself
50 NameRole, /// The display name of the agent type
51 IconNameRole, /// The icon name of the agent
52 TypeIdentifierRole, ///< The identifier of the agent type
53 DescriptionRole, ///< A description of the agent type
54 MimeTypesRole, ///< A list of supported mimetypes
55 CapabilitiesRole, ///< A list of supported capabilities
56 InstanceRole, ///< The agent instance itself
57 InstanceIdentifierRole, ///< The identifier of the agent instance
58 StatusRole, ///< The current status (numerical) of the instance
59 StatusMessageRole, ///< A textual presentation of the current status
60 ProgressRole, ///< The current progress (numerical in percent) of an operation
61 OnlineRole, ///< The current online/offline status
62 ActivitiesRole, ///< A list of activities
63 ActivitiesEnabledRole, ///< Return true if activities is enabled on agent
64 UserRole = Qt::UserRole + 42 ///< Role for user extensions
65 };
66
67 /**
68 * Creates a new agent instance model.
69 *
70 * @param parent The parent object.
71 */
72 explicit AgentInstanceModel(QObject *parent = nullptr);
73
74 /**
75 * Destroys the agent instance model.
76 */
78
79 [[nodiscard]] QHash<int, QByteArray> roleNames() const override;
80 [[nodiscard]] int columnCount(const QModelIndex &parent = QModelIndex()) const override;
81 [[nodiscard]] int rowCount(const QModelIndex &parent = QModelIndex()) const override;
82 [[nodiscard]] QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;
83 [[nodiscard]] QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const override;
84 [[nodiscard]] QModelIndex index(int row, int column, const QModelIndex &parent = QModelIndex()) const override;
85 [[nodiscard]] QModelIndex parent(const QModelIndex &index) const override;
86 [[nodiscard]] Qt::ItemFlags flags(const QModelIndex &index) const override;
87 [[nodiscard]] bool setData(const QModelIndex &index, const QVariant &value, int role) override;
88
89private:
90 /// @cond PRIVATE
91 friend class AgentInstanceModelPrivate;
92 std::unique_ptr<AgentInstanceModelPrivate> const d;
93 /// @endcond
94};
95
96}
Provides a data model for agent instances.
Roles
Describes the roles of this model.
@ StatusMessageRole
A textual presentation of the current status.
@ ActivitiesRole
A list of activities.
@ OnlineRole
The current online/offline status.
@ StatusRole
The current status (numerical) of the instance.
@ MimeTypesRole
A list of supported mimetypes.
@ InstanceRole
The agent instance itself.
@ DescriptionRole
A description of the agent type.
@ InstanceIdentifierRole
The identifier of the agent instance.
@ TypeIdentifierRole
The icon name of the agent.
@ CapabilitiesRole
A list of supported capabilities.
@ ActivitiesEnabledRole
Return true if activities is enabled on agent.
@ IconNameRole
The display name of the agent type.
@ ProgressRole
The current progress (numerical in percent) of an operation.
~AgentInstanceModel() override
Destroys the agent instance model.
Helper integration between Akonadi and Qt.
UserRole
typedef ItemFlags
Orientation
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Mon Nov 18 2024 12:08:29 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.