summaryrefslogtreecommitdiffstats
path: root/ktnef/lib/ktnefproperty.cpp
diff options
context:
space:
mode:
authortoma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2009-11-25 17:56:58 +0000
committertoma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2009-11-25 17:56:58 +0000
commit460c52653ab0dcca6f19a4f492ed2c5e4e963ab0 (patch)
tree67208f7c145782a7e90b123b982ca78d88cc2c87 /ktnef/lib/ktnefproperty.cpp
downloadtdepim-460c52653ab0dcca6f19a4f492ed2c5e4e963ab0.tar.gz
tdepim-460c52653ab0dcca6f19a4f492ed2c5e4e963ab0.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/kdepim@1054174 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'ktnef/lib/ktnefproperty.cpp')
-rw-r--r--ktnef/lib/ktnefproperty.cpp99
1 files changed, 99 insertions, 0 deletions
diff --git a/ktnef/lib/ktnefproperty.cpp b/ktnef/lib/ktnefproperty.cpp
new file mode 100644
index 000000000..3845b8d88
--- /dev/null
+++ b/ktnef/lib/ktnefproperty.cpp
@@ -0,0 +1,99 @@
+/*
+ ktnefproperty.cpp
+
+ Copyright (C) 2002 Michael Goffioul <kdeprint@swing.be>
+
+ This file is part of KTNEF, the KDE TNEF support library/program.
+
+ 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.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software Foundation,
+ Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
+ */
+
+#include "ktnef/ktnefproperty.h"
+#include "mapi.h"
+#include <qdatetime.h>
+#include <ctype.h>
+
+KTNEFProperty::KTNEFProperty()
+{
+}
+
+KTNEFProperty::KTNEFProperty( int key_, int type_, const QVariant& value_, const QVariant& name_ )
+ : _key( key_ ), _type( type_ ), _value( value_ ), _name( name_ )
+{
+}
+
+KTNEFProperty::KTNEFProperty( const KTNEFProperty& p )
+ : _key( p._key ), _type( p._type ), _value( p._value ), _name( p._name )
+{
+}
+
+QString KTNEFProperty::keyString()
+{
+ if ( _name.isValid() )
+ {
+ if ( _name.type() == QVariant::String )
+ return _name.asString();
+ else
+ return mapiNamedTagString( _name.asUInt(), _key );
+ }
+ else
+ return mapiTagString( _key );
+}
+
+QString KTNEFProperty::formatValue( const QVariant& value, bool beautify )
+{
+ if ( value.type() == QVariant::ByteArray )
+ {
+ // check the first bytes (up to 8) if they are
+ // printable characters
+ QByteArray arr = value.toByteArray();
+ bool printable = true;
+ for ( int i=QMIN( arr.size(), 8 )-1; i>=0 && printable; i-- )
+ printable = ( isprint( arr[ i ] ) != 0 );
+ if ( !printable )
+ {
+ QString s;
+ uint i;
+ uint txtCount = beautify ? QMIN( arr.size(), 32 ) : arr.size();
+ for ( i=0; i < txtCount; ++i )
+ {
+ s.append( QString().sprintf( "%02X", ( uchar )arr[ i ] ) );
+ if( beautify )
+ s.append( " " );
+ }
+ if ( i < arr.size() )
+ s.append( "... (size=" + QString::number( arr.size() ) + ")" );
+ return s;
+ }
+ }
+ //else if ( value.type() == QVariant::DateTime )
+ // return value.toDateTime().toString();
+ return value.toString();
+}
+
+QString KTNEFProperty::valueString()
+{
+ return formatValue( _value );
+}
+
+int KTNEFProperty::key() const
+{ return _key; }
+
+int KTNEFProperty::type() const
+{ return _type; }
+
+QVariant KTNEFProperty::value() const
+{ return _value; }
+
+QVariant KTNEFProperty::name() const
+{ return _name; }
+
+bool KTNEFProperty::isVector() const
+{ return ( _value.type() == QVariant::List ); }