lbajardsilogic@79: /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */ lbajardsilogic@79: lbajardsilogic@79: /* Sound Access lbajardsilogic@79: EASAIER client application. lbajardsilogic@79: Silogic 2007. Laure Bajard. lbajardsilogic@79: lbajardsilogic@79: This program is free software; you can redistribute it and/or lbajardsilogic@79: modify it under the terms of the GNU General Public License as lbajardsilogic@79: published by the Free Software Foundation; either version 2 of the lbajardsilogic@79: License, or (at your option) any later version. See the file lbajardsilogic@79: COPYING included with this distribution for more information. lbajardsilogic@79: */ lbajardsilogic@79: lbajardsilogic@79: #include "Filter.h" lbajardsilogic@79: lbajardsilogic@223: Filter::Filter() : QObject(), benoitrigolleau@88: m_sourceChannelCount(0), lbajardsilogic@202: filterEnabled(false) lbajardsilogic@79: {} lbajardsilogic@79: lbajardsilogic@79: Filter::~Filter() lbajardsilogic@223: { lbajardsilogic@223: while (!m_filterCollection.empty()) lbajardsilogic@223: { lbajardsilogic@223: std::vector::iterator iter = m_filterCollection.begin(); lbajardsilogic@223: PropertyContainer* filterElt = *(iter); lbajardsilogic@223: if (filterElt) lbajardsilogic@223: { lbajardsilogic@224: emit propertyContainerRemoved(filterElt->objectName()); lbajardsilogic@223: delete filterElt; lbajardsilogic@223: filterElt = 0; lbajardsilogic@223: } lbajardsilogic@223: m_filterCollection.erase(iter); lbajardsilogic@223: } lbajardsilogic@223: } benoitrigolleau@88: lbajardsilogic@203: bool Filter::isFilterEnabled() const { benoitrigolleau@88: return filterEnabled; benoitrigolleau@88: } benoitrigolleau@88: benoitrigolleau@88: benoitrigolleau@88: void Filter::setFilterEnabled(bool b){ benoitrigolleau@88: filterEnabled=b; benoitrigolleau@88: } benoitrigolleau@88: benoitrigolleau@88: void Filter::setFilterEnabled(int b){ lbajardsilogic@203: filterEnabled=(bool)b; lbajardsilogic@203: benoitrigolleau@88: } benoitrigolleau@88: lbajardsilogic@203: QString Filter::toEasaierXmlString(QString indent, QString extraAttributes) const lbajardsilogic@203: { lbajardsilogic@203: QString s; lbajardsilogic@203: lbajardsilogic@225: std::vector::const_iterator iter; lbajardsilogic@225: for (iter=m_filterCollection.begin(); iter!=m_filterCollection.end(); iter++) lbajardsilogic@225: { lbajardsilogic@225: PropertyContainer* filterElt = *(iter); lbajardsilogic@203: lbajardsilogic@225: s += indent + QString("objectName()); lbajardsilogic@225: lbajardsilogic@225: PropertyContainer::PropertyList propertyList = filterElt->getProperties(); lbajardsilogic@225: for(int i=0; i< ((int) propertyList.size());i++) lbajardsilogic@225: { lbajardsilogic@225: int min, max, deflt; lbajardsilogic@225: int value = filterElt->getPropertyRangeAndValue(propertyList[i], &min, &max, &deflt); lbajardsilogic@225: s += propertyList[i] + QString("=\"%1\" ").arg(value); lbajardsilogic@225: } lbajardsilogic@225: lbajardsilogic@225: s += QString(" %1 />\n").arg(extraAttributes); lbajardsilogic@203: } lbajardsilogic@203: lbajardsilogic@203: return s; lbajardsilogic@203: } benoitrigolleau@88: lbajardsilogic@203: void Filter::setProperties(const QXmlAttributes &attributes) lbajardsilogic@203: { lbajardsilogic@225: QString name = attributes.value("name"); lbajardsilogic@225: lbajardsilogic@225: std::vector::const_iterator iter; lbajardsilogic@225: for (iter=m_filterCollection.begin(); iter!=m_filterCollection.end(); iter++) lbajardsilogic@225: { lbajardsilogic@225: PropertyContainer* filterElt = *(iter); lbajardsilogic@203: lbajardsilogic@225: if (filterElt->objectName() == name) lbajardsilogic@225: { lbajardsilogic@225: PropertyContainer::PropertyList propertyList = filterElt->getProperties(); lbajardsilogic@225: int value; lbajardsilogic@225: for(int i=0; i< ((int) propertyList.size());i++) lbajardsilogic@225: { lbajardsilogic@225: value = attributes.value(propertyList[i]).toInt(); lbajardsilogic@225: filterElt->setProperty(propertyList[i], value); lbajardsilogic@225: } lbajardsilogic@225: filterElt->emitPropertiesChanged(); lbajardsilogic@225: } lbajardsilogic@203: } lbajardsilogic@203: }