Libksieve

sievescriptlistbox.h
1 /*
2  Copyright (C) 2013-2020 Laurent Montel <[email protected]>
3 
4  This library is free software; you can redistribute it and/or
5  modify it under the terms of the GNU Library General Public
6  License as published by the Free Software Foundation; either
7  version 2 of the License, or (at your option) any later version.
8 
9  This library is distributed in the hope that it will be useful,
10  but WITHOUT ANY WARRANTY; without even the implied warranty of
11  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12  Library General Public License for more details.
13 
14  You should have received a copy of the GNU Library General Public License
15  along with this library; see the file COPYING.LIB. If not, write to
16  the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17  Boston, MA 02110-1301, USA.
18 */
19 
20 #ifndef SIEVESCRIPTLISTBOX_H
21 #define SIEVESCRIPTLISTBOX_H
22 
23 #include <QGroupBox>
24 #include <QListWidgetItem>
25 #include "ksieveui_private_export.h"
26 
27 class QListWidget;
28 class QPushButton;
29 class QXmlStreamReader;
30 
31 namespace KSieveUi {
32 class SieveEditorGraphicalModeWidget;
33 class SieveScriptPage;
34 class SieveScriptListItem : public QListWidgetItem
35 {
36 public:
37  SieveScriptListItem(const QString &text, QListWidget *parent);
38  ~SieveScriptListItem();
39 
40  void setDescription(const QString &desc);
41  Q_REQUIRED_RESULT QString description() const;
42 
43  Q_REQUIRED_RESULT SieveScriptPage *scriptPage() const;
44  void setScriptPage(SieveScriptPage *page);
45 
46  Q_REQUIRED_RESULT QString generatedScript(QStringList &required) const;
47 
48 private:
49  QString mDescription;
50  SieveScriptPage *mScriptPage = nullptr;
51 };
52 
53 class KSIEVEUI_TESTS_EXPORT SieveScriptListBox : public QGroupBox
54 {
55  Q_OBJECT
56 public:
57  explicit SieveScriptListBox(const QString &title, QWidget *parent = nullptr);
58  ~SieveScriptListBox();
59 
60  void setSieveEditorGraphicalModeWidget(SieveEditorGraphicalModeWidget *graphicalModeWidget);
61  Q_REQUIRED_RESULT QString generatedScript(QStringList &required) const;
62  void loadScript(const QString &doc, QString &error);
63 
64 Q_SIGNALS:
65  void addNewPage(KSieveUi::SieveScriptPage *);
66  void removePage(QWidget *);
67  void activatePage(QWidget *);
68  void enableButtonOk(bool);
69  void valueChanged();
70 
71 private:
72  void slotCustomMenuRequested(const QPoint &pos);
73  void slotNew();
74  void slotDelete();
75  void slotRename();
76  void updateButtons();
77  void slotEditDescription();
78  void slotItemActived(QListWidgetItem *);
79  void slotTop();
80  void slotBottom();
81  void slotDown();
82  void slotUp();
83 
84  enum ParseSieveScriptTypeBlock {
85  TypeUnknown = 0,
86  TypeBlockIf,
87  TypeBlockElsif,
88  TypeBlockElse,
89  TypeBlockInclude,
90  TypeBlockGlobal,
91  TypeBlockAction,
92  TypeBlockForeachBlock
93  };
94 
95  void loadBlock(QXmlStreamReader &n, SieveScriptPage *currentPage, ParseSieveScriptTypeBlock typeBlock, QString &error);
96  void clear();
97  SieveScriptPage *createNewScript(const QString &newName, const QString &description = QString());
98  QString createUniqName();
99  SieveEditorGraphicalModeWidget *mSieveGraphicalModeWidget = nullptr;
100  QListWidget *mSieveListScript = nullptr;
101  QPushButton *mBtnNew = nullptr;
102  QPushButton *mBtnDelete = nullptr;
103  QPushButton *mBtnRename = nullptr;
104  QPushButton *mBtnDescription = nullptr;
105  QPushButton *mBtnTop = nullptr;
106  QPushButton *mBtnUp = nullptr;
107  QPushButton *mBtnDown = nullptr;
108  QPushButton *mBtnBottom = nullptr;
109  int mScriptNumber = 0;
110 };
111 }
112 
113 #endif // SIEVESCRIPTLISTBOX_H
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Fri Jun 5 2020 23:09:20 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.