File indexing completed on 2024-11-10 04:50:05

0001 /*
0002  * SPDX-FileCopyrightText: 1996-1998 Stefan Taferner <taferner@kde.org>
0003  *
0004  * SPDX-License-Identifier: GPL-2.0-or-later
0005  *
0006  */
0007 
0008 #include "filteractionwithtest.h"
0009 
0010 #include "filter/soundtestwidget.h"
0011 
0012 using namespace MailCommon;
0013 
0014 FilterActionWithTest::FilterActionWithTest(const QString &name, const QString &label, QObject *parent)
0015     : FilterAction(name, label, parent)
0016 {
0017 }
0018 
0019 FilterActionWithTest::~FilterActionWithTest() = default;
0020 
0021 bool FilterActionWithTest::isEmpty() const
0022 {
0023     return mParameter.trimmed().isEmpty();
0024 }
0025 
0026 QWidget *FilterActionWithTest::createParamWidget(QWidget *parent) const
0027 {
0028     auto soundWidget = new SoundTestWidget(parent);
0029     soundWidget->setUrl(mParameter);
0030     soundWidget->setObjectName(QLatin1StringView("soundwidget"));
0031 
0032     connect(soundWidget, &SoundTestWidget::textChanged, this, &FilterActionWithTest::filterActionModified);
0033 
0034     return soundWidget;
0035 }
0036 
0037 void FilterActionWithTest::applyParamWidgetValue(QWidget *paramWidget)
0038 {
0039     mParameter = static_cast<SoundTestWidget *>(paramWidget)->url();
0040 }
0041 
0042 void FilterActionWithTest::setParamWidgetValue(QWidget *paramWidget) const
0043 {
0044     static_cast<SoundTestWidget *>(paramWidget)->setUrl(mParameter);
0045 }
0046 
0047 void FilterActionWithTest::clearParamWidget(QWidget *paramWidget) const
0048 {
0049     static_cast<SoundTestWidget *>(paramWidget)->clear();
0050 }
0051 
0052 void FilterActionWithTest::argsFromString(const QString &argsStr)
0053 {
0054     mParameter = argsStr;
0055 }
0056 
0057 QString FilterActionWithTest::argsAsString() const
0058 {
0059     return mParameter;
0060 }
0061 
0062 QString FilterActionWithTest::displayString() const
0063 {
0064     return label() + QLatin1StringView(" \"") + argsAsString().toHtmlEscaped() + QLatin1StringView("\"");
0065 }
0066 
0067 #include "moc_filteractionwithtest.cpp"