Akonadi

agentinstancewidget.h
1 /*
2  SPDX-FileCopyrightText: 2006-2008 Tobias Koenig <[email protected]>
3  SPDX-FileCopyrightText: 2012-2022 Laurent Montel <[email protected]>
4 
5  SPDX-License-Identifier: LGPL-2.0-or-later
6 */
7 
8 #pragma once
9 
10 #include "akonadiwidgets_export.h"
11 
12 #include <QWidget>
13 
14 #include <memory>
15 
16 class QAbstractItemView;
17 namespace Akonadi
18 {
19 class AgentInstance;
20 class AgentFilterProxyModel;
21 class AgentInstanceWidgetPrivate;
22 
23 /**
24  * @short Provides a widget that lists all available agent instances.
25  *
26  * The widget is listening on the dbus for changes, so the
27  * widget is updated automatically as soon as new agent instances
28  * are added to or removed from the system.
29  *
30  * @code
31  *
32  * MyWidget::MyWidget( QWidget *parent )
33  * : QWidget( parent )
34  * {
35  * QVBoxLayout *layout = new QVBoxLayout( this );
36  *
37  * mAgentInstanceWidget = new Akonadi::AgentInstanceWidget( this );
38  * layout->addWidget( mAgentInstanceWidget );
39  *
40  * connect( mAgentInstanceWidget, SIGNAL(doubleClicked(Akonadi::AgentInstance)),
41  * this, SLOT(slotInstanceSelected(Akonadi::AgentInstance)) );
42  * }
43  *
44  * ...
45  *
46  * MyWidget::slotInstanceSelected( Akonadi::AgentInstance &instance )
47  * {
48  * qCDebug(AKONADIWIDGETS_LOG) << "Selected instance" << instance.name();
49  * }
50  *
51  * @endcode
52  *
53  * @author Tobias Koenig <[email protected]>
54  */
55 class AKONADIWIDGETS_EXPORT AgentInstanceWidget : public QWidget
56 {
57  Q_OBJECT
58 
59 public:
60  /**
61  * Creates a new agent instance widget.
62  *
63  * @param parent The parent widget.
64  */
65  explicit AgentInstanceWidget(QWidget *parent = nullptr);
66 
67  /**
68  * Destroys the agent instance widget.
69  */
70  ~AgentInstanceWidget() override;
71 
72  /**
73  * Returns the current agent instance or an invalid agent instance
74  * if no agent instance is selected.
75  */
76  Q_REQUIRED_RESULT AgentInstance currentAgentInstance() const;
77 
78  /**
79  * Returns the selected agent instances.
80  * @since 4.5
81  */
82  Q_REQUIRED_RESULT QVector<AgentInstance> selectedAgentInstances() const;
83 
84  /**
85  * Returns the agent filter proxy model, use this to filter by
86  * agent mimetype or capabilities.
87  */
88  Q_REQUIRED_RESULT AgentFilterProxyModel *agentFilterProxyModel() const;
89 
90  /**
91  * Returns the view used in the widget.
92  * @since 4.5
93  */
94  Q_REQUIRED_RESULT QAbstractItemView *view() const;
95 
96 Q_SIGNALS:
97  /**
98  * This signal is emitted whenever the current agent instance changes.
99  *
100  * @param current The current agent instance.
101  * @param previous The previous agent instance.
102  */
103  void currentChanged(const Akonadi::AgentInstance &current, const Akonadi::AgentInstance &previous);
104 
105  /**
106  * This signal is emitted whenever there is a double click on an agent instance.
107  *
108  * @param current The current agent instance.
109  */
110  void doubleClicked(const Akonadi::AgentInstance &current);
111 
112  /**
113  * This signal is emitted whenever there is a click on an agent instance.
114  *
115  * @param current The current agent instance.
116  * @since 4.9.1
117  */
118  void clicked(const Akonadi::AgentInstance &current);
119 
120 private:
121  /// @cond PRIVATE
122  std::unique_ptr<AgentInstanceWidgetPrivate> const d;
123  /// @endcond
124 };
125 
126 }
127 
Represents one agent instance and takes care of communication with it.
Provides a widget that lists all available agent instances.
A proxy model for filtering AgentType or AgentInstance.
A representation of an agent instance.
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.