Libksieve

sieveconditionwidgetlister.h
1 /*
2  Copyright (C) 2013-2020 Laurent Montel <[email protected]>
3 
4  This library is free software; you can redistribute it and/or
5  modify it under the terms of the GNU Library General Public
6  License as published by the Free Software Foundation; either
7  version 2 of the License, or (at your option) any later version.
8 
9  This library is distributed in the hope that it will be useful,
10  but WITHOUT ANY WARRANTY; without even the implied warranty of
11  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12  Library General Public License for more details.
13 
14  You should have received a copy of the GNU Library General Public License
15  along with this library; see the file COPYING.LIB. If not, write to
16  the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17  Boston, MA 02110-1301, USA.
18 */
19 
20 #ifndef SIEVECONDITIONWIDGETLISTER_H
21 #define SIEVECONDITIONWIDGETLISTER_H
22 
23 #include <Libkdepim/KWidgetLister>
24 #include <QVector>
25 class QPushButton;
26 class QGridLayout;
27 class QXmlStreamReader;
28 class QToolButton;
29 class QComboBox;
30 
31 namespace KSieveUi {
32 class SieveCondition;
33 class SieveHelpButton;
34 class SieveEditorGraphicalModeWidget;
35 class SieveConditionWidget : public QWidget
36 {
37  Q_OBJECT
38 public:
39  explicit SieveConditionWidget(SieveEditorGraphicalModeWidget *sieveGraphicalModeWidget, QWidget *parent);
40  ~SieveConditionWidget();
41 
42  void updateAddRemoveButton(bool addButtonEnabled, bool removeButtonEnabled);
43  void generatedScript(QString &script, QStringList &required, bool inForEveryPartLoop);
44  void setCondition(const QString &conditionName, QXmlStreamReader &element, bool notCondition, QString &error);
45  void clear();
46 
47 Q_SIGNALS:
48  void addWidget(QWidget *w);
49  void removeWidget(QWidget *w);
50  void valueChanged();
51 
52 private:
53  void slotAddWidget();
54  void slotRemoveWidget();
55  void slotConditionChanged(int index);
56  void slotHelp();
57  void slotAddComment();
58  void initWidget();
59  void setFilterCondition(QWidget *widget);
61  QPushButton *mAdd = nullptr;
62  QPushButton *mRemove = nullptr;
63  QComboBox *mComboBox = nullptr;
64  QGridLayout *mLayout = nullptr;
65  SieveHelpButton *mHelpButton = nullptr;
66  QToolButton *mCommentButton = nullptr;
67  SieveEditorGraphicalModeWidget *mSieveGraphicalModeWidget = nullptr;
68 };
69 
70 class SieveConditionWidgetLister : public KPIM::KWidgetLister
71 {
72  Q_OBJECT
73 public:
74  explicit SieveConditionWidgetLister(SieveEditorGraphicalModeWidget *sieveGraphicalModeWidget, QWidget *parent = nullptr);
75  ~SieveConditionWidgetLister();
76 
77  void generatedScript(QString &script, int &numberOfCondition, QStringList &requireModules, bool inForEveryPartLoop);
78  int conditionNumber() const;
79  void loadScript(QXmlStreamReader &element, bool uniqTest, bool notCondition, QString &error);
80 
81 Q_SIGNALS:
82  void valueChanged();
83 
84 public Q_SLOTS:
85  void slotAddWidget(QWidget *w);
86  void slotRemoveWidget(QWidget *w);
87 
88 protected:
89  void clearWidget(QWidget *aWidget) override;
90  QWidget *createWidget(QWidget *parent) override;
91 
92 private:
93  void loadTest(QXmlStreamReader &e, bool notCondition, QString &error);
94  void reconnectWidget(SieveConditionWidget *w);
95  void updateAddRemoveButton();
96  SieveEditorGraphicalModeWidget *mSieveGraphicalModeWidget = nullptr;
97 };
98 }
99 
100 #endif // SIEVECONDITIONWIDGETLISTER_H
Q_SIGNALSQ_SIGNALS
Q_OBJECTQ_OBJECT
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Mon Jun 1 2020 23:08:20 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.