diff options
author | toma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2009-11-25 17:56:58 +0000 |
---|---|---|
committer | toma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2009-11-25 17:56:58 +0000 |
commit | 47d455dd55be855e4cc691c32f687f723d9247ee (patch) | |
tree | 52e236aaa2576bdb3840ebede26619692fed6d7d /kpovmodeler/pmserializer.cpp | |
download | tdegraphics-47d455dd55be855e4cc691c32f687f723d9247ee.tar.gz tdegraphics-47d455dd55be855e4cc691c32f687f723d9247ee.zip |
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
Diffstat (limited to 'kpovmodeler/pmserializer.cpp')
-rw-r--r-- | kpovmodeler/pmserializer.cpp | 93 |
1 files changed, 93 insertions, 0 deletions
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 : [email protected] +************************************************************************** + +************************************************************************** +* * +* 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 <klocale.h> + +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++; + } +} |