author | zautrix <zautrix> | 2004-10-08 20:03:23 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2004-10-08 20:03:23 (UTC) |
commit | 10a0e05cc4962d9412a7a5faf3d69a3caf6d1c34 (patch) (unidiff) | |
tree | 3105b985a9dbedd31dff52e14fe667eeff4f9ff4 /kabc | |
parent | 13bd085e06b76228321f5a004759fcdf19cca711 (diff) | |
download | kdepimpi-10a0e05cc4962d9412a7a5faf3d69a3caf6d1c34.zip kdepimpi-10a0e05cc4962d9412a7a5faf3d69a3caf6d1c34.tar.gz kdepimpi-10a0e05cc4962d9412a7a5faf3d69a3caf6d1c34.tar.bz2 |
added contact phone support
-rw-r--r-- | kabc/addressee.cpp | 32 | ||||
-rw-r--r-- | kabc/addressee.h | 4 | ||||
-rw-r--r-- | kabc/phonenumber.cpp | 23 | ||||
-rw-r--r-- | kabc/phonenumber.h | 2 |
4 files changed, 61 insertions, 0 deletions
diff --git a/kabc/addressee.cpp b/kabc/addressee.cpp index 25c77f6..e571980 100644 --- a/kabc/addressee.cpp +++ b/kabc/addressee.cpp | |||
@@ -222,192 +222,224 @@ void Addressee::computeCsum(const QString &dev) | |||
222 | if ( mData->geo.isValid() ) l.append( mData->geo.asString() ); | 222 | if ( mData->geo.isValid() ) l.append( mData->geo.asString() ); |
223 | if ( !mData->title .isEmpty() ) l.append( mData->title ); | 223 | if ( !mData->title .isEmpty() ) l.append( mData->title ); |
224 | if ( !mData->role.isEmpty() ) l.append( mData->role ); | 224 | if ( !mData->role.isEmpty() ) l.append( mData->role ); |
225 | if ( !mData->organization.isEmpty() ) l.append( mData->organization ); | 225 | if ( !mData->organization.isEmpty() ) l.append( mData->organization ); |
226 | if ( !mData->note.isEmpty() ) l.append( mData->note ); | 226 | if ( !mData->note.isEmpty() ) l.append( mData->note ); |
227 | if ( !mData->productId.isEmpty() ) l.append(mData->productId ); | 227 | if ( !mData->productId.isEmpty() ) l.append(mData->productId ); |
228 | if ( !mData->sortString.isEmpty() ) l.append( mData->sortString ); | 228 | if ( !mData->sortString.isEmpty() ) l.append( mData->sortString ); |
229 | if ( mData->secrecy.isValid() ) l.append( mData->secrecy.asString()); | 229 | if ( mData->secrecy.isValid() ) l.append( mData->secrecy.asString()); |
230 | // if ( !mData->logo.isEmpty() ) l.append( ); | 230 | // if ( !mData->logo.isEmpty() ) l.append( ); |
231 | //if ( !mData->photo.isEmpty() ) l.append( ); | 231 | //if ( !mData->photo.isEmpty() ) l.append( ); |
232 | //if ( !mData->sound.isEmpty() ) l.append( ); | 232 | //if ( !mData->sound.isEmpty() ) l.append( ); |
233 | //if ( !mData->agent.isEmpty() ) l.append( ); | 233 | //if ( !mData->agent.isEmpty() ) l.append( ); |
234 | //if ( mData->url.isValid() ) l.append( ); | 234 | //if ( mData->url.isValid() ) l.append( ); |
235 | #if 0 | 235 | #if 0 |
236 | if ( !mData->phoneNumbers.isEmpty() ) l.append( ); | 236 | if ( !mData->phoneNumbers.isEmpty() ) l.append( ); |
237 | if ( !mData->addresses.isEmpty() ) l.append( ); | 237 | if ( !mData->addresses.isEmpty() ) l.append( ); |
238 | //if ( !mData->keys.isEmpty() ) l.append( ); | 238 | //if ( !mData->keys.isEmpty() ) l.append( ); |
239 | if ( !mData->emails.isEmpty() ) l.append( ); | 239 | if ( !mData->emails.isEmpty() ) l.append( ); |
240 | if ( !mData->categories .isEmpty() ) l.append( ); | 240 | if ( !mData->categories .isEmpty() ) l.append( ); |
241 | if ( !mData->custom.isEmpty() ) l.append( ); | 241 | if ( !mData->custom.isEmpty() ) l.append( ); |
242 | #endif | 242 | #endif |
243 | KABC::PhoneNumber::List phoneNumbers; | 243 | KABC::PhoneNumber::List phoneNumbers; |
244 | KABC::PhoneNumber::List::Iterator phoneIter; | 244 | KABC::PhoneNumber::List::Iterator phoneIter; |
245 | 245 | ||
246 | QStringList t; | 246 | QStringList t; |
247 | for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end(); | 247 | for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end(); |
248 | ++phoneIter ) | 248 | ++phoneIter ) |
249 | t.append( ( *phoneIter ).number()+QString::number( ( *phoneIter ).type() ) ); | 249 | t.append( ( *phoneIter ).number()+QString::number( ( *phoneIter ).type() ) ); |
250 | t.sort(); | 250 | t.sort(); |
251 | uint iii; | 251 | uint iii; |
252 | for ( iii = 0; iii < t.count(); ++iii) | 252 | for ( iii = 0; iii < t.count(); ++iii) |
253 | l.append( t[iii] ); | 253 | l.append( t[iii] ); |
254 | t = mData->emails; | 254 | t = mData->emails; |
255 | t.sort(); | 255 | t.sort(); |
256 | for ( iii = 0; iii < t.count(); ++iii) | 256 | for ( iii = 0; iii < t.count(); ++iii) |
257 | l.append( t[iii] ); | 257 | l.append( t[iii] ); |
258 | t = mData->categories; | 258 | t = mData->categories; |
259 | t.sort(); | 259 | t.sort(); |
260 | for ( iii = 0; iii < t.count(); ++iii) | 260 | for ( iii = 0; iii < t.count(); ++iii) |
261 | l.append( t[iii] ); | 261 | l.append( t[iii] ); |
262 | t = mData->custom; | 262 | t = mData->custom; |
263 | t.sort(); | 263 | t.sort(); |
264 | for ( iii = 0; iii < t.count(); ++iii) | 264 | for ( iii = 0; iii < t.count(); ++iii) |
265 | l.append( t[iii] ); | 265 | l.append( t[iii] ); |
266 | KABC::Address::List::Iterator addressIter; | 266 | KABC::Address::List::Iterator addressIter; |
267 | for ( addressIter = mData->addresses.begin(); addressIter != mData->addresses.end(); | 267 | for ( addressIter = mData->addresses.begin(); addressIter != mData->addresses.end(); |
268 | ++addressIter ) { | 268 | ++addressIter ) { |
269 | t = (*addressIter).asList(); | 269 | t = (*addressIter).asList(); |
270 | t.sort(); | 270 | t.sort(); |
271 | for ( iii = 0; iii < t.count(); ++iii) | 271 | for ( iii = 0; iii < t.count(); ++iii) |
272 | l.append( t[iii] ); | 272 | l.append( t[iii] ); |
273 | } | 273 | } |
274 | uint cs = getCsum4List(l); | 274 | uint cs = getCsum4List(l); |
275 | // qDebug("CSUM computed %d %s %s", cs,QString::number (cs ).latin1(), uid().latin1() ); | 275 | // qDebug("CSUM computed %d %s %s", cs,QString::number (cs ).latin1(), uid().latin1() ); |
276 | setCsum( dev, QString::number (cs )); | 276 | setCsum( dev, QString::number (cs )); |
277 | } | 277 | } |
278 | 278 | ||
279 | void Addressee::mergeContact( const Addressee& ad ) | 279 | void Addressee::mergeContact( const Addressee& ad ) |
280 | { | 280 | { |
281 | 281 | ||
282 | detach(); | 282 | detach(); |
283 | if ( mData->name.isEmpty() ) mData->name = ad.mData->name; | 283 | if ( mData->name.isEmpty() ) mData->name = ad.mData->name; |
284 | if ( mData->formattedName.isEmpty() ) mData->formattedName = ad.mData->formattedName; | 284 | if ( mData->formattedName.isEmpty() ) mData->formattedName = ad.mData->formattedName; |
285 | if ( mData->familyName.isEmpty() ) mData->familyName = ad.mData->familyName; | 285 | if ( mData->familyName.isEmpty() ) mData->familyName = ad.mData->familyName; |
286 | if ( mData->givenName.isEmpty() ) mData->givenName = ad.mData->givenName ; | 286 | if ( mData->givenName.isEmpty() ) mData->givenName = ad.mData->givenName ; |
287 | if ( mData->additionalName ) mData->additionalName = ad.mData->additionalName; | 287 | if ( mData->additionalName ) mData->additionalName = ad.mData->additionalName; |
288 | if ( mData->prefix.isEmpty() ) mData->prefix = ad.mData->prefix; | 288 | if ( mData->prefix.isEmpty() ) mData->prefix = ad.mData->prefix; |
289 | if ( mData->suffix.isEmpty() ) mData->suffix = ad.mData->suffix; | 289 | if ( mData->suffix.isEmpty() ) mData->suffix = ad.mData->suffix; |
290 | if ( mData->nickName.isEmpty() ) mData->nickName = ad.mData->nickName; | 290 | if ( mData->nickName.isEmpty() ) mData->nickName = ad.mData->nickName; |
291 | if ( !mData->birthday.isValid() ) | 291 | if ( !mData->birthday.isValid() ) |
292 | if ( ad.mData->birthday.isValid()) | 292 | if ( ad.mData->birthday.isValid()) |
293 | mData->birthday = ad.mData->birthday; | 293 | mData->birthday = ad.mData->birthday; |
294 | if ( mData->mailer.isEmpty() ) mData->mailer = ad.mData->mailer; | 294 | if ( mData->mailer.isEmpty() ) mData->mailer = ad.mData->mailer; |
295 | if ( !mData->timeZone.isValid() ) mData->timeZone = ad.mData->timeZone; | 295 | if ( !mData->timeZone.isValid() ) mData->timeZone = ad.mData->timeZone; |
296 | if ( !mData->geo.isValid() ) mData->geo = ad.mData->geo; | 296 | if ( !mData->geo.isValid() ) mData->geo = ad.mData->geo; |
297 | if ( mData->title .isEmpty() ) mData->title = ad.mData->title ; | 297 | if ( mData->title .isEmpty() ) mData->title = ad.mData->title ; |
298 | if ( mData->role.isEmpty() ) mData->role = ad.mData->role ; | 298 | if ( mData->role.isEmpty() ) mData->role = ad.mData->role ; |
299 | if ( mData->organization.isEmpty() ) mData->organization = ad.mData->organization ; | 299 | if ( mData->organization.isEmpty() ) mData->organization = ad.mData->organization ; |
300 | if ( mData->note.isEmpty() ) mData->note = ad.mData->note ; | 300 | if ( mData->note.isEmpty() ) mData->note = ad.mData->note ; |
301 | if ( mData->productId.isEmpty() ) mData->productId = ad.mData->productId; | 301 | if ( mData->productId.isEmpty() ) mData->productId = ad.mData->productId; |
302 | if ( mData->sortString.isEmpty() ) mData->sortString = ad.mData->sortString; | 302 | if ( mData->sortString.isEmpty() ) mData->sortString = ad.mData->sortString; |
303 | if ( !mData->secrecy.isValid() ) mData->secrecy = ad.mData->secrecy; | 303 | if ( !mData->secrecy.isValid() ) mData->secrecy = ad.mData->secrecy; |
304 | if ( ( !mData->url.isValid() && ad.mData->url.isValid() ) ) mData->url = ad.mData->url ; | 304 | if ( ( !mData->url.isValid() && ad.mData->url.isValid() ) ) mData->url = ad.mData->url ; |
305 | 305 | ||
306 | // pending: | 306 | // pending: |
307 | // merging phonenumbers | 307 | // merging phonenumbers |
308 | // merging addresses | 308 | // merging addresses |
309 | // merging emails; | 309 | // merging emails; |
310 | // merging categories; | 310 | // merging categories; |
311 | // merging custom; | 311 | // merging custom; |
312 | // merging keys | 312 | // merging keys |
313 | qDebug("merge contact %s ", ad.uid().latin1()); | 313 | qDebug("merge contact %s ", ad.uid().latin1()); |
314 | setUid( ad.uid() ); | 314 | setUid( ad.uid() ); |
315 | setRevision( ad.revision() ); | 315 | setRevision( ad.revision() ); |
316 | } | 316 | } |
317 | 317 | ||
318 | // removes all emails but the first | ||
319 | // needed by phone sync | ||
320 | void Addressee::simplifyEmails() | ||
321 | { | ||
322 | if ( mData->emails.count() == 0 ) return ; | ||
323 | QString email = mData->emails.first(); | ||
324 | detach(); | ||
325 | mData->emails.clear(); | ||
326 | mData->emails.append( email ); | ||
327 | } | ||
328 | |||
329 | void Addressee::simplifyPhoneNumbers() | ||
330 | { | ||
331 | KABC::PhoneNumber::List removeNumbers; | ||
332 | KABC::PhoneNumber::List::Iterator phoneIter; | ||
333 | for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end(); | ||
334 | ++phoneIter ) { | ||
335 | if ( ! ( *phoneIter ).simplifyNumber() ) | ||
336 | removeNumbers.append( ( *phoneIter ) ); | ||
337 | } | ||
338 | for ( phoneIter = removeNumbers.begin(); phoneIter != removeNumbers.end(); | ||
339 | ++phoneIter ) { | ||
340 | removePhoneNumber(( *phoneIter )); | ||
341 | } | ||
342 | } | ||
343 | void Addressee::simplifyPhoneNumberTypes() | ||
344 | { | ||
345 | KABC::PhoneNumber::List::Iterator phoneIter; | ||
346 | for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end(); | ||
347 | ++phoneIter ) | ||
348 | ( *phoneIter ).simplifyType(); | ||
349 | } | ||
318 | void Addressee::removeID(const QString &prof) | 350 | void Addressee::removeID(const QString &prof) |
319 | { | 351 | { |
320 | detach(); | 352 | detach(); |
321 | mData->mExternalId = KIdManager::removeId ( mData->mExternalId, prof); | 353 | mData->mExternalId = KIdManager::removeId ( mData->mExternalId, prof); |
322 | 354 | ||
323 | } | 355 | } |
324 | void Addressee::setID( const QString & prof , const QString & id ) | 356 | void Addressee::setID( const QString & prof , const QString & id ) |
325 | { | 357 | { |
326 | detach(); | 358 | detach(); |
327 | mData->mExternalId = KIdManager::setId ( mData->mExternalId, prof, id ); | 359 | mData->mExternalId = KIdManager::setId ( mData->mExternalId, prof, id ); |
328 | //qDebug("setID2 %s %s %s",mData->mExternalId.latin1(), prof.latin1(), id.latin1() ); | 360 | //qDebug("setID2 %s %s %s",mData->mExternalId.latin1(), prof.latin1(), id.latin1() ); |
329 | } | 361 | } |
330 | void Addressee::setTempSyncStat( int id ) | 362 | void Addressee::setTempSyncStat( int id ) |
331 | { | 363 | { |
332 | if ( mData->mTempSyncStat == id ) return; | 364 | if ( mData->mTempSyncStat == id ) return; |
333 | detach(); | 365 | detach(); |
334 | mData->mTempSyncStat = id; | 366 | mData->mTempSyncStat = id; |
335 | } | 367 | } |
336 | int Addressee::tempSyncStat() const | 368 | int Addressee::tempSyncStat() const |
337 | { | 369 | { |
338 | return mData->mTempSyncStat; | 370 | return mData->mTempSyncStat; |
339 | } | 371 | } |
340 | 372 | ||
341 | QString Addressee::getID( const QString & prof) | 373 | QString Addressee::getID( const QString & prof) |
342 | { | 374 | { |
343 | return KIdManager::getId ( mData->mExternalId, prof ); | 375 | return KIdManager::getId ( mData->mExternalId, prof ); |
344 | } | 376 | } |
345 | 377 | ||
346 | void Addressee::setCsum( const QString & prof , const QString & id ) | 378 | void Addressee::setCsum( const QString & prof , const QString & id ) |
347 | { | 379 | { |
348 | detach(); | 380 | detach(); |
349 | //qDebug("setcsum1 %s %s %s",mData->mExternalId.latin1(), prof.latin1(), id.latin1() ); | 381 | //qDebug("setcsum1 %s %s %s",mData->mExternalId.latin1(), prof.latin1(), id.latin1() ); |
350 | mData->mExternalId = KIdManager::setCsum ( mData->mExternalId, prof, id ); | 382 | mData->mExternalId = KIdManager::setCsum ( mData->mExternalId, prof, id ); |
351 | //qDebug("setcsum2 %s ",mData->mExternalId.latin1() ); | 383 | //qDebug("setcsum2 %s ",mData->mExternalId.latin1() ); |
352 | } | 384 | } |
353 | 385 | ||
354 | QString Addressee::getCsum( const QString & prof) | 386 | QString Addressee::getCsum( const QString & prof) |
355 | { | 387 | { |
356 | return KIdManager::getCsum ( mData->mExternalId, prof ); | 388 | return KIdManager::getCsum ( mData->mExternalId, prof ); |
357 | } | 389 | } |
358 | 390 | ||
359 | void Addressee::setIDStr( const QString & s ) | 391 | void Addressee::setIDStr( const QString & s ) |
360 | { | 392 | { |
361 | detach(); | 393 | detach(); |
362 | mData->mExternalId = s; | 394 | mData->mExternalId = s; |
363 | } | 395 | } |
364 | 396 | ||
365 | QString Addressee::IDStr() const | 397 | QString Addressee::IDStr() const |
366 | { | 398 | { |
367 | return mData->mExternalId; | 399 | return mData->mExternalId; |
368 | } | 400 | } |
369 | 401 | ||
370 | void Addressee::setExternalUID( const QString &id ) | 402 | void Addressee::setExternalUID( const QString &id ) |
371 | { | 403 | { |
372 | if ( id == mData->externalUID ) return; | 404 | if ( id == mData->externalUID ) return; |
373 | detach(); | 405 | detach(); |
374 | mData->empty = false; | 406 | mData->empty = false; |
375 | mData->externalUID = id; | 407 | mData->externalUID = id; |
376 | } | 408 | } |
377 | 409 | ||
378 | QString Addressee::externalUID() const | 410 | QString Addressee::externalUID() const |
379 | { | 411 | { |
380 | return mData->externalUID; | 412 | return mData->externalUID; |
381 | } | 413 | } |
382 | void Addressee::setOriginalExternalUID( const QString &id ) | 414 | void Addressee::setOriginalExternalUID( const QString &id ) |
383 | { | 415 | { |
384 | if ( id == mData->originalExternalUID ) return; | 416 | if ( id == mData->originalExternalUID ) return; |
385 | detach(); | 417 | detach(); |
386 | mData->empty = false; | 418 | mData->empty = false; |
387 | //qDebug("*******Set orig uid %s ", id.latin1()); | 419 | //qDebug("*******Set orig uid %s ", id.latin1()); |
388 | mData->originalExternalUID = id; | 420 | mData->originalExternalUID = id; |
389 | } | 421 | } |
390 | 422 | ||
391 | QString Addressee::originalExternalUID() const | 423 | QString Addressee::originalExternalUID() const |
392 | { | 424 | { |
393 | return mData->originalExternalUID; | 425 | return mData->originalExternalUID; |
394 | } | 426 | } |
395 | 427 | ||
396 | void Addressee::setUid( const QString &id ) | 428 | void Addressee::setUid( const QString &id ) |
397 | { | 429 | { |
398 | if ( id == mData->uid ) return; | 430 | if ( id == mData->uid ) return; |
399 | detach(); | 431 | detach(); |
400 | //qDebug("****setuid %s ", id.latin1()); | 432 | //qDebug("****setuid %s ", id.latin1()); |
401 | mData->empty = false; | 433 | mData->empty = false; |
402 | mData->uid = id; | 434 | mData->uid = id; |
403 | } | 435 | } |
404 | 436 | ||
405 | QString Addressee::uid() const | 437 | QString Addressee::uid() const |
406 | { | 438 | { |
407 | if ( mData->uid.isEmpty() ) | 439 | if ( mData->uid.isEmpty() ) |
408 | mData->uid = KApplication::randomString( 10 ); | 440 | mData->uid = KApplication::randomString( 10 ); |
409 | 441 | ||
410 | return mData->uid; | 442 | return mData->uid; |
411 | } | 443 | } |
412 | 444 | ||
413 | QString Addressee::uidLabel() | 445 | QString Addressee::uidLabel() |
diff --git a/kabc/addressee.h b/kabc/addressee.h index 8baa888..4cafa86 100644 --- a/kabc/addressee.h +++ b/kabc/addressee.h | |||
@@ -24,192 +24,196 @@ Enhanced Version of the file for platform independent KDE tools. | |||
24 | Copyright (c) 2004 Ulf Schenk | 24 | Copyright (c) 2004 Ulf Schenk |
25 | 25 | ||
26 | $Id$ | 26 | $Id$ |
27 | */ | 27 | */ |
28 | 28 | ||
29 | #ifndef KABC_ADDRESSEE_H | 29 | #ifndef KABC_ADDRESSEE_H |
30 | #define KABC_ADDRESSEE_H | 30 | #define KABC_ADDRESSEE_H |
31 | 31 | ||
32 | #include <qdatetime.h> | 32 | #include <qdatetime.h> |
33 | #include <qstring.h> | 33 | #include <qstring.h> |
34 | #include <qstringlist.h> | 34 | #include <qstringlist.h> |
35 | #include <qvaluelist.h> | 35 | #include <qvaluelist.h> |
36 | 36 | ||
37 | #include <ksharedptr.h> | 37 | #include <ksharedptr.h> |
38 | #include <kurl.h> | 38 | #include <kurl.h> |
39 | 39 | ||
40 | #include "address.h" | 40 | #include "address.h" |
41 | #include "agent.h" | 41 | #include "agent.h" |
42 | #include "geo.h" | 42 | #include "geo.h" |
43 | #include "key.h" | 43 | #include "key.h" |
44 | #include "phonenumber.h" | 44 | #include "phonenumber.h" |
45 | #include "picture.h" | 45 | #include "picture.h" |
46 | #include "secrecy.h" | 46 | #include "secrecy.h" |
47 | #include "sound.h" | 47 | #include "sound.h" |
48 | #include "timezone.h" | 48 | #include "timezone.h" |
49 | 49 | ||
50 | namespace KABC { | 50 | namespace KABC { |
51 | 51 | ||
52 | class Resource; | 52 | class Resource; |
53 | 53 | ||
54 | /** | 54 | /** |
55 | @short address book entry | 55 | @short address book entry |
56 | 56 | ||
57 | This class represents an entry in the address book. | 57 | This class represents an entry in the address book. |
58 | 58 | ||
59 | The data of this class is implicitly shared. You can pass this class by value. | 59 | The data of this class is implicitly shared. You can pass this class by value. |
60 | 60 | ||
61 | If you need the name of a field for presenting it to the user you should use | 61 | If you need the name of a field for presenting it to the user you should use |
62 | the functions ending in Label(). They return a translated string which can be | 62 | the functions ending in Label(). They return a translated string which can be |
63 | used as label for the corresponding field. | 63 | used as label for the corresponding field. |
64 | 64 | ||
65 | About the name fields: | 65 | About the name fields: |
66 | 66 | ||
67 | givenName() is the first name and familyName() the last name. In some | 67 | givenName() is the first name and familyName() the last name. In some |
68 | countries the family name comes first, that's the reason for the | 68 | countries the family name comes first, that's the reason for the |
69 | naming. formattedName() is the full name with the correct formatting. | 69 | naming. formattedName() is the full name with the correct formatting. |
70 | It is used as an override, when the correct formatting can't be generated | 70 | It is used as an override, when the correct formatting can't be generated |
71 | from the other name fields automatically. | 71 | from the other name fields automatically. |
72 | 72 | ||
73 | realName() returns a fully formatted name(). It uses formattedName, if set, | 73 | realName() returns a fully formatted name(). It uses formattedName, if set, |
74 | otherwise it constucts the name from the name fields. As fallback, if | 74 | otherwise it constucts the name from the name fields. As fallback, if |
75 | nothing else is set it uses name(). | 75 | nothing else is set it uses name(). |
76 | 76 | ||
77 | name() is the NAME type of RFC2426. It can be used as internal name for the | 77 | name() is the NAME type of RFC2426. It can be used as internal name for the |
78 | data enty, but shouldn't be used for displaying the data to the user. | 78 | data enty, but shouldn't be used for displaying the data to the user. |
79 | */ | 79 | */ |
80 | class Addressee | 80 | class Addressee |
81 | { | 81 | { |
82 | friend QDataStream &operator<<( QDataStream &, const Addressee & ); | 82 | friend QDataStream &operator<<( QDataStream &, const Addressee & ); |
83 | friend QDataStream &operator>>( QDataStream &, Addressee & ); | 83 | friend QDataStream &operator>>( QDataStream &, Addressee & ); |
84 | 84 | ||
85 | public: | 85 | public: |
86 | typedef QValueList<Addressee> List; | 86 | typedef QValueList<Addressee> List; |
87 | 87 | ||
88 | /** | 88 | /** |
89 | Construct an empty address book entry. | 89 | Construct an empty address book entry. |
90 | */ | 90 | */ |
91 | Addressee(); | 91 | Addressee(); |
92 | ~Addressee(); | 92 | ~Addressee(); |
93 | 93 | ||
94 | Addressee( const Addressee & ); | 94 | Addressee( const Addressee & ); |
95 | Addressee &operator=( const Addressee & ); | 95 | Addressee &operator=( const Addressee & ); |
96 | 96 | ||
97 | bool operator==( const Addressee & ) const; | 97 | bool operator==( const Addressee & ) const; |
98 | bool operator!=( const Addressee & ) const; | 98 | bool operator!=( const Addressee & ) const; |
99 | // sync stuff | 99 | // sync stuff |
100 | void setTempSyncStat(int id); | 100 | void setTempSyncStat(int id); |
101 | int tempSyncStat() const; | 101 | int tempSyncStat() const; |
102 | void setIDStr( const QString & ); | 102 | void setIDStr( const QString & ); |
103 | QString IDStr() const; | 103 | QString IDStr() const; |
104 | void setID( const QString &, const QString & ); | 104 | void setID( const QString &, const QString & ); |
105 | QString getID( const QString & ); | 105 | QString getID( const QString & ); |
106 | void setCsum( const QString &, const QString & ); | 106 | void setCsum( const QString &, const QString & ); |
107 | QString getCsum( const QString & ); | 107 | QString getCsum( const QString & ); |
108 | void removeID(const QString &); | 108 | void removeID(const QString &); |
109 | void computeCsum(const QString &dev); | 109 | void computeCsum(const QString &dev); |
110 | ulong getCsum4List( const QStringList & attList); | 110 | ulong getCsum4List( const QStringList & attList); |
111 | /** | 111 | /** |
112 | Return, if the address book entry is empty. | 112 | Return, if the address book entry is empty. |
113 | */ | 113 | */ |
114 | bool isEmpty() const; | 114 | bool isEmpty() const; |
115 | void setExternalUID( const QString &id ); | 115 | void setExternalUID( const QString &id ); |
116 | QString externalUID() const; | 116 | QString externalUID() const; |
117 | void setOriginalExternalUID( const QString &id ); | 117 | void setOriginalExternalUID( const QString &id ); |
118 | QString originalExternalUID() const; | 118 | QString originalExternalUID() const; |
119 | void mergeContact( const Addressee& ad ); | 119 | void mergeContact( const Addressee& ad ); |
120 | void simplifyEmails(); | ||
121 | void simplifyPhoneNumbers(); | ||
122 | void simplifyPhoneNumberTypes(); | ||
123 | |||
120 | /** | 124 | /** |
121 | Set unique identifier. | 125 | Set unique identifier. |
122 | */ | 126 | */ |
123 | void setUid( const QString &uid ); | 127 | void setUid( const QString &uid ); |
124 | /** | 128 | /** |
125 | Return unique identifier. | 129 | Return unique identifier. |
126 | */ | 130 | */ |
127 | QString uid() const; | 131 | QString uid() const; |
128 | /** | 132 | /** |
129 | Return translated label for uid field. | 133 | Return translated label for uid field. |
130 | */ | 134 | */ |
131 | static QString uidLabel(); | 135 | static QString uidLabel(); |
132 | 136 | ||
133 | /** | 137 | /** |
134 | Set name. | 138 | Set name. |
135 | */ | 139 | */ |
136 | void setName( const QString &name ); | 140 | void setName( const QString &name ); |
137 | /** | 141 | /** |
138 | Return name. | 142 | Return name. |
139 | */ | 143 | */ |
140 | QString name() const; | 144 | QString name() const; |
141 | /** | 145 | /** |
142 | Return translated label for name field. | 146 | Return translated label for name field. |
143 | */ | 147 | */ |
144 | static QString nameLabel(); | 148 | static QString nameLabel(); |
145 | 149 | ||
146 | /** | 150 | /** |
147 | Set formatted name. | 151 | Set formatted name. |
148 | */ | 152 | */ |
149 | void setFormattedName( const QString &formattedName ); | 153 | void setFormattedName( const QString &formattedName ); |
150 | /** | 154 | /** |
151 | Return formatted name. | 155 | Return formatted name. |
152 | */ | 156 | */ |
153 | QString formattedName() const; | 157 | QString formattedName() const; |
154 | /** | 158 | /** |
155 | Return translated label for formattedName field. | 159 | Return translated label for formattedName field. |
156 | */ | 160 | */ |
157 | static QString formattedNameLabel(); | 161 | static QString formattedNameLabel(); |
158 | 162 | ||
159 | /** | 163 | /** |
160 | Set family name. | 164 | Set family name. |
161 | */ | 165 | */ |
162 | void setFamilyName( const QString &familyName ); | 166 | void setFamilyName( const QString &familyName ); |
163 | /** | 167 | /** |
164 | Return family name. | 168 | Return family name. |
165 | */ | 169 | */ |
166 | QString familyName() const; | 170 | QString familyName() const; |
167 | /** | 171 | /** |
168 | Return translated label for familyName field. | 172 | Return translated label for familyName field. |
169 | */ | 173 | */ |
170 | static QString familyNameLabel(); | 174 | static QString familyNameLabel(); |
171 | 175 | ||
172 | /** | 176 | /** |
173 | Set given name. | 177 | Set given name. |
174 | */ | 178 | */ |
175 | void setGivenName( const QString &givenName ); | 179 | void setGivenName( const QString &givenName ); |
176 | /** | 180 | /** |
177 | Return given name. | 181 | Return given name. |
178 | */ | 182 | */ |
179 | QString givenName() const; | 183 | QString givenName() const; |
180 | /** | 184 | /** |
181 | Return translated label for givenName field. | 185 | Return translated label for givenName field. |
182 | */ | 186 | */ |
183 | static QString givenNameLabel(); | 187 | static QString givenNameLabel(); |
184 | 188 | ||
185 | /** | 189 | /** |
186 | Set additional names. | 190 | Set additional names. |
187 | */ | 191 | */ |
188 | void setAdditionalName( const QString &additionalName ); | 192 | void setAdditionalName( const QString &additionalName ); |
189 | /** | 193 | /** |
190 | Return additional names. | 194 | Return additional names. |
191 | */ | 195 | */ |
192 | QString additionalName() const; | 196 | QString additionalName() const; |
193 | /** | 197 | /** |
194 | Return translated label for additionalName field. | 198 | Return translated label for additionalName field. |
195 | */ | 199 | */ |
196 | static QString additionalNameLabel(); | 200 | static QString additionalNameLabel(); |
197 | 201 | ||
198 | /** | 202 | /** |
199 | Set honorific prefixes. | 203 | Set honorific prefixes. |
200 | */ | 204 | */ |
201 | void setPrefix( const QString &prefix ); | 205 | void setPrefix( const QString &prefix ); |
202 | /** | 206 | /** |
203 | Return honorific prefixes. | 207 | Return honorific prefixes. |
204 | */ | 208 | */ |
205 | QString prefix() const; | 209 | QString prefix() const; |
206 | /** | 210 | /** |
207 | Return translated label for prefix field. | 211 | Return translated label for prefix field. |
208 | */ | 212 | */ |
209 | static QString prefixLabel(); | 213 | static QString prefixLabel(); |
210 | 214 | ||
211 | /** | 215 | /** |
212 | Set honorific suffixes. | 216 | Set honorific suffixes. |
213 | */ | 217 | */ |
214 | void setSuffix( const QString &suffix ); | 218 | void setSuffix( const QString &suffix ); |
215 | /** | 219 | /** |
diff --git a/kabc/phonenumber.cpp b/kabc/phonenumber.cpp index 7aeb2ee..e5abc0e 100644 --- a/kabc/phonenumber.cpp +++ b/kabc/phonenumber.cpp | |||
@@ -1,164 +1,187 @@ | |||
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 | #include <kapplication.h> | 28 | #include <kapplication.h> |
29 | #include <klocale.h> | 29 | #include <klocale.h> |
30 | 30 | ||
31 | #include "phonenumber.h" | 31 | #include "phonenumber.h" |
32 | 32 | ||
33 | using namespace KABC; | 33 | using namespace KABC; |
34 | 34 | ||
35 | PhoneNumber::PhoneNumber() : | 35 | PhoneNumber::PhoneNumber() : |
36 | mType( Home ) | 36 | mType( Home ) |
37 | { | 37 | { |
38 | init(); | 38 | init(); |
39 | } | 39 | } |
40 | 40 | ||
41 | PhoneNumber::PhoneNumber( const QString &number, int type ) : | 41 | PhoneNumber::PhoneNumber( const QString &number, int type ) : |
42 | mType( type ), mNumber( number ) | 42 | mType( type ), mNumber( number ) |
43 | { | 43 | { |
44 | init(); | 44 | init(); |
45 | } | 45 | } |
46 | 46 | ||
47 | PhoneNumber::~PhoneNumber() | 47 | PhoneNumber::~PhoneNumber() |
48 | { | 48 | { |
49 | } | 49 | } |
50 | 50 | ||
51 | void PhoneNumber::init() | 51 | void PhoneNumber::init() |
52 | { | 52 | { |
53 | mId = KApplication::randomString( 8 ); | 53 | mId = KApplication::randomString( 8 ); |
54 | } | 54 | } |
55 | 55 | ||
56 | bool PhoneNumber::operator==( const PhoneNumber &p ) const | 56 | bool PhoneNumber::operator==( const PhoneNumber &p ) const |
57 | { | 57 | { |
58 | if ( mNumber != p.mNumber ) return false; | 58 | if ( mNumber != p.mNumber ) return false; |
59 | if ( mType != p.mType ) return false; | 59 | if ( mType != p.mType ) return false; |
60 | 60 | ||
61 | return true; | 61 | return true; |
62 | } | 62 | } |
63 | 63 | ||
64 | bool PhoneNumber::operator!=( const PhoneNumber &p ) const | 64 | bool PhoneNumber::operator!=( const PhoneNumber &p ) const |
65 | { | 65 | { |
66 | return !( p == *this ); | 66 | return !( p == *this ); |
67 | } | 67 | } |
68 | 68 | ||
69 | bool PhoneNumber::simplifyNumber() | ||
70 | { | ||
71 | QString Number; | ||
72 | int i; | ||
73 | Number = mNumber.stripWhiteSpace (); | ||
74 | mNumber = ""; | ||
75 | if ( Number.at(0) == '+' ) | ||
76 | mNumber += "+"; | ||
77 | for ( i = 0; i < Number.length(); ++i) { | ||
78 | if ( Number.at(i).isDigit() ) | ||
79 | mNumber += Number.at(i); | ||
80 | } | ||
81 | return ( mNumber.length() > 0 ); | ||
82 | } | ||
83 | // make cellphone compatible | ||
84 | void PhoneNumber::simplifyType() | ||
85 | { | ||
86 | if ( mType & Fax ) mType = Fax; | ||
87 | else if ( mType & Cell ) mType = Cell; | ||
88 | else if ( mType & Work ) mType = Work ; | ||
89 | else if ( mType & Home ) mType = Home; | ||
90 | else mType = Pref; | ||
91 | } | ||
69 | void PhoneNumber::setId( const QString &id ) | 92 | void PhoneNumber::setId( const QString &id ) |
70 | { | 93 | { |
71 | mId = id; | 94 | mId = id; |
72 | } | 95 | } |
73 | 96 | ||
74 | QString PhoneNumber::id() const | 97 | QString PhoneNumber::id() const |
75 | { | 98 | { |
76 | return mId; | 99 | return mId; |
77 | } | 100 | } |
78 | 101 | ||
79 | void PhoneNumber::setNumber( const QString &number ) | 102 | void PhoneNumber::setNumber( const QString &number ) |
80 | { | 103 | { |
81 | mNumber = number; | 104 | mNumber = number; |
82 | } | 105 | } |
83 | 106 | ||
84 | QString PhoneNumber::number() const | 107 | QString PhoneNumber::number() const |
85 | { | 108 | { |
86 | return mNumber; | 109 | return mNumber; |
87 | } | 110 | } |
88 | 111 | ||
89 | void PhoneNumber::setType( int type ) | 112 | void PhoneNumber::setType( int type ) |
90 | { | 113 | { |
91 | mType = type; | 114 | mType = type; |
92 | } | 115 | } |
93 | 116 | ||
94 | int PhoneNumber::type() const | 117 | int PhoneNumber::type() const |
95 | { | 118 | { |
96 | return mType; | 119 | return mType; |
97 | } | 120 | } |
98 | 121 | ||
99 | QString PhoneNumber::typeLabel() const | 122 | QString PhoneNumber::typeLabel() const |
100 | { | 123 | { |
101 | QString label; | 124 | QString label; |
102 | bool first = true; | 125 | bool first = true; |
103 | 126 | ||
104 | TypeList list = typeList(); | 127 | TypeList list = typeList(); |
105 | 128 | ||
106 | TypeList::Iterator it; | 129 | TypeList::Iterator it; |
107 | for ( it = list.begin(); it != list.end(); ++it ) { | 130 | for ( it = list.begin(); it != list.end(); ++it ) { |
108 | if ( ( type() & (*it) ) && ( (*it) != Pref ) ) { | 131 | if ( ( type() & (*it) ) && ( (*it) != Pref ) ) { |
109 | label.append( ( first ? "" : "/" ) + typeLabel( *it ) ); | 132 | label.append( ( first ? "" : "/" ) + typeLabel( *it ) ); |
110 | if ( first ) | 133 | if ( first ) |
111 | first = false; | 134 | first = false; |
112 | } | 135 | } |
113 | } | 136 | } |
114 | 137 | ||
115 | return label; | 138 | return label; |
116 | } | 139 | } |
117 | 140 | ||
118 | QString PhoneNumber::label() const | 141 | QString PhoneNumber::label() const |
119 | { | 142 | { |
120 | return typeLabel( type() ); | 143 | return typeLabel( type() ); |
121 | } | 144 | } |
122 | 145 | ||
123 | PhoneNumber::TypeList PhoneNumber::typeList() | 146 | PhoneNumber::TypeList PhoneNumber::typeList() |
124 | { | 147 | { |
125 | TypeList list; | 148 | TypeList list; |
126 | 149 | ||
127 | list << Home << Work << Msg << Pref << Voice << Fax << Cell << Video | 150 | list << Home << Work << Msg << Pref << Voice << Fax << Cell << Video |
128 | << Bbs << Modem << Car << Isdn << Pcs << Pager << Sip; | 151 | << Bbs << Modem << Car << Isdn << Pcs << Pager << Sip; |
129 | 152 | ||
130 | return list; | 153 | return list; |
131 | } | 154 | } |
132 | 155 | ||
133 | QString PhoneNumber::label( int type ) | 156 | QString PhoneNumber::label( int type ) |
134 | { | 157 | { |
135 | return typeLabel( type ); | 158 | return typeLabel( type ); |
136 | } | 159 | } |
137 | 160 | ||
138 | QString PhoneNumber::typeLabel( int type ) | 161 | QString PhoneNumber::typeLabel( int type ) |
139 | { | 162 | { |
140 | QString typeString; | 163 | QString typeString; |
141 | 164 | ||
142 | if ((type & Home) == Home) | 165 | if ((type & Home) == Home) |
143 | typeString += i18n("Home"); | 166 | typeString += i18n("Home"); |
144 | else if ((type & Work) == Work) | 167 | else if ((type & Work) == Work) |
145 | typeString += i18n("Work"); | 168 | typeString += i18n("Work"); |
146 | 169 | ||
147 | if (!typeString.isEmpty()) | 170 | if (!typeString.isEmpty()) |
148 | typeString += " "; | 171 | typeString += " "; |
149 | 172 | ||
150 | if ((type & Cell) == Cell) | 173 | if ((type & Cell) == Cell) |
151 | typeString += i18n("Mobile"); | 174 | typeString += i18n("Mobile"); |
152 | else if ((type & Fax) == Fax) | 175 | else if ((type & Fax) == Fax) |
153 | typeString += i18n("Fax"); | 176 | typeString += i18n("Fax"); |
154 | else if ((type & Msg) == Msg) | 177 | else if ((type & Msg) == Msg) |
155 | typeString += i18n("Messenger"); | 178 | typeString += i18n("Messenger"); |
156 | else if ((type & Voice) == Voice) { | 179 | else if ((type & Voice) == Voice) { |
157 | // add nothing in case of the Voice flag | 180 | // add nothing in case of the Voice flag |
158 | // typeString += i18n("Voice"); | 181 | // typeString += i18n("Voice"); |
159 | } | 182 | } |
160 | else if ((type & Video) == Video) | 183 | else if ((type & Video) == Video) |
161 | typeString += i18n("Video"); | 184 | typeString += i18n("Video"); |
162 | else if ((type & Bbs) == Bbs) | 185 | else if ((type & Bbs) == Bbs) |
163 | typeString += i18n("Mailbox"); | 186 | typeString += i18n("Mailbox"); |
164 | else if ((type & Modem) == Modem) | 187 | else if ((type & Modem) == Modem) |
diff --git a/kabc/phonenumber.h b/kabc/phonenumber.h index 1df344f..410a52f 100644 --- a/kabc/phonenumber.h +++ b/kabc/phonenumber.h | |||
@@ -55,112 +55,114 @@ class PhoneNumber | |||
55 | @li @p Msg - Messaging | 55 | @li @p Msg - Messaging |
56 | @li @p Pref - Preferred number | 56 | @li @p Pref - Preferred number |
57 | @li @p Voice - Voice | 57 | @li @p Voice - Voice |
58 | @li @p Fax - Fax machine | 58 | @li @p Fax - Fax machine |
59 | @li @p Cell - Cell phone | 59 | @li @p Cell - Cell phone |
60 | @li @p Video - Video phone | 60 | @li @p Video - Video phone |
61 | @li @p Bbs - Mailbox | 61 | @li @p Bbs - Mailbox |
62 | @li @p Modem - Modem | 62 | @li @p Modem - Modem |
63 | @li @p Car - Car phone | 63 | @li @p Car - Car phone |
64 | @li @p Isdn - ISDN connection | 64 | @li @p Isdn - ISDN connection |
65 | @li @p Pcs - Personal Communication Service | 65 | @li @p Pcs - Personal Communication Service |
66 | @li @p Pager - Pager | 66 | @li @p Pager - Pager |
67 | @li @p SIP - VoIP | 67 | @li @p SIP - VoIP |
68 | */ | 68 | */ |
69 | enum Types { Home = 1, Work = 2, Msg = 4, Pref = 8, Voice = 16, Fax = 32, | 69 | enum Types { Home = 1, Work = 2, Msg = 4, Pref = 8, Voice = 16, Fax = 32, |
70 | Cell = 64, Video = 128, Bbs = 256, Modem = 512, Car = 1024, | 70 | Cell = 64, Video = 128, Bbs = 256, Modem = 512, Car = 1024, |
71 | Isdn = 2048, Pcs = 4096, Pager = 8192, Sip = 16384 }; | 71 | Isdn = 2048, Pcs = 4096, Pager = 8192, Sip = 16384 }; |
72 | 72 | ||
73 | /** | 73 | /** |
74 | Create an empty phone number object. | 74 | Create an empty phone number object. |
75 | */ | 75 | */ |
76 | PhoneNumber(); | 76 | PhoneNumber(); |
77 | 77 | ||
78 | /** | 78 | /** |
79 | Create a phonenumber object. | 79 | Create a phonenumber object. |
80 | 80 | ||
81 | @param number Number | 81 | @param number Number |
82 | @param type Type as defined in enum. Multiple types can be | 82 | @param type Type as defined in enum. Multiple types can be |
83 | specified by combining them by a logical or. | 83 | specified by combining them by a logical or. |
84 | */ | 84 | */ |
85 | PhoneNumber( const QString &number, int type = Home ); | 85 | PhoneNumber( const QString &number, int type = Home ); |
86 | 86 | ||
87 | /** | 87 | /** |
88 | Destructor. | 88 | Destructor. |
89 | */ | 89 | */ |
90 | ~PhoneNumber(); | 90 | ~PhoneNumber(); |
91 | 91 | ||
92 | bool operator==( const PhoneNumber & ) const; | 92 | bool operator==( const PhoneNumber & ) const; |
93 | bool operator!=( const PhoneNumber & ) const; | 93 | bool operator!=( const PhoneNumber & ) const; |
94 | 94 | ||
95 | /** | 95 | /** |
96 | Sets the unique identifier. | 96 | Sets the unique identifier. |
97 | */ | 97 | */ |
98 | void setId( const QString &id ); | 98 | void setId( const QString &id ); |
99 | 99 | ||
100 | /** | 100 | /** |
101 | Returns the unique identifier. | 101 | Returns the unique identifier. |
102 | */ | 102 | */ |
103 | QString id() const; | 103 | QString id() const; |
104 | 104 | ||
105 | /** | 105 | /** |
106 | Sets the number. | 106 | Sets the number. |
107 | */ | 107 | */ |
108 | void setNumber( const QString & ); | 108 | void setNumber( const QString & ); |
109 | 109 | ||
110 | /** | 110 | /** |
111 | Returns the number. | 111 | Returns the number. |
112 | */ | 112 | */ |
113 | QString number() const; | 113 | QString number() const; |
114 | 114 | ||
115 | /** | 115 | /** |
116 | Sets the type. Multiple types can be specified by combining them by | 116 | Sets the type. Multiple types can be specified by combining them by |
117 | a logical or. | 117 | a logical or. |
118 | */ | 118 | */ |
119 | void setType( int ); | 119 | void setType( int ); |
120 | 120 | ||
121 | /** | 121 | /** |
122 | Returns the type. Can be a multiple types combined by a logical or. | 122 | Returns the type. Can be a multiple types combined by a logical or. |
123 | */ | 123 | */ |
124 | int type() const; | 124 | int type() const; |
125 | 125 | ||
126 | /** | 126 | /** |
127 | Returns a translated string of all types the address has. | 127 | Returns a translated string of all types the address has. |
128 | */ | 128 | */ |
129 | QString typeLabel() const; | 129 | QString typeLabel() const; |
130 | 130 | ||
131 | /** | 131 | /** |
132 | Returns the translated label for phone number depending on its type. | 132 | Returns the translated label for phone number depending on its type. |
133 | */ | 133 | */ |
134 | QString label() const; | 134 | QString label() const; |
135 | 135 | ||
136 | /** | 136 | /** |
137 | Returns a list of all available types | 137 | Returns a list of all available types |
138 | */ | 138 | */ |
139 | static TypeList typeList(); | 139 | static TypeList typeList(); |
140 | 140 | ||
141 | /** | 141 | /** |
142 | Returns the translated label for phone number type. | 142 | Returns the translated label for phone number type. |
143 | */ | 143 | */ |
144 | static QString typeLabel( int type ); | 144 | static QString typeLabel( int type ); |
145 | 145 | ||
146 | /** | 146 | /** |
147 | Returns the translated label for phone number type. | 147 | Returns the translated label for phone number type. |
148 | @obsolete | 148 | @obsolete |
149 | */ | 149 | */ |
150 | static QString label( int type ); | 150 | static QString label( int type ); |
151 | bool simplifyNumber(); | ||
152 | void simplifyType(); | ||
151 | 153 | ||
152 | private: | 154 | private: |
153 | void init(); | 155 | void init(); |
154 | 156 | ||
155 | QString mId; | 157 | QString mId; |
156 | 158 | ||
157 | int mType; | 159 | int mType; |
158 | QString mNumber; | 160 | QString mNumber; |
159 | }; | 161 | }; |
160 | 162 | ||
161 | QDataStream &operator<<( QDataStream &, const PhoneNumber & ); | 163 | QDataStream &operator<<( QDataStream &, const PhoneNumber & ); |
162 | QDataStream &operator>>( QDataStream &, PhoneNumber & ); | 164 | QDataStream &operator>>( QDataStream &, PhoneNumber & ); |
163 | 165 | ||
164 | } | 166 | } |
165 | 167 | ||
166 | #endif | 168 | #endif |