summaryrefslogtreecommitdiffabout
path: root/kabc
authorzautrix <zautrix>2005-01-17 19:49:42 (UTC)
committer zautrix <zautrix>2005-01-17 19:49:42 (UTC)
commit522486966ecf041a6e49913b6e420d58d4284837 (patch) (unidiff)
treed15da3e6ef9ec4638eba4aaf9f14ef0c5eaecd04 /kabc
parent32479683283fc9f20d369ac9671ba0f8a33d3381 (diff)
downloadkdepimpi-522486966ecf041a6e49913b6e420d58d4284837.zip
kdepimpi-522486966ecf041a6e49913b6e420d58d4284837.tar.gz
kdepimpi-522486966ecf041a6e49913b6e420d58d4284837.tar.bz2
const fixes
Diffstat (limited to 'kabc') (more/less context) (ignore whitespace changes)
-rw-r--r--kabc/addressbook.cpp4
-rw-r--r--kabc/addressbook.h2
-rw-r--r--kabc/addressee.cpp10
-rw-r--r--kabc/addressee.h10
4 files changed, 13 insertions, 13 deletions
diff --git a/kabc/addressbook.cpp b/kabc/addressbook.cpp
index 4de7da2..9e61261 100644
--- a/kabc/addressbook.cpp
+++ b/kabc/addressbook.cpp
@@ -867,195 +867,195 @@ void AddressBook::removeSyncAddressees( bool removeDeleted )
867 ++it; 867 ++it;
868 removeAddressee( it2 ); 868 removeAddressee( it2 );
869 } else { 869 } else {
870 //qDebug("skipping %s ",(*it).uid().latin1() ); 870 //qDebug("skipping %s ",(*it).uid().latin1() );
871 if ( removeDeleted ) { 871 if ( removeDeleted ) {
872 // we have no postprocessing in the resource, we have to do it here 872 // we have no postprocessing in the resource, we have to do it here
873 // we have to compute csum for all, because it could be the first sync 873 // we have to compute csum for all, because it could be the first sync
874 (*it).setTempSyncStat( SYNC_TEMPSTATE_NEW_ID ); 874 (*it).setTempSyncStat( SYNC_TEMPSTATE_NEW_ID );
875 } 875 }
876 ++it; 876 ++it;
877 } 877 }
878 } 878 }
879 deleteRemovedAddressees(); 879 deleteRemovedAddressees();
880} 880}
881 881
882void AddressBook::removeAddressee( const Iterator &it ) 882void AddressBook::removeAddressee( const Iterator &it )
883{ 883{
884 d->mRemovedAddressees.append( (*it) ); 884 d->mRemovedAddressees.append( (*it) );
885 d->mAddressees.remove( it.d->mIt ); 885 d->mAddressees.remove( it.d->mIt );
886} 886}
887 887
888AddressBook::Iterator AddressBook::find( const Addressee &a ) 888AddressBook::Iterator AddressBook::find( const Addressee &a )
889{ 889{
890 Iterator it; 890 Iterator it;
891 for ( it = begin(); it != end(); ++it ) { 891 for ( it = begin(); it != end(); ++it ) {
892 if ( a.uid() == (*it).uid() ) { 892 if ( a.uid() == (*it).uid() ) {
893 return it; 893 return it;
894 } 894 }
895 } 895 }
896 return end(); 896 return end();
897} 897}
898 898
899Addressee AddressBook::findByUid( const QString &uid ) 899Addressee AddressBook::findByUid( const QString &uid )
900{ 900{
901 Iterator it; 901 Iterator it;
902 for ( it = begin(); it != end(); ++it ) { 902 for ( it = begin(); it != end(); ++it ) {
903 if ( uid == (*it).uid() ) { 903 if ( uid == (*it).uid() ) {
904 return *it; 904 return *it;
905 } 905 }
906 } 906 }
907 return Addressee(); 907 return Addressee();
908} 908}
909void AddressBook::preExternSync( AddressBook* aBook, const QString& csd , bool isSubset ) 909void AddressBook::preExternSync( AddressBook* aBook, const QString& csd , bool isSubset )
910{ 910{
911 //qDebug("AddressBook::preExternSync "); 911 //qDebug("AddressBook::preExternSync ");
912 AddressBook::Iterator it; 912 AddressBook::Iterator it;
913 for ( it = begin(); it != end(); ++it ) { 913 for ( it = begin(); it != end(); ++it ) {
914 (*it).setID( csd, (*it).externalUID() ); 914 (*it).setID( csd, (*it).externalUID() );
915 (*it).computeCsum( csd ); 915 (*it).computeCsum( csd );
916 } 916 }
917 mergeAB( aBook ,csd, isSubset ); 917 mergeAB( aBook ,csd, isSubset );
918} 918}
919void AddressBook::postExternSync( AddressBook* aBook , const QString& csd, bool setID) 919void AddressBook::postExternSync( AddressBook* aBook , const QString& csd, bool setID)
920{ 920{
921 //qDebug("AddressBook::postExternSync "); 921 //qDebug("AddressBook::postExternSync ");
922 AddressBook::Iterator it; 922 AddressBook::Iterator it;
923 int foundEmpty = 0; 923 int foundEmpty = 0;
924 for ( it = begin(); it != end(); ++it ) { 924 for ( it = begin(); it != end(); ++it ) {
925 //qDebug("check uid %s ", (*it).uid().latin1() ); 925 //qDebug("check uid %s ", (*it).uid().latin1() );
926 if ( (*it).tempSyncStat() == SYNC_TEMPSTATE_NEW_ID || 926 if ( (*it).tempSyncStat() == SYNC_TEMPSTATE_NEW_ID ||
927 (*it).tempSyncStat() == SYNC_TEMPSTATE_NEW_CSUM || 927 (*it).tempSyncStat() == SYNC_TEMPSTATE_NEW_CSUM ||
928 (*it).tempSyncStat() == SYNC_TEMPSTATE_ADDED_EXTERNAL) { 928 (*it).tempSyncStat() == SYNC_TEMPSTATE_ADDED_EXTERNAL) {
929 Addressee ad = aBook->findByUid( ( (*it).uid() )); 929 Addressee ad = aBook->findByUid( ( (*it).uid() ));
930 if ( ad.isEmpty() ) { 930 if ( ad.isEmpty() ) {
931 ++foundEmpty; 931 ++foundEmpty;
932 //qDebug("postExternSync:addressee is empty: %s ", (*it).uid().latin1()); 932 //qDebug("postExternSync:addressee is empty: %s ", (*it).uid().latin1());
933 //qDebug("-- formatted name %s ",(*it).formattedName().latin1() ); 933 //qDebug("-- formatted name %s ",(*it).formattedName().latin1() );
934 } else { 934 } else {
935 (*it).setIDStr(":"); 935 (*it).setIDStr(":");
936 if ( setID ) { 936 if ( setID ) {
937 if ( (*it).tempSyncStat() == SYNC_TEMPSTATE_NEW_ID ) 937 if ( (*it).tempSyncStat() == SYNC_TEMPSTATE_NEW_ID )
938 ad.setID( csd, (*it).externalUID() ); 938 ad.setID( csd, (*it).externalUID() );
939 } else 939 } else
940 ad.setID( csd, (*it).uid() ); 940 ad.setID( csd, (*it).uid() );
941 (*it).computeCsum( csd ); 941 (*it).computeCsum( csd );
942 ad.setCsum( csd, (*it).getCsum( csd ) ); 942 ad.setCsum( csd, (*it).getCsum( csd ) );
943 //qDebug("CSUM %s ",(*it).getCsum( csd ).latin1() ); 943 //qDebug("CSUM %s ",(*it).getCsum( csd ).latin1() );
944 aBook->insertAddressee( ad , false); 944 aBook->insertAddressee( ad , false);
945 } 945 }
946 } 946 }
947 } 947 }
948 if ( foundEmpty ) { 948 if ( foundEmpty ) {
949 qDebug("postExternSync:%d empty addressees found:\n probably filtered out by incoming sync filter.",foundEmpty ); 949 qDebug("postExternSync:%d empty addressees found:\n probably filtered out by incoming sync filter.",foundEmpty );
950 } 950 }
951 951
952} 952}
953 953
954bool AddressBook::containsExternalUid( const QString& uid ) 954bool AddressBook::containsExternalUid( const QString& uid )
955{ 955{
956 Iterator it; 956 Iterator it;
957 for ( it = begin(); it != end(); ++it ) { 957 for ( it = begin(); it != end(); ++it ) {
958 if ( uid == (*it).externalUID( ) ) 958 if ( uid == (*it).externalUID( ) )
959 return true; 959 return true;
960 } 960 }
961 return false; 961 return false;
962} 962}
963Addressee AddressBook::findByExternUid( const QString& uid , const QString& profile ) 963const Addressee AddressBook::findByExternUid( const QString& uid , const QString& profile ) const
964{ 964{
965 Iterator it; 965 ConstIterator it;
966 for ( it = begin(); it != end(); ++it ) { 966 for ( it = begin(); it != end(); ++it ) {
967 if ( uid == (*it).getID( profile ) ) 967 if ( uid == (*it).getID( profile ) )
968 return (*it); 968 return (*it);
969 } 969 }
970 return Addressee(); 970 return Addressee();
971} 971}
972void AddressBook::mergeAB( AddressBook *aBook, const QString& profile , bool isSubset ) 972void AddressBook::mergeAB( AddressBook *aBook, const QString& profile , bool isSubset )
973{ 973{
974 Iterator it; 974 Iterator it;
975 Addressee ad; 975 Addressee ad;
976 for ( it = begin(); it != end(); ++it ) { 976 for ( it = begin(); it != end(); ++it ) {
977 ad = aBook->findByExternUid( (*it).externalUID(), profile ); 977 ad = aBook->findByExternUid( (*it).externalUID(), profile );
978 if ( !ad.isEmpty() ) { 978 if ( !ad.isEmpty() ) {
979 (*it).mergeContact( ad ,isSubset); 979 (*it).mergeContact( ad ,isSubset);
980 } 980 }
981 } 981 }
982#if 0 982#if 0
983 // test only 983 // test only
984 for ( it = begin(); it != end(); ++it ) { 984 for ( it = begin(); it != end(); ++it ) {
985 985
986 qDebug("uid %s ", (*it).uid().latin1()); 986 qDebug("uid %s ", (*it).uid().latin1());
987 } 987 }
988#endif 988#endif
989} 989}
990 990
991#if 0 991#if 0
992Addressee::List AddressBook::getExternLastSyncAddressees() 992Addressee::List AddressBook::getExternLastSyncAddressees()
993{ 993{
994 Addressee::List results; 994 Addressee::List results;
995 995
996 Iterator it; 996 Iterator it;
997 for ( it = begin(); it != end(); ++it ) { 997 for ( it = begin(); it != end(); ++it ) {
998 if ( (*it).uid().left( 19 ) == "last-syncAddressee-" ) { 998 if ( (*it).uid().left( 19 ) == "last-syncAddressee-" ) {
999 if ( (*it).familyName().left(4) == "!E: " ) 999 if ( (*it).familyName().left(4) == "!E: " )
1000 results.append( *it ); 1000 results.append( *it );
1001 } 1001 }
1002 } 1002 }
1003 1003
1004 return results; 1004 return results;
1005} 1005}
1006#endif 1006#endif
1007void AddressBook::resetTempSyncStat() 1007void AddressBook::resetTempSyncStat()
1008{ 1008{
1009 Iterator it; 1009 Iterator it;
1010 for ( it = begin(); it != end(); ++it ) { 1010 for ( it = begin(); it != end(); ++it ) {
1011 (*it).setTempSyncStat ( SYNC_TEMPSTATE_INITIAL ); 1011 (*it).setTempSyncStat ( SYNC_TEMPSTATE_INITIAL );
1012 } 1012 }
1013 1013
1014} 1014}
1015 1015
1016QStringList AddressBook:: uidList() 1016QStringList AddressBook:: uidList()
1017{ 1017{
1018 QStringList results; 1018 QStringList results;
1019 Iterator it; 1019 Iterator it;
1020 for ( it = begin(); it != end(); ++it ) { 1020 for ( it = begin(); it != end(); ++it ) {
1021 results.append( (*it).uid() ); 1021 results.append( (*it).uid() );
1022 } 1022 }
1023 return results; 1023 return results;
1024} 1024}
1025 1025
1026 1026
1027Addressee::List AddressBook::allAddressees() 1027Addressee::List AddressBook::allAddressees()
1028{ 1028{
1029 return d->mAddressees; 1029 return d->mAddressees;
1030 1030
1031} 1031}
1032 1032
1033Addressee::List AddressBook::findByName( const QString &name ) 1033Addressee::List AddressBook::findByName( const QString &name )
1034{ 1034{
1035 Addressee::List results; 1035 Addressee::List results;
1036 1036
1037 Iterator it; 1037 Iterator it;
1038 for ( it = begin(); it != end(); ++it ) { 1038 for ( it = begin(); it != end(); ++it ) {
1039 if ( name == (*it).realName() ) { 1039 if ( name == (*it).realName() ) {
1040 results.append( *it ); 1040 results.append( *it );
1041 } 1041 }
1042 } 1042 }
1043 1043
1044 return results; 1044 return results;
1045} 1045}
1046 1046
1047Addressee::List AddressBook::findByEmail( const QString &email ) 1047Addressee::List AddressBook::findByEmail( const QString &email )
1048{ 1048{
1049 Addressee::List results; 1049 Addressee::List results;
1050 QStringList mailList; 1050 QStringList mailList;
1051 1051
1052 Iterator it; 1052 Iterator it;
1053 for ( it = begin(); it != end(); ++it ) { 1053 for ( it = begin(); it != end(); ++it ) {
1054 mailList = (*it).emails(); 1054 mailList = (*it).emails();
1055 for ( QStringList::Iterator ite = mailList.begin(); ite != mailList.end(); ++ite ) { 1055 for ( QStringList::Iterator ite = mailList.begin(); ite != mailList.end(); ++ite ) {
1056 if ( email == (*ite) ) { 1056 if ( email == (*ite) ) {
1057 results.append( *it ); 1057 results.append( *it );
1058 } 1058 }
1059 } 1059 }
1060 } 1060 }
1061 1061
diff --git a/kabc/addressbook.h b/kabc/addressbook.h
index 2351add..18c03b5 100644
--- a/kabc/addressbook.h
+++ b/kabc/addressbook.h
@@ -211,140 +211,140 @@ class AddressBook : public QObject
211 /** 211 /**
212 Returns a list of all addressees in the address book. This list can 212 Returns a list of all addressees in the address book. This list can
213 be sorted with @ref KABC::AddresseeList for example. 213 be sorted with @ref KABC::AddresseeList for example.
214 */ 214 */
215 Addressee::List allAddressees(); 215 Addressee::List allAddressees();
216 216
217 /** 217 /**
218 Find all entries with the specified name in the address book. Returns 218 Find all entries with the specified name in the address book. Returns
219 an empty list, if no entries could be found. 219 an empty list, if no entries could be found.
220 */ 220 */
221 Addressee::List findByName( const QString & ); 221 Addressee::List findByName( const QString & );
222 222
223 /** 223 /**
224 Find all entries with the specified email address in the address book. 224 Find all entries with the specified email address in the address book.
225 Returns an empty list, if no entries could be found. 225 Returns an empty list, if no entries could be found.
226 */ 226 */
227 Addressee::List findByEmail( const QString & ); 227 Addressee::List findByEmail( const QString & );
228 228
229 /** 229 /**
230 Find all entries wich have the specified category in the address book. 230 Find all entries wich have the specified category in the address book.
231 Returns an empty list, if no entries could be found. 231 Returns an empty list, if no entries could be found.
232 */ 232 */
233 Addressee::List findByCategory( const QString & ); 233 Addressee::List findByCategory( const QString & );
234 234
235 /** 235 /**
236 Return a string identifying this addressbook. 236 Return a string identifying this addressbook.
237 */ 237 */
238 virtual QString identifier(); 238 virtual QString identifier();
239 239
240 /** 240 /**
241 Used for debug output. 241 Used for debug output.
242 */ 242 */
243 void dump() const; 243 void dump() const;
244 244
245 void emitAddressBookLocked() { emit addressBookLocked( this ); } 245 void emitAddressBookLocked() { emit addressBookLocked( this ); }
246 void emitAddressBookUnlocked() { emit addressBookUnlocked( this ); } 246 void emitAddressBookUnlocked() { emit addressBookUnlocked( this ); }
247 void emitAddressBookChanged() { emit addressBookChanged( this ); } 247 void emitAddressBookChanged() { emit addressBookChanged( this ); }
248 248
249 /** 249 /**
250 Return list of all Fields known to the address book which are associated 250 Return list of all Fields known to the address book which are associated
251 with the given field category. 251 with the given field category.
252 */ 252 */
253 Field::List fields( int category = Field::All ); 253 Field::List fields( int category = Field::All );
254 254
255 /** 255 /**
256 Add custom field to address book. 256 Add custom field to address book.
257 257
258 @param label User visible label of the field. 258 @param label User visible label of the field.
259 @param category Ored list of field categories. 259 @param category Ored list of field categories.
260 @param key Identifier used as key for reading and writing the field. 260 @param key Identifier used as key for reading and writing the field.
261 @param app String used as application key for reading and writing 261 @param app String used as application key for reading and writing
262 the field. 262 the field.
263 */ 263 */
264 bool addCustomField( const QString &label, int category = Field::All, 264 bool addCustomField( const QString &label, int category = Field::All,
265 const QString &key = QString::null, 265 const QString &key = QString::null,
266 const QString &app = QString::null ); 266 const QString &app = QString::null );
267 267
268 268
269 /** 269 /**
270 Add address book resource. 270 Add address book resource.
271 */ 271 */
272 bool addResource( Resource * ); 272 bool addResource( Resource * );
273 273
274 /** 274 /**
275 Remove address book resource. 275 Remove address book resource.
276 */ 276 */
277 void removeResources(); 277 void removeResources();
278 bool removeResource( Resource * ); 278 bool removeResource( Resource * );
279 279
280 /** 280 /**
281 Return pointer list of all resources. 281 Return pointer list of all resources.
282 */ 282 */
283 QPtrList<Resource> resources(); 283 QPtrList<Resource> resources();
284 284
285 /** 285 /**
286 Set the @p ErrorHandler, that is used by @ref error() to 286 Set the @p ErrorHandler, that is used by @ref error() to
287 provide gui-independend error messages. 287 provide gui-independend error messages.
288 */ 288 */
289 void setErrorHandler( ErrorHandler * ); 289 void setErrorHandler( ErrorHandler * );
290 290
291 /** 291 /**
292 Shows gui independend error messages. 292 Shows gui independend error messages.
293 */ 293 */
294 void error( const QString& ); 294 void error( const QString& );
295 295
296 /** 296 /**
297 Query all resources to clean up their lock files 297 Query all resources to clean up their lock files
298 */ 298 */
299 void cleanUp(); 299 void cleanUp();
300 300
301 // sync stuff 301 // sync stuff
302 //Addressee::List getExternLastSyncAddressees(); 302 //Addressee::List getExternLastSyncAddressees();
303 void resetTempSyncStat(); 303 void resetTempSyncStat();
304 QStringList uidList(); 304 QStringList uidList();
305 void removeSyncAddressees( bool removeDeleted = false ); 305 void removeSyncAddressees( bool removeDeleted = false );
306 void mergeAB( AddressBook *aBook, const QString& profile, bool isSubset ); 306 void mergeAB( AddressBook *aBook, const QString& profile, bool isSubset );
307 Addressee findByExternUid( const QString& uid , const QString& profile ); 307 const Addressee findByExternUid( const QString& uid , const QString& profile ) const;
308 bool containsExternalUid( const QString& uid ); 308 bool containsExternalUid( const QString& uid );
309 309
310 void preExternSync( AddressBook* aBook, const QString& csd, bool isSubset ); 310 void preExternSync( AddressBook* aBook, const QString& csd, bool isSubset );
311 void postExternSync( AddressBook* aBook, const QString& csd , bool setID ); 311 void postExternSync( AddressBook* aBook, const QString& csd , bool setID );
312 signals: 312 signals:
313 /** 313 /**
314 Emitted, when the address book has changed on disk. 314 Emitted, when the address book has changed on disk.
315 */ 315 */
316 void addressBookChanged( AddressBook * ); 316 void addressBookChanged( AddressBook * );
317 317
318 /** 318 /**
319 Emitted, when the address book has been locked for writing. 319 Emitted, when the address book has been locked for writing.
320 */ 320 */
321 void addressBookLocked( AddressBook * ); 321 void addressBookLocked( AddressBook * );
322 322
323 /** 323 /**
324 Emitted, when the address book has been unlocked. 324 Emitted, when the address book has been unlocked.
325 */ 325 */
326 void addressBookUnlocked( AddressBook * ); 326 void addressBookUnlocked( AddressBook * );
327 327
328 protected: 328 protected:
329 void deleteRemovedAddressees(); 329 void deleteRemovedAddressees();
330 void setStandardResource( Resource * ); 330 void setStandardResource( Resource * );
331 Resource *standardResource(); 331 Resource *standardResource();
332 KRES::Manager<Resource> *resourceManager(); 332 KRES::Manager<Resource> *resourceManager();
333 333
334 void init(const QString &config, const QString &family); 334 void init(const QString &config, const QString &family);
335 335
336 private: 336 private:
337//US QPtrList<Resource> mDummy; // Remove in KDE 4 337//US QPtrList<Resource> mDummy; // Remove in KDE 4
338 338
339 339
340 struct AddressBookData; 340 struct AddressBookData;
341 AddressBookData *d; 341 AddressBookData *d;
342 bool blockLSEchange; 342 bool blockLSEchange;
343}; 343};
344 344
345QDataStream &operator<<( QDataStream &, const AddressBook & ); 345QDataStream &operator<<( QDataStream &, const AddressBook & );
346QDataStream &operator>>( QDataStream &, AddressBook & ); 346QDataStream &operator>>( QDataStream &, AddressBook & );
347 347
348} 348}
349 349
350#endif 350#endif
diff --git a/kabc/addressee.cpp b/kabc/addressee.cpp
index d60cd6b..3b238f5 100644
--- a/kabc/addressee.cpp
+++ b/kabc/addressee.cpp
@@ -496,257 +496,257 @@ void Addressee::simplifyAddresses()
496 } 496 }
497} 497}
498 498
499// removes all emails but the first 499// removes all emails but the first
500// needed by phone sync 500// needed by phone sync
501void Addressee::simplifyEmails() 501void Addressee::simplifyEmails()
502{ 502{
503 if ( mData->emails.count() == 0 ) return ; 503 if ( mData->emails.count() == 0 ) return ;
504 QString email = mData->emails.first(); 504 QString email = mData->emails.first();
505 detach(); 505 detach();
506 mData->emails.clear(); 506 mData->emails.clear();
507 mData->emails.append( email ); 507 mData->emails.append( email );
508} 508}
509 509
510void Addressee::simplifyPhoneNumbers() 510void Addressee::simplifyPhoneNumbers()
511{ 511{
512 int max = 4; 512 int max = 4;
513 int inList = mData->phoneNumbers.count(); 513 int inList = mData->phoneNumbers.count();
514 KABC::PhoneNumber::List removeNumbers; 514 KABC::PhoneNumber::List removeNumbers;
515 KABC::PhoneNumber::List::Iterator phoneIter; 515 KABC::PhoneNumber::List::Iterator phoneIter;
516 if ( inList > max ) { 516 if ( inList > max ) {
517 // delete non-preferred numbers 517 // delete non-preferred numbers
518 for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end(); 518 for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end();
519 ++phoneIter ) { 519 ++phoneIter ) {
520 if ( inList > max ) { 520 if ( inList > max ) {
521 if ( ! (( *phoneIter ).type() & PhoneNumber::Pref )) { 521 if ( ! (( *phoneIter ).type() & PhoneNumber::Pref )) {
522 removeNumbers.append( ( *phoneIter ) ); 522 removeNumbers.append( ( *phoneIter ) );
523 --inList; 523 --inList;
524 } 524 }
525 } else 525 } else
526 break; 526 break;
527 } 527 }
528 for ( phoneIter = removeNumbers.begin(); phoneIter != removeNumbers.end(); 528 for ( phoneIter = removeNumbers.begin(); phoneIter != removeNumbers.end();
529 ++phoneIter ) { 529 ++phoneIter ) {
530 removePhoneNumber(( *phoneIter )); 530 removePhoneNumber(( *phoneIter ));
531 } 531 }
532 // delete preferred numbers 532 // delete preferred numbers
533 if ( inList > max ) { 533 if ( inList > max ) {
534 for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end(); 534 for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end();
535 ++phoneIter ) { 535 ++phoneIter ) {
536 if ( inList > max ) { 536 if ( inList > max ) {
537 removeNumbers.append( ( *phoneIter ) ); 537 removeNumbers.append( ( *phoneIter ) );
538 --inList; 538 --inList;
539 } else 539 } else
540 break; 540 break;
541 } 541 }
542 for ( phoneIter = removeNumbers.begin(); phoneIter != removeNumbers.end(); 542 for ( phoneIter = removeNumbers.begin(); phoneIter != removeNumbers.end();
543 ++phoneIter ) { 543 ++phoneIter ) {
544 removePhoneNumber(( *phoneIter )); 544 removePhoneNumber(( *phoneIter ));
545 } 545 }
546 } 546 }
547 } 547 }
548 // remove non-numeric characters 548 // remove non-numeric characters
549 for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end(); 549 for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end();
550 ++phoneIter ) { 550 ++phoneIter ) {
551 if ( ! ( *phoneIter ).simplifyNumber() ) 551 if ( ! ( *phoneIter ).simplifyNumber() )
552 removeNumbers.append( ( *phoneIter ) ); 552 removeNumbers.append( ( *phoneIter ) );
553 } 553 }
554 for ( phoneIter = removeNumbers.begin(); phoneIter != removeNumbers.end(); 554 for ( phoneIter = removeNumbers.begin(); phoneIter != removeNumbers.end();
555 ++phoneIter ) { 555 ++phoneIter ) {
556 removePhoneNumber(( *phoneIter )); 556 removePhoneNumber(( *phoneIter ));
557 } 557 }
558} 558}
559void Addressee::simplifyPhoneNumberTypes() 559void Addressee::simplifyPhoneNumberTypes()
560{ 560{
561 KABC::PhoneNumber::List::Iterator phoneIter; 561 KABC::PhoneNumber::List::Iterator phoneIter;
562 for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end(); 562 for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end();
563 ++phoneIter ) 563 ++phoneIter )
564 ( *phoneIter ).simplifyType(); 564 ( *phoneIter ).simplifyType();
565} 565}
566void Addressee::removeID(const QString &prof) 566void Addressee::removeID(const QString &prof)
567{ 567{
568 detach(); 568 detach();
569 if ( prof.isEmpty() ) 569 if ( prof.isEmpty() )
570 mData->mExternalId = ":"; 570 mData->mExternalId = ":";
571 else 571 else
572 mData->mExternalId = KIdManager::removeId ( mData->mExternalId, prof); 572 mData->mExternalId = KIdManager::removeId ( mData->mExternalId, prof);
573 573
574} 574}
575void Addressee::setID( const QString & prof , const QString & id ) 575void Addressee::setID( const QString & prof , const QString & id )
576{ 576{
577 detach(); 577 detach();
578 mData->mExternalId = KIdManager::setId ( mData->mExternalId, prof, id ); 578 mData->mExternalId = KIdManager::setId ( mData->mExternalId, prof, id );
579 //qDebug("setID2 %s %s %s",mData->mExternalId.latin1(), prof.latin1(), id.latin1() ); 579 //qDebug("setID2 %s %s %s",mData->mExternalId.latin1(), prof.latin1(), id.latin1() );
580} 580}
581void Addressee::setTempSyncStat( int id ) 581void Addressee::setTempSyncStat( int id )
582{ 582{
583 if ( mData->mTempSyncStat == id ) return; 583 if ( mData->mTempSyncStat == id ) return;
584 detach(); 584 detach();
585 mData->mTempSyncStat = id; 585 mData->mTempSyncStat = id;
586} 586}
587int Addressee::tempSyncStat() const 587int Addressee::tempSyncStat() const
588{ 588{
589 return mData->mTempSyncStat; 589 return mData->mTempSyncStat;
590} 590}
591 591
592QString Addressee::getID( const QString & prof) 592const QString Addressee::getID( const QString & prof) const
593{ 593{
594 return KIdManager::getId ( mData->mExternalId, prof ); 594 return KIdManager::getId ( mData->mExternalId, prof );
595} 595}
596 596
597void Addressee::setCsum( const QString & prof , const QString & id ) 597void Addressee::setCsum( const QString & prof , const QString & id )
598{ 598{
599 detach(); 599 detach();
600 //qDebug("setcsum1 %s %s %s",mData->mExternalId.latin1(), prof.latin1(), id.latin1() ); 600 //qDebug("setcsum1 %s %s %s",mData->mExternalId.latin1(), prof.latin1(), id.latin1() );
601 mData->mExternalId = KIdManager::setCsum ( mData->mExternalId, prof, id ); 601 mData->mExternalId = KIdManager::setCsum ( mData->mExternalId, prof, id );
602 //qDebug("setcsum2 %s ",mData->mExternalId.latin1() ); 602 //qDebug("setcsum2 %s ",mData->mExternalId.latin1() );
603} 603}
604 604
605QString Addressee::getCsum( const QString & prof) 605const QString Addressee::getCsum( const QString & prof) const
606{ 606{
607 return KIdManager::getCsum ( mData->mExternalId, prof ); 607 return KIdManager::getCsum ( mData->mExternalId, prof );
608} 608}
609 609
610void Addressee::setIDStr( const QString & s ) 610void Addressee::setIDStr( const QString & s )
611{ 611{
612 detach(); 612 detach();
613 mData->mExternalId = s; 613 mData->mExternalId = s;
614} 614}
615 615
616QString Addressee::IDStr() const 616const QString Addressee::IDStr() const
617{ 617{
618 return mData->mExternalId; 618 return mData->mExternalId;
619} 619}
620 620
621void Addressee::setExternalUID( const QString &id ) 621void Addressee::setExternalUID( const QString &id )
622{ 622{
623 if ( id == mData->externalUID ) return; 623 if ( id == mData->externalUID ) return;
624 detach(); 624 detach();
625 mData->empty = false; 625 mData->empty = false;
626 mData->externalUID = id; 626 mData->externalUID = id;
627} 627}
628 628
629QString Addressee::externalUID() const 629const QString Addressee::externalUID() const
630{ 630{
631 return mData->externalUID; 631 return mData->externalUID;
632} 632}
633void Addressee::setOriginalExternalUID( const QString &id ) 633void Addressee::setOriginalExternalUID( const QString &id )
634{ 634{
635 if ( id == mData->originalExternalUID ) return; 635 if ( id == mData->originalExternalUID ) return;
636 detach(); 636 detach();
637 mData->empty = false; 637 mData->empty = false;
638 //qDebug("*******Set orig uid %s ", id.latin1()); 638 //qDebug("*******Set orig uid %s ", id.latin1());
639 mData->originalExternalUID = id; 639 mData->originalExternalUID = id;
640} 640}
641 641
642QString Addressee::originalExternalUID() const 642QString Addressee::originalExternalUID() const
643{ 643{
644 return mData->originalExternalUID; 644 return mData->originalExternalUID;
645} 645}
646 646
647void Addressee::setUid( const QString &id ) 647void Addressee::setUid( const QString &id )
648{ 648{
649 if ( id == mData->uid ) return; 649 if ( id == mData->uid ) return;
650 detach(); 650 detach();
651 //qDebug("****setuid %s ", id.latin1()); 651 //qDebug("****setuid %s ", id.latin1());
652 mData->empty = false; 652 mData->empty = false;
653 mData->uid = id; 653 mData->uid = id;
654} 654}
655 655
656QString Addressee::uid() const 656const QString Addressee::uid() const
657{ 657{
658 if ( mData->uid.isEmpty() ) 658 if ( mData->uid.isEmpty() )
659 mData->uid = KApplication::randomString( 10 ); 659 mData->uid = KApplication::randomString( 10 );
660 660
661 return mData->uid; 661 return mData->uid;
662} 662}
663 663
664QString Addressee::uidLabel() 664QString Addressee::uidLabel()
665{ 665{
666 return i18n("Unique Identifier"); 666 return i18n("Unique Identifier");
667} 667}
668 668
669void Addressee::setName( const QString &name ) 669void Addressee::setName( const QString &name )
670{ 670{
671 if ( name == mData->name ) return; 671 if ( name == mData->name ) return;
672 detach(); 672 detach();
673 mData->empty = false; 673 mData->empty = false;
674 mData->name = name; 674 mData->name = name;
675} 675}
676 676
677QString Addressee::name() const 677QString Addressee::name() const
678{ 678{
679 return mData->name; 679 return mData->name;
680} 680}
681 681
682QString Addressee::nameLabel() 682QString Addressee::nameLabel()
683{ 683{
684 return i18n("Name"); 684 return i18n("Name");
685} 685}
686 686
687 687
688void Addressee::setFormattedName( const QString &formattedName ) 688void Addressee::setFormattedName( const QString &formattedName )
689{ 689{
690 if ( formattedName == mData->formattedName ) return; 690 if ( formattedName == mData->formattedName ) return;
691 detach(); 691 detach();
692 mData->empty = false; 692 mData->empty = false;
693 mData->formattedName = formattedName; 693 mData->formattedName = formattedName;
694} 694}
695 695
696QString Addressee::formattedName() const 696QString Addressee::formattedName() const
697{ 697{
698 return mData->formattedName; 698 return mData->formattedName;
699} 699}
700 700
701QString Addressee::formattedNameLabel() 701QString Addressee::formattedNameLabel()
702{ 702{
703 return i18n("Formatted Name"); 703 return i18n("Formatted Name");
704} 704}
705 705
706 706
707void Addressee::setFamilyName( const QString &familyName ) 707void Addressee::setFamilyName( const QString &familyName )
708{ 708{
709 if ( familyName == mData->familyName ) return; 709 if ( familyName == mData->familyName ) return;
710 detach(); 710 detach();
711 mData->empty = false; 711 mData->empty = false;
712 mData->familyName = familyName; 712 mData->familyName = familyName;
713} 713}
714 714
715QString Addressee::familyName() const 715QString Addressee::familyName() const
716{ 716{
717 return mData->familyName; 717 return mData->familyName;
718} 718}
719 719
720QString Addressee::familyNameLabel() 720QString Addressee::familyNameLabel()
721{ 721{
722 return i18n("Family Name"); 722 return i18n("Family Name");
723} 723}
724 724
725 725
726void Addressee::setGivenName( const QString &givenName ) 726void Addressee::setGivenName( const QString &givenName )
727{ 727{
728 if ( givenName == mData->givenName ) return; 728 if ( givenName == mData->givenName ) return;
729 detach(); 729 detach();
730 mData->empty = false; 730 mData->empty = false;
731 mData->givenName = givenName; 731 mData->givenName = givenName;
732} 732}
733 733
734QString Addressee::givenName() const 734QString Addressee::givenName() const
735{ 735{
736 return mData->givenName; 736 return mData->givenName;
737} 737}
738 738
739QString Addressee::givenNameLabel() 739QString Addressee::givenNameLabel()
740{ 740{
741 return i18n("Given Name"); 741 return i18n("Given Name");
742} 742}
743 743
744 744
745void Addressee::setAdditionalName( const QString &additionalName ) 745void Addressee::setAdditionalName( const QString &additionalName )
746{ 746{
747 if ( additionalName == mData->additionalName ) return; 747 if ( additionalName == mData->additionalName ) return;
748 detach(); 748 detach();
749 mData->empty = false; 749 mData->empty = false;
750 mData->additionalName = additionalName; 750 mData->additionalName = additionalName;
751} 751}
752 752
diff --git a/kabc/addressee.h b/kabc/addressee.h
index 08d2f56..8051fec 100644
--- a/kabc/addressee.h
+++ b/kabc/addressee.h
@@ -7,224 +7,224 @@
7 modify it under the terms of the GNU Library General Public 7 modify it under the terms of the GNU Library General Public
8 License as published by the Free Software Foundation; either 8 License as published by the Free Software Foundation; either
9 version 2 of the License, or (at your option) any later version. 9 version 2 of the License, or (at your option) any later version.
10 10
11 This library is distributed in the hope that it will be useful, 11 This library is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of 12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 Library General Public License for more details. 14 Library General Public License for more details.
15 15
16 You should have received a copy of the GNU Library General Public License 16 You should have received a copy of the GNU Library General Public License
17 along with this library; see the file COPYING.LIB. If not, write to 17 along with this library; see the file COPYING.LIB. If not, write to
18 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 18 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19 Boston, MA 02111-1307, USA. 19 Boston, MA 02111-1307, USA.
20*/ 20*/
21 21
22/* 22/*
23Enhanced Version of the file for platform independent KDE tools. 23Enhanced Version of the file for platform independent KDE tools.
24Copyright (c) 2004 Ulf Schenk 24Copyright (c) 2004 Ulf Schenk
25 25
26$Id$ 26$Id$
27*/ 27*/
28 28
29#ifndef KABC_ADDRESSEE_H 29#ifndef KABC_ADDRESSEE_H
30#define KABC_ADDRESSEE_H 30#define KABC_ADDRESSEE_H
31 31
32#include <qdatetime.h> 32#include <qdatetime.h>
33#include <qstring.h> 33#include <qstring.h>
34#include <qstringlist.h> 34#include <qstringlist.h>
35#include <qvaluelist.h> 35#include <qvaluelist.h>
36 36
37#include <ksharedptr.h> 37#include <ksharedptr.h>
38#include <kurl.h> 38#include <kurl.h>
39 39
40#include "address.h" 40#include "address.h"
41#include "agent.h" 41#include "agent.h"
42#include "geo.h" 42#include "geo.h"
43#include "key.h" 43#include "key.h"
44#include "phonenumber.h" 44#include "phonenumber.h"
45#include "picture.h" 45#include "picture.h"
46#include "secrecy.h" 46#include "secrecy.h"
47#include "sound.h" 47#include "sound.h"
48#include "timezone.h" 48#include "timezone.h"
49 49
50namespace KABC { 50namespace KABC {
51 51
52class Resource; 52class Resource;
53 53
54/** 54/**
55 @short address book entry 55 @short address book entry
56 56
57 This class represents an entry in the address book. 57 This class represents an entry in the address book.
58 58
59 The data of this class is implicitly shared. You can pass this class by value. 59 The data of this class is implicitly shared. You can pass this class by value.
60 60
61 If you need the name of a field for presenting it to the user you should use 61 If you need the name of a field for presenting it to the user you should use
62 the functions ending in Label(). They return a translated string which can be 62 the functions ending in Label(). They return a translated string which can be
63 used as label for the corresponding field. 63 used as label for the corresponding field.
64 64
65 About the name fields: 65 About the name fields:
66 66
67 givenName() is the first name and familyName() the last name. In some 67 givenName() is the first name and familyName() the last name. In some
68 countries the family name comes first, that's the reason for the 68 countries the family name comes first, that's the reason for the
69 naming. formattedName() is the full name with the correct formatting. 69 naming. formattedName() is the full name with the correct formatting.
70 It is used as an override, when the correct formatting can't be generated 70 It is used as an override, when the correct formatting can't be generated
71 from the other name fields automatically. 71 from the other name fields automatically.
72 72
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 const QString IDStr() const;
104 void setID( const QString &, const QString & ); 104 void setID( const QString &, const QString & );
105 QString getID( const QString & ); 105 const QString getID( const QString & ) const;
106 void setCsum( const QString &, const QString & ); 106 void setCsum( const QString &, const QString & );
107 QString getCsum( const QString & ); 107 const QString getCsum( const QString & ) const ;
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 const 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, bool isSubSet ); 119 void mergeContact( const Addressee& ad, bool isSubSet );
120 void simplifyEmails(); 120 void simplifyEmails();
121 void simplifyAddresses(); 121 void simplifyAddresses();
122 void simplifyPhoneNumbers(); 122 void simplifyPhoneNumbers();
123 void simplifyPhoneNumberTypes(); 123 void simplifyPhoneNumberTypes();
124 bool removeVoice(); 124 bool removeVoice();
125 bool containsAdr(const Addressee& addr ); 125 bool containsAdr(const Addressee& addr );
126 126
127 /** 127 /**
128 Set unique identifier. 128 Set unique identifier.
129 */ 129 */
130 void setUid( const QString &uid ); 130 void setUid( const QString &uid );
131 /** 131 /**
132 Return unique identifier. 132 Return unique identifier.
133 */ 133 */
134 QString uid() const; 134 const QString uid() const;
135 /** 135 /**
136 Return translated label for uid field. 136 Return translated label for uid field.
137 */ 137 */
138 static QString uidLabel(); 138 static QString uidLabel();
139 139
140 /** 140 /**
141 Set name. 141 Set name.
142 */ 142 */
143 void setName( const QString &name ); 143 void setName( const QString &name );
144 /** 144 /**
145 Return name. 145 Return name.
146 */ 146 */
147 QString name() const; 147 QString name() const;
148 /** 148 /**
149 Return translated label for name field. 149 Return translated label for name field.
150 */ 150 */
151 static QString nameLabel(); 151 static QString nameLabel();
152 152
153 /** 153 /**
154 Set formatted name. 154 Set formatted name.
155 */ 155 */
156 void setFormattedName( const QString &formattedName ); 156 void setFormattedName( const QString &formattedName );
157 /** 157 /**
158 Return formatted name. 158 Return formatted name.
159 */ 159 */
160 QString formattedName() const; 160 QString formattedName() const;
161 /** 161 /**
162 Return translated label for formattedName field. 162 Return translated label for formattedName field.
163 */ 163 */
164 static QString formattedNameLabel(); 164 static QString formattedNameLabel();
165 165
166 /** 166 /**
167 Set family name. 167 Set family name.
168 */ 168 */
169 void setFamilyName( const QString &familyName ); 169 void setFamilyName( const QString &familyName );
170 /** 170 /**
171 Return family name. 171 Return family name.
172 */ 172 */
173 QString familyName() const; 173 QString familyName() const;
174 /** 174 /**
175 Return translated label for familyName field. 175 Return translated label for familyName field.
176 */ 176 */
177 static QString familyNameLabel(); 177 static QString familyNameLabel();
178 178
179 /** 179 /**
180 Set given name. 180 Set given name.
181 */ 181 */
182 void setGivenName( const QString &givenName ); 182 void setGivenName( const QString &givenName );
183 /** 183 /**
184 Return given name. 184 Return given name.
185 */ 185 */
186 QString givenName() const; 186 QString givenName() const;
187 /** 187 /**
188 Return translated label for givenName field. 188 Return translated label for givenName field.
189 */ 189 */
190 static QString givenNameLabel(); 190 static QString givenNameLabel();
191 191
192 /** 192 /**
193 Set additional names. 193 Set additional names.
194 */ 194 */
195 void setAdditionalName( const QString &additionalName ); 195 void setAdditionalName( const QString &additionalName );
196 /** 196 /**
197 Return additional names. 197 Return additional names.
198 */ 198 */
199 QString additionalName() const; 199 QString additionalName() const;
200 /** 200 /**
201 Return translated label for additionalName field. 201 Return translated label for additionalName field.
202 */ 202 */
203 static QString additionalNameLabel(); 203 static QString additionalNameLabel();
204 204
205 /** 205 /**
206 Set honorific prefixes. 206 Set honorific prefixes.
207 */ 207 */
208 void setPrefix( const QString &prefix ); 208 void setPrefix( const QString &prefix );
209 /** 209 /**
210 Return honorific prefixes. 210 Return honorific prefixes.
211 */ 211 */
212 QString prefix() const; 212 QString prefix() const;
213 /** 213 /**
214 Return translated label for prefix field. 214 Return translated label for prefix field.
215 */ 215 */
216 static QString prefixLabel(); 216 static QString prefixLabel();
217 217
218 /** 218 /**
219 Set honorific suffixes. 219 Set honorific suffixes.
220 */ 220 */
221 void setSuffix( const QString &suffix ); 221 void setSuffix( const QString &suffix );
222 /** 222 /**
223 Return honorific suffixes. 223 Return honorific suffixes.
224 */ 224 */
225 QString suffix() const; 225 QString suffix() const;
226 /** 226 /**
227 Return translated label for suffix field. 227 Return translated label for suffix field.
228 */ 228 */
229 static QString suffixLabel(); 229 static QString suffixLabel();
230 230