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