summaryrefslogtreecommitdiffabout
path: root/kabc/addressee.cpp
Unidiff
Diffstat (limited to 'kabc/addressee.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--kabc/addressee.cpp2
1 files changed, 2 insertions, 0 deletions
diff --git a/kabc/addressee.cpp b/kabc/addressee.cpp
index 3ce733d..568dfc4 100644
--- a/kabc/addressee.cpp
+++ b/kabc/addressee.cpp
@@ -1558,319 +1558,321 @@ PhoneNumber Addressee::phoneNumber( int type ) const
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#if 0
1686 kdDebug(5700) << "Addressee {" << endl; 1687 kdDebug(5700) << "Addressee {" << endl;
1687 1688
1688 kdDebug(5700) << " Uid: '" << uid() << "'" << endl; 1689 kdDebug(5700) << " Uid: '" << uid() << "'" << endl;
1689 1690
1690 kdDebug(5700) << " Name: '" << name() << "'" << endl; 1691 kdDebug(5700) << " Name: '" << name() << "'" << endl;
1691 kdDebug(5700) << " FormattedName: '" << formattedName() << "'" << endl; 1692 kdDebug(5700) << " FormattedName: '" << formattedName() << "'" << endl;
1692 kdDebug(5700) << " FamilyName: '" << familyName() << "'" << endl; 1693 kdDebug(5700) << " FamilyName: '" << familyName() << "'" << endl;
1693 kdDebug(5700) << " GivenName: '" << givenName() << "'" << endl; 1694 kdDebug(5700) << " GivenName: '" << givenName() << "'" << endl;
1694 kdDebug(5700) << " AdditionalName: '" << additionalName() << "'" << endl; 1695 kdDebug(5700) << " AdditionalName: '" << additionalName() << "'" << endl;
1695 kdDebug(5700) << " Prefix: '" << prefix() << "'" << endl; 1696 kdDebug(5700) << " Prefix: '" << prefix() << "'" << endl;
1696 kdDebug(5700) << " Suffix: '" << suffix() << "'" << endl; 1697 kdDebug(5700) << " Suffix: '" << suffix() << "'" << endl;
1697 kdDebug(5700) << " NickName: '" << nickName() << "'" << endl; 1698 kdDebug(5700) << " NickName: '" << nickName() << "'" << endl;
1698 kdDebug(5700) << " Birthday: '" << birthday().toString() << "'" << endl; 1699 kdDebug(5700) << " Birthday: '" << birthday().toString() << "'" << endl;
1699 kdDebug(5700) << " Mailer: '" << mailer() << "'" << endl; 1700 kdDebug(5700) << " Mailer: '" << mailer() << "'" << endl;
1700 kdDebug(5700) << " TimeZone: '" << timeZone().asString() << "'" << endl; 1701 kdDebug(5700) << " TimeZone: '" << timeZone().asString() << "'" << endl;
1701 kdDebug(5700) << " Geo: '" << geo().asString() << "'" << endl; 1702 kdDebug(5700) << " Geo: '" << geo().asString() << "'" << endl;
1702 kdDebug(5700) << " Title: '" << title() << "'" << endl; 1703 kdDebug(5700) << " Title: '" << title() << "'" << endl;
1703 kdDebug(5700) << " Role: '" << role() << "'" << endl; 1704 kdDebug(5700) << " Role: '" << role() << "'" << endl;
1704 kdDebug(5700) << " Organization: '" << organization() << "'" << endl; 1705 kdDebug(5700) << " Organization: '" << organization() << "'" << endl;
1705 kdDebug(5700) << " Note: '" << note() << "'" << endl; 1706 kdDebug(5700) << " Note: '" << note() << "'" << endl;
1706 kdDebug(5700) << " ProductId: '" << productId() << "'" << endl; 1707 kdDebug(5700) << " ProductId: '" << productId() << "'" << endl;
1707 kdDebug(5700) << " Revision: '" << revision().toString() << "'" << endl; 1708 kdDebug(5700) << " Revision: '" << revision().toString() << "'" << endl;
1708 kdDebug(5700) << " SortString: '" << sortString() << "'" << endl; 1709 kdDebug(5700) << " SortString: '" << sortString() << "'" << endl;
1709 kdDebug(5700) << " Url: '" << url().url() << "'" << endl; 1710 kdDebug(5700) << " Url: '" << url().url() << "'" << endl;
1710 kdDebug(5700) << " Secrecy: '" << secrecy().asString() << "'" << endl; 1711 kdDebug(5700) << " Secrecy: '" << secrecy().asString() << "'" << endl;
1711 kdDebug(5700) << " Logo: '" << logo().asString() << "'" << endl; 1712 kdDebug(5700) << " Logo: '" << logo().asString() << "'" << endl;
1712 kdDebug(5700) << " Photo: '" << photo().asString() << "'" << endl; 1713 kdDebug(5700) << " Photo: '" << photo().asString() << "'" << endl;
1713 kdDebug(5700) << " Sound: '" << sound().asString() << "'" << endl; 1714 kdDebug(5700) << " Sound: '" << sound().asString() << "'" << endl;
1714 kdDebug(5700) << " Agent: '" << agent().asString() << "'" << endl; 1715 kdDebug(5700) << " Agent: '" << agent().asString() << "'" << endl;
1715 1716
1716 kdDebug(5700) << " Emails {" << endl; 1717 kdDebug(5700) << " Emails {" << endl;
1717 QStringList e = emails(); 1718 QStringList e = emails();
1718 QStringList::ConstIterator it; 1719 QStringList::ConstIterator it;
1719 for( it = e.begin(); it != e.end(); ++it ) { 1720 for( it = e.begin(); it != e.end(); ++it ) {
1720 kdDebug(5700) << " " << (*it) << endl; 1721 kdDebug(5700) << " " << (*it) << endl;
1721 } 1722 }
1722 kdDebug(5700) << " }" << endl; 1723 kdDebug(5700) << " }" << endl;
1723 1724
1724 kdDebug(5700) << " PhoneNumbers {" << endl; 1725 kdDebug(5700) << " PhoneNumbers {" << endl;
1725 PhoneNumber::List p = phoneNumbers(); 1726 PhoneNumber::List p = phoneNumbers();
1726 PhoneNumber::List::ConstIterator it2; 1727 PhoneNumber::List::ConstIterator it2;
1727 for( it2 = p.begin(); it2 != p.end(); ++it2 ) { 1728 for( it2 = p.begin(); it2 != p.end(); ++it2 ) {
1728 kdDebug(5700) << " Type: " << int((*it2).type()) << " Number: " << (*it2).number() << endl; 1729 kdDebug(5700) << " Type: " << int((*it2).type()) << " Number: " << (*it2).number() << endl;
1729 } 1730 }
1730 kdDebug(5700) << " }" << endl; 1731 kdDebug(5700) << " }" << endl;
1731 1732
1732 Address::List a = addresses(); 1733 Address::List a = addresses();
1733 Address::List::ConstIterator it3; 1734 Address::List::ConstIterator it3;
1734 for( it3 = a.begin(); it3 != a.end(); ++it3 ) { 1735 for( it3 = a.begin(); it3 != a.end(); ++it3 ) {
1735 (*it3).dump(); 1736 (*it3).dump();
1736 } 1737 }
1737 1738
1738 kdDebug(5700) << " Keys {" << endl; 1739 kdDebug(5700) << " Keys {" << endl;
1739 Key::List k = keys(); 1740 Key::List k = keys();
1740 Key::List::ConstIterator it4; 1741 Key::List::ConstIterator it4;
1741 for( it4 = k.begin(); it4 != k.end(); ++it4 ) { 1742 for( it4 = k.begin(); it4 != k.end(); ++it4 ) {
1742 kdDebug(5700) << " Type: " << int((*it4).type()) << 1743 kdDebug(5700) << " Type: " << int((*it4).type()) <<
1743 " Key: " << (*it4).textData() << 1744 " Key: " << (*it4).textData() <<
1744 " CustomString: " << (*it4).customTypeString() << endl; 1745 " CustomString: " << (*it4).customTypeString() << endl;
1745 } 1746 }
1746 kdDebug(5700) << " }" << endl; 1747 kdDebug(5700) << " }" << endl;
1747 1748
1748 kdDebug(5700) << "}" << endl; 1749 kdDebug(5700) << "}" << endl;
1750#endif
1749} 1751}
1750 1752
1751 1753
1752void Addressee::insertAddress( const Address &address ) 1754void Addressee::insertAddress( const Address &address )
1753{ 1755{
1754 detach(); 1756 detach();
1755 mData->empty = false; 1757 mData->empty = false;
1756 1758
1757 Address::List::Iterator it; 1759 Address::List::Iterator it;
1758 for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) { 1760 for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) {
1759 if ( (*it).id() == address.id() ) { 1761 if ( (*it).id() == address.id() ) {
1760 *it = address; 1762 *it = address;
1761 return; 1763 return;
1762 } 1764 }
1763 } 1765 }
1764 mData->addresses.append( address ); 1766 mData->addresses.append( address );
1765} 1767}
1766 1768
1767void Addressee::removeAddress( const Address &address ) 1769void Addressee::removeAddress( const Address &address )
1768{ 1770{
1769 detach(); 1771 detach();
1770 1772
1771 Address::List::Iterator it; 1773 Address::List::Iterator it;
1772 for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) { 1774 for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) {
1773 if ( (*it).id() == address.id() ) { 1775 if ( (*it).id() == address.id() ) {
1774 mData->addresses.remove( it ); 1776 mData->addresses.remove( it );
1775 return; 1777 return;
1776 } 1778 }
1777 } 1779 }
1778} 1780}
1779 1781
1780Address Addressee::address( int type ) const 1782Address Addressee::address( int type ) const
1781{ 1783{
1782 Address address( type ); 1784 Address address( type );
1783 Address::List::ConstIterator it; 1785 Address::List::ConstIterator it;
1784 for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) { 1786 for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) {
1785 if ( matchBinaryPatternA( (*it).type(), type ) ) { 1787 if ( matchBinaryPatternA( (*it).type(), type ) ) {
1786 if ( (*it).type() & Address::Pref ) 1788 if ( (*it).type() & Address::Pref )
1787 return (*it); 1789 return (*it);
1788 else if ( address.isEmpty() ) 1790 else if ( address.isEmpty() )
1789 address = (*it); 1791 address = (*it);
1790 } 1792 }
1791 } 1793 }
1792 1794
1793 return address; 1795 return address;
1794} 1796}
1795 1797
1796Address::List Addressee::addresses() const 1798Address::List Addressee::addresses() const
1797{ 1799{
1798 return mData->addresses; 1800 return mData->addresses;
1799} 1801}
1800 1802
1801Address::List Addressee::addresses( int type ) const 1803Address::List Addressee::addresses( int type ) const
1802{ 1804{
1803 Address::List list; 1805 Address::List list;
1804 1806
1805 Address::List::ConstIterator it; 1807 Address::List::ConstIterator it;
1806 for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) { 1808 for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) {
1807 if ( matchBinaryPattern( (*it).type(), type ) ) { 1809 if ( matchBinaryPattern( (*it).type(), type ) ) {
1808 list.append( *it ); 1810 list.append( *it );
1809 } 1811 }
1810 } 1812 }
1811 1813
1812 return list; 1814 return list;
1813} 1815}
1814 1816
1815Address Addressee::findAddress( const QString &id ) const 1817Address Addressee::findAddress( const QString &id ) const
1816{ 1818{
1817 Address::List::ConstIterator it; 1819 Address::List::ConstIterator it;
1818 for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) { 1820 for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) {
1819 if ( (*it).id() == id ) { 1821 if ( (*it).id() == id ) {
1820 return *it; 1822 return *it;
1821 } 1823 }
1822 } 1824 }
1823 return Address(); 1825 return Address();
1824} 1826}
1825 1827
1826void Addressee::insertCategory( const QString &c ) 1828void Addressee::insertCategory( const QString &c )
1827{ 1829{
1828 detach(); 1830 detach();
1829 mData->empty = false; 1831 mData->empty = false;
1830 1832
1831 if ( mData->categories.contains( c ) ) return; 1833 if ( mData->categories.contains( c ) ) return;
1832 1834
1833 mData->categories.append( c ); 1835 mData->categories.append( c );
1834} 1836}
1835 1837
1836void Addressee::removeCategory( const QString &c ) 1838void Addressee::removeCategory( const QString &c )
1837{ 1839{
1838 detach(); 1840 detach();
1839 1841
1840 QStringList::Iterator it = mData->categories.find( c ); 1842 QStringList::Iterator it = mData->categories.find( c );
1841 if ( it == mData->categories.end() ) return; 1843 if ( it == mData->categories.end() ) return;
1842 1844
1843 mData->categories.remove( it ); 1845 mData->categories.remove( it );
1844} 1846}
1845 1847
1846bool Addressee::hasCategory( const QString &c ) const 1848bool Addressee::hasCategory( const QString &c ) const
1847{ 1849{
1848 return ( mData->categories.contains( c ) ); 1850 return ( mData->categories.contains( c ) );
1849} 1851}
1850 1852
1851void Addressee::setCategories( const QStringList &c ) 1853void Addressee::setCategories( const QStringList &c )
1852{ 1854{
1853 detach(); 1855 detach();
1854 mData->empty = false; 1856 mData->empty = false;
1855 1857
1856 mData->categories = c; 1858 mData->categories = c;
1857} 1859}
1858 1860
1859QStringList Addressee::categories() const 1861QStringList Addressee::categories() const
1860{ 1862{
1861 return mData->categories; 1863 return mData->categories;
1862} 1864}
1863 1865
1864void Addressee::insertCustom( const QString &app, const QString &name, 1866void Addressee::insertCustom( const QString &app, const QString &name,
1865 const QString &value ) 1867 const QString &value )
1866{ 1868{
1867 if ( value.isNull() || name.isEmpty() || app.isEmpty() ) return; 1869 if ( value.isNull() || name.isEmpty() || app.isEmpty() ) return;
1868 1870
1869 detach(); 1871 detach();
1870 mData->empty = false; 1872 mData->empty = false;
1871 1873
1872 QString qualifiedName = app + "-" + name + ":"; 1874 QString qualifiedName = app + "-" + name + ":";
1873 1875
1874 QStringList::Iterator it; 1876 QStringList::Iterator it;
1875 for( it = mData->custom.begin(); it != mData->custom.end(); ++it ) { 1877 for( it = mData->custom.begin(); it != mData->custom.end(); ++it ) {
1876 if ( (*it).startsWith( qualifiedName ) ) { 1878 if ( (*it).startsWith( qualifiedName ) ) {