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

EffectsEngine: Store the effects by name.

parent ddb24139
......@@ -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;
}
......
......@@ -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 );
......
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