File indexing completed on 2024-06-23 05:07:16

0001 /*
0002     SPDX-FileCopyrightText: 2006-2008 Tobias Koenig <tokoe@kde.org>
0003 
0004     SPDX-License-Identifier: LGPL-2.0-or-later
0005 */
0006 
0007 #pragma once
0008 
0009 #include "akonadiwidgets_export.h"
0010 
0011 #include <QWidget>
0012 
0013 #include <memory>
0014 
0015 namespace Akonadi
0016 {
0017 class AgentFilterProxyModel;
0018 class AgentType;
0019 class AgentTypeWidgetPrivate;
0020 
0021 /**
0022  * @short Provides a widget that lists all available agent types.
0023  *
0024  * The widget is listening on the dbus for changes, so the
0025  * widget is updated automatically as soon as new agent types
0026  * are added to or removed from the system.
0027  *
0028  * @code
0029  *
0030  * Akonadi::AgentTypeWidget *widget = new Akonadi::AgentTypeWidget( this );
0031  *
0032  * // only list agent types that provide contacts
0033  * widget->agentFilterProxyModel()->addMimeTypeFilter( "text/directory" );
0034  *
0035  * @endcode
0036  *
0037  * If you want a dialog, you can use the Akonadi::AgentTypeDialog.
0038  *
0039  * @author Tobias Koenig <tokoe@kde.org>
0040  */
0041 class AKONADIWIDGETS_EXPORT AgentTypeWidget : public QWidget
0042 {
0043     Q_OBJECT
0044 
0045 public:
0046     /**
0047      * Creates a new agent type widget.
0048      *
0049      * @param parent The parent widget.
0050      */
0051     explicit AgentTypeWidget(QWidget *parent = nullptr);
0052 
0053     /**
0054      * Destroys the agent type widget.
0055      */
0056     ~AgentTypeWidget() override;
0057 
0058     /**
0059      * Returns the current agent type or an invalid agent type
0060      * if no agent type is selected.
0061      */
0062     [[nodiscard]] AgentType currentAgentType() const;
0063 
0064     /**
0065      * Returns the agent filter proxy model, use this to filter by
0066      * agent mimetype or capabilities.
0067      */
0068     [[nodiscard]] AgentFilterProxyModel *agentFilterProxyModel() const;
0069 
0070 Q_SIGNALS:
0071     /**
0072      * This signal is emitted whenever the current agent type changes.
0073      *
0074      * @param current The current agent type.
0075      * @param previous The previous agent type.
0076      */
0077     void currentChanged(const Akonadi::AgentType &current, const Akonadi::AgentType &previous);
0078 
0079     /**
0080      * This signal is emitted whenever the user activates an agent.
0081      * @since 4.2
0082      */
0083     void activated();
0084 
0085 private:
0086     /// @cond PRIVATE
0087     std::unique_ptr<AgentTypeWidgetPrivate> const d;
0088     /// @endcond
0089 };
0090 
0091 }