• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • kdepimlibs API Reference
  • KDE Home
  • Contact Us
 

KTNEF Library

  • sources
  • kde-4.12
  • kdepimlibs
  • ktnef
ktnefproperty.cpp
Go to the documentation of this file.
1 /*
2  ktnefproperty.cpp
3 
4  Copyright (C) 2002 Michael Goffioul <kdeprint@swing.be>
5 
6  This file is part of KTNEF, the KDE TNEF support library/program.
7 
8  This library is free software; you can redistribute it and/or
9  modify it under the terms of the GNU Library General Public
10  License as published by the Free Software Foundation; either
11  version 2 of the License, or (at your option) any later version.
12 
13  This library is distributed in the hope that it will be useful,
14  but WITHOUT ANY WARRANTY; without even the implied warranty of
15  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16  Library General Public License for more details.
17 
18  You should have received a copy of the GNU Library General Public License
19  along with this library; see the file COPYING.LIB. If not, write to
20  the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
21  Boston, MA 02110-1301, USA.
22  */
31 #include "ktnefproperty.h"
32 #include "mapi.h"
33 
34 #include <QtCore/QDateTime>
35 
36 #include <ctype.h>
37 
38 using namespace KTnef;
39 
40 class KTNEFProperty::Private
41 {
42  public:
43  int _key;
44  int _type;
45  QVariant _value;
46  QVariant _name;
47 };
48 
49 KTNEFProperty::KTNEFProperty()
50  : d( new Private )
51 {
52 }
53 
54 KTNEFProperty::KTNEFProperty( int key_, int type_, const QVariant &value_,
55  const QVariant &name_ )
56  : d( new Private )
57 {
58  d->_key = key_;
59  d->_type = type_;
60  d->_value = value_;
61  d->_name = name_;
62 }
63 
64 KTNEFProperty::KTNEFProperty( const KTNEFProperty &p )
65  : d( new Private )
66 {
67  *d = *p.d;
68 }
69 
70 KTNEFProperty::~KTNEFProperty()
71 {
72  delete d;
73 }
74 
75 KTNEFProperty &KTNEFProperty::operator=( const KTNEFProperty &other )
76 {
77  if ( this != &other ) {
78  *d = *other.d;
79  }
80 
81  return *this;
82 }
83 
84 QString KTNEFProperty::keyString() const
85 {
86  if ( d->_name.isValid() ) {
87  if ( d->_name.type() == QVariant::String ) {
88  return d->_name.toString();
89  } else {
90  return mapiNamedTagString( d->_name.toUInt(), d->_key );
91  }
92  } else {
93  return mapiTagString( d->_key );
94  }
95 }
96 
97 QString KTNEFProperty::formatValue( const QVariant &value, bool beautify )
98 {
99  if ( value.type() == QVariant::ByteArray ) {
100  // check the first bytes (up to 8) if they are
101  // printable characters
102  QByteArray arr = value.toByteArray();
103  bool printable = true;
104  for ( int i=qMin( arr.size(), 8 )-1; i>=0 && printable; i-- ) {
105  printable = ( isprint( arr[ i ] ) != 0 );
106  }
107  if ( !printable ) {
108  QString s;
109  int i;
110  int txtCount = beautify ? qMin( arr.size(), 32 ) : arr.size();
111  for ( i=0; i < txtCount; ++i ) {
112  s.append( QString().sprintf( "%02X", ( uchar )arr[ i ] ) );
113  if ( beautify ) {
114  s.append( " " );
115  }
116  }
117  if ( i < arr.size() ) {
118  s.append( "... (size=" + QString::number( arr.size() ) + ')' );
119  }
120  return s;
121  }
122  }
123  //else if ( value.type() == QVariant::DateTime )
124  // return value.toDateTime().toString();
125  return value.toString();
126 }
127 
128 QString KTNEFProperty::valueString() const
129 {
130  return formatValue( d->_value );
131 }
132 
133 int KTNEFProperty::key() const
134 {
135  return d->_key;
136 }
137 
138 int KTNEFProperty::type() const
139 {
140  return d->_type;
141 }
142 
143 QVariant KTNEFProperty::value() const
144 {
145  return d->_value;
146 }
147 
148 QVariant KTNEFProperty::name() const
149 {
150  return d->_name;
151 }
152 
153 bool KTNEFProperty::isVector() const
154 {
155  return d->_value.type() == QVariant::List;
156 }
KTnef::KTNEFProperty::KTNEFProperty
KTNEFProperty()
Constructs a TNEF property.
Definition: ktnefproperty.cpp:49
KTnef::KTNEFProperty::key
int key() const
Returns the integer key of the property.
Definition: ktnefproperty.cpp:133
mapiNamedTagString
QString mapiNamedTagString(int key, int tag)
Convert a keycode to a MAPI named tag string.
Definition: mapi.cpp:224
KTnef::KTNEFProperty::type
int type() const
Returns the integer type of the property.
Definition: ktnefproperty.cpp:138
KTnef::KTNEFProperty::~KTNEFProperty
~KTNEFProperty()
Destroys the property.
Definition: ktnefproperty.cpp:70
KTnef::KTNEFProperty::valueString
QString valueString() const
Returns the value string of the property.
Definition: ktnefproperty.cpp:128
KTnef::KTNEFProperty::value
QVariant value() const
Returns the value of the property.
Definition: ktnefproperty.cpp:143
KTnef::KTNEFProperty::isVector
bool isVector() const
Determines if the property is a vector type.
Definition: ktnefproperty.cpp:153
mapi.h
This file is part of the API for handling TNEF data and provides functions that convert MAPI keycodes...
ktnefproperty.h
This file is part of the API for handling TNEF data and defines the KTNEFProperty class...
KTnef::KTNEFProperty::formatValue
static QString formatValue(const QVariant &v, bool beautify=true)
Creates a formatted string from the value of the property.
Definition: ktnefproperty.cpp:97
KTnef::KTNEFProperty::name
QVariant name() const
Returns the name of the property.
Definition: ktnefproperty.cpp:148
mapiTagString
QString mapiTagString(int key)
Convert a keycode to a MAPI tag string.
Definition: mapi.cpp:208
KTnef::KTNEFProperty
Interface for setting MAPI properties.
Definition: ktnefproperty.h:44
KTnef::KTNEFProperty::keyString
QString keyString() const
Returns the key string of the property.
Definition: ktnefproperty.cpp:84
This file is part of the KDE documentation.
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 23:01:10 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

KTNEF Library

Skip menu "KTNEF Library"
  • Main Page
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members
  • Related Pages

kdepimlibs API Reference

Skip menu "kdepimlibs API Reference"
  • akonadi
  •   contact
  •   kmime
  •   socialutils
  • kabc
  • kalarmcal
  • kblog
  • kcal
  • kcalcore
  • kcalutils
  • kholidays
  • kimap
  • kldap
  • kmbox
  • kmime
  • kpimidentities
  • kpimtextedit
  • kresources
  • ktnef
  • kxmlrpcclient
  • microblog

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal