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

0001 /* SPDX-FileCopyrightText: 2011-2024 Laurent Montel <montel@kde.org>
0002  *
0003  * SPDX-License-Identifier: LGPL-2.0-or-later
0004  */
0005 
0006 #pragma once
0007 
0008 #include "ksieveui_export.h"
0009 #include <QDialog>
0010 #include <memory>
0011 namespace KSieveCore
0012 {
0013 class SieveImapAccountSettings;
0014 }
0015 namespace KSieveUi
0016 {
0017 class SieveEditorPrivate;
0018 /**
0019  * @brief The SieveEditor class
0020  * @author Laurent Montel <montel@kde.org>
0021  */
0022 class KSIEVEUI_EXPORT SieveEditor : public QDialog
0023 {
0024     Q_OBJECT
0025 public:
0026     explicit SieveEditor(QWidget *parent = nullptr);
0027     ~SieveEditor() override;
0028 
0029     [[nodiscard]] QString script() const;
0030     [[nodiscard]] QString originalScript() const;
0031     void setScript(const QString &script, bool clearUndoRedo = false);
0032     void setDebugScript(const QString &debug);
0033     void addFailedMessage(const QString &err);
0034     void addOkMessage(const QString &msg);
0035     void addNormalMessage(const QString &msg);
0036     void setScriptName(const QString &name);
0037 
0038     void resultDone();
0039 
0040     void setSieveCapabilities(const QStringList &capabilities);
0041     void setSieveImapAccountSettings(const KSieveCore::SieveImapAccountSettings &account);
0042 
0043     void setListOfIncludeFile(const QStringList &listOfIncludeFile);
0044     void setModified(bool b);
0045 
0046 Q_SIGNALS:
0047     void checkSyntax();
0048     void valueChanged(bool);
0049     void okClicked();
0050     void cancelClicked();
0051 
0052 protected:
0053     bool event(QEvent *e) override;
0054     void closeEvent(QCloseEvent *e) override;
0055 
0056 private:
0057     KSIEVEUI_NO_EXPORT void slotEnableButtonOk(bool b);
0058     KSIEVEUI_NO_EXPORT void slotAccepted();
0059     KSIEVEUI_NO_EXPORT void slotCanceled();
0060     KSIEVEUI_NO_EXPORT void writeConfig();
0061     KSIEVEUI_NO_EXPORT void readConfig();
0062     std::unique_ptr<SieveEditorPrivate> const d;
0063 };
0064 }