sieveeditorpagewidget.h 3.24 KB
Newer Older
Laurent Montel's avatar
Laurent Montel committed
1
/*
Laurent Montel's avatar
Laurent Montel committed
2
   Copyright (C) 2014-2016 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 26
namespace KManageSieve
{
Laurent Montel's avatar
Laurent Montel committed
27 28
class SieveJob;
}
Laurent Montel's avatar
Laurent Montel committed
29 30
namespace KSieveUi
{
Laurent Montel's avatar
Laurent Montel committed
31 32
class SieveEditorWidget;
}
Laurent Montel's avatar
Laurent Montel committed
33

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

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

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

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

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

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

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

#endif // SIEVEEDITORPAGEWIDGET_H