Akonadi

agenttypemodel.h
1 /*
2  SPDX-FileCopyrightText: 2006-2008 Tobias Koenig <[email protected]>
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 
15 namespace Akonadi
16 {
17 class 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 <[email protected]>
39  */
40 class AKONADICORE_EXPORT AgentTypeModel : public QAbstractItemModel
41 {
42  Q_OBJECT
43 
44 public:
45  /**
46  * Describes the roles of this model.
47  */
48  enum Roles {
49  TypeRole = Qt::UserRole + 1, ///< The agent type itself
50  IdentifierRole, ///< The identifier of the agent type
51  DescriptionRole, ///< A description of the agent type
52  MimeTypesRole, ///< A list of supported mimetypes
53  CapabilitiesRole, ///< A list of supported capabilities
54  UserRole = Qt::UserRole + 42 ///< Role for user extensions
55  };
56 
57  /**
58  * Creates a new agent type model.
59  */
60  explicit AgentTypeModel(QObject *parent = nullptr);
61 
62  /**
63  * Destroys the agent type model.
64  */
65  ~AgentTypeModel() override;
66 
67  Q_REQUIRED_RESULT int columnCount(const QModelIndex &parent = QModelIndex()) const override;
68  Q_REQUIRED_RESULT int rowCount(const QModelIndex &parent = QModelIndex()) const override;
69  Q_REQUIRED_RESULT QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;
70  Q_REQUIRED_RESULT QModelIndex index(int row, int column, const QModelIndex &parent = QModelIndex()) const override;
71  Q_REQUIRED_RESULT QModelIndex parent(const QModelIndex &index) const override;
72  Q_REQUIRED_RESULT Qt::ItemFlags flags(const QModelIndex &index) const override;
73  Q_REQUIRED_RESULT QHash<int, QByteArray> roleNames() const override;
74 
75 private:
76  /// @cond PRIVATE
77  std::unique_ptr<AgentTypeModelPrivate> const d;
78  /// @endcond
79 };
80 
81 }
82 
@ CapabilitiesRole
A list of supported capabilities.
@ MimeTypesRole
A list of supported mimetypes.
UserRole
typedef ItemFlags
@ IdentifierRole
The identifier of the agent type.
Provides a data model for agent types.
Roles
Describes the roles of this model.
@ DescriptionRole
A description of the agent type.
Helper integration between Akonadi and Qt.
This file is part of the KDE documentation.
Documentation copyright © 1996-2022 The KDE developers.
Generated on Sat Jul 2 2022 06:41:46 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.