Commit 00fd6710 authored by Laurent Montel's avatar Laurent Montel 😁

We need to add more indentation when we are in loop foreverypart

parent 95538f16
...@@ -81,13 +81,14 @@ void SieveForEveryPartWidget::slotHelp() ...@@ -81,13 +81,14 @@ void SieveForEveryPartWidget::slotHelp()
QWhatsThis::showText(QCursor::pos(), fullWhatsThis, mHelpButton); QWhatsThis::showText(QCursor::pos(), fullWhatsThis, mHelpButton);
} }
void SieveForEveryPartWidget::generatedScript(QString &script, QStringList &requires) void SieveForEveryPartWidget::generatedScript(QString &script, QStringList &requires, bool inForEveryPartLoop)
{ {
Q_UNUSED(inForEveryPartLoop);
if (mForLoop->isChecked()) { if (mForLoop->isChecked()) {
requires << QStringLiteral("foreverypart"); requires << QStringLiteral("foreverypart");
const QString loopName = mName->text(); const QString loopName = mName->text();
if (loopName.isEmpty()) { if (loopName.isEmpty()) {
script += QLatin1String("foreverypart {"); script += QStringLiteral("foreverypart {");
} else { } else {
script += QStringLiteral("foreverypart :name \"%1\" {").arg(loopName); script += QStringLiteral("foreverypart :name \"%1\" {").arg(loopName);
} }
......
...@@ -34,7 +34,7 @@ public: ...@@ -34,7 +34,7 @@ public:
explicit SieveForEveryPartWidget(QWidget *parent = nullptr); explicit SieveForEveryPartWidget(QWidget *parent = nullptr);
~SieveForEveryPartWidget(); ~SieveForEveryPartWidget();
void generatedScript(QString &script, QStringList &requires) Q_DECL_OVERRIDE; void generatedScript(QString &script, QStringList &requires, bool inForEveryPartLoop) Q_DECL_OVERRIDE;
void loadScript(const QDomElement &element, QString &error); void loadScript(const QDomElement &element, QString &error);
private Q_SLOTS: private Q_SLOTS:
......
...@@ -184,8 +184,9 @@ void SieveGlobalVariableWidget::slotHelp() ...@@ -184,8 +184,9 @@ void SieveGlobalVariableWidget::slotHelp()
QWhatsThis::showText(QCursor::pos(), fullWhatsThis, mHelpButton); QWhatsThis::showText(QCursor::pos(), fullWhatsThis, mHelpButton);
} }
void SieveGlobalVariableWidget::generatedScript(QString &script, QStringList &requires) void SieveGlobalVariableWidget::generatedScript(QString &script, QStringList &requires, bool inForEveryPartLoop)
{ {
Q_UNUSED(inForEveryPartLoop)
QString result; QString result;
QStringList lst; QStringList lst;
mIncludeLister->generatedScript(result, lst); mIncludeLister->generatedScript(result, lst);
......
...@@ -99,7 +99,7 @@ public: ...@@ -99,7 +99,7 @@ public:
explicit SieveGlobalVariableWidget(QWidget *parent = nullptr); explicit SieveGlobalVariableWidget(QWidget *parent = nullptr);
~SieveGlobalVariableWidget(); ~SieveGlobalVariableWidget();
void generatedScript(QString &script, QStringList &requires) Q_DECL_OVERRIDE; void generatedScript(QString &script, QStringList &requires, bool inForEveryPartLoop) Q_DECL_OVERRIDE;
void loadScript(const QDomElement &element, QString &error); void loadScript(const QDomElement &element, QString &error);
bool loadSetVariable(const QDomElement &element, QString &error); bool loadSetVariable(const QDomElement &element, QString &error);
......
...@@ -222,8 +222,9 @@ void SieveIncludeWidget::slotHelp() ...@@ -222,8 +222,9 @@ void SieveIncludeWidget::slotHelp()
QWhatsThis::showText(QCursor::pos(), fullWhatsThis, mHelpButton); QWhatsThis::showText(QCursor::pos(), fullWhatsThis, mHelpButton);
} }
void SieveIncludeWidget::generatedScript(QString &script, QStringList &requires) void SieveIncludeWidget::generatedScript(QString &script, QStringList &requires, bool inForEveryPartLoop)
{ {
Q_UNUSED(inForEveryPartLoop);
QString result; QString result;
QStringList lst; QStringList lst;
mIncludeLister->generatedScript(result, lst); mIncludeLister->generatedScript(result, lst);
......
...@@ -112,7 +112,7 @@ public: ...@@ -112,7 +112,7 @@ public:
explicit SieveIncludeWidget(QWidget *parent = nullptr); explicit SieveIncludeWidget(QWidget *parent = nullptr);
~SieveIncludeWidget(); ~SieveIncludeWidget();
void generatedScript(QString &script, QStringList &requires) Q_DECL_OVERRIDE; void generatedScript(QString &script, QStringList &requires, bool inForEveryPartLoop) Q_DECL_OVERRIDE;
void loadScript(const QDomElement &element, QString &error); void loadScript(const QDomElement &element, QString &error);
......
...@@ -171,7 +171,7 @@ void SieveScriptBlockWidget::updateWidget() ...@@ -171,7 +171,7 @@ void SieveScriptBlockWidget::updateWidget()
mAddBlockType->setEnabled(mMatchCondition != AllCondition); mAddBlockType->setEnabled(mMatchCondition != AllCondition);
} }
void SieveScriptBlockWidget::generatedScript(QString &script, QStringList &requires) void SieveScriptBlockWidget::generatedScript(QString &script, QStringList &requires, bool inForEveryPartLoop)
{ {
bool onlyActions = false; bool onlyActions = false;
if (mMatchCondition == AllCondition) { if (mMatchCondition == AllCondition) {
......
...@@ -49,7 +49,7 @@ public: ...@@ -49,7 +49,7 @@ public:
void setPageType(PageType type) Q_DECL_OVERRIDE; void setPageType(PageType type) Q_DECL_OVERRIDE;
void generatedScript(QString &script, QStringList &requires) Q_DECL_OVERRIDE; void generatedScript(QString &script, QStringList &requires, bool inForEveryPartLoop) Q_DECL_OVERRIDE;
MatchCondition matchCondition() const; MatchCondition matchCondition() const;
......
...@@ -135,9 +135,11 @@ void SieveScriptPage::generatedScript(QString &script, QStringList &requires) ...@@ -135,9 +135,11 @@ void SieveScriptPage::generatedScript(QString &script, QStringList &requires)
{ {
QString foreverypartStr; QString foreverypartStr;
QStringList foreverypartRequires; QStringList foreverypartRequires;
bool inForEveryPartLoop = false;
if (mForEveryPartWidget) { if (mForEveryPartWidget) {
mForEveryPartWidget->generatedScript(foreverypartStr, foreverypartRequires); mForEveryPartWidget->generatedScript(foreverypartStr, foreverypartRequires, false);
if (!foreverypartStr.isEmpty()) { inForEveryPartLoop = !foreverypartStr.isEmpty();
if (inForEveryPartLoop) {
requires << foreverypartRequires; requires << foreverypartRequires;
script += foreverypartStr + QLatin1Char('\n'); script += foreverypartStr + QLatin1Char('\n');
} }
...@@ -146,10 +148,10 @@ void SieveScriptPage::generatedScript(QString &script, QStringList &requires) ...@@ -146,10 +148,10 @@ void SieveScriptPage::generatedScript(QString &script, QStringList &requires)
for (int i = 0; i < numberOfTab; ++i) { for (int i = 0; i < numberOfTab; ++i) {
SieveWidgetPageAbstract *page = static_cast<SieveWidgetPageAbstract *>(mTabWidget->widget(i)); SieveWidgetPageAbstract *page = static_cast<SieveWidgetPageAbstract *>(mTabWidget->widget(i));
if (page->pageType() != KSieveUi::SieveScriptBlockWidget::ForEveryPart) { if (page->pageType() != KSieveUi::SieveScriptBlockWidget::ForEveryPart) {
page->generatedScript(script, requires); page->generatedScript(script, requires, inForEveryPartLoop);
} }
} }
if (!foreverypartStr.isEmpty()) { if (inForEveryPartLoop) {
script += QStringLiteral("\n}\n"); script += QStringLiteral("\n}\n");
} }
} }
......
...@@ -39,7 +39,7 @@ public: ...@@ -39,7 +39,7 @@ public:
explicit SieveWidgetPageAbstract(QWidget *parent = nullptr); explicit SieveWidgetPageAbstract(QWidget *parent = nullptr);
~SieveWidgetPageAbstract(); ~SieveWidgetPageAbstract();
virtual void generatedScript(QString &script, QStringList &requires) = 0; virtual void generatedScript(QString &script, QStringList &requires, bool inForEveryPartLoop) = 0;
virtual void setPageType(PageType type); virtual void setPageType(PageType type);
PageType pageType() const; PageType pageType() const;
......
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