Libksieve

sievescriptlistbox.h
1 /*
2  SPDX-FileCopyrightText: 2013-2021 Laurent Montel <[email protected]>
3 
4  SPDX-License-Identifier: LGPL-2.0-or-later
5 */
6 
7 #pragma once
8 
9 #include "ksieveui_private_export.h"
10 #include <QGroupBox>
11 #include <QListWidgetItem>
12 
13 class QListWidget;
14 class QPushButton;
15 class QXmlStreamReader;
16 
17 namespace KSieveUi
18 {
19 class SieveEditorGraphicalModeWidget;
20 class SieveScriptPage;
21 class SieveScriptListItem : public QListWidgetItem
22 {
23 public:
24  SieveScriptListItem(const QString &text, QListWidget *parent);
25  ~SieveScriptListItem() override;
26 
27  void setDescription(const QString &desc);
28  Q_REQUIRED_RESULT QString description() const;
29 
30  Q_REQUIRED_RESULT SieveScriptPage *scriptPage() const;
31  void setScriptPage(SieveScriptPage *page);
32 
33  Q_REQUIRED_RESULT QString generatedScript(QStringList &required) const;
34 
35 private:
36  QString mDescription;
37  SieveScriptPage *mScriptPage = nullptr;
38 };
39 
40 class KSIEVEUI_TESTS_EXPORT SieveScriptListBox : public QGroupBox
41 {
42  Q_OBJECT
43 public:
44  explicit SieveScriptListBox(const QString &title, QWidget *parent = nullptr);
45  ~SieveScriptListBox() override;
46 
47  void setSieveEditorGraphicalModeWidget(SieveEditorGraphicalModeWidget *graphicalModeWidget);
48  Q_REQUIRED_RESULT QString generatedScript(QStringList &required) const;
49  void loadScript(const QString &doc, QString &error);
50 
51 Q_SIGNALS:
52  void addNewPage(KSieveUi::SieveScriptPage *);
53  void removePage(QWidget *);
54  void activatePage(QWidget *);
55  void enableButtonOk(bool);
56  void valueChanged();
57 
58 private:
59  void slotCustomMenuRequested(const QPoint &pos);
60  void slotNew();
61  void slotDelete();
62  void slotRename();
63  void updateButtons();
64  void slotEditDescription();
65  void slotItemActived(QListWidgetItem *);
66  void slotTop();
67  void slotBottom();
68  void slotDown();
69  void slotUp();
70 
71  enum ParseSieveScriptTypeBlock {
72  TypeUnknown = 0,
73  TypeBlockIf,
74  TypeBlockElsif,
75  TypeBlockElse,
76  TypeBlockInclude,
77  TypeBlockGlobal,
78  TypeBlockAction,
79  TypeBlockForeachBlock
80  };
81 
82  void loadBlock(QXmlStreamReader &n, SieveScriptPage *currentPage, ParseSieveScriptTypeBlock typeBlock, QString &error);
83  void clear();
84  SieveScriptPage *createNewScript(const QString &newName, const QString &description = QString());
85  QString createUniqName();
86  SieveEditorGraphicalModeWidget *mSieveGraphicalModeWidget = nullptr;
87  QListWidget *mSieveListScript = nullptr;
88  QPushButton *mBtnNew = nullptr;
89  QPushButton *mBtnDelete = nullptr;
90  QPushButton *mBtnRename = nullptr;
91  QPushButton *mBtnDescription = nullptr;
92  QPushButton *mBtnTop = nullptr;
93  QPushButton *mBtnUp = nullptr;
94  QPushButton *mBtnDown = nullptr;
95  QPushButton *mBtnBottom = nullptr;
96  int mScriptNumber = 0;
97 };
98 }
99 
This file is part of the KDE documentation.
Documentation copyright © 1996-2021 The KDE developers.
Generated on Sun Apr 11 2021 23:09:37 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.