Libksieve

managesievewidget.h
1 /*
2  Copyright (C) 2014-2020 Laurent Montel <[email protected]>
3 
4  This program is free software; you can redistribute it and/or modify it
5  under the terms of the GNU General Public License, version 2, as
6  published by the Free Software Foundation.
7 
8  This program is distributed in the hope that it will be useful, but
9  WITHOUT ANY WARRANTY; without even the implied warranty of
10  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11  General Public License for more details.
12 
13  You should have received a copy of the GNU General Public License along
14  with this program; if not, write to the Free Software Foundation, Inc.,
15  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
16 */
17 
18 #ifndef MANAGESIEVEWIDGET_H
19 #define MANAGESIEVEWIDGET_H
20 #include "ksieveui_export.h"
21 
22 #include <QUrl>
23 #include <KSieveUi/SieveImapAccountSettings>
24 #include <QWidget>
25 #include <QMap>
26 
27 class QTreeWidgetItem;
28 
29 namespace KManageSieve {
30 class SieveJob;
31 }
32 
33 namespace KSieveUi {
34 class ManageSieveTreeView;
35 class ManageSieveWidgetPrivate;
36 class ParseUserScriptJob;
41 class KSIEVEUI_EXPORT ManageSieveWidget : public QWidget
42 {
43  Q_OBJECT
44 public:
45  enum SieveEditorMode {
46  NormalEditorMode = 0,
47  Kep14EditorMode
48  };
49 
50  struct ScriptInfo
51  {
52  QUrl currentUrl;
53  QStringList currentCapabilities;
54  KSieveUi::SieveImapAccountSettings sieveImapAccountSettings;
55  QStringList scriptList;
56  };
57 
58  explicit ManageSieveWidget(QWidget *parent = nullptr);
60 
61  ManageSieveTreeView *treeView() const;
62  void enableDisableActions(bool &newScriptAction, bool &editScriptAction, bool &deleteScriptAction, bool &desactivateScriptAction);
63 
64 Q_SIGNALS:
65  void updateButtons(QTreeWidgetItem *item);
66  void newScript(const ScriptInfo &info);
67  void editScript(const ScriptInfo &info);
68  void scriptDeleted(const QUrl &u);
69  void serverSieveFound(bool imapFound);
70  void scriptRenamed(const QUrl &oldUrl, const QUrl &newUrl);
71 
72 protected:
73  virtual bool refreshList() = 0;
74 
75 private Q_SLOTS:
76  void slotItemChanged(QTreeWidgetItem *item, int col);
77  void slotContextMenuRequested(const QPoint &p);
78  void slotUpdateButtons();
79  void slotDoubleClicked(QTreeWidgetItem *item);
80  void slotSystemNetworkOnlineStateChanged(bool state);
81  void slotCheckNetworkStatus();
82  void setActiveScripts(ParseUserScriptJob *job);
83 
84  void slotCancelFetch();
85  void slotRenameResult(KManageSieve::SieveJob *job, bool success);
86  void slotRenameFinished(const QUrl &oldUrl, const QUrl &newUrl, const QString &errorStr, bool success);
87 
88 public Q_SLOTS:
89  void slotRenameScript();
90  void slotGotList(KManageSieve::SieveJob *job, bool success, const QStringList &listScript, const QString &activeScript);
91  void slotNewScript();
92  void slotEditScript();
93  void slotDeleteScript();
94  void slotDeactivateScript();
95  void slotDeleteResult(KManageSieve::SieveJob *job, bool success);
96  void slotRefresh();
97 
98 protected:
101 
102 private:
103  enum sieveServerStatus {
104  SIEVE_SERVER_ERROR = Qt::UserRole + 1,
105  SIEVE_SERVER_CAPABILITIES = Qt::UserRole + 2,
106  SIEVE_SERVER_MODE = Qt::UserRole + 3,
107  SIEVE_SERVER_IMAP_SETTINGS = Qt::UserRole + 4,
108  SIEVE_SERVER_LIST_SCRIPT = Qt::UserRole + 5
109  };
110  bool canAddNewScript(QTreeWidgetItem *item, bool jobsListIsEmpty);
111  bool serverHasError(QTreeWidgetItem *item) const;
112  void killAllJobs();
113  void clear();
114  bool isFileNameItem(QTreeWidgetItem *item) const;
115  bool itemIsActived(QTreeWidgetItem *item) const;
116  void changeActiveScript(QTreeWidgetItem *item, bool activate);
117  void slotGenerateGlobalScriptError(const QString &errorStr);
118 
119  ManageSieveWidgetPrivate *const d;
120 };
121 }
122 
123 #endif // MANAGESIEVEWIDGET_H
The ManageSieveTreeView class.
The ManageSieveWidget class.
The SieveImapAccountSettings class.
A job to manage sieve scripts.
Definition: sievejob.h:41
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Mon Jun 1 2020 23:08:20 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.