sieveeditorpagewidget.h 3.31 KB
Newer Older
Laurent Montel's avatar
Laurent Montel committed
1
/*
2
   Copyright (C) 2014-2017 Montel Laurent <montel@kde.org>
Laurent Montel's avatar
Laurent Montel committed
3

Laurent Montel's avatar
Laurent Montel committed
4 5 6 7
   This program is free software; you can redistribute it and/or
   modify it under the terms of the GNU General Public
   License as published by the Free Software Foundation; either
   version 2 of the License, or (at your option) any later version.
Laurent Montel's avatar
Laurent Montel committed
8

Laurent Montel's avatar
Laurent Montel committed
9 10 11 12
   This program is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   General Public License for more details.
Laurent Montel's avatar
Laurent Montel committed
13

Laurent Montel's avatar
Laurent Montel committed
14 15 16 17
   You should have received a copy of the GNU General Public License
   along with this program; see the file COPYING.  If not, write to
   the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
   Boston, MA 02110-1301, USA.
Laurent Montel's avatar
Laurent Montel committed
18 19 20 21
*/

#ifndef SIEVEEDITORPAGEWIDGET_H
#define SIEVEEDITORPAGEWIDGET_H
Laurent Montel's avatar
Laurent Montel committed
22
#include <QWidget>
Laurent Montel's avatar
Laurent Montel committed
23
#include <QUrl>
24
#include "ksieveui/sieveeditorwidget.h"
Laurent Montel's avatar
Laurent Montel committed
25
namespace KManageSieve {
Laurent Montel's avatar
Laurent Montel committed
26 27
class SieveJob;
}
Laurent Montel's avatar
Laurent Montel committed
28
namespace KSieveUi {
Laurent Montel's avatar
Laurent Montel committed
29 30
class SieveEditorWidget;
}
Laurent Montel's avatar
Laurent Montel committed
31

Laurent Montel's avatar
Laurent Montel committed
32
class SieveEditorPageWidget : public QWidget
Laurent Montel's avatar
Laurent Montel committed
33 34 35
{
    Q_OBJECT
public:
Laurent Montel's avatar
Laurent Montel committed
36
    explicit SieveEditorPageWidget(QWidget *parent = nullptr);
Laurent Montel's avatar
Laurent Montel committed
37 38
    ~SieveEditorPageWidget();

Laurent Montel's avatar
Laurent Montel committed
39
    void loadScript(const QUrl &url, const QStringList &capabilities, const KSieveUi::SieveImapAccountSettings &sieveImapAccountSettings);
Laurent Montel's avatar
Laurent Montel committed
40
    QUrl currentUrl() const;
Laurent Montel's avatar
Laurent Montel committed
41
    void setCurrentUrl(const QUrl &url);
42
    void setIsNewScript(bool isNewScript);
Laurent Montel's avatar
Laurent Montel committed
43
    void uploadScript(bool showInformation = true, bool forceSave = false);
44
    bool needToSaveScript();
Laurent Montel's avatar
Laurent Montel committed
45

Laurent Montel's avatar
Laurent Montel committed
46
    bool isModified() const;
47
    void goToLine();
48
    KSieveUi::SieveEditorWidget::EditorMode pageMode() const;
49

50 51
    void find();
    void replace();
Laurent Montel's avatar
Laurent Montel committed
52 53 54 55
    void redo();
    void undo();
    bool isUndoAvailable() const;
    bool isRedoAvailable() const;
Laurent Montel's avatar
Laurent Montel committed
56 57 58
    void paste();
    void cut();
    void copy();
59
    bool hasSelection() const;
Laurent Montel's avatar
Laurent Montel committed
60

Laurent Montel's avatar
Laurent Montel committed
61
    void selectAll();
Laurent Montel's avatar
Laurent Montel committed
62
    void saveAs();
63
    void checkSpelling();
Laurent Montel's avatar
Laurent Montel committed
64
    void shareScript();
Laurent Montel's avatar
Laurent Montel committed
65
    void import();
Laurent Montel's avatar
Laurent Montel committed
66
    void createRulesGraphically();
67
    void checkSyntax();
68 69
    void comment();
    void uncomment();
70 71 72 73
    void lowerCase();
    void upperCase();
    void sentenceCase();
    void reverseCase();
Laurent Montel's avatar
Laurent Montel committed
74 75
    void zoomIn();
    void zoomOut();
Laurent Montel's avatar
Laurent Montel committed
76 77
    QString currentHelpTitle() const;
    QUrl currentHelpUrl() const;
Laurent Montel's avatar
Laurent Montel committed
78
    void openBookmarkUrl(const QUrl &url);
79
    void debugSieveScript();
Laurent Montel's avatar
Laurent Montel committed
80
    void zoomReset();
Laurent Montel's avatar
Laurent Montel committed
81
    void wordWrap(bool state);
Laurent Montel's avatar
Laurent Montel committed
82
    bool isWordWrap() const;
83 84
    void print();
    void printPreview();
85 86
    bool printSupportEnabled() const;
    bool isTextEditor() const;
Laurent Montel's avatar
Laurent Montel committed
87 88
Q_SIGNALS:
    void refreshList();
89
    void scriptModified(bool, SieveEditorPageWidget *);
90
    void modeEditorChanged(KSieveUi::SieveEditorWidget::EditorMode);
91 92
    void undoAvailable(bool);
    void redoAvailable(bool);
Laurent Montel's avatar
Laurent Montel committed
93
    void copyAvailable(bool);
94
    void sieveEditorTabCurrentChanged();
Laurent Montel's avatar
Laurent Montel committed
95

Laurent Montel's avatar
Laurent Montel committed
96
private Q_SLOTS:
Laurent Montel's avatar
Laurent Montel committed
97
    void slotGetResult(KManageSieve::SieveJob *, bool success, const QString &script, bool isActive);
Laurent Montel's avatar
Laurent Montel committed
98
    void slotCheckSyntaxClicked();
Laurent Montel's avatar
Laurent Montel committed
99
    void slotPutResult(KManageSieve::SieveJob *, bool success);
Laurent Montel's avatar
Laurent Montel committed
100
    void slotValueChanged(bool b);
Laurent Montel's avatar
Laurent Montel committed
101
    void slotCheckScriptJobFinished(const QString &errorMsg, bool success);
Laurent Montel's avatar
Laurent Montel committed
102

Laurent Montel's avatar
Laurent Montel committed
103
private:
104
    void setModified(bool b);
Laurent Montel's avatar
Laurent Montel committed
105
    QUrl mCurrentURL;
Laurent Montel's avatar
Laurent Montel committed
106
    KSieveUi::SieveEditorWidget *mSieveEditorWidget;
107
    bool mWasActive;
108
    bool mIsNewScript;
Laurent Montel's avatar
Laurent Montel committed
109 110 111
};

#endif // SIEVEEDITORPAGEWIDGET_H