summaryrefslogtreecommitdiffabout
authorzautrix <zautrix>2004-10-09 02:22:11 (UTC)
committer zautrix <zautrix>2004-10-09 02:22:11 (UTC)
commit69af2ac56474e3a1e3e59be318caf53f5d357f94 (patch) (unidiff)
tree05e8a657c6f2526f5d1d628e93e0f16e8ffbf11e
parentc2165f4e14bc2f7ab2ef19f5c35497dde5e87a0d (diff)
downloadkdepimpi-69af2ac56474e3a1e3e59be318caf53f5d357f94.zip
kdepimpi-69af2ac56474e3a1e3e59be318caf53f5d357f94.tar.gz
kdepimpi-69af2ac56474e3a1e3e59be318caf53f5d357f94.tar.bz2
more ir fixes
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--kabc/addressbook.cpp1
-rw-r--r--kaddressbook/kabcore.cpp3
2 files changed, 2 insertions, 2 deletions
diff --git a/kabc/addressbook.cpp b/kabc/addressbook.cpp
index bf6d053..1a06956 100644
--- a/kabc/addressbook.cpp
+++ b/kabc/addressbook.cpp
@@ -222,385 +222,384 @@ bool AddressBook::ConstIterator::operator!=( const ConstIterator &it )
222 222
223AddressBook::AddressBook() 223AddressBook::AddressBook()
224{ 224{
225 init(0, "contact"); 225 init(0, "contact");
226} 226}
227 227
228AddressBook::AddressBook( const QString &config ) 228AddressBook::AddressBook( const QString &config )
229{ 229{
230 init(config, "contact"); 230 init(config, "contact");
231} 231}
232 232
233AddressBook::AddressBook( const QString &config, const QString &family ) 233AddressBook::AddressBook( const QString &config, const QString &family )
234{ 234{
235 init(config, family); 235 init(config, family);
236 236
237} 237}
238 238
239// the default family is "contact" 239// the default family is "contact"
240void AddressBook::init(const QString &config, const QString &family ) 240void AddressBook::init(const QString &config, const QString &family )
241{ 241{
242 blockLSEchange = false; 242 blockLSEchange = false;
243 d = new AddressBookData; 243 d = new AddressBookData;
244 QString fami = family; 244 QString fami = family;
245 if (config != 0) { 245 if (config != 0) {
246 if ( family == "syncContact" ) { 246 if ( family == "syncContact" ) {
247 qDebug("creating sync config "); 247 qDebug("creating sync config ");
248 fami = "contact"; 248 fami = "contact";
249 KConfig* con = new KConfig( locateLocal("config", "syncContactrc") ); 249 KConfig* con = new KConfig( locateLocal("config", "syncContactrc") );
250 con->setGroup( "General" ); 250 con->setGroup( "General" );
251 con->writeEntry( "ResourceKeys", QString("sync") ); 251 con->writeEntry( "ResourceKeys", QString("sync") );
252 con->writeEntry( "Standard", QString("sync") ); 252 con->writeEntry( "Standard", QString("sync") );
253 con->setGroup( "Resource_sync" ); 253 con->setGroup( "Resource_sync" );
254 con->writeEntry( "FileName", config ); 254 con->writeEntry( "FileName", config );
255 con->writeEntry( "FileFormat", QString("vcard") ); 255 con->writeEntry( "FileFormat", QString("vcard") );
256 con->writeEntry( "ResourceIdentifier", QString("sync") ); 256 con->writeEntry( "ResourceIdentifier", QString("sync") );
257 con->writeEntry( "ResourceName", QString("sync_res") ); 257 con->writeEntry( "ResourceName", QString("sync_res") );
258 if ( config.right(4) == ".xml" ) 258 if ( config.right(4) == ".xml" )
259 con->writeEntry( "ResourceType", QString("qtopia") ); 259 con->writeEntry( "ResourceType", QString("qtopia") );
260 else if ( config == "sharp" ) { 260 else if ( config == "sharp" ) {
261 con->writeEntry( "ResourceType", QString("sharp") ); 261 con->writeEntry( "ResourceType", QString("sharp") );
262 } else { 262 } else {
263 con->writeEntry( "ResourceType", QString("file") ); 263 con->writeEntry( "ResourceType", QString("file") );
264 } 264 }
265 //con->sync(); 265 //con->sync();
266 d->mConfig = con; 266 d->mConfig = con;
267 } 267 }
268 else 268 else
269 d->mConfig = new KConfig( locateLocal("config", config) ); 269 d->mConfig = new KConfig( locateLocal("config", config) );
270// qDebug("AddressBook::init 1 config=%s",config.latin1() ); 270// qDebug("AddressBook::init 1 config=%s",config.latin1() );
271 } 271 }
272 else { 272 else {
273 d->mConfig = 0; 273 d->mConfig = 0;
274// qDebug("AddressBook::init 1 config=0"); 274// qDebug("AddressBook::init 1 config=0");
275 } 275 }
276 276
277//US d->mErrorHandler = 0; 277//US d->mErrorHandler = 0;
278 d->mManager = new KRES::Manager<Resource>( fami, false ); 278 d->mManager = new KRES::Manager<Resource>( fami, false );
279 d->mManager->readConfig( d->mConfig ); 279 d->mManager->readConfig( d->mConfig );
280 if ( family == "syncContact" ) { 280 if ( family == "syncContact" ) {
281 KRES::Manager<Resource> *manager = d->mManager; 281 KRES::Manager<Resource> *manager = d->mManager;
282 KRES::Manager<Resource>::ActiveIterator it; 282 KRES::Manager<Resource>::ActiveIterator it;
283 for ( it = manager->activeBegin(); it != manager->activeEnd(); ++it ) { 283 for ( it = manager->activeBegin(); it != manager->activeEnd(); ++it ) {
284 (*it)->setAddressBook( this ); 284 (*it)->setAddressBook( this );
285 if ( !(*it)->open() ) 285 if ( !(*it)->open() )
286 error( QString( "Unable to open resource '%1'!" ).arg( (*it)->resourceName() ) ); 286 error( QString( "Unable to open resource '%1'!" ).arg( (*it)->resourceName() ) );
287 } 287 }
288 Resource *res = standardResource(); 288 Resource *res = standardResource();
289 if ( !res ) { 289 if ( !res ) {
290 qDebug("ERROR: no standard resource"); 290 qDebug("ERROR: no standard resource");
291 res = manager->createResource( "file" ); 291 res = manager->createResource( "file" );
292 if ( res ) 292 if ( res )
293 { 293 {
294 addResource( res ); 294 addResource( res );
295 } 295 }
296 else 296 else
297 qDebug(" No resource available!!!"); 297 qDebug(" No resource available!!!");
298 } 298 }
299 setStandardResource( res ); 299 setStandardResource( res );
300 manager->writeConfig(); 300 manager->writeConfig();
301 } 301 }
302 addCustomField( i18n( "Department" ), KABC::Field::Organization, 302 addCustomField( i18n( "Department" ), KABC::Field::Organization,
303 "X-Department", "KADDRESSBOOK" ); 303 "X-Department", "KADDRESSBOOK" );
304 addCustomField( i18n( "Profession" ), KABC::Field::Organization, 304 addCustomField( i18n( "Profession" ), KABC::Field::Organization,
305 "X-Profession", "KADDRESSBOOK" ); 305 "X-Profession", "KADDRESSBOOK" );
306 addCustomField( i18n( "Assistant's Name" ), KABC::Field::Organization, 306 addCustomField( i18n( "Assistant's Name" ), KABC::Field::Organization,
307 "X-AssistantsName", "KADDRESSBOOK" ); 307 "X-AssistantsName", "KADDRESSBOOK" );
308 addCustomField( i18n( "Manager's Name" ), KABC::Field::Organization, 308 addCustomField( i18n( "Manager's Name" ), KABC::Field::Organization,
309 "X-ManagersName", "KADDRESSBOOK" ); 309 "X-ManagersName", "KADDRESSBOOK" );
310 addCustomField( i18n( "Spouse's Name" ), KABC::Field::Personal, 310 addCustomField( i18n( "Spouse's Name" ), KABC::Field::Personal,
311 "X-SpousesName", "KADDRESSBOOK" ); 311 "X-SpousesName", "KADDRESSBOOK" );
312 addCustomField( i18n( "Office" ), KABC::Field::Personal, 312 addCustomField( i18n( "Office" ), KABC::Field::Personal,
313 "X-Office", "KADDRESSBOOK" ); 313 "X-Office", "KADDRESSBOOK" );
314 addCustomField( i18n( "IM Address" ), KABC::Field::Personal, 314 addCustomField( i18n( "IM Address" ), KABC::Field::Personal,
315 "X-IMAddress", "KADDRESSBOOK" ); 315 "X-IMAddress", "KADDRESSBOOK" );
316 addCustomField( i18n( "Anniversary" ), KABC::Field::Personal, 316 addCustomField( i18n( "Anniversary" ), KABC::Field::Personal,
317 "X-Anniversary", "KADDRESSBOOK" ); 317 "X-Anniversary", "KADDRESSBOOK" );
318 318
319 //US added this field to become compatible with Opie/qtopia addressbook 319 //US added this field to become compatible with Opie/qtopia addressbook
320 // values can be "female" or "male" or "". An empty field represents undefined. 320 // values can be "female" or "male" or "". An empty field represents undefined.
321 addCustomField( i18n( "Gender" ), KABC::Field::Personal, 321 addCustomField( i18n( "Gender" ), KABC::Field::Personal,
322 "X-Gender", "KADDRESSBOOK" ); 322 "X-Gender", "KADDRESSBOOK" );
323 addCustomField( i18n( "Children" ), KABC::Field::Personal, 323 addCustomField( i18n( "Children" ), KABC::Field::Personal,
324 "X-Children", "KADDRESSBOOK" ); 324 "X-Children", "KADDRESSBOOK" );
325 addCustomField( i18n( "FreeBusyUrl" ), KABC::Field::Personal, 325 addCustomField( i18n( "FreeBusyUrl" ), KABC::Field::Personal,
326 "X-FreeBusyUrl", "KADDRESSBOOK" ); 326 "X-FreeBusyUrl", "KADDRESSBOOK" );
327 addCustomField( i18n( "ExternalID" ), KABC::Field::Personal, 327 addCustomField( i18n( "ExternalID" ), KABC::Field::Personal,
328 "X-ExternalID", "KADDRESSBOOK" ); 328 "X-ExternalID", "KADDRESSBOOK" );
329} 329}
330 330
331AddressBook::~AddressBook() 331AddressBook::~AddressBook()
332{ 332{
333 delete d->mConfig; d->mConfig = 0; 333 delete d->mConfig; d->mConfig = 0;
334 delete d->mManager; d->mManager = 0; 334 delete d->mManager; d->mManager = 0;
335//US delete d->mErrorHandler; d->mErrorHandler = 0; 335//US delete d->mErrorHandler; d->mErrorHandler = 0;
336 delete d; d = 0; 336 delete d; d = 0;
337} 337}
338 338
339bool AddressBook::load() 339bool AddressBook::load()
340{ 340{
341 341
342 342
343 clear(); 343 clear();
344 344
345 KRES::Manager<Resource>::ActiveIterator it; 345 KRES::Manager<Resource>::ActiveIterator it;
346 bool ok = true; 346 bool ok = true;
347 for ( it = d->mManager->activeBegin(); it != d->mManager->activeEnd(); ++it ) 347 for ( it = d->mManager->activeBegin(); it != d->mManager->activeEnd(); ++it )
348 if ( !(*it)->load() ) { 348 if ( !(*it)->load() ) {
349 error( i18n("Unable to load resource '%1'").arg( (*it)->resourceName() ) ); 349 error( i18n("Unable to load resource '%1'").arg( (*it)->resourceName() ) );
350 ok = false; 350 ok = false;
351 } 351 }
352 352
353 // mark all addressees as unchanged 353 // mark all addressees as unchanged
354 Addressee::List::Iterator addrIt; 354 Addressee::List::Iterator addrIt;
355 for ( addrIt = d->mAddressees.begin(); addrIt != d->mAddressees.end(); ++addrIt ) { 355 for ( addrIt = d->mAddressees.begin(); addrIt != d->mAddressees.end(); ++addrIt ) {
356 (*addrIt).setChanged( false ); 356 (*addrIt).setChanged( false );
357 QString id = (*addrIt).custom( "KADDRESSBOOK", "X-ExternalID" ); 357 QString id = (*addrIt).custom( "KADDRESSBOOK", "X-ExternalID" );
358 if ( !id.isEmpty() ) { 358 if ( !id.isEmpty() ) {
359 //qDebug("setId aa %s ", id.latin1()); 359 //qDebug("setId aa %s ", id.latin1());
360 (*addrIt).setIDStr(id ); 360 (*addrIt).setIDStr(id );
361 } 361 }
362 } 362 }
363 blockLSEchange = true; 363 blockLSEchange = true;
364 return ok; 364 return ok;
365} 365}
366 366
367bool AddressBook::save( Ticket *ticket ) 367bool AddressBook::save( Ticket *ticket )
368{ 368{
369 kdDebug(5700) << "AddressBook::save()"<< endl; 369 kdDebug(5700) << "AddressBook::save()"<< endl;
370 370
371 if ( ticket->resource() ) { 371 if ( ticket->resource() ) {
372 deleteRemovedAddressees(); 372 deleteRemovedAddressees();
373 return ticket->resource()->save( ticket ); 373 return ticket->resource()->save( ticket );
374 } 374 }
375 375
376 return false; 376 return false;
377} 377}
378void AddressBook::export2File( QString fileName ) 378void AddressBook::export2File( QString fileName )
379{ 379{
380 380
381 QFile outFile( fileName ); 381 QFile outFile( fileName );
382 if ( !outFile.open( IO_WriteOnly ) ) { 382 if ( !outFile.open( IO_WriteOnly ) ) {
383 QString text = i18n( "<qt>Unable to open file <b>%1</b> for export.</qt>" ); 383 QString text = i18n( "<qt>Unable to open file <b>%1</b> for export.</qt>" );
384 KMessageBox::error( 0, text.arg( fileName ) ); 384 KMessageBox::error( 0, text.arg( fileName ) );
385 return ; 385 return ;
386 } 386 }
387 QTextStream t( &outFile ); 387 QTextStream t( &outFile );
388 t.setEncoding( QTextStream::UnicodeUTF8 ); 388 t.setEncoding( QTextStream::UnicodeUTF8 );
389 Iterator it; 389 Iterator it;
390 KABC::VCardConverter::Version version; 390 KABC::VCardConverter::Version version;
391 version = KABC::VCardConverter::v3_0; 391 version = KABC::VCardConverter::v3_0;
392 for ( it = begin(); it != end(); ++it ) { 392 for ( it = begin(); it != end(); ++it ) {
393 if ( !(*it).IDStr().isEmpty() ) { 393 if ( !(*it).IDStr().isEmpty() ) {
394 (*it).insertCustom( "KADDRESSBOOK", "X-ExternalID", (*it).IDStr() ); 394 (*it).insertCustom( "KADDRESSBOOK", "X-ExternalID", (*it).IDStr() );
395 } 395 }
396 KABC::VCardConverter converter; 396 KABC::VCardConverter converter;
397 QString vcard; 397 QString vcard;
398 //Resource *resource() const; 398 //Resource *resource() const;
399 converter.addresseeToVCard( *it, vcard, version ); 399 converter.addresseeToVCard( *it, vcard, version );
400 t << vcard << "\r\n"; 400 t << vcard << "\r\n";
401 } 401 }
402 t << "\r\n\r\n"; 402 t << "\r\n\r\n";
403 outFile.close(); 403 outFile.close();
404} 404}
405void AddressBook::importFromFile( QString fileName, bool replaceLabel ) 405void AddressBook::importFromFile( QString fileName, bool replaceLabel )
406{ 406{
407 407
408 KABC::Addressee::List list; 408 KABC::Addressee::List list;
409 QFile file( fileName ); 409 QFile file( fileName );
410 410
411 file.open( IO_ReadOnly ); 411 file.open( IO_ReadOnly );
412 QByteArray rawData = file.readAll(); 412 QByteArray rawData = file.readAll();
413 file.close(); 413 file.close();
414 qDebug("AddressBook::importFromFile ");
415 QString data; 414 QString data;
416 if ( replaceLabel ) { 415 if ( replaceLabel ) {
417 data = QString::fromLatin1( rawData.data(), rawData.size() + 1 ); 416 data = QString::fromLatin1( rawData.data(), rawData.size() + 1 );
418 data.replace ( QRegExp("LABEL") , "ADR" ); 417 data.replace ( QRegExp("LABEL") , "ADR" );
419 data.replace ( QRegExp("CHARSET=ISO-8859-1") , "" ); 418 data.replace ( QRegExp("CHARSET=ISO-8859-1") , "" );
420 } else 419 } else
421 data = QString::fromUtf8( rawData.data(), rawData.size() + 1 ); 420 data = QString::fromUtf8( rawData.data(), rawData.size() + 1 );
422 KABC::VCardTool tool; 421 KABC::VCardTool tool;
423 list = tool.parseVCards( data ); 422 list = tool.parseVCards( data );
424 KABC::Addressee::List::Iterator it; 423 KABC::Addressee::List::Iterator it;
425 for ( it = list.begin(); it != list.end(); ++it ) { 424 for ( it = list.begin(); it != list.end(); ++it ) {
426 (*it).setResource( 0 ); 425 (*it).setResource( 0 );
427 if ( replaceLabel ) 426 if ( replaceLabel )
428 (*it).removeVoice(); 427 (*it).removeVoice();
429 insertAddressee( (*it), false, true ); 428 insertAddressee( (*it), false, true );
430 } 429 }
431 430
432} 431}
433 432
434bool AddressBook::saveAB() 433bool AddressBook::saveAB()
435{ 434{
436 bool ok = true; 435 bool ok = true;
437 436
438 deleteRemovedAddressees(); 437 deleteRemovedAddressees();
439 Iterator ait; 438 Iterator ait;
440 for ( ait = begin(); ait != end(); ++ait ) { 439 for ( ait = begin(); ait != end(); ++ait ) {
441 if ( !(*ait).IDStr().isEmpty() ) { 440 if ( !(*ait).IDStr().isEmpty() ) {
442 (*ait).insertCustom( "KADDRESSBOOK", "X-ExternalID", (*ait).IDStr() ); 441 (*ait).insertCustom( "KADDRESSBOOK", "X-ExternalID", (*ait).IDStr() );
443 } 442 }
444 } 443 }
445 KRES::Manager<Resource>::ActiveIterator it; 444 KRES::Manager<Resource>::ActiveIterator it;
446 KRES::Manager<Resource> *manager = d->mManager; 445 KRES::Manager<Resource> *manager = d->mManager;
447 for ( it = manager->activeBegin(); it != manager->activeEnd(); ++it ) { 446 for ( it = manager->activeBegin(); it != manager->activeEnd(); ++it ) {
448 if ( !(*it)->readOnly() && (*it)->isOpen() ) { 447 if ( !(*it)->readOnly() && (*it)->isOpen() ) {
449 Ticket *ticket = requestSaveTicket( *it ); 448 Ticket *ticket = requestSaveTicket( *it );
450// qDebug("StdAddressBook::save '%s'", (*it)->resourceName().latin1() ); 449// qDebug("StdAddressBook::save '%s'", (*it)->resourceName().latin1() );
451 if ( !ticket ) { 450 if ( !ticket ) {
452 error( i18n( "Unable to save to resource '%1'. It is locked." ) 451 error( i18n( "Unable to save to resource '%1'. It is locked." )
453 .arg( (*it)->resourceName() ) ); 452 .arg( (*it)->resourceName() ) );
454 return false; 453 return false;
455 } 454 }
456 455
457 //if ( !save( ticket ) ) 456 //if ( !save( ticket ) )
458 if ( ticket->resource() ) { 457 if ( ticket->resource() ) {
459 if ( ! ticket->resource()->save( ticket ) ) 458 if ( ! ticket->resource()->save( ticket ) )
460 ok = false; 459 ok = false;
461 } else 460 } else
462 ok = false; 461 ok = false;
463 462
464 } 463 }
465 } 464 }
466 return ok; 465 return ok;
467} 466}
468 467
469AddressBook::Iterator AddressBook::begin() 468AddressBook::Iterator AddressBook::begin()
470{ 469{
471 Iterator it = Iterator(); 470 Iterator it = Iterator();
472 it.d->mIt = d->mAddressees.begin(); 471 it.d->mIt = d->mAddressees.begin();
473 return it; 472 return it;
474} 473}
475 474
476AddressBook::ConstIterator AddressBook::begin() const 475AddressBook::ConstIterator AddressBook::begin() const
477{ 476{
478 ConstIterator it = ConstIterator(); 477 ConstIterator it = ConstIterator();
479 it.d->mIt = d->mAddressees.begin(); 478 it.d->mIt = d->mAddressees.begin();
480 return it; 479 return it;
481} 480}
482 481
483AddressBook::Iterator AddressBook::end() 482AddressBook::Iterator AddressBook::end()
484{ 483{
485 Iterator it = Iterator(); 484 Iterator it = Iterator();
486 it.d->mIt = d->mAddressees.end(); 485 it.d->mIt = d->mAddressees.end();
487 return it; 486 return it;
488} 487}
489 488
490AddressBook::ConstIterator AddressBook::end() const 489AddressBook::ConstIterator AddressBook::end() const
491{ 490{
492 ConstIterator it = ConstIterator(); 491 ConstIterator it = ConstIterator();
493 it.d->mIt = d->mAddressees.end(); 492 it.d->mIt = d->mAddressees.end();
494 return it; 493 return it;
495} 494}
496 495
497void AddressBook::clear() 496void AddressBook::clear()
498{ 497{
499 d->mAddressees.clear(); 498 d->mAddressees.clear();
500} 499}
501 500
502Ticket *AddressBook::requestSaveTicket( Resource *resource ) 501Ticket *AddressBook::requestSaveTicket( Resource *resource )
503{ 502{
504 kdDebug(5700) << "AddressBook::requestSaveTicket()" << endl; 503 kdDebug(5700) << "AddressBook::requestSaveTicket()" << endl;
505 504
506 if ( !resource ) 505 if ( !resource )
507 { 506 {
508 qDebug("AddressBook::requestSaveTicket no resource" ); 507 qDebug("AddressBook::requestSaveTicket no resource" );
509 resource = standardResource(); 508 resource = standardResource();
510 } 509 }
511 510
512 KRES::Manager<Resource>::ActiveIterator it; 511 KRES::Manager<Resource>::ActiveIterator it;
513 for ( it = d->mManager->activeBegin(); it != d->mManager->activeEnd(); ++it ) { 512 for ( it = d->mManager->activeBegin(); it != d->mManager->activeEnd(); ++it ) {
514 if ( (*it) == resource ) { 513 if ( (*it) == resource ) {
515 if ( (*it)->readOnly() || !(*it)->isOpen() ) 514 if ( (*it)->readOnly() || !(*it)->isOpen() )
516 return 0; 515 return 0;
517 else 516 else
518 return (*it)->requestSaveTicket(); 517 return (*it)->requestSaveTicket();
519 } 518 }
520 } 519 }
521 520
522 return 0; 521 return 0;
523} 522}
524 523
525void AddressBook::insertAddressee( const Addressee &a, bool setRev, bool takeResource ) 524void AddressBook::insertAddressee( const Addressee &a, bool setRev, bool takeResource )
526{ 525{
527 if ( blockLSEchange && setRev && a.uid().left( 19 ) == QString("last-syncAddressee-") ) { 526 if ( blockLSEchange && setRev && a.uid().left( 19 ) == QString("last-syncAddressee-") ) {
528 //qDebug("block insert "); 527 //qDebug("block insert ");
529 return; 528 return;
530 } 529 }
531 //qDebug("inserting.... %s ",a.uid().latin1() ); 530 //qDebug("inserting.... %s ",a.uid().latin1() );
532 bool found = false; 531 bool found = false;
533 Addressee::List::Iterator it; 532 Addressee::List::Iterator it;
534 for ( it = d->mAddressees.begin(); it != d->mAddressees.end(); ++it ) { 533 for ( it = d->mAddressees.begin(); it != d->mAddressees.end(); ++it ) {
535 if ( a.uid() == (*it).uid() ) { 534 if ( a.uid() == (*it).uid() ) {
536 535
537 bool changed = false; 536 bool changed = false;
538 Addressee addr = a; 537 Addressee addr = a;
539 if ( addr != (*it) ) 538 if ( addr != (*it) )
540 changed = true; 539 changed = true;
541 540
542 if ( takeResource ) { 541 if ( takeResource ) {
543 Resource * res = (*it).resource(); 542 Resource * res = (*it).resource();
544 (*it) = a; 543 (*it) = a;
545 (*it).setResource( res ); 544 (*it).setResource( res );
546 } else { 545 } else {
547 (*it) = a; 546 (*it) = a;
548 if ( (*it).resource() == 0 ) 547 if ( (*it).resource() == 0 )
549 (*it).setResource( standardResource() ); 548 (*it).setResource( standardResource() );
550 } 549 }
551 if ( changed ) { 550 if ( changed ) {
552 if ( setRev ) { 551 if ( setRev ) {
553 552
554 // get rid of micro seconds 553 // get rid of micro seconds
555 QDateTime dt = QDateTime::currentDateTime(); 554 QDateTime dt = QDateTime::currentDateTime();
556 QTime t = dt.time(); 555 QTime t = dt.time();
557 dt.setTime( QTime (t.hour (), t.minute (), t.second () ) ); 556 dt.setTime( QTime (t.hour (), t.minute (), t.second () ) );
558 (*it).setRevision( dt ); 557 (*it).setRevision( dt );
559 } 558 }
560 (*it).setChanged( true ); 559 (*it).setChanged( true );
561 } 560 }
562 561
563 found = true; 562 found = true;
564 } else { 563 } else {
565 if ( (*it).uid().left( 19 ) == QString("last-syncAddressee-") ) { 564 if ( (*it).uid().left( 19 ) == QString("last-syncAddressee-") ) {
566 QString name = (*it).uid().mid( 19 ); 565 QString name = (*it).uid().mid( 19 );
567 Addressee b = a; 566 Addressee b = a;
568 QString id = b.getID( name ); 567 QString id = b.getID( name );
569 if ( ! id.isEmpty() ) { 568 if ( ! id.isEmpty() ) {
570 QString des = (*it).note(); 569 QString des = (*it).note();
571 int startN; 570 int startN;
572 if( (startN = des.find( id ) ) >= 0 ) { 571 if( (startN = des.find( id ) ) >= 0 ) {
573 int endN = des.find( ",", startN+1 ); 572 int endN = des.find( ",", startN+1 );
574 des = des.left( startN ) + des.mid( endN+1 ); 573 des = des.left( startN ) + des.mid( endN+1 );
575 (*it).setNote( des ); 574 (*it).setNote( des );
576 } 575 }
577 } 576 }
578 } 577 }
579 } 578 }
580 } 579 }
581 if ( found ) 580 if ( found )
582 return; 581 return;
583 d->mAddressees.append( a ); 582 d->mAddressees.append( a );
584 Addressee& addr = d->mAddressees.last(); 583 Addressee& addr = d->mAddressees.last();
585 if ( addr.resource() == 0 ) 584 if ( addr.resource() == 0 )
586 addr.setResource( standardResource() ); 585 addr.setResource( standardResource() );
587 586
588 addr.setChanged( true ); 587 addr.setChanged( true );
589} 588}
590 589
591void AddressBook::removeAddressee( const Addressee &a ) 590void AddressBook::removeAddressee( const Addressee &a )
592{ 591{
593 Iterator it; 592 Iterator it;
594 Iterator it2; 593 Iterator it2;
595 bool found = false; 594 bool found = false;
596 for ( it = begin(); it != end(); ++it ) { 595 for ( it = begin(); it != end(); ++it ) {
597 if ( a.uid() == (*it).uid() ) { 596 if ( a.uid() == (*it).uid() ) {
598 found = true; 597 found = true;
599 it2 = it; 598 it2 = it;
600 } else { 599 } else {
601 if ( (*it).uid().left( 19 ) == QString("last-syncAddressee-") ) { 600 if ( (*it).uid().left( 19 ) == QString("last-syncAddressee-") ) {
602 QString name = (*it).uid().mid( 19 ); 601 QString name = (*it).uid().mid( 19 );
603 Addressee b = a; 602 Addressee b = a;
604 QString id = b.getID( name ); 603 QString id = b.getID( name );
605 if ( ! id.isEmpty() ) { 604 if ( ! id.isEmpty() ) {
606 QString des = (*it).note(); 605 QString des = (*it).note();
diff --git a/kaddressbook/kabcore.cpp b/kaddressbook/kabcore.cpp
index 3a542ba..efcd492 100644
--- a/kaddressbook/kabcore.cpp
+++ b/kaddressbook/kabcore.cpp
@@ -138,386 +138,387 @@ $Id$
138 138
139#include "addresseeutil.h" 139#include "addresseeutil.h"
140#include "undocmds.h" 140#include "undocmds.h"
141#include "addresseeeditordialog.h" 141#include "addresseeeditordialog.h"
142#include "viewmanager.h" 142#include "viewmanager.h"
143#include "details/detailsviewcontainer.h" 143#include "details/detailsviewcontainer.h"
144#include "kabprefs.h" 144#include "kabprefs.h"
145#include "xxportmanager.h" 145#include "xxportmanager.h"
146#include "incsearchwidget.h" 146#include "incsearchwidget.h"
147#include "jumpbuttonbar.h" 147#include "jumpbuttonbar.h"
148#include "extensionmanager.h" 148#include "extensionmanager.h"
149#include "addresseeconfig.h" 149#include "addresseeconfig.h"
150#include <kcmultidialog.h> 150#include <kcmultidialog.h>
151 151
152#ifdef _WIN32_ 152#ifdef _WIN32_
153 153
154#include "kaimportoldialog.h" 154#include "kaimportoldialog.h"
155#else 155#else
156#include <unistd.h> 156#include <unistd.h>
157#endif 157#endif
158// sync includes 158// sync includes
159#include <libkdepim/ksyncprofile.h> 159#include <libkdepim/ksyncprofile.h>
160#include <libkdepim/ksyncprefsdialog.h> 160#include <libkdepim/ksyncprefsdialog.h>
161 161
162class KAex2phonePrefs : public QDialog 162class KAex2phonePrefs : public QDialog
163{ 163{
164 public: 164 public:
165 KAex2phonePrefs( QWidget *parent=0, const char *name=0 ) : 165 KAex2phonePrefs( QWidget *parent=0, const char *name=0 ) :
166 QDialog( parent, name, true ) 166 QDialog( parent, name, true )
167 { 167 {
168 setCaption( i18n("Export to phone options") ); 168 setCaption( i18n("Export to phone options") );
169 QVBoxLayout* lay = new QVBoxLayout( this ); 169 QVBoxLayout* lay = new QVBoxLayout( this );
170 lay->setSpacing( 3 ); 170 lay->setSpacing( 3 );
171 lay->setMargin( 3 ); 171 lay->setMargin( 3 );
172 QLabel *lab; 172 QLabel *lab;
173 lay->addWidget(lab = new QLabel( i18n("Please read Help-Sync Howto\nto know what settings to use."), this ) ); 173 lay->addWidget(lab = new QLabel( i18n("Please read Help-Sync Howto\nto know what settings to use."), this ) );
174 lab->setAlignment (AlignHCenter ); 174 lab->setAlignment (AlignHCenter );
175 QHBox* temphb; 175 QHBox* temphb;
176 temphb = new QHBox( this ); 176 temphb = new QHBox( this );
177 new QLabel( i18n("I/O device: "), temphb ); 177 new QLabel( i18n("I/O device: "), temphb );
178 mPhoneDevice = new QLineEdit( temphb); 178 mPhoneDevice = new QLineEdit( temphb);
179 lay->addWidget( temphb ); 179 lay->addWidget( temphb );
180 temphb = new QHBox( this ); 180 temphb = new QHBox( this );
181 new QLabel( i18n("Connection: "), temphb ); 181 new QLabel( i18n("Connection: "), temphb );
182 mPhoneConnection = new QLineEdit( temphb); 182 mPhoneConnection = new QLineEdit( temphb);
183 lay->addWidget( temphb ); 183 lay->addWidget( temphb );
184 temphb = new QHBox( this ); 184 temphb = new QHBox( this );
185 new QLabel( i18n("Model(opt.): "), temphb ); 185 new QLabel( i18n("Model(opt.): "), temphb );
186 mPhoneModel = new QLineEdit( temphb); 186 mPhoneModel = new QLineEdit( temphb);
187 lay->addWidget( temphb ); 187 lay->addWidget( temphb );
188 mWriteToSim= new QCheckBox( i18n("Write Contacts to SIM card\n(if not, write to phone memory)"), this ); 188 mWriteToSim= new QCheckBox( i18n("Write Contacts to SIM card\n(if not, write to phone memory)"), this );
189 lay->addWidget( mWriteToSim ); 189 lay->addWidget( mWriteToSim );
190 lay->addWidget(lab = new QLabel( i18n("NOTE: This will remove all old\ncontact data on phone!"), this ) ); 190 lay->addWidget(lab = new QLabel( i18n("NOTE: This will remove all old\ncontact data on phone!"), this ) );
191 lab->setAlignment (AlignHCenter ); 191 lab->setAlignment (AlignHCenter );
192 QPushButton * ok = new QPushButton( i18n("Export to mobile phone!"), this ); 192 QPushButton * ok = new QPushButton( i18n("Export to mobile phone!"), this );
193 lay->addWidget( ok ); 193 lay->addWidget( ok );
194 QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); 194 QPushButton * cancel = new QPushButton( i18n("Cancel"), this );
195 lay->addWidget( cancel ); 195 lay->addWidget( cancel );
196 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); 196 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) );
197 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); 197 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) );
198 resize( 220, 240 ); 198 resize( 220, 240 );
199 199
200 } 200 }
201 201
202public: 202public:
203 QLineEdit* mPhoneConnection, *mPhoneDevice, *mPhoneModel; 203 QLineEdit* mPhoneConnection, *mPhoneDevice, *mPhoneModel;
204 QCheckBox* mWriteToSim; 204 QCheckBox* mWriteToSim;
205}; 205};
206 206
207bool pasteWithNewUid = true; 207bool pasteWithNewUid = true;
208 208
209#ifdef KAB_EMBEDDED 209#ifdef KAB_EMBEDDED
210KABCore::KABCore( KAddressBookMain *client, bool readWrite, QWidget *parent, const char *name ) 210KABCore::KABCore( KAddressBookMain *client, bool readWrite, QWidget *parent, const char *name )
211 : QWidget( parent, name ), KSyncInterface(), mGUIClient( client ), mViewManager( 0 ), 211 : QWidget( parent, name ), KSyncInterface(), mGUIClient( client ), mViewManager( 0 ),
212 mExtensionManager( 0 ),mConfigureDialog( 0 ),/*US mLdapSearchDialog( 0 ),*/ 212 mExtensionManager( 0 ),mConfigureDialog( 0 ),/*US mLdapSearchDialog( 0 ),*/
213 mReadWrite( readWrite ), mModified( false ), mMainWindow(client) 213 mReadWrite( readWrite ), mModified( false ), mMainWindow(client)
214#else //KAB_EMBEDDED 214#else //KAB_EMBEDDED
215KABCore::KABCore( KXMLGUIClient *client, bool readWrite, QWidget *parent, const char *name ) 215KABCore::KABCore( KXMLGUIClient *client, bool readWrite, QWidget *parent, const char *name )
216 : QWidget( parent, name ), KSyncInterface(), mGUIClient( client ), mViewManager( 0 ), 216 : QWidget( parent, name ), KSyncInterface(), mGUIClient( client ), mViewManager( 0 ),
217 mExtensionManager( 0 ), mConfigureDialog( 0 ), mLdapSearchDialog( 0 ), 217 mExtensionManager( 0 ), mConfigureDialog( 0 ), mLdapSearchDialog( 0 ),
218 mReadWrite( readWrite ), mModified( false ) 218 mReadWrite( readWrite ), mModified( false )
219#endif //KAB_EMBEDDED 219#endif //KAB_EMBEDDED
220{ 220{
221 // syncManager = new KSyncManager((QWidget*)this, (KSyncInterface*)this, KSyncManager::KAPI, KABPrefs::instance(), syncMenu); 221 // syncManager = new KSyncManager((QWidget*)this, (KSyncInterface*)this, KSyncManager::KAPI, KABPrefs::instance(), syncMenu);
222 // syncManager->setBlockSave(false); 222 // syncManager->setBlockSave(false);
223 mExtensionBarSplitter = 0; 223 mExtensionBarSplitter = 0;
224 mIsPart = !parent->inherits( "KAddressBookMain" ); 224 mIsPart = !parent->inherits( "KAddressBookMain" );
225 225
226 mAddressBook = KABC::StdAddressBook::self(); 226 mAddressBook = KABC::StdAddressBook::self();
227 KABC::StdAddressBook::setAutomaticSave( false ); 227 KABC::StdAddressBook::setAutomaticSave( false );
228 228
229#ifndef KAB_EMBEDDED 229#ifndef KAB_EMBEDDED
230 mAddressBook->setErrorHandler( new KABC::GUIErrorHandler ); 230 mAddressBook->setErrorHandler( new KABC::GUIErrorHandler );
231#endif //KAB_EMBEDDED 231#endif //KAB_EMBEDDED
232 232
233 connect( mAddressBook, SIGNAL( addressBookChanged( AddressBook * ) ), 233 connect( mAddressBook, SIGNAL( addressBookChanged( AddressBook * ) ),
234 SLOT( addressBookChanged() ) ); 234 SLOT( addressBookChanged() ) );
235 235
236#if 0 236#if 0
237 // LP moved to addressbook init method 237 // LP moved to addressbook init method
238 mAddressBook->addCustomField( i18n( "Department" ), KABC::Field::Organization, 238 mAddressBook->addCustomField( i18n( "Department" ), KABC::Field::Organization,
239 "X-Department", "KADDRESSBOOK" ); 239 "X-Department", "KADDRESSBOOK" );
240 mAddressBook->addCustomField( i18n( "Profession" ), KABC::Field::Organization, 240 mAddressBook->addCustomField( i18n( "Profession" ), KABC::Field::Organization,
241 "X-Profession", "KADDRESSBOOK" ); 241 "X-Profession", "KADDRESSBOOK" );
242 mAddressBook->addCustomField( i18n( "Assistant's Name" ), KABC::Field::Organization, 242 mAddressBook->addCustomField( i18n( "Assistant's Name" ), KABC::Field::Organization,
243 "X-AssistantsName", "KADDRESSBOOK" ); 243 "X-AssistantsName", "KADDRESSBOOK" );
244 mAddressBook->addCustomField( i18n( "Manager's Name" ), KABC::Field::Organization, 244 mAddressBook->addCustomField( i18n( "Manager's Name" ), KABC::Field::Organization,
245 "X-ManagersName", "KADDRESSBOOK" ); 245 "X-ManagersName", "KADDRESSBOOK" );
246 mAddressBook->addCustomField( i18n( "Spouse's Name" ), KABC::Field::Personal, 246 mAddressBook->addCustomField( i18n( "Spouse's Name" ), KABC::Field::Personal,
247 "X-SpousesName", "KADDRESSBOOK" ); 247 "X-SpousesName", "KADDRESSBOOK" );
248 mAddressBook->addCustomField( i18n( "Office" ), KABC::Field::Personal, 248 mAddressBook->addCustomField( i18n( "Office" ), KABC::Field::Personal,
249 "X-Office", "KADDRESSBOOK" ); 249 "X-Office", "KADDRESSBOOK" );
250 mAddressBook->addCustomField( i18n( "IM Address" ), KABC::Field::Personal, 250 mAddressBook->addCustomField( i18n( "IM Address" ), KABC::Field::Personal,
251 "X-IMAddress", "KADDRESSBOOK" ); 251 "X-IMAddress", "KADDRESSBOOK" );
252 mAddressBook->addCustomField( i18n( "Anniversary" ), KABC::Field::Personal, 252 mAddressBook->addCustomField( i18n( "Anniversary" ), KABC::Field::Personal,
253 "X-Anniversary", "KADDRESSBOOK" ); 253 "X-Anniversary", "KADDRESSBOOK" );
254 254
255 //US added this field to become compatible with Opie/qtopia addressbook 255 //US added this field to become compatible with Opie/qtopia addressbook
256 // values can be "female" or "male" or "". An empty field represents undefined. 256 // values can be "female" or "male" or "". An empty field represents undefined.
257 mAddressBook->addCustomField( i18n( "Gender" ), KABC::Field::Personal, 257 mAddressBook->addCustomField( i18n( "Gender" ), KABC::Field::Personal,
258 "X-Gender", "KADDRESSBOOK" ); 258 "X-Gender", "KADDRESSBOOK" );
259 mAddressBook->addCustomField( i18n( "Children" ), KABC::Field::Personal, 259 mAddressBook->addCustomField( i18n( "Children" ), KABC::Field::Personal,
260 "X-Children", "KADDRESSBOOK" ); 260 "X-Children", "KADDRESSBOOK" );
261 mAddressBook->addCustomField( i18n( "FreeBusyUrl" ), KABC::Field::Personal, 261 mAddressBook->addCustomField( i18n( "FreeBusyUrl" ), KABC::Field::Personal,
262 "X-FreeBusyUrl", "KADDRESSBOOK" ); 262 "X-FreeBusyUrl", "KADDRESSBOOK" );
263#endif 263#endif
264 initGUI(); 264 initGUI();
265 265
266 mIncSearchWidget->setFocus(); 266 mIncSearchWidget->setFocus();
267 267
268 268
269 connect( mViewManager, SIGNAL( selected( const QString& ) ), 269 connect( mViewManager, SIGNAL( selected( const QString& ) ),
270 SLOT( setContactSelected( const QString& ) ) ); 270 SLOT( setContactSelected( const QString& ) ) );
271 connect( mViewManager, SIGNAL( executed( const QString& ) ), 271 connect( mViewManager, SIGNAL( executed( const QString& ) ),
272 SLOT( executeContact( const QString& ) ) ); 272 SLOT( executeContact( const QString& ) ) );
273 273
274 connect( mViewManager, SIGNAL( deleteRequest( ) ), 274 connect( mViewManager, SIGNAL( deleteRequest( ) ),
275 SLOT( deleteContacts( ) ) ); 275 SLOT( deleteContacts( ) ) );
276 connect( mViewManager, SIGNAL( modified() ), 276 connect( mViewManager, SIGNAL( modified() ),
277 SLOT( setModified() ) ); 277 SLOT( setModified() ) );
278 278
279 connect( mExtensionManager, SIGNAL( modified( const KABC::Addressee::List& ) ), this, SLOT( extensionModified( const KABC::Addressee::List& ) ) ); 279 connect( mExtensionManager, SIGNAL( modified( const KABC::Addressee::List& ) ), this, SLOT( extensionModified( const KABC::Addressee::List& ) ) );
280 connect( mExtensionManager, SIGNAL( changedActiveExtension( int ) ), this, SLOT( extensionChanged( int ) ) ); 280 connect( mExtensionManager, SIGNAL( changedActiveExtension( int ) ), this, SLOT( extensionChanged( int ) ) );
281 281
282 connect( mXXPortManager, SIGNAL( modified() ), 282 connect( mXXPortManager, SIGNAL( modified() ),
283 SLOT( setModified() ) ); 283 SLOT( setModified() ) );
284 284
285 connect( mJumpButtonBar, SIGNAL( jumpToLetter( const QString& ) ), 285 connect( mJumpButtonBar, SIGNAL( jumpToLetter( const QString& ) ),
286 SLOT( incrementalSearch( const QString& ) ) ); 286 SLOT( incrementalSearch( const QString& ) ) );
287 connect( mIncSearchWidget, SIGNAL( fieldChanged() ), 287 connect( mIncSearchWidget, SIGNAL( fieldChanged() ),
288 mJumpButtonBar, SLOT( recreateButtons() ) ); 288 mJumpButtonBar, SLOT( recreateButtons() ) );
289 289
290 connect( mDetails, SIGNAL( sendEmail( const QString& ) ), 290 connect( mDetails, SIGNAL( sendEmail( const QString& ) ),
291 SLOT( sendMail( const QString& ) ) ); 291 SLOT( sendMail( const QString& ) ) );
292 292
293 293
294 connect( ExternalAppHandler::instance(), SIGNAL (requestForNameEmailUidList(const QString&, const QString&)),this, SLOT(requestForNameEmailUidList(const QString&, const QString&))); 294 connect( ExternalAppHandler::instance(), SIGNAL (requestForNameEmailUidList(const QString&, const QString&)),this, SLOT(requestForNameEmailUidList(const QString&, const QString&)));
295 connect( ExternalAppHandler::instance(), SIGNAL (requestForDetails(const QString&, const QString&, const QString&, const QString&, const QString&)),this, SLOT(requestForDetails(const QString&, const QString&, const QString&, const QString&, const QString&))); 295 connect( ExternalAppHandler::instance(), SIGNAL (requestForDetails(const QString&, const QString&, const QString&, const QString&, const QString&)),this, SLOT(requestForDetails(const QString&, const QString&, const QString&, const QString&, const QString&)));
296 connect( ExternalAppHandler::instance(), SIGNAL (requestForBirthdayList(const QString&, const QString&)),this, SLOT(requestForBirthdayList(const QString&, const QString&))); 296 connect( ExternalAppHandler::instance(), SIGNAL (requestForBirthdayList(const QString&, const QString&)),this, SLOT(requestForBirthdayList(const QString&, const QString&)));
297 297
298 298
299#ifndef KAB_EMBEDDED 299#ifndef KAB_EMBEDDED
300 connect( mViewManager, SIGNAL( urlDropped( const KURL& ) ), 300 connect( mViewManager, SIGNAL( urlDropped( const KURL& ) ),
301 mXXPortManager, SLOT( importVCard( const KURL& ) ) ); 301 mXXPortManager, SLOT( importVCard( const KURL& ) ) );
302 302
303 connect( mDetails, SIGNAL( browse( const QString& ) ), 303 connect( mDetails, SIGNAL( browse( const QString& ) ),
304 SLOT( browse( const QString& ) ) ); 304 SLOT( browse( const QString& ) ) );
305 305
306 306
307 mAddressBookService = new KAddressBookService( this ); 307 mAddressBookService = new KAddressBookService( this );
308 308
309#endif //KAB_EMBEDDED 309#endif //KAB_EMBEDDED
310 mEditorDialog = 0; 310 mEditorDialog = 0;
311 createAddresseeEditorDialog( this ); 311 createAddresseeEditorDialog( this );
312 setModified( false ); 312 setModified( false );
313} 313}
314 314
315KABCore::~KABCore() 315KABCore::~KABCore()
316{ 316{
317 // save(); 317 // save();
318 //saveSettings(); 318 //saveSettings();
319 //KABPrefs::instance()->writeConfig(); 319 //KABPrefs::instance()->writeConfig();
320 delete AddresseeConfig::instance(); 320 delete AddresseeConfig::instance();
321 mAddressBook = 0; 321 mAddressBook = 0;
322 KABC::StdAddressBook::close(); 322 KABC::StdAddressBook::close();
323 323
324 delete syncManager; 324 delete syncManager;
325 325
326} 326}
327 327
328void KABCore::recieve( QString fn ) 328void KABCore::recieve( QString fn )
329{ 329{
330 qDebug("KABCore::recieve "); 330 //qDebug("KABCore::recieve ");
331 mAddressBook->importFromFile( fn, true ); 331 mAddressBook->importFromFile( fn, true );
332 mViewManager->refreshView();
332 topLevelWidget()->raise(); 333 topLevelWidget()->raise();
333} 334}
334void KABCore::restoreSettings() 335void KABCore::restoreSettings()
335{ 336{
336 mMultipleViewsAtOnce = KABPrefs::instance()->mMultipleViewsAtOnce; 337 mMultipleViewsAtOnce = KABPrefs::instance()->mMultipleViewsAtOnce;
337 338
338 bool state; 339 bool state;
339 340
340 if (mMultipleViewsAtOnce) 341 if (mMultipleViewsAtOnce)
341 state = KABPrefs::instance()->mDetailsPageVisible; 342 state = KABPrefs::instance()->mDetailsPageVisible;
342 else 343 else
343 state = false; 344 state = false;
344 345
345 mActionDetails->setChecked( state ); 346 mActionDetails->setChecked( state );
346 setDetailsVisible( state ); 347 setDetailsVisible( state );
347 348
348 state = KABPrefs::instance()->mJumpButtonBarVisible; 349 state = KABPrefs::instance()->mJumpButtonBarVisible;
349 350
350 mActionJumpBar->setChecked( state ); 351 mActionJumpBar->setChecked( state );
351 setJumpButtonBarVisible( state ); 352 setJumpButtonBarVisible( state );
352/*US 353/*US
353 QValueList<int> splitterSize = KABPrefs::instance()->mDetailsSplitter; 354 QValueList<int> splitterSize = KABPrefs::instance()->mDetailsSplitter;
354 if ( splitterSize.count() == 0 ) { 355 if ( splitterSize.count() == 0 ) {
355 splitterSize.append( width() / 2 ); 356 splitterSize.append( width() / 2 );
356 splitterSize.append( width() / 2 ); 357 splitterSize.append( width() / 2 );
357 } 358 }
358 mMiniSplitter->setSizes( splitterSize ); 359 mMiniSplitter->setSizes( splitterSize );
359 if ( mExtensionBarSplitter ) { 360 if ( mExtensionBarSplitter ) {
360 splitterSize = KABPrefs::instance()->mExtensionsSplitter; 361 splitterSize = KABPrefs::instance()->mExtensionsSplitter;
361 if ( splitterSize.count() == 0 ) { 362 if ( splitterSize.count() == 0 ) {
362 splitterSize.append( width() / 2 ); 363 splitterSize.append( width() / 2 );
363 splitterSize.append( width() / 2 ); 364 splitterSize.append( width() / 2 );
364 } 365 }
365 mExtensionBarSplitter->setSizes( splitterSize ); 366 mExtensionBarSplitter->setSizes( splitterSize );
366 367
367 } 368 }
368*/ 369*/
369 mViewManager->restoreSettings(); 370 mViewManager->restoreSettings();
370 mIncSearchWidget->setCurrentItem( KABPrefs::instance()->mCurrentIncSearchField ); 371 mIncSearchWidget->setCurrentItem( KABPrefs::instance()->mCurrentIncSearchField );
371 mExtensionManager->restoreSettings(); 372 mExtensionManager->restoreSettings();
372#ifdef DESKTOP_VERSION 373#ifdef DESKTOP_VERSION
373 int wid = width(); 374 int wid = width();
374 if ( wid < 10 ) 375 if ( wid < 10 )
375 wid = 400; 376 wid = 400;
376#else 377#else
377 int wid = QApplication::desktop()->width(); 378 int wid = QApplication::desktop()->width();
378 if ( wid < 640 ) 379 if ( wid < 640 )
379 wid = QApplication::desktop()->height(); 380 wid = QApplication::desktop()->height();
380#endif 381#endif
381 QValueList<int> splitterSize;// = KABPrefs::instance()->mDetailsSplitter; 382 QValueList<int> splitterSize;// = KABPrefs::instance()->mDetailsSplitter;
382 if ( true /*splitterSize.count() == 0*/ ) { 383 if ( true /*splitterSize.count() == 0*/ ) {
383 splitterSize.append( wid / 2 ); 384 splitterSize.append( wid / 2 );
384 splitterSize.append( wid / 2 ); 385 splitterSize.append( wid / 2 );
385 } 386 }
386 mMiniSplitter->setSizes( splitterSize ); 387 mMiniSplitter->setSizes( splitterSize );
387 if ( mExtensionBarSplitter ) { 388 if ( mExtensionBarSplitter ) {
388 //splitterSize = KABPrefs::instance()->mExtensionsSplitter; 389 //splitterSize = KABPrefs::instance()->mExtensionsSplitter;
389 if ( true /*splitterSize.count() == 0*/ ) { 390 if ( true /*splitterSize.count() == 0*/ ) {
390 splitterSize.append( wid / 2 ); 391 splitterSize.append( wid / 2 );
391 splitterSize.append( wid / 2 ); 392 splitterSize.append( wid / 2 );
392 } 393 }
393 mExtensionBarSplitter->setSizes( splitterSize ); 394 mExtensionBarSplitter->setSizes( splitterSize );
394 395
395 } 396 }
396 397
397 398
398} 399}
399 400
400void KABCore::saveSettings() 401void KABCore::saveSettings()
401{ 402{
402 KABPrefs::instance()->mJumpButtonBarVisible = mActionJumpBar->isChecked(); 403 KABPrefs::instance()->mJumpButtonBarVisible = mActionJumpBar->isChecked();
403 if ( mExtensionBarSplitter ) 404 if ( mExtensionBarSplitter )
404 KABPrefs::instance()->mExtensionsSplitter = mExtensionBarSplitter->sizes(); 405 KABPrefs::instance()->mExtensionsSplitter = mExtensionBarSplitter->sizes();
405 KABPrefs::instance()->mDetailsPageVisible = mActionDetails->isChecked(); 406 KABPrefs::instance()->mDetailsPageVisible = mActionDetails->isChecked();
406 KABPrefs::instance()->mDetailsSplitter = mMiniSplitter->sizes(); 407 KABPrefs::instance()->mDetailsSplitter = mMiniSplitter->sizes();
407#ifndef KAB_EMBEDDED 408#ifndef KAB_EMBEDDED
408 409
409 KABPrefs::instance()->mExtensionsSplitter = mExtensionBarSplitter->sizes(); 410 KABPrefs::instance()->mExtensionsSplitter = mExtensionBarSplitter->sizes();
410 KABPrefs::instance()->mDetailsSplitter = mDetailsSplitter->sizes(); 411 KABPrefs::instance()->mDetailsSplitter = mDetailsSplitter->sizes();
411#endif //KAB_EMBEDDED 412#endif //KAB_EMBEDDED
412 mExtensionManager->saveSettings(); 413 mExtensionManager->saveSettings();
413 mViewManager->saveSettings(); 414 mViewManager->saveSettings();
414 415
415 KABPrefs::instance()->mCurrentIncSearchField = mIncSearchWidget->currentItem(); 416 KABPrefs::instance()->mCurrentIncSearchField = mIncSearchWidget->currentItem();
416} 417}
417 418
418KABC::AddressBook *KABCore::addressBook() const 419KABC::AddressBook *KABCore::addressBook() const
419{ 420{
420 return mAddressBook; 421 return mAddressBook;
421} 422}
422 423
423KConfig *KABCore::config() 424KConfig *KABCore::config()
424{ 425{
425#ifndef KAB_EMBEDDED 426#ifndef KAB_EMBEDDED
426 return KABPrefs::instance()->config(); 427 return KABPrefs::instance()->config();
427#else //KAB_EMBEDDED 428#else //KAB_EMBEDDED
428 return KABPrefs::instance()->getConfig(); 429 return KABPrefs::instance()->getConfig();
429#endif //KAB_EMBEDDED 430#endif //KAB_EMBEDDED
430} 431}
431 432
432KActionCollection *KABCore::actionCollection() const 433KActionCollection *KABCore::actionCollection() const
433{ 434{
434 return mGUIClient->actionCollection(); 435 return mGUIClient->actionCollection();
435} 436}
436 437
437KABC::Field *KABCore::currentSearchField() const 438KABC::Field *KABCore::currentSearchField() const
438{ 439{
439 if (mIncSearchWidget) 440 if (mIncSearchWidget)
440 return mIncSearchWidget->currentField(); 441 return mIncSearchWidget->currentField();
441 else 442 else
442 return 0; 443 return 0;
443} 444}
444 445
445QStringList KABCore::selectedUIDs() const 446QStringList KABCore::selectedUIDs() const
446{ 447{
447 return mViewManager->selectedUids(); 448 return mViewManager->selectedUids();
448} 449}
449 450
450KABC::Resource *KABCore::requestResource( QWidget *parent ) 451KABC::Resource *KABCore::requestResource( QWidget *parent )
451{ 452{
452 QPtrList<KABC::Resource> kabcResources = addressBook()->resources(); 453 QPtrList<KABC::Resource> kabcResources = addressBook()->resources();
453 454
454 QPtrList<KRES::Resource> kresResources; 455 QPtrList<KRES::Resource> kresResources;
455 QPtrListIterator<KABC::Resource> resIt( kabcResources ); 456 QPtrListIterator<KABC::Resource> resIt( kabcResources );
456 KABC::Resource *resource; 457 KABC::Resource *resource;
457 while ( ( resource = resIt.current() ) != 0 ) { 458 while ( ( resource = resIt.current() ) != 0 ) {
458 ++resIt; 459 ++resIt;
459 if ( !resource->readOnly() ) { 460 if ( !resource->readOnly() ) {
460 KRES::Resource *res = static_cast<KRES::Resource*>( resource ); 461 KRES::Resource *res = static_cast<KRES::Resource*>( resource );
461 if ( res ) 462 if ( res )
462 kresResources.append( res ); 463 kresResources.append( res );
463 } 464 }
464 } 465 }
465 466
466 KRES::Resource *res = KRES::SelectDialog::getResource( kresResources, parent ); 467 KRES::Resource *res = KRES::SelectDialog::getResource( kresResources, parent );
467 return static_cast<KABC::Resource*>( res ); 468 return static_cast<KABC::Resource*>( res );
468} 469}
469 470
470#ifndef KAB_EMBEDDED 471#ifndef KAB_EMBEDDED
471KAboutData *KABCore::createAboutData() 472KAboutData *KABCore::createAboutData()
472#else //KAB_EMBEDDED 473#else //KAB_EMBEDDED
473void KABCore::createAboutData() 474void KABCore::createAboutData()
474#endif //KAB_EMBEDDED 475#endif //KAB_EMBEDDED
475{ 476{
476#ifndef KAB_EMBEDDED 477#ifndef KAB_EMBEDDED
477 KAboutData *about = new KAboutData( "kaddressbook", I18N_NOOP( "KAddressBook" ), 478 KAboutData *about = new KAboutData( "kaddressbook", I18N_NOOP( "KAddressBook" ),
478 "3.1", I18N_NOOP( "The KDE Address Book" ), 479 "3.1", I18N_NOOP( "The KDE Address Book" ),
479 KAboutData::License_GPL_V2, 480 KAboutData::License_GPL_V2,
480 I18N_NOOP( "(c) 1997-2003, The KDE PIM Team" ) ); 481 I18N_NOOP( "(c) 1997-2003, The KDE PIM Team" ) );
481 about->addAuthor( "Tobias Koenig", I18N_NOOP( "Current maintainer " ), "tokoe@kde.org" ); 482 about->addAuthor( "Tobias Koenig", I18N_NOOP( "Current maintainer " ), "tokoe@kde.org" );
482 about->addAuthor( "Don Sanders", I18N_NOOP( "Original author " ) ); 483 about->addAuthor( "Don Sanders", I18N_NOOP( "Original author " ) );
483 about->addAuthor( "Cornelius Schumacher", 484 about->addAuthor( "Cornelius Schumacher",
484 I18N_NOOP( "Co-maintainer, libkabc port, CSV import/export " ), 485 I18N_NOOP( "Co-maintainer, libkabc port, CSV import/export " ),
485 "schumacher@kde.org" ); 486 "schumacher@kde.org" );
486 about->addAuthor( "Mike Pilone", I18N_NOOP( "GUI and framework redesign " ), 487 about->addAuthor( "Mike Pilone", I18N_NOOP( "GUI and framework redesign " ),
487 "mpilone@slac.com" ); 488 "mpilone@slac.com" );
488 about->addAuthor( "Greg Stern", I18N_NOOP( "DCOP interface" ) ); 489 about->addAuthor( "Greg Stern", I18N_NOOP( "DCOP interface" ) );
489 about->addAuthor( "Mark Westcott", I18N_NOOP( "Contact pinning" ) ); 490 about->addAuthor( "Mark Westcott", I18N_NOOP( "Contact pinning" ) );
490 about->addAuthor( "Michel Boyer de la Giroday", I18N_NOOP( "LDAP Lookup\n" ), 491 about->addAuthor( "Michel Boyer de la Giroday", I18N_NOOP( "LDAP Lookup\n" ),
491 "michel@klaralvdalens-datakonsult.se" ); 492 "michel@klaralvdalens-datakonsult.se" );
492 about->addAuthor( "Steffen Hansen", I18N_NOOP( "LDAP Lookup " ), 493 about->addAuthor( "Steffen Hansen", I18N_NOOP( "LDAP Lookup " ),
493 "hansen@kde.org" ); 494 "hansen@kde.org" );
494 495
495 return about; 496 return about;
496#endif //KAB_EMBEDDED 497#endif //KAB_EMBEDDED
497 498
498 QString version; 499 QString version;
499#include <../version> 500#include <../version>
500 QMessageBox::about( this, "About KAddressbook/Pi", 501 QMessageBox::about( this, "About KAddressbook/Pi",
501 "KAddressbook/Platform-independent\n" 502 "KAddressbook/Platform-independent\n"
502 "(KA/Pi) " +version + " - " + 503 "(KA/Pi) " +version + " - " +
503#ifdef DESKTOP_VERSION 504#ifdef DESKTOP_VERSION
504 "Desktop Edition\n" 505 "Desktop Edition\n"
505#else 506#else
506 "PDA-Edition\n" 507 "PDA-Edition\n"
507 "for: Zaurus 5500 / 7x0 / 8x0\n" 508 "for: Zaurus 5500 / 7x0 / 8x0\n"
508#endif 509#endif
509 510
510 "(c) 2004 Ulf Schenk\n" 511 "(c) 2004 Ulf Schenk\n"
511 "(c) 2004 Lutz Rogowski\n" 512 "(c) 2004 Lutz Rogowski\n"
512 "(c) 1997-2003, The KDE PIM Team\n" 513 "(c) 1997-2003, The KDE PIM Team\n"
513 "Tobias Koenig Current maintainer\ntokoe@kde.org\n" 514 "Tobias Koenig Current maintainer\ntokoe@kde.org\n"
514 "Don Sanders Original author\n" 515 "Don Sanders Original author\n"
515 "Cornelius Schumacher Co-maintainer\nschumacher@kde.org\n" 516 "Cornelius Schumacher Co-maintainer\nschumacher@kde.org\n"
516 "Mike Pilone GUI and framework redesign\nmpilone@slac.com\n" 517 "Mike Pilone GUI and framework redesign\nmpilone@slac.com\n"
517 "Greg Stern DCOP interface\n" 518 "Greg Stern DCOP interface\n"
518 "Mark Westcot Contact pinning\n" 519 "Mark Westcot Contact pinning\n"
519 "Michel Boyer de la Giroday LDAP Lookup\n" "michel@klaralvdalens-datakonsult.se\n" 520 "Michel Boyer de la Giroday LDAP Lookup\n" "michel@klaralvdalens-datakonsult.se\n"
520 "Steffen Hansen LDAP Lookup\nhansen@kde.org\n" 521 "Steffen Hansen LDAP Lookup\nhansen@kde.org\n"
521#ifdef _WIN32_ 522#ifdef _WIN32_
522 "(c) 2004 Lutz Rogowski Import from OL\nrogowski@kde.org\n" 523 "(c) 2004 Lutz Rogowski Import from OL\nrogowski@kde.org\n"
523#endif 524#endif