Commit fab4c862 authored by Laurent Montel's avatar Laurent Montel 😁
Browse files

Use QStringList so we can exclude already exist required

parent 39a06659
......@@ -76,7 +76,7 @@ void AutoCreateScriptDialog::setListOfIncludeFile(const QStringList &listOfInclu
mEditor->setListOfIncludeFile(listOfIncludeFile);
}
QString AutoCreateScriptDialog::script(QString &required) const
QString AutoCreateScriptDialog::script(QStringList &required) const
{
return mEditor->script(required);
}
......
......@@ -38,7 +38,7 @@ public:
explicit AutoCreateScriptDialog(QWidget *parent = nullptr);
~AutoCreateScriptDialog() override;
Q_REQUIRED_RESULT QString script(QString &required) const;
Q_REQUIRED_RESULT QString script(QStringList &required) const;
void setSieveCapabilities(const QStringList &capabilities);
void setListOfIncludeFile(const QStringList &listOfIncludeFile);
......
......@@ -100,7 +100,7 @@ QStringList SieveEditorGraphicalModeWidget::sieveCapabilities()
return mCapabilities;
}
QString SieveEditorGraphicalModeWidget::script(QString &required) const
QString SieveEditorGraphicalModeWidget::script(QStringList &required) const
{
return mSieveScript->generatedScript(required);
}
......@@ -124,10 +124,10 @@ void SieveEditorGraphicalModeWidget::slotActivateScriptPage(QWidget *page)
QString SieveEditorGraphicalModeWidget::currentscript()
{
QString requireModules;
QStringList requireModules;
QString script = mSieveScript->generatedScript(requireModules);
if (!requireModules.isEmpty()) {
script.prepend(requireModules + QLatin1Char('\n'));
script.prepend(requireModules.join(QStringLiteral("\n")) + QStringLiteral("\n\n"));
}
return script;
}
......
......@@ -37,7 +37,7 @@ public:
explicit SieveEditorGraphicalModeWidget(QWidget *parent = nullptr);
~SieveEditorGraphicalModeWidget();
Q_REQUIRED_RESULT QString script(QString &required) const override;
Q_REQUIRED_RESULT QString script(QStringList &required) const override;
void setSieveCapabilities(const QStringList &capabilities) override;
Q_REQUIRED_RESULT QStringList sieveCapabilities() override;
......
......@@ -30,7 +30,7 @@ public:
explicit SieveEditorGraphicalModeWidgetAbstract(QWidget *parent);
~SieveEditorGraphicalModeWidgetAbstract();
Q_REQUIRED_RESULT virtual QString script(QString &requireModules) const = 0;
Q_REQUIRED_RESULT virtual QString script(QStringList &requireModules) const = 0;
virtual void setSieveCapabilities(const QStringList &capabilities) = 0;
......
......@@ -366,7 +366,7 @@ void SieveScriptListBox::slotUp()
}
}
QString SieveScriptListBox::generatedScript(QString &requireModules) const
QString SieveScriptListBox::generatedScript(QStringList &requireModules) const
{
QString resultScript;
QStringList lstRequires;
......@@ -387,7 +387,7 @@ QString SieveScriptListBox::generatedScript(QString &requireModules) const
for (const QString &r : qAsConst(lstRequires)) {
if (!endRequires.contains(r)) {
endRequires.append(r);
requireModules += QStringLiteral("require \"%1\";\n").arg(r);
requireModules += QStringLiteral("require \"%1\";").arg(r);
}
}
......
......@@ -58,7 +58,7 @@ public:
~SieveScriptListBox();
void setSieveEditorGraphicalModeWidget(SieveEditorGraphicalModeWidget *graphicalModeWidget);
Q_REQUIRED_RESULT QString generatedScript(QString &required) const;
Q_REQUIRED_RESULT QString generatedScript(QStringList &required) const;
void loadScript(const QString &doc, QString &error);
Q_SIGNALS:
......
......@@ -37,7 +37,7 @@ int main(int argc, char **argv)
//Add all capabilities for testing
dialog->setSieveCapabilities(capabilities);
if (dialog->exec()) {
QString requireModules;
QStringList requireModules;
const QString script = dialog->script(requireModules);
qDebug() << " generated script :\n" << requireModules << "\n" << script;
}
......
......@@ -243,7 +243,7 @@ void SieveEditorTextModeWidget::slotEditRule(const QString &selectedText)
//qDebug() << " psb.result()" << psb.result();
dlg->loadScript(psb.result(), error);
if (dlg->exec()) {
QString requireModules;
QStringList requireModules;
const QString newScript = dlg->script(requireModules);
mTextEdit->insertPlainText(newScript);
}
......@@ -260,7 +260,7 @@ void SieveEditorTextModeWidget::slotInsertRule()
dlg->setSieveImapAccountSettings(mSieveImapAccountSettings);
dlg->setListOfIncludeFile(mListOfIncludeFile);
if (dlg->exec()) {
QString requireModules;
QStringList requireModules;
const QString newScript = dlg->script(requireModules);
mTextEdit->insertPlainText(newScript);
}
......@@ -274,11 +274,11 @@ void SieveEditorTextModeWidget::createRulesGraphically()
dlg->setSieveImapAccountSettings(mSieveImapAccountSettings);
dlg->setListOfIncludeFile(mListOfIncludeFile);
if (dlg->exec()) {
QString requireModules;
QStringList requireModules;
const QString script = dlg->script(requireModules);
QString newPlainText = mTextEdit->toPlainText() + script;
if (!requireModules.isEmpty()) {
newPlainText.prepend(requireModules + QLatin1Char('\n'));
newPlainText.prepend(requireModules.join(QStringLiteral("\n")) + QLatin1Char('\n'));
}
mTextEdit->selectAll();
......
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