sievescriptblockwidget.h 2.43 KB
Newer Older
1
/*
Laurent Montel's avatar
Laurent Montel committed
2
   Copyright (C) 2013-2017 Laurent Montel <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

   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.
18 19 20 21 22 23 24 25 26 27 28 29 30 31
*/

#ifndef SIEVESCRIPTBLOCKWIDGET_H
#define SIEVESCRIPTBLOCKWIDGET_H

#include "sievewidgetpageabstract.h"

class QRadioButton;
class QGroupBox;
class QAbstractButton;
class KComboBox;
class QPushButton;
class QDomElement;

Laurent Montel's avatar
Laurent Montel committed
32
namespace KSieveUi {
33 34
class SieveConditionWidgetLister;
class SieveActionWidgetLister;
35
class SieveEditorGraphicalModeWidget;
36 37 38 39 40 41 42 43 44 45 46

class SieveScriptBlockWidget : public SieveWidgetPageAbstract
{
    Q_OBJECT
public:
    enum MatchCondition {
        OrCondition,
        AndCondition,
        AllCondition
    };

Laurent Montel's avatar
Laurent Montel committed
47
    explicit SieveScriptBlockWidget(SieveEditorGraphicalModeWidget *graphicalModeWidget, QWidget *parent = nullptr);
48 49 50 51
    ~SieveScriptBlockWidget();

    void setPageType(PageType type) Q_DECL_OVERRIDE;

52
    void generatedScript(QString &script, QStringList &requires, bool inForEveryPartLoop) Q_DECL_OVERRIDE;
53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69

    MatchCondition matchCondition() const;

    void loadScript(const QDomElement &element, bool onlyActions, QString &error);

Q_SIGNALS:
    void addNewBlock(QWidget *widget, KSieveUi::SieveWidgetPageAbstract::PageType type);

private Q_SLOTS:
    void slotRadioClicked(QAbstractButton *);
    void slotAddBlock();

private:
    void updateWidget();
    void updateCondition();
    MatchCondition mMatchCondition;
    QGroupBox *mConditions;
70
    SieveEditorGraphicalModeWidget *mSieveGraphicalModeWidget;
71 72 73 74 75 76 77 78 79 80 81
    SieveConditionWidgetLister *mScriptConditionLister;
    SieveActionWidgetLister *mScriptActionLister;
    QRadioButton *mMatchAll;
    QRadioButton *mMatchAny;
    QRadioButton *mAllMessageRBtn;
    KComboBox *mNewBlockType;
    QPushButton *mAddBlockType;
};
}

#endif // SIEVESCRIPTBLOCKWIDGET_H