Commit c16cf1e3 authored by Hugo Beauzée-Luyssen's avatar Hugo Beauzée-Luyssen

EffectUser: Adding methods to remove and move effects.

parent 3cb012c4
......@@ -62,6 +62,7 @@ ENDIF(WIN32)
SET (VLMC_HDRS
EffectsEngine/EffectHelper.h
EffectsEngine/EffectUser.h
EffectsEngine/EffectsEngine.h
EffectsEngine/EffectSettingValue.h
Library/Library.h
......
......@@ -226,17 +226,42 @@ EffectUser::removeEffect( Effect::Type type, quint32 idx )
if ( type == Effect::Filter )
{
if ( idx < m_filters.size() )
m_filters.removeAt( idx );
{
EffectHelper *helper = m_filters.takeAt( idx );
emit effectRemoved( helper );
}
}
else if ( type == Effect::Mixer2 )
{
if ( idx < m_mixers.size() )
m_mixers.removeAt( idx );
{
EffectHelper *helper = m_mixers.takeAt( idx );
emit effectRemoved( helper );
}
}
else
qCritical() << "Unhandled effect type";
}
void
EffectUser::removeEffect(EffectHelper *helper)
{
QWriteLocker lock( m_effectsLock );
EffectsEngine::EffectList::iterator it = m_filters.begin();
EffectsEngine::EffectList::iterator ite = m_filters.end();
while ( it != ite )
{
if ( (*it)->uuid() == helper->uuid() )
{
m_filters.erase( it );
emit effectRemoved( (*it) );
return ;
}
}
qWarning() << "Can't find EffectHelper" << helper->uuid() << "for removal.";
}
void
EffectUser::swapFilters( quint32 idx, quint32 idx2 )
{
......@@ -259,3 +284,21 @@ EffectUser::count( Effect::Type type ) const
qCritical() << "Unhandled effect type";
return 0;
}
void
EffectUser::moveEffect( EffectHelper *helper, qint64 newPos )
{
QWriteLocker lock( m_effectsLock );
foreach ( EffectHelper *eh, m_filters )
{
if ( helper->uuid() == eh->uuid() )
{
qint64 offset = helper->begin() - newPos;
helper->setBoundaries( newPos, helper->end() - offset );
emit effectMoved( helper, newPos );
return ;
}
}
qWarning() << "Can't find effect" << helper->uuid();
}
......@@ -34,6 +34,8 @@ class QReadWriteLock;
class EffectUser : public QObject
{
Q_OBJECT
public:
/**
* \brief Add an effect to the TrackWorkflow
......@@ -41,6 +43,8 @@ class EffectUser : public QObject
* \param effect The effect instance. Can be either mixer or filter.
*/
EffectHelper *addEffect( Effect *effect, qint64 start = 0, qint64 end = -1 );
void moveEffect( EffectHelper *helper, qint64 newPos );
void removeEffect( EffectHelper *helper );
const EffectsEngine::EffectList &effects( Effect::Type type ) const;
void removeEffect( Effect::Type type, quint32 idx );
void swapFilters( quint32 idx, quint32 idx2 );
......@@ -75,6 +79,10 @@ class EffectUser : public QObject
QReadWriteLock *m_effectsLock;
EffectsEngine::EffectList m_mixers;
EffectsEngine::EffectList m_filters;
signals:
void effectMoved( EffectHelper *helper, qint64 newPos );
void effectRemoved( EffectHelper *helper );
};
#endif // EFFECTUSER_H
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment