summaryrefslogtreecommitdiffabout
path: root/kabc
Unidiff
Diffstat (limited to 'kabc') (more/less context) (show whitespace changes)
-rw-r--r--kabc/addressee.cpp16
-rw-r--r--kabc/addressee.h1
2 files changed, 17 insertions, 0 deletions
diff --git a/kabc/addressee.cpp b/kabc/addressee.cpp
index e571980..19a1845 100644
--- a/kabc/addressee.cpp
+++ b/kabc/addressee.cpp
@@ -270,96 +270,112 @@ void Addressee::computeCsum(const QString &dev)
270 t.sort(); 270 t.sort();
271 for ( iii = 0; iii < t.count(); ++iii) 271 for ( iii = 0; iii < t.count(); ++iii)
272 l.append( t[iii] ); 272 l.append( t[iii] );
273 } 273 }
274 uint cs = getCsum4List(l); 274 uint cs = getCsum4List(l);
275 // qDebug("CSUM computed %d %s %s", cs,QString::number (cs ).latin1(), uid().latin1() ); 275 // qDebug("CSUM computed %d %s %s", cs,QString::number (cs ).latin1(), uid().latin1() );
276 setCsum( dev, QString::number (cs )); 276 setCsum( dev, QString::number (cs ));
277} 277}
278 278
279void Addressee::mergeContact( const Addressee& ad ) 279void Addressee::mergeContact( const Addressee& ad )
280{ 280{
281 281
282 detach(); 282 detach();
283 if ( mData->name.isEmpty() ) mData->name = ad.mData->name; 283 if ( mData->name.isEmpty() ) mData->name = ad.mData->name;
284 if ( mData->formattedName.isEmpty() ) mData->formattedName = ad.mData->formattedName; 284 if ( mData->formattedName.isEmpty() ) mData->formattedName = ad.mData->formattedName;
285 if ( mData->familyName.isEmpty() ) mData->familyName = ad.mData->familyName; 285 if ( mData->familyName.isEmpty() ) mData->familyName = ad.mData->familyName;
286 if ( mData->givenName.isEmpty() ) mData->givenName = ad.mData->givenName ; 286 if ( mData->givenName.isEmpty() ) mData->givenName = ad.mData->givenName ;
287 if ( mData->additionalName ) mData->additionalName = ad.mData->additionalName; 287 if ( mData->additionalName ) mData->additionalName = ad.mData->additionalName;
288 if ( mData->prefix.isEmpty() ) mData->prefix = ad.mData->prefix; 288 if ( mData->prefix.isEmpty() ) mData->prefix = ad.mData->prefix;
289 if ( mData->suffix.isEmpty() ) mData->suffix = ad.mData->suffix; 289 if ( mData->suffix.isEmpty() ) mData->suffix = ad.mData->suffix;
290 if ( mData->nickName.isEmpty() ) mData->nickName = ad.mData->nickName; 290 if ( mData->nickName.isEmpty() ) mData->nickName = ad.mData->nickName;
291 if ( !mData->birthday.isValid() ) 291 if ( !mData->birthday.isValid() )
292 if ( ad.mData->birthday.isValid()) 292 if ( ad.mData->birthday.isValid())
293 mData->birthday = ad.mData->birthday; 293 mData->birthday = ad.mData->birthday;
294 if ( mData->mailer.isEmpty() ) mData->mailer = ad.mData->mailer; 294 if ( mData->mailer.isEmpty() ) mData->mailer = ad.mData->mailer;
295 if ( !mData->timeZone.isValid() ) mData->timeZone = ad.mData->timeZone; 295 if ( !mData->timeZone.isValid() ) mData->timeZone = ad.mData->timeZone;
296 if ( !mData->geo.isValid() ) mData->geo = ad.mData->geo; 296 if ( !mData->geo.isValid() ) mData->geo = ad.mData->geo;
297 if ( mData->title .isEmpty() ) mData->title = ad.mData->title ; 297 if ( mData->title .isEmpty() ) mData->title = ad.mData->title ;
298 if ( mData->role.isEmpty() ) mData->role = ad.mData->role ; 298 if ( mData->role.isEmpty() ) mData->role = ad.mData->role ;
299 if ( mData->organization.isEmpty() ) mData->organization = ad.mData->organization ; 299 if ( mData->organization.isEmpty() ) mData->organization = ad.mData->organization ;
300 if ( mData->note.isEmpty() ) mData->note = ad.mData->note ; 300 if ( mData->note.isEmpty() ) mData->note = ad.mData->note ;
301 if ( mData->productId.isEmpty() ) mData->productId = ad.mData->productId; 301 if ( mData->productId.isEmpty() ) mData->productId = ad.mData->productId;
302 if ( mData->sortString.isEmpty() ) mData->sortString = ad.mData->sortString; 302 if ( mData->sortString.isEmpty() ) mData->sortString = ad.mData->sortString;
303 if ( !mData->secrecy.isValid() ) mData->secrecy = ad.mData->secrecy; 303 if ( !mData->secrecy.isValid() ) mData->secrecy = ad.mData->secrecy;
304 if ( ( !mData->url.isValid() && ad.mData->url.isValid() ) ) mData->url = ad.mData->url ; 304 if ( ( !mData->url.isValid() && ad.mData->url.isValid() ) ) mData->url = ad.mData->url ;
305 305
306 // pending: 306 // pending:
307 // merging phonenumbers 307 // merging phonenumbers
308 // merging addresses 308 // merging addresses
309 // merging emails; 309 // merging emails;
310 // merging categories; 310 // merging categories;
311 // merging custom; 311 // merging custom;
312 // merging keys 312 // merging keys
313 qDebug("merge contact %s ", ad.uid().latin1()); 313 qDebug("merge contact %s ", ad.uid().latin1());
314 setUid( ad.uid() ); 314 setUid( ad.uid() );
315 setRevision( ad.revision() ); 315 setRevision( ad.revision() );
316} 316}
317 317
318void Addressee::simplifyAddresses()
319{
320 if ( mData->addresses.count() < 3 ) return ;
321 int count = 0;
322 Address::List list;
323 Address::List::Iterator it;
324 for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) {
325 if ( count > 1 )
326 list.append( *it );
327 ++count;
328 }
329 for( it = list.begin(); it != list.end(); ++it ) {
330 removeAddress( (*it) );
331 }
332}
333
318// removes all emails but the first 334// removes all emails but the first
319// needed by phone sync 335// needed by phone sync
320void Addressee::simplifyEmails() 336void Addressee::simplifyEmails()
321{ 337{
322 if ( mData->emails.count() == 0 ) return ; 338 if ( mData->emails.count() == 0 ) return ;
323 QString email = mData->emails.first(); 339 QString email = mData->emails.first();
324 detach(); 340 detach();
325 mData->emails.clear(); 341 mData->emails.clear();
326 mData->emails.append( email ); 342 mData->emails.append( email );
327} 343}
328 344
329void Addressee::simplifyPhoneNumbers() 345void Addressee::simplifyPhoneNumbers()
330{ 346{
331 KABC::PhoneNumber::List removeNumbers; 347 KABC::PhoneNumber::List removeNumbers;
332 KABC::PhoneNumber::List::Iterator phoneIter; 348 KABC::PhoneNumber::List::Iterator phoneIter;
333 for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end(); 349 for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end();
334 ++phoneIter ) { 350 ++phoneIter ) {
335 if ( ! ( *phoneIter ).simplifyNumber() ) 351 if ( ! ( *phoneIter ).simplifyNumber() )
336 removeNumbers.append( ( *phoneIter ) ); 352 removeNumbers.append( ( *phoneIter ) );
337 } 353 }
338 for ( phoneIter = removeNumbers.begin(); phoneIter != removeNumbers.end(); 354 for ( phoneIter = removeNumbers.begin(); phoneIter != removeNumbers.end();
339 ++phoneIter ) { 355 ++phoneIter ) {
340 removePhoneNumber(( *phoneIter )); 356 removePhoneNumber(( *phoneIter ));
341 } 357 }
342} 358}
343void Addressee::simplifyPhoneNumberTypes() 359void Addressee::simplifyPhoneNumberTypes()
344{ 360{
345 KABC::PhoneNumber::List::Iterator phoneIter; 361 KABC::PhoneNumber::List::Iterator phoneIter;
346 for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end(); 362 for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end();
347 ++phoneIter ) 363 ++phoneIter )
348 ( *phoneIter ).simplifyType(); 364 ( *phoneIter ).simplifyType();
349} 365}
350void Addressee::removeID(const QString &prof) 366void Addressee::removeID(const QString &prof)
351{ 367{
352 detach(); 368 detach();
353 mData->mExternalId = KIdManager::removeId ( mData->mExternalId, prof); 369 mData->mExternalId = KIdManager::removeId ( mData->mExternalId, prof);
354 370
355} 371}
356void Addressee::setID( const QString & prof , const QString & id ) 372void Addressee::setID( const QString & prof , const QString & id )
357{ 373{
358 detach(); 374 detach();
359 mData->mExternalId = KIdManager::setId ( mData->mExternalId, prof, id ); 375 mData->mExternalId = KIdManager::setId ( mData->mExternalId, prof, id );
360 //qDebug("setID2 %s %s %s",mData->mExternalId.latin1(), prof.latin1(), id.latin1() ); 376 //qDebug("setID2 %s %s %s",mData->mExternalId.latin1(), prof.latin1(), id.latin1() );
361} 377}
362void Addressee::setTempSyncStat( int id ) 378void Addressee::setTempSyncStat( int id )
363{ 379{
364 if ( mData->mTempSyncStat == id ) return; 380 if ( mData->mTempSyncStat == id ) return;
365 detach(); 381 detach();
diff --git a/kabc/addressee.h b/kabc/addressee.h
index 4cafa86..44f0629 100644
--- a/kabc/addressee.h
+++ b/kabc/addressee.h
@@ -73,96 +73,97 @@ class Resource;
73 realName() returns a fully formatted name(). It uses formattedName, if set, 73 realName() returns a fully formatted name(). It uses formattedName, if set,
74 otherwise it constucts the name from the name fields. As fallback, if 74 otherwise it constucts the name from the name fields. As fallback, if
75 nothing else is set it uses name(). 75 nothing else is set it uses name().
76 76
77 name() is the NAME type of RFC2426. It can be used as internal name for the 77 name() is the NAME type of RFC2426. It can be used as internal name for the
78 data enty, but shouldn't be used for displaying the data to the user. 78 data enty, but shouldn't be used for displaying the data to the user.
79 */ 79 */
80class Addressee 80class Addressee
81{ 81{
82 friend QDataStream &operator<<( QDataStream &, const Addressee & ); 82 friend QDataStream &operator<<( QDataStream &, const Addressee & );
83 friend QDataStream &operator>>( QDataStream &, Addressee & ); 83 friend QDataStream &operator>>( QDataStream &, Addressee & );
84 84
85 public: 85 public:
86 typedef QValueList<Addressee> List; 86 typedef QValueList<Addressee> List;
87 87
88 /** 88 /**
89 Construct an empty address book entry. 89 Construct an empty address book entry.
90 */ 90 */
91 Addressee(); 91 Addressee();
92 ~Addressee(); 92 ~Addressee();
93 93
94 Addressee( const Addressee & ); 94 Addressee( const Addressee & );
95 Addressee &operator=( const Addressee & ); 95 Addressee &operator=( const Addressee & );
96 96
97 bool operator==( const Addressee & ) const; 97 bool operator==( const Addressee & ) const;
98 bool operator!=( const Addressee & ) const; 98 bool operator!=( const Addressee & ) const;
99 // sync stuff 99 // sync stuff
100 void setTempSyncStat(int id); 100 void setTempSyncStat(int id);
101 int tempSyncStat() const; 101 int tempSyncStat() const;
102 void setIDStr( const QString & ); 102 void setIDStr( const QString & );
103 QString IDStr() const; 103 QString IDStr() const;
104 void setID( const QString &, const QString & ); 104 void setID( const QString &, const QString & );
105 QString getID( const QString & ); 105 QString getID( const QString & );
106 void setCsum( const QString &, const QString & ); 106 void setCsum( const QString &, const QString & );
107 QString getCsum( const QString & ); 107 QString getCsum( const QString & );
108 void removeID(const QString &); 108 void removeID(const QString &);
109 void computeCsum(const QString &dev); 109 void computeCsum(const QString &dev);
110 ulong getCsum4List( const QStringList & attList); 110 ulong getCsum4List( const QStringList & attList);
111 /** 111 /**
112 Return, if the address book entry is empty. 112 Return, if the address book entry is empty.
113 */ 113 */
114 bool isEmpty() const; 114 bool isEmpty() const;
115 void setExternalUID( const QString &id ); 115 void setExternalUID( const QString &id );
116 QString externalUID() const; 116 QString externalUID() const;
117 void setOriginalExternalUID( const QString &id ); 117 void setOriginalExternalUID( const QString &id );
118 QString originalExternalUID() const; 118 QString originalExternalUID() const;
119 void mergeContact( const Addressee& ad ); 119 void mergeContact( const Addressee& ad );
120 void simplifyEmails(); 120 void simplifyEmails();
121 void simplifyAddresses();
121 void simplifyPhoneNumbers(); 122 void simplifyPhoneNumbers();
122 void simplifyPhoneNumberTypes(); 123 void simplifyPhoneNumberTypes();
123 124
124 /** 125 /**
125 Set unique identifier. 126 Set unique identifier.
126 */ 127 */
127 void setUid( const QString &uid ); 128 void setUid( const QString &uid );
128 /** 129 /**
129 Return unique identifier. 130 Return unique identifier.
130 */ 131 */
131 QString uid() const; 132 QString uid() const;
132 /** 133 /**
133 Return translated label for uid field. 134 Return translated label for uid field.
134 */ 135 */
135 static QString uidLabel(); 136 static QString uidLabel();
136 137
137 /** 138 /**
138 Set name. 139 Set name.
139 */ 140 */
140 void setName( const QString &name ); 141 void setName( const QString &name );
141 /** 142 /**
142 Return name. 143 Return name.
143 */ 144 */
144 QString name() const; 145 QString name() const;
145 /** 146 /**
146 Return translated label for name field. 147 Return translated label for name field.
147 */ 148 */
148 static QString nameLabel(); 149 static QString nameLabel();
149 150
150 /** 151 /**
151 Set formatted name. 152 Set formatted name.
152 */ 153 */
153 void setFormattedName( const QString &formattedName ); 154 void setFormattedName( const QString &formattedName );
154 /** 155 /**
155 Return formatted name. 156 Return formatted name.
156 */ 157 */
157 QString formattedName() const; 158 QString formattedName() const;
158 /** 159 /**
159 Return translated label for formattedName field. 160 Return translated label for formattedName field.
160 */ 161 */
161 static QString formattedNameLabel(); 162 static QString formattedNameLabel();
162 163
163 /** 164 /**
164 Set family name. 165 Set family name.
165 */ 166 */
166 void setFamilyName( const QString &familyName ); 167 void setFamilyName( const QString &familyName );
167 /** 168 /**
168 Return family name. 169 Return family name.