-rw-r--r-- | kabc/addressee.cpp | 28 |
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$ using namespace KABC; static bool matchBinaryPattern( int value, int pattern ); +static bool matchBinaryPatternA( int value, int pattern ); +static bool matchBinaryPatternP( int value, int pattern ); struct Addressee::AddresseeData : public KShared { @@ -381,7 +383,7 @@ void Addressee::setOriginalExternalUID( const QString &id ) if ( id == mData->originalExternalUID ) return; detach(); mData->empty = false; - qDebug("*******Set orig uid %s ", id.latin1()); + //qDebug("*******Set orig uid %s ", id.latin1()); mData->originalExternalUID = id; } @@ -394,7 +396,7 @@ void Addressee::setUid( const QString &id ) { if ( id == mData->uid ) return; detach(); - qDebug("****setuid %s ", id.latin1()); + //qDebug("****setuid %s ", id.latin1()); mData->empty = false; mData->uid = id; } @@ -1290,7 +1292,7 @@ PhoneNumber Addressee::phoneNumber( int type ) const PhoneNumber phoneNumber( "", type ); PhoneNumber::List::ConstIterator it; for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { - if ( matchBinaryPattern( (*it).type(), type ) ) { + if ( matchBinaryPatternP( (*it).type(), type ) ) { if ( (*it).type() & PhoneNumber::Pref ) return (*it); else if ( phoneNumber.number().isEmpty() ) @@ -1527,7 +1529,7 @@ Address Addressee::address( int type ) const Address address( type ); Address::List::ConstIterator it; for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) { - if ( matchBinaryPattern( (*it).type(), type ) ) { + if ( matchBinaryPatternA( (*it).type(), type ) ) { if ( (*it).type() & Address::Pref ) return (*it); else if ( address.isEmpty() ) @@ -1835,7 +1837,6 @@ QDataStream &KABC::operator>>( QDataStream &s, Addressee &a ) return s; } - bool matchBinaryPattern( int value, int pattern ) { /** @@ -1849,3 +1850,20 @@ bool matchBinaryPattern( int value, int pattern ) else return ( pattern == ( pattern & value ) ); } + +bool matchBinaryPatternP( int value, int pattern ) +{ + + if ( pattern == 0 ) + return ( value == 0 ); + else + return ( (pattern |PhoneNumber::Pref ) == ( value |PhoneNumber::Pref ) ); +} +bool matchBinaryPatternA( int value, int pattern ) +{ + + if ( pattern == 0 ) + return ( value == 0 ); + else + return ( (pattern | Address::Pref) == ( value | Address::Pref ) ); +} |