Libksieve

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

KDE's Doxygen guidelines are available online.