view sv/filter/Filter.cpp @ 203:74d1b3bda5a3

allow to save and restore the filter settings from an easaier session
author lbajardsilogic
date Tue, 29 Jan 2008 17:21:42 +0000
parents bb04d9df8b41
children c413e82a4812
line wrap: on
line source
/* -*- c-basic-offset: 4 indent-tabs-mode: nil -*-  vi:set ts=8 sts=4 sw=4: */

/*	Sound Access	
		EASAIER client application.	
		Silogic 2007. Laure Bajard. 
	
	This program is free software; you can redistribute it and/or    
	modify it under the terms of the GNU General Public License as    
	published by the Free Software Foundation; either version 2 of the    
	License, or (at your option) any later version.  See the file    
	COPYING included with this distribution for more information.
*/
 
#include "Filter.h"

Filter::Filter() : PropertyContainer(),
	m_sourceChannelCount(0),
	filterEnabled(false)
{}

Filter::~Filter()
{}

bool Filter::isFilterEnabled() const {
	return filterEnabled;
}


void Filter::setFilterEnabled(bool b){
	filterEnabled=b;
}

void Filter::setFilterEnabled(int b){
	filterEnabled=(bool)b;
	
}

QString Filter::toEasaierXmlString(QString indent, QString extraAttributes) const
{
    QString s;

	int enable = isFilterEnabled();
	s += indent + QString("<filter name=\"%1\" enable=\"%2\" ").arg(objectName()).arg(enable);

	PropertyContainer::PropertyList propertyList = getProperties();
	for(int i=0; i< ((int) propertyList.size());i++)
	{
		int min, max, deflt;
		int value = getPropertyRangeAndValue(propertyList[i], &min, &max, &deflt);
		s += propertyList[i] + QString("=\"%1\" ").arg(value);
	}

	s += QString(" %1 />\n").arg(extraAttributes);

    return s;
}

void Filter::setProperties(const QXmlAttributes &attributes)
{
	int enable = attributes.value("enable").toInt();
	setFilterEnabled(enable);
	emit filterEnableChange(enable);

	PropertyContainer::PropertyList propertyList = getProperties();
	int value;
	for(int i=0; i< ((int) propertyList.size());i++)
	{
		 value = attributes.value(propertyList[i]).toInt(); 
		 setProperty(propertyList[i], value);
	}

	emit propertiesChanged(this);
}