source: trunk/src/3rdparty/phonon/mmf/effectparameter.cpp

Last change on this file was 651, checked in by Dmitry A. Kuminov, 16 years ago

trunk: Merged in qt 4.6.2 sources.

File size: 2.1 KB
Line 
1/* This file is part of the KDE project.
2
3Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
4
5This library is free software: you can redistribute it and/or modify
6it under the terms of the GNU Lesser General Public License as published by
7the Free Software Foundation, either version 2.1 or 3 of the License.
8
9This library is distributed in the hope that it will be useful,
10but WITHOUT ANY WARRANTY; without even the implied warranty of
11MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12GNU Lesser General Public License for more details.
13
14You should have received a copy of the GNU Lesser General Public License
15along with this library. If not, see <http://www.gnu.org/licenses/>.
16
17*/
18
19#include "effectparameter.h"
20
21QT_BEGIN_NAMESPACE
22
23using namespace Phonon;
24using namespace Phonon::MMF;
25
26/*! \class MMF::EffectParameter
27 \internal
28*/
29
30MMF::EffectParameter::EffectParameter()
31 : m_hasInternalRange(false)
32{
33
34}
35
36MMF::EffectParameter::EffectParameter(
37 int parameterId, const QString &name, Hints hints,
38 const QVariant &defaultValue, const QVariant &min,
39 const QVariant &max, const QVariantList &values,
40 const QString &description)
41 : Phonon::EffectParameter(parameterId, name, hints, defaultValue,
42 min, max, values, description)
43 , m_hasInternalRange(false)
44{
45
46}
47
48void MMF::EffectParameter::setInternalRange(qint32 min, qint32 max)
49{
50 Q_ASSERT_X(max >= min, Q_FUNC_INFO, "Invalid range");
51 m_internalRange = QPair<qint32, qint32>(min, max);
52 m_hasInternalRange = true;
53}
54
55qint32 MMF::EffectParameter::toInternalValue(qreal external) const
56{
57 Q_ASSERT_X(m_hasInternalRange, Q_FUNC_INFO, "Does not have internal range");
58 const qint32 range = m_internalRange.second - m_internalRange.first;
59 return m_internalRange.first + ((1.0 + external) / 2) * range;
60}
61
62qreal MMF::EffectParameter::toExternalValue
63 (qint32 value, qint32 min, qint32 max)
64{
65 Q_ASSERT_X(max >= min, Q_FUNC_INFO, "Invalid range");
66 const qint32 range = max - min;
67 return range == 0 ? 0.0 : ((2.0 * value - min) / range) - 1.0;
68}
69
70QT_END_NAMESPACE
71
Note: See TracBrowser for help on using the repository browser.