Mailcommon

filteractionwithtest.cpp
1 /*
2  * SPDX-FileCopyrightText: 1996-1998 Stefan Taferner <[email protected]>
3  *
4  * SPDX-License-Identifier: GPL-2.0-or-later
5  *
6  */
7 
8 #include "filteractionwithtest.h"
9 
10 #include "filter/soundtestwidget.h"
11 
12 using namespace MailCommon;
13 
14 FilterActionWithTest::FilterActionWithTest(const QString &name, const QString &label, QObject *parent)
15  : FilterAction(name, label, parent)
16 {
17 }
18 
19 FilterActionWithTest::~FilterActionWithTest() = default;
20 
21 bool FilterActionWithTest::isEmpty() const
22 {
23  return mParameter.trimmed().isEmpty();
24 }
25 
26 QWidget *FilterActionWithTest::createParamWidget(QWidget *parent) const
27 {
28  auto soundWidget = new SoundTestWidget(parent);
29  soundWidget->setUrl(mParameter);
30  soundWidget->setObjectName(QStringLiteral("soundwidget"));
31 
32  connect(soundWidget, &SoundTestWidget::textChanged, this, &FilterActionWithTest::filterActionModified);
33 
34  return soundWidget;
35 }
36 
37 void FilterActionWithTest::applyParamWidgetValue(QWidget *paramWidget)
38 {
39  mParameter = static_cast<SoundTestWidget *>(paramWidget)->url();
40 }
41 
42 void FilterActionWithTest::setParamWidgetValue(QWidget *paramWidget) const
43 {
44  static_cast<SoundTestWidget *>(paramWidget)->setUrl(mParameter);
45 }
46 
47 void FilterActionWithTest::clearParamWidget(QWidget *paramWidget) const
48 {
49  static_cast<SoundTestWidget *>(paramWidget)->clear();
50 }
51 
52 void FilterActionWithTest::argsFromString(const QString &argsStr)
53 {
54  mParameter = argsStr;
55 }
56 
57 QString FilterActionWithTest::argsAsString() const
58 {
59  return mParameter;
60 }
61 
62 QString FilterActionWithTest::displayString() const
63 {
64  return label() + QLatin1String(" \"") + argsAsString().toHtmlEscaped() + QLatin1String("\"");
65 }
A widget to play a sound from a given URL.
Abstract base class for mail filter actions.
Definition: filteraction.h:38
KGuiItem clear()
QString label(StandardShortcut id)
void textChanged(const QString &)
This signal is emitted when the user enters a new URL.
QString name(StandardShortcut id)
The filter dialog.
virtual bool isEmpty() const
Determines whether this action is valid.
This file is part of the KDE documentation.
Documentation copyright © 1996-2023 The KDE developers.
Generated on Sun Jun 4 2023 03:58:00 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.