1/*
2 Copyright (c) 2006-2008 Tobias Koenig <tokoe@kde.org>
3
4 This library is free software; you can redistribute it and/or modify it
5 under the terms of the GNU Library General Public License as published by
6 the Free Software Foundation; either version 2 of the License, or (at your
7 option) any later version.
8
9 This library is distributed in the hope that it will be useful, but WITHOUT
10 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
12 License for more details.
13
14 You should have received a copy of the GNU Library General Public License
15 along with this library; see the file COPYING.LIB. If not, write to the
16 Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
17 02110-1301, USA.
18*/
19
20#ifndef AKONADI_AGENTTYPEWIDGET_H
21#define AKONADI_AGENTTYPEWIDGET_H
22
23#include "akonadi_export.h"
24
25#include <QWidget>
26
27namespace Akonadi {
28
29class AgentFilterProxyModel;
30class AgentType;
31
32/**
33 * @short Provides a widget that lists all available agent types.
34 *
35 * The widget is listening on the dbus for changes, so the
36 * widget is updated automatically as soon as new agent types
37 * are added to or removed from the system.
38 *
39 * @code
40 *
41 * Akonadi::AgentTypeWidget *widget = new Akonadi::AgentTypeWidget( this );
42 *
43 * // only list agent types that provide contacts
44 * widget->agentFilterProxyModel()->addMimeTypeFilter( "text/directory" );
45 *
46 * @endcode
47 *
48 * If you want a dialog, you can use the Akonadi::AgentTypeDialog.
49 *
50 * @author Tobias Koenig <tokoe@kde.org>
51 */
52class AKONADI_EXPORT AgentTypeWidget : public QWidget
53{
54 Q_OBJECT
55
56public:
57 /**
58 * Creates a new agent type widget.
59 *
60 * @param parent The parent widget.
61 */
62 explicit AgentTypeWidget(QWidget *parent = 0);
63
64 /**
65 * Destroys the agent type widget.
66 */
67 ~AgentTypeWidget();
68
69 /**
70 * Returns the current agent type or an invalid agent type
71 * if no agent type is selected.
72 */
73 AgentType currentAgentType() const;
74
75 /**
76 * Returns the agent filter proxy model, use this to filter by
77 * agent mimetype or capabilities.
78 */
79 AgentFilterProxyModel *agentFilterProxyModel() const;
80
81Q_SIGNALS:
82 /**
83 * This signal is emitted whenever the current agent type changes.
84 *
85 * @param current The current agent type.
86 * @param previous The previous agent type.
87 */
88 void currentChanged(const Akonadi::AgentType &current, const Akonadi::AgentType &previous);
89
90 /**
91 * This signal is emitted whenever the user activates an agent.
92 * @since 4.2
93 */
94 void activated();
95
96private:
97 //@cond PRIVATE
98 class Private;
99 Private *const d;
100
101 Q_PRIVATE_SLOT(d, void currentAgentTypeChanged(const QModelIndex &, const QModelIndex &))
102 Q_PRIVATE_SLOT(d, void typeActivated(const QModelIndex &index))
103 //@endcond
104};
105
106}
107
108#endif
109