summaryrefslogtreecommitdiffabout
authorzautrix <zautrix>2005-01-17 12:18:59 (UTC)
committer zautrix <zautrix>2005-01-17 12:18:59 (UTC)
commit6b166ece0a576e9be9c71a61fab5424d75a9301f (patch) (unidiff)
treeb88bf3e82cafc0ac279eb46b8ebc61f112083032
parent376ffdba71ab4d7d7988229f38678394a54e5576 (diff)
downloadkdepimpi-6b166ece0a576e9be9c71a61fab5424d75a9301f.zip
kdepimpi-6b166ece0a576e9be9c71a61fab5424d75a9301f.tar.gz
kdepimpi-6b166ece0a576e9be9c71a61fab5424d75a9301f.tar.bz2
many AB fixes
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--kabc/addressbook.cpp9
-rw-r--r--kabc/addressee.cpp8
-rw-r--r--kabc/secrecy.h2
-rw-r--r--kabc/vcard/VCardv.cpp2
-rw-r--r--kaddressbook/filter.cpp2
-rw-r--r--kaddressbook/filter.h2
-rw-r--r--kaddressbook/filtereditdialog.cpp1
-rw-r--r--kaddressbook/kabcore.cpp16
-rw-r--r--kaddressbook/kaddressbookmain.cpp2
-rw-r--r--kaddressbook/viewmanager.cpp3
10 files changed, 30 insertions, 17 deletions
diff --git a/kabc/addressbook.cpp b/kabc/addressbook.cpp
index 8487ff3..4de7da2 100644
--- a/kabc/addressbook.cpp
+++ b/kabc/addressbook.cpp
@@ -859,150 +859,157 @@ void AddressBook::removeSyncAddressees( bool removeDeleted )
859 if (( *it).IDStr() != "changed" ) { 859 if (( *it).IDStr() != "changed" ) {
860 // "changed" is used for tagging changed addressees when syncing with KDE or OL 860 // "changed" is used for tagging changed addressees when syncing with KDE or OL
861 (*it).removeCustom( "KADDRESSBOOK", "X-ExternalID" ); 861 (*it).removeCustom( "KADDRESSBOOK", "X-ExternalID" );
862 (*it).setIDStr(":"); 862 (*it).setIDStr(":");
863 } 863 }
864 if ( ( (*it).tempSyncStat() == SYNC_TEMPSTATE_DELETE && removeDeleted )|| (*it).uid().left( 19 ) == QString("last-syncAddressee-")) { 864 if ( ( (*it).tempSyncStat() == SYNC_TEMPSTATE_DELETE && removeDeleted )|| (*it).uid().left( 19 ) == QString("last-syncAddressee-")) {
865 it2 = it; 865 it2 = it;
866 //qDebug("removing %s ",(*it).uid().latin1() ); 866 //qDebug("removing %s ",(*it).uid().latin1() );
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 for ( it = begin(); it != end(); ++it ) { 924 for ( it = begin(); it != end(); ++it ) {
924 //qDebug("check uid %s ", (*it).uid().latin1() ); 925 //qDebug("check uid %s ", (*it).uid().latin1() );
925 if ( (*it).tempSyncStat() == SYNC_TEMPSTATE_NEW_ID || 926 if ( (*it).tempSyncStat() == SYNC_TEMPSTATE_NEW_ID ||
926 (*it).tempSyncStat() == SYNC_TEMPSTATE_NEW_CSUM || 927 (*it).tempSyncStat() == SYNC_TEMPSTATE_NEW_CSUM ||
927 (*it).tempSyncStat() == SYNC_TEMPSTATE_ADDED_EXTERNAL) { 928 (*it).tempSyncStat() == SYNC_TEMPSTATE_ADDED_EXTERNAL) {
928 Addressee ad = aBook->findByUid( ( (*it).uid() )); 929 Addressee ad = aBook->findByUid( ( (*it).uid() ));
929 if ( ad.isEmpty() ) { 930 if ( ad.isEmpty() ) {
930 qDebug("postExternSync:ERROR addressee is empty: %s ", (*it).uid().latin1()); 931 ++foundEmpty;
932 //qDebug("postExternSync:addressee is empty: %s ", (*it).uid().latin1());
933 //qDebug("-- formatted name %s ",(*it).formattedName().latin1() );
931 } else { 934 } else {
932 (*it).setIDStr(":"); 935 (*it).setIDStr(":");
933 if ( setID ) { 936 if ( setID ) {
934 if ( (*it).tempSyncStat() == SYNC_TEMPSTATE_NEW_ID ) 937 if ( (*it).tempSyncStat() == SYNC_TEMPSTATE_NEW_ID )
935 ad.setID( csd, (*it).externalUID() ); 938 ad.setID( csd, (*it).externalUID() );
936 } else 939 } else
937 ad.setID( csd, (*it).uid() ); 940 ad.setID( csd, (*it).uid() );
938 (*it).computeCsum( csd ); 941 (*it).computeCsum( csd );
939 ad.setCsum( csd, (*it).getCsum( csd ) ); 942 ad.setCsum( csd, (*it).getCsum( csd ) );
940 //qDebug("CSUM %s ",(*it).getCsum( csd ).latin1() ); 943 //qDebug("CSUM %s ",(*it).getCsum( csd ).latin1() );
941 aBook->insertAddressee( ad , false); 944 aBook->insertAddressee( ad , false);
942 } 945 }
943 } 946 }
944 } 947 }
948 if ( foundEmpty ) {
949 qDebug("postExternSync:%d empty addressees found:\n probably filtered out by incoming sync filter.",foundEmpty );
950 }
951
945} 952}
946 953
947bool AddressBook::containsExternalUid( const QString& uid ) 954bool AddressBook::containsExternalUid( const QString& uid )
948{ 955{
949 Iterator it; 956 Iterator it;
950 for ( it = begin(); it != end(); ++it ) { 957 for ( it = begin(); it != end(); ++it ) {
951 if ( uid == (*it).externalUID( ) ) 958 if ( uid == (*it).externalUID( ) )
952 return true; 959 return true;
953 } 960 }
954 return false; 961 return false;
955} 962}
956Addressee AddressBook::findByExternUid( const QString& uid , const QString& profile ) 963Addressee AddressBook::findByExternUid( const QString& uid , const QString& profile )
957{ 964{
958 Iterator it; 965 Iterator it;
959 for ( it = begin(); it != end(); ++it ) { 966 for ( it = begin(); it != end(); ++it ) {
960 if ( uid == (*it).getID( profile ) ) 967 if ( uid == (*it).getID( profile ) )
961 return (*it); 968 return (*it);
962 } 969 }
963 return Addressee(); 970 return Addressee();
964} 971}
965void AddressBook::mergeAB( AddressBook *aBook, const QString& profile , bool isSubset ) 972void AddressBook::mergeAB( AddressBook *aBook, const QString& profile , bool isSubset )
966{ 973{
967 Iterator it; 974 Iterator it;
968 Addressee ad; 975 Addressee ad;
969 for ( it = begin(); it != end(); ++it ) { 976 for ( it = begin(); it != end(); ++it ) {
970 ad = aBook->findByExternUid( (*it).externalUID(), profile ); 977 ad = aBook->findByExternUid( (*it).externalUID(), profile );
971 if ( !ad.isEmpty() ) { 978 if ( !ad.isEmpty() ) {
972 (*it).mergeContact( ad ,isSubset); 979 (*it).mergeContact( ad ,isSubset);
973 } 980 }
974 } 981 }
975#if 0 982#if 0
976 // test only 983 // test only
977 for ( it = begin(); it != end(); ++it ) { 984 for ( it = begin(); it != end(); ++it ) {
978 985
979 qDebug("uid %s ", (*it).uid().latin1()); 986 qDebug("uid %s ", (*it).uid().latin1());
980 } 987 }
981#endif 988#endif
982} 989}
983 990
984#if 0 991#if 0
985Addressee::List AddressBook::getExternLastSyncAddressees() 992Addressee::List AddressBook::getExternLastSyncAddressees()
986{ 993{
987 Addressee::List results; 994 Addressee::List results;
988 995
989 Iterator it; 996 Iterator it;
990 for ( it = begin(); it != end(); ++it ) { 997 for ( it = begin(); it != end(); ++it ) {
991 if ( (*it).uid().left( 19 ) == "last-syncAddressee-" ) { 998 if ( (*it).uid().left( 19 ) == "last-syncAddressee-" ) {
992 if ( (*it).familyName().left(4) == "!E: " ) 999 if ( (*it).familyName().left(4) == "!E: " )
993 results.append( *it ); 1000 results.append( *it );
994 } 1001 }
995 } 1002 }
996 1003
997 return results; 1004 return results;
998} 1005}
999#endif 1006#endif
1000void AddressBook::resetTempSyncStat() 1007void AddressBook::resetTempSyncStat()
1001{ 1008{
1002 Iterator it; 1009 Iterator it;
1003 for ( it = begin(); it != end(); ++it ) { 1010 for ( it = begin(); it != end(); ++it ) {
1004 (*it).setTempSyncStat ( SYNC_TEMPSTATE_INITIAL ); 1011 (*it).setTempSyncStat ( SYNC_TEMPSTATE_INITIAL );
1005 } 1012 }
1006 1013
1007} 1014}
1008 1015
diff --git a/kabc/addressee.cpp b/kabc/addressee.cpp
index 568dfc4..d60cd6b 100644
--- a/kabc/addressee.cpp
+++ b/kabc/addressee.cpp
@@ -194,150 +194,152 @@ ulong Addressee::getCsum4List( const QStringList & attList)
194 if ( k < 16 ) 194 if ( k < 16 )
195 mul = mul * mul; 195 mul = mul * mul;
196 int ii = i+1; 196 int ii = i+1;
197 add = add * mul *ii*ii*ii; 197 add = add * mul *ii*ii*ii;
198 cSum += add; 198 cSum += add;
199 } 199 }
200 } 200 }
201 201
202 } 202 }
203 //QString dump = attList.join(","); 203 //QString dump = attList.join(",");
204 //qDebug("csum: %d %s", cSum,dump.latin1()); 204 //qDebug("csum: %d %s", cSum,dump.latin1());
205 205
206 return cSum; 206 return cSum;
207 207
208} 208}
209void Addressee::computeCsum(const QString &dev) 209void Addressee::computeCsum(const QString &dev)
210{ 210{
211 QStringList l; 211 QStringList l;
212 //if ( !mData->name.isEmpty() ) l.append(mData->name); 212 //if ( !mData->name.isEmpty() ) l.append(mData->name);
213 //if ( !mData->formattedName.isEmpty() ) l.append(mData->formattedName ); 213 //if ( !mData->formattedName.isEmpty() ) l.append(mData->formattedName );
214 if ( !mData->familyName.isEmpty() ) l.append( mData->familyName ); 214 if ( !mData->familyName.isEmpty() ) l.append( mData->familyName );
215 if ( !mData->givenName.isEmpty() ) l.append(mData->givenName ); 215 if ( !mData->givenName.isEmpty() ) l.append(mData->givenName );
216 if ( !mData->additionalName.isEmpty() ) l.append( mData->additionalName ); 216 if ( !mData->additionalName.isEmpty() ) l.append( mData->additionalName );
217 if ( !mData->prefix.isEmpty() ) l.append( mData->prefix ); 217 if ( !mData->prefix.isEmpty() ) l.append( mData->prefix );
218 if ( !mData->suffix.isEmpty() ) l.append( mData->suffix ); 218 if ( !mData->suffix.isEmpty() ) l.append( mData->suffix );
219 if ( !mData->nickName.isEmpty() ) l.append( mData->nickName ); 219 if ( !mData->nickName.isEmpty() ) l.append( mData->nickName );
220 if ( mData->birthday.isValid() ) l.append( mData->birthday.toString() ); 220 if ( mData->birthday.isValid() ) l.append( mData->birthday.toString() );
221 if ( !mData->mailer.isEmpty() ) l.append( mData->mailer ); 221 if ( !mData->mailer.isEmpty() ) l.append( mData->mailer );
222 if ( mData->timeZone.isValid() ) l.append( mData->timeZone.asString() ); 222 if ( mData->timeZone.isValid() ) l.append( mData->timeZone.asString() );
223 if ( mData->geo.isValid() ) l.append( mData->geo.asString() ); 223 if ( mData->geo.isValid() ) l.append( mData->geo.asString() );
224 if ( !mData->title .isEmpty() ) l.append( mData->title ); 224 if ( !mData->title .isEmpty() ) l.append( mData->title );
225 if ( !mData->role.isEmpty() ) l.append( mData->role ); 225 if ( !mData->role.isEmpty() ) l.append( mData->role );
226 if ( !mData->organization.isEmpty() ) l.append( mData->organization ); 226 if ( !mData->organization.isEmpty() ) l.append( mData->organization );
227 if ( !mData->note.isEmpty() ) l.append( mData->note ); 227 if ( !mData->note.isEmpty() ) l.append( mData->note );
228 if ( !mData->productId.isEmpty() ) l.append(mData->productId ); 228 if ( !mData->productId.isEmpty() ) l.append(mData->productId );
229 if ( !mData->sortString.isEmpty() ) l.append( mData->sortString ); 229 if ( !mData->sortString.isEmpty() ) l.append( mData->sortString );
230 if ( mData->secrecy.isValid() ) l.append( mData->secrecy.asString()); 230 if ( mData->secrecy.isValid() ) l.append( mData->secrecy.asString());
231 // if ( !mData->logo.isEmpty() ) l.append( ); 231 // if ( !mData->logo.isEmpty() ) l.append( );
232 //if ( !mData->photo.isEmpty() ) l.append( ); 232 //if ( !mData->photo.isEmpty() ) l.append( );
233 //if ( !mData->sound.isEmpty() ) l.append( ); 233 //if ( !mData->sound.isEmpty() ) l.append( );
234 //if ( !mData->agent.isEmpty() ) l.append( ); 234 //if ( !mData->agent.isEmpty() ) l.append( );
235 if ( mData->url.isValid() ) 235 if ( mData->url.isValid() )
236 if ( ! mData->url.path().isEmpty()) l.append( mData->url.path() ); 236 if ( ! mData->url.path().isEmpty()) l.append( mData->url.path() );
237 KABC::PhoneNumber::List phoneNumbers; 237 KABC::PhoneNumber::List phoneNumbers;
238 KABC::PhoneNumber::List::Iterator phoneIter; 238 KABC::PhoneNumber::List::Iterator phoneIter;
239 239
240 QStringList t; 240 QStringList t;
241 for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end(); 241 for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end();
242 ++phoneIter ) 242 ++phoneIter )
243 t.append( ( *phoneIter ).number()+QString::number( ( *phoneIter ).type() ) ); 243 t.append( ( *phoneIter ).number()+QString::number( ( *phoneIter ).type() ) );
244 t.sort(); 244 t.sort();
245 uint iii; 245 uint iii;
246 for ( iii = 0; iii < t.count(); ++iii) 246 for ( iii = 0; iii < t.count(); ++iii)
247 l.append( t[iii] ); 247 l.append( t[iii] );
248 t = mData->emails; 248 t = mData->emails;
249 t.sort(); 249 t.sort();
250 for ( iii = 0; iii < t.count(); ++iii) 250 for ( iii = 0; iii < t.count(); ++iii)
251 l.append( t[iii] ); 251 l.append( t[iii] );
252 t = mData->categories; 252 t = mData->categories;
253 t.sort(); 253 t.sort();
254 for ( iii = 0; iii < t.count(); ++iii) 254 for ( iii = 0; iii < t.count(); ++iii)
255 l.append( t[iii] ); 255 l.append( t[iii] );
256 t = mData->custom; 256 t = mData->custom;
257 t.sort(); 257 t.sort();
258 for ( iii = 0; iii < t.count(); ++iii) 258 for ( iii = 0; iii < t.count(); ++iii)
259 if ( t[iii].left( 25 ) != "KADDRESSBOOK-X-ExternalID" ) { 259 if ( t[iii].left( 25 ) != "KADDRESSBOOK-X-ExternalID" ) {
260 int find = t[iii].find (':')+1; 260 int find = t[iii].find (':')+1;
261 //qDebug("lennnn %d %d ", find, t[iii].length()); 261 //qDebug("lennnn %d %d ", find, t[iii].length());
262 if ( find < t[iii].length()) 262 if ( find < t[iii].length())
263 l.append( t[iii] ); 263 l.append( t[iii] );
264 264
265 } 265 }
266 KABC::Address::List::Iterator addressIter; 266 KABC::Address::List::Iterator addressIter;
267 for ( addressIter = mData->addresses.begin(); addressIter != mData->addresses.end(); 267 for ( addressIter = mData->addresses.begin(); addressIter != mData->addresses.end();
268 ++addressIter ) { 268 ++addressIter ) {
269 t = (*addressIter).asList(); 269 t = (*addressIter).asList();
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
275#if 0 276#if 0
276 for ( iii = 0; iii < l.count(); ++iii) 277 for ( iii = 0; iii < l.count(); ++iii)
277 qDebug("%d***%s***",iii,l[iii].latin1()); 278 qDebug("%d***%s***",iii,l[iii].latin1());
278 qDebug("CSUM computed %d %s %s", cs,QString::number (cs ).latin1(), uid().latin1() ); 279 qDebug("CSUM computed %d %s %s", cs,QString::number (cs ).latin1(), uid().latin1() );
279#endif 280#endif
281
280 setCsum( dev, QString::number (cs )); 282 setCsum( dev, QString::number (cs ));
281} 283}
282 284
283void Addressee::mergeContact( const Addressee& ad , bool isSubSet) // = false) 285void Addressee::mergeContact( const Addressee& ad , bool isSubSet) // = false)
284{ 286{
285 287
286 detach(); 288 detach();
287 if ( mData->name.isEmpty() ) mData->name = ad.mData->name; 289 if ( mData->name.isEmpty() ) mData->name = ad.mData->name;
288 if ( mData->formattedName.isEmpty() ) mData->formattedName = ad.mData->formattedName; 290 if ( mData->formattedName.isEmpty() ) mData->formattedName = ad.mData->formattedName;
289 if ( mData->familyName.isEmpty() ) mData->familyName = ad.mData->familyName; 291 if ( mData->familyName.isEmpty() ) mData->familyName = ad.mData->familyName;
290 if ( mData->givenName.isEmpty() ) mData->givenName = ad.mData->givenName ; 292 if ( mData->givenName.isEmpty() ) mData->givenName = ad.mData->givenName ;
291 if ( mData->additionalName ) mData->additionalName = ad.mData->additionalName; 293 if ( mData->additionalName ) mData->additionalName = ad.mData->additionalName;
292 if ( mData->prefix.isEmpty() ) mData->prefix = ad.mData->prefix; 294 if ( mData->prefix.isEmpty() ) mData->prefix = ad.mData->prefix;
293 if ( mData->suffix.isEmpty() ) mData->suffix = ad.mData->suffix; 295 if ( mData->suffix.isEmpty() ) mData->suffix = ad.mData->suffix;
294 if ( mData->nickName.isEmpty() ) mData->nickName = ad.mData->nickName; 296 if ( mData->nickName.isEmpty() ) mData->nickName = ad.mData->nickName;
295 if ( !mData->birthday.isValid() ) 297 if ( !mData->birthday.isValid() )
296 if ( ad.mData->birthday.isValid()) 298 if ( ad.mData->birthday.isValid())
297 mData->birthday = ad.mData->birthday; 299 mData->birthday = ad.mData->birthday;
298 if ( mData->mailer.isEmpty() ) mData->mailer = ad.mData->mailer; 300 if ( mData->mailer.isEmpty() ) mData->mailer = ad.mData->mailer;
299 if ( !mData->timeZone.isValid() ) mData->timeZone = ad.mData->timeZone; 301 if ( !mData->timeZone.isValid() ) mData->timeZone = ad.mData->timeZone;
300 if ( !mData->geo.isValid() ) mData->geo = ad.mData->geo; 302 if ( !mData->geo.isValid() ) mData->geo = ad.mData->geo;
301 if ( mData->title .isEmpty() ) mData->title = ad.mData->title ; 303 if ( mData->title .isEmpty() ) mData->title = ad.mData->title ;
302 if ( mData->role.isEmpty() ) mData->role = ad.mData->role ; 304 if ( mData->role.isEmpty() ) mData->role = ad.mData->role ;
303 if ( mData->organization.isEmpty() ) mData->organization = ad.mData->organization ; 305 if ( mData->organization.isEmpty() ) mData->organization = ad.mData->organization ;
304 if ( mData->note.isEmpty() ) mData->note = ad.mData->note ; 306 if ( mData->note.isEmpty() ) mData->note = ad.mData->note ;
305 if ( mData->productId.isEmpty() ) mData->productId = ad.mData->productId; 307 if ( mData->productId.isEmpty() ) mData->productId = ad.mData->productId;
306 if ( mData->sortString.isEmpty() ) mData->sortString = ad.mData->sortString; 308 if ( mData->sortString.isEmpty() ) mData->sortString = ad.mData->sortString;
307 if ( !mData->secrecy.isValid() ) mData->secrecy = ad.mData->secrecy; 309 if ( !mData->secrecy.isValid() ) mData->secrecy = ad.mData->secrecy;
308 if ( ( !mData->url.isValid() && ad.mData->url.isValid() ) ) mData->url = ad.mData->url ; 310 if ( ( !mData->url.isValid() && ad.mData->url.isValid() ) ) mData->url = ad.mData->url ;
309 QStringList t; 311 QStringList t;
310 QStringList tAD; 312 QStringList tAD;
311 uint iii; 313 uint iii;
312 314
313 // ********** phone numbers 315 // ********** phone numbers
314 PhoneNumber::List phoneAD = ad.phoneNumbers(); 316 PhoneNumber::List phoneAD = ad.phoneNumbers();
315 PhoneNumber::List::Iterator phoneItAD; 317 PhoneNumber::List::Iterator phoneItAD;
316 for ( phoneItAD = phoneAD.begin(); phoneItAD != phoneAD.end(); ++phoneItAD ) { 318 for ( phoneItAD = phoneAD.begin(); phoneItAD != phoneAD.end(); ++phoneItAD ) {
317 bool found = false; 319 bool found = false;
318 PhoneNumber::List::Iterator it; 320 PhoneNumber::List::Iterator it;
319 for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { 321 for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) {
320 if ( ( *phoneItAD ).contains( (*it) ) ) { 322 if ( ( *phoneItAD ).contains( (*it) ) ) {
321 found = true; 323 found = true;
322 (*it).setType( ( *phoneItAD ).type() ); 324 (*it).setType( ( *phoneItAD ).type() );
323 (*it).setNumber( ( *phoneItAD ).number() ); 325 (*it).setNumber( ( *phoneItAD ).number() );
324 break; 326 break;
325 } 327 }
326 } 328 }
327 // if ( isSubSet && ! found ) 329 // if ( isSubSet && ! found )
328 if ( ! found ) // LR try this one... 330 if ( ! found ) // LR try this one...
329 mData->phoneNumbers.append( *phoneItAD ); 331 mData->phoneNumbers.append( *phoneItAD );
330 } 332 }
331 if ( isSubSet ) { 333 if ( isSubSet ) {
332 // ************* emails; 334 // ************* emails;
333 t = mData->emails; 335 t = mData->emails;
334 tAD = ad.mData->emails; 336 tAD = ad.mData->emails;
335 for ( iii = 0; iii < tAD.count(); ++iii) 337 for ( iii = 0; iii < tAD.count(); ++iii)
336 if ( !t.contains(tAD[iii] ) ) 338 if ( !t.contains(tAD[iii] ) )
337 mData->emails.append( tAD[iii] ); 339 mData->emails.append( tAD[iii] );
338 } 340 }
339 341
340 // ************* categories; 342 // ************* categories;
341 t = mData->categories; 343 t = mData->categories;
342 tAD = ad.mData->categories; 344 tAD = ad.mData->categories;
343 for ( iii = 0; iii < tAD.count(); ++iii) 345 for ( iii = 0; iii < tAD.count(); ++iii)
diff --git a/kabc/secrecy.h b/kabc/secrecy.h
index 8f2f736..b2ff565 100644
--- a/kabc/secrecy.h
+++ b/kabc/secrecy.h
@@ -1,102 +1,102 @@
1/* 1/*
2 This file is part of libkabc. 2 This file is part of libkabc.
3 Copyright (c) 2002 Tobias Koenig <tokoe@kde.org> 3 Copyright (c) 2002 Tobias Koenig <tokoe@kde.org>
4 4
5 This library is free software; you can redistribute it and/or 5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Library General Public 6 modify it under the terms of the GNU Library General Public
7 License as published by the Free Software Foundation; either 7 License as published by the Free Software Foundation; either
8 version 2 of the License, or (at your option) any later version. 8 version 2 of the License, or (at your option) any later version.
9 9
10 This library is distributed in the hope that it will be useful, 10 This library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Library General Public License for more details. 13 Library General Public License for more details.
14 14
15 You should have received a copy of the GNU Library General Public License 15 You should have received a copy of the GNU Library General Public License
16 along with this library; see the file COPYING.LIB. If not, write to 16 along with this library; see the file COPYING.LIB. If not, write to
17 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 17 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 Boston, MA 02111-1307, USA. 18 Boston, MA 02111-1307, USA.
19*/ 19*/
20 20
21/* 21/*
22Enhanced Version of the file for platform independent KDE tools. 22Enhanced Version of the file for platform independent KDE tools.
23Copyright (c) 2004 Ulf Schenk 23Copyright (c) 2004 Ulf Schenk
24 24
25$Id$ 25$Id$
26*/ 26*/
27 27
28#ifndef KABC_SECRECY_H 28#ifndef KABC_SECRECY_H
29#define KABC_SECRECY_H 29#define KABC_SECRECY_H
30 30
31#include <qvaluelist.h> 31#include <qvaluelist.h>
32 32
33namespace KABC { 33namespace KABC {
34 34
35class Secrecy 35class Secrecy
36{ 36{
37 friend QDataStream &operator<<( QDataStream &, const Secrecy & ); 37 friend QDataStream &operator<<( QDataStream &, const Secrecy & );
38 friend QDataStream &operator>>( QDataStream &, Secrecy & ); 38 friend QDataStream &operator>>( QDataStream &, Secrecy & );
39 39
40public: 40public:
41 typedef QValueList<int> TypeList; 41 typedef QValueList<int> TypeList;
42 42
43 /** 43 /**
44 * Secrecy types 44 * Secrecy types
45 * 45 *
46 * @li Public - for public access 46 * @li Public - for public access
47 * @li Private - only private access 47 * @li Private - only private access
48 * @li Confidential - access for confidential persons 48 * @li Confidential - access for confidential persons
49 */ 49 */
50 enum Types { 50 enum Types {
51 Public, 51 Public,
52 Private, 52 Private,
53 Confidential, 53 Confidential,
54 Invalid 54 Invalid
55 }; 55 };
56 56
57 /** 57 /**
58 * Constructor. 58 * Constructor.
59 * 59 *
60 * @param type The secrecy type, @see Types. 60 * @param type The secrecy type, @see Types.
61 */ 61 */
62 Secrecy( int type = Invalid ); 62 Secrecy( int type = Public );
63 63
64 bool operator==( const Secrecy & ) const; 64 bool operator==( const Secrecy & ) const;
65 bool operator!=( const Secrecy & ) const; 65 bool operator!=( const Secrecy & ) const;
66 66
67 /** 67 /**
68 Returns if the Secrecy object has a valid value. 68 Returns if the Secrecy object has a valid value.
69 */ 69 */
70 bool isValid() const; 70 bool isValid() const;
71 71
72 /** 72 /**
73 * Sets the type, @see Types. 73 * Sets the type, @see Types.
74 */ 74 */
75 void setType( int type ); 75 void setType( int type );
76 76
77 /** 77 /**
78 * Returns the type, @see Types. 78 * Returns the type, @see Types.
79 */ 79 */
80 int type() const; 80 int type() const;
81 81
82 /** 82 /**
83 * Returns a list of all available secrecy types. 83 * Returns a list of all available secrecy types.
84 */ 84 */
85 static TypeList typeList(); 85 static TypeList typeList();
86 86
87 /** 87 /**
88 * Returns a translated label for a given secrecy type. 88 * Returns a translated label for a given secrecy type.
89 */ 89 */
90 static QString typeLabel( int type ); 90 static QString typeLabel( int type );
91 91
92 /** 92 /**
93 * For debug. 93 * For debug.
94 */ 94 */
95 QString asString() const; 95 QString asString() const;
96 96
97private: 97private:
98 int mType; 98 int mType;
99}; 99};
100 100
101} 101}
102#endif 102#endif
diff --git a/kabc/vcard/VCardv.cpp b/kabc/vcard/VCardv.cpp
index 1166aac..bad2ef1 100644
--- a/kabc/vcard/VCardv.cpp
+++ b/kabc/vcard/VCardv.cpp
@@ -111,129 +111,129 @@ VCard::_parse()
111 } 111 }
112 l = QStringList::fromStrList( sl ); 112 l = QStringList::fromStrList( sl );
113 // Get the first line 113 // Get the first line
114 QString beginLine = l[0].stripWhiteSpace(); 114 QString beginLine = l[0].stripWhiteSpace();
115 115
116 // Remove extra blank lines 116 // Remove extra blank lines
117 while (l.last().isEmpty()) 117 while (l.last().isEmpty())
118 l.remove(l.last()); 118 l.remove(l.last());
119 119
120 // Now we know this is the last line 120 // Now we know this is the last line
121 QString endLine = l.last(); 121 QString endLine = l.last();
122 122
123 // Trash the first and last lines as we have seen them. 123 // Trash the first and last lines as we have seen them.
124 l.remove(l.begin()); 124 l.remove(l.begin());
125 l.remove(l.last()); 125 l.remove(l.last());
126 126
127 /////////////////////////////////////////////////////////////// 127 ///////////////////////////////////////////////////////////////
128 // FIRST LINE 128 // FIRST LINE
129 129
130 int split = beginLine.find(':'); 130 int split = beginLine.find(':');
131 131
132 if (split == -1) { // invalid, no BEGIN 132 if (split == -1) { // invalid, no BEGIN
133 vDebug("No split"); 133 vDebug("No split");
134 return; 134 return;
135 } 135 }
136 136
137 QString firstPart(beginLine.left(split)); 137 QString firstPart(beginLine.left(split));
138 QString valuePart(beginLine.mid(split + 1)); 138 QString valuePart(beginLine.mid(split + 1));
139 139
140 split = firstPart.find('.'); 140 split = firstPart.find('.');
141 141
142 if (split != -1) { 142 if (split != -1) {
143 group_ = firstPart.left(split); 143 group_ = firstPart.left(split);
144 firstPart= firstPart.right(firstPart.length() - split - 1); 144 firstPart= firstPart.right(firstPart.length() - split - 1);
145 } 145 }
146 146
147 if (firstPart.left(5) != "BEGIN" ) { // No BEGIN ! 147 if (firstPart.left(5) != "BEGIN" ) { // No BEGIN !
148 qDebug("no BEGIN in vcard "); 148 qDebug("no BEGIN in vcard ");
149 return; 149 return;
150 } 150 }
151 151
152 if (valuePart.left(5) != "VCARD") { // Not a vcard ! 152 if (valuePart.left(5) != "VCARD") { // Not a vcard !
153 qDebug("not a VCARD "); 153 qDebug("not a VCARD ");
154 return; 154 return;
155 } 155 }
156 156
157 /////////////////////////////////////////////////////////////// 157 ///////////////////////////////////////////////////////////////
158 // CONTENT LINES 158 // CONTENT LINES
159 // 159 //
160 vDebug("Content lines"); 160 vDebug("Content lines");
161 161
162 // Handle folded lines. 162 // Handle folded lines.
163 163
164 QStringList refolded; 164 QStringList refolded;
165 165
166 166
167 QStringList::Iterator it = l.begin(); 167 QStringList::Iterator it = l.begin();
168 168
169 QString cur; 169 QString cur;
170 170
171 for (; it != l.end(); ++it) { 171 for (; it != l.end(); ++it) {
172 cur = (*it); 172 cur = (*it);
173 ++it; 173 ++it;
174 while ( it!= l.end() && (*it).at(0) == ' '&& (*it).length()!= 1) { 174 while ( it!= l.end() && (*it).at(0) == ' '&& (*it).length()!= 1) {
175 cur += (*it) ; 175 cur += (*it).mid(1) ;
176 ++it; 176 ++it;
177 } 177 }
178 --it; 178 --it;
179 refolded.append(cur); 179 refolded.append(cur);
180 } 180 }
181 QStringList::Iterator it2 = refolded.begin(); 181 QStringList::Iterator it2 = refolded.begin();
182 for (; it2 != refolded.end(); ++it2) { 182 for (; it2 != refolded.end(); ++it2) {
183 ContentLine * cl = new ContentLine(QCString((*it2).latin1())); 183 ContentLine * cl = new ContentLine(QCString((*it2).latin1()));
184 cl->parse(); 184 cl->parse();
185 if (cl->value() == 0) 185 if (cl->value() == 0)
186 { 186 {
187 qDebug("Content line could not be parsed. Discarded: %s", (*it2).latin1()); 187 qDebug("Content line could not be parsed. Discarded: %s", (*it2).latin1());
188 delete cl; 188 delete cl;
189 } 189 }
190 else 190 else
191 contentLineList_.append(cl); 191 contentLineList_.append(cl);
192 } 192 }
193 193
194 /////////////////////////////////////////////////////////////// 194 ///////////////////////////////////////////////////////////////
195 // LAST LINE 195 // LAST LINE
196 196
197 197
198 // LR: sorry, but the remaining code in this method makes no sense 198 // LR: sorry, but the remaining code in this method makes no sense
199 199
200#if 0 200#if 0
201 split = endLine.find(':'); 201 split = endLine.find(':');
202 202
203 if (split == -1) // invalid, no END 203 if (split == -1) // invalid, no END
204 return; 204 return;
205 205
206 firstPart = endLine.left(split); 206 firstPart = endLine.left(split);
207 valuePart = endLine.right(firstPart.length() - split - 1); 207 valuePart = endLine.right(firstPart.length() - split - 1);
208 208
209 split = firstPart.find('.'); 209 split = firstPart.find('.');
210 210
211 if (split != -1) { 211 if (split != -1) {
212 group_ = firstPart.left(split); 212 group_ = firstPart.left(split);
213 firstPart= firstPart.right(firstPart.length() - split - 1); 213 firstPart= firstPart.right(firstPart.length() - split - 1);
214 } 214 }
215 215
216 if (qstricmp(firstPart, "END") != 0) // No END ! 216 if (qstricmp(firstPart, "END") != 0) // No END !
217 return; 217 return;
218 218
219 if (qstricmp(valuePart, "VCARD") != 0) // Not a vcard ! 219 if (qstricmp(valuePart, "VCARD") != 0) // Not a vcard !
220 return; 220 return;
221#endif 221#endif
222} 222}
223 223
224 void 224 void
225VCard::_assemble() 225VCard::_assemble()
226{ 226{
227 vDebug("Assembling vcard"); 227 vDebug("Assembling vcard");
228 strRep_ = "BEGIN:VCARD\r\n"; 228 strRep_ = "BEGIN:VCARD\r\n";
229 strRep_ += "VERSION:3.0\r\n"; 229 strRep_ += "VERSION:3.0\r\n";
230 230
231 QPtrListIterator<ContentLine> it(contentLineList_); 231 QPtrListIterator<ContentLine> it(contentLineList_);
232 232
233 for (; it.current(); ++it) 233 for (; it.current(); ++it)
234 strRep_ += it.current()->asString() + "\r\n"; 234 strRep_ += it.current()->asString() + "\r\n";
235 235
236 strRep_ += "END:VCARD\r\n"; 236 strRep_ += "END:VCARD\r\n";
237} 237}
238 238
239 bool 239 bool
diff --git a/kaddressbook/filter.cpp b/kaddressbook/filter.cpp
index 9cb4c2d..7a869fa 100644
--- a/kaddressbook/filter.cpp
+++ b/kaddressbook/filter.cpp
@@ -88,129 +88,129 @@ bool Filter::filterAddressee( const KABC::Addressee &a )
88 return false; 88 return false;
89 break; 89 break;
90 case KABC::Secrecy::Private: 90 case KABC::Secrecy::Private:
91 if (! (mCriteria & ShowPrivate )) 91 if (! (mCriteria & ShowPrivate ))
92 return false; 92 return false;
93 break; 93 break;
94 case KABC::Secrecy::Confidential: 94 case KABC::Secrecy::Confidential:
95 if (! (mCriteria & ShowConfidential )) 95 if (! (mCriteria & ShowConfidential ))
96 return false; 96 return false;
97 break; 97 break;
98 default: 98 default:
99 return false; 99 return false;
100 break; 100 break;
101 } 101 }
102 QStringList::Iterator iter; 102 QStringList::Iterator iter;
103 iter = mCategoryList.begin(); 103 iter = mCategoryList.begin();
104 // empty filter always matches 104 // empty filter always matches
105 105
106 if ( iter == mCategoryList.end() ) 106 if ( iter == mCategoryList.end() )
107 return true; 107 return true;
108 108
109 for ( ; iter != mCategoryList.end(); ++iter ) { 109 for ( ; iter != mCategoryList.end(); ++iter ) {
110 if ( a.hasCategory( *iter ) ) 110 if ( a.hasCategory( *iter ) )
111 return ( mMatchRule == Matching ); 111 return ( mMatchRule == Matching );
112 } 112 }
113 113
114 return !( mMatchRule == Matching ); 114 return !( mMatchRule == Matching );
115} 115}
116 116
117void Filter::setEnabled( bool on ) 117void Filter::setEnabled( bool on )
118{ 118{
119 mEnabled = on; 119 mEnabled = on;
120} 120}
121 121
122bool Filter::isEnabled() const 122bool Filter::isEnabled() const
123{ 123{
124 return mEnabled; 124 return mEnabled;
125} 125}
126 126
127void Filter::setCategories( const QStringList &list ) 127void Filter::setCategories( const QStringList &list )
128{ 128{
129 mCategoryList = list; 129 mCategoryList = list;
130} 130}
131 131
132const QStringList &Filter::categories() const 132const QStringList &Filter::categories() const
133{ 133{
134 return mCategoryList; 134 return mCategoryList;
135} 135}
136 136
137void Filter::save( KConfig *config ) 137void Filter::save( KConfig *config )
138{ 138{
139 config->writeEntry( "Name", mName ); 139 config->writeEntry( "Name", mName );
140 config->writeEntry( "Enabled", mEnabled ); 140 config->writeEntry( "Enabled", mEnabled );
141 config->writeEntry( "Categories", mCategoryList ); 141 config->writeEntry( "Categories", mCategoryList );
142 config->writeEntry( "MatchRule", (int)mMatchRule ); 142 config->writeEntry( "MatchRule", (int)mMatchRule );
143 config->writeEntry( "Criteria", (int)mCriteria ); 143 config->writeEntry( "Criteria", (int)mCriteria );
144} 144}
145 145
146void Filter::restore( KConfig *config ) 146void Filter::restore( KConfig *config )
147{ 147{
148 mName = config->readEntry( "Name", "<internal error>" ); 148 mName = config->readEntry( "Name", "<internal error>" );
149 mEnabled = config->readBoolEntry( "Enabled", true ); 149 mEnabled = config->readBoolEntry( "Enabled", true );
150 mCategoryList = config->readListEntry( "Categories" ); 150 mCategoryList = config->readListEntry( "Categories" );
151 mMatchRule = (MatchRule)config->readNumEntry( "MatchRule", Matching ); 151 mMatchRule = (MatchRule)config->readNumEntry( "MatchRule", Matching );
152 mCriteria = config->readNumEntry( "Criteria", (ShowPublic | ShowPrivate| ShowConfidential) ); 152 mCriteria = config->readNumEntry( "Criteria", (ShowPublic | ShowPrivate| ShowConfidential ) );
153} 153}
154 154
155void Filter::save( KConfig *config, QString baseGroup, Filter::List &list ) 155void Filter::save( KConfig *config, QString baseGroup, Filter::List &list )
156{ 156{
157 { 157 {
158 KConfigGroupSaver s( config, baseGroup ); 158 KConfigGroupSaver s( config, baseGroup );
159 159
160 // remove the old filters 160 // remove the old filters
161 uint count = config->readNumEntry( "Count" ); 161 uint count = config->readNumEntry( "Count" );
162 /* // memory access violation here 162 /* // memory access violation here
163 for ( uint i = 0; i < count; ++i ) 163 for ( uint i = 0; i < count; ++i )
164 config->deleteGroup( QString( "%1_%2" ).arg( baseGroup ).arg( i ) ); 164 config->deleteGroup( QString( "%1_%2" ).arg( baseGroup ).arg( i ) );
165 */ 165 */
166 } 166 }
167 167
168 int index = 0; 168 int index = 0;
169 Filter::List::Iterator iter; 169 Filter::List::Iterator iter;
170 for ( iter = list.begin(); iter != list.end(); ++iter ) { 170 for ( iter = list.begin(); iter != list.end(); ++iter ) {
171 if ( !(*iter).mInternal ) { 171 if ( !(*iter).mInternal ) {
172 KConfigGroupSaver s( config, QString( "%1_%2" ).arg( baseGroup ).arg( index ) ); 172 KConfigGroupSaver s( config, QString( "%1_%2" ).arg( baseGroup ).arg( index ) );
173 173
174 (*iter).save( config ); 174 (*iter).save( config );
175 index++; 175 index++;
176 } 176 }
177 } 177 }
178 178
179 KConfigGroupSaver s( config, baseGroup ); 179 KConfigGroupSaver s( config, baseGroup );
180 180
181 config->writeEntry( "Count", index ); 181 config->writeEntry( "Count", index );
182 182
183} 183}
184 184
185Filter::List Filter::restore( KConfig *config, QString baseGroup ) 185Filter::List Filter::restore( KConfig *config, QString baseGroup )
186{ 186{
187 Filter::List list; 187 Filter::List list;
188 int count = 0; 188 int count = 0;
189 Filter f; 189 Filter f;
190 190
191 { 191 {
192 KConfigGroupSaver s( config, baseGroup ); 192 KConfigGroupSaver s( config, baseGroup );
193 count = config->readNumEntry( "Count", 0 ); 193 count = config->readNumEntry( "Count", 0 );
194 } 194 }
195 195
196 for ( int i = 0; i < count; i++ ) { 196 for ( int i = 0; i < count; i++ ) {
197 { 197 {
198 KConfigGroupSaver s( config, QString( "%1_%2" ).arg( baseGroup ).arg( i ) ); 198 KConfigGroupSaver s( config, QString( "%1_%2" ).arg( baseGroup ).arg( i ) );
199 f.restore( config ); 199 f.restore( config );
200 } 200 }
201 201
202 list.append( f ); 202 list.append( f );
203 } 203 }
204 204
205 if ( list.isEmpty()) { 205 if ( list.isEmpty()) {
206 QStringList cats = KABPrefs::instance()->mCustomCategories; 206 QStringList cats = KABPrefs::instance()->mCustomCategories;
207 for ( QStringList::Iterator it = cats.begin(); it != cats.end(); ++it ) { 207 for ( QStringList::Iterator it = cats.begin(); it != cats.end(); ++it ) {
208 Filter filter; 208 Filter filter;
209 filter.mName = *it; 209 filter.mName = *it;
210 filter.mEnabled = true; 210 filter.mEnabled = true;
211 filter.mCategoryList = *it; 211 filter.mCategoryList = *it;
212 filter.mMatchRule = Matching; 212 filter.mMatchRule = Matching;
213 filter.mInternal = true; 213 filter.mInternal = true;
214 list.append( filter ); 214 list.append( filter );
215 } 215 }
216 } 216 }
diff --git a/kaddressbook/filter.h b/kaddressbook/filter.h
index 26870d7..93f1352 100644
--- a/kaddressbook/filter.h
+++ b/kaddressbook/filter.h
@@ -1,106 +1,106 @@
1/* 1/*
2 This file is part of KAddressBook. 2 This file is part of KAddressBook.
3 Copyright (c) 2002 Mike Pilone <mpilone@slac.com> 3 Copyright (c) 2002 Mike Pilone <mpilone@slac.com>
4 4
5 This program is free software; you can redistribute it and/or modify 5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or 7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version. 8 (at your option) any later version.
9 9
10 This program is distributed in the hope that it will be useful, 10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details. 13 GNU General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License 15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software 16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 18
19 As a special exception, permission is given to link this program 19 As a special exception, permission is given to link this program
20 with any edition of Qt, and distribute the resulting executable, 20 with any edition of Qt, and distribute the resulting executable,
21 without including the source code for Qt in the source distribution. 21 without including the source code for Qt in the source distribution.
22*/ 22*/
23 23
24#ifndef FILTER_H 24#ifndef FILTER_H
25#define FILTER_H 25#define FILTER_H
26 26
27#include <qstring.h> 27#include <qstring.h>
28#include <qstringlist.h> 28#include <qstringlist.h>
29#include <qvaluelist.h> 29#include <qvaluelist.h>
30 30
31#include <kabc/addressee.h> 31#include <kabc/addressee.h>
32#include <kconfig.h> 32#include <kconfig.h>
33 33
34/** 34/**
35 Filter for AddressBook related objects (Addressees) 35 Filter for AddressBook related objects (Addressees)
36 36
37 @todo This class should be switched to use shared data. 37 @todo This class should be switched to use shared data.
38 */ 38 */
39class Filter 39class Filter
40{ 40{
41 public: 41 public:
42 enum { ShowPublic = 1, ShowPrivate = 2, ShowConfidential = 4}; 42 enum { ShowPublic = 1, ShowPrivate = 2, ShowConfidential = 4 };
43 void setCriteria(int c) { mCriteria = c ;} 43 void setCriteria(int c) { mCriteria = c ;}
44 int criteria() const { return mCriteria;} 44 int criteria() const { return mCriteria;}
45 typedef QValueList<Filter> List; 45 typedef QValueList<Filter> List;
46 46
47 enum MatchRule { Matching = 0, NotMatching = 1 }; 47 enum MatchRule { Matching = 0, NotMatching = 1 };
48 48
49 Filter(); 49 Filter();
50 Filter( const QString& name ); 50 Filter( const QString& name );
51 ~Filter(); 51 ~Filter();
52 52
53 /** 53 /**
54 Set the name of the filter. 54 Set the name of the filter.
55 */ 55 */
56 void setName( const QString &name ); 56 void setName( const QString &name );
57 57
58 /** 58 /**
59 @return The name of the filter. 59 @return The name of the filter.
60 */ 60 */
61 const QString &name() const; 61 const QString &name() const;
62 62
63 /** 63 /**
64 @return Whether the filter is an internal one. 64 @return Whether the filter is an internal one.
65 */ 65 */
66 bool isInternal() const; 66 bool isInternal() const;
67 67
68 /** 68 /**
69 Apply the filter to the addressee list. All addressees not passing 69 Apply the filter to the addressee list. All addressees not passing
70 the filter criterias will be removed from the list. 70 the filter criterias will be removed from the list.
71 71
72 If the MatchRule is NotMatch, then all the addressees matching the 72 If the MatchRule is NotMatch, then all the addressees matching the
73 filter will be removed from the list. 73 filter will be removed from the list.
74 */ 74 */
75 void apply( KABC::Addressee::List &addresseeList ); 75 void apply( KABC::Addressee::List &addresseeList );
76 76
77 /** 77 /**
78 Apply the filter to the addressee. 78 Apply the filter to the addressee.
79 79
80 @return True if the addressee passes the criteria, false otherwise. 80 @return True if the addressee passes the criteria, false otherwise.
81 The return values are opposite if the MatchRule is NotMatch. 81 The return values are opposite if the MatchRule is NotMatch.
82 */ 82 */
83 bool filterAddressee( const KABC::Addressee &a ); 83 bool filterAddressee( const KABC::Addressee &a );
84 84
85 /** 85 /**
86 Enable or disable the filter 86 Enable or disable the filter
87 */ 87 */
88 void setEnabled( bool on ); 88 void setEnabled( bool on );
89 89
90 /** 90 /**
91 @return True if this filter is enabled, false otherwise. 91 @return True if this filter is enabled, false otherwise.
92 */ 92 */
93 bool isEnabled() const; 93 bool isEnabled() const;
94 94
95 /** 95 /**
96 Set the list of categories. This list is used to filter addressees. 96 Set the list of categories. This list is used to filter addressees.
97 */ 97 */
98 void setCategories( const QStringList &list ); 98 void setCategories( const QStringList &list );
99 99
100 /** 100 /**
101 @return The list of categories. 101 @return The list of categories.
102 */ 102 */
103 const QStringList &categories() const; 103 const QStringList &categories() const;
104 104
105 /** 105 /**
106 Saves the filter to the config file. The group should already be set. 106 Saves the filter to the config file. The group should already be set.
diff --git a/kaddressbook/filtereditdialog.cpp b/kaddressbook/filtereditdialog.cpp
index 987f234..1194406 100644
--- a/kaddressbook/filtereditdialog.cpp
+++ b/kaddressbook/filtereditdialog.cpp
@@ -35,129 +35,128 @@ $Id$
35#include <qpushbutton.h> 35#include <qpushbutton.h>
36#include <qradiobutton.h> 36#include <qradiobutton.h>
37#include <qcheckbox.h> 37#include <qcheckbox.h>
38#include <qregexp.h> 38#include <qregexp.h>
39#include <qstring.h> 39#include <qstring.h>
40#include <qtoolbutton.h> 40#include <qtoolbutton.h>
41#include <qtooltip.h> 41#include <qtooltip.h>
42#include <qwidget.h> 42#include <qwidget.h>
43 43
44#include <kapplication.h> 44#include <kapplication.h>
45#include <kbuttonbox.h> 45#include <kbuttonbox.h>
46#include <kdebug.h> 46#include <kdebug.h>
47#include <kiconloader.h> 47#include <kiconloader.h>
48#include <klineedit.h> 48#include <klineedit.h>
49#include <klistbox.h> 49#include <klistbox.h>
50#include <klistview.h> 50#include <klistview.h>
51#include <klocale.h> 51#include <klocale.h>
52#include <kglobal.h> 52#include <kglobal.h>
53 53
54#include "kabprefs.h" 54#include "kabprefs.h"
55#include "filtereditdialog.h" 55#include "filtereditdialog.h"
56 56
57FilterEditDialog::FilterEditDialog( QWidget *parent, const char *name ) 57FilterEditDialog::FilterEditDialog( QWidget *parent, const char *name )
58 : KDialogBase( Plain, i18n( "Edit Address Book Filter" ), 58 : KDialogBase( Plain, i18n( "Edit Address Book Filter" ),
59 Help | Ok | Cancel, Ok, parent, name, /*US false*/ true, true ) 59 Help | Ok | Cancel, Ok, parent, name, /*US false*/ true, true )
60{ 60{
61 initGUI(); 61 initGUI();
62 62
63 QStringList cats = KABPrefs::instance()->mCustomCategories; 63 QStringList cats = KABPrefs::instance()->mCustomCategories;
64 64
65 QStringList::Iterator iter; 65 QStringList::Iterator iter;
66 for ( iter = cats.begin(); iter != cats.end(); ++iter ) 66 for ( iter = cats.begin(); iter != cats.end(); ++iter )
67 mCategoriesView->insertItem( new QCheckListItem( mCategoriesView, (*iter), QCheckListItem::CheckBox ) ); 67 mCategoriesView->insertItem( new QCheckListItem( mCategoriesView, (*iter), QCheckListItem::CheckBox ) );
68 filterNameTextChanged( mNameEdit->text() ); 68 filterNameTextChanged( mNameEdit->text() );
69} 69}
70 70
71FilterEditDialog::~FilterEditDialog() 71FilterEditDialog::~FilterEditDialog()
72{ 72{
73} 73}
74 74
75void FilterEditDialog::setFilter( const Filter &filter ) 75void FilterEditDialog::setFilter( const Filter &filter )
76{ 76{
77 mNameEdit->setText( filter.name() ); 77 mNameEdit->setText( filter.name() );
78 78
79 QStringList categories = filter.categories(); 79 QStringList categories = filter.categories();
80 QListViewItem *item = mCategoriesView->firstChild(); 80 QListViewItem *item = mCategoriesView->firstChild();
81 while ( item != 0 ) { 81 while ( item != 0 ) {
82 if ( categories.contains( item->text( 0 ) ) ) { 82 if ( categories.contains( item->text( 0 ) ) ) {
83 QCheckListItem *checkItem = static_cast<QCheckListItem*>( item ); 83 QCheckListItem *checkItem = static_cast<QCheckListItem*>( item );
84 checkItem->setOn( true ); 84 checkItem->setOn( true );
85 } 85 }
86 86
87 item = item->nextSibling(); 87 item = item->nextSibling();
88 } 88 }
89 89
90 if ( filter.matchRule() == Filter::Matching ) 90 if ( filter.matchRule() == Filter::Matching )
91 mMatchRuleGroup->setButton( 0 ); 91 mMatchRuleGroup->setButton( 0 );
92 else 92 else
93 mMatchRuleGroup->setButton( 1 ); 93 mMatchRuleGroup->setButton( 1 );
94 94
95 int c = filter.criteria() ; 95 int c = filter.criteria() ;
96 mPublic->setChecked(c &Filter::ShowPublic); 96 mPublic->setChecked(c &Filter::ShowPublic);
97 mPrivate->setChecked(c & Filter::ShowPrivate); 97 mPrivate->setChecked(c & Filter::ShowPrivate);
98 mConfidential->setChecked(c & Filter::ShowConfidential); 98 mConfidential->setChecked(c & Filter::ShowConfidential);
99
100} 99}
101 100
102Filter FilterEditDialog::filter() 101Filter FilterEditDialog::filter()
103{ 102{
104 Filter filter; 103 Filter filter;
105 104
106 filter.setName( mNameEdit->text() ); 105 filter.setName( mNameEdit->text() );
107 106
108 QStringList categories; 107 QStringList categories;
109 QListViewItem *item = mCategoriesView->firstChild(); 108 QListViewItem *item = mCategoriesView->firstChild();
110 while ( item != 0 ) { 109 while ( item != 0 ) {
111 QCheckListItem *checkItem = static_cast<QCheckListItem*>( item ); 110 QCheckListItem *checkItem = static_cast<QCheckListItem*>( item );
112 if ( checkItem->isOn() ) 111 if ( checkItem->isOn() )
113 categories.append( item->text( 0 ) ); 112 categories.append( item->text( 0 ) );
114 113
115 item = item->nextSibling(); 114 item = item->nextSibling();
116 } 115 }
117 filter.setCategories( categories ); 116 filter.setCategories( categories );
118 117
119 if ( mMatchRuleGroup->find( 0 )->isOn() ) 118 if ( mMatchRuleGroup->find( 0 )->isOn() )
120 filter.setMatchRule( Filter::Matching ); 119 filter.setMatchRule( Filter::Matching );
121 else 120 else
122 filter.setMatchRule( Filter::NotMatching ); 121 filter.setMatchRule( Filter::NotMatching );
123 122
124 int c = 0; 123 int c = 0;
125 if (mPublic->isChecked()) c |= Filter::ShowPublic; 124 if (mPublic->isChecked()) c |= Filter::ShowPublic;
126 if (mPrivate->isChecked()) c |= Filter::ShowPrivate; 125 if (mPrivate->isChecked()) c |= Filter::ShowPrivate;
127 if (mConfidential->isChecked()) c |= Filter::ShowConfidential; 126 if (mConfidential->isChecked()) c |= Filter::ShowConfidential;
128 filter.setCriteria( c ) ; 127 filter.setCriteria( c ) ;
129 128
130 return filter; 129 return filter;
131} 130}
132 131
133void FilterEditDialog::initGUI() 132void FilterEditDialog::initGUI()
134{ 133{
135#ifndef KAB_EMBEDDED 134#ifndef KAB_EMBEDDED
136 resize( 490, 300 ); 135 resize( 490, 300 );
137#else //KAB_EMBEDDED 136#else //KAB_EMBEDDED
138 resize( KMIN(KGlobal::getDesktopWidth()-10, 490), KMIN(KGlobal::getDesktopHeight()-50, 300)); 137 resize( KMIN(KGlobal::getDesktopWidth()-10, 490), KMIN(KGlobal::getDesktopHeight()-50, 300));
139#endif //KAB_EMBEDDED 138#endif //KAB_EMBEDDED
140 139
141 140
142 QWidget *page = plainPage(); 141 QWidget *page = plainPage();
143 QLabel *label; 142 QLabel *label;
144 143
145 QGridLayout *topLayout = new QGridLayout( page, 3, 2, 0, spacingHint() ); 144 QGridLayout *topLayout = new QGridLayout( page, 3, 2, 0, spacingHint() );
146 145
147 label = new QLabel( i18n( "Name" ), page ); 146 label = new QLabel( i18n( "Name" ), page );
148 mNameEdit = new KLineEdit( page ); 147 mNameEdit = new KLineEdit( page );
149 mNameEdit->setFocus(); 148 mNameEdit->setFocus();
150 topLayout->addWidget( label, 0, 0 ); 149 topLayout->addWidget( label, 0, 0 );
151 topLayout->addWidget( mNameEdit, 0, 1 ); 150 topLayout->addWidget( mNameEdit, 0, 1 );
152 connect( mNameEdit, SIGNAL( textChanged( const QString& ) ), 151 connect( mNameEdit, SIGNAL( textChanged( const QString& ) ),
153 SLOT( filterNameTextChanged( const QString&) ) ); 152 SLOT( filterNameTextChanged( const QString&) ) );
154 153
155 mCategoriesView = new KListView( page ); 154 mCategoriesView = new KListView( page );
156 mCategoriesView->addColumn( i18n( "Categories" ) ); 155 mCategoriesView->addColumn( i18n( "Categories" ) );
157 topLayout->addMultiCellWidget( mCategoriesView, 1, 1, 0, 1 ); 156 topLayout->addMultiCellWidget( mCategoriesView, 1, 1, 0, 1 );
158 157
159 mMatchRuleGroup = new QHButtonGroup( i18n( "Category rule" ), page ); 158 mMatchRuleGroup = new QHButtonGroup( i18n( "Category rule" ), page );
160 mMatchRuleGroup->setExclusive( true ); 159 mMatchRuleGroup->setExclusive( true );
161 QRadioButton *radio = new QRadioButton( i18n( "Include categories" ), mMatchRuleGroup ); 160 QRadioButton *radio = new QRadioButton( i18n( "Include categories" ), mMatchRuleGroup );
162 radio->setChecked( true ); 161 radio->setChecked( true );
163 //mMatchRuleGroup->insert( radio ); 162 //mMatchRuleGroup->insert( radio );
diff --git a/kaddressbook/kabcore.cpp b/kaddressbook/kabcore.cpp
index e61f65f..aa04631 100644
--- a/kaddressbook/kabcore.cpp
+++ b/kaddressbook/kabcore.cpp
@@ -202,129 +202,129 @@ class KABFormatPrefs : public QDialog
202 public: 202 public:
203 KABFormatPrefs( QWidget *parent=0, const char *name=0 ) : 203 KABFormatPrefs( QWidget *parent=0, const char *name=0 ) :
204 QDialog( parent, name, true ) 204 QDialog( parent, name, true )
205 { 205 {
206 setCaption( i18n("Set formatted name") ); 206 setCaption( i18n("Set formatted name") );
207 QVBoxLayout* lay = new QVBoxLayout( this ); 207 QVBoxLayout* lay = new QVBoxLayout( this );
208 lay->setSpacing( 3 ); 208 lay->setSpacing( 3 );
209 lay->setMargin( 3 ); 209 lay->setMargin( 3 );
210 QLabel * lab = new QLabel( i18n("You can set the formatted name\nfor a list of contacts in one go."), this ); 210 QLabel * lab = new QLabel( i18n("You can set the formatted name\nfor a list of contacts in one go."), this );
211 lay->addWidget( lab ); 211 lay->addWidget( lab );
212 QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("Set formatted name to:"), this ); 212 QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("Set formatted name to:"), this );
213 lay->addWidget( format ); 213 lay->addWidget( format );
214 format->setExclusive ( true ) ; 214 format->setExclusive ( true ) ;
215 simple = new QRadioButton(i18n("Simple: James Bond"), format ); 215 simple = new QRadioButton(i18n("Simple: James Bond"), format );
216 full = new QRadioButton(i18n("Full: Mr. James 007 Bond I"), format ); 216 full = new QRadioButton(i18n("Full: Mr. James 007 Bond I"), format );
217 reverse = new QRadioButton(i18n("Reverse: Bond, James"), format ); 217 reverse = new QRadioButton(i18n("Reverse: Bond, James"), format );
218 company = new QRadioButton(i18n("Organization: MI6"), format ); 218 company = new QRadioButton(i18n("Organization: MI6"), format );
219 simple->setChecked( true ); 219 simple->setChecked( true );
220 setCompany = new QCheckBox(i18n("Set formatted name to\norganization, if name empty"), this); 220 setCompany = new QCheckBox(i18n("Set formatted name to\norganization, if name empty"), this);
221 lay->addWidget( setCompany ); 221 lay->addWidget( setCompany );
222 QPushButton * ok = new QPushButton( i18n("Select contact list"), this ); 222 QPushButton * ok = new QPushButton( i18n("Select contact list"), this );
223 lay->addWidget( ok ); 223 lay->addWidget( ok );
224 QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); 224 QPushButton * cancel = new QPushButton( i18n("Cancel"), this );
225 lay->addWidget( cancel ); 225 lay->addWidget( cancel );
226 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); 226 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) );
227 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); 227 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) );
228 resize( 200, 200 ); 228 resize( 200, 200 );
229 } 229 }
230public: 230public:
231 QRadioButton* simple, *full, *reverse, *company; 231 QRadioButton* simple, *full, *reverse, *company;
232 QCheckBox* setCompany; 232 QCheckBox* setCompany;
233}; 233};
234 234
235 235
236 236
237class KAex2phonePrefs : public QDialog 237class KAex2phonePrefs : public QDialog
238{ 238{
239 public: 239 public:
240 KAex2phonePrefs( QWidget *parent=0, const char *name=0 ) : 240 KAex2phonePrefs( QWidget *parent=0, const char *name=0 ) :
241 QDialog( parent, name, true ) 241 QDialog( parent, name, true )
242 { 242 {
243 setCaption( i18n("Export to phone options") ); 243 setCaption( i18n("Export to phone options") );
244 QVBoxLayout* lay = new QVBoxLayout( this ); 244 QVBoxLayout* lay = new QVBoxLayout( this );
245 lay->setSpacing( 3 ); 245 lay->setSpacing( 3 );
246 lay->setMargin( 3 ); 246 lay->setMargin( 3 );
247 QLabel *lab; 247 QLabel *lab;
248 lay->addWidget(lab = new QLabel( i18n("Please read Help-Sync Howto\nto know what settings to use."), this ) ); 248 lay->addWidget(lab = new QLabel( i18n("Please read Help-Sync Howto\nto know what settings to use."), this ) );
249 lab->setAlignment (AlignHCenter ); 249 lab->setAlignment (AlignHCenter );
250 QHBox* temphb; 250 QHBox* temphb;
251 temphb = new QHBox( this ); 251 temphb = new QHBox( this );
252 new QLabel( i18n("I/O device: "), temphb ); 252 new QLabel( i18n("I/O device: "), temphb );
253 mPhoneDevice = new QLineEdit( temphb); 253 mPhoneDevice = new QLineEdit( temphb);
254 lay->addWidget( temphb ); 254 lay->addWidget( temphb );
255 temphb = new QHBox( this ); 255 temphb = new QHBox( this );
256 new QLabel( i18n("Connection: "), temphb ); 256 new QLabel( i18n("Connection: "), temphb );
257 mPhoneConnection = new QLineEdit( temphb); 257 mPhoneConnection = new QLineEdit( temphb);
258 lay->addWidget( temphb ); 258 lay->addWidget( temphb );
259 temphb = new QHBox( this ); 259 temphb = new QHBox( this );
260 new QLabel( i18n("Model(opt.): "), temphb ); 260 new QLabel( i18n("Model(opt.): "), temphb );
261 mPhoneModel = new QLineEdit( temphb); 261 mPhoneModel = new QLineEdit( temphb);
262 lay->addWidget( temphb ); 262 lay->addWidget( temphb );
263 // mWriteToSim = new QCheckBox( i18n("Write Contacts to SIM card\n(if not, write to phone memory)"), this ); 263 // mWriteToSim = new QCheckBox( i18n("Write Contacts to SIM card\n(if not, write to phone memory)"), this );
264 // lay->addWidget( mWriteToSim ); 264 // lay->addWidget( mWriteToSim );
265 lay->addWidget(lab = new QLabel( i18n("NOTE: This will remove all old\ncontact data on phone!"), this ) ); 265 lay->addWidget(lab = new QLabel( i18n("NOTE: This will remove all old\ncontact data on phone!"), this ) );
266 lab->setAlignment (AlignHCenter ); 266 lab->setAlignment (AlignHCenter);
267 QPushButton * ok = new QPushButton( i18n("Export to mobile phone!"), this ); 267 QPushButton * ok = new QPushButton( i18n("Export to mobile phone!"), this );
268 lay->addWidget( ok ); 268 lay->addWidget( ok );
269 QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); 269 QPushButton * cancel = new QPushButton( i18n("Cancel"), this );
270 lay->addWidget( cancel ); 270 lay->addWidget( cancel );
271 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); 271 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) );
272 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); 272 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) );
273 resize( 220, 240 ); 273 resize( 220, 240 );
274 274
275 } 275 }
276 276
277public: 277public:
278 QLineEdit* mPhoneConnection, *mPhoneDevice, *mPhoneModel; 278 QLineEdit* mPhoneConnection, *mPhoneDevice, *mPhoneModel;
279 QCheckBox* mWriteToSim; 279 QCheckBox* mWriteToSim;
280}; 280};
281 281
282 282
283bool pasteWithNewUid = true; 283bool pasteWithNewUid = true;
284 284
285#ifdef KAB_EMBEDDED 285#ifdef KAB_EMBEDDED
286KABCore::KABCore( KAddressBookMain *client, bool readWrite, QWidget *parent, const char *name ) 286KABCore::KABCore( KAddressBookMain *client, bool readWrite, QWidget *parent, const char *name )
287 : QWidget( parent, name ), KSyncInterface(), mGUIClient( client ), mViewManager( 0 ), 287 : QWidget( parent, name ), KSyncInterface(), mGUIClient( client ), mViewManager( 0 ),
288 mExtensionManager( 0 ),mConfigureDialog( 0 ),/*US mLdapSearchDialog( 0 ),*/ 288 mExtensionManager( 0 ),mConfigureDialog( 0 ),/*US mLdapSearchDialog( 0 ),*/
289 mReadWrite( readWrite ), mModified( false ), mMainWindow(client) 289 mReadWrite( readWrite ), mModified( false ), mMainWindow(client)
290#else //KAB_EMBEDDED 290#else //KAB_EMBEDDED
291KABCore::KABCore( KXMLGUIClient *client, bool readWrite, QWidget *parent, const char *name ) 291KABCore::KABCore( KXMLGUIClient *client, bool readWrite, QWidget *parent, const char *name )
292 : QWidget( parent, name ), KSyncInterface(), mGUIClient( client ), mViewManager( 0 ), 292 : QWidget( parent, name ), KSyncInterface(), mGUIClient( client ), mViewManager( 0 ),
293 mExtensionManager( 0 ), mConfigureDialog( 0 ), mLdapSearchDialog( 0 ), 293 mExtensionManager( 0 ), mConfigureDialog( 0 ), mLdapSearchDialog( 0 ),
294 mReadWrite( readWrite ), mModified( false ) 294 mReadWrite( readWrite ), mModified( false )
295#endif //KAB_EMBEDDED 295#endif //KAB_EMBEDDED
296{ 296{
297 // syncManager = new KSyncManager((QWidget*)this, (KSyncInterface*)this, KSyncManager::KAPI, KABPrefs::instance(), syncMenu); 297 // syncManager = new KSyncManager((QWidget*)this, (KSyncInterface*)this, KSyncManager::KAPI, KABPrefs::instance(), syncMenu);
298 // syncManager->setBlockSave(false); 298 // syncManager->setBlockSave(false);
299 mMiniSplitter = 0; 299 mMiniSplitter = 0;
300 mExtensionBarSplitter = 0; 300 mExtensionBarSplitter = 0;
301 mIsPart = !parent->inherits( "KAddressBookMain" ); 301 mIsPart = !parent->inherits( "KAddressBookMain" );
302 mAddressBook = KABC::StdAddressBook::self(); 302 mAddressBook = KABC::StdAddressBook::self();
303 KABC::StdAddressBook::setAutomaticSave( false ); 303 KABC::StdAddressBook::setAutomaticSave( false );
304 304
305#ifndef KAB_EMBEDDED 305#ifndef KAB_EMBEDDED
306 mAddressBook->setErrorHandler( new KABC::GUIErrorHandler ); 306 mAddressBook->setErrorHandler( new KABC::GUIErrorHandler );
307#endif //KAB_EMBEDDED 307#endif //KAB_EMBEDDED
308 308
309 connect( mAddressBook, SIGNAL( addressBookChanged( AddressBook * ) ), 309 connect( mAddressBook, SIGNAL( addressBookChanged( AddressBook * ) ),
310 SLOT( addressBookChanged() ) ); 310 SLOT( addressBookChanged() ) );
311 311
312#if 0 312#if 0
313 // LP moved to addressbook init method 313 // LP moved to addressbook init method
314 mAddressBook->addCustomField( i18n( "Department" ), KABC::Field::Organization, 314 mAddressBook->addCustomField( i18n( "Department" ), KABC::Field::Organization,
315 "X-Department", "KADDRESSBOOK" ); 315 "X-Department", "KADDRESSBOOK" );
316 mAddressBook->addCustomField( i18n( "Profession" ), KABC::Field::Organization, 316 mAddressBook->addCustomField( i18n( "Profession" ), KABC::Field::Organization,
317 "X-Profession", "KADDRESSBOOK" ); 317 "X-Profession", "KADDRESSBOOK" );
318 mAddressBook->addCustomField( i18n( "Assistant's Name" ), KABC::Field::Organization, 318 mAddressBook->addCustomField( i18n( "Assistant's Name" ), KABC::Field::Organization,
319 "X-AssistantsName", "KADDRESSBOOK" ); 319 "X-AssistantsName", "KADDRESSBOOK" );
320 mAddressBook->addCustomField( i18n( "Manager's Name" ), KABC::Field::Organization, 320 mAddressBook->addCustomField( i18n( "Manager's Name" ), KABC::Field::Organization,
321 "X-ManagersName", "KADDRESSBOOK" ); 321 "X-ManagersName", "KADDRESSBOOK" );
322 mAddressBook->addCustomField( i18n( "Spouse's Name" ), KABC::Field::Personal, 322 mAddressBook->addCustomField( i18n( "Spouse's Name" ), KABC::Field::Personal,
323 "X-SpousesName", "KADDRESSBOOK" ); 323 "X-SpousesName", "KADDRESSBOOK" );
324 mAddressBook->addCustomField( i18n( "Office" ), KABC::Field::Personal, 324 mAddressBook->addCustomField( i18n( "Office" ), KABC::Field::Personal,
325 "X-Office", "KADDRESSBOOK" ); 325 "X-Office", "KADDRESSBOOK" );
326 mAddressBook->addCustomField( i18n( "IM Address" ), KABC::Field::Personal, 326 mAddressBook->addCustomField( i18n( "IM Address" ), KABC::Field::Personal,
327 "X-IMAddress", "KADDRESSBOOK" ); 327 "X-IMAddress", "KADDRESSBOOK" );
328 mAddressBook->addCustomField( i18n( "Anniversary" ), KABC::Field::Personal, 328 mAddressBook->addCustomField( i18n( "Anniversary" ), KABC::Field::Personal,
329 "X-Anniversary", "KADDRESSBOOK" ); 329 "X-Anniversary", "KADDRESSBOOK" );
330 330
@@ -504,128 +504,130 @@ void KABCore::restoreSettings()
504/*US 504/*US
505 QValueList<int> splitterSize = KABPrefs::instance()->mDetailsSplitter; 505 QValueList<int> splitterSize = KABPrefs::instance()->mDetailsSplitter;
506 if ( splitterSize.count() == 0 ) { 506 if ( splitterSize.count() == 0 ) {
507 splitterSize.append( width() / 2 ); 507 splitterSize.append( width() / 2 );
508 splitterSize.append( width() / 2 ); 508 splitterSize.append( width() / 2 );
509 } 509 }
510 mMiniSplitter->setSizes( splitterSize ); 510 mMiniSplitter->setSizes( splitterSize );
511 if ( mExtensionBarSplitter ) { 511 if ( mExtensionBarSplitter ) {
512 splitterSize = KABPrefs::instance()->mExtensionsSplitter; 512 splitterSize = KABPrefs::instance()->mExtensionsSplitter;
513 if ( splitterSize.count() == 0 ) { 513 if ( splitterSize.count() == 0 ) {
514 splitterSize.append( width() / 2 ); 514 splitterSize.append( width() / 2 );
515 splitterSize.append( width() / 2 ); 515 splitterSize.append( width() / 2 );
516 } 516 }
517 mExtensionBarSplitter->setSizes( splitterSize ); 517 mExtensionBarSplitter->setSizes( splitterSize );
518 518
519 } 519 }
520*/ 520*/
521 mViewManager->restoreSettings(); 521 mViewManager->restoreSettings();
522 mIncSearchWidget->setCurrentItem( KABPrefs::instance()->mCurrentIncSearchField ); 522 mIncSearchWidget->setCurrentItem( KABPrefs::instance()->mCurrentIncSearchField );
523 mExtensionManager->restoreSettings(); 523 mExtensionManager->restoreSettings();
524#ifdef DESKTOP_VERSION 524#ifdef DESKTOP_VERSION
525 int wid = width(); 525 int wid = width();
526 if ( wid < 10 ) 526 if ( wid < 10 )
527 wid = 400; 527 wid = 400;
528#else 528#else
529 int wid = QApplication::desktop()->width(); 529 int wid = QApplication::desktop()->width();
530 if ( wid < 640 ) 530 if ( wid < 640 )
531 wid = QApplication::desktop()->height(); 531 wid = QApplication::desktop()->height();
532#endif 532#endif
533 QValueList<int> splitterSize;// = KABPrefs::instance()->mDetailsSplitter; 533 QValueList<int> splitterSize;// = KABPrefs::instance()->mDetailsSplitter;
534 if ( true /*splitterSize.count() == 0*/ ) { 534 if ( true /*splitterSize.count() == 0*/ ) {
535 splitterSize.append( wid / 2 ); 535 splitterSize.append( wid / 2 );
536 splitterSize.append( wid / 2 ); 536 splitterSize.append( wid / 2 );
537 } 537 }
538 mMiniSplitter->setSizes( splitterSize ); 538 mMiniSplitter->setSizes( splitterSize );
539 if ( mExtensionBarSplitter ) { 539 if ( mExtensionBarSplitter ) {
540 //splitterSize = KABPrefs::instance()->mExtensionsSplitter; 540 //splitterSize = KABPrefs::instance()->mExtensionsSplitter;
541 if ( true /*splitterSize.count() == 0*/ ) { 541 if ( true /*splitterSize.count() == 0*/ ) {
542 splitterSize.append( wid / 2 ); 542 splitterSize.append( wid / 2 );
543 splitterSize.append( wid / 2 ); 543 splitterSize.append( wid / 2 );
544 } 544 }
545 mExtensionBarSplitter->setSizes( splitterSize ); 545 mExtensionBarSplitter->setSizes( splitterSize );
546 546
547 } 547 }
548 548
549 549
550} 550}
551 551
552void KABCore::saveSettings() 552void KABCore::saveSettings()
553{ 553{
554 KABPrefs::instance()->mJumpButtonBarVisible = mActionJumpBar->isChecked(); 554 KABPrefs::instance()->mJumpButtonBarVisible = mActionJumpBar->isChecked();
555 if ( mExtensionBarSplitter ) 555 if ( mExtensionBarSplitter )
556 KABPrefs::instance()->mExtensionsSplitter = mExtensionBarSplitter->sizes(); 556 KABPrefs::instance()->mExtensionsSplitter = mExtensionBarSplitter->sizes();
557 KABPrefs::instance()->mDetailsPageVisible = mActionDetails->isChecked(); 557 KABPrefs::instance()->mDetailsPageVisible = mActionDetails->isChecked();
558 KABPrefs::instance()->mDetailsSplitter = mMiniSplitter->sizes(); 558 KABPrefs::instance()->mDetailsSplitter = mMiniSplitter->sizes();
559#ifndef KAB_EMBEDDED 559#ifndef KAB_EMBEDDED
560 560
561 KABPrefs::instance()->mExtensionsSplitter = mExtensionBarSplitter->sizes(); 561 KABPrefs::instance()->mExtensionsSplitter = mExtensionBarSplitter->sizes();
562 KABPrefs::instance()->mDetailsSplitter = mDetailsSplitter->sizes(); 562 KABPrefs::instance()->mDetailsSplitter = mDetailsSplitter->sizes();
563#endif //KAB_EMBEDDED 563#endif //KAB_EMBEDDED
564 mExtensionManager->saveSettings(); 564 mExtensionManager->saveSettings();
565 mViewManager->saveSettings(); 565 mViewManager->saveSettings();
566 566
567 KABPrefs::instance()->mCurrentIncSearchField = mIncSearchWidget->currentItem(); 567 KABPrefs::instance()->mCurrentIncSearchField = mIncSearchWidget->currentItem();
568 KABPrefs::instance()->writeConfig();
569 qDebug("KABPrefs::instance()->writeConfig() ");
568} 570}
569 571
570KABC::AddressBook *KABCore::addressBook() const 572KABC::AddressBook *KABCore::addressBook() const
571{ 573{
572 return mAddressBook; 574 return mAddressBook;
573} 575}
574 576
575KConfig *KABCore::config() 577KConfig *KABCore::config()
576{ 578{
577#ifndef KAB_EMBEDDED 579#ifndef KAB_EMBEDDED
578 return KABPrefs::instance()->config(); 580 return KABPrefs::instance()->config();
579#else //KAB_EMBEDDED 581#else //KAB_EMBEDDED
580 return KABPrefs::instance()->getConfig(); 582 return KABPrefs::instance()->getConfig();
581#endif //KAB_EMBEDDED 583#endif //KAB_EMBEDDED
582} 584}
583 585
584KActionCollection *KABCore::actionCollection() const 586KActionCollection *KABCore::actionCollection() const
585{ 587{
586 return mGUIClient->actionCollection(); 588 return mGUIClient->actionCollection();
587} 589}
588 590
589KABC::Field *KABCore::currentSearchField() const 591KABC::Field *KABCore::currentSearchField() const
590{ 592{
591 if (mIncSearchWidget) 593 if (mIncSearchWidget)
592 return mIncSearchWidget->currentField(); 594 return mIncSearchWidget->currentField();
593 else 595 else
594 return 0; 596 return 0;
595} 597}
596 598
597QStringList KABCore::selectedUIDs() const 599QStringList KABCore::selectedUIDs() const
598{ 600{
599 return mViewManager->selectedUids(); 601 return mViewManager->selectedUids();
600} 602}
601 603
602KABC::Resource *KABCore::requestResource( QWidget *parent ) 604KABC::Resource *KABCore::requestResource( QWidget *parent )
603{ 605{
604 QPtrList<KABC::Resource> kabcResources = addressBook()->resources(); 606 QPtrList<KABC::Resource> kabcResources = addressBook()->resources();
605 607
606 QPtrList<KRES::Resource> kresResources; 608 QPtrList<KRES::Resource> kresResources;
607 QPtrListIterator<KABC::Resource> resIt( kabcResources ); 609 QPtrListIterator<KABC::Resource> resIt( kabcResources );
608 KABC::Resource *resource; 610 KABC::Resource *resource;
609 while ( ( resource = resIt.current() ) != 0 ) { 611 while ( ( resource = resIt.current() ) != 0 ) {
610 ++resIt; 612 ++resIt;
611 if ( !resource->readOnly() ) { 613 if ( !resource->readOnly() ) {
612 KRES::Resource *res = static_cast<KRES::Resource*>( resource ); 614 KRES::Resource *res = static_cast<KRES::Resource*>( resource );
613 if ( res ) 615 if ( res )
614 kresResources.append( res ); 616 kresResources.append( res );
615 } 617 }
616 } 618 }
617 619
618 KRES::Resource *res = KRES::SelectDialog::getResource( kresResources, parent ); 620 KRES::Resource *res = KRES::SelectDialog::getResource( kresResources, parent );
619 return static_cast<KABC::Resource*>( res ); 621 return static_cast<KABC::Resource*>( res );
620} 622}
621 623
622#ifndef KAB_EMBEDDED 624#ifndef KAB_EMBEDDED
623KAboutData *KABCore::createAboutData() 625KAboutData *KABCore::createAboutData()
624#else //KAB_EMBEDDED 626#else //KAB_EMBEDDED
625void KABCore::createAboutData() 627void KABCore::createAboutData()
626#endif //KAB_EMBEDDED 628#endif //KAB_EMBEDDED
627{ 629{
628#ifndef KAB_EMBEDDED 630#ifndef KAB_EMBEDDED
629 KAboutData *about = new KAboutData( "kaddressbook", I18N_NOOP( "KAddressBook" ), 631 KAboutData *about = new KAboutData( "kaddressbook", I18N_NOOP( "KAddressBook" ),
630 "3.1", I18N_NOOP( "The KDE Address Book" ), 632 "3.1", I18N_NOOP( "The KDE Address Book" ),
631 KAboutData::License_GPL_V2, 633 KAboutData::License_GPL_V2,
@@ -2624,207 +2626,209 @@ void KABCore::whatsnew()
2624} 2626}
2625void KABCore::synchowto() 2627void KABCore::synchowto()
2626{ 2628{
2627 KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/SyncHowto.txt" ); 2629 KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/SyncHowto.txt" );
2628} 2630}
2629void KABCore::kdesynchowto() 2631void KABCore::kdesynchowto()
2630{ 2632{
2631 KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/Zaurus-KDE_syncHowTo.txt" ); 2633 KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/Zaurus-KDE_syncHowTo.txt" );
2632} 2634}
2633void KABCore::multisynchowto() 2635void KABCore::multisynchowto()
2634{ 2636{
2635 KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/MultiSyncHowTo.txt" ); 2637 KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/MultiSyncHowTo.txt" );
2636} 2638}
2637void KABCore::faq() 2639void KABCore::faq()
2638{ 2640{
2639 KApplication::showFile( "KA/Pi FAQ", "kdepim/kaddressbook/kapiFAQ.txt" ); 2641 KApplication::showFile( "KA/Pi FAQ", "kdepim/kaddressbook/kapiFAQ.txt" );
2640} 2642}
2641 2643
2642#include <libkcal/syncdefines.h> 2644#include <libkcal/syncdefines.h>
2643 2645
2644KABC::Addressee KABCore::getLastSyncAddressee() 2646KABC::Addressee KABCore::getLastSyncAddressee()
2645{ 2647{
2646 Addressee lse; 2648 Addressee lse;
2647 QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice(); 2649 QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice();
2648 2650
2649 //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() ); 2651 //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() );
2650 lse = mAddressBook->findByUid( "last-syncAddressee-"+mCurrentSyncDevice ); 2652 lse = mAddressBook->findByUid( "last-syncAddressee-"+mCurrentSyncDevice );
2651 if (lse.isEmpty()) { 2653 if (lse.isEmpty()) {
2652 qDebug("Creating new last-syncAddressee "); 2654 qDebug("Creating new last-syncAddressee ");
2653 lse.setUid( "last-syncAddressee-"+mCurrentSyncDevice ); 2655 lse.setUid( "last-syncAddressee-"+mCurrentSyncDevice );
2654 QString sum = ""; 2656 QString sum = "";
2655 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) 2657 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL )
2656 sum = "E: "; 2658 sum = "E: ";
2657 lse.setFamilyName("!"+sum+mCurrentSyncDevice + i18n(" - sync event")); 2659 lse.setFamilyName("!"+sum+mCurrentSyncDevice + i18n(" - sync event"));
2658 lse.setRevision( mLastAddressbookSync ); 2660 lse.setRevision( mLastAddressbookSync );
2659 lse.setCategories( i18n("SyncEvent") ); 2661 lse.setCategories( i18n("SyncEvent") );
2660 mAddressBook->insertAddressee( lse ); 2662 mAddressBook->insertAddressee( lse );
2661 } 2663 }
2662 return lse; 2664 return lse;
2663} 2665}
2664int KABCore::takeAddressee( KABC::Addressee* local, KABC::Addressee* remote, int mode , bool full ) 2666int KABCore::takeAddressee( KABC::Addressee* local, KABC::Addressee* remote, int mode , bool full )
2665{ 2667{
2666 2668
2667 //void setZaurusId(int id); 2669 //void setZaurusId(int id);
2668 // int zaurusId() const; 2670 // int zaurusId() const;
2669 // void setZaurusUid(int id); 2671 // void setZaurusUid(int id);
2670 // int zaurusUid() const; 2672 // int zaurusUid() const;
2671 // void setZaurusStat(int id); 2673 // void setZaurusStat(int id);
2672 // int zaurusStat() const; 2674 // int zaurusStat() const;
2673 // 0 equal 2675 // 0 equal
2674 // 1 take local 2676 // 1 take local
2675 // 2 take remote 2677 // 2 take remote
2676 // 3 cancel 2678 // 3 cancel
2677 QDateTime lastSync = mLastAddressbookSync; 2679 QDateTime lastSync = mLastAddressbookSync;
2678 QDateTime localMod = local->revision(); 2680 QDateTime localMod = local->revision();
2679 QDateTime remoteMod = remote->revision(); 2681 QDateTime remoteMod = remote->revision();
2680 2682
2681 QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice(); 2683 QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice();
2682 2684
2683 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 2685 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
2684 bool remCh, locCh; 2686 bool remCh, locCh;
2685 remCh = ( remote->getCsum(mCurrentSyncDevice) != local->getCsum(mCurrentSyncDevice) ); 2687 remCh = ( remote->getCsum(mCurrentSyncDevice) != local->getCsum(mCurrentSyncDevice) );
2686 //qDebug("loc %s rem %s", local->getCsum(mCurrentSyncDevice).latin1(), remote->getCsum(mCurrentSyncDevice).latin1() ); 2688 //qDebug("loc %s rem %s", local->getCsum(mCurrentSyncDevice).latin1(), remote->getCsum(mCurrentSyncDevice).latin1() );
2687 locCh = ( localMod > mLastAddressbookSync ); 2689 locCh = ( localMod > mLastAddressbookSync );
2690 //qDebug("cahnged rem %d loc %d",remCh, locCh );
2688 if ( !remCh && ! locCh ) { 2691 if ( !remCh && ! locCh ) {
2689 //qDebug("both not changed "); 2692 //qDebug("both not changed ");
2690 lastSync = localMod.addDays(1); 2693 lastSync = localMod.addDays(1);
2691 if ( mode <= SYNC_PREF_ASK ) 2694 if ( mode <= SYNC_PREF_ASK )
2692 return 0; 2695 return 0;
2693 } else { 2696 } else {
2694 if ( locCh ) { 2697 if ( locCh ) {
2695 //qDebug("loc changed %s %s", localMod.toString().latin1(), mLastAddressbookSync.toString().latin1()); 2698 //qDebug("loc changed %s %s", localMod.toString().latin1(), mLastAddressbookSync.toString().latin1());
2696 lastSync = localMod.addDays( -1 ); 2699 lastSync = localMod.addDays( -1 );
2697 if ( !remCh ) 2700 if ( !remCh )
2698 remoteMod =( lastSync.addDays( -1 ) ); 2701 remoteMod =( lastSync.addDays( -1 ) );
2699 } else { 2702 } else {
2700 //qDebug(" not loc changed "); 2703 //qDebug(" not loc changed ");
2701 lastSync = localMod.addDays( 1 ); 2704 lastSync = localMod.addDays( 1 );
2702 if ( remCh ) { 2705 if ( remCh ) {
2703 //qDebug("rem changed "); 2706 //qDebug("rem changed ");
2704 remoteMod =( lastSync.addDays( 1 ) ); 2707 remoteMod =( lastSync.addDays( 1 ) );
2705 } 2708 }
2706 2709
2707 } 2710 }
2708 } 2711 }
2709 full = true; 2712 full = true;
2710 if ( mode < SYNC_PREF_ASK ) 2713 if ( mode < SYNC_PREF_ASK )
2711 mode = SYNC_PREF_ASK; 2714 mode = SYNC_PREF_ASK;
2712 } else { 2715 } else {
2713 if ( localMod == remoteMod ) 2716 if ( localMod == remoteMod )
2714 return 0; 2717 return 0;
2715 2718
2716 } 2719 }
2717 //qDebug("%s %s --- %d %d", localMod.toString().latin1() , remoteMod.toString().latin1(), localMod.time().msec(), remoteMod.time().msec()); 2720 //qDebug("%s %s --- %d %d", localMod.toString().latin1() , remoteMod.toString().latin1(), localMod.time().msec(), remoteMod.time().msec());
2718 //qDebug("lastsync %s ", lastSync.toString().latin1() ); 2721 //qDebug("lastsync %s ", lastSync.toString().latin1() );
2719 //full = true; //debug only 2722 //full = true; //debug only
2720 if ( full ) { 2723 if ( full ) {
2721 bool equ = ( (*local) == (*remote) ); 2724 bool equ = ( (*local) == (*remote) );
2722 if ( equ ) { 2725 if ( equ ) {
2723 //qDebug("equal "); 2726 //qDebug("equal ");
2724 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 2727 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
2725 local->setCsum( mCurrentSyncDevice, remote->getCsum(mCurrentSyncDevice) ); 2728 local->setCsum( mCurrentSyncDevice, remote->getCsum(mCurrentSyncDevice) );
2726 } 2729 }
2727 if ( mode < SYNC_PREF_FORCE_LOCAL ) 2730 if ( mode < SYNC_PREF_FORCE_LOCAL )
2728 return 0; 2731 return 0;
2729 2732
2730 }//else //debug only 2733 }//else //debug only
2731 //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1()); 2734 //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1());
2732 } 2735 }
2733 int result; 2736 int result;
2734 bool localIsNew; 2737 bool localIsNew;
2735 //qDebug("%s -- %s mLastCalendarSync %s lastsync %s --- local %s remote %s ",local->summary().latin1(), remote->summary().latin1(),mLastCalendarSync.toString().latin1() ,lastSync.toString().latin1() , local->lastModified().toString().latin1() , remote->lastModified().toString().latin1() ); 2738 //qDebug("%s -- %s mLastCalendarSync %s lastsync %s --- local %s remote %s ",local->summary().latin1(), remote->summary().latin1(),mLastCalendarSync.toString().latin1() ,lastSync.toString().latin1() , local->lastModified().toString().latin1() , remote->lastModified().toString().latin1() );
2736 2739
2737 if ( full && mode < SYNC_PREF_NEWEST ) 2740 if ( full && mode < SYNC_PREF_NEWEST )
2738 mode = SYNC_PREF_ASK; 2741 mode = SYNC_PREF_ASK;
2739 2742
2740 switch( mode ) { 2743 switch( mode ) {
2741 case SYNC_PREF_LOCAL: 2744 case SYNC_PREF_LOCAL:
2742 if ( lastSync > remoteMod ) 2745 if ( lastSync > remoteMod )
2743 return 1; 2746 return 1;
2744 if ( lastSync > localMod ) 2747 if ( lastSync > localMod )
2745 return 2; 2748 return 2;
2746 return 1; 2749 return 1;
2747 break; 2750 break;
2748 case SYNC_PREF_REMOTE: 2751 case SYNC_PREF_REMOTE:
2749 if ( lastSync > remoteMod ) 2752 if ( lastSync > remoteMod )
2750 return 1; 2753 return 1;
2751 if ( lastSync > localMod ) 2754 if ( lastSync > localMod )
2752 return 2; 2755 return 2;
2753 return 2; 2756 return 2;
2754 break; 2757 break;
2755 case SYNC_PREF_NEWEST: 2758 case SYNC_PREF_NEWEST:
2756 if ( localMod > remoteMod ) 2759 if ( localMod > remoteMod )
2757 return 1; 2760 return 1;
2758 else 2761 else
2759 return 2; 2762 return 2;
2760 break; 2763 break;
2761 case SYNC_PREF_ASK: 2764 case SYNC_PREF_ASK:
2762 //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); 2765 //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() );
2763 if ( lastSync > remoteMod ) 2766 if ( lastSync > remoteMod )
2764 return 1; 2767 return 1;
2765 if ( lastSync > localMod ) 2768 if ( lastSync > localMod ) {
2766 return 2; 2769 return 2;
2770 }
2767 localIsNew = localMod >= remoteMod; 2771 localIsNew = localMod >= remoteMod;
2768 //qDebug("conflict! ************************************** "); 2772 //qDebug("conflict! ************************************** ");
2769 { 2773 {
2770 KABC::AddresseeChooser acd ( *local,*remote, localIsNew , this ); 2774 KABC::AddresseeChooser acd ( *local,*remote, localIsNew , this );
2771 result = acd.executeD(localIsNew); 2775 result = acd.executeD(localIsNew);
2772 return result; 2776 return result;
2773 } 2777 }
2774 break; 2778 break;
2775 case SYNC_PREF_FORCE_LOCAL: 2779 case SYNC_PREF_FORCE_LOCAL:
2776 return 1; 2780 return 1;
2777 break; 2781 break;
2778 case SYNC_PREF_FORCE_REMOTE: 2782 case SYNC_PREF_FORCE_REMOTE:
2779 return 2; 2783 return 2;
2780 break; 2784 break;
2781 2785
2782 default: 2786 default:
2783 // SYNC_PREF_TAKE_BOTH not implemented 2787 // SYNC_PREF_TAKE_BOTH not implemented
2784 break; 2788 break;
2785 } 2789 }
2786 return 0; 2790 return 0;
2787} 2791}
2788 2792
2789 2793
2790bool KABCore::synchronizeAddressbooks( KABC::AddressBook* local, KABC::AddressBook* remote,int mode) 2794bool KABCore::synchronizeAddressbooks( KABC::AddressBook* local, KABC::AddressBook* remote,int mode)
2791{ 2795{
2792 bool syncOK = true; 2796 bool syncOK = true;
2793 int addedAddressee = 0; 2797 int addedAddressee = 0;
2794 int addedAddresseeR = 0; 2798 int addedAddresseeR = 0;
2795 int deletedAddresseeR = 0; 2799 int deletedAddresseeR = 0;
2796 int deletedAddresseeL = 0; 2800 int deletedAddresseeL = 0;
2797 int changedLocal = 0; 2801 int changedLocal = 0;
2798 int changedRemote = 0; 2802 int changedRemote = 0;
2799 2803
2800 QString mCurrentSyncName = syncManager->getCurrentSyncName(); 2804 QString mCurrentSyncName = syncManager->getCurrentSyncName();
2801 QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice(); 2805 QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice();
2802 2806
2803 //QPtrList<Addressee> el = local->rawAddressees(); 2807 //QPtrList<Addressee> el = local->rawAddressees();
2804 Addressee addresseeR; 2808 Addressee addresseeR;
2805 QString uid; 2809 QString uid;
2806 int take; 2810 int take;
2807 Addressee addresseeL; 2811 Addressee addresseeL;
2808 Addressee addresseeRSync; 2812 Addressee addresseeRSync;
2809 Addressee addresseeLSync; 2813 Addressee addresseeLSync;
2810 // KABC::Addressee::List addresseeRSyncSharp = remote->getExternLastSyncAddressees(); 2814 // KABC::Addressee::List addresseeRSyncSharp = remote->getExternLastSyncAddressees();
2811 //KABC::Addressee::List addresseeLSyncSharp = local->getExternLastSyncAddressees(); 2815 //KABC::Addressee::List addresseeLSyncSharp = local->getExternLastSyncAddressees();
2812 bool fullDateRange = false; 2816 bool fullDateRange = false;
2813 local->resetTempSyncStat(); 2817 local->resetTempSyncStat();
2814 mLastAddressbookSync = QDateTime::currentDateTime(); 2818 mLastAddressbookSync = QDateTime::currentDateTime();
2815 if ( syncManager->syncWithDesktop() ) { 2819 if ( syncManager->syncWithDesktop() ) {
2816 // remote->removeSyncInfo( QString());//remove all info 2820 // remote->removeSyncInfo( QString());//remove all info
2817 if ( KSyncManager::mRequestedSyncEvent.isValid() ) { 2821 if ( KSyncManager::mRequestedSyncEvent.isValid() ) {
2818 mLastAddressbookSync = KSyncManager::mRequestedSyncEvent; 2822 mLastAddressbookSync = KSyncManager::mRequestedSyncEvent;
2819 qDebug("using extern time for calendar sync: %s ", mLastAddressbookSync.toString().latin1() ); 2823 qDebug("using extern time for calendar sync: %s ", mLastAddressbookSync.toString().latin1() );
2820 } else { 2824 } else {
2821 qDebug("KSyncManager::mRequestedSyncEvent has invalid datatime "); 2825 qDebug("KSyncManager::mRequestedSyncEvent has invalid datatime ");
2822 } 2826 }
2823 } 2827 }
2824 QDateTime modifiedCalendar = mLastAddressbookSync; 2828 QDateTime modifiedCalendar = mLastAddressbookSync;
2825 addresseeLSync = getLastSyncAddressee(); 2829 addresseeLSync = getLastSyncAddressee();
2826 qDebug("Last Sync %s ", addresseeLSync.revision().toString().latin1()); 2830 qDebug("Last Sync %s ", addresseeLSync.revision().toString().latin1());
2827 addresseeR = remote->findByUid("last-syncAddressee-"+mCurrentSyncName ); 2831 addresseeR = remote->findByUid("last-syncAddressee-"+mCurrentSyncName );
2828 if ( !addresseeR.isEmpty() ) { 2832 if ( !addresseeR.isEmpty() ) {
2829 addresseeRSync = addresseeR; 2833 addresseeRSync = addresseeR;
2830 remote->removeAddressee(addresseeR ); 2834 remote->removeAddressee(addresseeR );
@@ -2945,132 +2949,134 @@ bool KABCore::synchronizeAddressbooks( KABC::AddressBook* local, KABC::AddressBo
2945 inL.setIDStr( idS ); 2949 inL.setIDStr( idS );
2946 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 2950 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
2947 inL.setCsum( mCurrentSyncDevice, inR.getCsum(mCurrentSyncDevice) ); 2951 inL.setCsum( mCurrentSyncDevice, inR.getCsum(mCurrentSyncDevice) );
2948 inL.setID( mCurrentSyncDevice, inR.getID(mCurrentSyncDevice) ); 2952 inL.setID( mCurrentSyncDevice, inR.getID(mCurrentSyncDevice) );
2949 } 2953 }
2950 inL.setResource( 0 ); 2954 inL.setResource( 0 );
2951 local->insertAddressee( inL , false ); 2955 local->insertAddressee( inL , false );
2952 ++changedLocal; 2956 ++changedLocal;
2953 } 2957 }
2954 } 2958 }
2955 } 2959 }
2956 } else { // no conflict ********** add or delete remote 2960 } else { // no conflict ********** add or delete remote
2957 if ( filterIN.name().isEmpty() || filterIN.filterAddressee( inR ) ) { 2961 if ( filterIN.name().isEmpty() || filterIN.filterAddressee( inR ) ) {
2958 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 2962 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
2959 QString des = addresseeLSync.note(); 2963 QString des = addresseeLSync.note();
2960 if ( des.find( inR.getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it 2964 if ( des.find( inR.getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it
2961 inR.setTempSyncStat( SYNC_TEMPSTATE_DELETE ); 2965 inR.setTempSyncStat( SYNC_TEMPSTATE_DELETE );
2962 remote->insertAddressee( inR, false ); 2966 remote->insertAddressee( inR, false );
2963 ++deletedAddresseeR; 2967 ++deletedAddresseeR;
2964 } else { 2968 } else {
2965 inR.setRevision( modifiedCalendar ); 2969 inR.setRevision( modifiedCalendar );
2966 remote->insertAddressee( inR, false ); 2970 remote->insertAddressee( inR, false );
2967 inL = inR; 2971 inL = inR;
2968 inL.setIDStr( ":" ); 2972 inL.setIDStr( ":" );
2969 inL.setCsum( mCurrentSyncDevice, inR.getCsum(mCurrentSyncDevice) ); 2973 inL.setCsum( mCurrentSyncDevice, inR.getCsum(mCurrentSyncDevice) );
2970 inL.setID( mCurrentSyncDevice, inR.getID(mCurrentSyncDevice) ); 2974 inL.setID( mCurrentSyncDevice, inR.getID(mCurrentSyncDevice) );
2971 inL.setResource( 0 ); 2975 inL.setResource( 0 );
2972 local->insertAddressee( inL , false); 2976 local->insertAddressee( inL , false);
2973 ++addedAddressee; 2977 ++addedAddressee;
2974 } 2978 }
2975 } else { 2979 } else {
2976 if ( inR.revision() > mLastAddressbookSync || mode == 5 ) { 2980 if ( inR.revision() > mLastAddressbookSync || mode == 5 ) {
2977 inR.setRevision( modifiedCalendar ); 2981 inR.setRevision( modifiedCalendar );
2978 remote->insertAddressee( inR, false ); 2982 remote->insertAddressee( inR, false );
2979 inR.setResource( 0 ); 2983 inR.setResource( 0 );
2980 local->insertAddressee( inR, false ); 2984 local->insertAddressee( inR, false );
2981 ++addedAddressee; 2985 ++addedAddressee;
2982 } else { 2986 } else {
2983 // pending checkExternSyncAddressee(addresseeRSyncSharp, inR); 2987 // pending checkExternSyncAddressee(addresseeRSyncSharp, inR);
2984 remote->removeAddressee( inR ); 2988 remote->removeAddressee( inR );
2985 ++deletedAddresseeR; 2989 ++deletedAddresseeR;
2986 } 2990 }
2987 } 2991 }
2988 } 2992 }
2989 } 2993 }
2990 } 2994 }
2991 ++incCounter; 2995 ++incCounter;
2992 } 2996 }
2993 er.clear(); 2997 er.clear();
2994 QStringList el = local->uidList(); 2998 QStringList el = local->uidList();
2995 modulo = (el.count()/10)+1; 2999 modulo = (el.count()/10)+1;
2996 3000
2997 syncManager->showProgressBar(0, i18n("Add / remove addressees"), el.count()); 3001 syncManager->showProgressBar(0, i18n("Add / remove addressees"), el.count());
2998 incCounter = 0; 3002 incCounter = 0;
2999 while ( incCounter < el.count()) { 3003 while ( incCounter < el.count()) {
3000 qApp->processEvents(); 3004 qApp->processEvents();
3001 if (syncManager->isProgressBarCanceled()) 3005 if (syncManager->isProgressBarCanceled())
3002 return false; 3006 return false;
3003 if ( incCounter % modulo == 0 ) 3007 if ( incCounter % modulo == 0 )
3004 syncManager->showProgressBar(incCounter); 3008 syncManager->showProgressBar(incCounter);
3005 uid = el[ incCounter ]; 3009 uid = el[ incCounter ];
3006 bool skipIncidence = false; 3010 bool skipIncidence = false;
3007 if ( uid.left(19) == QString("last-syncAddressee-") ) 3011 if ( uid.left(19) == QString("last-syncAddressee-") )
3008 skipIncidence = true; 3012 skipIncidence = true;
3009 if ( !filterOUT.name().isEmpty() && ! filterOUT.filterAddressee( inL ) ) 3013 if ( ! skipIncidence ) {
3010 skipIncidence = true;
3011 if ( !skipIncidence ) {
3012 inL = local->findByUid( uid ); 3014 inL = local->findByUid( uid );
3015 if ( (!filterOUT.name().isEmpty()) && (! filterOUT.filterAddressee( inL ) ) )
3016 skipIncidence = true;
3017 }
3018 if ( !skipIncidence ) {
3013 if ( !inL.resource() || inL.resource()->includeInSync() ) { 3019 if ( !inL.resource() || inL.resource()->includeInSync() ) {
3014 inR = remote->findByUid( uid ); 3020 inR = remote->findByUid( uid );
3015 if ( inR.isEmpty() ) { // no conflict ********** add or delete local 3021 if ( inR.isEmpty() ) { // no conflict ********** add or delete local
3016 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 3022 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
3017 if ( !inL.getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) { 3023 if ( !inL.getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) {
3018 // pending checkExternSyncAddressee(addresseeLSyncSharp, inL); 3024 // pending checkExternSyncAddressee(addresseeLSyncSharp, inL);
3019 local->removeAddressee( inL ); 3025 local->removeAddressee( inL );
3020 ++deletedAddresseeL; 3026 ++deletedAddresseeL;
3021 } else { 3027 } else {
3022 if ( ! syncManager->mWriteBackExistingOnly ) { 3028 if ( ! syncManager->mWriteBackExistingOnly ) {
3023 inL.removeID(mCurrentSyncDevice ); 3029 inL.removeID(mCurrentSyncDevice );
3024 ++addedAddresseeR; 3030 ++addedAddresseeR;
3025 inL.setRevision( modifiedCalendar ); 3031 inL.setRevision( modifiedCalendar );
3026 local->insertAddressee( inL, false ); 3032 local->insertAddressee( inL, false );
3027 inR = inL; 3033 inR = inL;
3028 inR.setTempSyncStat( SYNC_TEMPSTATE_ADDED_EXTERNAL ); 3034 inR.setTempSyncStat( SYNC_TEMPSTATE_ADDED_EXTERNAL );
3029 inR.setResource( 0 ); 3035 inR.setResource( 0 );
3030 remote->insertAddressee( inR, false ); 3036 remote->insertAddressee( inR, false );
3031 } 3037 }
3032 } 3038 }
3033 } else { 3039 } else {
3034 if ( inL.revision() < mLastAddressbookSync && mode != 4 ) { 3040 if ( inL.revision() < mLastAddressbookSync && mode != 4 ) {
3035 //qDebug("data %s ", inL.revision().toString().latin1()); 3041 //qDebug("data %s ", inL.revision().toString().latin1());
3036 // pending checkExternSyncAddressee(addresseeLSyncSharp, inL); 3042 // pending checkExternSyncAddressee(addresseeLSyncSharp, inL);
3037 local->removeAddressee( inL ); 3043 local->removeAddressee( inL );
3038 ++deletedAddresseeL; 3044 ++deletedAddresseeL;
3039 } else { 3045 } else {
3040 if ( ! syncManager->mWriteBackExistingOnly ) { 3046 if ( ! syncManager->mWriteBackExistingOnly ) {
3041 ++addedAddresseeR; 3047 ++addedAddresseeR;
3042 inL.setRevision( modifiedCalendar ); 3048 inL.setRevision( modifiedCalendar );
3043 local->insertAddressee( inL, false ); 3049 local->insertAddressee( inL, false );
3044 inR = inL; 3050 inR = inL;
3045 inR.setIDStr( ":" ); 3051 inR.setIDStr( ":" );
3046 inR.setResource( 0 ); 3052 inR.setResource( 0 );
3047 remote->insertAddressee( inR, false ); 3053 remote->insertAddressee( inR, false );
3048 } 3054 }
3049 } 3055 }
3050 } 3056 }
3051 } 3057 }
3052 } 3058 }
3053 } 3059 }
3054 ++incCounter; 3060 ++incCounter;
3055 } 3061 }
3056 el.clear(); 3062 el.clear();
3057 syncManager->hideProgressBar(); 3063 syncManager->hideProgressBar();
3058 mLastAddressbookSync = QDateTime::currentDateTime().addSecs( 1 ); 3064 mLastAddressbookSync = QDateTime::currentDateTime().addSecs( 1 );
3059 // get rid of micro seconds 3065 // get rid of micro seconds
3060 QTime t = mLastAddressbookSync.time(); 3066 QTime t = mLastAddressbookSync.time();
3061 mLastAddressbookSync.setTime( QTime (t.hour (), t.minute (), t.second () ) ); 3067 mLastAddressbookSync.setTime( QTime (t.hour (), t.minute (), t.second () ) );
3062 addresseeLSync.setRevision( mLastAddressbookSync ); 3068 addresseeLSync.setRevision( mLastAddressbookSync );
3063 addresseeRSync.setRevision( mLastAddressbookSync ); 3069 addresseeRSync.setRevision( mLastAddressbookSync );
3064 addresseeRSync.setRole( i18n("!Remote from: ")+mCurrentSyncName ) ; 3070 addresseeRSync.setRole( i18n("!Remote from: ")+mCurrentSyncName ) ;
3065 addresseeLSync.setRole(i18n("!Local from: ") + mCurrentSyncName ); 3071 addresseeLSync.setRole(i18n("!Local from: ") + mCurrentSyncName );
3066 addresseeRSync.setGivenName( i18n("!DO NOT EDIT!") ) ; 3072 addresseeRSync.setGivenName( i18n("!DO NOT EDIT!") ) ;
3067 addresseeLSync.setGivenName(i18n("!DO NOT EDIT!") ); 3073 addresseeLSync.setGivenName(i18n("!DO NOT EDIT!") );
3068 addresseeRSync.setOrganization( "!"+mLastAddressbookSync.toString() ) ; 3074 addresseeRSync.setOrganization( "!"+mLastAddressbookSync.toString() ) ;
3069 addresseeLSync.setOrganization("!"+ mLastAddressbookSync.toString() ); 3075 addresseeLSync.setOrganization("!"+ mLastAddressbookSync.toString() );
3070 addresseeRSync.setNote( "" ) ; 3076 addresseeRSync.setNote( "" ) ;
3071 addresseeLSync.setNote( "" ); 3077 addresseeLSync.setNote( "" );
3072 3078
3073 if ( mGlobalSyncMode == SYNC_MODE_NORMAL) 3079 if ( mGlobalSyncMode == SYNC_MODE_NORMAL)
3074 remote->insertAddressee( addresseeRSync, false ); 3080 remote->insertAddressee( addresseeRSync, false );
3075 local->insertAddressee( addresseeLSync, false ); 3081 local->insertAddressee( addresseeLSync, false );
3076 QString mes; 3082 QString mes;
diff --git a/kaddressbook/kaddressbookmain.cpp b/kaddressbook/kaddressbookmain.cpp
index 2832257..519dc92 100644
--- a/kaddressbook/kaddressbookmain.cpp
+++ b/kaddressbook/kaddressbookmain.cpp
@@ -166,74 +166,74 @@ void KAddressBookMain::createGUI()
166 166
167void KAddressBookMain::configureToolbars() 167void KAddressBookMain::configureToolbars()
168{ 168{
169#ifndef KAB_EMBEDDED 169#ifndef KAB_EMBEDDED
170 saveMainWindowSettings( KGlobal::config(), "MainWindow" ); 170 saveMainWindowSettings( KGlobal::config(), "MainWindow" );
171 171
172 KEditToolbar dlg( factory() ); 172 KEditToolbar dlg( factory() );
173 connect( &dlg, SIGNAL( newToolbarConfig() ), SLOT( slotNewToolbarConfig() ) ); 173 connect( &dlg, SIGNAL( newToolbarConfig() ), SLOT( slotNewToolbarConfig() ) );
174 174
175 dlg.exec(); 175 dlg.exec();
176#else //KAB_EMBEDDED 176#else //KAB_EMBEDDED
177 qDebug("KAddressBookMain::configureToolbars() not implemented by ulf" ); 177 qDebug("KAddressBookMain::configureToolbars() not implemented by ulf" );
178#endif //KAB_EMBEDDED 178#endif //KAB_EMBEDDED
179} 179}
180 180
181void KAddressBookMain::slotNewToolbarConfig() 181void KAddressBookMain::slotNewToolbarConfig()
182{ 182{
183#ifndef KAB_EMBEDDED 183#ifndef KAB_EMBEDDED
184 applyMainWindowSettings( KGlobal::config(), "MainWindow" ); 184 applyMainWindowSettings( KGlobal::config(), "MainWindow" );
185#else //KAB_EMBEDDED 185#else //KAB_EMBEDDED
186 qDebug("KAddressBookMain::slotNewToolbarConfig() not implemented by ulf" ); 186 qDebug("KAddressBookMain::slotNewToolbarConfig() not implemented by ulf" );
187#endif //KAB_EMBEDDED 187#endif //KAB_EMBEDDED
188} 188}
189 189
190void KAddressBookMain::configureKeys() 190void KAddressBookMain::configureKeys()
191{ 191{
192#ifndef KAB_EMBEDDED 192#ifndef KAB_EMBEDDED
193 KKeyDialog::configureKeys( actionCollection(), xmlFile(), true, this ); 193 KKeyDialog::configureKeys( actionCollection(), xmlFile(), true, this );
194#else //KAB_EMBEDDED 194#else //KAB_EMBEDDED
195 qDebug("KAddressBookMain::configureKeys() not implemented by ulf" ); 195 qDebug("KAddressBookMain::configureKeys() not implemented by ulf" );
196#endif //KAB_EMBEDDED 196#endif //KAB_EMBEDDED
197} 197}
198 198
199void KAddressBookMain::closeEvent( QCloseEvent* ce ) 199void KAddressBookMain::closeEvent( QCloseEvent* ce )
200{ 200{
201 bool mModified = mCore->modified(); 201 bool mModified = mCore->modified();
202 bool mAskForQuit = KABPrefs::instance()->mAskForQuit; 202 bool mAskForQuit = KABPrefs::instance()->mAskForQuit;
203 203
204 QString mess = i18n( "Close KA/Pi?"); 204 QString mess = i18n( "Close KA/Pi?");
205 if ( mModified == true ) 205 if ( mModified == true )
206 mess += i18n( "\nChanges will be saved!"); 206 mess += i18n( "\nChanges will be saved!");
207 else 207 else
208 mess += i18n( "\nNo unsaved changes detected!\nNothing will be saved!"); 208 mess += i18n( "\nNo unsaved changes detected!\nNothing will be saved!");
209 209
210 bool mQuit = true; 210 bool mQuit = true;
211 211
212 212
213 if (mAskForQuit) 213 if (mAskForQuit)
214 { 214 {
215 215
216 int res = QMessageBox::information( this, "KA/Pi", mess , i18n("Yes!"), i18n("No"), 0, 0 ); 216 int res = QMessageBox::information( this, "KA/Pi", mess , i18n("Yes!"), i18n("No"), 0, 0 );
217 if (res == 0) 217 if (res == 0)
218 mQuit = true; 218 mQuit = true;
219 else 219 else
220 mQuit = false; 220 mQuit = false;
221 } 221 }
222 222
223 if (mQuit == false) 223 if (mQuit == false)
224 return; 224 return;
225 225
226 if (mModified == true) 226 if (mModified == true)
227 { 227 {
228 save(); 228 save();
229 mCore->saveSettings(); 229 mCore->saveSettings();
230 KABPrefs::instance()->writeConfig(); 230 //KABPrefs::instance()->writeConfig();
231 } 231 }
232 232
233 ce->accept(); 233 ce->accept();
234} 234}
235 235
236#ifndef KAB_EMBEDDED 236#ifndef KAB_EMBEDDED
237#include "kaddressbookmain.moc" 237#include "kaddressbookmain.moc"
238#endif //KAB_EMBEDDED 238#endif //KAB_EMBEDDED
239 239
diff --git a/kaddressbook/viewmanager.cpp b/kaddressbook/viewmanager.cpp
index 9c3a641..4be860e 100644
--- a/kaddressbook/viewmanager.cpp
+++ b/kaddressbook/viewmanager.cpp
@@ -222,134 +222,133 @@ void ViewManager::setActiveView( const QString &name )
222 // Check if we found the view. If we didn't, then we need to create it 222 // Check if we found the view. If we didn't, then we need to create it
223 if ( view == 0 ) { 223 if ( view == 0 ) {
224 KConfig *config = mCore->config(); 224 KConfig *config = mCore->config();
225 225
226 KConfigGroupSaver saver( config, name ); 226 KConfigGroupSaver saver( config, name );
227 227
228 QString type = config->readEntry( "Type", "Table" ); 228 QString type = config->readEntry( "Type", "Table" );
229 229
230 kdDebug(5720) << "ViewManager::setActiveView: creating view - " << name << endl; 230 kdDebug(5720) << "ViewManager::setActiveView: creating view - " << name << endl;
231 231
232 ViewFactory *factory = mViewFactoryDict.find( type ); 232 ViewFactory *factory = mViewFactoryDict.find( type );
233 if ( factory ) 233 if ( factory )
234 view = factory->view( mCore->addressBook(), mViewWidgetStack ); 234 view = factory->view( mCore->addressBook(), mViewWidgetStack );
235 235
236 if ( view ) { 236 if ( view ) {
237 view->setCaption( name ); 237 view->setCaption( name );
238 mViewDict.insert( name, view ); 238 mViewDict.insert( name, view );
239//US my version needs an int as second parameter to addWidget 239//US my version needs an int as second parameter to addWidget
240 mViewWidgetStack->addWidget( view, -1 ); 240 mViewWidgetStack->addWidget( view, -1 );
241 view->readConfig( config ); 241 view->readConfig( config );
242 242
243 // The manager just relays the signals 243 // The manager just relays the signals
244 connect( view, SIGNAL( selected( const QString& ) ), 244 connect( view, SIGNAL( selected( const QString& ) ),
245 SIGNAL( selected( const QString & ) ) ); 245 SIGNAL( selected( const QString & ) ) );
246 connect( view, SIGNAL( executed( const QString& ) ), 246 connect( view, SIGNAL( executed( const QString& ) ),
247 SIGNAL( executed( const QString& ) ) ); 247 SIGNAL( executed( const QString& ) ) );
248 248
249 connect( view, SIGNAL( deleteRequest( ) ), 249 connect( view, SIGNAL( deleteRequest( ) ),
250 SIGNAL( deleteRequest( ) ) ); 250 SIGNAL( deleteRequest( ) ) );
251 251
252 connect( view, SIGNAL( modified() ), SIGNAL( modified() ) ); 252 connect( view, SIGNAL( modified() ), SIGNAL( modified() ) );
253 connect( view, SIGNAL( dropped( QDropEvent* ) ), 253 connect( view, SIGNAL( dropped( QDropEvent* ) ),
254 SLOT( dropped( QDropEvent* ) ) ); 254 SLOT( dropped( QDropEvent* ) ) );
255 connect( view, SIGNAL( startDrag() ), SLOT( startDrag() ) ); 255 connect( view, SIGNAL( startDrag() ), SLOT( startDrag() ) );
256 } 256 }
257 } 257 }
258 258
259 // If we found or created the view, raise it and refresh it 259 // If we found or created the view, raise it and refresh it
260 if ( view ) { 260 if ( view ) {
261 mActiveView = view; 261 mActiveView = view;
262 mViewWidgetStack->raiseWidget( view ); 262 mViewWidgetStack->raiseWidget( view );
263 // Set the proper filter in the view. By setting the combo 263 // Set the proper filter in the view. By setting the combo
264 // box, the activated slot will be called, which will push 264 // box, the activated slot will be called, which will push
265 // the filter to the view and refresh it. 265 // the filter to the view and refresh it.
266 266
267 if ( view->defaultFilterType() == KAddressBookView::None ) { 267 if ( view->defaultFilterType() == KAddressBookView::None ) {
268 268
269 mActionSelectFilter->setCurrentItem( 0 ); 269 mActionSelectFilter->setCurrentItem( 0 );
270 setActiveFilter( 0 ); 270 setActiveFilter( 0 );
271 } else if ( view->defaultFilterType() == KAddressBookView::Active ) { 271 } else if ( view->defaultFilterType() == KAddressBookView::Active ) {
272 setActiveFilter( mActionSelectFilter->currentItem() ); 272 setActiveFilter( mActionSelectFilter->currentItem() );
273 } else { 273 } else {
274 uint pos = filterPosition( view->defaultFilterName() ); 274 uint pos = filterPosition( view->defaultFilterName() );
275 mActionSelectFilter->setCurrentItem( pos ); 275 mActionSelectFilter->setCurrentItem( pos );
276 setActiveFilter( pos ); 276 setActiveFilter( pos );
277 } 277 }
278//US qDebug("ViewManager::setActiveView 6" ); 278//US qDebug("ViewManager::setActiveView 6" );
279 279
280 // Update the inc search widget to show the fields in the new active 280 // Update the inc search widget to show the fields in the new active
281 // view. 281 // view.
282 mCore->setSearchFields( mActiveView->fields() ); 282 mCore->setSearchFields( mActiveView->fields() );
283 283
284//US performance optimization. setActiveFilter calls also mActiveView->refresh() 284//US performance optimization. setActiveFilter calls also mActiveView->refresh()
285//US mActiveView->refresh(); 285//US mActiveView->refresh();
286 286 mCore->saveSettings();
287 } 287 }
288 else 288 else
289 { 289 {
290 qDebug("ViewManager::setActiveView: unable to find view" ); 290 qDebug("ViewManager::setActiveView: unable to find view" );
291 kdDebug(5720) << "ViewManager::setActiveView: unable to find view\n";
292 } 291 }
293} 292}
294 293
295//US added another method with no parameter, since my moc compiler does not support default parameters. 294//US added another method with no parameter, since my moc compiler does not support default parameters.
296void ViewManager::refreshView() 295void ViewManager::refreshView()
297{ 296{
298 refreshView( QString::null ); 297 refreshView( QString::null );
299} 298}
300 299
301void ViewManager::refreshView( const QString &uid ) 300void ViewManager::refreshView( const QString &uid )
302{ 301{
303 if ( mActiveView ) 302 if ( mActiveView )
304 mActiveView->refresh( uid ); 303 mActiveView->refresh( uid );
305} 304}
306 305
307void ViewManager::setFocusAV() 306void ViewManager::setFocusAV()
308{ 307{
309 if ( mActiveView ) 308 if ( mActiveView )
310 mActiveView->setFocusAV(); 309 mActiveView->setFocusAV();
311} 310}
312void ViewManager::editView() 311void ViewManager::editView()
313{ 312{
314 if ( !mActiveView ) 313 if ( !mActiveView )
315 return; 314 return;
316 315
317 ViewFactory *factory = mViewFactoryDict.find( mActiveView->type() ); 316 ViewFactory *factory = mViewFactoryDict.find( mActiveView->type() );
318 ViewConfigureWidget *wdg = 0; 317 ViewConfigureWidget *wdg = 0;
319 ViewConfigureDialog* dlg = 0; 318 ViewConfigureDialog* dlg = 0;
320 if ( factory ) { 319 if ( factory ) {
321 // Save the filters so the dialog has the latest set 320 // Save the filters so the dialog has the latest set
322 Filter::save( mCore->config(), "Filter", mFilterList ); 321 Filter::save( mCore->config(), "Filter", mFilterList );
323 dlg = new ViewConfigureDialog( 0, mActiveView->caption(), this, "conf_dlg" ); 322 dlg = new ViewConfigureDialog( 0, mActiveView->caption(), this, "conf_dlg" );
324 wdg = factory->configureWidget( mCore->addressBook(), dlg,"conf_wid" ); 323 wdg = factory->configureWidget( mCore->addressBook(), dlg,"conf_wid" );
325 } else { 324 } else {
326 qDebug("ViewManager::editView()::cannot find viewfactory "); 325 qDebug("ViewManager::editView()::cannot find viewfactory ");
327 return; 326 return;
328 } 327 }
329 if ( wdg ) { 328 if ( wdg ) {
330 dlg->setWidget( wdg ); 329 dlg->setWidget( wdg );
331 330
332#ifndef DESKTOP_VERSION 331#ifndef DESKTOP_VERSION
333 //dlg.setMaximumSize( 640, 480 ); 332 //dlg.setMaximumSize( 640, 480 );
334 //dlg->setGeometry( 40,40, 400, 300); 333 //dlg->setGeometry( 40,40, 400, 300);
335 dlg->showMaximized(); 334 dlg->showMaximized();
336#endif 335#endif
337 336
338 KConfigGroupSaver saver( mCore->config(), mActiveView->caption() ); 337 KConfigGroupSaver saver( mCore->config(), mActiveView->caption() );
339 338
340 dlg->restoreSettings( mCore->config() ); 339 dlg->restoreSettings( mCore->config() );
341 340
342 if ( dlg->exec() ) { 341 if ( dlg->exec() ) {
343 dlg->saveSettings( mCore->config() ); 342 dlg->saveSettings( mCore->config() );
344 mActiveView->readConfig( mCore->config() ); 343 mActiveView->readConfig( mCore->config() );
345 344
346 // Set the proper filter in the view. By setting the combo 345 // Set the proper filter in the view. By setting the combo
347 // box, the activated slot will be called, which will push 346 // box, the activated slot will be called, which will push
348 // the filter to the view and refresh it. 347 // the filter to the view and refresh it.
349 if ( mActiveView->defaultFilterType() == KAddressBookView::None ) { 348 if ( mActiveView->defaultFilterType() == KAddressBookView::None ) {
350 mActionSelectFilter->setCurrentItem( 0 ); 349 mActionSelectFilter->setCurrentItem( 0 );
351 setActiveFilter( 0 ); 350 setActiveFilter( 0 );
352 } else if ( mActiveView->defaultFilterType() == KAddressBookView::Active ) { 351 } else if ( mActiveView->defaultFilterType() == KAddressBookView::Active ) {
353 setActiveFilter( mActionSelectFilter->currentItem() ); 352 setActiveFilter( mActionSelectFilter->currentItem() );
354 } else { 353 } else {
355 uint pos = filterPosition( mActiveView->defaultFilterName() ); 354 uint pos = filterPosition( mActiveView->defaultFilterName() );