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