From 0c8ed6c9a4000af8f48581a81c4b5c2f5b9fd502 Mon Sep 17 00:00:00 2001 From: Michele Calgaro Date: Sun, 13 Oct 2024 11:56:14 +0900 Subject: Rearrange folders structure to remove unnecessary 'krecipes' second level subfolder Signed-off-by: Michele Calgaro --- src/importers/mxpimporter.cpp | 382 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 382 insertions(+) create mode 100644 src/importers/mxpimporter.cpp (limited to 'src/importers/mxpimporter.cpp') diff --git a/src/importers/mxpimporter.cpp b/src/importers/mxpimporter.cpp new file mode 100644 index 0000000..20fbf0f --- /dev/null +++ b/src/importers/mxpimporter.cpp @@ -0,0 +1,382 @@ +/*************************************************************************** +* Copyright (C) 2003 by * +* Jason Kivlighn (jkivlighn@gmail.com) * +* * +* 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. * +***************************************************************************/ + +#include "mxpimporter.h" + +#include +#include +#include +#include + +#include +#include +#include + +#include "datablocks/mixednumber.h" +#include "datablocks/recipe.h" + +MXPImporter::MXPImporter() : BaseImporter() +{} + +void MXPImporter::parseFile( const TQString &file ) +{ + TQFile input( file ); + + if ( input.open( IO_ReadOnly ) ) { + TQTextStream stream( &input ); + stream.skipWhiteSpace(); + + TQString line; + while ( !stream.atEnd() ) { + line = stream.readLine().stripWhiteSpace(); + + if ( line.simplifyWhiteSpace().contains( "Exported from MasterCook" ) ) { + importMXP( stream ); + } + else if ( line == "{ Exported from MasterCook Mac }" ) { + importMac( stream ); + } + else if ( line == "@@@@@" ) { + importGeneric( stream ); + } + + stream.skipWhiteSpace(); + } + + if ( fileRecipeCount() == 0 ) + addWarningMsg( i18n( "No recipes found in this file." ) ); + } + else + setErrorMsg( i18n( "Unable to open file." ) ); +} + +MXPImporter::~MXPImporter() +{} + +void MXPImporter::importMXP( TQTextStream &stream ) +{ + Recipe recipe; + + kapp->processEvents(); //don't want the user to think its frozen... especially for files with thousands of recipes + + //kdDebug()<<"Found recipe MXP format: * Exported from MasterCook *"<