File indexing completed on 2024-06-16 04:50:35
0001 /* 0002 SPDX-FileCopyrightText: 2006-2008 Tobias Koenig <tokoe@kde.org> 0003 SPDX-FileCopyrightText: 2012-2024 Laurent Montel <montel@kde.org> 0004 0005 SPDX-License-Identifier: LGPL-2.0-or-later 0006 */ 0007 0008 #pragma once 0009 0010 #include "akonadiwidgets_export.h" 0011 0012 #include <QWidget> 0013 0014 #include <memory> 0015 0016 class QAbstractItemView; 0017 namespace Akonadi 0018 { 0019 class AgentInstance; 0020 class AgentFilterProxyModel; 0021 class AgentInstanceWidgetPrivate; 0022 0023 /** 0024 * @short Provides a widget that lists all available agent instances. 0025 * 0026 * The widget is listening on the dbus for changes, so the 0027 * widget is updated automatically as soon as new agent instances 0028 * are added to or removed from the system. 0029 * 0030 * @code 0031 * 0032 * MyWidget::MyWidget( QWidget *parent ) 0033 * : QWidget( parent ) 0034 * { 0035 * QVBoxLayout *layout = new QVBoxLayout( this ); 0036 * 0037 * mAgentInstanceWidget = new Akonadi::AgentInstanceWidget( this ); 0038 * layout->addWidget( mAgentInstanceWidget ); 0039 * 0040 * connect( mAgentInstanceWidget, SIGNAL(doubleClicked(Akonadi::AgentInstance)), 0041 * this, SLOT(slotInstanceSelected(Akonadi::AgentInstance)) ); 0042 * } 0043 * 0044 * ... 0045 * 0046 * MyWidget::slotInstanceSelected( Akonadi::AgentInstance &instance ) 0047 * { 0048 * qCDebug(AKONADIWIDGETS_LOG) << "Selected instance" << instance.name(); 0049 * } 0050 * 0051 * @endcode 0052 * 0053 * @author Tobias Koenig <tokoe@kde.org> 0054 */ 0055 class AKONADIWIDGETS_EXPORT AgentInstanceWidget : public QWidget 0056 { 0057 Q_OBJECT 0058 0059 public: 0060 /** 0061 * Creates a new agent instance widget. 0062 * 0063 * @param parent The parent widget. 0064 */ 0065 explicit AgentInstanceWidget(QWidget *parent = nullptr); 0066 0067 /** 0068 * Destroys the agent instance widget. 0069 */ 0070 ~AgentInstanceWidget() override; 0071 0072 /** 0073 * Returns the current agent instance or an invalid agent instance 0074 * if no agent instance is selected. 0075 */ 0076 [[nodiscard]] AgentInstance currentAgentInstance() const; 0077 0078 /** 0079 * Returns the selected agent instances. 0080 * @since 4.5 0081 */ 0082 [[nodiscard]] QList<AgentInstance> selectedAgentInstances() const; 0083 0084 /** 0085 * Returns the agent filter proxy model, use this to filter by 0086 * agent mimetype or capabilities. 0087 */ 0088 [[nodiscard]] AgentFilterProxyModel *agentFilterProxyModel() const; 0089 0090 /** 0091 * Returns the view used in the widget. 0092 * @since 4.5 0093 */ 0094 [[nodiscard]] QAbstractItemView *view() const; 0095 0096 Q_SIGNALS: 0097 /** 0098 * This signal is emitted whenever the current agent instance changes. 0099 * 0100 * @param current The current agent instance. 0101 * @param previous The previous agent instance. 0102 */ 0103 void currentChanged(const Akonadi::AgentInstance ¤t, const Akonadi::AgentInstance &previous); 0104 0105 /** 0106 * This signal is emitted whenever there is a double click on an agent instance. 0107 * 0108 * @param current The current agent instance. 0109 */ 0110 void doubleClicked(const Akonadi::AgentInstance ¤t); 0111 0112 /** 0113 * This signal is emitted whenever there is a click on an agent instance. 0114 * 0115 * @param current The current agent instance. 0116 * @since 4.9.1 0117 */ 0118 void clicked(const Akonadi::AgentInstance ¤t); 0119 0120 private: 0121 /// @cond PRIVATE 0122 std::unique_ptr<AgentInstanceWidgetPrivate> const d; 0123 /// @endcond 0124 }; 0125 0126 }