sieveactionwidgetlister.cpp 20.2 KB
Newer Older
1
/*
Laurent Montel's avatar
Laurent Montel committed
2
   Copyright (C) 2013-2017 Laurent Montel <montel@kde.org>
3

Laurent Montel's avatar
Laurent Montel committed
4 5 6 7
   This library is free software; you can redistribute it and/or
   modify it under the terms of the GNU Library General Public
   License as published by the Free Software Foundation; either
   version 2 of the License, or (at your option) any later version.
8

Laurent Montel's avatar
Laurent Montel committed
9 10 11 12
   This library is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   Library General Public License for more details.
13

Laurent Montel's avatar
Laurent Montel committed
14 15 16 17
   You should have received a copy of the GNU Library General Public License
   along with this library; see the file COPYING.LIB.  If not, write to
   the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
   Boston, MA 02110-1301, USA.
18 19 20 21 22 23 24 25 26 27
*/

#include "sieveactionwidgetlister.h"
#include "autocreatescriptdialog.h"
#include "sieveeditorgraphicalmodewidget.h"
#include "sievescriptdescriptiondialog.h"
#include "sieveactions/sieveaction.h"
#include "sieveactions/sieveactionlist.h"
#include "commonwidgets/sievehelpbutton.h"
#include "autocreatescriptutil_p.h"
Laurent Montel's avatar
Laurent Montel committed
28
#include <PimCommon/MinimumComboBox>
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45

#include <QPushButton>
#include <KLocalizedString>
#include <QIcon>

#include <QGridLayout>
#include <QLabel>
#include "libksieve_debug.h"
#include <QToolButton>
#include <QWhatsThis>
#include <QDomElement>

using namespace KSieveUi;

static int MINIMUMACTION = 1;
static int MAXIMUMACTION = 8;

46
SieveActionWidget::SieveActionWidget(SieveEditorGraphicalModeWidget *graphicalModeWidget, QWidget *parent)
Laurent Montel's avatar
Laurent Montel committed
47 48
    : QWidget(parent)
    , mSieveGraphicalModeWidget(graphicalModeWidget)
49 50 51 52 53 54 55 56 57 58 59 60
{
    initWidget();
}

SieveActionWidget::~SieveActionWidget()
{
    qDeleteAll(mActionList);
    mActionList.clear();
}

bool SieveActionWidget::isConfigurated() const
{
Laurent Montel's avatar
Laurent Montel committed
61
    return mComboBox->currentIndex() != (mComboBox->count() - 1);
62 63 64 65 66 67 68 69 70 71 72 73 74 75 76
}

void SieveActionWidget::setFilterAction(QWidget *widget)
{
    if (mLayout->itemAtPosition(1, 3)) {
        delete mLayout->itemAtPosition(1, 3)->widget();
    }

    if (widget) {
        mLayout->addWidget(widget, 1, 3);
    } else {
        mLayout->addWidget(new QLabel(i18n("Please select an action."), this), 1, 3);
    }
}

Laurent Montel's avatar
Laurent Montel committed
77
void SieveActionWidget::generatedScript(QString &script, QStringList &requires, bool onlyActions, bool inForEveryPartLoop)
78 79 80 81 82 83
{
    const int index = mComboBox->currentIndex();
    if (index != mComboBox->count() - 1) {
        KSieveUi::SieveAction *widgetAction = mActionList.at(mComboBox->currentIndex());
        QWidget *currentWidget = mLayout->itemAtPosition(1, 3)->widget();
        const QStringList lstRequires = widgetAction->needRequires(currentWidget);
Laurent Montel's avatar
Laurent Montel committed
84
        for (const QString &r : lstRequires) {
85 86 87 88 89
            if (!requires.contains(r)) {
                requires.append(r);
            }
        }
        QString comment = widgetAction->comment();
Laurent Montel's avatar
Laurent Montel committed
90 91 92 93 94 95 96
        QString indent;
        if (!onlyActions) {
            indent += AutoCreateScriptUtil::indentation();
        }
        if (inForEveryPartLoop) {
            indent += AutoCreateScriptUtil::indentation();
        }
Laurent Montel's avatar
Laurent Montel committed
97
        if (!comment.trimmed().isEmpty()) {
98
            const QStringList commentList = comment.split(QLatin1Char('\n'));
Laurent Montel's avatar
Laurent Montel committed
99

100 101 102 103 104 105 106
            for (const QString &str : commentList) {
                if (str.isEmpty()) {
                    script += QLatin1Char('\n');
                } else {
                    script += indent + QLatin1Char('#') + str + QLatin1Char('\n');
                }
            }
107
        }
Laurent Montel's avatar
Laurent Montel committed
108
        script += indent + widgetAction->code(currentWidget) + QLatin1Char('\n');
109 110 111 112 113 114 115 116 117 118
    }
}

