-rw-r--r-- | kabc/phonenumber.cpp | 31 |
1 files changed, 13 insertions, 18 deletions
diff --git a/kabc/phonenumber.cpp b/kabc/phonenumber.cpp index 3d82553..abb3b3b 100644 --- a/kabc/phonenumber.cpp +++ b/kabc/phonenumber.cpp @@ -68,66 +68,61 @@ bool PhoneNumber::operator!=( const PhoneNumber &p ) const bool PhoneNumber::simplifyNumber() { QString Number; int i; Number = mNumber.stripWhiteSpace (); mNumber = ""; for ( i = 0; i < Number.length(); ++i) { if ( Number.at(i).isDigit() || Number.at(i) == '+'|| Number.at(i) == '*'|| Number.at(i) == '#' ) mNumber += Number.at(i); } return ( mNumber.length() > 0 ); } // make cellphone compatible void PhoneNumber::simplifyType() { if ( mType & Fax ) mType = Fax; else if ( mType & Cell ) mType = Cell; else if ( mType & Work ) mType = Work ; else if ( mType & Home ) mType = Home; else mType = Pref; } bool PhoneNumber::contains( const PhoneNumber &p ) { - QString Number; - QString Num; - uint i; - Number = mNumber.stripWhiteSpace (); - Num = ""; - for ( i = 0; i < Number.length(); ++i) { - if ( Number.at(i).isDigit() || Number.at(i) == '+'|| Number.at(i) == '*'|| Number.at(i) == '#' ) - Num += Number.at(i); - } - QString NumberR; - QString NumR; - NumberR = p.mNumber.stripWhiteSpace (); - NumR = ""; - for ( i = 0; i < NumberR.length(); ++i) { - if ( NumberR.at(i).isDigit() || NumberR.at(i) == '+'|| NumberR.at(i) == '*'|| NumberR.at(i) == '#' ) - NumR += NumberR.at(i); - } - return (Num == NumR); + PhoneNumber myself; + PhoneNumber other; + myself = *this; + other = p; + myself.simplifyNumber(); + other.simplifyNumber(); + if ( myself.number() != other.number ()) + return false; + myself.simplifyType(); + other.simplifyType(); + if ( myself.type() == other.type()) + return true; + return false; } void PhoneNumber::setId( const QString &id ) { mId = id; } QString PhoneNumber::id() const { return mId; } void PhoneNumber::setNumber( const QString &number ) { mNumber = number; } QString PhoneNumber::number() const { return mNumber; } void PhoneNumber::setType( int type ) { |