author | zautrix <zautrix> | 2004-10-08 20:03:23 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2004-10-08 20:03:23 (UTC) |
commit | 10a0e05cc4962d9412a7a5faf3d69a3caf6d1c34 (patch) (side-by-side diff) | |
tree | 3105b985a9dbedd31dff52e14fe667eeff4f9ff4 /kabc | |
parent | 13bd085e06b76228321f5a004759fcdf19cca711 (diff) | |
download | kdepimpi-10a0e05cc4962d9412a7a5faf3d69a3caf6d1c34.zip kdepimpi-10a0e05cc4962d9412a7a5faf3d69a3caf6d1c34.tar.gz kdepimpi-10a0e05cc4962d9412a7a5faf3d69a3caf6d1c34.tar.bz2 |
added contact phone support
-rw-r--r-- | kabc/addressee.cpp | 32 | ||||
-rw-r--r-- | kabc/addressee.h | 4 | ||||
-rw-r--r-- | kabc/phonenumber.cpp | 23 | ||||
-rw-r--r-- | kabc/phonenumber.h | 2 |
4 files changed, 61 insertions, 0 deletions
diff --git a/kabc/addressee.cpp b/kabc/addressee.cpp index 25c77f6..e571980 100644 --- a/kabc/addressee.cpp +++ b/kabc/addressee.cpp @@ -306,24 +306,56 @@ void Addressee::mergeContact( const Addressee& ad ) // pending: // merging phonenumbers // merging addresses // merging emails; // merging categories; // merging custom; // merging keys qDebug("merge contact %s ", ad.uid().latin1()); setUid( ad.uid() ); setRevision( ad.revision() ); } +// removes all emails but the first +// needed by phone sync +void Addressee::simplifyEmails() +{ + if ( mData->emails.count() == 0 ) return ; + QString email = mData->emails.first(); + detach(); + mData->emails.clear(); + mData->emails.append( email ); +} + +void Addressee::simplifyPhoneNumbers() +{ + KABC::PhoneNumber::List removeNumbers; + KABC::PhoneNumber::List::Iterator phoneIter; + for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end(); + ++phoneIter ) { + if ( ! ( *phoneIter ).simplifyNumber() ) + removeNumbers.append( ( *phoneIter ) ); + } + for ( phoneIter = removeNumbers.begin(); phoneIter != removeNumbers.end(); + ++phoneIter ) { + removePhoneNumber(( *phoneIter )); + } +} +void Addressee::simplifyPhoneNumberTypes() +{ + KABC::PhoneNumber::List::Iterator phoneIter; + for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end(); + ++phoneIter ) + ( *phoneIter ).simplifyType(); +} void Addressee::removeID(const QString &prof) { detach(); mData->mExternalId = KIdManager::removeId ( mData->mExternalId, prof); } void Addressee::setID( const QString & prof , const QString & id ) { detach(); mData->mExternalId = KIdManager::setId ( mData->mExternalId, prof, id ); //qDebug("setID2 %s %s %s",mData->mExternalId.latin1(), prof.latin1(), id.latin1() ); } diff --git a/kabc/addressee.h b/kabc/addressee.h index 8baa888..4cafa86 100644 --- a/kabc/addressee.h +++ b/kabc/addressee.h @@ -108,24 +108,28 @@ class Addressee void removeID(const QString &); void computeCsum(const QString &dev); ulong getCsum4List( const QStringList & attList); /** Return, if the address book entry is empty. */ bool isEmpty() const; void setExternalUID( const QString &id ); QString externalUID() const; void setOriginalExternalUID( const QString &id ); QString originalExternalUID() const; void mergeContact( const Addressee& ad ); + void simplifyEmails(); + void simplifyPhoneNumbers(); + void simplifyPhoneNumberTypes(); + /** Set unique identifier. */ void setUid( const QString &uid ); /** Return unique identifier. */ QString uid() const; /** Return translated label for uid field. */ static QString uidLabel(); diff --git a/kabc/phonenumber.cpp b/kabc/phonenumber.cpp index 7aeb2ee..e5abc0e 100644 --- a/kabc/phonenumber.cpp +++ b/kabc/phonenumber.cpp @@ -57,24 +57,47 @@ bool PhoneNumber::operator==( const PhoneNumber &p ) const { if ( mNumber != p.mNumber ) return false; if ( mType != p.mType ) return false; return true; } bool PhoneNumber::operator!=( const PhoneNumber &p ) const { return !( p == *this ); } +bool PhoneNumber::simplifyNumber() +{ + QString Number; + int i; + Number = mNumber.stripWhiteSpace (); + mNumber = ""; + if ( Number.at(0) == '+' ) + mNumber += "+"; + for ( i = 0; i < Number.length(); ++i) { + if ( Number.at(i).isDigit() ) + 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; +} void PhoneNumber::setId( const QString &id ) { mId = id; } QString PhoneNumber::id() const { return mId; } void PhoneNumber::setNumber( const QString &number ) { diff --git a/kabc/phonenumber.h b/kabc/phonenumber.h index 1df344f..410a52f 100644 --- a/kabc/phonenumber.h +++ b/kabc/phonenumber.h @@ -139,24 +139,26 @@ class PhoneNumber static TypeList typeList(); /** Returns the translated label for phone number type. */ static QString typeLabel( int type ); /** Returns the translated label for phone number type. @obsolete */ static QString label( int type ); + bool simplifyNumber(); + void simplifyType(); private: void init(); QString mId; int mType; QString mNumber; }; QDataStream &operator<<( QDataStream &, const PhoneNumber & ); QDataStream &operator>>( QDataStream &, PhoneNumber & ); |