File indexing completed on 2024-11-24 04:50:45
0001 // SPDX-FileCopyrightText: 2021 Carl Schwan <carlschwan@kde.org> 0002 // SPDX-License-Identifier: LGPL-2.1-or-later 0003 0004 #pragma once 0005 0006 #include <Akonadi/AgentFilterProxyModel> 0007 #include <Akonadi/AgentInstance> 0008 0009 class AgentConfiguration : public QObject 0010 { 0011 Q_OBJECT 0012 Q_PROPERTY(Akonadi::AgentFilterProxyModel *availableAgents READ availableAgents NOTIFY availableAgentsChanged) 0013 Q_PROPERTY(Akonadi::AgentFilterProxyModel *runningAgents READ runningAgents NOTIFY runningAgentsChanged) 0014 Q_PROPERTY(QStringList mimetypes READ mimetypes WRITE setMimetypes NOTIFY mimetypesChanged) 0015 public: 0016 enum AgentStatuses { 0017 Idle = Akonadi::AgentInstance::Idle, 0018 Running = Akonadi::AgentInstance::Running, 0019 Broken = Akonadi::AgentInstance::Broken, 0020 NotConfigured = Akonadi::AgentInstance::NotConfigured, 0021 }; 0022 Q_ENUM(AgentStatuses) 0023 0024 explicit AgentConfiguration(QObject *parent = nullptr); 0025 ~AgentConfiguration() override; 0026 0027 Akonadi::AgentFilterProxyModel *availableAgents(); 0028 Akonadi::AgentFilterProxyModel *runningAgents(); 0029 QStringList mimetypes() const; 0030 void setMimetypes(QStringList mimetypes); 0031 0032 Q_INVOKABLE void createNew(int index); 0033 Q_INVOKABLE void edit(int index); 0034 Q_INVOKABLE void editIdentifier(const QString &resourceIdentifier); 0035 Q_INVOKABLE void remove(int index); 0036 Q_INVOKABLE void removeIdentifier(const QString &resourceIdentifier); 0037 Q_INVOKABLE void restart(int index); 0038 Q_INVOKABLE void restartIdentifier(const QString &resourceIdentifier); 0039 0040 public Q_SLOTS: 0041 void processInstanceProgressChanged(const Akonadi::AgentInstance &instance); 0042 0043 Q_SIGNALS: 0044 void agentProgressChanged(const QVariantMap agentData); 0045 void mimetypesChanged(); 0046 void runningAgentsChanged(); 0047 void availableAgentsChanged(); 0048 0049 private: 0050 void setupEdit(Akonadi::AgentInstance instance); 0051 void setupRemove(const Akonadi::AgentInstance &instance); 0052 void setupRestart(Akonadi::AgentInstance instance); 0053 0054 Akonadi::AgentFilterProxyModel *m_runningAgents = nullptr; 0055 Akonadi::AgentFilterProxyModel *m_availableAgents = nullptr; 0056 QStringList m_mimetypes; 0057 };