// This file is generated by kxml_compiler from kde-features.xsd.
// All changes you do to this file will be lost.
/*
    This file is part of KDE.

    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.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program; if not, write to the Free Software
    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
    USA.

    As a special exception, permission is given to link this program
    with any edition of Qt, and distribute the resulting executable,
    without including the source code for Qt in the source distribution.
 */

#include "kde-features.h"

#include <kdebug.h>
#include <QTextStream>
#include <QFile>
#include <QTextStream>

QString indent( int n = 0 )
{
  static int i = 0;
  i += n;
  QString space;
  return space.fill( ' ', i );
}

void Responsible::setName( const QString &v )
{
  mName = v;
}

QString Responsible::name() const
{
  return mName;
}

void Responsible::setEmail( const QString &v )
{
  mEmail = v;
}

QString Responsible::email() const
{
  return mEmail;
}

QString Responsible::writeElement()
{
  QString xml;
  xml += indent() + "<responsible name=\"" + name() + "\" email=\"" + email() + "\"/>\n";
  return xml;
}


void Feature::setStatus( const QString &v )
{
  mStatus = v;
}

QString Feature::status() const
{
  return mStatus;
}

void Feature::setTarget( const QString &v )
{
  mTarget = v;
}

QString Feature::target() const
{
  return mTarget;
}

void Feature::setSummary( const QString &v )
{
  mSummary = v;
}

QString Feature::summary() const
{
  return mSummary;
}

void Feature::addResponsible( const Responsible &v )
{
  mResponsibleList.append( v );
}

void Feature::setResponsibleList( const Responsible::List &v )
{
  mResponsibleList = v;
}

Responsible::List Feature::responsibleList() const
{
  return mResponsibleList;
}

QString Feature::writeElement()
{
  QString xml;
  xml += indent() + "<feature status=\"" + status() + "\" target=\"" + target() + "\">\n";
  indent( 2 );
  xml += indent() + "<summary>" + summary() + "</summary>\n";
  foreach( Responsible e, responsibleList() ) {
    xml += e.writeElement();
  }
  indent( -2 );
  xml += indent() + "</feature>\n";
  return xml;
}


void Category::setName( const QString &v )
{
  mName = v;
}

QString Category::name() const
{
  return mName;
}

void Category::addFeature( const Feature &v )
{
  mFeatureList.append( v );
}

void Category::setFeatureList( const Feature::List &v )
{
  mFeatureList = v;
}

Feature::List Category::featureList() const
{
  return mFeatureList;
}

void Category::addCategory( const Category &v )
{
  mCategoryList.append( v );
}

void Category::setCategoryList( const Category::List &v )
{
  mCategoryList = v;
}

Category::List Category::categoryList() const
{
  return mCategoryList;
}

QString Category::writeElement()
{
  QString xml;
  xml += indent() + "<category name=\"" + name() + "\">\n";
  indent( 2 );
  foreach( Feature e, featureList() ) {
    xml += e.writeElement();
  }
  foreach( Category e, categoryList() ) {
    xml += e.writeElement();
  }
  indent( -2 );
  xml += indent() + "</category>\n";
  return xml;
}


void Features::addCategory( const Category &v )
{
  mCategoryList.append( v );
}

void Features::setCategoryList( const Category::List &v )
{
  mCategoryList = v;
}

Category::List Features::categoryList() const
{
  return mCategoryList;
}

QString Features::writeElement()
{
  QString xml;
  xml += indent() + "<features>\n";
  indent( 2 );
  foreach( Category e, categoryList() ) {
    xml += e.writeElement();
  }
  indent( -2 );
  xml += indent() + "</features>\n";
  return xml;
}

bool Features::writeFile( const QString &filename )
{
  QFile file( filename );
  if ( !file.open( QIODevice::WriteOnly ) ) {
    kError() << "Unable to open file '" << filename << "'";
    return false;
  }

  QTextStream ts( &file );
  ts << "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n";
  ts << writeElement();
  file.close();

  return true;
}


