Akonadi

agenttypemodel.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 AgentTypeModelPrivate;
18
19/**
20 * @short Provides a data model for agent types.
21 *
22 * This class provides the interface of a QAbstractItemModel to
23 * access all available agent types: their name, identifier,
24 * supported mimetypes and capabilities.
25 *
26 * @code
27 *
28 * Akonadi::AgentTypeModel *model = new Akonadi::AgentTypeModel( this );
29 *
30 * QListView *view = new QListView( this );
31 * view->setModel( model );
32 *
33 * @endcode
34 *
35 * To show only agent types 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 AgentTypeModel : 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 nme of the agent type
51 IconNameRole, /// The icon name of the agent
52 IdentifierRole, ///< 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 UserRole = Qt::UserRole + 42 ///< Role for user extensions
57 };
58
59 /**
60 * Creates a new agent type model.
61 */
62 explicit AgentTypeModel(QObject *parent = nullptr);
63
64 /**
65 * Destroys the agent type model.
66 */
67 ~AgentTypeModel() override;
68
69 [[nodiscard]] int columnCount(const QModelIndex &parent = QModelIndex()) const override;
70 [[nodiscard]] int rowCount(const QModelIndex &parent = QModelIndex()) const override;
71 [[nodiscard]] QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;
72 [[nodiscard]] QModelIndex index(int row, int column, const QModelIndex &parent = QModelIndex()) const override;
73 [[nodiscard]] QModelIndex parent(const QModelIndex &index) const override;
74 [[nodiscard]] Qt::ItemFlags flags(const QModelIndex &index) const override;
75 [[nodiscard]] QHash<int, QByteArray> roleNames() const override;
76
77private:
78 /// @cond PRIVATE
79 std::unique_ptr<AgentTypeModelPrivate> const d;
80 /// @endcond
81};
82
83}
Provides a data model for agent types.
~AgentTypeModel() override
Destroys the agent type model.
Roles
Describes the roles of this model.
@ MimeTypesRole
A list of supported mimetypes.
@ IdentifierRole
The icon name of the agent.
@ DescriptionRole
A description of the agent type.
@ IconNameRole
The display nme of the agent type.
@ CapabilitiesRole
A list of supported capabilities.
Helper integration between Akonadi and Qt.
UserRole
typedef ItemFlags
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Fri Nov 1 2024 18:51:22 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.