1 /* This file is part of the KDE project
2 Copyright (C) 2005-2006 Matthias Kretz <kretz@kde.org>
4 This library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Library General Public
6 License version 2 as published by the Free Software Foundation.
8 This library is distributed in the hope that it will be useful,
9 but WITHOUT ANY WARRANTY; without even the implied warranty of
10 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 Library General Public License for more details.
13 You should have received a copy of the GNU Library General Public License
14 along with this library; see the file COPYING.LIB. If not, write to
15 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
16 Boston, MA 02110-1301, USA.
19 #include "videoeffect.h"
20 #include "videoeffect_p.h"
21 #include "effectparameter.h"
27 VideoEffect::VideoEffect( const VideoEffectDescription
& type
, QObject
* parent
)
29 , Base( *new VideoEffectPrivate
)
32 d
->type
= type
.index();
36 VideoEffect::VideoEffect( VideoEffectPrivate
& dd
, QObject
* parent
, const VideoEffectDescription
& type
)
41 d
->type
= type
.index();
44 void VideoEffectPrivate::createIface()
49 backendObject
= Factory::createVideoEffect(type
, q
);
54 VideoEffectDescription
VideoEffect::type() const
56 K_D( const VideoEffect
);
57 return VideoEffectDescription::fromIndex( d
->type
);
60 QList
<EffectParameter
> VideoEffect::parameterList() const
62 K_D( const VideoEffect
);
63 QList
<EffectParameter
> ret
;
64 // there should be an iface object, but better be safe for those backend
65 // switching corner-cases: when the backend switches the new backend might
66 // not support this effect -> no iface object
67 if( d
->backendObject
)
69 BACKEND_GET( QList
<EffectParameter
>, ret
, "parameterList" );
70 for( int i
= 0; i
< ret
.size(); ++i
)
71 ret
[ i
].setEffect( const_cast<VideoEffect
*>( this ) );
76 QVariant
VideoEffect::value( int parameterId
) const
78 K_D( const VideoEffect
);
79 if( !d
->backendObject
)
80 return d
->parameterValues
[ parameterId
];
82 BACKEND_GET1( QVariant
, ret
, "value", int, parameterId
);
86 void VideoEffect::setValue( int parameterId
, QVariant newValue
)
90 BACKEND_CALL2( "setValue", int, parameterId
, QVariant
, newValue
);
92 d
->parameterValues
[ parameterId
] = newValue
;
95 bool VideoEffectPrivate::aboutToDeleteIface()
99 QList
<EffectParameter
> plist
;
100 pBACKEND_GET( QList
<EffectParameter
>, plist
, "parameterList" );
101 foreach( EffectParameter p
, plist
)
102 parameterValues
[ p
.id() ] = p
.value();
107 void VideoEffect::setupIface()
110 Q_ASSERT( d
->backendObject
);
113 QList
<EffectParameter
> plist
;
114 BACKEND_GET( QList
<EffectParameter
>, plist
, "parameterList" );
115 foreach( EffectParameter p
, plist
)
116 if( d
->parameterValues
.contains( p
.id() ) )
117 p
.setValue( d
->parameterValues
[ p
.id() ] );
122 #include "videoeffect.moc"
124 // vim: sw=4 ts=4 tw=80