summaryrefslogtreecommitdiffabout
authorzautrix <zautrix>2004-09-08 09:57:16 (UTC)
committer zautrix <zautrix>2004-09-08 09:57:16 (UTC)
commit848c77f86b7105095b27a6034a0fefac8a7a0891 (patch) (unidiff)
tree2816ee9a05000ccabc43d3c9be4558053bfc8c0b
parent6650dd66dd13498a6d28844770d9d8c291335ad4 (diff)
downloadkdepimpi-848c77f86b7105095b27a6034a0fefac8a7a0891.zip
kdepimpi-848c77f86b7105095b27a6034a0fefac8a7a0891.tar.gz
kdepimpi-848c77f86b7105095b27a6034a0fefac8a7a0891.tar.bz2
Beam vcard fix
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--kaddressbook/kabcore.cpp52
1 files changed, 32 insertions, 20 deletions
diff --git a/kaddressbook/kabcore.cpp b/kaddressbook/kabcore.cpp
index 6538295..d1d385c 100644
--- a/kaddressbook/kabcore.cpp
+++ b/kaddressbook/kabcore.cpp
@@ -261,802 +261,814 @@ void KABCore::restoreSettings()
261 mMultipleViewsAtOnce = KABPrefs::instance()->mMultipleViewsAtOnce; 261 mMultipleViewsAtOnce = KABPrefs::instance()->mMultipleViewsAtOnce;
262 262
263 bool state; 263 bool state;
264 264
265 if (mMultipleViewsAtOnce) 265 if (mMultipleViewsAtOnce)
266 state = KABPrefs::instance()->mDetailsPageVisible; 266 state = KABPrefs::instance()->mDetailsPageVisible;
267 else 267 else
268 state = false; 268 state = false;
269 269
270 mActionDetails->setChecked( state ); 270 mActionDetails->setChecked( state );
271 setDetailsVisible( state ); 271 setDetailsVisible( state );
272 272
273 state = KABPrefs::instance()->mJumpButtonBarVisible; 273 state = KABPrefs::instance()->mJumpButtonBarVisible;
274 274
275 mActionJumpBar->setChecked( state ); 275 mActionJumpBar->setChecked( state );
276 setJumpButtonBarVisible( state ); 276 setJumpButtonBarVisible( state );
277/*US 277/*US
278 QValueList<int> splitterSize = KABPrefs::instance()->mDetailsSplitter; 278 QValueList<int> splitterSize = KABPrefs::instance()->mDetailsSplitter;
279 if ( splitterSize.count() == 0 ) { 279 if ( splitterSize.count() == 0 ) {
280 splitterSize.append( width() / 2 ); 280 splitterSize.append( width() / 2 );
281 splitterSize.append( width() / 2 ); 281 splitterSize.append( width() / 2 );
282 } 282 }
283 mMiniSplitter->setSizes( splitterSize ); 283 mMiniSplitter->setSizes( splitterSize );
284 if ( mExtensionBarSplitter ) { 284 if ( mExtensionBarSplitter ) {
285 splitterSize = KABPrefs::instance()->mExtensionsSplitter; 285 splitterSize = KABPrefs::instance()->mExtensionsSplitter;
286 if ( splitterSize.count() == 0 ) { 286 if ( splitterSize.count() == 0 ) {
287 splitterSize.append( width() / 2 ); 287 splitterSize.append( width() / 2 );
288 splitterSize.append( width() / 2 ); 288 splitterSize.append( width() / 2 );
289 } 289 }
290 mExtensionBarSplitter->setSizes( splitterSize ); 290 mExtensionBarSplitter->setSizes( splitterSize );
291 291
292 } 292 }
293*/ 293*/
294 mViewManager->restoreSettings(); 294 mViewManager->restoreSettings();
295 mIncSearchWidget->setCurrentItem( KABPrefs::instance()->mCurrentIncSearchField ); 295 mIncSearchWidget->setCurrentItem( KABPrefs::instance()->mCurrentIncSearchField );
296 mExtensionManager->restoreSettings(); 296 mExtensionManager->restoreSettings();
297 297
298 QValueList<int> splitterSize = KABPrefs::instance()->mDetailsSplitter; 298 QValueList<int> splitterSize = KABPrefs::instance()->mDetailsSplitter;
299 if ( splitterSize.count() == 0 ) { 299 if ( splitterSize.count() == 0 ) {
300 splitterSize.append( width() / 2 ); 300 splitterSize.append( width() / 2 );
301 splitterSize.append( width() / 2 ); 301 splitterSize.append( width() / 2 );
302 } 302 }
303 mMiniSplitter->setSizes( splitterSize ); 303 mMiniSplitter->setSizes( splitterSize );
304 if ( mExtensionBarSplitter ) { 304 if ( mExtensionBarSplitter ) {
305 splitterSize = KABPrefs::instance()->mExtensionsSplitter; 305 splitterSize = KABPrefs::instance()->mExtensionsSplitter;
306 if ( splitterSize.count() == 0 ) { 306 if ( splitterSize.count() == 0 ) {
307 splitterSize.append( width() / 2 ); 307 splitterSize.append( width() / 2 );
308 splitterSize.append( width() / 2 ); 308 splitterSize.append( width() / 2 );
309 } 309 }
310 mExtensionBarSplitter->setSizes( splitterSize ); 310 mExtensionBarSplitter->setSizes( splitterSize );
311 311
312 } 312 }
313 313
314 314
315} 315}
316 316
317void KABCore::saveSettings() 317void KABCore::saveSettings()
318{ 318{
319 KABPrefs::instance()->mJumpButtonBarVisible = mActionJumpBar->isChecked(); 319 KABPrefs::instance()->mJumpButtonBarVisible = mActionJumpBar->isChecked();
320 if ( mExtensionBarSplitter ) 320 if ( mExtensionBarSplitter )
321 KABPrefs::instance()->mExtensionsSplitter = mExtensionBarSplitter->sizes(); 321 KABPrefs::instance()->mExtensionsSplitter = mExtensionBarSplitter->sizes();
322 KABPrefs::instance()->mDetailsPageVisible = mActionDetails->isChecked(); 322 KABPrefs::instance()->mDetailsPageVisible = mActionDetails->isChecked();
323 KABPrefs::instance()->mDetailsSplitter = mMiniSplitter->sizes(); 323 KABPrefs::instance()->mDetailsSplitter = mMiniSplitter->sizes();
324#ifndef KAB_EMBEDDED 324#ifndef KAB_EMBEDDED
325 325
326 KABPrefs::instance()->mExtensionsSplitter = mExtensionBarSplitter->sizes(); 326 KABPrefs::instance()->mExtensionsSplitter = mExtensionBarSplitter->sizes();
327 KABPrefs::instance()->mDetailsSplitter = mDetailsSplitter->sizes(); 327 KABPrefs::instance()->mDetailsSplitter = mDetailsSplitter->sizes();
328#endif //KAB_EMBEDDED 328#endif //KAB_EMBEDDED
329 mExtensionManager->saveSettings(); 329 mExtensionManager->saveSettings();
330 mViewManager->saveSettings(); 330 mViewManager->saveSettings();
331 331
332 KABPrefs::instance()->mCurrentIncSearchField = mIncSearchWidget->currentItem(); 332 KABPrefs::instance()->mCurrentIncSearchField = mIncSearchWidget->currentItem();
333} 333}
334 334
335KABC::AddressBook *KABCore::addressBook() const 335KABC::AddressBook *KABCore::addressBook() const
336{ 336{
337 return mAddressBook; 337 return mAddressBook;
338} 338}
339 339
340KConfig *KABCore::config() 340KConfig *KABCore::config()
341{ 341{
342#ifndef KAB_EMBEDDED 342#ifndef KAB_EMBEDDED
343 return KABPrefs::instance()->config(); 343 return KABPrefs::instance()->config();
344#else //KAB_EMBEDDED 344#else //KAB_EMBEDDED
345 return KABPrefs::instance()->getConfig(); 345 return KABPrefs::instance()->getConfig();
346#endif //KAB_EMBEDDED 346#endif //KAB_EMBEDDED
347} 347}
348 348
349KActionCollection *KABCore::actionCollection() const 349KActionCollection *KABCore::actionCollection() const
350{ 350{
351 return mGUIClient->actionCollection(); 351 return mGUIClient->actionCollection();
352} 352}
353 353
354KABC::Field *KABCore::currentSearchField() const 354KABC::Field *KABCore::currentSearchField() const
355{ 355{
356 if (mIncSearchWidget) 356 if (mIncSearchWidget)
357 return mIncSearchWidget->currentField(); 357 return mIncSearchWidget->currentField();
358 else 358 else
359 return 0; 359 return 0;
360} 360}
361 361
362QStringList KABCore::selectedUIDs() const 362QStringList KABCore::selectedUIDs() const
363{ 363{
364 return mViewManager->selectedUids(); 364 return mViewManager->selectedUids();
365} 365}
366 366
367KABC::Resource *KABCore::requestResource( QWidget *parent ) 367KABC::Resource *KABCore::requestResource( QWidget *parent )
368{ 368{
369 QPtrList<KABC::Resource> kabcResources = addressBook()->resources(); 369 QPtrList<KABC::Resource> kabcResources = addressBook()->resources();
370 370
371 QPtrList<KRES::Resource> kresResources; 371 QPtrList<KRES::Resource> kresResources;
372 QPtrListIterator<KABC::Resource> resIt( kabcResources ); 372 QPtrListIterator<KABC::Resource> resIt( kabcResources );
373 KABC::Resource *resource; 373 KABC::Resource *resource;
374 while ( ( resource = resIt.current() ) != 0 ) { 374 while ( ( resource = resIt.current() ) != 0 ) {
375 ++resIt; 375 ++resIt;
376 if ( !resource->readOnly() ) { 376 if ( !resource->readOnly() ) {
377 KRES::Resource *res = static_cast<KRES::Resource*>( resource ); 377 KRES::Resource *res = static_cast<KRES::Resource*>( resource );
378 if ( res ) 378 if ( res )
379 kresResources.append( res ); 379 kresResources.append( res );
380 } 380 }
381 } 381 }
382 382
383 KRES::Resource *res = KRES::SelectDialog::getResource( kresResources, parent ); 383 KRES::Resource *res = KRES::SelectDialog::getResource( kresResources, parent );
384 return static_cast<KABC::Resource*>( res ); 384 return static_cast<KABC::Resource*>( res );
385} 385}
386 386
387#ifndef KAB_EMBEDDED 387#ifndef KAB_EMBEDDED
388KAboutData *KABCore::createAboutData() 388KAboutData *KABCore::createAboutData()
389#else //KAB_EMBEDDED 389#else //KAB_EMBEDDED
390void KABCore::createAboutData() 390void KABCore::createAboutData()
391#endif //KAB_EMBEDDED 391#endif //KAB_EMBEDDED
392{ 392{
393#ifndef KAB_EMBEDDED 393#ifndef KAB_EMBEDDED
394 KAboutData *about = new KAboutData( "kaddressbook", I18N_NOOP( "KAddressBook" ), 394 KAboutData *about = new KAboutData( "kaddressbook", I18N_NOOP( "KAddressBook" ),
395 "3.1", I18N_NOOP( "The KDE Address Book" ), 395 "3.1", I18N_NOOP( "The KDE Address Book" ),
396 KAboutData::License_GPL_V2, 396 KAboutData::License_GPL_V2,
397 I18N_NOOP( "(c) 1997-2003, The KDE PIM Team" ) ); 397 I18N_NOOP( "(c) 1997-2003, The KDE PIM Team" ) );
398 about->addAuthor( "Tobias Koenig", I18N_NOOP( "Current maintainer " ), "tokoe@kde.org" ); 398 about->addAuthor( "Tobias Koenig", I18N_NOOP( "Current maintainer " ), "tokoe@kde.org" );
399 about->addAuthor( "Don Sanders", I18N_NOOP( "Original author " ) ); 399 about->addAuthor( "Don Sanders", I18N_NOOP( "Original author " ) );
400 about->addAuthor( "Cornelius Schumacher", 400 about->addAuthor( "Cornelius Schumacher",
401 I18N_NOOP( "Co-maintainer, libkabc port, CSV import/export " ), 401 I18N_NOOP( "Co-maintainer, libkabc port, CSV import/export " ),
402 "schumacher@kde.org" ); 402 "schumacher@kde.org" );
403 about->addAuthor( "Mike Pilone", I18N_NOOP( "GUI and framework redesign " ), 403 about->addAuthor( "Mike Pilone", I18N_NOOP( "GUI and framework redesign " ),
404 "mpilone@slac.com" ); 404 "mpilone@slac.com" );
405 about->addAuthor( "Greg Stern", I18N_NOOP( "DCOP interface" ) ); 405 about->addAuthor( "Greg Stern", I18N_NOOP( "DCOP interface" ) );
406 about->addAuthor( "Mark Westcott", I18N_NOOP( "Contact pinning" ) ); 406 about->addAuthor( "Mark Westcott", I18N_NOOP( "Contact pinning" ) );
407 about->addAuthor( "Michel Boyer de la Giroday", I18N_NOOP( "LDAP Lookup\n" ), 407 about->addAuthor( "Michel Boyer de la Giroday", I18N_NOOP( "LDAP Lookup\n" ),
408 "michel@klaralvdalens-datakonsult.se" ); 408 "michel@klaralvdalens-datakonsult.se" );
409 about->addAuthor( "Steffen Hansen", I18N_NOOP( "LDAP Lookup " ), 409 about->addAuthor( "Steffen Hansen", I18N_NOOP( "LDAP Lookup " ),
410 "hansen@kde.org" ); 410 "hansen@kde.org" );
411 411
412 return about; 412 return about;
413#endif //KAB_EMBEDDED 413#endif //KAB_EMBEDDED
414 414
415 QString version; 415 QString version;
416#include <../version> 416#include <../version>
417 QMessageBox::about( this, "About KAddressbook/Pi", 417 QMessageBox::about( this, "About KAddressbook/Pi",
418 "KAddressbook/Platform-independent\n" 418 "KAddressbook/Platform-independent\n"
419 "(KA/Pi) " +version + " - " + 419 "(KA/Pi) " +version + " - " +
420#ifdef DESKTOP_VERSION 420#ifdef DESKTOP_VERSION
421 "Desktop Edition\n" 421 "Desktop Edition\n"
422#else 422#else
423 "PDA-Edition\n" 423 "PDA-Edition\n"
424 "for: Zaurus 5500 / 7x0 / 8x0\n" 424 "for: Zaurus 5500 / 7x0 / 8x0\n"
425#endif 425#endif
426 426
427 "(c) 2004 Ulf Schenk\n" 427 "(c) 2004 Ulf Schenk\n"
428 "(c) 2004 Lutz Rogowski\n" 428 "(c) 2004 Lutz Rogowski\n"
429 "(c) 1997-2003, The KDE PIM Team\n" 429 "(c) 1997-2003, The KDE PIM Team\n"
430 "Tobias Koenig Current maintainer\ntokoe@kde.org\n" 430 "Tobias Koenig Current maintainer\ntokoe@kde.org\n"
431 "Don Sanders Original author\n" 431 "Don Sanders Original author\n"
432 "Cornelius Schumacher Co-maintainer\nschumacher@kde.org\n" 432 "Cornelius Schumacher Co-maintainer\nschumacher@kde.org\n"
433 "Mike Pilone GUI and framework redesign\nmpilone@slac.com\n" 433 "Mike Pilone GUI and framework redesign\nmpilone@slac.com\n"
434 "Greg Stern DCOP interface\n" 434 "Greg Stern DCOP interface\n"
435 "Mark Westcot Contact pinning\n" 435 "Mark Westcot Contact pinning\n"
436 "Michel Boyer de la Giroday LDAP Lookup\n" "michel@klaralvdalens-datakonsult.se\n" 436 "Michel Boyer de la Giroday LDAP Lookup\n" "michel@klaralvdalens-datakonsult.se\n"
437 "Steffen Hansen LDAP Lookup\nhansen@kde.org\n" 437 "Steffen Hansen LDAP Lookup\nhansen@kde.org\n"
438#ifdef _WIN32_ 438#ifdef _WIN32_
439 "(c) 2004 Lutz Rogowski Import from OL\nrogowski@kde.org\n" 439 "(c) 2004 Lutz Rogowski Import from OL\nrogowski@kde.org\n"
440#endif 440#endif
441 ); 441 );
442} 442}
443 443
444void KABCore::setContactSelected( const QString &uid ) 444void KABCore::setContactSelected( const QString &uid )
445{ 445{
446 KABC::Addressee addr = mAddressBook->findByUid( uid ); 446 KABC::Addressee addr = mAddressBook->findByUid( uid );
447 if ( !mDetails->isHidden() ) 447 if ( !mDetails->isHidden() )
448 mDetails->setAddressee( addr ); 448 mDetails->setAddressee( addr );
449 449
450 if ( !addr.isEmpty() ) { 450 if ( !addr.isEmpty() ) {
451 emit contactSelected( addr.formattedName() ); 451 emit contactSelected( addr.formattedName() );
452 KABC::Picture pic = addr.photo(); 452 KABC::Picture pic = addr.photo();
453 if ( pic.isIntern() ) { 453 if ( pic.isIntern() ) {
454//US emit contactSelected( pic.data() ); 454//US emit contactSelected( pic.data() );
455//US instead use: 455//US instead use:
456 QPixmap px; 456 QPixmap px;
457 if (pic.data().isNull() != true) 457 if (pic.data().isNull() != true)
458 { 458 {
459 px.convertFromImage(pic.data()); 459 px.convertFromImage(pic.data());
460 } 460 }
461 461
462 emit contactSelected( px ); 462 emit contactSelected( px );
463 } 463 }
464 } 464 }
465 465
466 466
467 mExtensionManager->setSelectionChanged(); 467 mExtensionManager->setSelectionChanged();
468 468
469 // update the actions 469 // update the actions
470 bool selected = !uid.isEmpty(); 470 bool selected = !uid.isEmpty();
471 471
472 if ( mReadWrite ) { 472 if ( mReadWrite ) {
473 mActionCut->setEnabled( selected ); 473 mActionCut->setEnabled( selected );
474 mActionPaste->setEnabled( selected ); 474 mActionPaste->setEnabled( selected );
475 } 475 }
476 476
477 mActionCopy->setEnabled( selected ); 477 mActionCopy->setEnabled( selected );
478 mActionDelete->setEnabled( selected ); 478 mActionDelete->setEnabled( selected );
479 mActionEditAddressee->setEnabled( selected ); 479 mActionEditAddressee->setEnabled( selected );
480 mActionMail->setEnabled( selected ); 480 mActionMail->setEnabled( selected );
481 mActionMailVCard->setEnabled( selected ); 481 mActionMailVCard->setEnabled( selected );
482 //if (mActionBeam) 482 //if (mActionBeam)
483 //mActionBeam->setEnabled( selected ); 483 //mActionBeam->setEnabled( selected );
484 484
485 if (mActionBeamVCard) 485 if (mActionBeamVCard)
486 mActionBeamVCard->setEnabled( selected ); 486 mActionBeamVCard->setEnabled( selected );
487 487
488 mActionWhoAmI->setEnabled( selected ); 488 mActionWhoAmI->setEnabled( selected );
489 mActionCategories->setEnabled( selected ); 489 mActionCategories->setEnabled( selected );
490} 490}
491 491
492void KABCore::sendMail() 492void KABCore::sendMail()
493{ 493{
494 sendMail( mViewManager->selectedEmails().join( ", " ) ); 494 sendMail( mViewManager->selectedEmails().join( ", " ) );
495} 495}
496 496
497void KABCore::sendMail( const QString& emaillist ) 497void KABCore::sendMail( const QString& emaillist )
498{ 498{
499 // the parameter has the form "name1 <abc@aol.com>,name2 <abc@aol.com>;... " 499 // the parameter has the form "name1 <abc@aol.com>,name2 <abc@aol.com>;... "
500 if (emaillist.contains(",") > 0) 500 if (emaillist.contains(",") > 0)
501 ExternalAppHandler::instance()->mailToMultipleContacts( emaillist, QString::null ); 501 ExternalAppHandler::instance()->mailToMultipleContacts( emaillist, QString::null );
502 else 502 else
503 ExternalAppHandler::instance()->mailToOneContact( emaillist ); 503 ExternalAppHandler::instance()->mailToOneContact( emaillist );
504} 504}
505 505
506 506
507 507
508void KABCore::mailVCard() 508void KABCore::mailVCard()
509{ 509{
510 QStringList uids = mViewManager->selectedUids(); 510 QStringList uids = mViewManager->selectedUids();
511 if ( !uids.isEmpty() ) 511 if ( !uids.isEmpty() )
512 mailVCard( uids ); 512 mailVCard( uids );
513} 513}
514 514
515void KABCore::mailVCard( const QStringList& uids ) 515void KABCore::mailVCard( const QStringList& uids )
516{ 516{
517 QStringList urls; 517 QStringList urls;
518 518
519// QString tmpdir = locateLocal("tmp", KGlobal::getAppName()); 519// QString tmpdir = locateLocal("tmp", KGlobal::getAppName());
520 520
521 QString dirName = "/tmp/" + KApplication::randomString( 8 ); 521 QString dirName = "/tmp/" + KApplication::randomString( 8 );
522 522
523 523
524 524
525 QDir().mkdir( dirName, true ); 525 QDir().mkdir( dirName, true );
526 526
527 for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) { 527 for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) {
528 KABC::Addressee a = mAddressBook->findByUid( *it ); 528 KABC::Addressee a = mAddressBook->findByUid( *it );
529 529
530 if ( a.isEmpty() ) 530 if ( a.isEmpty() )
531 continue; 531 continue;
532 532
533 QString name = a.givenName() + "_" + a.familyName() + ".vcf"; 533 QString name = a.givenName() + "_" + a.familyName() + ".vcf";
534 534
535 QString fileName = dirName + "/" + name; 535 QString fileName = dirName + "/" + name;
536 536
537 QFile outFile(fileName); 537 QFile outFile(fileName);
538 538
539 if ( outFile.open(IO_WriteOnly) ) { // file opened successfully 539 if ( outFile.open(IO_WriteOnly) ) { // file opened successfully
540 KABC::VCardConverter converter; 540 KABC::VCardConverter converter;
541 QString vcard; 541 QString vcard;
542 542
543 converter.addresseeToVCard( a, vcard ); 543 converter.addresseeToVCard( a, vcard );
544 544
545 QTextStream t( &outFile ); // use a text stream 545 QTextStream t( &outFile ); // use a text stream
546 t.setEncoding( QTextStream::UnicodeUTF8 ); 546 t.setEncoding( QTextStream::UnicodeUTF8 );
547 t << vcard; 547 t << vcard;
548 548
549 outFile.close(); 549 outFile.close();
550 550
551 urls.append( fileName ); 551 urls.append( fileName );
552 } 552 }
553 } 553 }
554 554
555 bool result = ExternalAppHandler::instance()->mailToMultipleContacts( QString::null, urls.join(", ") ); 555 bool result = ExternalAppHandler::instance()->mailToMultipleContacts( QString::null, urls.join(", ") );
556 556
557 557
558/*US 558/*US
559 kapp->invokeMailer( QString::null, QString::null, QString::null, 559 kapp->invokeMailer( QString::null, QString::null, QString::null,
560 QString::null, // subject 560 QString::null, // subject
561 QString::null, // body 561 QString::null, // body
562 QString::null, 562 QString::null,
563 urls ); // attachments 563 urls ); // attachments
564*/ 564*/
565 565
566} 566}
567 567
568/** 568/**
569 Beams the "WhoAmI contact. 569 Beams the "WhoAmI contact.
570*/ 570*/
571void KABCore::beamMySelf() 571void KABCore::beamMySelf()
572{ 572{
573 KABC::Addressee a = KABC::StdAddressBook::self()->whoAmI(); 573 KABC::Addressee a = KABC::StdAddressBook::self()->whoAmI();
574 if (!a.isEmpty()) 574 if (!a.isEmpty())
575 { 575 {
576 QStringList uids; 576 QStringList uids;
577 uids << a.uid(); 577 uids << a.uid();
578 578
579 beamVCard(uids); 579 beamVCard(uids);
580 } else { 580 } else {
581 KMessageBox::information( this, i18n( "Your personal contact is\nnot set! Please select it\nand set it with menu:\nSettings - Set Who Am I\n" ) ); 581 KMessageBox::information( this, i18n( "Your personal contact is\nnot set! Please select it\nand set it with menu:\nSettings - Set Who Am I\n" ) );
582 582
583 583
584 } 584 }
585} 585}
586 586
587void KABCore::beamVCard() 587void KABCore::beamVCard()
588{ 588{
589 QStringList uids = mViewManager->selectedUids(); 589 QStringList uids = mViewManager->selectedUids();
590 if ( !uids.isEmpty() ) 590 if ( !uids.isEmpty() )
591 beamVCard( uids ); 591 beamVCard( uids );
592} 592}
593 593
594 594
595void KABCore::beamVCard(const QStringList& uids) 595void KABCore::beamVCard(const QStringList& uids)
596{ 596{
597/*US 597/*US
598 QString beamFilename; 598 QString beamFilename;
599 Opie::OPimContact c; 599 Opie::OPimContact c;
600 if ( actionPersonal->isOn() ) { 600 if ( actionPersonal->isOn() ) {
601 beamFilename = addressbookPersonalVCardName(); 601 beamFilename = addressbookPersonalVCardName();
602 if ( !QFile::exists( beamFilename ) ) 602 if ( !QFile::exists( beamFilename ) )
603 return; // can't beam a non-existent file 603 return; // can't beam a non-existent file
604 Opie::OPimContactAccessBackend* vcard_backend = new Opie::OPimContactAccessBackend_VCard( QString::null, 604 Opie::OPimContactAccessBackend* vcard_backend = new Opie::OPimContactAccessBackend_VCard( QString::null,
605 beamFilename ); 605 beamFilename );
606 Opie::OPimContactAccess* access = new Opie::OPimContactAccess ( "addressbook", QString::null , vcard_backend, true ); 606 Opie::OPimContactAccess* access = new Opie::OPimContactAccess ( "addressbook", QString::null , vcard_backend, true );
607 Opie::OPimContactAccess::List allList = access->allRecords(); 607 Opie::OPimContactAccess::List allList = access->allRecords();
608 Opie::OPimContactAccess::List::Iterator it = allList.begin(); // Just take first 608 Opie::OPimContactAccess::List::Iterator it = allList.begin(); // Just take first
609 c = *it; 609 c = *it;
610 610
611 delete access; 611 delete access;
612 } else { 612 } else {
613 unlink( beamfile ); // delete if exists 613 unlink( beamfile ); // delete if exists
614 mkdir("/tmp/obex/", 0755); 614 mkdir("/tmp/obex/", 0755);
615 c = m_abView -> currentEntry(); 615 c = m_abView -> currentEntry();
616 Opie::OPimContactAccessBackend* vcard_backend = new Opie::OPimContactAccessBackend_VCard( QString::null, 616 Opie::OPimContactAccessBackend* vcard_backend = new Opie::OPimContactAccessBackend_VCard( QString::null,
617 beamfile ); 617 beamfile );
618 Opie::OPimContactAccess* access = new Opie::OPimContactAccess ( "addressbook", QString::null , vcard_backend, true ); 618 Opie::OPimContactAccess* access = new Opie::OPimContactAccess ( "addressbook", QString::null , vcard_backend, true );
619 access->add( c ); 619 access->add( c );
620 access->save(); 620 access->save();
621 delete access; 621 delete access;
622 622
623 beamFilename = beamfile; 623 beamFilename = beamfile;
624 } 624 }
625 625
626 owarn << "Beaming: " << beamFilename << oendl; 626 owarn << "Beaming: " << beamFilename << oendl;
627*/ 627*/
628 628
629#if 0 629#if 0
630 QString tmpdir = locateLocal("tmp", KGlobal::getAppName()); 630 QString tmpdir = locateLocal("tmp", KGlobal::getAppName());
631 631
632 QString dirName = tmpdir + "/" + KApplication::randomString( 8 ); 632 QString dirName = tmpdir + "/" + KApplication::randomString( 8 );
633 633
634 QString name = "contact.vcf"; 634 QString name = "contact.vcf";
635 635
636 QString fileName = dirName + "/" + name; 636 QString fileName = dirName + "/" + name;
637#endif 637#endif
638 // LR: we should use the /tmp dir, because: /tmp = RAM, (HOME)/kdepim = flash memory 638 // LR: we should use the /tmp dir, because: /tmp = RAM, (HOME)/kdepim = flash memory
639 // 639 //
640 QString fileName = "/tmp/kapibeamfile.vcf"; 640 QString fileName = "/tmp/kapibeamfile.vcf";
641 641
642 642
643 //QDir().mkdir( dirName, true ); 643 //QDir().mkdir( dirName, true );
644 644
645 QFile outFile(fileName); 645
646 KABC::VCardConverter converter; 646 KABC::VCardConverter converter;
647 QString description; 647 QString description;
648 648 QString datastream;
649 if ( outFile.open(IO_WriteOnly) ) { // file opened successfully 649 for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) {
650
651 QTextStream t( &outFile ); // use a text stream
652 t.setEncoding( QTextStream::UnicodeUTF8 );
653
654 for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) {
655 KABC::Addressee a = mAddressBook->findByUid( *it ); 650 KABC::Addressee a = mAddressBook->findByUid( *it );
656 651
657 if ( a.isEmpty() ) 652 if ( a.isEmpty() )
658 continue; 653 continue;
659 654
660 if (description.isEmpty()) 655 if (description.isEmpty())
661 description = a.formattedName(); 656 description = a.formattedName();
662 657
663 QString vcard; 658 QString vcard;
664 converter.addresseeToVCard( a, vcard ); 659 converter.addresseeToVCard( a, vcard );
665 t << vcard; 660 int start = 0;
666 661 int next;
667 } 662 while ( (next = vcard.find("TYPE=", start) )>= 0 ) {
663 int semi = vcard.find(";", next);
664 int dopp = vcard.find(":", next);
665 int sep;
666 if ( semi < dopp && semi >= 0 )
667 sep = semi ;
668 else
669 sep = dopp;
670 datastream +=vcard.mid( start, next - start);
671 datastream +=vcard.mid( next+5,sep -next -5 ).upper();
672 start = sep;
673 }
674 datastream += vcard.mid( start,vcard.length() );
675 }
676#ifndef DESKTOP_VERSION
677 QFile outFile(fileName);
678 if ( outFile.open(IO_WriteOnly) ) {
679 datastream.replace ( QRegExp("VERSION:3.0") , "VERSION:2.1" );
680 QTextStream t( &outFile ); // use a text stream
681 t.setEncoding( QTextStream::UnicodeUTF8 );
682 t <<datastream;
683 outFile.close();
684 Ir *ir = new Ir( this );
685 connect( ir, SIGNAL( done(Ir*) ), this, SLOT( beamDone(Ir*) ) );
686 ir->send( fileName, description, "text/x-vCard" );
668 } else { 687 } else {
669 qDebug("Error open temp beam file "); 688 qDebug("Error open temp beam file ");
670 return; 689 return;
671 } 690 }
672
673 outFile.close();
674
675#ifndef DESKTOP_VERSION
676 Ir *ir = new Ir( this );
677 connect( ir, SIGNAL( done(Ir*) ), this, SLOT( beamDone(Ir*) ) );
678 ir->send( fileName, description, "text/x-vCard" );
679#endif 691#endif
680 692
681} 693}
682 694
683void KABCore::beamDone( Ir *ir ) 695void KABCore::beamDone( Ir *ir )
684{ 696{
685#ifndef DESKTOP_VERSION 697#ifndef DESKTOP_VERSION
686 delete ir; 698 delete ir;
687#endif 699#endif
688} 700}
689 701
690 702
691void KABCore::browse( const QString& url ) 703void KABCore::browse( const QString& url )
692{ 704{
693#ifndef KAB_EMBEDDED 705#ifndef KAB_EMBEDDED
694 kapp->invokeBrowser( url ); 706 kapp->invokeBrowser( url );
695#else //KAB_EMBEDDED 707#else //KAB_EMBEDDED
696 qDebug("KABCore::browse must be fixed"); 708 qDebug("KABCore::browse must be fixed");
697#endif //KAB_EMBEDDED 709#endif //KAB_EMBEDDED
698} 710}
699 711
700void KABCore::selectAllContacts() 712void KABCore::selectAllContacts()
701{ 713{
702 mViewManager->setSelected( QString::null, true ); 714 mViewManager->setSelected( QString::null, true );
703} 715}
704 716
705void KABCore::deleteContacts() 717void KABCore::deleteContacts()
706{ 718{
707 QStringList uidList = mViewManager->selectedUids(); 719 QStringList uidList = mViewManager->selectedUids();
708 deleteContacts( uidList ); 720 deleteContacts( uidList );
709} 721}
710 722
711void KABCore::deleteContacts( const QStringList &uids ) 723void KABCore::deleteContacts( const QStringList &uids )
712{ 724{
713 if ( uids.count() > 0 ) { 725 if ( uids.count() > 0 ) {
714 PwDeleteCommand *command = new PwDeleteCommand( mAddressBook, uids ); 726 PwDeleteCommand *command = new PwDeleteCommand( mAddressBook, uids );
715 UndoStack::instance()->push( command ); 727 UndoStack::instance()->push( command );
716 RedoStack::instance()->clear(); 728 RedoStack::instance()->clear();
717 729
718 // now if we deleted anything, refresh 730 // now if we deleted anything, refresh
719 setContactSelected( QString::null ); 731 setContactSelected( QString::null );
720 setModified( true ); 732 setModified( true );
721 } 733 }
722} 734}
723 735
724void KABCore::copyContacts() 736void KABCore::copyContacts()
725{ 737{
726 KABC::Addressee::List addrList = mViewManager->selectedAddressees(); 738 KABC::Addressee::List addrList = mViewManager->selectedAddressees();
727 739
728 QString clipText = AddresseeUtil::addresseesToClipboard( addrList ); 740 QString clipText = AddresseeUtil::addresseesToClipboard( addrList );
729 741
730 kdDebug(5720) << "KABCore::copyContacts: " << clipText << endl; 742 kdDebug(5720) << "KABCore::copyContacts: " << clipText << endl;
731 743
732 QClipboard *cb = QApplication::clipboard(); 744 QClipboard *cb = QApplication::clipboard();
733 cb->setText( clipText ); 745 cb->setText( clipText );
734} 746}
735 747
736void KABCore::cutContacts() 748void KABCore::cutContacts()
737{ 749{
738 QStringList uidList = mViewManager->selectedUids(); 750 QStringList uidList = mViewManager->selectedUids();
739 751
740//US if ( uidList.size() > 0 ) { 752//US if ( uidList.size() > 0 ) {
741 if ( uidList.count() > 0 ) { 753 if ( uidList.count() > 0 ) {
742 PwCutCommand *command = new PwCutCommand( mAddressBook, uidList ); 754 PwCutCommand *command = new PwCutCommand( mAddressBook, uidList );
743 UndoStack::instance()->push( command ); 755 UndoStack::instance()->push( command );
744 RedoStack::instance()->clear(); 756 RedoStack::instance()->clear();
745 757
746 setModified( true ); 758 setModified( true );
747 } 759 }
748} 760}
749 761
750void KABCore::pasteContacts() 762void KABCore::pasteContacts()
751{ 763{
752 QClipboard *cb = QApplication::clipboard(); 764 QClipboard *cb = QApplication::clipboard();
753 765
754 KABC::Addressee::List list = AddresseeUtil::clipboardToAddressees( cb->text() ); 766 KABC::Addressee::List list = AddresseeUtil::clipboardToAddressees( cb->text() );
755 767
756 pasteContacts( list ); 768 pasteContacts( list );
757} 769}
758 770
759void KABCore::pasteContacts( KABC::Addressee::List &list ) 771void KABCore::pasteContacts( KABC::Addressee::List &list )
760{ 772{
761 KABC::Resource *resource = requestResource( this ); 773 KABC::Resource *resource = requestResource( this );
762 KABC::Addressee::List::Iterator it; 774 KABC::Addressee::List::Iterator it;
763 for ( it = list.begin(); it != list.end(); ++it ) 775 for ( it = list.begin(); it != list.end(); ++it )
764 (*it).setResource( resource ); 776 (*it).setResource( resource );
765 777
766 PwPasteCommand *command = new PwPasteCommand( this, list ); 778 PwPasteCommand *command = new PwPasteCommand( this, list );
767 UndoStack::instance()->push( command ); 779 UndoStack::instance()->push( command );
768 RedoStack::instance()->clear(); 780 RedoStack::instance()->clear();
769 781
770 setModified( true ); 782 setModified( true );
771} 783}
772 784
773void KABCore::setWhoAmI() 785void KABCore::setWhoAmI()
774{ 786{
775 KABC::Addressee::List addrList = mViewManager->selectedAddressees(); 787 KABC::Addressee::List addrList = mViewManager->selectedAddressees();
776 788
777 if ( addrList.count() > 1 ) { 789 if ( addrList.count() > 1 ) {
778 KMessageBox::sorry( this, i18n( "Please select only one contact." ) ); 790 KMessageBox::sorry( this, i18n( "Please select only one contact." ) );
779 return; 791 return;
780 } 792 }
781 793
782 QString text( i18n( "<qt>Do you really want to use <b>%1</b> as your new personal contact?</qt>" ) ); 794 QString text( i18n( "<qt>Do you really want to use <b>%1</b> as your new personal contact?</qt>" ) );
783 if ( KMessageBox::questionYesNo( this, text.arg( addrList[ 0 ].assembledName() ) ) == KMessageBox::Yes ) 795 if ( KMessageBox::questionYesNo( this, text.arg( addrList[ 0 ].assembledName() ) ) == KMessageBox::Yes )
784 static_cast<KABC::StdAddressBook*>( KABC::StdAddressBook::self() )->setWhoAmI( addrList[ 0 ] ); 796 static_cast<KABC::StdAddressBook*>( KABC::StdAddressBook::self() )->setWhoAmI( addrList[ 0 ] );
785} 797}
786 798
787void KABCore::setCategories() 799void KABCore::setCategories()
788{ 800{
789 KPIM::CategorySelectDialog dlg( KABPrefs::instance(), this, "", true ); 801 KPIM::CategorySelectDialog dlg( KABPrefs::instance(), this, "", true );
790 if ( !dlg.exec() ) 802 if ( !dlg.exec() )
791 return; 803 return;
792 804
793 bool merge = false; 805 bool merge = false;
794 QString msg = i18n( "Merge with existing categories?" ); 806 QString msg = i18n( "Merge with existing categories?" );
795 if ( KMessageBox::questionYesNo( this, msg ) == KMessageBox::Yes ) 807 if ( KMessageBox::questionYesNo( this, msg ) == KMessageBox::Yes )
796 merge = true; 808 merge = true;
797 809
798 QStringList categories = dlg.selectedCategories(); 810 QStringList categories = dlg.selectedCategories();
799 811
800 QStringList uids = mViewManager->selectedUids(); 812 QStringList uids = mViewManager->selectedUids();
801 QStringList::Iterator it; 813 QStringList::Iterator it;
802 for ( it = uids.begin(); it != uids.end(); ++it ) { 814 for ( it = uids.begin(); it != uids.end(); ++it ) {
803 KABC::Addressee addr = mAddressBook->findByUid( *it ); 815 KABC::Addressee addr = mAddressBook->findByUid( *it );
804 if ( !addr.isEmpty() ) { 816 if ( !addr.isEmpty() ) {
805 if ( !merge ) 817 if ( !merge )
806 addr.setCategories( categories ); 818 addr.setCategories( categories );
807 else { 819 else {
808 QStringList addrCategories = addr.categories(); 820 QStringList addrCategories = addr.categories();
809 QStringList::Iterator catIt; 821 QStringList::Iterator catIt;
810 for ( catIt = categories.begin(); catIt != categories.end(); ++catIt ) { 822 for ( catIt = categories.begin(); catIt != categories.end(); ++catIt ) {
811 if ( !addrCategories.contains( *catIt ) ) 823 if ( !addrCategories.contains( *catIt ) )
812 addrCategories.append( *catIt ); 824 addrCategories.append( *catIt );
813 } 825 }
814 addr.setCategories( addrCategories ); 826 addr.setCategories( addrCategories );
815 } 827 }
816 828
817 mAddressBook->insertAddressee( addr ); 829 mAddressBook->insertAddressee( addr );
818 } 830 }
819 } 831 }
820 832
821 if ( uids.count() > 0 ) 833 if ( uids.count() > 0 )
822 setModified( true ); 834 setModified( true );
823} 835}
824 836
825void KABCore::setSearchFields( const KABC::Field::List &fields ) 837void KABCore::setSearchFields( const KABC::Field::List &fields )
826{ 838{
827 mIncSearchWidget->setFields( fields ); 839 mIncSearchWidget->setFields( fields );
828} 840}
829 841
830void KABCore::incrementalSearch( const QString& text ) 842void KABCore::incrementalSearch( const QString& text )
831{ 843{
832 mViewManager->setSelected( QString::null, false ); 844 mViewManager->setSelected( QString::null, false );
833 845
834 if ( !text.isEmpty() ) { 846 if ( !text.isEmpty() ) {
835 KABC::Field *field = mIncSearchWidget->currentField(); 847 KABC::Field *field = mIncSearchWidget->currentField();
836 QString pattern = text.lower()+"*"; 848 QString pattern = text.lower()+"*";
837 QRegExp re; 849 QRegExp re;
838 re.setWildcard(true); // most people understand these better. 850 re.setWildcard(true); // most people understand these better.
839 re.setCaseSensitive(false); 851 re.setCaseSensitive(false);
840 re.setPattern( pattern ); 852 re.setPattern( pattern );
841 QStringList foundUids; 853 QStringList foundUids;
842 if (!re.isValid()) 854 if (!re.isValid())
843 return; 855 return;
844#if 1 //KDE_VERSION >= 319 856#if 1 //KDE_VERSION >= 319
845 KABC::AddresseeList list( mAddressBook->allAddressees() ); 857 KABC::AddresseeList list( mAddressBook->allAddressees() );
846 if ( field ) { 858 if ( field ) {
847 list.sortByField( field ); 859 list.sortByField( field );
848 KABC::AddresseeList::Iterator it; 860 KABC::AddresseeList::Iterator it;
849 for ( it = list.begin(); it != list.end(); ++it ) { 861 for ( it = list.begin(); it != list.end(); ++it ) {
850 862
851#if QT_VERSION >= 300 863#if QT_VERSION >= 300
852 if (re.search(field->value( *it ).lower()) != -1) 864 if (re.search(field->value( *it ).lower()) != -1)
853#else 865#else
854 if (re.match(field->value( *it ).lower()) != -1) 866 if (re.match(field->value( *it ).lower()) != -1)
855#endif 867#endif
856 { 868 {
857 // if ( field->value( *it ).lower().startsWith( pattern ) ) { 869 // if ( field->value( *it ).lower().startsWith( pattern ) ) {
858 //mViewManager->setSelected( (*it).uid(), true ); 870 //mViewManager->setSelected( (*it).uid(), true );
859 foundUids.append( (*it).uid() ); 871 foundUids.append( (*it).uid() );
860 //return; 872 //return;
861 } 873 }
862 } 874 }
863 } else { 875 } else {
864 KABC::AddresseeList::Iterator it; 876 KABC::AddresseeList::Iterator it;
865 for ( it = list.begin(); it != list.end(); ++it ) { 877 for ( it = list.begin(); it != list.end(); ++it ) {
866 KABC::Field::List fieldList = mIncSearchWidget->fields(); 878 KABC::Field::List fieldList = mIncSearchWidget->fields();
867 KABC::Field::List::ConstIterator fieldIt; 879 KABC::Field::List::ConstIterator fieldIt;
868 for ( fieldIt = fieldList.begin(); fieldIt != fieldList.end(); ++fieldIt ) { 880 for ( fieldIt = fieldList.begin(); fieldIt != fieldList.end(); ++fieldIt ) {
869#if QT_VERSION >= 300 881#if QT_VERSION >= 300
870 if (re.search((*fieldIt)->value( *it ).lower()) != -1) 882 if (re.search((*fieldIt)->value( *it ).lower()) != -1)
871#else 883#else
872 if (re.match((*fieldIt)->value( *it ).lower()) != -1) 884 if (re.match((*fieldIt)->value( *it ).lower()) != -1)
873#endif 885#endif
874 { 886 {
875 // if ( (*fieldIt)->value( *it ).lower().startsWith( pattern ) ) { 887 // if ( (*fieldIt)->value( *it ).lower().startsWith( pattern ) ) {
876 //mViewManager->setSelected( (*it).uid(), true ); 888 //mViewManager->setSelected( (*it).uid(), true );
877 foundUids.append( (*it).uid() ); 889 foundUids.append( (*it).uid() );
878 //return; 890 //return;
879 } 891 }
880 } 892 }
881 } 893 }
882 } 894 }
883 if ( foundUids.count() > 0 ) 895 if ( foundUids.count() > 0 )
884 mViewManager->setListSelected( foundUids ); 896 mViewManager->setListSelected( foundUids );
885#else 897#else
886 KABC::AddressBook::Iterator it; 898 KABC::AddressBook::Iterator it;
887 for ( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) { 899 for ( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) {
888 if ( field ) { 900 if ( field ) {
889 if ( field->value( *it ).lower().startsWith( pattern ) ) { 901 if ( field->value( *it ).lower().startsWith( pattern ) ) {
890 mViewManager->setSelected( (*it).uid(), true ); 902 mViewManager->setSelected( (*it).uid(), true );
891 return; 903 return;
892 } 904 }
893 } else { 905 } else {
894 KABC::Field::List fieldList = mIncSearchWidget->fields(); 906 KABC::Field::List fieldList = mIncSearchWidget->fields();
895 KABC::Field::List::ConstIterator fieldIt; 907 KABC::Field::List::ConstIterator fieldIt;
896 for ( fieldIt = fieldList.begin(); fieldIt != fieldList.end(); ++fieldIt ) { 908 for ( fieldIt = fieldList.begin(); fieldIt != fieldList.end(); ++fieldIt ) {
897 if ( (*fieldIt)->value( *it ).lower().startsWith( pattern ) ) { 909 if ( (*fieldIt)->value( *it ).lower().startsWith( pattern ) ) {
898 mViewManager->setSelected( (*it).uid(), true ); 910 mViewManager->setSelected( (*it).uid(), true );
899 return; 911 return;
900 } 912 }
901 } 913 }
902 } 914 }
903 } 915 }
904#endif 916#endif
905 } 917 }
906} 918}
907 919
908void KABCore::setModified() 920void KABCore::setModified()
909{ 921{
910 setModified( true ); 922 setModified( true );
911} 923}
912 924
913void KABCore::setModifiedWOrefresh() 925void KABCore::setModifiedWOrefresh()
914{ 926{
915 // qDebug("KABCore::setModifiedWOrefresh() "); 927 // qDebug("KABCore::setModifiedWOrefresh() ");
916 mModified = true; 928 mModified = true;
917 mActionSave->setEnabled( mModified ); 929 mActionSave->setEnabled( mModified );
918#ifdef DESKTOP_VERSION 930#ifdef DESKTOP_VERSION
919 mDetails->refreshView(); 931 mDetails->refreshView();
920#endif 932#endif
921 933
922} 934}
923void KABCore::setModified( bool modified ) 935void KABCore::setModified( bool modified )
924{ 936{
925 mModified = modified; 937 mModified = modified;
926 mActionSave->setEnabled( mModified ); 938 mActionSave->setEnabled( mModified );
927 939
928 if ( modified ) 940 if ( modified )
929 mJumpButtonBar->recreateButtons(); 941 mJumpButtonBar->recreateButtons();
930 942
931 mViewManager->refreshView(); 943 mViewManager->refreshView();
932 mDetails->refreshView(); 944 mDetails->refreshView();
933 945
934} 946}
935 947
936bool KABCore::modified() const 948bool KABCore::modified() const
937{ 949{
938 return mModified; 950 return mModified;
939} 951}
940 952
941void KABCore::contactModified( const KABC::Addressee &addr ) 953void KABCore::contactModified( const KABC::Addressee &addr )
942{ 954{
943 955
944 Command *command = 0; 956 Command *command = 0;
945 QString uid; 957 QString uid;
946 958
947 // check if it exists already 959 // check if it exists already
948 KABC::Addressee origAddr = mAddressBook->findByUid( addr.uid() ); 960 KABC::Addressee origAddr = mAddressBook->findByUid( addr.uid() );
949 if ( origAddr.isEmpty() ) 961 if ( origAddr.isEmpty() )
950 command = new PwNewCommand( mAddressBook, addr ); 962 command = new PwNewCommand( mAddressBook, addr );
951 else { 963 else {
952 command = new PwEditCommand( mAddressBook, origAddr, addr ); 964 command = new PwEditCommand( mAddressBook, origAddr, addr );
953 uid = addr.uid(); 965 uid = addr.uid();
954 } 966 }
955 967
956 UndoStack::instance()->push( command ); 968 UndoStack::instance()->push( command );
957 RedoStack::instance()->clear(); 969 RedoStack::instance()->clear();
958 970
959 setModified( true ); 971 setModified( true );
960} 972}
961 973
962void KABCore::newContact() 974void KABCore::newContact()
963{ 975{
964 976
965 977
966 QPtrList<KABC::Resource> kabcResources = mAddressBook->resources(); 978 QPtrList<KABC::Resource> kabcResources = mAddressBook->resources();
967 979
968 QPtrList<KRES::Resource> kresResources; 980 QPtrList<KRES::Resource> kresResources;
969 QPtrListIterator<KABC::Resource> it( kabcResources ); 981 QPtrListIterator<KABC::Resource> it( kabcResources );
970 KABC::Resource *resource; 982 KABC::Resource *resource;
971 while ( ( resource = it.current() ) != 0 ) { 983 while ( ( resource = it.current() ) != 0 ) {
972 ++it; 984 ++it;
973 if ( !resource->readOnly() ) { 985 if ( !resource->readOnly() ) {
974 KRES::Resource *res = static_cast<KRES::Resource*>( resource ); 986 KRES::Resource *res = static_cast<KRES::Resource*>( resource );
975 if ( res ) 987 if ( res )
976 kresResources.append( res ); 988 kresResources.append( res );
977 } 989 }
978 } 990 }
979 991
980 KRES::Resource *res = KRES::SelectDialog::getResource( kresResources, this ); 992 KRES::Resource *res = KRES::SelectDialog::getResource( kresResources, this );
981 resource = static_cast<KABC::Resource*>( res ); 993 resource = static_cast<KABC::Resource*>( res );
982 994
983 if ( resource ) { 995 if ( resource ) {
984 KABC::Addressee addr; 996 KABC::Addressee addr;
985 addr.setResource( resource ); 997 addr.setResource( resource );
986 mEditorDialog->setAddressee( addr ); 998 mEditorDialog->setAddressee( addr );
987 KApplication::execDialog ( mEditorDialog ); 999 KApplication::execDialog ( mEditorDialog );
988 1000
989 } else 1001 } else
990 return; 1002 return;
991 1003
992 // mEditorDict.insert( dialog->addressee().uid(), dialog ); 1004 // mEditorDict.insert( dialog->addressee().uid(), dialog );
993 1005
994 1006
995} 1007}
996 1008
997void KABCore::addEmail( QString aStr ) 1009void KABCore::addEmail( QString aStr )
998{ 1010{
999#ifndef KAB_EMBEDDED 1011#ifndef KAB_EMBEDDED
1000 QString fullName, email; 1012 QString fullName, email;
1001 1013
1002 KABC::Addressee::parseEmailAddress( aStr, fullName, email ); 1014 KABC::Addressee::parseEmailAddress( aStr, fullName, email );
1003 1015
1004 // Try to lookup the addressee matching the email address 1016 // Try to lookup the addressee matching the email address
1005 bool found = false; 1017 bool found = false;
1006 QStringList emailList; 1018 QStringList emailList;
1007 KABC::AddressBook::Iterator it; 1019 KABC::AddressBook::Iterator it;
1008 for ( it = mAddressBook->begin(); !found && (it != mAddressBook->end()); ++it ) { 1020 for ( it = mAddressBook->begin(); !found && (it != mAddressBook->end()); ++it ) {
1009 emailList = (*it).emails(); 1021 emailList = (*it).emails();
1010 if ( emailList.contains( email ) > 0 ) { 1022 if ( emailList.contains( email ) > 0 ) {
1011 found = true; 1023 found = true;
1012 (*it).setNameFromString( fullName ); 1024 (*it).setNameFromString( fullName );
1013 editContact( (*it).uid() ); 1025 editContact( (*it).uid() );
1014 } 1026 }
1015 } 1027 }
1016 1028
1017 if ( !found ) { 1029 if ( !found ) {
1018 KABC::Addressee addr; 1030 KABC::Addressee addr;
1019 addr.setNameFromString( fullName ); 1031 addr.setNameFromString( fullName );
1020 addr.insertEmail( email, true ); 1032 addr.insertEmail( email, true );
1021 1033
1022 mAddressBook->insertAddressee( addr ); 1034 mAddressBook->insertAddressee( addr );
1023 mViewManager->refreshView( addr.uid() ); 1035 mViewManager->refreshView( addr.uid() );
1024 editContact( addr.uid() ); 1036 editContact( addr.uid() );
1025 } 1037 }
1026#else //KAB_EMBEDDED 1038#else //KAB_EMBEDDED
1027 qDebug("KABCore::addEmail finsih method"); 1039 qDebug("KABCore::addEmail finsih method");
1028#endif //KAB_EMBEDDED 1040#endif //KAB_EMBEDDED
1029} 1041}
1030 1042
1031void KABCore::importVCard( const KURL &url, bool showPreview ) 1043void KABCore::importVCard( const KURL &url, bool showPreview )
1032{ 1044{
1033 mXXPortManager->importVCard( url, showPreview ); 1045 mXXPortManager->importVCard( url, showPreview );
1034} 1046}
1035void KABCore::importFromOL() 1047void KABCore::importFromOL()
1036{ 1048{
1037#ifdef _WIN32_ 1049#ifdef _WIN32_
1038 KAImportOLdialog* idgl = new KAImportOLdialog( i18n("Import Contacts from OL"), mAddressBook, this ); 1050 KAImportOLdialog* idgl = new KAImportOLdialog( i18n("Import Contacts from OL"), mAddressBook, this );
1039 idgl->exec(); 1051 idgl->exec();
1040 KABC::Addressee::List list = idgl->getAddressList(); 1052 KABC::Addressee::List list = idgl->getAddressList();
1041 if ( list.count() > 0 ) { 1053 if ( list.count() > 0 ) {
1042 KABC::Addressee::List listNew; 1054 KABC::Addressee::List listNew;
1043 KABC::Addressee::List listExisting; 1055 KABC::Addressee::List listExisting;
1044 KABC::Addressee::List::Iterator it; 1056 KABC::Addressee::List::Iterator it;
1045 KABC::AddressBook::Iterator iter; 1057 KABC::AddressBook::Iterator iter;
1046 for ( it = list.begin(); it != list.end(); ++it ) { 1058 for ( it = list.begin(); it != list.end(); ++it ) {
1047 if ( mAddressBook->findByUid((*it).uid() ).isEmpty()) 1059 if ( mAddressBook->findByUid((*it).uid() ).isEmpty())
1048 listNew.append( (*it) ); 1060 listNew.append( (*it) );
1049 else 1061 else
1050 listExisting.append( (*it) ); 1062 listExisting.append( (*it) );
1051 } 1063 }
1052 if ( listExisting.count() > 0 ) 1064 if ( listExisting.count() > 0 )
1053 KMessageBox::information( this, i18n("%1 contacts not added to addressbook\nbecause they were already in the addressbook!").arg( listExisting.count() )); 1065 KMessageBox::information( this, i18n("%1 contacts not added to addressbook\nbecause they were already in the addressbook!").arg( listExisting.count() ));
1054 if ( listNew.count() > 0 ) { 1066 if ( listNew.count() > 0 ) {
1055 pasteWithNewUid = false; 1067 pasteWithNewUid = false;
1056 pasteContacts( listNew ); 1068 pasteContacts( listNew );
1057 pasteWithNewUid = true; 1069 pasteWithNewUid = true;
1058 } 1070 }
1059 } 1071 }
1060 delete idgl; 1072 delete idgl;
1061#endif 1073#endif
1062} 1074}