summaryrefslogtreecommitdiffabout
path: root/kabc/addressee.cpp
Unidiff
Diffstat (limited to 'kabc/addressee.cpp') (more/less context) (show whitespace changes)
-rw-r--r--kabc/addressee.cpp28
1 files changed, 23 insertions, 5 deletions
diff --git a/kabc/addressee.cpp b/kabc/addressee.cpp
index e241281..31ce1d6 100644
--- a/kabc/addressee.cpp
+++ b/kabc/addressee.cpp
@@ -43,6 +43,8 @@ $Id$
43using namespace KABC; 43using namespace KABC;
44 44
45static bool matchBinaryPattern( int value, int pattern ); 45static bool matchBinaryPattern( int value, int pattern );
46static bool matchBinaryPatternA( int value, int pattern );
47static bool matchBinaryPatternP( int value, int pattern );
46 48
47struct Addressee::AddresseeData : public KShared 49struct Addressee::AddresseeData : public KShared
48{ 50{
@@ -381,7 +383,7 @@ void Addressee::setOriginalExternalUID( const QString &id )
381 if ( id == mData->originalExternalUID ) return; 383 if ( id == mData->originalExternalUID ) return;
382 detach(); 384 detach();
383 mData->empty = false; 385 mData->empty = false;
384 qDebug("*******Set orig uid %s ", id.latin1()); 386 //qDebug("*******Set orig uid %s ", id.latin1());
385 mData->originalExternalUID = id; 387 mData->originalExternalUID = id;
386} 388}
387 389
@@ -394,7 +396,7 @@ void Addressee::setUid( const QString &id )
394{ 396{
395 if ( id == mData->uid ) return; 397 if ( id == mData->uid ) return;
396 detach(); 398 detach();
397 qDebug("****setuid %s ", id.latin1()); 399 //qDebug("****setuid %s ", id.latin1());
398 mData->empty = false; 400 mData->empty = false;
399 mData->uid = id; 401 mData->uid = id;
400} 402}
@@ -1290,7 +1292,7 @@ PhoneNumber Addressee::phoneNumber( int type ) const
1290 PhoneNumber phoneNumber( "", type ); 1292 PhoneNumber phoneNumber( "", type );
1291 PhoneNumber::List::ConstIterator it; 1293 PhoneNumber::List::ConstIterator it;
1292 for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { 1294 for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) {
1293 if ( matchBinaryPattern( (*it).type(), type ) ) { 1295 if ( matchBinaryPatternP( (*it).type(), type ) ) {
1294 if ( (*it).type() & PhoneNumber::Pref ) 1296 if ( (*it).type() & PhoneNumber::Pref )
1295 return (*it); 1297 return (*it);
1296 else if ( phoneNumber.number().isEmpty() ) 1298 else if ( phoneNumber.number().isEmpty() )
@@ -1527,7 +1529,7 @@ Address Addressee::address( int type ) const
1527 Address address( type ); 1529 Address address( type );
1528 Address::List::ConstIterator it; 1530 Address::List::ConstIterator it;
1529 for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) { 1531 for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) {
1530 if ( matchBinaryPattern( (*it).type(), type ) ) { 1532 if ( matchBinaryPatternA( (*it).type(), type ) ) {
1531 if ( (*it).type() & Address::Pref ) 1533 if ( (*it).type() & Address::Pref )
1532 return (*it); 1534 return (*it);
1533 else if ( address.isEmpty() ) 1535 else if ( address.isEmpty() )
@@ -1835,7 +1837,6 @@ QDataStream &KABC::operator>>( QDataStream &s, Addressee &a )
1835 1837
1836 return s; 1838 return s;
1837} 1839}
1838
1839bool matchBinaryPattern( int value, int pattern ) 1840bool matchBinaryPattern( int value, int pattern )
1840{ 1841{
1841 /** 1842 /**
@@ -1849,3 +1850,20 @@ bool matchBinaryPattern( int value, int pattern )
1849 else 1850 else
1850 return ( pattern == ( pattern & value ) ); 1851 return ( pattern == ( pattern & value ) );
1851} 1852}
1853
1854bool matchBinaryPatternP( int value, int pattern )
1855{
1856
1857 if ( pattern == 0 )
1858 return ( value == 0 );
1859 else
1860 return ( (pattern |PhoneNumber::Pref ) == ( value |PhoneNumber::Pref ) );
1861}
1862bool matchBinaryPatternA( int value, int pattern )
1863{
1864
1865 if ( pattern == 0 )
1866 return ( value == 0 );
1867 else
1868 return ( (pattern | Address::Pref) == ( value | Address::Pref ) );
1869}