From 47d455dd55be855e4cc691c32f687f723d9247ee Mon Sep 17 00:00:00 2001 From: toma Date: Wed, 25 Nov 2009 17:56:58 +0000 Subject: Copy the KDE 3.5 branch to branches/trinity for new KDE 3.5 features. BUG:215923 git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdegraphics@1054174 283d02a7-25f6-0310-bc7c-ecb5cbfe19da --- kpovmodeler/pmserializer.cpp | 93 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 93 insertions(+) create mode 100644 kpovmodeler/pmserializer.cpp (limited to 'kpovmodeler/pmserializer.cpp') diff --git a/kpovmodeler/pmserializer.cpp b/kpovmodeler/pmserializer.cpp new file mode 100644 index 00000000..087631cc --- /dev/null +++ b/kpovmodeler/pmserializer.cpp @@ -0,0 +1,93 @@ +/* +************************************************************************** + description + -------------------- + copyright : (C) 2003 by Andreas Zehender + email : zehender@kde.org +************************************************************************** + +************************************************************************** +* * +* 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 "pmserializer.h" +#include "pmerrorflags.h" +#include "pmdebug.h" + +#include + +unsigned int PMSerializer::s_maxErrors = 30; +unsigned int PMSerializer::s_maxWarnings = 50; + + +PMSerializer::PMSerializer( QIODevice* dev ) +{ + m_pDev = dev; + m_errors = 0; + m_warnings = 0; + m_bFatalError = false; +} + +PMSerializer::~PMSerializer( ) +{ + +} + +void PMSerializer::serializeList( const PMObjectList& objects ) +{ + PMObjectListIterator it( objects ); + for( ; it.current( ); ++it ) + serialize( it.current( ) ); +} + +int PMSerializer::errorFlags( ) const +{ + int result = 0; + if( errors( ) ) + result |= PMEError; + if( warnings( ) ) + result |= PMEWarning; + if( fatal( ) ) + result |= PMEFatal; + return result; +} + +void PMSerializer::printMessage( const QString& type, const QString& msg ) +{ + m_messages += PMMessage( type + ": " + msg ); +} + +void PMSerializer::printError( const QString& msg ) +{ + if( m_errors < s_maxErrors ) + { + printMessage( i18n( "Error" ), msg ); + m_errors++; + } + else if( m_errors == s_maxErrors ) + { + m_messages += PMMessage( i18n( "Maximum of %1 errors reached." ) + .arg( s_maxErrors ) ); + m_errors++; + } +} + +void PMSerializer::printWarning( const QString& msg ) +{ + if( m_warnings < s_maxWarnings ) + { + printMessage( i18n( "Warning" ), msg ); + m_warnings++; + } + else if( m_warnings == s_maxWarnings ) + { + m_messages += PMMessage( i18n( "Maximum of %1 warnings reached." ) + .arg( s_maxWarnings ) ); + m_warnings++; + } +} -- cgit v1.2.1