use XML rather than binary blobs for saving plugin-/effect-key
git-svn-id: https://lmms.svn.sf.net/svnroot/lmms/trunk/lmms@1433 0778d3d1-df1d-0410-868b-ea421aaaa00d
This commit is contained in:
@@ -62,7 +62,7 @@ void effectChain::saveSettings( QDomDocument & _doc, QDomElement & _this )
|
||||
{
|
||||
QDomElement ef = ( *it )->saveState( _doc, _this );
|
||||
ef.setAttribute( "name", ( *it )->getDescriptor()->name );
|
||||
ef.setAttribute( "key", ( *it )->getKey().dumpBase64() );
|
||||
ef.appendChild( ( *it )->getKey().saveXML( _doc ) );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -85,10 +85,8 @@ void effectChain::loadSettings( const QDomElement & _this )
|
||||
{
|
||||
QDomElement cn = node.toElement();
|
||||
const QString name = cn.attribute( "name" );
|
||||
// we have this really convenient key-ctor
|
||||
// which takes a QString and decodes the
|
||||
// base64-data inside :-)
|
||||
effectKey key( cn.attribute( "key" ) );
|
||||
effectKey key( cn.elementsByTagName( "key" ).
|
||||
item( 0 ).toElement() );
|
||||
effect * e = effect::instantiate( name, this, &key );
|
||||
if( e->isOkay() )
|
||||
{
|
||||
@@ -96,7 +94,7 @@ void effectChain::loadSettings( const QDomElement & _this )
|
||||
{
|
||||
if( e->nodeName() == node.nodeName() )
|
||||
{
|
||||
e->restoreState( node.toElement() );
|
||||
e->restoreState( node.toElement() );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -136,7 +136,7 @@ void ladspaManager::addPlugins(
|
||||
( descriptor = _descriptor_func( pluginIndex ) ) != NULL;
|
||||
++pluginIndex )
|
||||
{
|
||||
ladspa_key_t key( QString( descriptor->Label ), _file );
|
||||
ladspa_key_t key( _file, QString( descriptor->Label ) );
|
||||
if( m_ladspaManagerMap.contains( key ) )
|
||||
{
|
||||
continue;
|
||||
@@ -167,7 +167,7 @@ void ladspaManager::addPlugins(
|
||||
{
|
||||
plugIn->type = OTHER;
|
||||
}
|
||||
|
||||
|
||||
m_ladspaManagerMap[key] = plugIn;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -37,6 +37,8 @@
|
||||
#include "config_mgr.h"
|
||||
#include "project_version.h"
|
||||
#include "song_editor.h"
|
||||
#include "effect.h"
|
||||
|
||||
|
||||
|
||||
multimediaProject::typeDescStruct
|
||||
@@ -667,6 +669,46 @@ void multimediaProject::upgrade( void )
|
||||
el.setAttribute( "src", s );
|
||||
}
|
||||
}
|
||||
|
||||
if( version < "0.4.0-beta1" )
|
||||
{
|
||||
// convert binary effect-key-blobs to XML
|
||||
QDomNodeList list;
|
||||
list = elementsByTagName( "effect" );
|
||||
for( int i = 0; !list.item( i ).isNull(); ++i )
|
||||
{
|
||||
QDomElement el = list.item( i ).toElement();
|
||||
QString k = el.attribute( "key" );
|
||||
if( !k.isEmpty() )
|
||||
{
|
||||
const QList<QVariant> l =
|
||||
base64::decode( k, QVariant::List ).
|
||||
toList();
|
||||
if( !l.isEmpty() )
|
||||
{
|
||||
QString name = l[0].toString();
|
||||
QVariant u = l[1];
|
||||
effectKey::attributeMap m;
|
||||
// VST-effect?
|
||||
if( u.type() == QVariant::String )
|
||||
{
|
||||
m["file"] = u.toString();
|
||||
}
|
||||
// LADSPA-effect?
|
||||
else if( u.type() ==
|
||||
QVariant::StringList )
|
||||
{
|
||||
const QStringList sl =
|
||||
u.toStringList();
|
||||
m["plugin"] = sl.value( 0 );
|
||||
m["file"] = sl.value( 1 );
|
||||
}
|
||||
effectKey key( NULL, name, m );
|
||||
el.appendChild( key.saveXML( *this ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
/* if( version < "0.4.0-beta" )
|
||||
{
|
||||
QDomNodeList list;
|
||||
|
||||
@@ -205,5 +205,38 @@ pluginView * plugin::createView( QWidget * _parent )
|
||||
|
||||
|
||||
|
||||
plugin::descriptor::subPluginFeatures::key::key(
|
||||
const QDomElement & _key ) :
|
||||
desc( NULL ),
|
||||
name( _key.attribute( "key" ) ),
|
||||
attributes()
|
||||
{
|
||||
QDomNodeList l = _key.elementsByTagName( "attribute" );
|
||||
for( int i = 0; !l.item( i ).isNull(); ++i )
|
||||
{
|
||||
QDomElement e = l.item( i ).toElement();
|
||||
attributes[e.attribute( "name" )] = e.attribute( "value" );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
QDomElement plugin::descriptor::subPluginFeatures::key::saveXML(
|
||||
QDomDocument & _doc ) const
|
||||
{
|
||||
QDomElement e = _doc.createElement( "key" );
|
||||
for( attributeMap::const_iterator it = attributes.begin();
|
||||
it != attributes.end(); ++it )
|
||||
{
|
||||
QDomElement a = _doc.createElement( "attribute" );
|
||||
a.setAttribute( "name", it.key() );
|
||||
a.setAttribute( "value", it.value() );
|
||||
e.appendChild( a );
|
||||
}
|
||||
return( e );
|
||||
}
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user