-rw-r--r-- | kabc/addressee.cpp | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/kabc/addressee.cpp b/kabc/addressee.cpp index 18b4d58..39d14bb 100644 --- a/kabc/addressee.cpp +++ b/kabc/addressee.cpp | |||
@@ -1306,385 +1306,386 @@ Sound Addressee::sound() const | |||
1306 | 1306 | ||
1307 | QString Addressee::soundLabel() | 1307 | QString Addressee::soundLabel() |
1308 | { | 1308 | { |
1309 | return i18n("Sound"); | 1309 | return i18n("Sound"); |
1310 | } | 1310 | } |
1311 | 1311 | ||
1312 | 1312 | ||
1313 | void Addressee::setAgent( const Agent &agent ) | 1313 | void Addressee::setAgent( const Agent &agent ) |
1314 | { | 1314 | { |
1315 | if ( agent == mData->agent ) return; | 1315 | if ( agent == mData->agent ) return; |
1316 | detach(); | 1316 | detach(); |
1317 | mData->empty = false; | 1317 | mData->empty = false; |
1318 | mData->agent = agent; | 1318 | mData->agent = agent; |
1319 | } | 1319 | } |
1320 | 1320 | ||
1321 | Agent Addressee::agent() const | 1321 | Agent Addressee::agent() const |
1322 | { | 1322 | { |
1323 | return mData->agent; | 1323 | return mData->agent; |
1324 | } | 1324 | } |
1325 | 1325 | ||
1326 | QString Addressee::agentLabel() | 1326 | QString Addressee::agentLabel() |
1327 | { | 1327 | { |
1328 | return i18n("Agent"); | 1328 | return i18n("Agent"); |
1329 | } | 1329 | } |
1330 | 1330 | ||
1331 | 1331 | ||
1332 | 1332 | ||
1333 | void Addressee::setNameFromString( const QString &str ) | 1333 | void Addressee::setNameFromString( const QString &str ) |
1334 | { | 1334 | { |
1335 | setFormattedName( str ); | 1335 | setFormattedName( str ); |
1336 | setName( str ); | 1336 | setName( str ); |
1337 | 1337 | ||
1338 | static bool first = true; | 1338 | static bool first = true; |
1339 | static QStringList titles; | 1339 | static QStringList titles; |
1340 | static QStringList suffixes; | 1340 | static QStringList suffixes; |
1341 | static QStringList prefixes; | 1341 | static QStringList prefixes; |
1342 | 1342 | ||
1343 | if ( first ) { | 1343 | if ( first ) { |
1344 | first = false; | 1344 | first = false; |
1345 | titles += i18n( "Dr." ); | 1345 | titles += i18n( "Dr." ); |
1346 | titles += i18n( "Miss" ); | 1346 | titles += i18n( "Miss" ); |
1347 | titles += i18n( "Mr." ); | 1347 | titles += i18n( "Mr." ); |
1348 | titles += i18n( "Mrs." ); | 1348 | titles += i18n( "Mrs." ); |
1349 | titles += i18n( "Ms." ); | 1349 | titles += i18n( "Ms." ); |
1350 | titles += i18n( "Prof." ); | 1350 | titles += i18n( "Prof." ); |
1351 | 1351 | ||
1352 | suffixes += i18n( "I" ); | 1352 | suffixes += i18n( "I" ); |
1353 | suffixes += i18n( "II" ); | 1353 | suffixes += i18n( "II" ); |
1354 | suffixes += i18n( "III" ); | 1354 | suffixes += i18n( "III" ); |
1355 | suffixes += i18n( "Jr." ); | 1355 | suffixes += i18n( "Jr." ); |
1356 | suffixes += i18n( "Sr." ); | 1356 | suffixes += i18n( "Sr." ); |
1357 | 1357 | ||
1358 | prefixes += "van"; | 1358 | prefixes += "van"; |
1359 | prefixes += "von"; | 1359 | prefixes += "von"; |
1360 | prefixes += "de"; | 1360 | prefixes += "de"; |
1361 | 1361 | ||
1362 | KConfig config( locateLocal( "config", "kabcrc") ); | 1362 | KConfig config( locateLocal( "config", "kabcrc") ); |
1363 | config.setGroup( "General" ); | 1363 | config.setGroup( "General" ); |
1364 | titles += config.readListEntry( "Prefixes" ); | 1364 | titles += config.readListEntry( "Prefixes" ); |
1365 | titles.remove( "" ); | 1365 | titles.remove( "" ); |
1366 | prefixes += config.readListEntry( "Inclusions" ); | 1366 | prefixes += config.readListEntry( "Inclusions" ); |
1367 | prefixes.remove( "" ); | 1367 | prefixes.remove( "" ); |
1368 | suffixes += config.readListEntry( "Suffixes" ); | 1368 | suffixes += config.readListEntry( "Suffixes" ); |
1369 | suffixes.remove( "" ); | 1369 | suffixes.remove( "" ); |
1370 | } | 1370 | } |
1371 | 1371 | ||
1372 | // clear all name parts | 1372 | // clear all name parts |
1373 | setPrefix( "" ); | 1373 | setPrefix( "" ); |
1374 | setGivenName( "" ); | 1374 | setGivenName( "" ); |
1375 | setAdditionalName( "" ); | 1375 | setAdditionalName( "" ); |
1376 | setFamilyName( "" ); | 1376 | setFamilyName( "" ); |
1377 | setSuffix( "" ); | 1377 | setSuffix( "" ); |
1378 | 1378 | ||
1379 | if ( str.isEmpty() ) | 1379 | if ( str.isEmpty() ) |
1380 | return; | 1380 | return; |
1381 | 1381 | ||
1382 | int i = str.find(','); | 1382 | int i = str.find(','); |
1383 | if( i < 0 ) { | 1383 | if( i < 0 ) { |
1384 | QStringList parts = QStringList::split( " ", str ); | 1384 | QStringList parts = QStringList::split( " ", str ); |
1385 | int leftOffset = 0; | 1385 | int leftOffset = 0; |
1386 | int rightOffset = parts.count() - 1; | 1386 | int rightOffset = parts.count() - 1; |
1387 | 1387 | ||
1388 | QString suffix; | 1388 | QString suffix; |
1389 | while ( rightOffset >= 0 ) { | 1389 | while ( rightOffset >= 0 ) { |
1390 | if ( suffixes.contains( parts[ rightOffset ] ) ) { | 1390 | if ( suffixes.contains( parts[ rightOffset ] ) ) { |
1391 | suffix.prepend(parts[ rightOffset ] + (suffix.isEmpty() ? "" : " ")); | 1391 | suffix.prepend(parts[ rightOffset ] + (suffix.isEmpty() ? "" : " ")); |
1392 | rightOffset--; | 1392 | rightOffset--; |
1393 | } else | 1393 | } else |
1394 | break; | 1394 | break; |
1395 | } | 1395 | } |
1396 | setSuffix( suffix ); | 1396 | setSuffix( suffix ); |
1397 | 1397 | ||
1398 | if ( rightOffset < 0 ) | 1398 | if ( rightOffset < 0 ) |
1399 | return; | 1399 | return; |
1400 | 1400 | ||
1401 | if ( rightOffset - 1 >= 0 && prefixes.contains( parts[ rightOffset - 1 ].lower() ) ) { | 1401 | if ( rightOffset - 1 >= 0 && prefixes.contains( parts[ rightOffset - 1 ].lower() ) ) { |
1402 | setFamilyName( parts[ rightOffset - 1 ] + " " + parts[ rightOffset ] ); | 1402 | setFamilyName( parts[ rightOffset - 1 ] + " " + parts[ rightOffset ] ); |
1403 | rightOffset--; | 1403 | rightOffset--; |
1404 | } else | 1404 | } else |
1405 | setFamilyName( parts[ rightOffset ] ); | 1405 | setFamilyName( parts[ rightOffset ] ); |
1406 | 1406 | ||
1407 | QString prefix; | 1407 | QString prefix; |
1408 | while ( leftOffset < rightOffset ) { | 1408 | while ( leftOffset < rightOffset ) { |
1409 | if ( titles.contains( parts[ leftOffset ] ) ) { | 1409 | if ( titles.contains( parts[ leftOffset ] ) ) { |
1410 | prefix.append( ( prefix.isEmpty() ? "" : " ") + parts[ leftOffset ] ); | 1410 | prefix.append( ( prefix.isEmpty() ? "" : " ") + parts[ leftOffset ] ); |
1411 | leftOffset++; | 1411 | leftOffset++; |
1412 | } else | 1412 | } else |
1413 | break; | 1413 | break; |
1414 | } | 1414 | } |
1415 | setPrefix( prefix ); | 1415 | setPrefix( prefix ); |
1416 | 1416 | ||
1417 | if ( leftOffset < rightOffset ) { | 1417 | if ( leftOffset < rightOffset ) { |
1418 | setGivenName( parts[ leftOffset ] ); | 1418 | setGivenName( parts[ leftOffset ] ); |
1419 | leftOffset++; | 1419 | leftOffset++; |
1420 | } | 1420 | } |
1421 | 1421 | ||
1422 | QString additionalName; | 1422 | QString additionalName; |
1423 | while ( leftOffset < rightOffset ) { | 1423 | while ( leftOffset < rightOffset ) { |
1424 | additionalName.append( ( additionalName.isEmpty() ? "" : " ") + parts[ leftOffset ] ); | 1424 | additionalName.append( ( additionalName.isEmpty() ? "" : " ") + parts[ leftOffset ] ); |
1425 | leftOffset++; | 1425 | leftOffset++; |
1426 | } | 1426 | } |
1427 | setAdditionalName( additionalName ); | 1427 | setAdditionalName( additionalName ); |
1428 | } else { | 1428 | } else { |
1429 | QString part1 = str.left( i ); | 1429 | QString part1 = str.left( i ); |
1430 | QString part2 = str.mid( i + 1 ); | 1430 | QString part2 = str.mid( i + 1 ); |
1431 | 1431 | ||
1432 | QStringList parts = QStringList::split( " ", part1 ); | 1432 | QStringList parts = QStringList::split( " ", part1 ); |
1433 | int leftOffset = 0; | 1433 | int leftOffset = 0; |
1434 | int rightOffset = parts.count() - 1; | 1434 | int rightOffset = parts.count() - 1; |
1435 | 1435 | ||
1436 | QString suffix; | 1436 | QString suffix; |
1437 | while ( rightOffset >= 0 ) { | 1437 | while ( rightOffset >= 0 ) { |
1438 | if ( suffixes.contains( parts[ rightOffset ] ) ) { | 1438 | if ( suffixes.contains( parts[ rightOffset ] ) ) { |
1439 | suffix.prepend(parts[ rightOffset ] + (suffix.isEmpty() ? "" : " ")); | 1439 | suffix.prepend(parts[ rightOffset ] + (suffix.isEmpty() ? "" : " ")); |
1440 | rightOffset--; | 1440 | rightOffset--; |
1441 | } else | 1441 | } else |
1442 | break; | 1442 | break; |
1443 | } | 1443 | } |
1444 | setSuffix( suffix ); | 1444 | setSuffix( suffix ); |
1445 | 1445 | ||
1446 | if ( rightOffset - 1 >= 0 && prefixes.contains( parts[ rightOffset - 1 ].lower() ) ) { | 1446 | if ( rightOffset - 1 >= 0 && prefixes.contains( parts[ rightOffset - 1 ].lower() ) ) { |
1447 | setFamilyName( parts[ rightOffset - 1 ] + " " + parts[ rightOffset ] ); | 1447 | setFamilyName( parts[ rightOffset - 1 ] + " " + parts[ rightOffset ] ); |
1448 | rightOffset--; | 1448 | rightOffset--; |
1449 | } else | 1449 | } else |
1450 | setFamilyName( parts[ rightOffset ] ); | 1450 | setFamilyName( parts[ rightOffset ] ); |
1451 | 1451 | ||
1452 | QString prefix; | 1452 | QString prefix; |
1453 | while ( leftOffset < rightOffset ) { | 1453 | while ( leftOffset < rightOffset ) { |
1454 | if ( titles.contains( parts[ leftOffset ] ) ) { | 1454 | if ( titles.contains( parts[ leftOffset ] ) ) { |
1455 | prefix.append( ( prefix.isEmpty() ? "" : " ") + parts[ leftOffset ] ); | 1455 | prefix.append( ( prefix.isEmpty() ? "" : " ") + parts[ leftOffset ] ); |
1456 | leftOffset++; | 1456 | leftOffset++; |
1457 | } else | 1457 | } else |
1458 | break; | 1458 | break; |
1459 | } | 1459 | } |
1460 | 1460 | ||
1461 | parts = QStringList::split( " ", part2 ); | 1461 | parts = QStringList::split( " ", part2 ); |
1462 | 1462 | ||
1463 | leftOffset = 0; | 1463 | leftOffset = 0; |
1464 | rightOffset = parts.count(); | 1464 | rightOffset = parts.count(); |
1465 | 1465 | ||
1466 | while ( leftOffset < rightOffset ) { | 1466 | while ( leftOffset < rightOffset ) { |
1467 | if ( titles.contains( parts[ leftOffset ] ) ) { | 1467 | if ( titles.contains( parts[ leftOffset ] ) ) { |
1468 | prefix.append( ( prefix.isEmpty() ? "" : " ") + parts[ leftOffset ] ); | 1468 | prefix.append( ( prefix.isEmpty() ? "" : " ") + parts[ leftOffset ] ); |
1469 | leftOffset++; | 1469 | leftOffset++; |
1470 | } else | 1470 | } else |
1471 | break; | 1471 | break; |
1472 | } | 1472 | } |
1473 | setPrefix( prefix ); | 1473 | setPrefix( prefix ); |
1474 | 1474 | ||
1475 | if ( leftOffset < rightOffset ) { | 1475 | if ( leftOffset < rightOffset ) { |
1476 | setGivenName( parts[ leftOffset ] ); | 1476 | setGivenName( parts[ leftOffset ] ); |
1477 | leftOffset++; | 1477 | leftOffset++; |
1478 | } | 1478 | } |
1479 | 1479 | ||
1480 | QString additionalName; | 1480 | QString additionalName; |
1481 | while ( leftOffset < rightOffset ) { | 1481 | while ( leftOffset < rightOffset ) { |
1482 | additionalName.append( ( additionalName.isEmpty() ? "" : " ") + parts[ leftOffset ] ); | 1482 | additionalName.append( ( additionalName.isEmpty() ? "" : " ") + parts[ leftOffset ] ); |
1483 | leftOffset++; | 1483 | leftOffset++; |
1484 | } | 1484 | } |
1485 | setAdditionalName( additionalName ); | 1485 | setAdditionalName( additionalName ); |
1486 | } | 1486 | } |
1487 | } | 1487 | } |
1488 | 1488 | ||
1489 | QString Addressee::realName() const | 1489 | QString Addressee::realName() const |
1490 | { | 1490 | { |
1491 | if ( !formattedName().isEmpty() ) | 1491 | if ( !formattedName().isEmpty() ) |
1492 | return formattedName(); | 1492 | return formattedName(); |
1493 | 1493 | ||
1494 | QString n = assembledName(); | 1494 | QString n = assembledName(); |
1495 | 1495 | ||
1496 | if ( n.isEmpty() ) | 1496 | if ( n.isEmpty() ) |
1497 | n = name(); | 1497 | n = name(); |
1498 | 1498 | if ( n.isEmpty() ) | |
1499 | n = organization(); | ||
1499 | return n; | 1500 | return n; |
1500 | } | 1501 | } |
1501 | 1502 | ||
1502 | QString Addressee::assembledName() const | 1503 | QString Addressee::assembledName() const |
1503 | { | 1504 | { |
1504 | QString name = prefix() + " " + givenName() + " " + additionalName() + " " + | 1505 | QString name = prefix() + " " + givenName() + " " + additionalName() + " " + |
1505 | familyName() + " " + suffix(); | 1506 | familyName() + " " + suffix(); |
1506 | 1507 | ||
1507 | return name.simplifyWhiteSpace(); | 1508 | return name.simplifyWhiteSpace(); |
1508 | } | 1509 | } |
1509 | 1510 | ||
1510 | QString Addressee::fullEmail( const QString &email ) const | 1511 | QString Addressee::fullEmail( const QString &email ) const |
1511 | { | 1512 | { |
1512 | QString e; | 1513 | QString e; |
1513 | if ( email.isNull() ) { | 1514 | if ( email.isNull() ) { |
1514 | e = preferredEmail(); | 1515 | e = preferredEmail(); |
1515 | } else { | 1516 | } else { |
1516 | e = email; | 1517 | e = email; |
1517 | } | 1518 | } |
1518 | if ( e.isEmpty() ) return QString::null; | 1519 | if ( e.isEmpty() ) return QString::null; |
1519 | 1520 | ||
1520 | QString text; | 1521 | QString text; |
1521 | if ( realName().isEmpty() ) | 1522 | if ( realName().isEmpty() ) |
1522 | text = e; | 1523 | text = e; |
1523 | else | 1524 | else |
1524 | text = assembledName() + " <" + e + ">"; | 1525 | text = assembledName() + " <" + e + ">"; |
1525 | 1526 | ||
1526 | return text; | 1527 | return text; |
1527 | } | 1528 | } |
1528 | 1529 | ||
1529 | void Addressee::insertEmail( const QString &email, bool preferred ) | 1530 | void Addressee::insertEmail( const QString &email, bool preferred ) |
1530 | { | 1531 | { |
1531 | detach(); | 1532 | detach(); |
1532 | 1533 | ||
1533 | QStringList::Iterator it = mData->emails.find( email ); | 1534 | QStringList::Iterator it = mData->emails.find( email ); |
1534 | 1535 | ||
1535 | if ( it != mData->emails.end() ) { | 1536 | if ( it != mData->emails.end() ) { |
1536 | if ( !preferred || it == mData->emails.begin() ) return; | 1537 | if ( !preferred || it == mData->emails.begin() ) return; |
1537 | mData->emails.remove( it ); | 1538 | mData->emails.remove( it ); |
1538 | mData->emails.prepend( email ); | 1539 | mData->emails.prepend( email ); |
1539 | } else { | 1540 | } else { |
1540 | if ( preferred ) { | 1541 | if ( preferred ) { |
1541 | mData->emails.prepend( email ); | 1542 | mData->emails.prepend( email ); |
1542 | } else { | 1543 | } else { |
1543 | mData->emails.append( email ); | 1544 | mData->emails.append( email ); |
1544 | } | 1545 | } |
1545 | } | 1546 | } |
1546 | } | 1547 | } |
1547 | 1548 | ||
1548 | void Addressee::removeEmail( const QString &email ) | 1549 | void Addressee::removeEmail( const QString &email ) |
1549 | { | 1550 | { |
1550 | detach(); | 1551 | detach(); |
1551 | 1552 | ||
1552 | QStringList::Iterator it = mData->emails.find( email ); | 1553 | QStringList::Iterator it = mData->emails.find( email ); |
1553 | if ( it == mData->emails.end() ) return; | 1554 | if ( it == mData->emails.end() ) return; |
1554 | 1555 | ||
1555 | mData->emails.remove( it ); | 1556 | mData->emails.remove( it ); |
1556 | } | 1557 | } |
1557 | 1558 | ||
1558 | QString Addressee::preferredEmail() const | 1559 | QString Addressee::preferredEmail() const |
1559 | { | 1560 | { |
1560 | if ( mData->emails.count() == 0 ) return QString::null; | 1561 | if ( mData->emails.count() == 0 ) return QString::null; |
1561 | else return mData->emails.first(); | 1562 | else return mData->emails.first(); |
1562 | } | 1563 | } |
1563 | 1564 | ||
1564 | QStringList Addressee::emails() const | 1565 | QStringList Addressee::emails() const |
1565 | { | 1566 | { |
1566 | return mData->emails; | 1567 | return mData->emails; |
1567 | } | 1568 | } |
1568 | void Addressee::setEmails( const QStringList& emails ) { | 1569 | void Addressee::setEmails( const QStringList& emails ) { |
1569 | detach(); | 1570 | detach(); |
1570 | mData->emails = emails; | 1571 | mData->emails = emails; |
1571 | } | 1572 | } |
1572 | void Addressee::insertPhoneNumber( const PhoneNumber &phoneNumber ) | 1573 | void Addressee::insertPhoneNumber( const PhoneNumber &phoneNumber ) |
1573 | { | 1574 | { |
1574 | detach(); | 1575 | detach(); |
1575 | mData->empty = false; | 1576 | mData->empty = false; |
1576 | 1577 | ||
1577 | PhoneNumber::List::Iterator it; | 1578 | PhoneNumber::List::Iterator it; |
1578 | for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { | 1579 | for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { |
1579 | if ( (*it).id() == phoneNumber.id() ) { | 1580 | if ( (*it).id() == phoneNumber.id() ) { |
1580 | *it = phoneNumber; | 1581 | *it = phoneNumber; |
1581 | return; | 1582 | return; |
1582 | } | 1583 | } |
1583 | } | 1584 | } |
1584 | mData->phoneNumbers.append( phoneNumber ); | 1585 | mData->phoneNumbers.append( phoneNumber ); |
1585 | } | 1586 | } |
1586 | 1587 | ||
1587 | void Addressee::removePhoneNumber( const PhoneNumber &phoneNumber ) | 1588 | void Addressee::removePhoneNumber( const PhoneNumber &phoneNumber ) |
1588 | { | 1589 | { |
1589 | detach(); | 1590 | detach(); |
1590 | 1591 | ||
1591 | PhoneNumber::List::Iterator it; | 1592 | PhoneNumber::List::Iterator it; |
1592 | for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { | 1593 | for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { |
1593 | if ( (*it).id() == phoneNumber.id() ) { | 1594 | if ( (*it).id() == phoneNumber.id() ) { |
1594 | mData->phoneNumbers.remove( it ); | 1595 | mData->phoneNumbers.remove( it ); |
1595 | return; | 1596 | return; |
1596 | } | 1597 | } |
1597 | } | 1598 | } |
1598 | } | 1599 | } |
1599 | 1600 | ||
1600 | PhoneNumber Addressee::phoneNumber( int type ) const | 1601 | PhoneNumber Addressee::phoneNumber( int type ) const |
1601 | { | 1602 | { |
1602 | PhoneNumber phoneNumber( "", type ); | 1603 | PhoneNumber phoneNumber( "", type ); |
1603 | PhoneNumber::List::ConstIterator it; | 1604 | PhoneNumber::List::ConstIterator it; |
1604 | for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { | 1605 | for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { |
1605 | if ( matchBinaryPatternP( (*it).type(), type ) ) { | 1606 | if ( matchBinaryPatternP( (*it).type(), type ) ) { |
1606 | if ( (*it).type() & PhoneNumber::Pref ) | 1607 | if ( (*it).type() & PhoneNumber::Pref ) |
1607 | return (*it); | 1608 | return (*it); |
1608 | else if ( phoneNumber.number().isEmpty() ) | 1609 | else if ( phoneNumber.number().isEmpty() ) |
1609 | phoneNumber = (*it); | 1610 | phoneNumber = (*it); |
1610 | } | 1611 | } |
1611 | } | 1612 | } |
1612 | 1613 | ||
1613 | return phoneNumber; | 1614 | return phoneNumber; |
1614 | } | 1615 | } |
1615 | 1616 | ||
1616 | PhoneNumber::List Addressee::phoneNumbers() const | 1617 | PhoneNumber::List Addressee::phoneNumbers() const |
1617 | { | 1618 | { |
1618 | return mData->phoneNumbers; | 1619 | return mData->phoneNumbers; |
1619 | } | 1620 | } |
1620 | 1621 | ||
1621 | PhoneNumber::List Addressee::phoneNumbers( int type ) const | 1622 | PhoneNumber::List Addressee::phoneNumbers( int type ) const |
1622 | { | 1623 | { |
1623 | PhoneNumber::List list; | 1624 | PhoneNumber::List list; |
1624 | 1625 | ||
1625 | PhoneNumber::List::ConstIterator it; | 1626 | PhoneNumber::List::ConstIterator it; |
1626 | for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { | 1627 | for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { |
1627 | if ( matchBinaryPattern( (*it).type(), type ) ) { | 1628 | if ( matchBinaryPattern( (*it).type(), type ) ) { |
1628 | list.append( *it ); | 1629 | list.append( *it ); |
1629 | } | 1630 | } |
1630 | } | 1631 | } |
1631 | return list; | 1632 | return list; |
1632 | } | 1633 | } |
1633 | 1634 | ||
1634 | PhoneNumber Addressee::findPhoneNumber( const QString &id ) const | 1635 | PhoneNumber Addressee::findPhoneNumber( const QString &id ) const |
1635 | { | 1636 | { |
1636 | PhoneNumber::List::ConstIterator it; | 1637 | PhoneNumber::List::ConstIterator it; |
1637 | for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { | 1638 | for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { |
1638 | if ( (*it).id() == id ) { | 1639 | if ( (*it).id() == id ) { |
1639 | return *it; | 1640 | return *it; |
1640 | } | 1641 | } |
1641 | } | 1642 | } |
1642 | return PhoneNumber(); | 1643 | return PhoneNumber(); |
1643 | } | 1644 | } |
1644 | 1645 | ||
1645 | void Addressee::insertKey( const Key &key ) | 1646 | void Addressee::insertKey( const Key &key ) |
1646 | { | 1647 | { |
1647 | detach(); | 1648 | detach(); |
1648 | mData->empty = false; | 1649 | mData->empty = false; |
1649 | 1650 | ||
1650 | Key::List::Iterator it; | 1651 | Key::List::Iterator it; |
1651 | for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) { | 1652 | for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) { |
1652 | if ( (*it).id() == key.id() ) { | 1653 | if ( (*it).id() == key.id() ) { |
1653 | *it = key; | 1654 | *it = key; |
1654 | return; | 1655 | return; |
1655 | } | 1656 | } |
1656 | } | 1657 | } |
1657 | mData->keys.append( key ); | 1658 | mData->keys.append( key ); |
1658 | } | 1659 | } |
1659 | 1660 | ||
1660 | void Addressee::removeKey( const Key &key ) | 1661 | void Addressee::removeKey( const Key &key ) |
1661 | { | 1662 | { |
1662 | detach(); | 1663 | detach(); |
1663 | 1664 | ||
1664 | Key::List::Iterator it; | 1665 | Key::List::Iterator it; |
1665 | for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) { | 1666 | for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) { |
1666 | if ( (*it).id() == key.id() ) { | 1667 | if ( (*it).id() == key.id() ) { |
1667 | mData->keys.remove( key ); | 1668 | mData->keys.remove( key ); |
1668 | return; | 1669 | return; |
1669 | } | 1670 | } |
1670 | } | 1671 | } |
1671 | } | 1672 | } |
1672 | 1673 | ||
1673 | Key Addressee::key( int type, QString customTypeString ) const | 1674 | Key Addressee::key( int type, QString customTypeString ) const |
1674 | { | 1675 | { |
1675 | Key::List::ConstIterator it; | 1676 | Key::List::ConstIterator it; |
1676 | for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) { | 1677 | for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) { |
1677 | if ( (*it).type() == type ) { | 1678 | if ( (*it).type() == type ) { |
1678 | if ( type == Key::Custom ) { | 1679 | if ( type == Key::Custom ) { |
1679 | if ( customTypeString.isEmpty() ) { | 1680 | if ( customTypeString.isEmpty() ) { |
1680 | return *it; | 1681 | return *it; |
1681 | } else { | 1682 | } else { |
1682 | if ( (*it).customTypeString() == customTypeString ) | 1683 | if ( (*it).customTypeString() == customTypeString ) |
1683 | return (*it); | 1684 | return (*it); |
1684 | } | 1685 | } |
1685 | } else { | 1686 | } else { |
1686 | return *it; | 1687 | return *it; |
1687 | } | 1688 | } |
1688 | } | 1689 | } |
1689 | } | 1690 | } |
1690 | return Key( QString(), type ); | 1691 | return Key( QString(), type ); |