Libksieve

managesievewidget.h
1/*
2 SPDX-FileCopyrightText: 2014-2024 Laurent Montel <montel@kde.org>
3
4 SPDX-License-Identifier: GPL-2.0-only
5*/
6
7#pragma once
8#include "ksieveui_export.h"
9#include <KSieveCore/SieveImapAccountSettings>
10#include <QMap>
11#include <QUrl>
12#include <QWidget>
13#include <memory>
14
15class QTreeWidgetItem;
16
17namespace KManageSieve
18{
19class SieveJob;
20}
21namespace KSieveCore
22{
23class ParseUserScriptJob;
24}
25namespace KSieveUi
26{
27class ManageSieveTreeView;
28class ManageSieveWidgetPrivate;
29/**
30 * @brief The ManageSieveWidget class
31 * @author Laurent Montel <montel@kde.org>
32 */
33class KSIEVEUI_EXPORT ManageSieveWidget : public QWidget
34{
35 Q_OBJECT
36public:
37 enum SieveEditorMode : uint8_t {
38 NormalEditorMode = 0,
39 Kep14EditorMode
40 };
41
42 struct ScriptInfo {
43 QUrl currentUrl;
44 QStringList currentCapabilities;
45 KSieveCore::SieveImapAccountSettings sieveImapAccountSettings;
46 QStringList scriptList;
47 };
48
49 explicit ManageSieveWidget(QWidget *parent = nullptr);
50 ~ManageSieveWidget() override;
51
52 ManageSieveTreeView *treeView() const;
53 void enableDisableActions(bool &newScriptAction, bool &editScriptAction, bool &deleteScriptAction, bool &desactivateScriptAction);
54
55Q_SIGNALS:
56 void updateButtons(QTreeWidgetItem *item);
57 void newScript(const KSieveUi::ManageSieveWidget::ScriptInfo &info);
58 void editScript(const KSieveUi::ManageSieveWidget::ScriptInfo &info);
59 void scriptDeleted(const QUrl &u);
60 void serverSieveFound(bool imapFound);
61 void scriptRenamed(const QUrl &oldUrl, const QUrl &newUrl);
62 void updateSieveSettingsDone();
63
64protected:
65 virtual bool refreshList() = 0;
66 virtual void updateSieveSettings() = 0;
67
68private Q_SLOTS:
69 KSIEVEUI_NO_EXPORT void slotItemChanged(QTreeWidgetItem *item, int col);
70 KSIEVEUI_NO_EXPORT void slotContextMenuRequested(const QPoint &p);
71 KSIEVEUI_NO_EXPORT void slotUpdateButtons();
72 KSIEVEUI_NO_EXPORT void slotDoubleClicked(QTreeWidgetItem *item);
73 KSIEVEUI_NO_EXPORT void slotSystemNetworkOnlineStateChanged(bool state);
74 KSIEVEUI_NO_EXPORT void slotCheckNetworkStatus();
75 KSIEVEUI_NO_EXPORT void setActiveScripts(KSieveCore::ParseUserScriptJob *job);
76
77 KSIEVEUI_NO_EXPORT void slotCancelFetch();
78 KSIEVEUI_NO_EXPORT void slotRenameResult(KManageSieve::SieveJob *job, bool success);
79 KSIEVEUI_NO_EXPORT void slotRenameFinished(const QUrl &oldUrl, const QUrl &newUrl, const QString &errorStr, bool success);
80
81public Q_SLOTS:
82 void slotRenameScript();
83 void slotGotList(KManageSieve::SieveJob *job, bool success, const QStringList &listScript, const QString &activeScript);
84 void slotNewScript();
85 void slotEditScript();
86 void slotDeleteScript();
87 void slotDeactivateScript();
88 void slotDeleteResult(KManageSieve::SieveJob *job, bool success);
89 void slotRefresh();
90
91protected:
94
95private:
96 void updateSieveSettingsFinished();
97 enum sieveServerStatus {
98 SIEVE_SERVER_ERROR = Qt::UserRole + 1,
99 SIEVE_SERVER_CAPABILITIES = Qt::UserRole + 2,
100 SIEVE_SERVER_MODE = Qt::UserRole + 3,
101 SIEVE_SERVER_IMAP_SETTINGS = Qt::UserRole + 4,
102 SIEVE_SERVER_LIST_SCRIPT = Qt::UserRole + 5
103 };
104 KSIEVEUI_NO_EXPORT bool canAddNewScript(QTreeWidgetItem *item, bool jobsListIsEmpty);
105 KSIEVEUI_NO_EXPORT bool serverHasError(QTreeWidgetItem *item) const;
106 KSIEVEUI_NO_EXPORT void killAllJobs();
107 KSIEVEUI_NO_EXPORT void clear();
108 [[nodiscard]] KSIEVEUI_NO_EXPORT bool isFileNameItem(QTreeWidgetItem *item) const;
109 [[nodiscard]] KSIEVEUI_NO_EXPORT bool itemIsActived(QTreeWidgetItem *item) const;
110 KSIEVEUI_NO_EXPORT void changeActiveScript(QTreeWidgetItem *item, bool activate, bool deleteScript = false);
111 [[nodiscard]] KSIEVEUI_NO_EXPORT bool updateGlobalScript(QTreeWidgetItem *item, const QUrl &u);
112 KSIEVEUI_NO_EXPORT void slotGenerateGlobalScriptError(const QString &errorStr);
113 std::unique_ptr<ManageSieveWidgetPrivate> const d;
114};
115}
A job to manage sieve scripts.
Definition sievejob.h:31
The SieveImapAccountSettings class.
The ManageSieveTreeView class.
The ManageSieveWidget class.
UserRole
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Mon Nov 18 2024 12:14:30 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.