author | zautrix <zautrix> | 2005-03-30 10:41:33 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2005-03-30 10:41:33 (UTC) |
commit | 597cad3a63e6c22855704bf8435db70e3c2b184f (patch) (unidiff) | |
tree | f7093b331be9a52a07d01a6f2f5c1f26daf42d50 /kabc/addressee.cpp | |
parent | 889d2102fcfe2fb0786b3f8f406dc32b42e38c7a (diff) | |
download | kdepimpi-597cad3a63e6c22855704bf8435db70e3c2b184f.zip kdepimpi-597cad3a63e6c22855704bf8435db70e3c2b184f.tar.gz kdepimpi-597cad3a63e6c22855704bf8435db70e3c2b184f.tar.bz2 |
fix
-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 | |||
@@ -1450,97 +1450,98 @@ void Addressee::setNameFromString( const QString &str ) | |||
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 | } |