void SieveActionWidget::initWidget()
{
    mLayout = new QGridLayout(this);
    mLayout->setContentsMargins(0, 0, 0, 0);

    mComboBox = new PimCommon::MinimumComboBox;
    mComboBox->setEditable(false);
119
    const QList<KSieveUi::SieveAction *> list = KSieveUi::SieveActionList::actionList(mSieveGraphicalModeWidget);
120 121 122
    QList<KSieveUi::SieveAction *>::const_iterator it;
    QList<KSieveUi::SieveAction *>::const_iterator end(list.constEnd());
    int index = 0;
123
    QStringList listCapabilities = mSieveGraphicalModeWidget->sieveCapabilities();
124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147
    //imapflags was old name of imap4flags but still used.
    if (listCapabilities.contains(QStringLiteral("imap4flags"))) {
        listCapabilities.append(QStringLiteral("imapflags"));
    }
    for (index = 0, it = list.constBegin(); it != end; ++it, ++index) {
        if ((*it)->needCheckIfServerHasCapability()) {
            if (listCapabilities.contains((*it)->serverNeedsCapability())) {
                // append to the list of actions:
                mActionList.append(*it);
                connect(*it, &SieveAction::valueChanged, this, &SieveActionWidget::valueChanged);
                // add (i18n-ized) name to combo box
                mComboBox->addItem((*it)->label(), (*it)->name());
            } else {
                delete(*it);
            }
        } else {
            // append to the list of actions:
            mActionList.append(*it);
            connect(*it, &SieveAction::valueChanged, this, &SieveActionWidget::valueChanged);
            // add (i18n-ized) name to combo box
            mComboBox->addItem((*it)->label(), (*it)->name());
        }
    }

Laurent Montel's avatar
Laurent Montel committed
148
    mHelpButton = new SieveHelpButton(this);
149 150 151
    connect(mHelpButton, &SieveHelpButton::clicked, this, &SieveActionWidget::slotHelp);
    mLayout->addWidget(mHelpButton, 1, 0);

Laurent Montel's avatar
Laurent Montel committed
152
    mCommentButton = new QToolButton(this);
153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184
    mCommentButton->setToolTip(i18n("Add comment"));
    mLayout->addWidget(mCommentButton, 1, 1);
    mCommentButton->setIcon(QIcon::fromTheme(QStringLiteral("view-pim-notes")));
    connect(mCommentButton, &QToolButton::clicked, this, &SieveActionWidget::slotAddComment);

    mComboBox->addItem(QLatin1String(""));

    mComboBox->setMaxCount(mComboBox->count());
    mComboBox->setSizePolicy(QSizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed));
    setSizePolicy(QSizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed));
    mComboBox->adjustSize();
    mLayout->addWidget(mComboBox, 1, 2);

    updateGeometry();

    connect(mComboBox, static_cast<void (PimCommon::MinimumComboBox::*)(int)>(&PimCommon::MinimumComboBox::activated), this, &SieveActionWidget::slotActionChanged);

    mAdd = new QPushButton(this);
    mAdd->setIcon(QIcon::fromTheme(QStringLiteral("list-add")));
    mAdd->setSizePolicy(QSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed));

    mRemove = new QPushButton(this);
    mRemove->setIcon(QIcon::fromTheme(QStringLiteral("list-remove")));
    mRemove->setSizePolicy(QSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed));
    mLayout->addWidget(mAdd, 1, 4);
    mLayout->addWidget(mRemove, 1, 5);

    // redirect focus to the filter action combo box
    setFocusProxy(mComboBox);

    connect(mAdd, &QPushButton::clicked, this, &SieveActionWidget::slotAddWidget);
    connect(mRemove, &QPushButton::clicked, this, &SieveActionWidget::slotRemoveWidget);
