/* -*- indent-tabs-mode: nil; -*-
 *
 * This file is part of the Mango recipe management distribution.
 * Copyright (c) 2000, Roland Jesse
 * All rights reserved.
 *
 * For license and copyright information see the file COPYRIGHT or 
 * <http://www.opensource.org/licenses/bsd-license.html>.
 *
 * $Id: Exporter.cpp,v 1.9 2003/01/05 16:35:24 rjesse Exp $
 */

#include "Exporter.h"
#include "Repository.h"
#include <qfileinfo.h>

/*!
  Make sure to set something to export via setCookbook() or setRecipe()
  before using apply().
*/
Exporter::Exporter()
{
}

Exporter::Exporter( RecipeModel* model)
{
   setCookbook( model);
}

Exporter::Exporter( const Recipe& recipe)
{
   setRecipe( recipe);
}

Exporter::~Exporter()
{
}

/*!
  Return all file extension associated with recipe formats that can currently be
  exported.
  
  The string is complete and ready to be used in file dialogs.
*/
QString
Exporter::getSupportedFileExtensions()
{
   QString str( "Recipes (*.mm *.RecipeML *.xml)");
   return str;
}

void
Exporter::setFileName( const QString& fname)
{
   m_fname = fname;
   QFileInfo finfo( fname);
   QString dir( finfo.dirPath());
   Repository::getInstance()->setDefaultPath( "ExportDirectory", dir);

}

void
Exporter::setCookbook( RecipeModel* cookbook)
{
   m_cookbook = cookbook;
   m_type = COOKBOOK;
}

void
Exporter::setRecipe( const Recipe& recipe)
{
   m_recipe = recipe;
   m_type = RECIPE;
}
