File indexing completed on 2024-12-29 04:54:45

0001 /*
0002    SPDX-FileCopyrightText: 2013-2024 Laurent Montel <montel@kde.org>
0003 
0004    SPDX-License-Identifier: LGPL-2.0-or-later
0005 */
0006 
0007 #pragma once
0008 
0009 #include "sieveglobalvariablewidget.h"
0010 #include "sievewidgetpageabstract.h"
0011 
0012 class QRadioButton;
0013 class QGroupBox;
0014 class QAbstractButton;
0015 class QComboBox;
0016 class QPushButton;
0017 class QXmlStreamReader;
0018 
0019 namespace KSieveUi
0020 {
0021 class SieveConditionWidgetLister;
0022 class SieveActionWidgetLister;
0023 class SieveEditorGraphicalModeWidget;
0024 
0025 class SieveScriptBlockWidget : public SieveWidgetPageAbstract
0026 {
0027     Q_OBJECT
0028 public:
0029     enum MatchCondition { OrCondition, AndCondition, AllCondition };
0030 
0031     explicit SieveScriptBlockWidget(SieveEditorGraphicalModeWidget *graphicalModeWidget, QWidget *parent = nullptr);
0032     ~SieveScriptBlockWidget() override;
0033 
0034     void setPageType(PageType type) override;
0035 
0036     void generatedScript(QString &script, QStringList &required, bool inForEveryPartLoop) override;
0037 
0038     [[nodiscard]] MatchCondition matchCondition() const;
0039 
0040     void loadScript(QXmlStreamReader &element, bool onlyActions, QString &error);
0041 
0042     void loadLocalVariable(const SieveGlobalVariableActionWidget::VariableElement &var);
0043 Q_SIGNALS:
0044     void addNewBlock(QWidget *widget, KSieveUi::SieveWidgetPageAbstract::PageType type);
0045 
0046 private:
0047     void slotRadioClicked(QAbstractButton *);
0048     void slotAddBlock();
0049     void updateWidget();
0050     void updateCondition();
0051     MatchCondition mMatchCondition = AndCondition;
0052     QGroupBox *mConditions = nullptr;
0053     SieveEditorGraphicalModeWidget *const mSieveGraphicalModeWidget;
0054     SieveConditionWidgetLister *mScriptConditionLister = nullptr;
0055     SieveActionWidgetLister *mScriptActionLister = nullptr;
0056     QRadioButton *mMatchAll = nullptr;
0057     QRadioButton *mMatchAny = nullptr;
0058     QRadioButton *mAllMessageRBtn = nullptr;
0059     QComboBox *mNewBlockType = nullptr;
0060     QPushButton *mAddBlockType = nullptr;
0061 };
0062 }