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

KTNEF Library

  • 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
38using namespace KTnef;
39
40class KTNEFProperty::Private
41{
42 public:
43 int _key;
44 int _type;
45 QVariant _value;
46 QVariant _name;
47};
48
49KTNEFProperty::KTNEFProperty()
50 : d( new Private )
51{
52}
53
54KTNEFProperty::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
64KTNEFProperty::KTNEFProperty( const KTNEFProperty &p )
65 : d( new Private )
66{
67 *d = *p.d;
68}
69
70KTNEFProperty::~KTNEFProperty()
71{
72 delete d;
73}
74
75KTNEFProperty &KTNEFProperty::operator=( const KTNEFProperty &other )
76{
77 if ( this != &other ) {
78 *d = *other.d;
79 }
80
81 return *this;
82}
83
84QString 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
97QString 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
128QString KTNEFProperty::valueString() const
129{
130 return formatValue( d->_value );
131}
132
133int KTNEFProperty::key() const
134{
135 return d->_key;
136}
137
138int KTNEFProperty::type() const
139{
140 return d->_type;
141}
142
143QVariant KTNEFProperty::value() const
144{
145 return d->_value;
146}
147
148QVariant KTNEFProperty::name() const
149{
150 return d->_name;
151}
152
153bool KTNEFProperty::isVector() const
154{
155 return d->_value.type() == QVariant::List;
156}
KTnef::KTNEFProperty
Interface for setting MAPI properties.
Definition ktnefproperty.h:45
KTnef::KTNEFProperty::type
int type() const
Returns the integer type of the property.
Definition ktnefproperty.cpp:138
KTnef::KTNEFProperty::valueString
QString valueString() const
Returns the value string of the property.
Definition ktnefproperty.cpp:128
KTnef::KTNEFProperty::key
int key() const
Returns the integer key of the property.
Definition ktnefproperty.cpp:133
KTnef::KTNEFProperty::isVector
bool isVector() const
Determines if the property is a vector type.
Definition ktnefproperty.cpp:153
KTnef::KTNEFProperty::name
QVariant name() const
Returns the name of the property.
Definition ktnefproperty.cpp:148
KTnef::KTNEFProperty::value
QVariant value() const
Returns the value of the property.
Definition ktnefproperty.cpp:143
KTnef::KTNEFProperty::KTNEFProperty
KTNEFProperty()
Constructs a TNEF property.
Definition ktnefproperty.cpp:49
KTnef::KTNEFProperty::~KTNEFProperty
~KTNEFProperty()
Destroys the property.
Definition ktnefproperty.cpp:70
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::keyString
QString keyString() const
Returns the key string of the property.
Definition ktnefproperty.cpp:84
ktnefproperty.h
This file is part of the API for handling TNEF data and defines the KTNEFProperty class.
mapiTagString
QString mapiTagString(int key)
Convert a keycode to a MAPI tag string.
Definition mapi.cpp:207
mapiNamedTagString
QString mapiNamedTagString(int key, int tag)
Convert a keycode to a MAPI named tag string.
Definition mapi.cpp:223
mapi.h
This file is part of the API for handling TNEF data and provides functions that convert MAPI keycodes...
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Wed Jan 24 2024 00:00:00 by doxygen 1.10.0 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-4.14.10 API Reference

Skip menu "kdepimlibs-4.14.10 API Reference"
  • akonadi
  •   contact
  •   kmime
  •   socialutils
  • kabc
  • kalarmcal
  • kblog
  • kcal
  • kcalcore
  • kcalutils
  • kholidays
  • kimap
  • kioslave
  •   imap4
  •   mbox
  •   nntp
  • kldap
  • kmbox
  • kmime
  • kontactinterface
  • kpimidentities
  • kpimtextedit
  • kpimutils
  • kresources
  • ktnef
  • kxmlrpcclient
  • mailtransport
  • microblog
  • qgpgme
  • syndication
  •   atom
  •   rdf
  •   rss2
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