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 UserRole = Qt::UserRole + 42 ///< Role for user extensions
63 };
64
65 /**
66 * Creates a new agent instance model.
67 *
68 * @param parent The parent object.
69 */
70 explicit AgentInstanceModel(QObject *parent = nullptr);
71
72 /**
73 * Destroys the agent instance model.
74 */
76
77 [[nodiscard]] QHash<int, QByteArray> roleNames() const override;
78 [[nodiscard]] int columnCount(const QModelIndex &parent = QModelIndex()) const override;
79 [[nodiscard]] int rowCount(const QModelIndex &parent = QModelIndex()) const override;
80 [[nodiscard]] QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;
81 [[nodiscard]] QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const override;
82 [[nodiscard]] QModelIndex index(int row, int column, const QModelIndex &parent = QModelIndex()) const override;
83 [[nodiscard]] QModelIndex parent(const QModelIndex &index) const override;
84 [[nodiscard]] Qt::ItemFlags flags(const QModelIndex &index) const override;
85 [[nodiscard]] bool setData(const QModelIndex &index, const QVariant &value, int role) override;
86
87private:
88 /// @cond PRIVATE
89 friend class AgentInstanceModelPrivate;
90 std::unique_ptr<AgentInstanceModelPrivate> const d;
91 /// @endcond
92};
93
94}
Provides a data model for agent instances.
Roles
Describes the roles of this model.
@ StatusMessageRole
A textual presentation of the current status.
@ 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.
@ 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 Fri Jun 21 2024 11:57:48 by doxygen 1.10.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.