Libksieve

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

KDE's Doxygen guidelines are available online.