[vlmc-devel] commit: EffectsEngine: Store the effects by name. ( Hugo Beauzée-Luyssen )

git at videolan.org git at videolan.org
Wed Jul 28 00:22:05 CEST 2010


vlmc | branch: master | Hugo Beauzée-Luyssen <beauze.h at gmail.com> | Sun Jul 25 22:11:11 2010 +0200| [43e1b8b38a84e567ad434ec21e832f57f6aadb79] | committer: Hugo Beauzée-Luyssen 

EffectsEngine: Store the effects by name.

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

 src/EffectsEngine/EffectsEngine.cpp |   12 ++++++------
 src/EffectsEngine/EffectsEngine.h   |    6 +++---
 2 files changed, 9 insertions(+), 9 deletions(-)

diff --git a/src/EffectsEngine/EffectsEngine.cpp b/src/EffectsEngine/EffectsEngine.cpp
index 2e33a74..e14e0bf 100644
--- a/src/EffectsEngine/EffectsEngine.cpp
+++ b/src/EffectsEngine/EffectsEngine.cpp
@@ -28,9 +28,6 @@
 
 EffectsEngine::EffectsEngine()
 {
-    Effect  *e = new Effect("libbw0r");
-
-    m_effects.push_back( e );
 }
 
 EffectsEngine::~EffectsEngine()
@@ -45,9 +42,12 @@ EffectsEngine::initAll( quint32 width, quint32 height )
 }
 
 Effect*
-EffectsEngine::effect( qint32 idx )
+EffectsEngine::effect( const QString& name )
 {
-    return m_effects.at( idx );
+    QHash<QString, Effect*>::iterator   it = m_effects.find( name );
+    if ( it != m_effects.end() )
+        return it.value();
+    return NULL;
 }
 
 bool
@@ -59,7 +59,7 @@ EffectsEngine::loadEffect( const QString &fileName )
         delete e;
         return false;
     }
-    m_effects.push_back( e );
+    m_effects[e->name()] = e;
     emit effectAdded( e, e->type() );
     return true;
 }
diff --git a/src/EffectsEngine/EffectsEngine.h b/src/EffectsEngine/EffectsEngine.h
index 59d9e2c..805f4b2 100644
--- a/src/EffectsEngine/EffectsEngine.h
+++ b/src/EffectsEngine/EffectsEngine.h
@@ -28,7 +28,7 @@
 #include "Effect.h"
 
 #include <QObject>
-#include <QList>
+#include <QHash>
 
 class   EffectsEngine : public QObject, public Singleton<EffectsEngine>
 {
@@ -36,14 +36,14 @@ class   EffectsEngine : public QObject, public Singleton<EffectsEngine>
 
     public:
         void        initAll( quint32 width, quint32 height );
-        Effect*     effect( qint32 idx );
+        Effect*     effect( const QString& name );
         bool        loadEffect( const QString& fileName );
         void        browseDirectory( const QString& path );
     private:
         EffectsEngine();
         ~EffectsEngine();
 
-        QList<Effect*>  m_effects;
+        QHash<QString, Effect*>  m_effects;
 
     signals:
         void        effectAdded( Effect*, Effect::Type );



More information about the Vlmc-devel mailing list