File indexing completed on 2024-04-14 04:38:24

0001 /*  This file is part of the KDE project
0002     Copyright (C) 2006 Matthias Kretz <kretz@kde.org>
0003 
0004     This library is free software; you can redistribute it and/or
0005     modify it under the terms of the GNU Lesser General Public
0006     License as published by the Free Software Foundation; either
0007     version 2.1 of the License, or (at your option) version 3, or any
0008     later version accepted by the membership of KDE e.V. (or its
0009     successor approved by the membership of KDE e.V.), Nokia Corporation 
0010     (or its successors, if any) and the KDE Free Qt Foundation, which shall
0011     act as a proxy defined in Section 6 of version 3 of the license.
0012 
0013     This library is distributed in the hope that it will be useful,
0014     but WITHOUT ANY WARRANTY; without even the implied warranty of
0015     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
0016     Lesser General Public License for more details.
0017 
0018     You should have received a copy of the GNU Lesser General Public 
0019     License along with this library.  If not, see <http://www.gnu.org/licenses/>.
0020 
0021 */
0022 
0023 #ifndef PHONON_EFFECTPARAMETER_H
0024 #define PHONON_EFFECTPARAMETER_H
0025 
0026 #include "phonon_export.h"
0027 
0028 #include <QExplicitlySharedDataPointer>
0029 #include <QVariant>
0030 
0031 
0032 #ifndef QT_NO_PHONON_EFFECT
0033 
0034 namespace Phonon
0035 {
0036 
0037 class Effect;
0038 class EffectParameterPrivate;
0039 
0040 /** \class EffectParameter effectparameter.h phonon/EffectParameter
0041  * \brief This class describes one parameter of an effect.
0042  *
0043  * \ingroup PhononEffects
0044  * \author Matthias Kretz <kretz@kde.org>
0045  * \see Effect
0046  */
0047 class PHONON_EXPORT EffectParameter
0048 {
0049     friend class BrightnessControl;
0050     public:
0051         /**
0052          * \internal
0053          *
0054          * Creates an invalid effect parameter.
0055          */
0056         EffectParameter();
0057 
0058         /**
0059          * The name of the parameter. Can be used as the label.
0060          *
0061          * \return A label for the parameter.
0062          */
0063         const QString &name() const;
0064 
0065         /**
0066          * The parameter may come with a description (LADSPA doesn't have a
0067          * field for this, so don't expect many effects to provide a
0068          * description).
0069          *
0070          * The description can be used for a tooltip or WhatsThis help.
0071          *
0072          * \return A text describing the parameter.
0073          */
0074         const QString &description() const;
0075 
0076         /**
0077          * Returns the parameter type.
0078          *
0079          * Common types are QVariant::Int, QVariant::Double, QVariant::Bool and QVariant::String. When
0080          * QVariant::String is returned you get the possible values from possibleValues.
0081          */
0082         QVariant::Type type() const;
0083 
0084         /**
0085          * Returns whether the parameter should be
0086          * displayed using a logarithmic scale. This is particularly useful for
0087          * frequencies and gains.
0088          */
0089         bool isLogarithmicControl() const;
0090 
0091         /**
0092          * The minimum value to be used for the control to edit the parameter.
0093          *
0094          * If the returned QVariant is invalid the value is not bounded from
0095          * below.
0096          */
0097         QVariant minimumValue() const;
0098 
0099         /**
0100          * The maximum value to be used for the control to edit the parameter.
0101          *
0102          * If the returned QVariant is invalid the value is not bounded from
0103          * above.
0104          */
0105         QVariant maximumValue() const;
0106 
0107         /**
0108          * The default value.
0109          */
0110         QVariant defaultValue() const;
0111 
0112         /**
0113          * The possible values to be used for the control to edit the parameter.
0114          *
0115          * if the value of this parameter is to be picked from predefined values
0116          * this returns the list (otherwise it returns an empty QVariantList).
0117          */
0118         QVariantList possibleValues() const;
0119 
0120         /**
0121          * \internal
0122          * compares the ids of the parameters
0123          */
0124         bool operator<(const EffectParameter &rhs) const;
0125 
0126         /**
0127          * \internal
0128          * compares the ids of the parameters
0129          */
0130         bool operator>(const EffectParameter &rhs) const;
0131 
0132         /**
0133          * \internal
0134          * compares the ids of the parameters
0135          */
0136         bool operator==(const EffectParameter &rhs) const;
0137 
0138         /* dtor, cctor and operator= for forward decl of EffectParameterPrivate */
0139         ~EffectParameter();
0140         EffectParameter(const EffectParameter &rhs);
0141         EffectParameter &operator=(const EffectParameter &rhs);
0142 
0143         /**
0144          * Only for backend developers:
0145          *
0146          * Flags to set the return values of isToggleControl(),
0147          * isLogarithmicControl(), isIntegerControl(), isBoundedBelow() and
0148          * isBoundedAbove(). The values of the flags correspond to the values
0149          * used for LADSPA effects.
0150          */
0151         enum Hint {
0152             /**
0153              * If this hint is set it means that
0154              * the control has only two states: zero and non-zero.
0155              *
0156              * \see isToggleControl()
0157              */
0158             ToggledHint      = 0x04,
0159 
0160             /* LADSPA's SAMPLE_RATE hint needs to be translated by the backend
0161              * to normal bounds, as the backend knows the sample rate - and the
0162              * frontend doesn't */
0163 
0164             /**
0165              * \see isLogarithmicControl()
0166              */
0167             LogarithmicHint  = 0x10,
0168             /**
0169              * \see isIntegerControl
0170              */
0171             IntegerHint      = 0x20
0172         };
0173         Q_DECLARE_FLAGS(Hints, Hint)
0174 
0175         /**
0176          * Only to be used by backend implementations:
0177          *
0178          * Creates a new effect parameter.
0179          *
0180          * \param parameterId This is a number to uniquely identify the
0181          * parameter. The id is used for value() and setValue().
0182          *
0183          * \param name The name/label for this parameter.
0184          *
0185          * \param hints Sets the hints for the type of parameter.
0186          *
0187          * \param defaultValue The value that should be used as a default.
0188          *
0189          * \param min The minimum value allowed for this parameter. You only
0190          * need to set this if the BoundedBelowHint is set.
0191          *
0192          * \param max The maximum value allowed for this parameter. You only
0193          * need to set this if the BoundedAboveHint is set.
0194          *
0195          * \param description A descriptive text for the parameter
0196          * (explaining what it controls) to be used as a tooltip or
0197          * WhatsThis help.
0198          */
0199         EffectParameter(int parameterId, const QString &name, Hints hints,
0200                 const QVariant &defaultValue, const QVariant &min = QVariant(),
0201                 const QVariant &max = QVariant(), const QVariantList &values = QVariantList(),
0202                 const QString &description = QString());
0203 
0204         /**
0205          * \internal
0206          *
0207          * Returns the parameter's id.
0208          */
0209         int id() const;
0210 
0211     protected:
0212         /**
0213          * The data is implicitly shared.
0214          */
0215         QExplicitlySharedDataPointer<EffectParameterPrivate> d;
0216 };
0217 
0218 Q_DECLARE_OPERATORS_FOR_FLAGS(EffectParameter::Hints)
0219 
0220 uint PHONON_EXPORT qHash(const Phonon::EffectParameter &param);
0221 
0222 } // namespace Phonon
0223 
0224 #if defined(Q_CC_MSVC) && _MSC_VER <= 1300
0225 //this ensures that code outside Phonon can use the hash function
0226 //it also a workaround for some compilers
0227 inline uint qHash(const Phonon::EffectParameter &param) { return Phonon::qHash(param); } //krazy:exclude=inline
0228 #endif
0229 
0230 #endif //QT_NO_PHONON_EFFECT
0231 
0232 
0233 #endif // PHONON_EFFECTPARAMETER_H
0234 // vim: sw=4 ts=4 tw=80