1/*
2 ktnefpropertyset.h
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 */
23/**
24 * @file
25 * This file is part of the API for handling TNEF data and
26 * defines the KTNEFPropertySet class.
27 *
28 * @author Michael Goffioul
29 */
30
31#ifndef KTNEFPROPERTYSET_H
32#define KTNEFPROPERTYSET_H
33
34#include <QtCore/QMap>
35#include <QtCore/QVariant>
36#include "ktnef_export.h"
37
38namespace KTnef {
39 class KTNEFProperty;
40}
41
42namespace KTnef {
43
44/**
45 * @brief
46 * Interface for setting @acronym MAPI properties and @acronym TNEF attributes.
47 */
48class KTNEF_EXPORT KTNEFPropertySet
49{
50 public:
51 /**
52 Constructor.
53 */
54 KTNEFPropertySet();
55
56 /**
57 Destructor.
58 */
59 ~KTNEFPropertySet();
60
61 /**
62 Adds a @acronym MAPI property.
63
64 @param key is the property key.
65 @param type is the property type.
66 @param value is the property value.
67 @param name is the property name.
68 @param overwrite if true, then remove the property if it already exists.
69 */
70 void addProperty( int key, int type, const QVariant &value,
71 const QVariant &name=QVariant(), bool overwrite=false );
72
73 /**
74 Finds a property by @p key, returning a formatted value.
75
76 @param key is the property key.
77 @param fallback is the fallback formatted value to use if the @p key
78 is not found.
79 @param convertToUpper if true, then return the formatted value in all
80 upper case characters.
81
82 @return a formatted value string.
83 */
84 QString findProp( int key, const QString &fallback=QString(),
85 bool convertToUpper=false ) const;
86
87 /**
88 Finds a property by @p name, returning a formatted value.
89
90 @param name is the property name.
91 @param fallback is the fallback formatted value to use if the @p name
92 is not found.
93 @param convertToUpper if true, then return the formatted value in all
94 upper case characters.
95
96 @return a formatted value string.
97 */
98 QString findNamedProp( const QString &name,
99 const QString &fallback=QString(),
100 bool convertToUpper=false ) const;
101
102 /**
103 Returns a #QMap of all (key,@acronym MAPI) properties
104 */
105 QMap<int,KTNEFProperty*>& properties();
106
107 /**
108 Returns a #QMap of all (key,@acronym MAPI) properties
109 */
110 const QMap<int,KTNEFProperty*>& properties() const; //krazy:exclude=constref
111
112 /**
113 Returns the property associcated with the specified @p key.
114
115 @param key is the property key.
116
117 @return the property.q
118 */
119 QVariant property( int key ) const;
120
121 /**
122 Adds a @acronym TNEF attribute.
123
124 @param key is the attribute key.
125 @param type is the attribute type.
126 @param value is the attribute value.
127 @param overwrite if true, then remove the attribute if it already exists.
128 */
129 void addAttribute( int key, int type, const QVariant &value,
130 bool overwrite=false );
131
132 /**
133 Returns a #QMap of all (key,@acronym TNEF) attributes.
134 */
135 QMap<int,KTNEFProperty*>& attributes();
136
137 /**
138 Returns a #QMap of all (key,@acronym TNEF) attributes.
139 */
140 const QMap<int,KTNEFProperty*>& attributes() const; //krazy:exclude=constref
141
142 /**
143 Returns the attribute associcated with the specified @p key.
144
145 @param key is the @acronym TNEF key.
146
147 @return the attribute associated with the key.
148 */
149 QVariant attribute( int key ) const;
150
151 /**
152 Clears the @acronym MAPI and @acronym TNEF maps.
153
154 @param deleteAll if true, delete the map memory as well.
155 */
156 void clear( bool deleteAll=false );
157
158 private:
159 //@cond PRIVATE
160 class Private;
161 Private *const d;
162 //@endcond
163
164 Q_DISABLE_COPY( KTNEFPropertySet )
165};
166
167}
168#endif
169