void KrecipesView::printRequested()
{
	QWidget * vis_panel = rightPanel->visiblePanel();
	if ( vis_panel == viewPanel ) {
		//Create the temporary directory.
		m_tempdir = new KTempDir(KStandardDirs::locateLocal("tmp", "krecipes-data-print"));
		QString tmp_filename = m_tempdir->name() + "krecipes_recipe_view.html";
		//Export to HTML in the temporary directory.
		XSLTExporter html_generator( tmp_filename, "html" );
		KConfigGroup config(KGlobal::config(), "Page Setup" );
		QString styleFile = config.readEntry( "PrintLayout", KStandardDirs::locate( "appdata", "layouts/None.klo" ) );
		if ( !styleFile.isEmpty() && QFile::exists( styleFile ) )
			html_generator.setStyle( styleFile );

		QString templateFile = config.readEntry( "PrintTemplate", KStandardDirs::locate( "appdata", "layouts/Default.xsl" ) );
		if ( !templateFile.isEmpty() && QFile::exists( templateFile ) )
			html_generator.setTemplate( templateFile );
		html_generator.exporter( viewPanel->currentRecipes(), database );
		//Load the generated HTML. When loaded, KrecipesView::print(...) will be called.
		m_printPage = new KWebPage;
		connect(m_printPage, SIGNAL(loadFinished(bool)), this, SLOT(print(bool)));
		m_printPage->mainFrame()->load( KUrl(tmp_filename) );
	}
}
void KrecipesView::printRequested()
{
	QWidget * vis_panel = rightPanel->visiblePanel();
	if ( vis_panel == viewPanel ) {
		 
		m_tempdir = new KTempDir(KStandardDirs::locateLocal("tmp", "krecipes-data-print"));
		QString tmp_filename = m_tempdir->name() + "krecipes_recipe_view.html";
		 
		XSLTExporter html_generator( tmp_filename, "html" );
		KConfigGroup config(KGlobal::config(), "Page Setup" );
		QString styleFile = config.readEntry( "PrintLayout", KStandardDirs::locate( "appdata", "layouts/None.klo" ) );
		if ( !styleFile.isEmpty() && QFile::exists( styleFile ) )
			html_generator.setStyle( styleFile );

		QString templateFile = config.readEntry( "PrintTemplate", KStandardDirs::locate( "appdata", "layouts/Default.xsl" ) );
		if ( !templateFile.isEmpty() && QFile::exists( templateFile ) )
			html_generator.setTemplate( templateFile );
		html_generator.exporter( viewPanel->currentRecipes(), database );
		 
		m_printPage = new KWebPage;
		connect(m_printPage, SIGNAL(loadFinished(bool)), this, SLOT(print(bool)));
		m_printPage->mainFrame()->load( KUrl(tmp_filename) );
	}
}