File indexing completed on 2024-12-29 04:54:44
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 <Libkdepim/KWidgetLister> 0011 class QPushButton; 0012 class QComboBox; 0013 class QGridLayout; 0014 class QToolButton; 0015 class QXmlStreamReader; 0016 0017 namespace KSieveUi 0018 { 0019 class SieveAction; 0020 class SieveHelpButton; 0021 class SieveEditorGraphicalModeWidget; 0022 class SieveActionWidget : public QWidget 0023 { 0024 Q_OBJECT 0025 public: 0026 explicit SieveActionWidget(SieveEditorGraphicalModeWidget *graphicalModeWidget, QWidget *parent); 0027 ~SieveActionWidget() override; 0028 0029 void updateAddRemoveButton(bool addButtonEnabled, bool removeButtonEnabled); 0030 void generatedScript(QString &script, QStringList &required, bool onlyActions, bool inForEveryPartLoop); 0031 void setAction(const QString &actionName, QXmlStreamReader &element, const QString &comment, QString &error); 0032 [[nodiscard]] bool isConfigurated() const; 0033 void clear(); 0034 0035 void setLocaleVariable(const SieveGlobalVariableActionWidget::VariableElement &var); 0036 0037 Q_SIGNALS: 0038 void addWidget(QWidget *w); 0039 void removeWidget(QWidget *w); 0040 void valueChanged(); 0041 0042 private: 0043 void slotAddWidget(); 0044 void slotRemoveWidget(); 0045 void slotActionChanged(int index); 0046 void slotHelp(); 0047 void slotAddComment(); 0048 void setFilterAction(QWidget *widget); 0049 void initWidget(); 0050 QList<KSieveUi::SieveAction *> mActionList; 0051 QPushButton *mAdd = nullptr; 0052 QPushButton *mRemove = nullptr; 0053 QComboBox *mComboBox = nullptr; 0054 QGridLayout *mLayout = nullptr; 0055 SieveHelpButton *mHelpButton = nullptr; 0056 QToolButton *mCommentButton = nullptr; 0057 SieveEditorGraphicalModeWidget *const mSieveGraphicalModeWidget; 0058 }; 0059 0060 class SieveActionWidgetLister : public KPIM::KWidgetLister 0061 { 0062 Q_OBJECT 0063 public: 0064 explicit SieveActionWidgetLister(SieveEditorGraphicalModeWidget *graphicalModeWidget, QWidget *parent = nullptr); 0065 ~SieveActionWidgetLister() override; 0066 0067 void generatedScript(QString &script, QStringList &requireModules, bool onlyActions, bool inForEveryPartLoop); 0068 void loadScript(QXmlStreamReader &element, bool onlyActions, QString &error); 0069 0070 int actionNumber() const; 0071 0072 void loadLocalVariable(const SieveGlobalVariableActionWidget::VariableElement &var); 0073 public Q_SLOTS: 0074 void slotAddWidget(QWidget *w); 0075 void slotRemoveWidget(QWidget *w); 0076 0077 Q_SIGNALS: 0078 void valueChanged(); 0079 0080 protected: 0081 void clearWidget(QWidget *aWidget) override; 0082 QWidget *createWidget(QWidget *parent) override; 0083 0084 private: 0085 void reconnectWidget(SieveActionWidget *w); 0086 void updateAddRemoveButton(); 0087 0088 SieveEditorGraphicalModeWidget *const mSieveGraphicalModeWidget; 0089 }; 0090 }