Libksieve

sieveglobalvariablewidget.h
1/*
2 SPDX-FileCopyrightText: 2013-2024 Laurent Montel <montel@kde.org>
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
12class QPushButton;
13class QLineEdit;
14class QGridLayout;
15class QCheckBox;
17
18namespace KSieveUi
19{
20class SieveHelpButton;
21class SieveGlobalVariableWidget;
22
23class SieveGlobalVariableActionWidget : public QWidget
24{
26public:
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 [[nodiscard]] bool isInitialized() const;
42 void loadScript(QXmlStreamReader &element, QString &error);
43 void setVariableValue(const QString &name);
44 [[nodiscard]] QString variableName() const;
45
46 void clear();
47private Q_SLOTS:
48 void slotAddWidget();
49 void slotRemoveWidget();
50
52 void addWidget(QWidget *w);
53 void removeWidget(QWidget *w);
54 void valueChanged();
55
56private:
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
66class SieveGlobalVariableLister : public KPIM::KWidgetLister
67{
69public:
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
78 void valueChanged();
79
80public Q_SLOTS:
81 void slotAddWidget(QWidget *w);
82 void slotRemoveWidget(QWidget *w);
83
84protected:
85 void clearWidget(QWidget *aWidget) override;
86 QWidget *createWidget(QWidget *parent) override;
87
88private:
89 void reconnectWidget(SieveGlobalVariableActionWidget *w);
90 void updateAddRemoveButton();
91};
92
93class SieveGlobalVariableWidget : public SieveWidgetPageAbstract
94{
96public:
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
105private Q_SLOTS:
106 void slotHelp();
107
108private:
109 SieveGlobalVariableLister *mGlobalVariableLister = nullptr;
110 SieveHelpButton *mHelpButton = nullptr;
111};
112}
Q_OBJECTQ_OBJECT
Q_SIGNALSQ_SIGNALS
Q_SLOTSQ_SLOTS
QObject * parent() const const
bool isEmpty() const const
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Tue Mar 26 2024 11:17:19 by doxygen 1.10.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.