void
Dynamic::ReplacementBias::factoryChanged()
{
    DEBUG_BLOCK;

    // -- search if there is a new factory with my name
    foreach( AbstractBiasFactory* factory, BiasFactory::instance()->factories() )
    {
        if( factory->name() == m_name )
        {
            debug() << "Found new factory for" << m_name;

            // -- replace myself with the new bias
            QXmlStreamReader reader( m_html );

            Dynamic::BiasPtr newBias( factory->createFromXml( &reader ) );
            replace( newBias );
            return;
        }
    }
}
void
PlaylistBrowserNS::BiasDialog::selectionChanged( int index )
{
    DEBUG_BLOCK;
    Q_ASSERT( m_biasSelection );

    QString biasName = m_biasSelection->itemData( index ).toString();

    Dynamic::BiasPtr oldBias( m_bias );
    Dynamic::BiasPtr newBias( Dynamic::BiasFactory::fromName( biasName ) );
    if( !newBias )
    {
        warning() << "Could not create bias with name:"<<biasName;
        return;
    }

    debug() << "replace bias" << oldBias->toString() << "with" << newBias->toString();
    m_bias->replace( newBias ); // tell the old bias it has just been replaced
    debug() << "replaced";

    // -- if the new bias is AndBias, try to add the old biase(s) into it
    Dynamic::AndBias *oldABias = qobject_cast<Dynamic::AndBias*>(oldBias.data());
    Dynamic::AndBias *newABias = qobject_cast<Dynamic::AndBias*>(newBias.data());
    if( newABias ) {
        if( oldABias ) {
            for( int i = 0; i < oldABias->biases().count(); i++ )
            {
                newABias->appendBias( oldABias->biases()[i] );
            }
        }
        else
        {
            newABias->appendBias( oldBias );
        }
    }
}