Akonadi

agentinstancemodel.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 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 <[email protected]>
39  */
40 class AKONADICORE_EXPORT AgentInstanceModel : 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  TypeIdentifierRole, ///< 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  InstanceRole, ///< The agent instance itself
55  InstanceIdentifierRole, ///< The identifier of the agent instance
56  StatusRole, ///< The current status (numerical) of the instance
57  StatusMessageRole, ///< A textual presentation of the current status
58  ProgressRole, ///< The current progress (numerical in percent) of an operation
59  OnlineRole, ///< The current online/offline status
60  UserRole = Qt::UserRole + 42 ///< Role for user extensions
61  };
62 
63  /**
64  * Creates a new agent instance model.
65  *
66  * @param parent The parent object.
67  */
68  explicit AgentInstanceModel(QObject *parent = nullptr);
69 
70  /**
71  * Destroys the agent instance model.
72  */
73  ~AgentInstanceModel() override;
74 
75  Q_REQUIRED_RESULT QHash<int, QByteArray> roleNames() const override;
76  Q_REQUIRED_RESULT int columnCount(const QModelIndex &parent = QModelIndex()) const override;
77  Q_REQUIRED_RESULT int rowCount(const QModelIndex &parent = QModelIndex()) const override;
78  Q_REQUIRED_RESULT QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;
79  Q_REQUIRED_RESULT QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const override;
80  Q_REQUIRED_RESULT QModelIndex index(int row, int column, const QModelIndex &parent = QModelIndex()) const override;
81  Q_REQUIRED_RESULT QModelIndex parent(const QModelIndex &index) const override;
82  Q_REQUIRED_RESULT Qt::ItemFlags flags(const QModelIndex &index) const override;
83  Q_REQUIRED_RESULT bool setData(const QModelIndex &index, const QVariant &value, int role) override;
84 
85 private:
86  /// @cond PRIVATE
87  friend class AgentInstanceModelPrivate;
88  std::unique_ptr<AgentInstanceModelPrivate> const d;
89  /// @endcond
90 };
91 
92 }
93 
@ ProgressRole
The current progress (numerical in percent) of an operation.
@ InstanceRole
The agent instance itself.
UserRole
@ InstanceIdentifierRole
The identifier of the agent instance.
@ CapabilitiesRole
A list of supported capabilities.
@ MimeTypesRole
A list of supported mimetypes.
typedef ItemFlags
@ DescriptionRole
A description of the agent type.
@ StatusMessageRole
A textual presentation of the current status.
Orientation
Provides a data model for agent instances.
@ TypeIdentifierRole
The identifier of the agent type.
@ OnlineRole
The current online/offline status.
@ StatusRole
The current status (numerical) of the instance.
Helper integration between Akonadi and Qt.
Roles
Describes the roles of this model.
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.