Libksieve

sieveincludewidget.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 "sievewidgetpageabstract.h"
10 #include <Libkdepim/KWidgetLister>
11 #include <QComboBox>
12 
13 class QPushButton;
14 class QGridLayout;
15 class QCheckBox;
16 class QXmlStreamReader;
17 namespace KSieveUi
18 {
19 class SieveHelpButton;
20 class IncludeFileLineEdit;
21 class SieveIncludeLocation : public QComboBox
22 {
23  Q_OBJECT
24 public:
25  explicit SieveIncludeLocation(QWidget *parent = nullptr);
26  ~SieveIncludeLocation() override;
27 
28  Q_REQUIRED_RESULT QString code() const;
29  void setCode(const QString &code, QString &error);
30 
31 Q_SIGNALS:
32  void valueChanged();
33 
34 private:
35  void initialize();
36 };
37 
38 class SieveIncludeActionWidget : public QWidget
39 {
40  Q_OBJECT
41 public:
42  explicit SieveIncludeActionWidget(QWidget *parent = nullptr);
43  ~SieveIncludeActionWidget();
44 
45  void generatedScript(QString &script);
46  void updateAddRemoveButton(bool addButtonEnabled, bool removeButtonEnabled);
47  void loadScript(QXmlStreamReader &element, QString &error);
48  Q_REQUIRED_RESULT bool isInitialized() const;
49  void clear();
50  void setListOfIncludeFile(const QStringList &listOfIncludeFile);
51 
52 private Q_SLOTS:
53  void slotAddWidget();
54  void slotRemoveWidget();
55 
56 Q_SIGNALS:
57  void addWidget(QWidget *w);
58  void removeWidget(QWidget *w);
59  void valueChanged();
60 
61 private:
62  void initWidget();
63  QPushButton *mAdd = nullptr;
64  QPushButton *mRemove = nullptr;
65  QGridLayout *mLayout = nullptr;
66  QCheckBox *mOptional = nullptr;
67  QCheckBox *mOnce = nullptr;
68  SieveIncludeLocation *mLocation = nullptr;
69  IncludeFileLineEdit *mIncludeFileName = nullptr;
70 };
71 
72 class SieveIncludeWidgetLister : public KPIM::KWidgetLister
73 {
74  Q_OBJECT
75 public:
76  explicit SieveIncludeWidgetLister(QWidget *parent = nullptr);
77  ~SieveIncludeWidgetLister() override;
78 
79  void generatedScript(QString &script, QStringList &requireModules);
80  void loadScript(QXmlStreamReader &element, QString &error);
81 
82  void setListOfIncludeFile(const QStringList &listOfIncludeFile);
83 
84 Q_SIGNALS:
85  void valueChanged();
86 
87 public Q_SLOTS:
88  void slotAddWidget(QWidget *w);
89  void slotRemoveWidget(QWidget *w);
90 
91 protected:
92  void clearWidget(QWidget *aWidget) override;
93  QWidget *createWidget(QWidget *parent) override;
94 
95 private:
96  void reconnectWidget(SieveIncludeActionWidget *w);
97  void updateAddRemoveButton();
98  QStringList mListOfIncludeFile;
99 };
100 
101 class SieveIncludeWidget : public SieveWidgetPageAbstract
102 {
103  Q_OBJECT
104 public:
105  explicit SieveIncludeWidget(QWidget *parent = nullptr);
106  ~SieveIncludeWidget() override;
107 
108  void generatedScript(QString &script, QStringList &requireModules, bool inForEveryPartLoop) override;
109 
110  void loadScript(QXmlStreamReader &element, QString &error);
111 
112  void setListOfIncludeFile(const QStringList &lst);
113 private Q_SLOTS:
114  void slotHelp();
115 
116 private:
117  SieveIncludeWidgetLister *mIncludeLister = nullptr;
118  SieveHelpButton *mHelpButton = nullptr;
119 };
120 }
121 
KCRASH_EXPORT void initialize()
Q_SIGNALSQ_SIGNALS
Q_OBJECTQ_OBJECT
This file is part of the KDE documentation.
Documentation copyright © 1996-2021 The KDE developers.
Generated on Sun Apr 11 2021 23:09:36 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.