File indexing completed on 2024-09-22 04:50:02

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 #pragma once
0009 
0010 #include "filteraction.h"
0011 #include <QToolButton>
0012 
0013 namespace MailCommon
0014 {
0015 /**
0016  * @short Abstract base class for filter actions with a command line as parameter.
0017  *
0018  * Abstract base class for mail filter actions that need a command
0019  * line as parameter, e.g. 'forward to'. Can create a QLineEdit
0020  * (are there better widgets in the depths of the kdelibs?) as
0021  * parameter widget. A subclass of this must provide at least
0022  * implementations for the following methods:
0023  *
0024  * @li virtual FilterAction::ReturnCodes FilterAction::process
0025  * @li static FilterAction::newAction
0026  *
0027  * The implementation of FilterAction::process should take the
0028  * command line specified in mParameter, make all required
0029  * modifications and stream the resulting command line into @p
0030  * mProcess. Then you can start the command with @p mProcess.start().
0031  *
0032  * @author Marc Mutz <mutz@kde.org>, based upon work by Stefan Taferner <taferner@kde.org>
0033  * @see FilterActionWithString FilterAction Filter KProcess
0034  */
0035 class FilterActionWithUrlHelpButton : public QToolButton
0036 {
0037     Q_OBJECT
0038 public:
0039     explicit FilterActionWithUrlHelpButton(QWidget *parent = nullptr);
0040     ~FilterActionWithUrlHelpButton() override;
0041 };
0042 
0043 class FilterActionWithUrl : public FilterAction
0044 {
0045     Q_OBJECT
0046 public:
0047     /**
0048      * @copydoc FilterAction::FilterAction
0049      */
0050     FilterActionWithUrl(const QString &name, const QString &label, QObject *parent = nullptr);
0051 
0052     /**
0053      * @copydoc FilterAction::~FilterAction
0054      */
0055     ~FilterActionWithUrl() override;
0056 
0057     /**
0058      * @copydoc FilterAction::isEmpty
0059      */
0060     [[nodiscard]] bool isEmpty() const override;
0061 
0062     /**
0063      * @copydoc FilterAction::createParamWidget
0064      */
0065     [[nodiscard]] QWidget *createParamWidget(QWidget *parent) const override;
0066 
0067     /**
0068      * @copydoc FilterAction::applyParamWidgetValue
0069      */
0070     void applyParamWidgetValue(QWidget *paramWidget) override;
0071 
0072     /**
0073      * @copydoc FilterAction::setParamWidgetValue
0074      */
0075     void setParamWidgetValue(QWidget *paramWidget) const override;
0076 
0077     /**
0078      * @copydoc FilterAction::clearParamWidget
0079      */
0080     void clearParamWidget(QWidget *paramWidget) const override;
0081 
0082     /**
0083      * @copydoc FilterAction::applyFromString
0084      */
0085     void argsFromString(const QString &argsStr) override;
0086 
0087     /**
0088      * @copydoc FilterAction::argsAsString
0089      */
0090     [[nodiscard]] QString argsAsString() const override;
0091 
0092     /**
0093      * @copydoc FilterAction::displayString
0094      */
0095     [[nodiscard]] QString displayString() const override;
0096 
0097 protected:
0098     QString mParameter;
0099 
0100 private:
0101     mutable FilterActionWithUrlHelpButton *mHelpButton = nullptr;
0102 
0103 private:
0104     void slotHelp();
0105 };
0106 }