Commit 292f882d authored by Laurent Montel's avatar Laurent Montel 😁

continue adding indent

parent 11704c16
......@@ -4,8 +4,8 @@ require "ihave";
#SCRIPTNAME: Script part 0
#Script name: test-foreach
foreverypart :name "foreach1" {
if ihave "value"
{
if ihave "value"
{
stop;
}
}
}
......@@ -74,7 +74,7 @@ void SieveActionWidget::setFilterAction(QWidget *widget)
}
}
void SieveActionWidget::generatedScript(QString &script, QStringList &requires, bool onlyActions)
void SieveActionWidget::generatedScript(QString &script, QStringList &requires, bool onlyActions, bool inForEveryPartLoop)
{
const int index = mComboBox->currentIndex();
if (index != mComboBox->count() - 1) {
......@@ -305,14 +305,14 @@ void SieveActionWidgetLister::updateAddRemoveButton()
}
}
void SieveActionWidgetLister::generatedScript(QString &script, QStringList &requires, bool onlyActions)
void SieveActionWidgetLister::generatedScript(QString &script, QStringList &requires, bool onlyActions, bool inForEveryPartLoop)
{
const QList<QWidget *> widgetList = widgets();
QList<QWidget *>::ConstIterator wIt = widgetList.constBegin();
QList<QWidget *>::ConstIterator wEnd = widgetList.constEnd();
for (; wIt != wEnd; ++wIt) {
SieveActionWidget *w = qobject_cast<SieveActionWidget *>(*wIt);
w->generatedScript(script, requires, onlyActions);
w->generatedScript(script, requires, onlyActions, inForEveryPartLoop);
}
}
......
......@@ -44,7 +44,7 @@ public:
~SieveActionWidget();
void updateAddRemoveButton(bool addButtonEnabled, bool removeButtonEnabled);
void generatedScript(QString &script, QStringList &requires, bool onlyActions);
void generatedScript(QString &script, QStringList &requires, bool onlyActions, bool inForEveryPartLoop);
bool setAction(const QString &actionName, const QDomElement &element, const QString &comment, QString &error);
bool isConfigurated() const;
......@@ -81,7 +81,7 @@ public:
explicit SieveActionWidgetLister(SieveEditorGraphicalModeWidget *graphicalModeWidget, QWidget *parent = nullptr);
~SieveActionWidgetLister();
void generatedScript(QString &script, QStringList &requires, bool onlyActions);
void generatedScript(QString &script, QStringList &requires, bool onlyActions, bool inForEveryPartLoop);
void loadScript(const QDomElement &element, bool onlyActions, QString &error);
int actionNumber() const;
......
......@@ -68,7 +68,7 @@ void SieveConditionWidget::setFilterCondition(QWidget *widget)
}
}
void SieveConditionWidget::generatedScript(QString &script, QStringList &requires)
void SieveConditionWidget::generatedScript(QString &script, QStringList &requires, bool inForEveryPartLoop)
{
const int index = mComboBox->currentIndex();
if (index != mComboBox->count() - 1) {
......@@ -281,7 +281,7 @@ QWidget *SieveConditionWidgetLister::createWidget(QWidget *parent)
return w;
}
void SieveConditionWidgetLister::generatedScript(QString &script, int &numberOfCondition, QStringList &requires)
void SieveConditionWidgetLister::generatedScript(QString &script, int &numberOfCondition, QStringList &requires, bool inForEveryPartLoop)
{
const QList<QWidget *> widgetList = widgets();
QList<QWidget *>::ConstIterator wIt = widgetList.constBegin();
......@@ -290,7 +290,7 @@ void SieveConditionWidgetLister::generatedScript(QString &script, int &numberOfC
for (; wIt != wEnd; ++wIt) {
QString condition;
SieveConditionWidget *w = qobject_cast<SieveConditionWidget *>(*wIt);
w->generatedScript(condition, requires);
w->generatedScript(condition, requires, inForEveryPartLoop);
if (!condition.isEmpty()) {
if (!wasFirst) {
script += QLatin1String(", ");
......
......@@ -42,7 +42,7 @@ public:
~SieveConditionWidget();
void updateAddRemoveButton(bool addButtonEnabled, bool removeButtonEnabled);
void generatedScript(QString &script, QStringList &requires);
void generatedScript(QString &script, QStringList &requires, bool inForEveryPartLoop);
void setCondition(const QString &conditionName, const QDomElement &element, bool notCondition, QString &error);
private Q_SLOTS:
......@@ -76,7 +76,7 @@ public:
explicit SieveConditionWidgetLister(SieveEditorGraphicalModeWidget *sieveGraphicalModeWidget, QWidget *parent = nullptr);
~SieveConditionWidgetLister();
void generatedScript(QString &script, int &numberOfCondition, QStringList &requires);
void generatedScript(QString &script, int &numberOfCondition, QStringList &requires, bool inForEveryPartLoop);
int conditionNumber() const;
void loadScript(const QDomElement &element, bool uniqTest, bool notCondition, QString &error);
......
......@@ -20,6 +20,7 @@
#include "sievescriptblockwidget.h"
#include "sieveactionwidgetlister.h"
#include "sieveconditionwidgetlister.h"
#include "autocreatescriptutil_p.h"
#include <KLocalizedString>
#include <KComboBox>
......@@ -173,16 +174,20 @@ void SieveScriptBlockWidget::updateWidget()
void SieveScriptBlockWidget::generatedScript(QString &script, QStringList &requires, bool inForEveryPartLoop)
{
QString indentation;
if (inForEveryPartLoop) {
indentation = AutoCreateScriptUtil::indentation();
}
bool onlyActions = false;
if (mMatchCondition == AllCondition) {
onlyActions = true;
//Just actions type
} else if (pageType() == BlockElse) {
script += QLatin1String("else {\n");
script += indentation + QLatin1String("else {\n");
} else {
QString conditionStr;
int numberOfCondition = 0;
mScriptConditionLister->generatedScript(conditionStr, numberOfCondition, requires);
mScriptConditionLister->generatedScript(conditionStr, numberOfCondition, requires, inForEveryPartLoop);
const bool hasUniqCondition = (numberOfCondition == 1);
QString filterStr;
QString blockStr;
......@@ -211,17 +216,17 @@ void SieveScriptBlockWidget::generatedScript(QString &script, QStringList &requi
if (conditionStr.isEmpty()) {
return;
} else {
script += filterStr + conditionStr;
script += indentation +filterStr + conditionStr;
}
if (hasUniqCondition) {
script += QLatin1String("{\n");
script += indentation + QLatin1String("{\n");
} else {
script += QLatin1String(")\n{\n");
script += indentation +QLatin1String(")\n{\n");
}
}
mScriptActionLister->generatedScript(script, requires, onlyActions);
mScriptActionLister->generatedScript(script, requires, onlyActions, inForEveryPartLoop);
if (!onlyActions) {
script += QLatin1String("} ");
script += indentation + QLatin1String("} ");
}
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment