[vlmc-devel] commit: EffectUser: Adding methods to remove and move effects. ( Hugo Beauzée-Luyssen )

git at videolan.org git at videolan.org
Wed Sep 8 19:45:15 CEST 2010


vlmc | branch: master | Hugo Beauzée-Luyssen <beauze.h at gmail.com> | Wed Sep  8 17:38:58 2010 +0200| [c16cf1e3a722807d8030869b870e76b9ef0ec150] | committer: Hugo Beauzée-Luyssen 

EffectUser: Adding methods to remove and move effects.

> http://git.videolan.org/gitweb.cgi/vlmc.git/?a=commit;h=c16cf1e3a722807d8030869b870e76b9ef0ec150
---

 src/CMakeLists.txt               |    1 +
 src/EffectsEngine/EffectUser.cpp |   47 ++++++++++++++++++++++++++++++++++++-
 src/EffectsEngine/EffectUser.h   |    8 ++++++
 3 files changed, 54 insertions(+), 2 deletions(-)

diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 53601f0..ccbbeb3 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -62,6 +62,7 @@ ENDIF(WIN32)
 
 SET (VLMC_HDRS
     EffectsEngine/EffectHelper.h
+    EffectsEngine/EffectUser.h
     EffectsEngine/EffectsEngine.h
     EffectsEngine/EffectSettingValue.h
     Library/Library.h
diff --git a/src/EffectsEngine/EffectUser.cpp b/src/EffectsEngine/EffectUser.cpp
index 7179649..300b488 100644
--- a/src/EffectsEngine/EffectUser.cpp
+++ b/src/EffectsEngine/EffectUser.cpp
@@ -226,18 +226,43 @@ 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 )
 {
     if ( idx >= m_filters.size() || idx2 > m_filters.size() )
@@ -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();
+}
diff --git a/src/EffectsEngine/EffectUser.h b/src/EffectsEngine/EffectUser.h
index 360bfcf..f541d62 100644
--- a/src/EffectsEngine/EffectUser.h
+++ b/src/EffectsEngine/EffectUser.h
@@ -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



More information about the Vlmc-devel mailing list