Laurent Montel's avatar
Laurent Montel committed
185 186

    clear();
187 188 189 190 191 192 193 194 195 196 197 198 199 200
}

void SieveActionWidget::slotHelp()
{
    const int index = mComboBox->currentIndex();
    if (index < mActionList.count()) {
        KSieveUi::SieveAction *action = mActionList.at(index);
        const QString help = action->help();
        const QUrl href = action->href();
        const QString fullWhatsThis = AutoCreateScriptUtil::createFullWhatsThis(help, href.toString());
        QWhatsThis::showText(QCursor::pos(), fullWhatsThis, mHelpButton);
    }
}

Laurent Montel's avatar
Laurent Montel committed
201 202 203 204 205 206 207 208
void SieveActionWidget::clear()
{
    mComboBox->setCurrentIndex(mComboBox->count() - 1);
    setFilterAction(nullptr);
    mCommentButton->setEnabled(false);
    mHelpButton->setEnabled(false);
}

209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237
void SieveActionWidget::slotAddComment()
{
    const int index = mComboBox->currentIndex();
    if (index < mActionList.count()) {
        KSieveUi::SieveAction *action = mActionList.at(index);
        const QString comment = action->comment();
        QPointer<SieveScriptDescriptionDialog> dlg = new SieveScriptDescriptionDialog;
        dlg->setDescription(comment);
        if (dlg->exec()) {
            action->setComment(dlg->description());
            Q_EMIT valueChanged();
        }
        delete dlg;
    }
}

void SieveActionWidget::slotActionChanged(int index)
{
    if (index < mActionList.count()) {
        KSieveUi::SieveAction *action = mActionList.at(index);
        mHelpButton->setEnabled(!action->help().isEmpty());
        mCommentButton->setEnabled(true);
        setFilterAction(action->createParamWidget(this));
        //All actions after stop will not execute => don't allow to add more actions.
        const bool enableAddAction = (action->name() != QLatin1String("stop"));
        mAdd->setEnabled(enableAddAction);
    } else {
        mAdd->setEnabled(true);
        mCommentButton->setEnabled(false);
Laurent Montel's avatar
Laurent Montel committed
238
        setFilterAction(nullptr);
239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261
        mHelpButton->setEnabled(false);
    }
    Q_EMIT valueChanged();
}

void SieveActionWidget::slotAddWidget()
{
    Q_EMIT valueChanged();
    Q_EMIT addWidget(this);
}

void SieveActionWidget::slotRemoveWidget()
{
    Q_EMIT valueChanged();
    Q_EMIT removeWidget(this);
}

void SieveActionWidget::updateAddRemoveButton(bool addButtonEnabled, bool removeButtonEnabled)
{
    mAdd->setEnabled(addButtonEnabled);
    mRemove->setEnabled(removeButtonEnabled);
}

Laurent Montel's avatar
Laurent Montel committed
262
bool SieveActionWidget::setAction(const QString &actionName, QXmlStreamReader &element, const QString &comment, QString &error)
263
{
Laurent Montel's avatar
Laurent Montel committed
264
    qDebug() << "bool SieveActionWidget::setAction(const QString &actionName, QXmlStreamReader &element, const QString &comment, QString &error)" << actionName;
265 266 267 268 269 270 271 272
    const int index = mComboBox->findData(actionName);
    bool result = false;
    if (index != -1) {
        mComboBox->setCurrentIndex(index);
        slotActionChanged(index);
        KSieveUi::SieveAction *action = mActionList.at(index);
        result = action->setParamWidgetValue(element, this, error);
        action->setComment(comment);
Laurent Montel's avatar
Laurent Montel committed
273
    } else {
Laurent Montel's avatar
Laurent Montel committed
274
        error += i18n("Script contains unsupported feature \"%1\"", actionName) + QLatin1Char('\n');
Laurent Montel's avatar
Laurent Montel committed
275
        qCDebug(LIBKSIEVE_LOG) << "Condition " << actionName << " not supported";
276 277 278 279
    }
    return result;
}

