-rw-r--r-- | kabc/addressee.cpp | 28 |
1 files changed, 23 insertions, 5 deletions
diff --git a/kabc/addressee.cpp b/kabc/addressee.cpp index e241281..31ce1d6 100644 --- a/kabc/addressee.cpp +++ b/kabc/addressee.cpp | |||
@@ -1,93 +1,95 @@ | |||
1 | /*** Warning! This file has been generated by the script makeaddressee ***/ | 1 | /*** Warning! This file has been generated by the script makeaddressee ***/ |
2 | /* | 2 | /* |
3 | This file is part of libkabc. | 3 | This file is part of libkabc. |
4 | Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> | 4 | Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> |
5 | 5 | ||
6 | This library is free software; you can redistribute it and/or | 6 | This library is free software; you can redistribute it and/or |
7 | modify it under the terms of the GNU Library General Public | 7 | modify it under the terms of the GNU Library General Public |
8 | License as published by the Free Software Foundation; either | 8 | License as published by the Free Software Foundation; either |
9 | version 2 of the License, or (at your option) any later version. | 9 | version 2 of the License, or (at your option) any later version. |
10 | 10 | ||
11 | This library is distributed in the hope that it will be useful, | 11 | This library is distributed in the hope that it will be useful, |
12 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
14 | Library General Public License for more details. | 14 | Library General Public License for more details. |
15 | 15 | ||
16 | You should have received a copy of the GNU Library General Public License | 16 | You should have received a copy of the GNU Library General Public License |
17 | along with this library; see the file COPYING.LIB. If not, write to | 17 | along with this library; see the file COPYING.LIB. If not, write to |
18 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, | 18 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
19 | Boston, MA 02111-1307, USA. | 19 | Boston, MA 02111-1307, USA. |
20 | */ | 20 | */ |
21 | 21 | ||
22 | /* | 22 | /* |
23 | Enhanced Version of the file for platform independent KDE tools. | 23 | 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 | #include <kconfig.h> | 29 | #include <kconfig.h> |
30 | 30 | ||
31 | #include <ksharedptr.h> | 31 | #include <ksharedptr.h> |
32 | #include <kdebug.h> | 32 | #include <kdebug.h> |
33 | #include <kapplication.h> | 33 | #include <kapplication.h> |
34 | #include <klocale.h> | 34 | #include <klocale.h> |
35 | #include <kidmanager.h> | 35 | #include <kidmanager.h> |
36 | //US | 36 | //US |
37 | #include <kstandarddirs.h> | 37 | #include <kstandarddirs.h> |
38 | #include <libkcal/syncdefines.h> | 38 | #include <libkcal/syncdefines.h> |
39 | 39 | ||
40 | //US #include "resource.h" | 40 | //US #include "resource.h" |
41 | #include "addressee.h" | 41 | #include "addressee.h" |
42 | 42 | ||
43 | using namespace KABC; | 43 | using namespace KABC; |
44 | 44 | ||
45 | static bool matchBinaryPattern( int value, int pattern ); | 45 | static bool matchBinaryPattern( int value, int pattern ); |
46 | static bool matchBinaryPatternA( int value, int pattern ); | ||
47 | static bool matchBinaryPatternP( int value, int pattern ); | ||
46 | 48 | ||
47 | struct Addressee::AddresseeData : public KShared | 49 | struct Addressee::AddresseeData : public KShared |
48 | { | 50 | { |
49 | QString uid; | 51 | QString uid; |
50 | QString name; | 52 | QString name; |
51 | QString formattedName; | 53 | QString formattedName; |
52 | QString familyName; | 54 | QString familyName; |
53 | QString givenName; | 55 | QString givenName; |
54 | QString additionalName; | 56 | QString additionalName; |
55 | QString prefix; | 57 | QString prefix; |
56 | QString suffix; | 58 | QString suffix; |
57 | QString nickName; | 59 | QString nickName; |
58 | QDateTime birthday; | 60 | QDateTime birthday; |
59 | QString mailer; | 61 | QString mailer; |
60 | TimeZone timeZone; | 62 | TimeZone timeZone; |
61 | Geo geo; | 63 | Geo geo; |
62 | QString title; | 64 | QString title; |
63 | QString role; | 65 | QString role; |
64 | QString organization; | 66 | QString organization; |
65 | QString note; | 67 | QString note; |
66 | QString productId; | 68 | QString productId; |
67 | QDateTime revision; | 69 | QDateTime revision; |
68 | QString sortString; | 70 | QString sortString; |
69 | QString externalUID; | 71 | QString externalUID; |
70 | QString originalExternalUID; | 72 | QString originalExternalUID; |
71 | KURL url; | 73 | KURL url; |
72 | Secrecy secrecy; | 74 | Secrecy secrecy; |
73 | Picture logo; | 75 | Picture logo; |
74 | Picture photo; | 76 | Picture photo; |
75 | Sound sound; | 77 | Sound sound; |
76 | Agent agent; | 78 | Agent agent; |
77 | QString mExternalId; | 79 | QString mExternalId; |
78 | PhoneNumber::List phoneNumbers; | 80 | PhoneNumber::List phoneNumbers; |
79 | Address::List addresses; | 81 | Address::List addresses; |
80 | Key::List keys; | 82 | Key::List keys; |
81 | QStringList emails; | 83 | QStringList emails; |
82 | QStringList categories; | 84 | QStringList categories; |
83 | QStringList custom; | 85 | QStringList custom; |
84 | int mTempSyncStat; | 86 | int mTempSyncStat; |
85 | Resource *resource; | 87 | Resource *resource; |
86 | 88 | ||
87 | bool empty :1; | 89 | bool empty :1; |
88 | bool changed :1; | 90 | bool changed :1; |
89 | }; | 91 | }; |
90 | 92 | ||
91 | Addressee::Addressee() | 93 | Addressee::Addressee() |
92 | { | 94 | { |
93 | mData = new AddresseeData; | 95 | mData = new AddresseeData; |
@@ -336,110 +338,110 @@ int Addressee::tempSyncStat() const | |||
336 | } | 338 | } |
337 | 339 | ||
338 | QString Addressee::getID( const QString & prof) | 340 | QString Addressee::getID( const QString & prof) |
339 | { | 341 | { |
340 | return KIdManager::getId ( mData->mExternalId, prof ); | 342 | return KIdManager::getId ( mData->mExternalId, prof ); |
341 | } | 343 | } |
342 | 344 | ||
343 | void Addressee::setCsum( const QString & prof , const QString & id ) | 345 | void Addressee::setCsum( const QString & prof , const QString & id ) |
344 | { | 346 | { |
345 | detach(); | 347 | detach(); |
346 | //qDebug("setcsum1 %s %s %s",mData->mExternalId.latin1(), prof.latin1(), id.latin1() ); | 348 | //qDebug("setcsum1 %s %s %s",mData->mExternalId.latin1(), prof.latin1(), id.latin1() ); |
347 | mData->mExternalId = KIdManager::setCsum ( mData->mExternalId, prof, id ); | 349 | mData->mExternalId = KIdManager::setCsum ( mData->mExternalId, prof, id ); |
348 | //qDebug("setcsum2 %s ",mData->mExternalId.latin1() ); | 350 | //qDebug("setcsum2 %s ",mData->mExternalId.latin1() ); |
349 | } | 351 | } |
350 | 352 | ||
351 | QString Addressee::getCsum( const QString & prof) | 353 | QString Addressee::getCsum( const QString & prof) |
352 | { | 354 | { |
353 | return KIdManager::getCsum ( mData->mExternalId, prof ); | 355 | return KIdManager::getCsum ( mData->mExternalId, prof ); |
354 | } | 356 | } |
355 | 357 | ||
356 | void Addressee::setIDStr( const QString & s ) | 358 | void Addressee::setIDStr( const QString & s ) |
357 | { | 359 | { |
358 | detach(); | 360 | detach(); |
359 | mData->mExternalId = s; | 361 | mData->mExternalId = s; |
360 | } | 362 | } |
361 | 363 | ||
362 | QString Addressee::IDStr() const | 364 | QString Addressee::IDStr() const |
363 | { | 365 | { |
364 | return mData->mExternalId; | 366 | return mData->mExternalId; |
365 | } | 367 | } |
366 | 368 | ||
367 | void Addressee::setExternalUID( const QString &id ) | 369 | void Addressee::setExternalUID( const QString &id ) |
368 | { | 370 | { |
369 | if ( id == mData->externalUID ) return; | 371 | if ( id == mData->externalUID ) return; |
370 | detach(); | 372 | detach(); |
371 | mData->empty = false; | 373 | mData->empty = false; |
372 | mData->externalUID = id; | 374 | mData->externalUID = id; |
373 | } | 375 | } |
374 | 376 | ||
375 | QString Addressee::externalUID() const | 377 | QString Addressee::externalUID() const |
376 | { | 378 | { |
377 | return mData->externalUID; | 379 | return mData->externalUID; |
378 | } | 380 | } |
379 | void Addressee::setOriginalExternalUID( const QString &id ) | 381 | void Addressee::setOriginalExternalUID( const QString &id ) |
380 | { | 382 | { |
381 | if ( id == mData->originalExternalUID ) return; | 383 | if ( id == mData->originalExternalUID ) return; |
382 | detach(); | 384 | detach(); |
383 | mData->empty = false; | 385 | mData->empty = false; |
384 | qDebug("*******Set orig uid %s ", id.latin1()); | 386 | //qDebug("*******Set orig uid %s ", id.latin1()); |
385 | mData->originalExternalUID = id; | 387 | mData->originalExternalUID = id; |
386 | } | 388 | } |
387 | 389 | ||
388 | QString Addressee::originalExternalUID() const | 390 | QString Addressee::originalExternalUID() const |
389 | { | 391 | { |
390 | return mData->originalExternalUID; | 392 | return mData->originalExternalUID; |
391 | } | 393 | } |
392 | 394 | ||
393 | void Addressee::setUid( const QString &id ) | 395 | void Addressee::setUid( const QString &id ) |
394 | { | 396 | { |
395 | if ( id == mData->uid ) return; | 397 | if ( id == mData->uid ) return; |
396 | detach(); | 398 | detach(); |
397 | qDebug("****setuid %s ", id.latin1()); | 399 | //qDebug("****setuid %s ", id.latin1()); |
398 | mData->empty = false; | 400 | mData->empty = false; |
399 | mData->uid = id; | 401 | mData->uid = id; |
400 | } | 402 | } |
401 | 403 | ||
402 | QString Addressee::uid() const | 404 | QString Addressee::uid() const |
403 | { | 405 | { |
404 | if ( mData->uid.isEmpty() ) | 406 | if ( mData->uid.isEmpty() ) |
405 | mData->uid = KApplication::randomString( 10 ); | 407 | mData->uid = KApplication::randomString( 10 ); |
406 | 408 | ||
407 | return mData->uid; | 409 | return mData->uid; |
408 | } | 410 | } |
409 | 411 | ||
410 | QString Addressee::uidLabel() | 412 | QString Addressee::uidLabel() |
411 | { | 413 | { |
412 | return i18n("Unique Identifier"); | 414 | return i18n("Unique Identifier"); |
413 | } | 415 | } |
414 | 416 | ||
415 | void Addressee::setName( const QString &name ) | 417 | void Addressee::setName( const QString &name ) |
416 | { | 418 | { |
417 | if ( name == mData->name ) return; | 419 | if ( name == mData->name ) return; |
418 | detach(); | 420 | detach(); |
419 | mData->empty = false; | 421 | mData->empty = false; |
420 | mData->name = name; | 422 | mData->name = name; |
421 | } | 423 | } |
422 | 424 | ||
423 | QString Addressee::name() const | 425 | QString Addressee::name() const |
424 | { | 426 | { |
425 | return mData->name; | 427 | return mData->name; |
426 | } | 428 | } |
427 | 429 | ||
428 | QString Addressee::nameLabel() | 430 | QString Addressee::nameLabel() |
429 | { | 431 | { |
430 | return i18n("Name"); | 432 | return i18n("Name"); |
431 | } | 433 | } |
432 | 434 | ||
433 | 435 | ||
434 | void Addressee::setFormattedName( const QString &formattedName ) | 436 | void Addressee::setFormattedName( const QString &formattedName ) |
435 | { | 437 | { |
436 | if ( formattedName == mData->formattedName ) return; | 438 | if ( formattedName == mData->formattedName ) return; |
437 | detach(); | 439 | detach(); |
438 | mData->empty = false; | 440 | mData->empty = false; |
439 | mData->formattedName = formattedName; | 441 | mData->formattedName = formattedName; |
440 | } | 442 | } |
441 | 443 | ||
442 | QString Addressee::formattedName() const | 444 | QString Addressee::formattedName() const |
443 | { | 445 | { |
444 | return mData->formattedName; | 446 | return mData->formattedName; |
445 | } | 447 | } |
@@ -1245,97 +1247,97 @@ void Addressee::removeEmail( const QString &email ) | |||
1245 | 1247 | ||
1246 | QString Addressee::preferredEmail() const | 1248 | QString Addressee::preferredEmail() const |
1247 | { | 1249 | { |
1248 | if ( mData->emails.count() == 0 ) return QString::null; | 1250 | if ( mData->emails.count() == 0 ) return QString::null; |
1249 | else return mData->emails.first(); | 1251 | else return mData->emails.first(); |
1250 | } | 1252 | } |
1251 | 1253 | ||
1252 | QStringList Addressee::emails() const | 1254 | QStringList Addressee::emails() const |
1253 | { | 1255 | { |
1254 | return mData->emails; | 1256 | return mData->emails; |
1255 | } | 1257 | } |
1256 | void Addressee::setEmails( const QStringList& emails ) { | 1258 | void Addressee::setEmails( const QStringList& emails ) { |
1257 | detach(); | 1259 | detach(); |
1258 | mData->emails = emails; | 1260 | mData->emails = emails; |
1259 | } | 1261 | } |
1260 | void Addressee::insertPhoneNumber( const PhoneNumber &phoneNumber ) | 1262 | void Addressee::insertPhoneNumber( const PhoneNumber &phoneNumber ) |
1261 | { | 1263 | { |
1262 | detach(); | 1264 | detach(); |
1263 | mData->empty = false; | 1265 | mData->empty = false; |
1264 | 1266 | ||
1265 | PhoneNumber::List::Iterator it; | 1267 | PhoneNumber::List::Iterator it; |
1266 | for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { | 1268 | for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { |
1267 | if ( (*it).id() == phoneNumber.id() ) { | 1269 | if ( (*it).id() == phoneNumber.id() ) { |
1268 | *it = phoneNumber; | 1270 | *it = phoneNumber; |
1269 | return; | 1271 | return; |
1270 | } | 1272 | } |
1271 | } | 1273 | } |
1272 | mData->phoneNumbers.append( phoneNumber ); | 1274 | mData->phoneNumbers.append( phoneNumber ); |
1273 | } | 1275 | } |
1274 | 1276 | ||
1275 | void Addressee::removePhoneNumber( const PhoneNumber &phoneNumber ) | 1277 | void Addressee::removePhoneNumber( const PhoneNumber &phoneNumber ) |
1276 | { | 1278 | { |
1277 | detach(); | 1279 | detach(); |
1278 | 1280 | ||
1279 | PhoneNumber::List::Iterator it; | 1281 | PhoneNumber::List::Iterator it; |
1280 | for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { | 1282 | for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { |
1281 | if ( (*it).id() == phoneNumber.id() ) { | 1283 | if ( (*it).id() == phoneNumber.id() ) { |
1282 | mData->phoneNumbers.remove( it ); | 1284 | mData->phoneNumbers.remove( it ); |
1283 | return; | 1285 | return; |
1284 | } | 1286 | } |
1285 | } | 1287 | } |
1286 | } | 1288 | } |
1287 | 1289 | ||
1288 | PhoneNumber Addressee::phoneNumber( int type ) const | 1290 | PhoneNumber Addressee::phoneNumber( int type ) const |
1289 | { | 1291 | { |
1290 | PhoneNumber phoneNumber( "", type ); | 1292 | PhoneNumber phoneNumber( "", type ); |
1291 | PhoneNumber::List::ConstIterator it; | 1293 | PhoneNumber::List::ConstIterator it; |
1292 | for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { | 1294 | for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { |
1293 | if ( matchBinaryPattern( (*it).type(), type ) ) { | 1295 | if ( matchBinaryPatternP( (*it).type(), type ) ) { |
1294 | if ( (*it).type() & PhoneNumber::Pref ) | 1296 | if ( (*it).type() & PhoneNumber::Pref ) |
1295 | return (*it); | 1297 | return (*it); |
1296 | else if ( phoneNumber.number().isEmpty() ) | 1298 | else if ( phoneNumber.number().isEmpty() ) |
1297 | phoneNumber = (*it); | 1299 | phoneNumber = (*it); |
1298 | } | 1300 | } |
1299 | } | 1301 | } |
1300 | 1302 | ||
1301 | return phoneNumber; | 1303 | return phoneNumber; |
1302 | } | 1304 | } |
1303 | 1305 | ||
1304 | PhoneNumber::List Addressee::phoneNumbers() const | 1306 | PhoneNumber::List Addressee::phoneNumbers() const |
1305 | { | 1307 | { |
1306 | return mData->phoneNumbers; | 1308 | return mData->phoneNumbers; |
1307 | } | 1309 | } |
1308 | 1310 | ||
1309 | PhoneNumber::List Addressee::phoneNumbers( int type ) const | 1311 | PhoneNumber::List Addressee::phoneNumbers( int type ) const |
1310 | { | 1312 | { |
1311 | PhoneNumber::List list; | 1313 | PhoneNumber::List list; |
1312 | 1314 | ||
1313 | PhoneNumber::List::ConstIterator it; | 1315 | PhoneNumber::List::ConstIterator it; |
1314 | for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { | 1316 | for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { |
1315 | if ( matchBinaryPattern( (*it).type(), type ) ) { | 1317 | if ( matchBinaryPattern( (*it).type(), type ) ) { |
1316 | list.append( *it ); | 1318 | list.append( *it ); |
1317 | } | 1319 | } |
1318 | } | 1320 | } |
1319 | return list; | 1321 | return list; |
1320 | } | 1322 | } |
1321 | 1323 | ||
1322 | PhoneNumber Addressee::findPhoneNumber( const QString &id ) const | 1324 | PhoneNumber Addressee::findPhoneNumber( const QString &id ) const |
1323 | { | 1325 | { |
1324 | PhoneNumber::List::ConstIterator it; | 1326 | PhoneNumber::List::ConstIterator it; |
1325 | for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { | 1327 | for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { |
1326 | if ( (*it).id() == id ) { | 1328 | if ( (*it).id() == id ) { |
1327 | return *it; | 1329 | return *it; |
1328 | } | 1330 | } |
1329 | } | 1331 | } |
1330 | return PhoneNumber(); | 1332 | return PhoneNumber(); |
1331 | } | 1333 | } |
1332 | 1334 | ||
1333 | void Addressee::insertKey( const Key &key ) | 1335 | void Addressee::insertKey( const Key &key ) |
1334 | { | 1336 | { |
1335 | detach(); | 1337 | detach(); |
1336 | mData->empty = false; | 1338 | mData->empty = false; |
1337 | 1339 | ||
1338 | Key::List::Iterator it; | 1340 | Key::List::Iterator it; |
1339 | for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) { | 1341 | for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) { |
1340 | if ( (*it).id() == key.id() ) { | 1342 | if ( (*it).id() == key.id() ) { |
1341 | *it = key; | 1343 | *it = key; |
@@ -1482,97 +1484,97 @@ void Addressee::dump() const | |||
1482 | 1484 | ||
1483 | kdDebug(5700) << " Keys {" << endl; | 1485 | kdDebug(5700) << " Keys {" << endl; |
1484 | Key::List k = keys(); | 1486 | Key::List k = keys(); |
1485 | Key::List::ConstIterator it4; | 1487 | Key::List::ConstIterator it4; |
1486 | for( it4 = k.begin(); it4 != k.end(); ++it4 ) { | 1488 | for( it4 = k.begin(); it4 != k.end(); ++it4 ) { |
1487 | kdDebug(5700) << " Type: " << int((*it4).type()) << | 1489 | kdDebug(5700) << " Type: " << int((*it4).type()) << |
1488 | " Key: " << (*it4).textData() << | 1490 | " Key: " << (*it4).textData() << |
1489 | " CustomString: " << (*it4).customTypeString() << endl; | 1491 | " CustomString: " << (*it4).customTypeString() << endl; |
1490 | } | 1492 | } |
1491 | kdDebug(5700) << " }" << endl; | 1493 | kdDebug(5700) << " }" << endl; |
1492 | 1494 | ||
1493 | kdDebug(5700) << "}" << endl; | 1495 | kdDebug(5700) << "}" << endl; |
1494 | } | 1496 | } |
1495 | 1497 | ||
1496 | 1498 | ||
1497 | void Addressee::insertAddress( const Address &address ) | 1499 | void Addressee::insertAddress( const Address &address ) |
1498 | { | 1500 | { |
1499 | detach(); | 1501 | detach(); |
1500 | mData->empty = false; | 1502 | mData->empty = false; |
1501 | 1503 | ||
1502 | Address::List::Iterator it; | 1504 | Address::List::Iterator it; |
1503 | for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) { | 1505 | for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) { |
1504 | if ( (*it).id() == address.id() ) { | 1506 | if ( (*it).id() == address.id() ) { |
1505 | *it = address; | 1507 | *it = address; |
1506 | return; | 1508 | return; |
1507 | } | 1509 | } |
1508 | } | 1510 | } |
1509 | mData->addresses.append( address ); | 1511 | mData->addresses.append( address ); |
1510 | } | 1512 | } |
1511 | 1513 | ||
1512 | void Addressee::removeAddress( const Address &address ) | 1514 | void Addressee::removeAddress( const Address &address ) |
1513 | { | 1515 | { |
1514 | detach(); | 1516 | detach(); |
1515 | 1517 | ||
1516 | Address::List::Iterator it; | 1518 | Address::List::Iterator it; |
1517 | for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) { | 1519 | for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) { |
1518 | if ( (*it).id() == address.id() ) { | 1520 | if ( (*it).id() == address.id() ) { |
1519 | mData->addresses.remove( it ); | 1521 | mData->addresses.remove( it ); |
1520 | return; | 1522 | return; |
1521 | } | 1523 | } |
1522 | } | 1524 | } |
1523 | } | 1525 | } |
1524 | 1526 | ||
1525 | Address Addressee::address( int type ) const | 1527 | Address Addressee::address( int type ) const |
1526 | { | 1528 | { |
1527 | Address address( type ); | 1529 | Address address( type ); |
1528 | Address::List::ConstIterator it; | 1530 | Address::List::ConstIterator it; |
1529 | for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) { | 1531 | for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) { |
1530 | if ( matchBinaryPattern( (*it).type(), type ) ) { | 1532 | if ( matchBinaryPatternA( (*it).type(), type ) ) { |
1531 | if ( (*it).type() & Address::Pref ) | 1533 | if ( (*it).type() & Address::Pref ) |
1532 | return (*it); | 1534 | return (*it); |
1533 | else if ( address.isEmpty() ) | 1535 | else if ( address.isEmpty() ) |
1534 | address = (*it); | 1536 | address = (*it); |
1535 | } | 1537 | } |
1536 | } | 1538 | } |
1537 | 1539 | ||
1538 | return address; | 1540 | return address; |
1539 | } | 1541 | } |
1540 | 1542 | ||
1541 | Address::List Addressee::addresses() const | 1543 | Address::List Addressee::addresses() const |
1542 | { | 1544 | { |
1543 | return mData->addresses; | 1545 | return mData->addresses; |
1544 | } | 1546 | } |
1545 | 1547 | ||
1546 | Address::List Addressee::addresses( int type ) const | 1548 | Address::List Addressee::addresses( int type ) const |
1547 | { | 1549 | { |
1548 | Address::List list; | 1550 | Address::List list; |
1549 | 1551 | ||
1550 | Address::List::ConstIterator it; | 1552 | Address::List::ConstIterator it; |
1551 | for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) { | 1553 | for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) { |
1552 | if ( matchBinaryPattern( (*it).type(), type ) ) { | 1554 | if ( matchBinaryPattern( (*it).type(), type ) ) { |
1553 | list.append( *it ); | 1555 | list.append( *it ); |
1554 | } | 1556 | } |
1555 | } | 1557 | } |
1556 | 1558 | ||
1557 | return list; | 1559 | return list; |
1558 | } | 1560 | } |
1559 | 1561 | ||
1560 | Address Addressee::findAddress( const QString &id ) const | 1562 | Address Addressee::findAddress( const QString &id ) const |
1561 | { | 1563 | { |
1562 | Address::List::ConstIterator it; | 1564 | Address::List::ConstIterator it; |
1563 | for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) { | 1565 | for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) { |
1564 | if ( (*it).id() == id ) { | 1566 | if ( (*it).id() == id ) { |
1565 | return *it; | 1567 | return *it; |
1566 | } | 1568 | } |
1567 | } | 1569 | } |
1568 | return Address(); | 1570 | return Address(); |
1569 | } | 1571 | } |
1570 | 1572 | ||
1571 | void Addressee::insertCategory( const QString &c ) | 1573 | void Addressee::insertCategory( const QString &c ) |
1572 | { | 1574 | { |
1573 | detach(); | 1575 | detach(); |
1574 | mData->empty = false; | 1576 | mData->empty = false; |
1575 | 1577 | ||
1576 | if ( mData->categories.contains( c ) ) return; | 1578 | if ( mData->categories.contains( c ) ) return; |
1577 | 1579 | ||
1578 | mData->categories.append( c ); | 1580 | mData->categories.append( c ); |
@@ -1790,62 +1792,78 @@ QDataStream &KABC::operator<<( QDataStream &s, const Addressee &a ) | |||
1790 | s << a.mData->categories; | 1792 | s << a.mData->categories; |
1791 | s << a.mData->custom; | 1793 | s << a.mData->custom; |
1792 | s << a.mData->keys; | 1794 | s << a.mData->keys; |
1793 | return s; | 1795 | return s; |
1794 | } | 1796 | } |
1795 | 1797 | ||
1796 | QDataStream &KABC::operator>>( QDataStream &s, Addressee &a ) | 1798 | QDataStream &KABC::operator>>( QDataStream &s, Addressee &a ) |
1797 | { | 1799 | { |
1798 | if (!a.mData) return s; | 1800 | if (!a.mData) return s; |
1799 | 1801 | ||
1800 | s >> a.mData->uid; | 1802 | s >> a.mData->uid; |
1801 | 1803 | ||
1802 | s >> a.mData->name; | 1804 | s >> a.mData->name; |
1803 | s >> a.mData->formattedName; | 1805 | s >> a.mData->formattedName; |
1804 | s >> a.mData->familyName; | 1806 | s >> a.mData->familyName; |
1805 | s >> a.mData->givenName; | 1807 | s >> a.mData->givenName; |
1806 | s >> a.mData->additionalName; | 1808 | s >> a.mData->additionalName; |
1807 | s >> a.mData->prefix; | 1809 | s >> a.mData->prefix; |
1808 | s >> a.mData->suffix; | 1810 | s >> a.mData->suffix; |
1809 | s >> a.mData->nickName; | 1811 | s >> a.mData->nickName; |
1810 | s >> a.mData->birthday; | 1812 | s >> a.mData->birthday; |
1811 | s >> a.mData->mailer; | 1813 | s >> a.mData->mailer; |
1812 | s >> a.mData->timeZone; | 1814 | s >> a.mData->timeZone; |
1813 | s >> a.mData->geo; | 1815 | s >> a.mData->geo; |
1814 | s >> a.mData->title; | 1816 | s >> a.mData->title; |
1815 | s >> a.mData->role; | 1817 | s >> a.mData->role; |
1816 | s >> a.mData->organization; | 1818 | s >> a.mData->organization; |
1817 | s >> a.mData->note; | 1819 | s >> a.mData->note; |
1818 | s >> a.mData->productId; | 1820 | s >> a.mData->productId; |
1819 | s >> a.mData->revision; | 1821 | s >> a.mData->revision; |
1820 | s >> a.mData->sortString; | 1822 | s >> a.mData->sortString; |
1821 | s >> a.mData->url; | 1823 | s >> a.mData->url; |
1822 | s >> a.mData->secrecy; | 1824 | s >> a.mData->secrecy; |
1823 | s >> a.mData->logo; | 1825 | s >> a.mData->logo; |
1824 | s >> a.mData->photo; | 1826 | s >> a.mData->photo; |
1825 | s >> a.mData->sound; | 1827 | s >> a.mData->sound; |
1826 | s >> a.mData->agent; | 1828 | s >> a.mData->agent; |
1827 | s >> a.mData->phoneNumbers; | 1829 | s >> a.mData->phoneNumbers; |
1828 | s >> a.mData->addresses; | 1830 | s >> a.mData->addresses; |
1829 | s >> a.mData->emails; | 1831 | s >> a.mData->emails; |
1830 | s >> a.mData->categories; | 1832 | s >> a.mData->categories; |
1831 | s >> a.mData->custom; | 1833 | s >> a.mData->custom; |
1832 | s >> a.mData->keys; | 1834 | s >> a.mData->keys; |
1833 | 1835 | ||
1834 | a.mData->empty = false; | 1836 | a.mData->empty = false; |
1835 | 1837 | ||
1836 | return s; | 1838 | return s; |
1837 | } | 1839 | } |
1838 | |||
1839 | bool matchBinaryPattern( int value, int pattern ) | 1840 | bool matchBinaryPattern( int value, int pattern ) |
1840 | { | 1841 | { |
1841 | /** | 1842 | /** |
1842 | We want to match all telephonnumbers/addresses which have the bits in the | 1843 | We want to match all telephonnumbers/addresses which have the bits in the |
1843 | pattern set. More are allowed. | 1844 | pattern set. More are allowed. |
1844 | if pattern == 0 we have a special handling, then we want only those with | 1845 | if pattern == 0 we have a special handling, then we want only those with |
1845 | exactly no bit set. | 1846 | exactly no bit set. |
1846 | */ | 1847 | */ |
1847 | if ( pattern == 0 ) | 1848 | if ( pattern == 0 ) |
1848 | return ( value == 0 ); | 1849 | return ( value == 0 ); |
1849 | else | 1850 | else |
1850 | return ( pattern == ( pattern & value ) ); | 1851 | return ( pattern == ( pattern & value ) ); |
1851 | } | 1852 | } |
1853 | |||
1854 | bool matchBinaryPatternP( int value, int pattern ) | ||
1855 | { | ||
1856 | |||
1857 | if ( pattern == 0 ) | ||
1858 | return ( value == 0 ); | ||
1859 | else | ||
1860 | return ( (pattern |PhoneNumber::Pref ) == ( value |PhoneNumber::Pref ) ); | ||
1861 | } | ||
1862 | bool matchBinaryPatternA( int value, int pattern ) | ||
1863 | { | ||
1864 | |||
1865 | if ( pattern == 0 ) | ||
1866 | return ( value == 0 ); | ||
1867 | else | ||
1868 | return ( (pattern | Address::Pref) == ( value | Address::Pref ) ); | ||
1869 | } | ||