Libksieve

sieveglobalvariablewidget.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 
12 class QPushButton;
13 class QLineEdit;
14 class QGridLayout;
15 class QCheckBox;
16 class QXmlStreamReader;
17 
18 namespace KSieveUi
19 {
20 class SieveHelpButton;
21 class SieveGlobalVariableWidget;
22 
23 class SieveGlobalVariableActionWidget : public QWidget
24 {
25  Q_OBJECT
26 public:
27  struct VariableElement {
28  QString variableName;
29  QString variableValue;
30  bool isValid() const
31  {
32  return !variableName.isEmpty();
33  }
34  };
35 
36  explicit SieveGlobalVariableActionWidget(QWidget *parent = nullptr);
37  ~SieveGlobalVariableActionWidget() override;
38 
39  void generatedScript(QString &script);
40  void updateAddRemoveButton(bool addButtonEnabled, bool removeButtonEnabled);
41  Q_REQUIRED_RESULT bool isInitialized() const;
42  void loadScript(QXmlStreamReader &element, QString &error);
43  void setVariableValue(const QString &name);
44  Q_REQUIRED_RESULT QString variableName() const;
45 
46  void clear();
47 private Q_SLOTS:
48  void slotAddWidget();
49  void slotRemoveWidget();
50 
51 Q_SIGNALS:
52  void addWidget(QWidget *w);
53  void removeWidget(QWidget *w);
54  void valueChanged();
55 
56 private:
57  void initWidget();
58  QPushButton *mAdd = nullptr;
59  QPushButton *mRemove = nullptr;
60  QGridLayout *mLayout = nullptr;
61  QLineEdit *mVariableName = nullptr;
62  QCheckBox *mSetValueTo = nullptr;
63  QLineEdit *mVariableValue = nullptr;
64 };
65 
66 class SieveGlobalVariableLister : public KPIM::KWidgetLister
67 {
68  Q_OBJECT
69 public:
70  explicit SieveGlobalVariableLister(QWidget *parent = nullptr);
71  ~SieveGlobalVariableLister() override;
72 
73  void generatedScript(QString &script, QStringList &requireModules);
74  void loadScript(QXmlStreamReader &element, QString &error);
75  SieveGlobalVariableActionWidget::VariableElement loadSetVariable(QXmlStreamReader &element, QString &error);
76 
77 Q_SIGNALS:
78  void valueChanged();
79 
80 public Q_SLOTS:
81  void slotAddWidget(QWidget *w);
82  void slotRemoveWidget(QWidget *w);
83 
84 protected:
85  void clearWidget(QWidget *aWidget) override;
86  QWidget *createWidget(QWidget *parent) override;
87 
88 private:
89  void reconnectWidget(SieveGlobalVariableActionWidget *w);
90  void updateAddRemoveButton();
91 };
92 
93 class SieveGlobalVariableWidget : public SieveWidgetPageAbstract
94 {
95  Q_OBJECT
96 public:
97  explicit SieveGlobalVariableWidget(QWidget *parent = nullptr);
98  ~SieveGlobalVariableWidget() override;
99 
100  void generatedScript(QString &script, QStringList &requireModules, bool inForEveryPartLoop) override;
101 
102  void loadScript(QXmlStreamReader &element, QString &error);
103  SieveGlobalVariableActionWidget::VariableElement loadSetVariable(QXmlStreamReader &element, QString &error);
104 
105 private Q_SLOTS:
106  void slotHelp();
107 
108 private:
109  SieveGlobalVariableLister *mIncludeLister = nullptr;
110  SieveHelpButton *mHelpButton = nullptr;
111 };
112 }
113 
Q_OBJECTQ_OBJECT
bool isEmpty() const const
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.