Libksieve

sieveeditorwidget.h
1/*
2 SPDX-FileCopyrightText: 2014-2024 Laurent Montel <montel@kde.org>
3
4 SPDX-License-Identifier: LGPL-2.0-or-later
5
6*/
7
8#pragma once
9#include "ksieveui_export.h"
10
11#include <QWidget>
12class QStackedWidget;
13class QLineEdit;
14class QAction;
15namespace KSieveCore
16{
17class SieveImapAccountSettings;
18}
19namespace KSieveUi
20{
21class SieveEditorTextModeWidget;
22class SieveEditorGraphicalModeWidget;
23/**
24 * @brief The SieveEditorWidget class
25 * @author Laurent Montel <montel@kde.org>
26 */
27class KSIEVEUI_EXPORT SieveEditorWidget : public QWidget
28{
29 Q_OBJECT
30public:
31 explicit SieveEditorWidget(bool useMenuBar, QWidget *parent = nullptr);
32 ~SieveEditorWidget() override;
33 enum EditorMode {
34 Unknown = -1,
35 TextMode = 0,
36 GraphicMode = 1
37 };
38
39 void setReadOnly(bool b);
40 [[nodiscard]] QString script() const;
41 [[nodiscard]] QString originalScript() const;
42 void setScript(const QString &script, bool clearUndoRedo = false);
43 void setDebugScript(const QString &debug);
44 void setScriptName(const QString &name);
45
46 void resultDone();
47
48 void setSieveCapabilities(const QStringList &capabilities);
49 void setSieveImapAccountSettings(const KSieveCore::SieveImapAccountSettings &sieveImapAccountSettings);
50 void setListOfIncludeFile(const QStringList &listOfIncludeFile);
51
52 void addFailedMessage(const QString &err);
53 void addOkMessage(const QString &msg);
54 void addNormalMessage(const QString &msg);
55
56 void setModified(bool b);
57 [[nodiscard]] bool isModified() const;
58
59 [[nodiscard]] EditorMode mode() const;
60
61 [[nodiscard]] bool isRedoAvailable() const;
62 [[nodiscard]] bool isUndoAvailable() const;
63 [[nodiscard]] bool hasSelection() const;
64
65 void checkSpelling();
66 void import();
67 void lowerCase();
68 void upperCase();
69 void sentenceCase();
70 void reverseCase();
71 void zoomOut();
72 void zoomIn();
73 [[nodiscard]] QString currentHelpTitle() const;
74 [[nodiscard]] QUrl currentHelpUrl() const;
75 void openBookmarkUrl(const QUrl &url);
76 void debugSieveScript();
77 void zoomReset();
78 bool isWordWrap() const;
79
80 void updateOriginalScript();
81 void print();
82 void printPreview();
83
84 bool printSupportEnabled() const;
85 bool isTextEditor() const;
86public Q_SLOTS:
87 void find();
88 void replace();
89 void undo();
90 void redo();
91 void paste();
92 void copy();
93 void cut();
94 void selectAll();
95 void goToLine();
96 void slotSaveAs();
97 void slotImport();
98 void slotCreateRulesGraphically();
99 void slotCheckSyntax();
100 void comment();
101 void uncomment();
102 void setWordWrap(bool state);
103
104Q_SIGNALS:
105 void checkSyntax();
106 void enableButtonOk(bool b);
107 void valueChanged(bool b);
108 void modeEditorChanged(KSieveUi::SieveEditorWidget::EditorMode);
109 void undoAvailable(bool);
110 void redoAvailable(bool);
111 void copyAvailable(bool);
112 void changeModeEditor(bool);
113 void sieveEditorTabCurrentChanged();
114
115private:
116 KSIEVEUI_NO_EXPORT void slotEnableButtonOk(bool b);
117 KSIEVEUI_NO_EXPORT void slotGenerateXml();
118 KSIEVEUI_NO_EXPORT void slotSwitchMode();
119 KSIEVEUI_NO_EXPORT void slotSwitchTextMode(const QString &script);
120 KSIEVEUI_NO_EXPORT void slotSwitchToGraphicalMode();
121 KSIEVEUI_NO_EXPORT void slotModified();
122 KSIEVEUI_NO_EXPORT void changeSwitchButtonText();
123 KSIEVEUI_NO_EXPORT void changeMode(EditorMode mode);
124 KSIEVEUI_NO_EXPORT void addMessageEntry(const QString &errorMsg, const QColor &color);
125 KSIEVEUI_NO_EXPORT void slotServerInfo();
126 QString mOriginalScript;
127 SieveEditorTextModeWidget *mTextModeWidget = nullptr;
128 SieveEditorGraphicalModeWidget *mGraphicalModeWidget = nullptr;
129 QStackedWidget *mStackedWidget = nullptr;
130 QLineEdit *mScriptName = nullptr;
131 QAction *mCheckSyntax = nullptr;
132 QAction *mSwitchMode = nullptr;
133 QAction *mCreateRulesGraphically = nullptr;
134 QAction *mSaveAs = nullptr;
135 QAction *mGenerateXml = nullptr;
136 QAction *mServerInfo = nullptr;
137 EditorMode mMode = EditorMode::TextMode;
138 bool mModified = false;
139 bool mDebug = false;
140};
141}
The SieveImapAccountSettings class.
The SieveEditorTextModeWidget class.
The SieveEditorWidget class.
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Sat Dec 21 2024 16:57:10 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.