summaryrefslogtreecommitdiffabout
path: root/kabc/addressee.cpp
Unidiff
Diffstat (limited to 'kabc/addressee.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--kabc/addressee.cpp4
1 files changed, 4 insertions, 0 deletions
diff --git a/kabc/addressee.cpp b/kabc/addressee.cpp
index eec0f1f..3ce733d 100644
--- a/kabc/addressee.cpp
+++ b/kabc/addressee.cpp
@@ -1487,647 +1487,651 @@ void Addressee::insertEmail( const QString &email, bool preferred )
1487 } 1487 }
1488 } 1488 }
1489} 1489}
1490 1490
1491void Addressee::removeEmail( const QString &email ) 1491void Addressee::removeEmail( const QString &email )
1492{ 1492{
1493 detach(); 1493 detach();
1494 1494
1495 QStringList::Iterator it = mData->emails.find( email ); 1495 QStringList::Iterator it = mData->emails.find( email );
1496 if ( it == mData->emails.end() ) return; 1496 if ( it == mData->emails.end() ) return;
1497 1497
1498 mData->emails.remove( it ); 1498 mData->emails.remove( it );
1499} 1499}
1500 1500
1501QString Addressee::preferredEmail() const 1501QString Addressee::preferredEmail() const
1502{ 1502{
1503 if ( mData->emails.count() == 0 ) return QString::null; 1503 if ( mData->emails.count() == 0 ) return QString::null;
1504 else return mData->emails.first(); 1504 else return mData->emails.first();
1505} 1505}
1506 1506
1507QStringList Addressee::emails() const 1507QStringList Addressee::emails() const
1508{ 1508{
1509 return mData->emails; 1509 return mData->emails;
1510} 1510}
1511void Addressee::setEmails( const QStringList& emails ) { 1511void Addressee::setEmails( const QStringList& emails ) {
1512 detach(); 1512 detach();
1513 mData->emails = emails; 1513 mData->emails = emails;
1514} 1514}
1515void Addressee::insertPhoneNumber( const PhoneNumber &phoneNumber ) 1515void Addressee::insertPhoneNumber( const PhoneNumber &phoneNumber )
1516{ 1516{
1517 detach(); 1517 detach();
1518 mData->empty = false; 1518 mData->empty = false;
1519 1519
1520 PhoneNumber::List::Iterator it; 1520 PhoneNumber::List::Iterator it;
1521 for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { 1521 for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) {
1522 if ( (*it).id() == phoneNumber.id() ) { 1522 if ( (*it).id() == phoneNumber.id() ) {
1523 *it = phoneNumber; 1523 *it = phoneNumber;
1524 return; 1524 return;
1525 } 1525 }
1526 } 1526 }
1527 mData->phoneNumbers.append( phoneNumber ); 1527 mData->phoneNumbers.append( phoneNumber );
1528} 1528}
1529 1529
1530void Addressee::removePhoneNumber( const PhoneNumber &phoneNumber ) 1530void Addressee::removePhoneNumber( const PhoneNumber &phoneNumber )
1531{ 1531{
1532 detach(); 1532 detach();
1533 1533
1534 PhoneNumber::List::Iterator it; 1534 PhoneNumber::List::Iterator it;
1535 for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { 1535 for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) {
1536 if ( (*it).id() == phoneNumber.id() ) { 1536 if ( (*it).id() == phoneNumber.id() ) {
1537 mData->phoneNumbers.remove( it ); 1537 mData->phoneNumbers.remove( it );
1538 return; 1538 return;
1539 } 1539 }
1540 } 1540 }
1541} 1541}
1542 1542
1543PhoneNumber Addressee::phoneNumber( int type ) const 1543PhoneNumber Addressee::phoneNumber( int type ) const
1544{ 1544{
1545 PhoneNumber phoneNumber( "", type ); 1545 PhoneNumber phoneNumber( "", type );
1546 PhoneNumber::List::ConstIterator it; 1546 PhoneNumber::List::ConstIterator it;
1547 for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { 1547 for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) {
1548 if ( matchBinaryPatternP( (*it).type(), type ) ) { 1548 if ( matchBinaryPatternP( (*it).type(), type ) ) {
1549 if ( (*it).type() & PhoneNumber::Pref ) 1549 if ( (*it).type() & PhoneNumber::Pref )
1550 return (*it); 1550 return (*it);
1551 else if ( phoneNumber.number().isEmpty() ) 1551 else if ( phoneNumber.number().isEmpty() )
1552 phoneNumber = (*it); 1552 phoneNumber = (*it);
1553 } 1553 }
1554 } 1554 }
1555 1555
1556 return phoneNumber; 1556 return phoneNumber;
1557} 1557}
1558 1558
1559PhoneNumber::List Addressee::phoneNumbers() const 1559PhoneNumber::List Addressee::phoneNumbers() const
1560{ 1560{
1561 return mData->phoneNumbers; 1561 return mData->phoneNumbers;
1562} 1562}
1563 1563
1564PhoneNumber::List Addressee::phoneNumbers( int type ) const 1564PhoneNumber::List Addressee::phoneNumbers( int type ) const
1565{ 1565{
1566 PhoneNumber::List list; 1566 PhoneNumber::List list;
1567 1567
1568 PhoneNumber::List::ConstIterator it; 1568 PhoneNumber::List::ConstIterator it;
1569 for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { 1569 for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) {
1570 if ( matchBinaryPattern( (*it).type(), type ) ) { 1570 if ( matchBinaryPattern( (*it).type(), type ) ) {
1571 list.append( *it ); 1571 list.append( *it );
1572 } 1572 }
1573 } 1573 }
1574 return list; 1574 return list;
1575} 1575}
1576 1576
1577PhoneNumber Addressee::findPhoneNumber( const QString &id ) const 1577PhoneNumber Addressee::findPhoneNumber( const QString &id ) const
1578{ 1578{
1579 PhoneNumber::List::ConstIterator it; 1579 PhoneNumber::List::ConstIterator it;
1580 for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { 1580 for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) {
1581 if ( (*it).id() == id ) { 1581 if ( (*it).id() == id ) {
1582 return *it; 1582 return *it;
1583 } 1583 }
1584 } 1584 }
1585 return PhoneNumber(); 1585 return PhoneNumber();
1586} 1586}
1587 1587
1588void Addressee::insertKey( const Key &key ) 1588void Addressee::insertKey( const Key &key )
1589{ 1589{
1590 detach(); 1590 detach();
1591 mData->empty = false; 1591 mData->empty = false;
1592 1592
1593 Key::List::Iterator it; 1593 Key::List::Iterator it;
1594 for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) { 1594 for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) {
1595 if ( (*it).id() == key.id() ) { 1595 if ( (*it).id() == key.id() ) {
1596 *it = key; 1596 *it = key;
1597 return; 1597 return;
1598 } 1598 }
1599 } 1599 }
1600 mData->keys.append( key ); 1600 mData->keys.append( key );
1601} 1601}
1602 1602
1603void Addressee::removeKey( const Key &key ) 1603void Addressee::removeKey( const Key &key )
1604{ 1604{
1605 detach(); 1605 detach();
1606 1606
1607 Key::List::Iterator it; 1607 Key::List::Iterator it;
1608 for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) { 1608 for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) {
1609 if ( (*it).id() == key.id() ) { 1609 if ( (*it).id() == key.id() ) {
1610 mData->keys.remove( key ); 1610 mData->keys.remove( key );
1611 return; 1611 return;
1612 } 1612 }
1613 } 1613 }
1614} 1614}
1615 1615
1616Key Addressee::key( int type, QString customTypeString ) const 1616Key Addressee::key( int type, QString customTypeString ) const
1617{ 1617{
1618 Key::List::ConstIterator it; 1618 Key::List::ConstIterator it;
1619 for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) { 1619 for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) {
1620 if ( (*it).type() == type ) { 1620 if ( (*it).type() == type ) {
1621 if ( type == Key::Custom ) { 1621 if ( type == Key::Custom ) {
1622 if ( customTypeString.isEmpty() ) { 1622 if ( customTypeString.isEmpty() ) {
1623 return *it; 1623 return *it;
1624 } else { 1624 } else {
1625 if ( (*it).customTypeString() == customTypeString ) 1625 if ( (*it).customTypeString() == customTypeString )
1626 return (*it); 1626 return (*it);
1627 } 1627 }
1628 } else { 1628 } else {
1629 return *it; 1629 return *it;
1630 } 1630 }
1631 } 1631 }
1632 } 1632 }
1633 return Key( QString(), type ); 1633 return Key( QString(), type );
1634} 1634}
1635void Addressee::setKeys( const Key::List& list ) { 1635void Addressee::setKeys( const Key::List& list ) {
1636 detach(); 1636 detach();
1637 mData->keys = list; 1637 mData->keys = list;
1638} 1638}
1639 1639
1640Key::List Addressee::keys() const 1640Key::List Addressee::keys() const
1641{ 1641{
1642 return mData->keys; 1642 return mData->keys;
1643} 1643}
1644 1644
1645Key::List Addressee::keys( int type, QString customTypeString ) const 1645Key::List Addressee::keys( int type, QString customTypeString ) const
1646{ 1646{
1647 Key::List list; 1647 Key::List list;
1648 1648
1649 Key::List::ConstIterator it; 1649 Key::List::ConstIterator it;
1650 for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) { 1650 for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) {
1651 if ( (*it).type() == type ) { 1651 if ( (*it).type() == type ) {
1652 if ( type == Key::Custom ) { 1652 if ( type == Key::Custom ) {
1653 if ( customTypeString.isEmpty() ) { 1653 if ( customTypeString.isEmpty() ) {
1654 list.append(*it); 1654 list.append(*it);
1655 } else { 1655 } else {
1656 if ( (*it).customTypeString() == customTypeString ) 1656 if ( (*it).customTypeString() == customTypeString )
1657 list.append(*it); 1657 list.append(*it);
1658 } 1658 }
1659 } else { 1659 } else {
1660 list.append(*it); 1660 list.append(*it);
1661 } 1661 }
1662 } 1662 }
1663 } 1663 }
1664 return list; 1664 return list;
1665} 1665}
1666 1666
1667Key Addressee::findKey( const QString &id ) const 1667Key Addressee::findKey( const QString &id ) const
1668{ 1668{
1669 Key::List::ConstIterator it; 1669 Key::List::ConstIterator it;
1670 for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) { 1670 for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) {
1671 if ( (*it).id() == id ) { 1671 if ( (*it).id() == id ) {
1672 return *it; 1672 return *it;
1673 } 1673 }
1674 } 1674 }
1675 return Key(); 1675 return Key();
1676} 1676}
1677 1677
1678QString Addressee::asString() const 1678QString Addressee::asString() const
1679{ 1679{
1680 return "Smith, agent Smith..."; 1680 return "Smith, agent Smith...";
1681} 1681}
1682 1682
1683void Addressee::dump() const 1683void Addressee::dump() const
1684{ 1684{
1685 return; 1685 return;
1686 kdDebug(5700) << "Addressee {" << endl; 1686 kdDebug(5700) << "Addressee {" << endl;
1687 1687
1688 kdDebug(5700) << " Uid: '" << uid() << "'" << endl; 1688 kdDebug(5700) << " Uid: '" << uid() << "'" << endl;
1689 1689
1690 kdDebug(5700) << " Name: '" << name() << "'" << endl; 1690 kdDebug(5700) << " Name: '" << name() << "'" << endl;
1691 kdDebug(5700) << " FormattedName: '" << formattedName() << "'" << endl; 1691 kdDebug(5700) << " FormattedName: '" << formattedName() << "'" << endl;
1692 kdDebug(5700) << " FamilyName: '" << familyName() << "'" << endl; 1692 kdDebug(5700) << " FamilyName: '" << familyName() << "'" << endl;
1693 kdDebug(5700) << " GivenName: '" << givenName() << "'" << endl; 1693 kdDebug(5700) << " GivenName: '" << givenName() << "'" << endl;
1694 kdDebug(5700) << " AdditionalName: '" << additionalName() << "'" << endl; 1694 kdDebug(5700) << " AdditionalName: '" << additionalName() << "'" << endl;
1695 kdDebug(5700) << " Prefix: '" << prefix() << "'" << endl; 1695 kdDebug(5700) << " Prefix: '" << prefix() << "'" << endl;
1696 kdDebug(5700) << " Suffix: '" << suffix() << "'" << endl; 1696 kdDebug(5700) << " Suffix: '" << suffix() << "'" << endl;
1697 kdDebug(5700) << " NickName: '" << nickName() << "'" << endl; 1697 kdDebug(5700) << " NickName: '" << nickName() << "'" << endl;
1698 kdDebug(5700) << " Birthday: '" << birthday().toString() << "'" << endl; 1698 kdDebug(5700) << " Birthday: '" << birthday().toString() << "'" << endl;
1699 kdDebug(5700) << " Mailer: '" << mailer() << "'" << endl; 1699 kdDebug(5700) << " Mailer: '" << mailer() << "'" << endl;
1700 kdDebug(5700) << " TimeZone: '" << timeZone().asString() << "'" << endl; 1700 kdDebug(5700) << " TimeZone: '" << timeZone().asString() << "'" << endl;
1701 kdDebug(5700) << " Geo: '" << geo().asString() << "'" << endl; 1701 kdDebug(5700) << " Geo: '" << geo().asString() << "'" << endl;
1702 kdDebug(5700) << " Title: '" << title() << "'" << endl; 1702 kdDebug(5700) << " Title: '" << title() << "'" << endl;
1703 kdDebug(5700) << " Role: '" << role() << "'" << endl; 1703 kdDebug(5700) << " Role: '" << role() << "'" << endl;
1704 kdDebug(5700) << " Organization: '" << organization() << "'" << endl; 1704 kdDebug(5700) << " Organization: '" << organization() << "'" << endl;
1705 kdDebug(5700) << " Note: '" << note() << "'" << endl; 1705 kdDebug(5700) << " Note: '" << note() << "'" << endl;
1706 kdDebug(5700) << " ProductId: '" << productId() << "'" << endl; 1706 kdDebug(5700) << " ProductId: '" << productId() << "'" << endl;
1707 kdDebug(5700) << " Revision: '" << revision().toString() << "'" << endl; 1707 kdDebug(5700) << " Revision: '" << revision().toString() << "'" << endl;
1708 kdDebug(5700) << " SortString: '" << sortString() << "'" << endl; 1708 kdDebug(5700) << " SortString: '" << sortString() << "'" << endl;
1709 kdDebug(5700) << " Url: '" << url().url() << "'" << endl; 1709 kdDebug(5700) << " Url: '" << url().url() << "'" << endl;
1710 kdDebug(5700) << " Secrecy: '" << secrecy().asString() << "'" << endl; 1710 kdDebug(5700) << " Secrecy: '" << secrecy().asString() << "'" << endl;
1711 kdDebug(5700) << " Logo: '" << logo().asString() << "'" << endl; 1711 kdDebug(5700) << " Logo: '" << logo().asString() << "'" << endl;
1712 kdDebug(5700) << " Photo: '" << photo().asString() << "'" << endl; 1712 kdDebug(5700) << " Photo: '" << photo().asString() << "'" << endl;
1713 kdDebug(5700) << " Sound: '" << sound().asString() << "'" << endl; 1713 kdDebug(5700) << " Sound: '" << sound().asString() << "'" << endl;
1714 kdDebug(5700) << " Agent: '" << agent().asString() << "'" << endl; 1714 kdDebug(5700) << " Agent: '" << agent().asString() << "'" << endl;
1715 1715
1716 kdDebug(5700) << " Emails {" << endl; 1716 kdDebug(5700) << " Emails {" << endl;
1717 QStringList e = emails(); 1717 QStringList e = emails();
1718 QStringList::ConstIterator it; 1718 QStringList::ConstIterator it;
1719 for( it = e.begin(); it != e.end(); ++it ) { 1719 for( it = e.begin(); it != e.end(); ++it ) {
1720 kdDebug(5700) << " " << (*it) << endl; 1720 kdDebug(5700) << " " << (*it) << endl;
1721 } 1721 }
1722 kdDebug(5700) << " }" << endl; 1722 kdDebug(5700) << " }" << endl;
1723 1723
1724 kdDebug(5700) << " PhoneNumbers {" << endl; 1724 kdDebug(5700) << " PhoneNumbers {" << endl;
1725 PhoneNumber::List p = phoneNumbers(); 1725 PhoneNumber::List p = phoneNumbers();
1726 PhoneNumber::List::ConstIterator it2; 1726 PhoneNumber::List::ConstIterator it2;
1727 for( it2 = p.begin(); it2 != p.end(); ++it2 ) { 1727 for( it2 = p.begin(); it2 != p.end(); ++it2 ) {
1728 kdDebug(5700) << " Type: " << int((*it2).type()) << " Number: " << (*it2).number() << endl; 1728 kdDebug(5700) << " Type: " << int((*it2).type()) << " Number: " << (*it2).number() << endl;
1729 } 1729 }
1730 kdDebug(5700) << " }" << endl; 1730 kdDebug(5700) << " }" << endl;
1731 1731
1732 Address::List a = addresses(); 1732 Address::List a = addresses();
1733 Address::List::ConstIterator it3; 1733 Address::List::ConstIterator it3;
1734 for( it3 = a.begin(); it3 != a.end(); ++it3 ) { 1734 for( it3 = a.begin(); it3 != a.end(); ++it3 ) {
1735 (*it3).dump(); 1735 (*it3).dump();
1736 } 1736 }
1737 1737
1738 kdDebug(5700) << " Keys {" << endl; 1738 kdDebug(5700) << " Keys {" << endl;
1739 Key::List k = keys(); 1739 Key::List k = keys();
1740 Key::List::ConstIterator it4; 1740 Key::List::ConstIterator it4;
1741 for( it4 = k.begin(); it4 != k.end(); ++it4 ) { 1741 for( it4 = k.begin(); it4 != k.end(); ++it4 ) {
1742 kdDebug(5700) << " Type: " << int((*it4).type()) << 1742 kdDebug(5700) << " Type: " << int((*it4).type()) <<
1743 " Key: " << (*it4).textData() << 1743 " Key: " << (*it4).textData() <<
1744 " CustomString: " << (*it4).customTypeString() << endl; 1744 " CustomString: " << (*it4).customTypeString() << endl;
1745 } 1745 }
1746 kdDebug(5700) << " }" << endl; 1746 kdDebug(5700) << " }" << endl;
1747 1747
1748 kdDebug(5700) << "}" << endl; 1748 kdDebug(5700) << "}" << endl;
1749} 1749}
1750 1750
1751 1751
1752void Addressee::insertAddress( const Address &address ) 1752void Addressee::insertAddress( const Address &address )
1753{ 1753{
1754 detach(); 1754 detach();
1755 mData->empty = false; 1755 mData->empty = false;
1756 1756
1757 Address::List::Iterator it; 1757 Address::List::Iterator it;
1758 for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) { 1758 for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) {
1759 if ( (*it).id() == address.id() ) { 1759 if ( (*it).id() == address.id() ) {
1760 *it = address; 1760 *it = address;
1761 return; 1761 return;
1762 } 1762 }
1763 } 1763 }
1764 mData->addresses.append( address ); 1764 mData->addresses.append( address );
1765} 1765}
1766 1766
1767void Addressee::removeAddress( const Address &address ) 1767void Addressee::removeAddress( const Address &address )
1768{ 1768{
1769 detach(); 1769 detach();
1770 1770
1771 Address::List::Iterator it; 1771 Address::List::Iterator it;
1772 for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) { 1772 for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) {
1773 if ( (*it).id() == address.id() ) { 1773 if ( (*it).id() == address.id() ) {
1774 mData->addresses.remove( it ); 1774 mData->addresses.remove( it );
1775 return; 1775 return;
1776 } 1776 }
1777 } 1777 }
1778} 1778}
1779 1779
1780Address Addressee::address( int type ) const 1780Address Addressee::address( int type ) const
1781{ 1781{
1782 Address address( type ); 1782 Address address( type );
1783 Address::List::ConstIterator it; 1783 Address::List::ConstIterator it;
1784 for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) { 1784 for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) {
1785 if ( matchBinaryPatternA( (*it).type(), type ) ) { 1785 if ( matchBinaryPatternA( (*it).type(), type ) ) {
1786 if ( (*it).type() & Address::Pref ) 1786 if ( (*it).type() & Address::Pref )
1787 return (*it); 1787 return (*it);
1788 else if ( address.isEmpty() ) 1788 else if ( address.isEmpty() )
1789 address = (*it); 1789 address = (*it);
1790 } 1790 }
1791 } 1791 }
1792 1792
1793 return address; 1793 return address;
1794} 1794}
1795 1795
1796Address::List Addressee::addresses() const 1796Address::List Addressee::addresses() const
1797{ 1797{
1798 return mData->addresses; 1798 return mData->addresses;
1799} 1799}
1800 1800
1801Address::List Addressee::addresses( int type ) const 1801Address::List Addressee::addresses( int type ) const
1802{ 1802{
1803 Address::List list; 1803 Address::List list;
1804 1804
1805 Address::List::ConstIterator it; 1805 Address::List::ConstIterator it;
1806 for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) { 1806 for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) {
1807 if ( matchBinaryPattern( (*it).type(), type ) ) { 1807 if ( matchBinaryPattern( (*it).type(), type ) ) {
1808 list.append( *it ); 1808 list.append( *it );
1809 } 1809 }
1810 } 1810 }
1811 1811
1812 return list; 1812 return list;
1813} 1813}
1814 1814
1815Address Addressee::findAddress( const QString &id ) const 1815Address Addressee::findAddress( const QString &id ) const
1816{ 1816{
1817 Address::List::ConstIterator it; 1817 Address::List::ConstIterator it;
1818 for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) { 1818 for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) {
1819 if ( (*it).id() == id ) { 1819 if ( (*it).id() == id ) {
1820 return *it; 1820 return *it;
1821 } 1821 }
1822 } 1822 }
1823 return Address(); 1823 return Address();
1824} 1824}
1825 1825
1826void Addressee::insertCategory( const QString &c ) 1826void Addressee::insertCategory( const QString &c )
1827{ 1827{
1828 detach(); 1828 detach();
1829 mData->empty = false; 1829 mData->empty = false;
1830 1830
1831 if ( mData->categories.contains( c ) ) return; 1831 if ( mData->categories.contains( c ) ) return;
1832 1832
1833 mData->categories.append( c ); 1833 mData->categories.append( c );
1834} 1834}
1835 1835
1836void Addressee::removeCategory( const QString &c ) 1836void Addressee::removeCategory( const QString &c )
1837{ 1837{
1838 detach(); 1838 detach();
1839 1839
1840 QStringList::Iterator it = mData->categories.find( c ); 1840 QStringList::Iterator it = mData->categories.find( c );
1841 if ( it == mData->categories.end() ) return; 1841 if ( it == mData->categories.end() ) return;
1842 1842
1843 mData->categories.remove( it ); 1843 mData->categories.remove( it );
1844} 1844}
1845 1845
1846bool Addressee::hasCategory( const QString &c ) const 1846bool Addressee::hasCategory( const QString &c ) const
1847{ 1847{
1848 return ( mData->categories.contains( c ) ); 1848 return ( mData->categories.contains( c ) );
1849} 1849}
1850 1850
1851void Addressee::setCategories( const QStringList &c ) 1851void Addressee::setCategories( const QStringList &c )
1852{ 1852{
1853 detach(); 1853 detach();
1854 mData->empty = false; 1854 mData->empty = false;
1855 1855
1856 mData->categories = c; 1856 mData->categories = c;
1857} 1857}
1858 1858
1859QStringList Addressee::categories() const 1859QStringList Addressee::categories() const
1860{ 1860{
1861 return mData->categories; 1861 return mData->categories;
1862} 1862}
1863 1863
1864void Addressee::insertCustom( const QString &app, const QString &name, 1864void Addressee::insertCustom( const QString &app, const QString &name,
1865 const QString &value ) 1865 const QString &value )
1866{ 1866{
1867 if ( value.isNull() || name.isEmpty() || app.isEmpty() ) return; 1867 if ( value.isNull() || name.isEmpty() || app.isEmpty() ) return;
1868 1868
1869 detach(); 1869 detach();
1870 mData->empty = false; 1870 mData->empty = false;
1871 1871
1872 QString qualifiedName = app + "-" + name + ":"; 1872 QString qualifiedName = app + "-" + name + ":";
1873 1873
1874 QStringList::Iterator it; 1874 QStringList::Iterator it;
1875 for( it = mData->custom.begin(); it != mData->custom.end(); ++it ) { 1875 for( it = mData->custom.begin(); it != mData->custom.end(); ++it ) {
1876 if ( (*it).startsWith( qualifiedName ) ) { 1876 if ( (*it).startsWith( qualifiedName ) ) {
1877 (*it) = qualifiedName + value; 1877 (*it) = qualifiedName + value;
1878 return; 1878 return;
1879 } 1879 }
1880 } 1880 }
1881 mData->custom.append( qualifiedName + value ); 1881 mData->custom.append( qualifiedName + value );
1882} 1882}
1883 1883
1884void Addressee::removeCustom( const QString &app, const QString &name) 1884void Addressee::removeCustom( const QString &app, const QString &name)
1885{ 1885{
1886 detach(); 1886 detach();
1887 1887
1888 QString qualifiedName = app + "-" + name + ":"; 1888 QString qualifiedName = app + "-" + name + ":";
1889 1889
1890 QStringList::Iterator it; 1890 QStringList::Iterator it;
1891 for( it = mData->custom.begin(); it != mData->custom.end(); ++it ) { 1891 for( it = mData->custom.begin(); it != mData->custom.end(); ++it ) {
1892 if ( (*it).startsWith( qualifiedName ) ) { 1892 if ( (*it).startsWith( qualifiedName ) ) {
1893 mData->custom.remove( it ); 1893 mData->custom.remove( it );
1894 return; 1894 return;
1895 } 1895 }
1896 } 1896 }
1897} 1897}
1898 1898
1899QString Addressee::custom( const QString &app, const QString &name ) const 1899QString Addressee::custom( const QString &app, const QString &name ) const
1900{ 1900{
1901 QString qualifiedName = app + "-" + name + ":"; 1901 QString qualifiedName = app + "-" + name + ":";
1902 QString value; 1902 QString value;
1903 1903
1904 QStringList::ConstIterator it; 1904 QStringList::ConstIterator it;
1905 for( it = mData->custom.begin(); it != mData->custom.end(); ++it ) { 1905 for( it = mData->custom.begin(); it != mData->custom.end(); ++it ) {
1906 if ( (*it).startsWith( qualifiedName ) ) { 1906 if ( (*it).startsWith( qualifiedName ) ) {
1907 value = (*it).mid( (*it).find( ":" ) + 1 ); 1907 value = (*it).mid( (*it).find( ":" ) + 1 );
1908 break; 1908 break;
1909 } 1909 }
1910 } 1910 }
1911 1911
1912 return value; 1912 return value;
1913} 1913}
1914 1914
1915void Addressee::setCustoms( const QStringList &l ) 1915void Addressee::setCustoms( const QStringList &l )
1916{ 1916{
1917 detach(); 1917 detach();
1918 mData->empty = false; 1918 mData->empty = false;
1919 1919
1920 mData->custom = l; 1920 mData->custom = l;
1921} 1921}
1922 1922
1923QStringList Addressee::customs() const 1923QStringList Addressee::customs() const
1924{ 1924{
1925 return mData->custom; 1925 return mData->custom;
1926} 1926}
1927 1927
1928void Addressee::parseEmailAddress( const QString &rawEmail, QString &fullName, 1928void Addressee::parseEmailAddress( const QString &rawEmail, QString &fullName,
1929 QString &email) 1929 QString &email)
1930{ 1930{
1931 int startPos, endPos, len; 1931 int startPos, endPos, len;
1932 QString partA, partB, result; 1932 QString partA, partB, result;
1933 char endCh = '>'; 1933 char endCh = '>';
1934 1934
1935 startPos = rawEmail.find('<'); 1935 startPos = rawEmail.find('<');
1936 if (startPos < 0) 1936 if (startPos < 0)
1937 { 1937 {
1938 startPos = rawEmail.find('('); 1938 startPos = rawEmail.find('(');
1939 endCh = ')'; 1939 endCh = ')';
1940 } 1940 }
1941 if (startPos < 0) 1941 if (startPos < 0)
1942 { 1942 {
1943 // We couldn't find any separators, so we assume the whole string 1943 // We couldn't find any separators, so we assume the whole string
1944 // is the email address 1944 // is the email address
1945 email = rawEmail; 1945 email = rawEmail;
1946 fullName = ""; 1946 fullName = "";
1947 } 1947 }
1948 else 1948 else
1949 { 1949 {
1950 // We have a start position, try to find an end 1950 // We have a start position, try to find an end
1951 endPos = rawEmail.find(endCh, startPos+1); 1951 endPos = rawEmail.find(endCh, startPos+1);
1952 1952
1953 if (endPos < 0) 1953 if (endPos < 0)
1954 { 1954 {
1955 // We couldn't find the end of the email address. We can only 1955 // We couldn't find the end of the email address. We can only
1956 // assume the entire string is the email address. 1956 // assume the entire string is the email address.
1957 email = rawEmail; 1957 email = rawEmail;
1958 fullName = ""; 1958 fullName = "";
1959 } 1959 }
1960 else 1960 else
1961 { 1961 {
1962 // We have a start and end to the email address 1962 // We have a start and end to the email address
1963 1963
1964 // Grab the name part 1964 // Grab the name part
1965 fullName = rawEmail.left(startPos).stripWhiteSpace(); 1965 fullName = rawEmail.left(startPos).stripWhiteSpace();
1966 1966
1967 // grab the email part 1967 // grab the email part
1968 email = rawEmail.mid(startPos+1, endPos-startPos-1).stripWhiteSpace(); 1968 email = rawEmail.mid(startPos+1, endPos-startPos-1).stripWhiteSpace();
1969 1969
1970 // Check that we do not have any extra characters on the end of the 1970 // Check that we do not have any extra characters on the end of the
1971 // strings 1971 // strings
1972 len = fullName.length(); 1972 len = fullName.length();
1973 if (fullName[0]=='"' && fullName[len-1]=='"') 1973 if (fullName[0]=='"' && fullName[len-1]=='"')
1974 fullName = fullName.mid(1, len-2); 1974 fullName = fullName.mid(1, len-2);
1975 else if (fullName[0]=='<' && fullName[len-1]=='>') 1975 else if (fullName[0]=='<' && fullName[len-1]=='>')
1976 fullName = fullName.mid(1, len-2); 1976 fullName = fullName.mid(1, len-2);
1977 else if (fullName[0]=='(' && fullName[len-1]==')') 1977 else if (fullName[0]=='(' && fullName[len-1]==')')
1978 fullName = fullName.mid(1, len-2); 1978 fullName = fullName.mid(1, len-2);
1979 } 1979 }
1980 } 1980 }
1981} 1981}
1982 1982
1983void Addressee::setResource( Resource *resource ) 1983void Addressee::setResource( Resource *resource )
1984{ 1984{
1985 detach(); 1985 detach();
1986 mData->resource = resource; 1986 mData->resource = resource;
1987} 1987}
1988 1988
1989Resource *Addressee::resource() const 1989Resource *Addressee::resource() const
1990{ 1990{
1991 return mData->resource; 1991 return mData->resource;
1992} 1992}
1993 1993
1994//US 1994//US
1995QString Addressee::resourceLabel() 1995QString Addressee::resourceLabel()
1996{ 1996{
1997 return i18n("Resource"); 1997 return i18n("Resource");
1998} 1998}
1999QString Addressee::categoryLabel()
2000{
2001 return i18n("Category");
2002}
1999 2003
2000void Addressee::setChanged( bool value ) 2004void Addressee::setChanged( bool value )
2001{ 2005{
2002 detach(); 2006 detach();
2003 mData->changed = value; 2007 mData->changed = value;
2004} 2008}
2005 2009
2006bool Addressee::changed() const 2010bool Addressee::changed() const
2007{ 2011{
2008 return mData->changed; 2012 return mData->changed;
2009} 2013}
2010 2014
2011void Addressee::setTagged( bool value ) 2015void Addressee::setTagged( bool value )
2012{ 2016{
2013 detach(); 2017 detach();
2014 mData->tagged = value; 2018 mData->tagged = value;
2015} 2019}
2016 2020
2017bool Addressee::tagged() const 2021bool Addressee::tagged() const
2018{ 2022{
2019 return mData->tagged; 2023 return mData->tagged;
2020} 2024}
2021 2025
2022QDataStream &KABC::operator<<( QDataStream &s, const Addressee &a ) 2026QDataStream &KABC::operator<<( QDataStream &s, const Addressee &a )
2023{ 2027{
2024 if (!a.mData) return s; 2028 if (!a.mData) return s;
2025 2029
2026 s << a.uid(); 2030 s << a.uid();
2027 2031
2028 s << a.mData->name; 2032 s << a.mData->name;
2029 s << a.mData->formattedName; 2033 s << a.mData->formattedName;
2030 s << a.mData->familyName; 2034 s << a.mData->familyName;
2031 s << a.mData->givenName; 2035 s << a.mData->givenName;
2032 s << a.mData->additionalName; 2036 s << a.mData->additionalName;
2033 s << a.mData->prefix; 2037 s << a.mData->prefix;
2034 s << a.mData->suffix; 2038 s << a.mData->suffix;
2035 s << a.mData->nickName; 2039 s << a.mData->nickName;
2036 s << a.mData->birthday; 2040 s << a.mData->birthday;
2037 s << a.mData->mailer; 2041 s << a.mData->mailer;
2038 s << a.mData->timeZone; 2042 s << a.mData->timeZone;
2039 s << a.mData->geo; 2043 s << a.mData->geo;
2040 s << a.mData->title; 2044 s << a.mData->title;
2041 s << a.mData->role; 2045 s << a.mData->role;
2042 s << a.mData->organization; 2046 s << a.mData->organization;
2043 s << a.mData->note; 2047 s << a.mData->note;
2044 s << a.mData->productId; 2048 s << a.mData->productId;
2045 s << a.mData->revision; 2049 s << a.mData->revision;
2046 s << a.mData->sortString; 2050 s << a.mData->sortString;
2047 s << a.mData->url; 2051 s << a.mData->url;
2048 s << a.mData->secrecy; 2052 s << a.mData->secrecy;
2049 s << a.mData->logo; 2053 s << a.mData->logo;
2050 s << a.mData->photo; 2054 s << a.mData->photo;
2051 s << a.mData->sound; 2055 s << a.mData->sound;
2052 s << a.mData->agent; 2056 s << a.mData->agent;
2053 s << a.mData->phoneNumbers; 2057 s << a.mData->phoneNumbers;
2054 s << a.mData->addresses; 2058 s << a.mData->addresses;
2055 s << a.mData->emails; 2059 s << a.mData->emails;
2056 s << a.mData->categories; 2060 s << a.mData->categories;
2057 s << a.mData->custom; 2061 s << a.mData->custom;
2058 s << a.mData->keys; 2062 s << a.mData->keys;
2059 return s; 2063 return s;
2060} 2064}
2061 2065
2062QDataStream &KABC::operator>>( QDataStream &s, Addressee &a ) 2066QDataStream &KABC::operator>>( QDataStream &s, Addressee &a )
2063{ 2067{
2064 if (!a.mData) return s; 2068 if (!a.mData) return s;
2065 2069
2066 s >> a.mData->uid; 2070 s >> a.mData->uid;
2067 2071
2068 s >> a.mData->name; 2072 s >> a.mData->name;
2069 s >> a.mData->formattedName; 2073 s >> a.mData->formattedName;
2070 s >> a.mData->familyName; 2074 s >> a.mData->familyName;
2071 s >> a.mData->givenName; 2075 s >> a.mData->givenName;
2072 s >> a.mData->additionalName; 2076 s >> a.mData->additionalName;
2073 s >> a.mData->prefix; 2077 s >> a.mData->prefix;
2074 s >> a.mData->suffix; 2078 s >> a.mData->suffix;
2075 s >> a.mData->nickName; 2079 s >> a.mData->nickName;
2076 s >> a.mData->birthday; 2080 s >> a.mData->birthday;
2077 s >> a.mData->mailer; 2081 s >> a.mData->mailer;
2078 s >> a.mData->timeZone; 2082 s >> a.mData->timeZone;
2079 s >> a.mData->geo; 2083 s >> a.mData->geo;
2080 s >> a.mData->title; 2084 s >> a.mData->title;
2081 s >> a.mData->role; 2085 s >> a.mData->role;
2082 s >> a.mData->organization; 2086 s >> a.mData->organization;
2083 s >> a.mData->note; 2087 s >> a.mData->note;
2084 s >> a.mData->productId; 2088 s >> a.mData->productId;
2085 s >> a.mData->revision; 2089 s >> a.mData->revision;
2086 s >> a.mData->sortString; 2090 s >> a.mData->sortString;
2087 s >> a.mData->url; 2091 s >> a.mData->url;
2088 s >> a.mData->secrecy; 2092 s >> a.mData->secrecy;
2089 s >> a.mData->logo; 2093 s >> a.mData->logo;
2090 s >> a.mData->photo; 2094 s >> a.mData->photo;
2091 s >> a.mData->sound; 2095 s >> a.mData->sound;
2092 s >> a.mData->agent; 2096 s >> a.mData->agent;
2093 s >> a.mData->phoneNumbers; 2097 s >> a.mData->phoneNumbers;
2094 s >> a.mData->addresses; 2098 s >> a.mData->addresses;
2095 s >> a.mData->emails; 2099 s >> a.mData->emails;
2096 s >> a.mData->categories; 2100 s >> a.mData->categories;
2097 s >> a.mData->custom; 2101 s >> a.mData->custom;
2098 s >> a.mData->keys; 2102 s >> a.mData->keys;
2099 2103
2100 a.mData->empty = false; 2104 a.mData->empty = false;
2101 2105
2102 return s; 2106 return s;
2103} 2107}
2104bool matchBinaryPattern( int value, int pattern ) 2108bool matchBinaryPattern( int value, int pattern )
2105{ 2109{
2106 /** 2110 /**
2107 We want to match all telephonnumbers/addresses which have the bits in the 2111 We want to match all telephonnumbers/addresses which have the bits in the
2108 pattern set. More are allowed. 2112 pattern set. More are allowed.
2109 if pattern == 0 we have a special handling, then we want only those with 2113 if pattern == 0 we have a special handling, then we want only those with
2110 exactly no bit set. 2114 exactly no bit set.
2111 */ 2115 */
2112 if ( pattern == 0 ) 2116 if ( pattern == 0 )
2113 return ( value == 0 ); 2117 return ( value == 0 );
2114 else 2118 else
2115 return ( pattern == ( pattern & value ) ); 2119 return ( pattern == ( pattern & value ) );
2116} 2120}
2117 2121
2118bool matchBinaryPatternP( int value, int pattern ) 2122bool matchBinaryPatternP( int value, int pattern )
2119{ 2123{
2120 2124
2121 if ( pattern == 0 ) 2125 if ( pattern == 0 )
2122 return ( value == 0 ); 2126 return ( value == 0 );
2123 else 2127 else
2124 return ( (pattern |PhoneNumber::Pref ) == ( value |PhoneNumber::Pref ) ); 2128 return ( (pattern |PhoneNumber::Pref ) == ( value |PhoneNumber::Pref ) );
2125} 2129}
2126bool matchBinaryPatternA( int value, int pattern ) 2130bool matchBinaryPatternA( int value, int pattern )
2127{ 2131{
2128 2132
2129 if ( pattern == 0 ) 2133 if ( pattern == 0 )
2130 return ( value == 0 ); 2134 return ( value == 0 );
2131 else 2135 else
2132 return ( (pattern | Address::Pref) == ( value | Address::Pref ) ); 2136 return ( (pattern | Address::Pref) == ( value | Address::Pref ) );
2133} 2137}