author | ulf69 <ulf69> | 2004-06-30 22:07:56 (UTC) |
---|---|---|
committer | ulf69 <ulf69> | 2004-06-30 22:07:56 (UTC) |
commit | 1b7b7755bfbedddc72293b784577ded4e684bd6f (patch) (unidiff) | |
tree | ff4eba9b8bb53401d2000d70e73a40f7c330d577 /kabc/addressee.cpp | |
parent | c6f3a3f49498dca52d10418d845f4a84c0c6d941 (diff) | |
download | kdepimpi-1b7b7755bfbedddc72293b784577ded4e684bd6f.zip kdepimpi-1b7b7755bfbedddc72293b784577ded4e684bd6f.tar.gz kdepimpi-1b7b7755bfbedddc72293b784577ded4e684bd6f.tar.bz2 |
added a new field of type Resource. This allowes us to display in KAddressbook for each
Addressbookentry its location
-rw-r--r-- | kabc/addressee.cpp | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/kabc/addressee.cpp b/kabc/addressee.cpp index 5cb194a..d484073 100644 --- a/kabc/addressee.cpp +++ b/kabc/addressee.cpp | |||
@@ -1414,192 +1414,198 @@ void Addressee::removeCustom( const QString &app, const QString &name) | |||
1414 | 1414 | ||
1415 | QString Addressee::custom( const QString &app, const QString &name ) const | 1415 | QString Addressee::custom( const QString &app, const QString &name ) const |
1416 | { | 1416 | { |
1417 | QString qualifiedName = app + "-" + name + ":"; | 1417 | QString qualifiedName = app + "-" + name + ":"; |
1418 | QString value; | 1418 | QString value; |
1419 | 1419 | ||
1420 | QStringList::ConstIterator it; | 1420 | QStringList::ConstIterator it; |
1421 | for( it = mData->custom.begin(); it != mData->custom.end(); ++it ) { | 1421 | for( it = mData->custom.begin(); it != mData->custom.end(); ++it ) { |
1422 | if ( (*it).startsWith( qualifiedName ) ) { | 1422 | if ( (*it).startsWith( qualifiedName ) ) { |
1423 | value = (*it).mid( (*it).find( ":" ) + 1 ); | 1423 | value = (*it).mid( (*it).find( ":" ) + 1 ); |
1424 | break; | 1424 | break; |
1425 | } | 1425 | } |
1426 | } | 1426 | } |
1427 | 1427 | ||
1428 | return value; | 1428 | return value; |
1429 | } | 1429 | } |
1430 | 1430 | ||
1431 | void Addressee::setCustoms( const QStringList &l ) | 1431 | void Addressee::setCustoms( const QStringList &l ) |
1432 | { | 1432 | { |
1433 | detach(); | 1433 | detach(); |
1434 | mData->empty = false; | 1434 | mData->empty = false; |
1435 | 1435 | ||
1436 | mData->custom = l; | 1436 | mData->custom = l; |
1437 | } | 1437 | } |
1438 | 1438 | ||
1439 | QStringList Addressee::customs() const | 1439 | QStringList Addressee::customs() const |
1440 | { | 1440 | { |
1441 | return mData->custom; | 1441 | return mData->custom; |
1442 | } | 1442 | } |
1443 | 1443 | ||
1444 | void Addressee::parseEmailAddress( const QString &rawEmail, QString &fullName, | 1444 | void Addressee::parseEmailAddress( const QString &rawEmail, QString &fullName, |
1445 | QString &email) | 1445 | QString &email) |
1446 | { | 1446 | { |
1447 | int startPos, endPos, len; | 1447 | int startPos, endPos, len; |
1448 | QString partA, partB, result; | 1448 | QString partA, partB, result; |
1449 | char endCh = '>'; | 1449 | char endCh = '>'; |
1450 | 1450 | ||
1451 | startPos = rawEmail.find('<'); | 1451 | startPos = rawEmail.find('<'); |
1452 | if (startPos < 0) | 1452 | if (startPos < 0) |
1453 | { | 1453 | { |
1454 | startPos = rawEmail.find('('); | 1454 | startPos = rawEmail.find('('); |
1455 | endCh = ')'; | 1455 | endCh = ')'; |
1456 | } | 1456 | } |
1457 | if (startPos < 0) | 1457 | if (startPos < 0) |
1458 | { | 1458 | { |
1459 | // We couldn't find any separators, so we assume the whole string | 1459 | // We couldn't find any separators, so we assume the whole string |
1460 | // is the email address | 1460 | // is the email address |
1461 | email = rawEmail; | 1461 | email = rawEmail; |
1462 | fullName = ""; | 1462 | fullName = ""; |
1463 | } | 1463 | } |
1464 | else | 1464 | else |
1465 | { | 1465 | { |
1466 | // We have a start position, try to find an end | 1466 | // We have a start position, try to find an end |
1467 | endPos = rawEmail.find(endCh, startPos+1); | 1467 | endPos = rawEmail.find(endCh, startPos+1); |
1468 | 1468 | ||
1469 | if (endPos < 0) | 1469 | if (endPos < 0) |
1470 | { | 1470 | { |
1471 | // We couldn't find the end of the email address. We can only | 1471 | // We couldn't find the end of the email address. We can only |
1472 | // assume the entire string is the email address. | 1472 | // assume the entire string is the email address. |
1473 | email = rawEmail; | 1473 | email = rawEmail; |
1474 | fullName = ""; | 1474 | fullName = ""; |
1475 | } | 1475 | } |
1476 | else | 1476 | else |
1477 | { | 1477 | { |
1478 | // We have a start and end to the email address | 1478 | // We have a start and end to the email address |
1479 | 1479 | ||
1480 | // Grab the name part | 1480 | // Grab the name part |
1481 | fullName = rawEmail.left(startPos).stripWhiteSpace(); | 1481 | fullName = rawEmail.left(startPos).stripWhiteSpace(); |
1482 | 1482 | ||
1483 | // grab the email part | 1483 | // grab the email part |
1484 | email = rawEmail.mid(startPos+1, endPos-startPos-1).stripWhiteSpace(); | 1484 | email = rawEmail.mid(startPos+1, endPos-startPos-1).stripWhiteSpace(); |
1485 | 1485 | ||
1486 | // Check that we do not have any extra characters on the end of the | 1486 | // Check that we do not have any extra characters on the end of the |
1487 | // strings | 1487 | // strings |
1488 | len = fullName.length(); | 1488 | len = fullName.length(); |
1489 | if (fullName[0]=='"' && fullName[len-1]=='"') | 1489 | if (fullName[0]=='"' && fullName[len-1]=='"') |
1490 | fullName = fullName.mid(1, len-2); | 1490 | fullName = fullName.mid(1, len-2); |
1491 | else if (fullName[0]=='<' && fullName[len-1]=='>') | 1491 | else if (fullName[0]=='<' && fullName[len-1]=='>') |
1492 | fullName = fullName.mid(1, len-2); | 1492 | fullName = fullName.mid(1, len-2); |
1493 | else if (fullName[0]=='(' && fullName[len-1]==')') | 1493 | else if (fullName[0]=='(' && fullName[len-1]==')') |
1494 | fullName = fullName.mid(1, len-2); | 1494 | fullName = fullName.mid(1, len-2); |
1495 | } | 1495 | } |
1496 | } | 1496 | } |
1497 | } | 1497 | } |
1498 | 1498 | ||
1499 | void Addressee::setResource( Resource *resource ) | 1499 | void Addressee::setResource( Resource *resource ) |
1500 | { | 1500 | { |
1501 | detach(); | 1501 | detach(); |
1502 | mData->resource = resource; | 1502 | mData->resource = resource; |
1503 | } | 1503 | } |
1504 | 1504 | ||
1505 | Resource *Addressee::resource() const | 1505 | Resource *Addressee::resource() const |
1506 | { | 1506 | { |
1507 | return mData->resource; | 1507 | return mData->resource; |
1508 | } | 1508 | } |
1509 | 1509 | ||
1510 | //US | ||
1511 | QString Addressee::resourceLabel() | ||
1512 | { | ||
1513 | return i18n("Resource"); | ||
1514 | } | ||
1515 | |||
1510 | void Addressee::setChanged( bool value ) | 1516 | void Addressee::setChanged( bool value ) |
1511 | { | 1517 | { |
1512 | detach(); | 1518 | detach(); |
1513 | mData->changed = value; | 1519 | mData->changed = value; |
1514 | } | 1520 | } |
1515 | 1521 | ||
1516 | bool Addressee::changed() const | 1522 | bool Addressee::changed() const |
1517 | { | 1523 | { |
1518 | return mData->changed; | 1524 | return mData->changed; |
1519 | } | 1525 | } |
1520 | 1526 | ||
1521 | QDataStream &KABC::operator<<( QDataStream &s, const Addressee &a ) | 1527 | QDataStream &KABC::operator<<( QDataStream &s, const Addressee &a ) |
1522 | { | 1528 | { |
1523 | if (!a.mData) return s; | 1529 | if (!a.mData) return s; |
1524 | 1530 | ||
1525 | s << a.uid(); | 1531 | s << a.uid(); |
1526 | 1532 | ||
1527 | s << a.mData->name; | 1533 | s << a.mData->name; |
1528 | s << a.mData->formattedName; | 1534 | s << a.mData->formattedName; |
1529 | s << a.mData->familyName; | 1535 | s << a.mData->familyName; |
1530 | s << a.mData->givenName; | 1536 | s << a.mData->givenName; |
1531 | s << a.mData->additionalName; | 1537 | s << a.mData->additionalName; |
1532 | s << a.mData->prefix; | 1538 | s << a.mData->prefix; |
1533 | s << a.mData->suffix; | 1539 | s << a.mData->suffix; |
1534 | s << a.mData->nickName; | 1540 | s << a.mData->nickName; |
1535 | s << a.mData->birthday; | 1541 | s << a.mData->birthday; |
1536 | s << a.mData->mailer; | 1542 | s << a.mData->mailer; |
1537 | s << a.mData->timeZone; | 1543 | s << a.mData->timeZone; |
1538 | s << a.mData->geo; | 1544 | s << a.mData->geo; |
1539 | s << a.mData->title; | 1545 | s << a.mData->title; |
1540 | s << a.mData->role; | 1546 | s << a.mData->role; |
1541 | s << a.mData->organization; | 1547 | s << a.mData->organization; |
1542 | s << a.mData->note; | 1548 | s << a.mData->note; |
1543 | s << a.mData->productId; | 1549 | s << a.mData->productId; |
1544 | s << a.mData->revision; | 1550 | s << a.mData->revision; |
1545 | s << a.mData->sortString; | 1551 | s << a.mData->sortString; |
1546 | s << a.mData->url; | 1552 | s << a.mData->url; |
1547 | s << a.mData->secrecy; | 1553 | s << a.mData->secrecy; |
1548 | s << a.mData->logo; | 1554 | s << a.mData->logo; |
1549 | s << a.mData->photo; | 1555 | s << a.mData->photo; |
1550 | s << a.mData->sound; | 1556 | s << a.mData->sound; |
1551 | s << a.mData->agent; | 1557 | s << a.mData->agent; |
1552 | s << a.mData->phoneNumbers; | 1558 | s << a.mData->phoneNumbers; |
1553 | s << a.mData->addresses; | 1559 | s << a.mData->addresses; |
1554 | s << a.mData->emails; | 1560 | s << a.mData->emails; |
1555 | s << a.mData->categories; | 1561 | s << a.mData->categories; |
1556 | s << a.mData->custom; | 1562 | s << a.mData->custom; |
1557 | s << a.mData->keys; | 1563 | s << a.mData->keys; |
1558 | return s; | 1564 | return s; |
1559 | } | 1565 | } |
1560 | 1566 | ||
1561 | QDataStream &KABC::operator>>( QDataStream &s, Addressee &a ) | 1567 | QDataStream &KABC::operator>>( QDataStream &s, Addressee &a ) |
1562 | { | 1568 | { |
1563 | if (!a.mData) return s; | 1569 | if (!a.mData) return s; |
1564 | 1570 | ||
1565 | s >> a.mData->uid; | 1571 | s >> a.mData->uid; |
1566 | 1572 | ||
1567 | s >> a.mData->name; | 1573 | s >> a.mData->name; |
1568 | s >> a.mData->formattedName; | 1574 | s >> a.mData->formattedName; |
1569 | s >> a.mData->familyName; | 1575 | s >> a.mData->familyName; |
1570 | s >> a.mData->givenName; | 1576 | s >> a.mData->givenName; |
1571 | s >> a.mData->additionalName; | 1577 | s >> a.mData->additionalName; |
1572 | s >> a.mData->prefix; | 1578 | s >> a.mData->prefix; |
1573 | s >> a.mData->suffix; | 1579 | s >> a.mData->suffix; |
1574 | s >> a.mData->nickName; | 1580 | s >> a.mData->nickName; |
1575 | s >> a.mData->birthday; | 1581 | s >> a.mData->birthday; |
1576 | s >> a.mData->mailer; | 1582 | s >> a.mData->mailer; |
1577 | s >> a.mData->timeZone; | 1583 | s >> a.mData->timeZone; |
1578 | s >> a.mData->geo; | 1584 | s >> a.mData->geo; |
1579 | s >> a.mData->title; | 1585 | s >> a.mData->title; |
1580 | s >> a.mData->role; | 1586 | s >> a.mData->role; |
1581 | s >> a.mData->organization; | 1587 | s >> a.mData->organization; |
1582 | s >> a.mData->note; | 1588 | s >> a.mData->note; |
1583 | s >> a.mData->productId; | 1589 | s >> a.mData->productId; |
1584 | s >> a.mData->revision; | 1590 | s >> a.mData->revision; |
1585 | s >> a.mData->sortString; | 1591 | s >> a.mData->sortString; |
1586 | s >> a.mData->url; | 1592 | s >> a.mData->url; |
1587 | s >> a.mData->secrecy; | 1593 | s >> a.mData->secrecy; |
1588 | s >> a.mData->logo; | 1594 | s >> a.mData->logo; |
1589 | s >> a.mData->photo; | 1595 | s >> a.mData->photo; |
1590 | s >> a.mData->sound; | 1596 | s >> a.mData->sound; |
1591 | s >> a.mData->agent; | 1597 | s >> a.mData->agent; |
1592 | s >> a.mData->phoneNumbers; | 1598 | s >> a.mData->phoneNumbers; |
1593 | s >> a.mData->addresses; | 1599 | s >> a.mData->addresses; |
1594 | s >> a.mData->emails; | 1600 | s >> a.mData->emails; |
1595 | s >> a.mData->categories; | 1601 | s >> a.mData->categories; |
1596 | s >> a.mData->custom; | 1602 | s >> a.mData->custom; |
1597 | s >> a.mData->keys; | 1603 | s >> a.mData->keys; |
1598 | 1604 | ||
1599 | a.mData->empty = false; | 1605 | a.mData->empty = false; |
1600 | 1606 | ||
1601 | return s; | 1607 | return s; |
1602 | } | 1608 | } |
1603 | 1609 | ||
1604 | bool matchBinaryPattern( int value, int pattern ) | 1610 | bool matchBinaryPattern( int value, int pattern ) |
1605 | { | 1611 | { |