280
SieveActionWidgetLister::SieveActionWidgetLister(SieveEditorGraphicalModeWidget *graphicalModeWidget, QWidget *parent)
Laurent Montel's avatar
Laurent Montel committed
281 282
    : KPIM::KWidgetLister(false, MINIMUMACTION, MAXIMUMACTION, parent)
    , mSieveGraphicalModeWidget(graphicalModeWidget)
283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327
{
    slotClear();
    updateAddRemoveButton();
}

SieveActionWidgetLister::~SieveActionWidgetLister()
{
}

void SieveActionWidgetLister::slotAddWidget(QWidget *w)
{
    addWidgetAfterThisWidget(w);
    updateAddRemoveButton();
}

void SieveActionWidgetLister::slotRemoveWidget(QWidget *w)
{
    removeWidget(w);
    updateAddRemoveButton();
}

void SieveActionWidgetLister::updateAddRemoveButton()
{
    QList<QWidget *> widgetList = widgets();
    const int numberOfWidget(widgetList.count());
    bool addButtonEnabled = false;
    bool removeButtonEnabled = false;
    if (numberOfWidget <= widgetsMinimum()) {
        addButtonEnabled = true;
        removeButtonEnabled = false;
    } else if (numberOfWidget >= widgetsMaximum()) {
        addButtonEnabled = false;
        removeButtonEnabled = true;
    } else {
        addButtonEnabled = true;
        removeButtonEnabled = true;
    }
    QList<QWidget *>::ConstIterator wIt = widgetList.constBegin();
    QList<QWidget *>::ConstIterator wEnd = widgetList.constEnd();
    for (; wIt != wEnd; ++wIt) {
        SieveActionWidget *w = qobject_cast<SieveActionWidget *>(*wIt);
        w->updateAddRemoveButton(addButtonEnabled, removeButtonEnabled);
    }
}

Laurent Montel's avatar
Laurent Montel committed
328
void SieveActionWidgetLister::generatedScript(QString &script, QStringList &requires, bool onlyActions, bool inForEveryPartLoop)
329 330 331 332 333 334
{
    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);
Laurent Montel's avatar
Laurent Montel committed
335
        w->generatedScript(script, requires, onlyActions, inForEveryPartLoop);
336 337 338 339 340 341 342 343 344 345 346 347
    }
}

void SieveActionWidgetLister::reconnectWidget(SieveActionWidget *w)
{
    connect(w, &SieveActionWidget::addWidget, this, &SieveActionWidgetLister::slotAddWidget, Qt::UniqueConnection);
    connect(w, &SieveActionWidget::removeWidget, this, &SieveActionWidgetLister::slotRemoveWidget, Qt::UniqueConnection);
    connect(w, &SieveActionWidget::valueChanged, this, &SieveActionWidgetLister::valueChanged, Qt::UniqueConnection);
}

void SieveActionWidgetLister::clearWidget(QWidget *aWidget)
{
Laurent Montel's avatar
Laurent Montel committed
348 349 350 351
    if (aWidget) {
        SieveActionWidget *widget = static_cast<SieveActionWidget *>(aWidget);
        widget->clear();
    }
352 353 354 355 356
    Q_EMIT valueChanged();
}

QWidget *SieveActionWidgetLister::createWidget(QWidget *parent)
{
357
    SieveActionWidget *w = new SieveActionWidget(mSieveGraphicalModeWidget, parent);
358 359 360 361 362 363 364 365 366
    reconnectWidget(w);
    return w;
}

int SieveActionWidgetLister::actionNumber() const
{
    return widgets().count();
}

