summaryrefslogtreecommitdiffabout
path: root/kabc/address.h
Unidiff
Diffstat (limited to 'kabc/address.h') (more/less context) (ignore whitespace changes)
-rw-r--r--kabc/address.h1
1 files changed, 1 insertions, 0 deletions
diff --git a/kabc/address.h b/kabc/address.h
index ad132a7..6b53c7e 100644
--- a/kabc/address.h
+++ b/kabc/address.h
@@ -1,346 +1,347 @@
1/* 1/*
2 This file is part of libkabc. 2 This file is part of libkabc.
3 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> 3 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org>
4 4
5 This library is free software; you can redistribute it and/or 5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Library General Public 6 modify it under the terms of the GNU Library General Public
7 License as published by the Free Software Foundation; either 7 License as published by the Free Software Foundation; either
8 version 2 of the License, or (at your option) any later version. 8 version 2 of the License, or (at your option) any later version.
9 9
10 This library is distributed in the hope that it will be useful, 10 This library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Library General Public License for more details. 13 Library General Public License for more details.
14 14
15 You should have received a copy of the GNU Library General Public License 15 You should have received a copy of the GNU Library General Public License
16 along with this library; see the file COPYING.LIB. If not, write to 16 along with this library; see the file COPYING.LIB. If not, write to
17 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 17 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 Boston, MA 02111-1307, USA. 18 Boston, MA 02111-1307, USA.
19*/ 19*/
20 20
21/* 21/*
22Enhanced Version of the file for platform independent KDE tools. 22Enhanced Version of the file for platform independent KDE tools.
23Copyright (c) 2004 Ulf Schenk 23Copyright (c) 2004 Ulf Schenk
24 24
25$Id$ 25$Id$
26*/ 26*/
27 27
28#ifndef KABC_ADDRESS_H 28#ifndef KABC_ADDRESS_H
29#define KABC_ADDRESS_H 29#define KABC_ADDRESS_H
30 30
31#include <qmap.h> 31#include <qmap.h>
32#include <qstring.h> 32#include <qstring.h>
33#include <qvaluelist.h> 33#include <qvaluelist.h>
34 34
35// template tags for address formatting localization 35// template tags for address formatting localization
36#define KABC_FMTTAG_realname QString("%n") 36#define KABC_FMTTAG_realname QString("%n")
37#define KABC_FMTTAG_REALNAME QString("%N") 37#define KABC_FMTTAG_REALNAME QString("%N")
38#define KABC_FMTTAG_company QString("%cm") 38#define KABC_FMTTAG_company QString("%cm")
39#define KABC_FMTTAG_COMPANY QString("%CM") 39#define KABC_FMTTAG_COMPANY QString("%CM")
40#define KABC_FMTTAG_pobox QString("%p") 40#define KABC_FMTTAG_pobox QString("%p")
41#define KABC_FMTTAG_street QString("%s") 41#define KABC_FMTTAG_street QString("%s")
42#define KABC_FMTTAG_STREET QString("%S") 42#define KABC_FMTTAG_STREET QString("%S")
43#define KABC_FMTTAG_zipcode QString("%z") 43#define KABC_FMTTAG_zipcode QString("%z")
44#define KABC_FMTTAG_location QString("%l") 44#define KABC_FMTTAG_location QString("%l")
45#define KABC_FMTTAG_LOCATION QString("%L") 45#define KABC_FMTTAG_LOCATION QString("%L")
46#define KABC_FMTTAG_region QString("%r") 46#define KABC_FMTTAG_region QString("%r")
47#define KABC_FMTTAG_REGION QString("%R") 47#define KABC_FMTTAG_REGION QString("%R")
48#define KABC_FMTTAG_newline QString("\\n") 48#define KABC_FMTTAG_newline QString("\\n")
49#define KABC_FMTTAG_condcomma QString("%,") 49#define KABC_FMTTAG_condcomma QString("%,")
50#define KABC_FMTTAG_condwhite QString("%w") 50#define KABC_FMTTAG_condwhite QString("%w")
51#define KABC_FMTTAG_purgeempty QString("%0") 51#define KABC_FMTTAG_purgeempty QString("%0")
52 52
53namespace KABC { 53namespace KABC {
54 54
55/** 55/**
56 @short Postal address information. 56 @short Postal address information.
57 57
58 This class represents information about a postal address. 58 This class represents information about a postal address.
59*/ 59*/
60class Address 60class Address
61{ 61{
62 friend QDataStream &operator<<( QDataStream &, const Address & ); 62 friend QDataStream &operator<<( QDataStream &, const Address & );
63 friend QDataStream &operator>>( QDataStream &, Address & ); 63 friend QDataStream &operator>>( QDataStream &, Address & );
64 64
65 public: 65 public:
66 /** 66 /**
67 List of addresses. 67 List of addresses.
68 */ 68 */
69 typedef QValueList<Address> List; 69 typedef QValueList<Address> List;
70 typedef QValueList<int> TypeList; 70 typedef QValueList<int> TypeList;
71 71
72 /** 72 /**
73 Address types: 73 Address types:
74 74
75 @li @p Dom - domestic 75 @li @p Dom - domestic
76 @li @p Intl - international 76 @li @p Intl - international
77 @li @p Postal - postal 77 @li @p Postal - postal
78 @li @p Parcel - parcel 78 @li @p Parcel - parcel
79 @li @p Home - home address 79 @li @p Home - home address
80 @li @p Work - address at work 80 @li @p Work - address at work
81 @li @p Pref - preferred address 81 @li @p Pref - preferred address
82 */ 82 */
83 enum Type { Dom = 1, Intl = 2, Postal = 4, Parcel = 8, Home = 16, Work = 32, 83 enum Type { Dom = 1, Intl = 2, Postal = 4, Parcel = 8, Home = 16, Work = 32,
84 Pref = 64 }; 84 Pref = 64 };
85 85
86 /** 86 /**
87 Constructor that creates an empty Address, which is initialized 87 Constructor that creates an empty Address, which is initialized
88 with a unique id (see @ref id()). 88 with a unique id (see @ref id()).
89 */ 89 */
90 Address(); 90 Address();
91 91
92 /** 92 /**
93 This is like @ref Address() just above, with the difference 93 This is like @ref Address() just above, with the difference
94 that you can specify the type. 94 that you can specify the type.
95 */ 95 */
96 Address( int ); 96 Address( int );
97 97
98 bool operator==( const Address & ) const; 98 bool operator==( const Address & ) const;
99 bool operator!=( const Address & ) const; 99 bool operator!=( const Address & ) const;
100 100
101 /** 101 /**
102 Returns true, if the address is empty. 102 Returns true, if the address is empty.
103 */ 103 */
104 bool isEmpty() const; 104 bool isEmpty() const;
105 105
106 /** 106 /**
107 Clears all entries of the address. 107 Clears all entries of the address.
108 */ 108 */
109 void clear(); 109 void clear();
110 QStringList asList();
110 111
111 /** 112 /**
112 Sets the unique id. 113 Sets the unique id.
113 */ 114 */
114 void setId( const QString & ); 115 void setId( const QString & );
115 116
116 /* 117 /*
117 Returns the unique id. 118 Returns the unique id.
118 */ 119 */
119 QString id() const; 120 QString id() const;
120 121
121 /** 122 /**
122 Sets the type of address. See enum for definiton of types. 123 Sets the type of address. See enum for definiton of types.
123 124
124 @param type type, can be a bitwise or of multiple types. 125 @param type type, can be a bitwise or of multiple types.
125 */ 126 */
126 void setType( int type ); 127 void setType( int type );
127 128
128 /** 129 /**
129 Returns the type of address. Can be a bitwise or of multiple types. 130 Returns the type of address. Can be a bitwise or of multiple types.
130 */ 131 */
131 int type() const; 132 int type() const;
132 133
133 /** 134 /**
134 Returns a translated string of all types the address has. 135 Returns a translated string of all types the address has.
135 */ 136 */
136 QString typeLabel() const; 137 QString typeLabel() const;
137 138
138 /** 139 /**
139 Sets the post office box. 140 Sets the post office box.
140 */ 141 */
141 void setPostOfficeBox( const QString & ); 142 void setPostOfficeBox( const QString & );
142 143
143 /** 144 /**
144 Returns the post office box. 145 Returns the post office box.
145 */ 146 */
146 QString postOfficeBox() const; 147 QString postOfficeBox() const;
147 148
148 /** 149 /**
149 Returns the translated label for post office box field. 150 Returns the translated label for post office box field.
150 */ 151 */
151 static QString postOfficeBoxLabel(); 152 static QString postOfficeBoxLabel();
152 153
153 /** 154 /**
154 Sets the extended address information. 155 Sets the extended address information.
155 */ 156 */
156 void setExtended( const QString & ); 157 void setExtended( const QString & );
157 158
158 /** 159 /**
159 Returns the extended address information. 160 Returns the extended address information.
160 */ 161 */
161 QString extended() const; 162 QString extended() const;
162 163
163 /** 164 /**
164 Returns the translated label for extended field. 165 Returns the translated label for extended field.
165 */ 166 */
166 static QString extendedLabel(); 167 static QString extendedLabel();
167 168
168 /** 169 /**
169 Sets the street (including number). 170 Sets the street (including number).
170 */ 171 */
171 void setStreet( const QString & ); 172 void setStreet( const QString & );
172 173
173 /** 174 /**
174 Returns the street. 175 Returns the street.
175 */ 176 */
176 QString street() const; 177 QString street() const;
177 178
178 /** 179 /**
179 Returns the translated label for street field. 180 Returns the translated label for street field.
180 */ 181 */
181 static QString streetLabel(); 182 static QString streetLabel();
182 183
183 /** 184 /**
184 Sets the locality, e.g. city. 185 Sets the locality, e.g. city.
185 */ 186 */
186 void setLocality( const QString & ); 187 void setLocality( const QString & );
187 188
188 /** 189 /**
189 Returns the locality. 190 Returns the locality.
190 */ 191 */
191 QString locality() const; 192 QString locality() const;
192 193
193 /** 194 /**
194 Returns the translated label for locality field. 195 Returns the translated label for locality field.
195 */ 196 */
196 static QString localityLabel(); 197 static QString localityLabel();
197 198
198 /** 199 /**
199 Sets the region, e.g. state. 200 Sets the region, e.g. state.
200 */ 201 */
201 void setRegion( const QString & ); 202 void setRegion( const QString & );
202 203
203 /** 204 /**
204 Returns the region. 205 Returns the region.
205 */ 206 */
206 QString region() const; 207 QString region() const;
207 208
208 /** 209 /**
209 Returns the translated label for region field. 210 Returns the translated label for region field.
210 */ 211 */
211 static QString regionLabel(); 212 static QString regionLabel();
212 213
213 /** 214 /**
214 Sets the postal code. 215 Sets the postal code.
215 */ 216 */
216 void setPostalCode( const QString & ); 217 void setPostalCode( const QString & );
217 218
218 /** 219 /**
219 Returns the postal code. 220 Returns the postal code.
220 */ 221 */
221 QString postalCode() const; 222 QString postalCode() const;
222 223
223 /** 224 /**
224 Returns the translated label for postal code field. 225 Returns the translated label for postal code field.
225 */ 226 */
226 static QString postalCodeLabel(); 227 static QString postalCodeLabel();
227 228
228 /** 229 /**
229 Sets the country. 230 Sets the country.
230 */ 231 */
231 void setCountry( const QString & ); 232 void setCountry( const QString & );
232 233
233 /** 234 /**
234 Returns the country. 235 Returns the country.
235 */ 236 */
236 QString country() const; 237 QString country() const;
237 238
238 /** 239 /**
239 Returns the translated label for country field. 240 Returns the translated label for country field.
240 */ 241 */
241 static QString countryLabel(); 242 static QString countryLabel();
242 243
243 /** 244 /**
244 Sets the delivery label. This is the literal text to be used as label. 245 Sets the delivery label. This is the literal text to be used as label.
245 */ 246 */
246 void setLabel( const QString & ); 247 void setLabel( const QString & );
247 248
248 /** 249 /**
249 Returns the delivery label. 250 Returns the delivery label.
250 */ 251 */
251 QString label() const; 252 QString label() const;
252 253
253 /** 254 /**
254 Returns the translated label for delivery label field. 255 Returns the translated label for delivery label field.
255 */ 256 */
256 static QString labelLabel(); 257 static QString labelLabel();
257 258
258 /** 259 /**
259 Returns the list of available types. 260 Returns the list of available types.
260 */ 261 */
261 static TypeList typeList(); 262 static TypeList typeList();
262 263
263 /** 264 /**
264 Returns the translated label for a special type. 265 Returns the translated label for a special type.
265 */ 266 */
266 static QString typeLabel( int type ); 267 static QString typeLabel( int type );
267 268
268 /** 269 /**
269 Used for debug output. 270 Used for debug output.
270 */ 271 */
271 void dump() const; 272 void dump() const;
272 273
273 /** 274 /**
274 Returns this address formatted according to the country-specific 275 Returns this address formatted according to the country-specific
275 address formatting rules. The formatting rules applied depend on 276 address formatting rules. The formatting rules applied depend on
276 either the addresses {@link #country country} field, or (if the 277 either the addresses {@link #country country} field, or (if the
277 latter is empty) on the system country setting. If companyName is 278 latter is empty) on the system country setting. If companyName is
278 provided, an available business address format will be preferred. 279 provided, an available business address format will be preferred.
279 280
280 @param realName the formatted name of the contact 281 @param realName the formatted name of the contact
281 @param orgaName the name of the organization or company 282 @param orgaName the name of the organization or company
282 @return the formatted address (containing newline characters) 283 @return the formatted address (containing newline characters)
283 */ 284 */
284 QString formattedAddress( const QString &realName=QString::null 285 QString formattedAddress( const QString &realName=QString::null
285 , const QString &orgaName=QString::null ) const; 286 , const QString &orgaName=QString::null ) const;
286 287
287 /** 288 /**
288 Returns ISO code for a localized country name. Only localized country 289 Returns ISO code for a localized country name. Only localized country
289 names will be understood. This might be replaced by a KLocale method in 290 names will be understood. This might be replaced by a KLocale method in
290 the future. 291 the future.
291 @param cname name of the country 292 @param cname name of the country
292 @return two digit ISO code 293 @return two digit ISO code
293 */ 294 */
294 static QString countryToISO( const QString &cname ); 295 static QString countryToISO( const QString &cname );
295 296
296 /** 297 /**
297 Returns a localized country name for a ISO code. 298 Returns a localized country name for a ISO code.
298 This might be replaced by a KLocale method in the future. 299 This might be replaced by a KLocale method in the future.
299 @param ISOname two digit ISO code 300 @param ISOname two digit ISO code
300 @return localized name of the country 301 @return localized name of the country
301 @since 3.2 302 @since 3.2
302 */ 303 */
303 static QString ISOtoCountry( const QString &ISOname ); 304 static QString ISOtoCountry( const QString &ISOname );
304 305
305 private: 306 private:
306 /** 307 /**
307 Parses a snippet of an address template 308 Parses a snippet of an address template
308 @param tsection the template string to be parsed 309 @param tsection the template string to be parsed
309 @param result QString reference in which the result will be stored 310 @param result QString reference in which the result will be stored
310 @return true if at least one tag evaluated positively, else false 311 @return true if at least one tag evaluated positively, else false
311 */ 312 */
312 bool parseAddressTemplateSection( const QString &tsection 313 bool parseAddressTemplateSection( const QString &tsection
313 , QString &result 314 , QString &result
314 , const QString &realName 315 , const QString &realName
315 , const QString &orgaName ) const; 316 , const QString &orgaName ) const;
316 317
317 /** 318 /**
318 Finds the balanced closing bracket starting from the opening bracket at 319 Finds the balanced closing bracket starting from the opening bracket at
319 pos in tsection. 320 pos in tsection.
320 @return position of closing bracket, -1 for unbalanced brackets 321 @return position of closing bracket, -1 for unbalanced brackets
321 */ 322 */
322 int findBalancedBracket( const QString &tsection, int pos ) const; 323 int findBalancedBracket( const QString &tsection, int pos ) const;
323 324
324 bool mEmpty; 325 bool mEmpty;
325 326
326 QString mId; 327 QString mId;
327 int mType; 328 int mType;
328 329
329 QString mPostOfficeBox; 330 QString mPostOfficeBox;
330 QString mExtended; 331 QString mExtended;
331 QString mStreet; 332 QString mStreet;
332 QString mLocality; 333 QString mLocality;
333 QString mRegion; 334 QString mRegion;
334 QString mPostalCode; 335 QString mPostalCode;
335 QString mCountry; 336 QString mCountry;
336 QString mLabel; 337 QString mLabel;
337 338
338 static QMap<QString, QString> mISOMap; 339 static QMap<QString, QString> mISOMap;
339}; 340};
340 341
341QDataStream &operator<<( QDataStream &, const Address & ); 342QDataStream &operator<<( QDataStream &, const Address & );
342QDataStream &operator>>( QDataStream &, Address & ); 343QDataStream &operator>>( QDataStream &, Address & );
343 344
344} 345}
345 346
346#endif 347#endif