sieveeditorpagewidget.h 3.08 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 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22

  This library is free software; you can redistribute it and/or modify it
  under the terms of the GNU Library General Public License as published by
  the Free Software Foundation; either version 2 of the License, or (at your
  option) any later version.

  This library 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 Library General Public
  License for more details.

  You should have received a copy of the GNU Library General Public License
  along with this library; see the file COPYING.LIB.  If not, write to the
  Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
  02110-1301, USA.

*/

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

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

Laurent Montel's avatar
Laurent Montel committed
42 43
    void loadScript(const QUrl &url, const QStringList &capabilities);
    QUrl currentUrl() const;
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 67
    void share();
    void import();
68 69
    void autoGenerateScript();
    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;
Laurent Montel's avatar
Laurent Montel committed
85 86
Q_SIGNALS:
    void refreshList();
87
    void scriptModified(bool, SieveEditorPageWidget *);
88
    void modeEditorChanged(KSieveUi::SieveEditorWidget::EditorMode);
89 90
    void undoAvailable(bool);
    void redoAvailable(bool);
Laurent Montel's avatar
Laurent Montel committed
91
    void copyAvailable(bool);
Laurent Montel's avatar
Laurent Montel committed
92

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

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

#endif // SIEVEEDITORPAGEWIDGET_H