-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 @@ -42,8 +42,10 @@ $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 { QString uid; @@ -380,9 +382,9 @@ 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; } QString Addressee::originalExternalUID() const @@ -393,9 +395,9 @@ QString Addressee::originalExternalUID() const 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; } @@ -1289,9 +1291,9 @@ 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() ) phoneNumber = (*it); @@ -1526,9 +1528,9 @@ 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() ) address = (*it); @@ -1834,9 +1836,8 @@ QDataStream &KABC::operator>>( QDataStream &s, Addressee &a ) a.mData->empty = false; return s; } - bool matchBinaryPattern( int value, int pattern ) { /** We want to match all telephonnumbers/addresses which have the bits in the @@ -1848,4 +1849,21 @@ bool matchBinaryPattern( int value, int pattern ) return ( value == 0 ); 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 ) ); +} |