Laurent Montel's avatar
Laurent Montel committed
367
void SieveActionWidgetLister::loadScript(QXmlStreamReader &element, bool onlyActions, QString &error)
368
{
Laurent Montel's avatar
Laurent Montel committed
369
    qDebug() <<" void SieveActionWidgetLister::loadScript(QXmlStreamReader &element, bool onlyActions, QString &error) onlyaction" << onlyActions;
370 371 372 373
    QString comment;
    if (onlyActions) {
        const QStringRef tagName = element.name();
        if (tagName == QLatin1String("action")) {
Laurent Montel's avatar
Laurent Montel committed
374
            qDebug() << " tagname !!!!!!!!!!!!!!!!!!!!!!!!" << tagName;
375 376 377 378 379 380 381 382 383 384
            if (element.attributes().hasAttribute(QStringLiteral("name"))) {
                const QString actionName = element.attributes().value(QStringLiteral("name")).toString();
                SieveActionWidget *w = qobject_cast<SieveActionWidget *>(widgets().constLast());
                if (w->isConfigurated()) {
                    addWidgetAfterThisWidget(widgets().constLast());
                    w = qobject_cast<SieveActionWidget *>(widgets().constLast());
                }
                w->setAction(actionName, element, comment, error);
                //comment.clear();
            } else if (tagName == QLatin1String("crlf")) {
Laurent Montel's avatar
Laurent Montel committed
385
                element.skipCurrentElement();
386 387 388
                //nothing
            } else {
                qCDebug(LIBKSIEVE_LOG) << " SieveActionWidgetLister::loadScript don't have name attribute " << tagName;
Laurent Montel's avatar
Laurent Montel committed
389

390 391 392 393 394 395 396 397 398
            }
        } else {
            qCDebug(LIBKSIEVE_LOG) << " SieveActionWidgetLister::loadScript Unknow tag name " << tagName;
        }
    } else {
        bool firstAction = true;
        bool previousActionWasAComment = false;
        while (element.readNextStartElement()) {
            const QStringRef tagName = element.name();
Laurent Montel's avatar
Laurent Montel committed
399
            qDebug() << "ieveActionWidgetLister::loadScript SSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSs" << tagName;
400 401 402
            if (tagName == QLatin1String("action") || tagName == QLatin1String("control") /*for break action*/) {
                if (element.attributes().hasAttribute(QStringLiteral("name"))) {
                    const QString actionName = element.attributes().value(QStringLiteral("name")).toString();
Laurent Montel's avatar
Laurent Montel committed
403
                    qDebug() << "************************************* actionName"<<actionName;
404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425
                    if (tagName == QLatin1String("control") && actionName == QLatin1String("if")) {
                        qCDebug(LIBKSIEVE_LOG) << "We found an loop if in a loop if. Not supported";
                        error += i18n("We detected a loop if in a loop if. It's not supported") + QLatin1Char('\n');
                    }
                    if (firstAction) {
                        firstAction = false;
                    } else {
                        addWidgetAfterThisWidget(widgets().constLast());
                    }
                    SieveActionWidget *w = qobject_cast<SieveActionWidget *>(widgets().constLast());
                    w->setAction(actionName, element, comment, error);
                    comment.clear();
                } else {
                    qCDebug(LIBKSIEVE_LOG) << " SieveActionWidgetLister::loadScript don't have name attribute " << tagName;
                }
                previousActionWasAComment = false;
            } else if (tagName == QLatin1String("comment")) {
                if (!comment.isEmpty()) {
                    comment += QLatin1Char('\n');
                }
                previousActionWasAComment = true;
                comment += element.readElementText();
Laurent Montel's avatar
Laurent Montel committed
426
                qDebug() << "ieveActionWidgetLister::loadScript comment " << comment;
427 428 429 430 431
            } else if (tagName == QLatin1String("crlf")) {
                //Add new line if previous action was a comment
                if (previousActionWasAComment) {
                    comment += QLatin1Char('\n');
                }
Laurent Montel's avatar
Laurent Montel committed
432
                element.skipCurrentElement();
433 434 435 436 437 438
            } else {
                qCDebug(LIBKSIEVE_LOG) << " SieveActionWidgetLister::loadScript unknown tagName " << tagName;
            }
        }
    }

Laurent Montel's avatar
Laurent Montel committed
439
#ifdef REMOVE_QDOMELEMENT
440 441 442 443 444 445 446
    QString comment;
    if (onlyActions) {
        if (!element.isNull()) {
            const QString tagName = element.tagName();
            if (tagName == QLatin1String("action")) {
                if (element.hasAttribute(QStringLiteral("name"))) {
                    const QString actionName = element.attribute(QStringLiteral("name"));
Laurent Montel's avatar
Laurent Montel committed
447
                    SieveActionWidget *w = qobject_cast<SieveActionWidget *>(widgets().constLast());
448
                    if (w->isConfigurated()) {
Laurent Montel's avatar
Laurent Montel committed
449 450
                        addWidgetAfterThisWidget(widgets().constLast());
                        w = qobject_cast<SieveActionWidget *>(widgets().constLast());
451 452 453 454 455 456 457 458
                    }
                    w->setAction(actionName, element, comment, error);
                    //comment.clear();
                } else if (tagName == QLatin1String("crlf")) {
                    //nothing
                } else {
                    qCDebug(LIBKSIEVE_LOG) << " SieveActionWidgetLister::loadScript don't have name attribute " << tagName;
                }
Laurent Montel's avatar
Laurent Montel committed
459 460
            } else {
                qCDebug(LIBKSIEVE_LOG) << " SieveActionWidgetLister::loadScript Unknow tag name " << tagName;
461 462 463 464 465
            }
        }
    } else {
        bool firstAction = true;
        QDomNode node = element.firstChild();
Laurent Montel's avatar
Laurent Montel committed
466
        bool previousActionWasAComment = false;
467 468 469 470
        while (!node.isNull()) {
            QDomElement e = node.toElement();
            if (!e.isNull()) {
                const QString tagName = e.tagName();
Laurent Montel's avatar
Laurent Montel committed
471
                if (tagName == QLatin1String("action") || tagName == QLatin1String("control") /*for break action*/) {
472 473 474 475
                    if (e.hasAttribute(QStringLiteral("name"))) {
                        const QString actionName = e.attribute(QStringLiteral("name"));
                        if (tagName == QLatin1String("control") && actionName == QLatin1String("if")) {
                            qCDebug(LIBKSIEVE_LOG) << "We found an loop if in a loop if. Not supported";
476
                            error += i18n("We detected a loop if in a loop if. It's not supported") + QLatin1Char('\n');
477 478 479 480
                        }
                        if (firstAction) {
                            firstAction = false;
                        } else {
Laurent Montel's avatar
Laurent Montel committed
481
                            addWidgetAfterThisWidget(widgets().constLast());
482
                        }
Laurent Montel's avatar
Laurent Montel committed
483
                        SieveActionWidget *w = qobject_cast<SieveActionWidget *>(widgets().constLast());
484 485 486 487 488
                        w->setAction(actionName, e, comment, error);
                        comment.clear();
                    } else {
                        qCDebug(LIBKSIEVE_LOG) << " SieveActionWidgetLister::loadScript don't have name attribute " << tagName;
                    }
Laurent Montel's avatar
Laurent Montel committed
489
                    previousActionWasAComment = false;
490 491 492 493
                } else if (tagName == QLatin1String("comment")) {
                    if (!comment.isEmpty()) {
                        comment += QLatin1Char('\n');
                    }
Laurent Montel's avatar
Laurent Montel committed
494
                    previousActionWasAComment = true;
495 496
                    comment += e.text();
                } else if (tagName == QLatin1String("crlf")) {
Laurent Montel's avatar
Laurent Montel committed
497 498 499 500
                    //Add new line if previous action was a comment
                    if (previousActionWasAComment) {
                        comment += QLatin1Char('\n');
                    }
501 502 503 504 505 506 507
                } else {
                    qCDebug(LIBKSIEVE_LOG) << " SieveActionWidgetLister::loadScript unknown tagName " << tagName;
                }
            }
            node = node.nextSibling();
        }
    }
Laurent Montel's avatar
Laurent Montel committed
508
#endif
509
}