summaryrefslogtreecommitdiffabout
path: root/kabc/addressee.cpp
authorzautrix <zautrix>2004-09-18 22:33:39 (UTC)
committer zautrix <zautrix>2004-09-18 22:33:39 (UTC)
commitf370d0f89bcaeeb68bd60152a9812a9cd55e5d8a (patch) (side-by-side diff)
treec1a9de8b305200a7cec885764a0afb4beb92dabb /kabc/addressee.cpp
parent28f894fd2a0dfbd5f09f9e530f359981efe0198c (diff)
downloadkdepimpi-f370d0f89bcaeeb68bd60152a9812a9cd55e5d8a.zip
kdepimpi-f370d0f89bcaeeb68bd60152a9812a9cd55e5d8a.tar.gz
kdepimpi-f370d0f89bcaeeb68bd60152a9812a9cd55e5d8a.tar.bz2
more AB sync
Diffstat (limited to 'kabc/addressee.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--kabc/addressee.cpp99
1 files changed, 97 insertions, 2 deletions
diff --git a/kabc/addressee.cpp b/kabc/addressee.cpp
index 7f04d8f..0f5d605 100644
--- a/kabc/addressee.cpp
+++ b/kabc/addressee.cpp
@@ -174,6 +174,102 @@ bool Addressee::isEmpty() const
{
return mData->empty;
}
+ulong Addressee::getCsum4List( const QStringList & attList)
+{
+ int max = attList.count();
+ ulong cSum = 0;
+ int j,k,i;
+ int add;
+ for ( i = 0; i < max ; ++i ) {
+ QString s = attList[i];
+ if ( ! s.isEmpty() ){
+ j = s.length();
+ for ( k = 0; k < j; ++k ) {
+ int mul = k +1;
+ add = s[k].unicode ();
+ if ( k < 16 )
+ mul = mul * mul;
+ int ii = i+1;
+ add = add * mul *ii*ii*ii;
+ cSum += add;
+ }
+ }
+
+ }
+ //QString dump = attList.join(",");
+ //qDebug("csum: %d %s", cSum,dump.latin1());
+
+ return cSum;
+
+}
+void Addressee::computeCsum(const QString &dev)
+{
+ QStringList l;
+ if ( !mData->name.isEmpty() ) l.append(mData->name);
+ if ( !mData->formattedName.isEmpty() ) l.append(mData->formattedName );
+ if ( !mData->familyName.isEmpty() ) l.append( mData->familyName );
+ if ( !mData->givenName.isEmpty() ) l.append(mData->givenName );
+ if ( !mData->additionalName ) l.append( mData->additionalName );
+ if ( !mData->prefix.isEmpty() ) l.append( mData->prefix );
+ if ( !mData->suffix.isEmpty() ) l.append( mData->suffix );
+ if ( !mData->nickName.isEmpty() ) l.append( mData->nickName );
+ if ( mData->birthday.isValid() ) l.append( mData->birthday.toString() );
+ if ( !mData->mailer.isEmpty() ) l.append( mData->mailer );
+ if ( mData->timeZone.isValid() ) l.append( mData->timeZone.asString() );
+ if ( mData->geo.isValid() ) l.append( mData->geo.asString() );
+ if ( !mData->title .isEmpty() ) l.append( mData->title );
+ if ( !mData->role.isEmpty() ) l.append( mData->role );
+ if ( !mData->organization.isEmpty() ) l.append( mData->organization );
+ if ( !mData->note.isEmpty() ) l.append( mData->note );
+ if ( !mData->productId.isEmpty() ) l.append(mData->productId );
+ if ( !mData->sortString.isEmpty() ) l.append( mData->sortString );
+ if ( mData->secrecy.isValid() ) l.append( mData->secrecy.asString());
+ // if ( !mData->logo.isEmpty() ) l.append( );
+ //if ( !mData->photo.isEmpty() ) l.append( );
+ //if ( !mData->sound.isEmpty() ) l.append( );
+ //if ( !mData->agent.isEmpty() ) l.append( );
+ //if ( mData->url.isValid() ) l.append( );
+#if 0
+ if ( !mData->phoneNumbers.isEmpty() ) l.append( );
+ if ( !mData->addresses.isEmpty() ) l.append( );
+ //if ( !mData->keys.isEmpty() ) l.append( );
+ if ( !mData->emails.isEmpty() ) l.append( );
+ if ( !mData->categories .isEmpty() ) l.append( );
+ if ( !mData->custom.isEmpty() ) l.append( );
+#endif
+ KABC::PhoneNumber::List phoneNumbers;
+ KABC::PhoneNumber::List::Iterator phoneIter;
+
+ QStringList t;
+ for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end();
+ ++phoneIter )
+ t.append( ( *phoneIter ).number()+QString::number( ( *phoneIter ).type() ) );
+ t.sort();
+ uint iii;
+ for ( iii = 0; iii < t.count(); ++iii)
+ l.append( t[iii] );
+ t = mData->emails;
+ t.sort();
+ for ( iii = 0; iii < t.count(); ++iii)
+ l.append( t[iii] );
+ t = mData->categories;
+ t.sort();
+ for ( iii = 0; iii < t.count(); ++iii)
+ l.append( t[iii] );
+ t = mData->custom;
+ t.sort();
+ for ( iii = 0; iii < t.count(); ++iii)
+ l.append( t[iii] );
+ KABC::Address::List::Iterator addressIter;
+ for ( addressIter = mData->addresses.begin(); addressIter != mData->addresses.end();
+ ++addressIter ) {
+ t = (*addressIter).asList();
+ t.sort();
+ for ( iii = 0; iii < t.count(); ++iii)
+ l.append( t[iii] );
+ }
+ setCsum( dev, QString::number (getCsum4List(l)) );
+}
void Addressee::removeID(const QString &prof)
{
detach();
@@ -1450,11 +1546,10 @@ void Addressee::insertCustom( const QString &app, const QString &name,
QStringList::Iterator it;
for( it = mData->custom.begin(); it != mData->custom.end(); ++it ) {
if ( (*it).startsWith( qualifiedName ) ) {
- (*it) = qualifiedName + value;
+ (*it) = qualifiedName + value;
return;
}
}
-
mData->custom.append( qualifiedName + value );
}