summaryrefslogtreecommitdiffabout
path: root/kaddressbook
Unidiff
Diffstat (limited to 'kaddressbook') (more/less context) (ignore whitespace changes)
-rw-r--r--kaddressbook/kabcore.cpp19
-rw-r--r--kaddressbook/xxportselectdialog.cpp16
2 files changed, 25 insertions, 10 deletions
diff --git a/kaddressbook/kabcore.cpp b/kaddressbook/kabcore.cpp
index d99a9cd..7be5db8 100644
--- a/kaddressbook/kabcore.cpp
+++ b/kaddressbook/kabcore.cpp
@@ -299,1115 +299,1126 @@ KABCore::KABCore( KXMLGUIClient *client, bool readWrite, QWidget *parent, const
299 "X-Children", "KADDRESSBOOK" ); 299 "X-Children", "KADDRESSBOOK" );
300 mAddressBook->addCustomField( i18n( "FreeBusyUrl" ), KABC::Field::Personal, 300 mAddressBook->addCustomField( i18n( "FreeBusyUrl" ), KABC::Field::Personal,
301 "X-FreeBusyUrl", "KADDRESSBOOK" ); 301 "X-FreeBusyUrl", "KADDRESSBOOK" );
302#endif 302#endif
303 initGUI(); 303 initGUI();
304 304
305 mIncSearchWidget->setFocus(); 305 mIncSearchWidget->setFocus();
306 306
307 307
308 connect( mViewManager, SIGNAL( selected( const QString& ) ), 308 connect( mViewManager, SIGNAL( selected( const QString& ) ),
309 SLOT( setContactSelected( const QString& ) ) ); 309 SLOT( setContactSelected( const QString& ) ) );
310 connect( mViewManager, SIGNAL( executed( const QString& ) ), 310 connect( mViewManager, SIGNAL( executed( const QString& ) ),
311 SLOT( executeContact( const QString& ) ) ); 311 SLOT( executeContact( const QString& ) ) );
312 312
313 connect( mViewManager, SIGNAL( deleteRequest( ) ), 313 connect( mViewManager, SIGNAL( deleteRequest( ) ),
314 SLOT( deleteContacts( ) ) ); 314 SLOT( deleteContacts( ) ) );
315 connect( mViewManager, SIGNAL( modified() ), 315 connect( mViewManager, SIGNAL( modified() ),
316 SLOT( setModified() ) ); 316 SLOT( setModified() ) );
317 317
318 connect( mExtensionManager, SIGNAL( modified( const KABC::Addressee::List& ) ), this, SLOT( extensionModified( const KABC::Addressee::List& ) ) ); 318 connect( mExtensionManager, SIGNAL( modified( const KABC::Addressee::List& ) ), this, SLOT( extensionModified( const KABC::Addressee::List& ) ) );
319 connect( mExtensionManager, SIGNAL( changedActiveExtension( int ) ), this, SLOT( extensionChanged( int ) ) ); 319 connect( mExtensionManager, SIGNAL( changedActiveExtension( int ) ), this, SLOT( extensionChanged( int ) ) );
320 320
321 connect( mXXPortManager, SIGNAL( modified() ), 321 connect( mXXPortManager, SIGNAL( modified() ),
322 SLOT( setModified() ) ); 322 SLOT( setModified() ) );
323 323
324 connect( mJumpButtonBar, SIGNAL( jumpToLetter( const QString& ) ), 324 connect( mJumpButtonBar, SIGNAL( jumpToLetter( const QString& ) ),
325 SLOT( incrementalSearch( const QString& ) ) ); 325 SLOT( incrementalSearch( const QString& ) ) );
326 connect( mIncSearchWidget, SIGNAL( fieldChanged() ), 326 connect( mIncSearchWidget, SIGNAL( fieldChanged() ),
327 mJumpButtonBar, SLOT( recreateButtons() ) ); 327 mJumpButtonBar, SLOT( recreateButtons() ) );
328 328
329 connect( mDetails, SIGNAL( sendEmail( const QString& ) ), 329 connect( mDetails, SIGNAL( sendEmail( const QString& ) ),
330 SLOT( sendMail( const QString& ) ) ); 330 SLOT( sendMail( const QString& ) ) );
331 331
332 332
333 connect( ExternalAppHandler::instance(), SIGNAL (requestForNameEmailUidList(const QString&, const QString&)),this, SLOT(requestForNameEmailUidList(const QString&, const QString&))); 333 connect( ExternalAppHandler::instance(), SIGNAL (requestForNameEmailUidList(const QString&, const QString&)),this, SLOT(requestForNameEmailUidList(const QString&, const QString&)));
334 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&))); 334 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&)));
335 connect( ExternalAppHandler::instance(), SIGNAL (requestForBirthdayList(const QString&, const QString&)),this, SLOT(requestForBirthdayList(const QString&, const QString&))); 335 connect( ExternalAppHandler::instance(), SIGNAL (requestForBirthdayList(const QString&, const QString&)),this, SLOT(requestForBirthdayList(const QString&, const QString&)));
336 connect( ExternalAppHandler::instance(), SIGNAL (nextView()),this, SLOT(setDetailsToggle())); 336 connect( ExternalAppHandler::instance(), SIGNAL (nextView()),this, SLOT(setDetailsToggle()));
337 337
338 338
339#ifndef KAB_EMBEDDED 339#ifndef KAB_EMBEDDED
340 connect( mViewManager, SIGNAL( urlDropped( const KURL& ) ), 340 connect( mViewManager, SIGNAL( urlDropped( const KURL& ) ),
341 mXXPortManager, SLOT( importVCard( const KURL& ) ) ); 341 mXXPortManager, SLOT( importVCard( const KURL& ) ) );
342 342
343 connect( mDetails, SIGNAL( browse( const QString& ) ), 343 connect( mDetails, SIGNAL( browse( const QString& ) ),
344 SLOT( browse( const QString& ) ) ); 344 SLOT( browse( const QString& ) ) );
345 345
346 346
347 mAddressBookService = new KAddressBookService( this ); 347 mAddressBookService = new KAddressBookService( this );
348 348
349#endif //KAB_EMBEDDED 349#endif //KAB_EMBEDDED
350 350
351 mMessageTimer = new QTimer( this ); 351 mMessageTimer = new QTimer( this );
352 connect( mMessageTimer, SIGNAL( timeout() ), this, SLOT( setCaptionBack() ) ); 352 connect( mMessageTimer, SIGNAL( timeout() ), this, SLOT( setCaptionBack() ) );
353 mEditorDialog = 0; 353 mEditorDialog = 0;
354 createAddresseeEditorDialog( this ); 354 createAddresseeEditorDialog( this );
355 setModified( false ); 355 setModified( false );
356 mBRdisabled = false; 356 mBRdisabled = false;
357#ifndef DESKTOP_VERSION 357#ifndef DESKTOP_VERSION
358 infrared = 0; 358 infrared = 0;
359#endif 359#endif
360 //toggleBeamReceive( ); 360 //toggleBeamReceive( );
361 361
362 // we have a toolbar repainting error on the Zaurus when starting KA/Pi 362 // we have a toolbar repainting error on the Zaurus when starting KA/Pi
363 QTimer::singleShot( 1, this , SLOT ( updateToolBar())); 363 QTimer::singleShot( 1, this , SLOT ( updateToolBar()));
364} 364}
365 365
366void KABCore::updateToolBar() 366void KABCore::updateToolBar()
367{ 367{
368 mMainWindow->toolBar()->repaint(); 368 mMainWindow->toolBar()->repaint();
369} 369}
370KABCore::~KABCore() 370KABCore::~KABCore()
371{ 371{
372 // save(); 372 // save();
373 //saveSettings(); 373 //saveSettings();
374 //KABPrefs::instance()->writeConfig(); 374 //KABPrefs::instance()->writeConfig();
375 delete AddresseeConfig::instance(); 375 delete AddresseeConfig::instance();
376 mAddressBook = 0; 376 mAddressBook = 0;
377 KABC::StdAddressBook::close(); 377 KABC::StdAddressBook::close();
378 378
379 delete syncManager; 379 delete syncManager;
380#ifndef DESKTOP_VERSION 380#ifndef DESKTOP_VERSION
381 if ( infrared ) 381 if ( infrared )
382 delete infrared; 382 delete infrared;
383#endif 383#endif
384} 384}
385void KABCore::receive( const QCString& cmsg, const QByteArray& data ) 385void KABCore::receive( const QCString& cmsg, const QByteArray& data )
386{ 386{
387 qDebug("KA: QCOP message received: %s ", cmsg.data() ); 387 qDebug("KA: QCOP message received: %s ", cmsg.data() );
388 if ( cmsg == "setDocument(QString)" ) { 388 if ( cmsg == "setDocument(QString)" ) {
389 QDataStream stream( data, IO_ReadOnly ); 389 QDataStream stream( data, IO_ReadOnly );
390 QString fileName; 390 QString fileName;
391 stream >> fileName; 391 stream >> fileName;
392 recieve( fileName ); 392 recieve( fileName );
393 return; 393 return;
394 } 394 }
395} 395}
396void KABCore::toggleBeamReceive( ) 396void KABCore::toggleBeamReceive( )
397{ 397{
398 if ( mBRdisabled ) 398 if ( mBRdisabled )
399 return; 399 return;
400#ifndef DESKTOP_VERSION 400#ifndef DESKTOP_VERSION
401 if ( infrared ) { 401 if ( infrared ) {
402 qDebug("AB disable BeamReceive "); 402 qDebug("AB disable BeamReceive ");
403 delete infrared; 403 delete infrared;
404 infrared = 0; 404 infrared = 0;
405 mActionBR->setChecked(false); 405 mActionBR->setChecked(false);
406 return; 406 return;
407 } 407 }
408 qDebug("AB enable BeamReceive "); 408 qDebug("AB enable BeamReceive ");
409 mActionBR->setChecked(true); 409 mActionBR->setChecked(true);
410 410
411 infrared = new QCopChannel("QPE/Application/addressbook",this, "channelAB" ) ; 411 infrared = new QCopChannel("QPE/Application/addressbook",this, "channelAB" ) ;
412 QObject::connect( infrared, SIGNAL (received ( const QCString &, const QByteArray & )),this, SLOT(receive( const QCString&, const QByteArray& ))); 412 QObject::connect( infrared, SIGNAL (received ( const QCString &, const QByteArray & )),this, SLOT(receive( const QCString&, const QByteArray& )));
413#endif 413#endif
414} 414}
415 415
416 416
417void KABCore::disableBR(bool b) 417void KABCore::disableBR(bool b)
418{ 418{
419#ifndef DESKTOP_VERSION 419#ifndef DESKTOP_VERSION
420 if ( b ) { 420 if ( b ) {
421 if ( infrared ) { 421 if ( infrared ) {
422 toggleBeamReceive( ); 422 toggleBeamReceive( );
423 } 423 }
424 mBRdisabled = true; 424 mBRdisabled = true;
425 } else { 425 } else {
426 if ( mBRdisabled ) { 426 if ( mBRdisabled ) {
427 mBRdisabled = false; 427 mBRdisabled = false;
428 //toggleBeamReceive( ); 428 //toggleBeamReceive( );
429 } 429 }
430 } 430 }
431#endif 431#endif
432 432
433} 433}
434void KABCore::recieve( QString fn ) 434void KABCore::recieve( QString fn )
435{ 435{
436 //qDebug("KABCore::recieve "); 436 //qDebug("KABCore::recieve ");
437 int count = mAddressBook->importFromFile( fn, true ); 437 int count = mAddressBook->importFromFile( fn, true );
438 if ( count ) 438 if ( count )
439 setModified( true ); 439 setModified( true );
440 mViewManager->refreshView(); 440 mViewManager->refreshView();
441 message(i18n("%1 contact(s) received!").arg( count )); 441 message(i18n("%1 contact(s) received!").arg( count ));
442 topLevelWidget()->showMaximized(); 442 topLevelWidget()->showMaximized();
443 topLevelWidget()->raise(); 443 topLevelWidget()->raise();
444} 444}
445void KABCore::restoreSettings() 445void KABCore::restoreSettings()
446{ 446{
447 mMultipleViewsAtOnce = KABPrefs::instance()->mMultipleViewsAtOnce; 447 mMultipleViewsAtOnce = KABPrefs::instance()->mMultipleViewsAtOnce;
448 448
449 bool state; 449 bool state;
450 450
451 if (mMultipleViewsAtOnce) 451 if (mMultipleViewsAtOnce)
452 state = KABPrefs::instance()->mDetailsPageVisible; 452 state = KABPrefs::instance()->mDetailsPageVisible;
453 else 453 else
454 state = false; 454 state = false;
455 455
456 mActionDetails->setChecked( state ); 456 mActionDetails->setChecked( state );
457 setDetailsVisible( state ); 457 setDetailsVisible( state );
458 458
459 state = KABPrefs::instance()->mJumpButtonBarVisible; 459 state = KABPrefs::instance()->mJumpButtonBarVisible;
460 460
461 mActionJumpBar->setChecked( state ); 461 mActionJumpBar->setChecked( state );
462 setJumpButtonBarVisible( state ); 462 setJumpButtonBarVisible( state );
463/*US 463/*US
464 QValueList<int> splitterSize = KABPrefs::instance()->mDetailsSplitter; 464 QValueList<int> splitterSize = KABPrefs::instance()->mDetailsSplitter;
465 if ( splitterSize.count() == 0 ) { 465 if ( splitterSize.count() == 0 ) {
466 splitterSize.append( width() / 2 ); 466 splitterSize.append( width() / 2 );
467 splitterSize.append( width() / 2 ); 467 splitterSize.append( width() / 2 );
468 } 468 }
469 mMiniSplitter->setSizes( splitterSize ); 469 mMiniSplitter->setSizes( splitterSize );
470 if ( mExtensionBarSplitter ) { 470 if ( mExtensionBarSplitter ) {
471 splitterSize = KABPrefs::instance()->mExtensionsSplitter; 471 splitterSize = KABPrefs::instance()->mExtensionsSplitter;
472 if ( splitterSize.count() == 0 ) { 472 if ( splitterSize.count() == 0 ) {
473 splitterSize.append( width() / 2 ); 473 splitterSize.append( width() / 2 );
474 splitterSize.append( width() / 2 ); 474 splitterSize.append( width() / 2 );
475 } 475 }
476 mExtensionBarSplitter->setSizes( splitterSize ); 476 mExtensionBarSplitter->setSizes( splitterSize );
477 477
478 } 478 }
479*/ 479*/
480 mViewManager->restoreSettings(); 480 mViewManager->restoreSettings();
481 mIncSearchWidget->setCurrentItem( KABPrefs::instance()->mCurrentIncSearchField ); 481 mIncSearchWidget->setCurrentItem( KABPrefs::instance()->mCurrentIncSearchField );
482 mExtensionManager->restoreSettings(); 482 mExtensionManager->restoreSettings();
483#ifdef DESKTOP_VERSION 483#ifdef DESKTOP_VERSION
484 int wid = width(); 484 int wid = width();
485 if ( wid < 10 ) 485 if ( wid < 10 )
486 wid = 400; 486 wid = 400;
487#else 487#else
488 int wid = QApplication::desktop()->width(); 488 int wid = QApplication::desktop()->width();
489 if ( wid < 640 ) 489 if ( wid < 640 )
490 wid = QApplication::desktop()->height(); 490 wid = QApplication::desktop()->height();
491#endif 491#endif
492 QValueList<int> splitterSize;// = KABPrefs::instance()->mDetailsSplitter; 492 QValueList<int> splitterSize;// = KABPrefs::instance()->mDetailsSplitter;
493 if ( true /*splitterSize.count() == 0*/ ) { 493 if ( true /*splitterSize.count() == 0*/ ) {
494 splitterSize.append( wid / 2 ); 494 splitterSize.append( wid / 2 );
495 splitterSize.append( wid / 2 ); 495 splitterSize.append( wid / 2 );
496 } 496 }
497 mMiniSplitter->setSizes( splitterSize ); 497 mMiniSplitter->setSizes( splitterSize );
498 if ( mExtensionBarSplitter ) { 498 if ( mExtensionBarSplitter ) {
499 //splitterSize = KABPrefs::instance()->mExtensionsSplitter; 499 //splitterSize = KABPrefs::instance()->mExtensionsSplitter;
500 if ( true /*splitterSize.count() == 0*/ ) { 500 if ( true /*splitterSize.count() == 0*/ ) {
501 splitterSize.append( wid / 2 ); 501 splitterSize.append( wid / 2 );
502 splitterSize.append( wid / 2 ); 502 splitterSize.append( wid / 2 );
503 } 503 }
504 mExtensionBarSplitter->setSizes( splitterSize ); 504 mExtensionBarSplitter->setSizes( splitterSize );
505 505
506 } 506 }
507 507
508 508
509} 509}
510 510
511void KABCore::saveSettings() 511void KABCore::saveSettings()
512{ 512{
513 KABPrefs::instance()->mJumpButtonBarVisible = mActionJumpBar->isChecked(); 513 KABPrefs::instance()->mJumpButtonBarVisible = mActionJumpBar->isChecked();
514 if ( mExtensionBarSplitter ) 514 if ( mExtensionBarSplitter )
515 KABPrefs::instance()->mExtensionsSplitter = mExtensionBarSplitter->sizes(); 515 KABPrefs::instance()->mExtensionsSplitter = mExtensionBarSplitter->sizes();
516 KABPrefs::instance()->mDetailsPageVisible = mActionDetails->isChecked(); 516 KABPrefs::instance()->mDetailsPageVisible = mActionDetails->isChecked();
517 KABPrefs::instance()->mDetailsSplitter = mMiniSplitter->sizes(); 517 KABPrefs::instance()->mDetailsSplitter = mMiniSplitter->sizes();
518#ifndef KAB_EMBEDDED 518#ifndef KAB_EMBEDDED
519 519
520 KABPrefs::instance()->mExtensionsSplitter = mExtensionBarSplitter->sizes(); 520 KABPrefs::instance()->mExtensionsSplitter = mExtensionBarSplitter->sizes();
521 KABPrefs::instance()->mDetailsSplitter = mDetailsSplitter->sizes(); 521 KABPrefs::instance()->mDetailsSplitter = mDetailsSplitter->sizes();
522#endif //KAB_EMBEDDED 522#endif //KAB_EMBEDDED
523 mExtensionManager->saveSettings(); 523 mExtensionManager->saveSettings();
524 mViewManager->saveSettings(); 524 mViewManager->saveSettings();
525 525
526 KABPrefs::instance()->mCurrentIncSearchField = mIncSearchWidget->currentItem(); 526 KABPrefs::instance()->mCurrentIncSearchField = mIncSearchWidget->currentItem();
527} 527}
528 528
529KABC::AddressBook *KABCore::addressBook() const 529KABC::AddressBook *KABCore::addressBook() const
530{ 530{
531 return mAddressBook; 531 return mAddressBook;
532} 532}
533 533
534KConfig *KABCore::config() 534KConfig *KABCore::config()
535{ 535{
536#ifndef KAB_EMBEDDED 536#ifndef KAB_EMBEDDED
537 return KABPrefs::instance()->config(); 537 return KABPrefs::instance()->config();
538#else //KAB_EMBEDDED 538#else //KAB_EMBEDDED
539 return KABPrefs::instance()->getConfig(); 539 return KABPrefs::instance()->getConfig();
540#endif //KAB_EMBEDDED 540#endif //KAB_EMBEDDED
541} 541}
542 542
543KActionCollection *KABCore::actionCollection() const 543KActionCollection *KABCore::actionCollection() const
544{ 544{
545 return mGUIClient->actionCollection(); 545 return mGUIClient->actionCollection();
546} 546}
547 547
548KABC::Field *KABCore::currentSearchField() const 548KABC::Field *KABCore::currentSearchField() const
549{ 549{
550 if (mIncSearchWidget) 550 if (mIncSearchWidget)
551 return mIncSearchWidget->currentField(); 551 return mIncSearchWidget->currentField();
552 else 552 else
553 return 0; 553 return 0;
554} 554}
555 555
556QStringList KABCore::selectedUIDs() const 556QStringList KABCore::selectedUIDs() const
557{ 557{
558 return mViewManager->selectedUids(); 558 return mViewManager->selectedUids();
559} 559}
560 560
561KABC::Resource *KABCore::requestResource( QWidget *parent ) 561KABC::Resource *KABCore::requestResource( QWidget *parent )
562{ 562{
563 QPtrList<KABC::Resource> kabcResources = addressBook()->resources(); 563 QPtrList<KABC::Resource> kabcResources = addressBook()->resources();
564 564
565 QPtrList<KRES::Resource> kresResources; 565 QPtrList<KRES::Resource> kresResources;
566 QPtrListIterator<KABC::Resource> resIt( kabcResources ); 566 QPtrListIterator<KABC::Resource> resIt( kabcResources );
567 KABC::Resource *resource; 567 KABC::Resource *resource;
568 while ( ( resource = resIt.current() ) != 0 ) { 568 while ( ( resource = resIt.current() ) != 0 ) {
569 ++resIt; 569 ++resIt;
570 if ( !resource->readOnly() ) { 570 if ( !resource->readOnly() ) {
571 KRES::Resource *res = static_cast<KRES::Resource*>( resource ); 571 KRES::Resource *res = static_cast<KRES::Resource*>( resource );
572 if ( res ) 572 if ( res )
573 kresResources.append( res ); 573 kresResources.append( res );
574 } 574 }
575 } 575 }
576 576
577 KRES::Resource *res = KRES::SelectDialog::getResource( kresResources, parent ); 577 KRES::Resource *res = KRES::SelectDialog::getResource( kresResources, parent );
578 return static_cast<KABC::Resource*>( res ); 578 return static_cast<KABC::Resource*>( res );
579} 579}
580 580
581#ifndef KAB_EMBEDDED 581#ifndef KAB_EMBEDDED
582KAboutData *KABCore::createAboutData() 582KAboutData *KABCore::createAboutData()
583#else //KAB_EMBEDDED 583#else //KAB_EMBEDDED
584void KABCore::createAboutData() 584void KABCore::createAboutData()
585#endif //KAB_EMBEDDED 585#endif //KAB_EMBEDDED
586{ 586{
587#ifndef KAB_EMBEDDED 587#ifndef KAB_EMBEDDED
588 KAboutData *about = new KAboutData( "kaddressbook", I18N_NOOP( "KAddressBook" ), 588 KAboutData *about = new KAboutData( "kaddressbook", I18N_NOOP( "KAddressBook" ),
589 "3.1", I18N_NOOP( "The KDE Address Book" ), 589 "3.1", I18N_NOOP( "The KDE Address Book" ),
590 KAboutData::License_GPL_V2, 590 KAboutData::License_GPL_V2,
591 I18N_NOOP( "(c) 1997-2003, The KDE PIM Team" ) ); 591 I18N_NOOP( "(c) 1997-2003, The KDE PIM Team" ) );
592 about->addAuthor( "Tobias Koenig", I18N_NOOP( "Current maintainer " ), "tokoe@kde.org" ); 592 about->addAuthor( "Tobias Koenig", I18N_NOOP( "Current maintainer " ), "tokoe@kde.org" );
593 about->addAuthor( "Don Sanders", I18N_NOOP( "Original author " ) ); 593 about->addAuthor( "Don Sanders", I18N_NOOP( "Original author " ) );
594 about->addAuthor( "Cornelius Schumacher", 594 about->addAuthor( "Cornelius Schumacher",
595 I18N_NOOP( "Co-maintainer, libkabc port, CSV import/export " ), 595 I18N_NOOP( "Co-maintainer, libkabc port, CSV import/export " ),
596 "schumacher@kde.org" ); 596 "schumacher@kde.org" );
597 about->addAuthor( "Mike Pilone", I18N_NOOP( "GUI and framework redesign " ), 597 about->addAuthor( "Mike Pilone", I18N_NOOP( "GUI and framework redesign " ),
598 "mpilone@slac.com" ); 598 "mpilone@slac.com" );
599 about->addAuthor( "Greg Stern", I18N_NOOP( "DCOP interface" ) ); 599 about->addAuthor( "Greg Stern", I18N_NOOP( "DCOP interface" ) );
600 about->addAuthor( "Mark Westcott", I18N_NOOP( "Contact pinning" ) ); 600 about->addAuthor( "Mark Westcott", I18N_NOOP( "Contact pinning" ) );
601 about->addAuthor( "Michel Boyer de la Giroday", I18N_NOOP( "LDAP Lookup\n" ), 601 about->addAuthor( "Michel Boyer de la Giroday", I18N_NOOP( "LDAP Lookup\n" ),
602 "michel@klaralvdalens-datakonsult.se" ); 602 "michel@klaralvdalens-datakonsult.se" );
603 about->addAuthor( "Steffen Hansen", I18N_NOOP( "LDAP Lookup " ), 603 about->addAuthor( "Steffen Hansen", I18N_NOOP( "LDAP Lookup " ),
604 "hansen@kde.org" ); 604 "hansen@kde.org" );
605 605
606 return about; 606 return about;
607#endif //KAB_EMBEDDED 607#endif //KAB_EMBEDDED
608 608
609 QString version; 609 QString version;
610#include <../version> 610#include <../version>
611 QMessageBox::about( this, "About KAddressbook/Pi", 611 QMessageBox::about( this, "About KAddressbook/Pi",
612 "KAddressbook/Platform-independent\n" 612 "KAddressbook/Platform-independent\n"
613 "(KA/Pi) " +version + " - " + 613 "(KA/Pi) " +version + " - " +
614#ifdef DESKTOP_VERSION 614#ifdef DESKTOP_VERSION
615 "Desktop Edition\n" 615 "Desktop Edition\n"
616#else 616#else
617 "PDA-Edition\n" 617 "PDA-Edition\n"
618 "for: Zaurus 5500 / 7x0 / 8x0\n" 618 "for: Zaurus 5500 / 7x0 / 8x0\n"
619#endif 619#endif
620 620
621 "(c) 2004 Ulf Schenk\n" 621 "(c) 2004 Ulf Schenk\n"
622 "(c) 2004 Lutz Rogowski\n" 622 "(c) 2004 Lutz Rogowski\n"
623 "(c) 1997-2003, The KDE PIM Team\n" 623 "(c) 1997-2003, The KDE PIM Team\n"
624 "Tobias Koenig Current maintainer\ntokoe@kde.org\n" 624 "Tobias Koenig Current maintainer\ntokoe@kde.org\n"
625 "Don Sanders Original author\n" 625 "Don Sanders Original author\n"
626 "Cornelius Schumacher Co-maintainer\nschumacher@kde.org\n" 626 "Cornelius Schumacher Co-maintainer\nschumacher@kde.org\n"
627 "Mike Pilone GUI and framework redesign\nmpilone@slac.com\n" 627 "Mike Pilone GUI and framework redesign\nmpilone@slac.com\n"
628 "Greg Stern DCOP interface\n" 628 "Greg Stern DCOP interface\n"
629 "Mark Westcot Contact pinning\n" 629 "Mark Westcot Contact pinning\n"
630 "Michel Boyer de la Giroday LDAP Lookup\n" "michel@klaralvdalens-datakonsult.se\n" 630 "Michel Boyer de la Giroday LDAP Lookup\n" "michel@klaralvdalens-datakonsult.se\n"
631 "Steffen Hansen LDAP Lookup\nhansen@kde.org\n" 631 "Steffen Hansen LDAP Lookup\nhansen@kde.org\n"
632#ifdef _WIN32_ 632#ifdef _WIN32_
633 "(c) 2004 Lutz Rogowski Import from OL\nrogowski@kde.org\n" 633 "(c) 2004 Lutz Rogowski Import from OL\nrogowski@kde.org\n"
634#endif 634#endif
635 ); 635 );
636} 636}
637 637
638void KABCore::setContactSelected( const QString &uid ) 638void KABCore::setContactSelected( const QString &uid )
639{ 639{
640 KABC::Addressee addr = mAddressBook->findByUid( uid ); 640 KABC::Addressee addr = mAddressBook->findByUid( uid );
641 if ( !mDetails->isHidden() ) 641 if ( !mDetails->isHidden() )
642 mDetails->setAddressee( addr ); 642 mDetails->setAddressee( addr );
643 643
644 if ( !addr.isEmpty() ) { 644 if ( !addr.isEmpty() ) {
645 emit contactSelected( addr.formattedName() ); 645 emit contactSelected( addr.formattedName() );
646 KABC::Picture pic = addr.photo(); 646 KABC::Picture pic = addr.photo();
647 if ( pic.isIntern() ) { 647 if ( pic.isIntern() ) {
648//US emit contactSelected( pic.data() ); 648//US emit contactSelected( pic.data() );
649//US instead use: 649//US instead use:
650 QPixmap px; 650 QPixmap px;
651 if (pic.data().isNull() != true) 651 if (pic.data().isNull() != true)
652 { 652 {
653 px.convertFromImage(pic.data()); 653 px.convertFromImage(pic.data());
654 } 654 }
655 655
656 emit contactSelected( px ); 656 emit contactSelected( px );
657 } 657 }
658 } 658 }
659 659
660 660
661 mExtensionManager->setSelectionChanged(); 661 mExtensionManager->setSelectionChanged();
662 662
663 // update the actions 663 // update the actions
664 bool selected = !uid.isEmpty(); 664 bool selected = !uid.isEmpty();
665 665
666 if ( mReadWrite ) { 666 if ( mReadWrite ) {
667 mActionCut->setEnabled( selected ); 667 mActionCut->setEnabled( selected );
668 mActionPaste->setEnabled( selected ); 668 mActionPaste->setEnabled( selected );
669 } 669 }
670 670
671 mActionCopy->setEnabled( selected ); 671 mActionCopy->setEnabled( selected );
672 mActionDelete->setEnabled( selected ); 672 mActionDelete->setEnabled( selected );
673 mActionEditAddressee->setEnabled( selected ); 673 mActionEditAddressee->setEnabled( selected );
674 mActionMail->setEnabled( selected ); 674 mActionMail->setEnabled( selected );
675 mActionMailVCard->setEnabled( selected ); 675 mActionMailVCard->setEnabled( selected );
676 //if (mActionBeam) 676 //if (mActionBeam)
677 //mActionBeam->setEnabled( selected ); 677 //mActionBeam->setEnabled( selected );
678 678
679 if (mActionBeamVCard) 679 if (mActionBeamVCard)
680 mActionBeamVCard->setEnabled( selected ); 680 mActionBeamVCard->setEnabled( selected );
681 681
682 mActionWhoAmI->setEnabled( selected ); 682 mActionWhoAmI->setEnabled( selected );
683 mActionCategories->setEnabled( selected );
684} 683}
685 684
686void KABCore::sendMail() 685void KABCore::sendMail()
687{ 686{
688 sendMail( mViewManager->selectedEmails().join( ", " ) ); 687 sendMail( mViewManager->selectedEmails().join( ", " ) );
689} 688}
690 689
691void KABCore::sendMail( const QString& emaillist ) 690void KABCore::sendMail( const QString& emaillist )
692{ 691{
693 // the parameter has the form "name1 <abc@aol.com>,name2 <abc@aol.com>;... " 692 // the parameter has the form "name1 <abc@aol.com>,name2 <abc@aol.com>;... "
694 if (emaillist.contains(",") > 0) 693 if (emaillist.contains(",") > 0)
695 ExternalAppHandler::instance()->mailToMultipleContacts( emaillist, QString::null ); 694 ExternalAppHandler::instance()->mailToMultipleContacts( emaillist, QString::null );
696 else 695 else
697 ExternalAppHandler::instance()->mailToOneContact( emaillist ); 696 ExternalAppHandler::instance()->mailToOneContact( emaillist );
698} 697}
699 698
700 699
701 700
702void KABCore::mailVCard() 701void KABCore::mailVCard()
703{ 702{
704 QStringList uids = mViewManager->selectedUids(); 703 QStringList uids = mViewManager->selectedUids();
705 if ( !uids.isEmpty() ) 704 if ( !uids.isEmpty() )
706 mailVCard( uids ); 705 mailVCard( uids );
707} 706}
708 707
709void KABCore::mailVCard( const QStringList& uids ) 708void KABCore::mailVCard( const QStringList& uids )
710{ 709{
711 QStringList urls; 710 QStringList urls;
712 711
713// QString tmpdir = locateLocal("tmp", KGlobal::getAppName()); 712// QString tmpdir = locateLocal("tmp", KGlobal::getAppName());
714 713
715 QString dirName = "/tmp/" + KApplication::randomString( 8 ); 714 QString dirName = "/tmp/" + KApplication::randomString( 8 );
716 715
717 716
718 717
719 QDir().mkdir( dirName, true ); 718 QDir().mkdir( dirName, true );
720 719
721 for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) { 720 for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) {
722 KABC::Addressee a = mAddressBook->findByUid( *it ); 721 KABC::Addressee a = mAddressBook->findByUid( *it );
723 722
724 if ( a.isEmpty() ) 723 if ( a.isEmpty() )
725 continue; 724 continue;
726 725
727 QString name = a.givenName() + "_" + a.familyName() + ".vcf"; 726 QString name = a.givenName() + "_" + a.familyName() + ".vcf";
728 727
729 QString fileName = dirName + "/" + name; 728 QString fileName = dirName + "/" + name;
730 729
731 QFile outFile(fileName); 730 QFile outFile(fileName);
732 731
733 if ( outFile.open(IO_WriteOnly) ) { // file opened successfully 732 if ( outFile.open(IO_WriteOnly) ) { // file opened successfully
734 KABC::VCardConverter converter; 733 KABC::VCardConverter converter;
735 QString vcard; 734 QString vcard;
736 735
737 converter.addresseeToVCard( a, vcard ); 736 converter.addresseeToVCard( a, vcard );
738 737
739 QTextStream t( &outFile ); // use a text stream 738 QTextStream t( &outFile ); // use a text stream
740 t.setEncoding( QTextStream::UnicodeUTF8 ); 739 t.setEncoding( QTextStream::UnicodeUTF8 );
741 t << vcard; 740 t << vcard;
742 741
743 outFile.close(); 742 outFile.close();
744 743
745 urls.append( fileName ); 744 urls.append( fileName );
746 } 745 }
747 } 746 }
748 747
749 bool result = ExternalAppHandler::instance()->mailToMultipleContacts( QString::null, urls.join(", ") ); 748 bool result = ExternalAppHandler::instance()->mailToMultipleContacts( QString::null, urls.join(", ") );
750 749
751 750
752/*US 751/*US
753 kapp->invokeMailer( QString::null, QString::null, QString::null, 752 kapp->invokeMailer( QString::null, QString::null, QString::null,
754 QString::null, // subject 753 QString::null, // subject
755 QString::null, // body 754 QString::null, // body
756 QString::null, 755 QString::null,
757 urls ); // attachments 756 urls ); // attachments
758*/ 757*/
759 758
760} 759}
761 760
762/** 761/**
763 Beams the "WhoAmI contact. 762 Beams the "WhoAmI contact.
764*/ 763*/
765void KABCore::beamMySelf() 764void KABCore::beamMySelf()
766{ 765{
767 KABC::Addressee a = KABC::StdAddressBook::self()->whoAmI(); 766 KABC::Addressee a = KABC::StdAddressBook::self()->whoAmI();
768 if (!a.isEmpty()) 767 if (!a.isEmpty())
769 { 768 {
770 QStringList uids; 769 QStringList uids;
771 uids << a.uid(); 770 uids << a.uid();
772 771
773 beamVCard(uids); 772 beamVCard(uids);
774 } else { 773 } else {
775 KMessageBox::information( this, i18n( "Your personal contact is\nnot set! Please select it\nand set it with menu:\nSettings - Set Who Am I\n" ) ); 774 KMessageBox::information( this, i18n( "Your personal contact is\nnot set! Please select it\nand set it with menu:\nSettings - Set Who Am I\n" ) );
776 775
777 776
778 } 777 }
779} 778}
780 779
781void KABCore::export2phone() 780void KABCore::export2phone()
782{ 781{
783 QStringList uids; 782 QStringList uids;
784 XXPortSelectDialog dlg( this, false, this ); 783 XXPortSelectDialog dlg( this, false, this );
785 if ( dlg.exec() ) 784 if ( dlg.exec() )
786 uids = dlg.uids(); 785 uids = dlg.uids();
787 else 786 else
788 return; 787 return;
789 if ( uids.isEmpty() ) 788 if ( uids.isEmpty() )
790 return; 789 return;
791 // qDebug("count %d ", uids.count()); 790 // qDebug("count %d ", uids.count());
792 791
793 KAex2phonePrefs ex2phone; 792 KAex2phonePrefs ex2phone;
794 ex2phone.mPhoneConnection->setText( KPimGlobalPrefs::instance()->mEx2PhoneConnection ); 793 ex2phone.mPhoneConnection->setText( KPimGlobalPrefs::instance()->mEx2PhoneConnection );
795 ex2phone.mPhoneDevice->setText( KPimGlobalPrefs::instance()->mEx2PhoneDevice ); 794 ex2phone.mPhoneDevice->setText( KPimGlobalPrefs::instance()->mEx2PhoneDevice );
796 ex2phone.mPhoneModel->setText( KPimGlobalPrefs::instance()->mEx2PhoneModel ); 795 ex2phone.mPhoneModel->setText( KPimGlobalPrefs::instance()->mEx2PhoneModel );
797 796
798 if ( !ex2phone.exec() ) { 797 if ( !ex2phone.exec() ) {
799 return; 798 return;
800 } 799 }
801 KPimGlobalPrefs::instance()->mEx2PhoneConnection = ex2phone.mPhoneConnection->text(); 800 KPimGlobalPrefs::instance()->mEx2PhoneConnection = ex2phone.mPhoneConnection->text();
802 KPimGlobalPrefs::instance()->mEx2PhoneDevice = ex2phone.mPhoneDevice->text(); 801 KPimGlobalPrefs::instance()->mEx2PhoneDevice = ex2phone.mPhoneDevice->text();
803 KPimGlobalPrefs::instance()->mEx2PhoneModel = ex2phone.mPhoneModel->text(); 802 KPimGlobalPrefs::instance()->mEx2PhoneModel = ex2phone.mPhoneModel->text();
804 803
805 804
806 PhoneAccess::writeConfig( KPimGlobalPrefs::instance()->mEx2PhoneDevice, 805 PhoneAccess::writeConfig( KPimGlobalPrefs::instance()->mEx2PhoneDevice,
807 KPimGlobalPrefs::instance()->mEx2PhoneConnection, 806 KPimGlobalPrefs::instance()->mEx2PhoneConnection,
808 KPimGlobalPrefs::instance()->mEx2PhoneModel ); 807 KPimGlobalPrefs::instance()->mEx2PhoneModel );
809 808
810 QString fileName = getPhoneFile(); 809 QString fileName = getPhoneFile();
811 if ( ! mAddressBook->export2PhoneFormat( uids ,fileName ) ) 810 if ( ! mAddressBook->export2PhoneFormat( uids ,fileName ) )
812 return; 811 return;
813 812
814 message(i18n("Exporting to phone...")); 813 message(i18n("Exporting to phone..."));
815 QTimer::singleShot( 1, this , SLOT ( writeToPhone())); 814 QTimer::singleShot( 1, this , SLOT ( writeToPhone()));
816 815
817} 816}
818QString KABCore::getPhoneFile() 817QString KABCore::getPhoneFile()
819{ 818{
820#ifdef DESKTOP_VERSION 819#ifdef DESKTOP_VERSION
821 return locateLocal("tmp", "phonefile.vcf"); 820 return locateLocal("tmp", "phonefile.vcf");
822#else 821#else
823 return "/tmp/phonefile.vcf"; 822 return "/tmp/phonefile.vcf";
824#endif 823#endif
825 824
826} 825}
827void KABCore::writeToPhone( ) 826void KABCore::writeToPhone( )
828{ 827{
829 if ( PhoneAccess::writeToPhone( getPhoneFile() ) ) 828 if ( PhoneAccess::writeToPhone( getPhoneFile() ) )
830 message(i18n("Export to phone finished!")); 829 message(i18n("Export to phone finished!"));
831 else 830 else
832 qDebug(i18n("Error exporting to phone")); 831 qDebug(i18n("Error exporting to phone"));
833} 832}
834void KABCore::beamVCard() 833void KABCore::beamVCard()
835{ 834{
836 QStringList uids = mViewManager->selectedUids(); 835 QStringList uids = mViewManager->selectedUids();
837 if ( !uids.isEmpty() ) 836 if ( !uids.isEmpty() )
838 beamVCard( uids ); 837 beamVCard( uids );
839} 838}
840 839
841 840
842void KABCore::beamVCard(const QStringList& uids) 841void KABCore::beamVCard(const QStringList& uids)
843{ 842{
844 843
845 // LR: we should use the /tmp dir on the Zaurus, 844 // LR: we should use the /tmp dir on the Zaurus,
846 // because: /tmp = RAM, (HOME)/kdepim = flash memory 845 // because: /tmp = RAM, (HOME)/kdepim = flash memory
847 846
848#ifdef DESKTOP_VERSION 847#ifdef DESKTOP_VERSION
849 QString fileName = locateLocal("tmp", "kapibeamfile.vcf"); 848 QString fileName = locateLocal("tmp", "kapibeamfile.vcf");
850#else 849#else
851 QString fileName = "/tmp/kapibeamfile.vcf"; 850 QString fileName = "/tmp/kapibeamfile.vcf";
852#endif 851#endif
853 852
854 KABC::VCardConverter converter; 853 KABC::VCardConverter converter;
855 QString description; 854 QString description;
856 QString datastream; 855 QString datastream;
857 for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) { 856 for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) {
858 KABC::Addressee a = mAddressBook->findByUid( *it ); 857 KABC::Addressee a = mAddressBook->findByUid( *it );
859 858
860 if ( a.isEmpty() ) 859 if ( a.isEmpty() )
861 continue; 860 continue;
862 861
863 if (description.isEmpty()) 862 if (description.isEmpty())
864 description = a.formattedName(); 863 description = a.formattedName();
865 864
866 QString vcard; 865 QString vcard;
867 converter.addresseeToVCard( a, vcard ); 866 converter.addresseeToVCard( a, vcard );
868 int start = 0; 867 int start = 0;
869 int next; 868 int next;
870 while ( (next = vcard.find("TYPE=", start) )>= 0 ) { 869 while ( (next = vcard.find("TYPE=", start) )>= 0 ) {
871 int semi = vcard.find(";", next); 870 int semi = vcard.find(";", next);
872 int dopp = vcard.find(":", next); 871 int dopp = vcard.find(":", next);
873 int sep; 872 int sep;
874 if ( semi < dopp && semi >= 0 ) 873 if ( semi < dopp && semi >= 0 )
875 sep = semi ; 874 sep = semi ;
876 else 875 else
877 sep = dopp; 876 sep = dopp;
878 datastream +=vcard.mid( start, next - start); 877 datastream +=vcard.mid( start, next - start);
879 datastream +=vcard.mid( next+5,sep -next -5 ).upper(); 878 datastream +=vcard.mid( next+5,sep -next -5 ).upper();
880 start = sep; 879 start = sep;
881 } 880 }
882 datastream += vcard.mid( start,vcard.length() ); 881 datastream += vcard.mid( start,vcard.length() );
883 } 882 }
884#ifndef DESKTOP_VERSION 883#ifndef DESKTOP_VERSION
885 QFile outFile(fileName); 884 QFile outFile(fileName);
886 if ( outFile.open(IO_WriteOnly) ) { 885 if ( outFile.open(IO_WriteOnly) ) {
887 datastream.replace ( QRegExp("VERSION:3.0") , "VERSION:2.1" ); 886 datastream.replace ( QRegExp("VERSION:3.0") , "VERSION:2.1" );
888 QTextStream t( &outFile ); // use a text stream 887 QTextStream t( &outFile ); // use a text stream
889 //t.setEncoding( QTextStream::UnicodeUTF8 ); 888 //t.setEncoding( QTextStream::UnicodeUTF8 );
890 t.setEncoding( QTextStream::Latin1 ); 889 t.setEncoding( QTextStream::Latin1 );
891 t <<datastream.latin1(); 890 t <<datastream.latin1();
892 outFile.close(); 891 outFile.close();
893 Ir *ir = new Ir( this ); 892 Ir *ir = new Ir( this );
894 connect( ir, SIGNAL( done(Ir*) ), this, SLOT( beamDone(Ir*) ) ); 893 connect( ir, SIGNAL( done(Ir*) ), this, SLOT( beamDone(Ir*) ) );
895 ir->send( fileName, description, "text/x-vCard" ); 894 ir->send( fileName, description, "text/x-vCard" );
896 } else { 895 } else {
897 qDebug("Error open temp beam file "); 896 qDebug("Error open temp beam file ");
898 return; 897 return;
899 } 898 }
900#endif 899#endif
901 900
902} 901}
903 902
904void KABCore::beamDone( Ir *ir ) 903void KABCore::beamDone( Ir *ir )
905{ 904{
906#ifndef DESKTOP_VERSION 905#ifndef DESKTOP_VERSION
907 delete ir; 906 delete ir;
908#endif 907#endif
909 topLevelWidget()->raise(); 908 topLevelWidget()->raise();
910 message( i18n("Beaming finished!") ); 909 message( i18n("Beaming finished!") );
911} 910}
912 911
913 912
914void KABCore::browse( const QString& url ) 913void KABCore::browse( const QString& url )
915{ 914{
916#ifndef KAB_EMBEDDED 915#ifndef KAB_EMBEDDED
917 kapp->invokeBrowser( url ); 916 kapp->invokeBrowser( url );
918#else //KAB_EMBEDDED 917#else //KAB_EMBEDDED
919 qDebug("KABCore::browse must be fixed"); 918 qDebug("KABCore::browse must be fixed");
920#endif //KAB_EMBEDDED 919#endif //KAB_EMBEDDED
921} 920}
922 921
923void KABCore::selectAllContacts() 922void KABCore::selectAllContacts()
924{ 923{
925 mViewManager->setSelected( QString::null, true ); 924 mViewManager->setSelected( QString::null, true );
926} 925}
927 926
928void KABCore::deleteContacts() 927void KABCore::deleteContacts()
929{ 928{
930 QStringList uidList = mViewManager->selectedUids(); 929 QStringList uidList = mViewManager->selectedUids();
931 deleteContacts( uidList ); 930 deleteContacts( uidList );
932} 931}
933 932
934void KABCore::deleteContacts( const QStringList &uids ) 933void KABCore::deleteContacts( const QStringList &uids )
935{ 934{
936 if ( uids.count() > 0 ) { 935 if ( uids.count() > 0 ) {
937 PwDeleteCommand *command = new PwDeleteCommand( mAddressBook, uids ); 936 PwDeleteCommand *command = new PwDeleteCommand( mAddressBook, uids );
938 UndoStack::instance()->push( command ); 937 UndoStack::instance()->push( command );
939 RedoStack::instance()->clear(); 938 RedoStack::instance()->clear();
940 939
941 // now if we deleted anything, refresh 940 // now if we deleted anything, refresh
942 setContactSelected( QString::null ); 941 setContactSelected( QString::null );
943 setModified( true ); 942 setModified( true );
944 } 943 }
945} 944}
946 945
947void KABCore::copyContacts() 946void KABCore::copyContacts()
948{ 947{
949 KABC::Addressee::List addrList = mViewManager->selectedAddressees(); 948 KABC::Addressee::List addrList = mViewManager->selectedAddressees();
950 949
951 QString clipText = AddresseeUtil::addresseesToClipboard( addrList ); 950 QString clipText = AddresseeUtil::addresseesToClipboard( addrList );
952 951
953 kdDebug(5720) << "KABCore::copyContacts: " << clipText << endl; 952 kdDebug(5720) << "KABCore::copyContacts: " << clipText << endl;
954 953
955 QClipboard *cb = QApplication::clipboard(); 954 QClipboard *cb = QApplication::clipboard();
956 cb->setText( clipText ); 955 cb->setText( clipText );
957} 956}
958 957
959void KABCore::cutContacts() 958void KABCore::cutContacts()
960{ 959{
961 QStringList uidList = mViewManager->selectedUids(); 960 QStringList uidList = mViewManager->selectedUids();
962 961
963//US if ( uidList.size() > 0 ) { 962//US if ( uidList.size() > 0 ) {
964 if ( uidList.count() > 0 ) { 963 if ( uidList.count() > 0 ) {
965 PwCutCommand *command = new PwCutCommand( mAddressBook, uidList ); 964 PwCutCommand *command = new PwCutCommand( mAddressBook, uidList );
966 UndoStack::instance()->push( command ); 965 UndoStack::instance()->push( command );
967 RedoStack::instance()->clear(); 966 RedoStack::instance()->clear();
968 967
969 setModified( true ); 968 setModified( true );
970 } 969 }
971} 970}
972 971
973void KABCore::pasteContacts() 972void KABCore::pasteContacts()
974{ 973{
975 QClipboard *cb = QApplication::clipboard(); 974 QClipboard *cb = QApplication::clipboard();
976 975
977 KABC::Addressee::List list = AddresseeUtil::clipboardToAddressees( cb->text() ); 976 KABC::Addressee::List list = AddresseeUtil::clipboardToAddressees( cb->text() );
978 977
979 pasteContacts( list ); 978 pasteContacts( list );
980} 979}
981 980
982void KABCore::pasteContacts( KABC::Addressee::List &list ) 981void KABCore::pasteContacts( KABC::Addressee::List &list )
983{ 982{
984 KABC::Resource *resource = requestResource( this ); 983 KABC::Resource *resource = requestResource( this );
985 KABC::Addressee::List::Iterator it; 984 KABC::Addressee::List::Iterator it;
986 for ( it = list.begin(); it != list.end(); ++it ) 985 for ( it = list.begin(); it != list.end(); ++it )
987 (*it).setResource( resource ); 986 (*it).setResource( resource );
988 987
989 PwPasteCommand *command = new PwPasteCommand( this, list ); 988 PwPasteCommand *command = new PwPasteCommand( this, list );
990 UndoStack::instance()->push( command ); 989 UndoStack::instance()->push( command );
991 RedoStack::instance()->clear(); 990 RedoStack::instance()->clear();
992 991
993 setModified( true ); 992 setModified( true );
994} 993}
995 994
996void KABCore::setWhoAmI() 995void KABCore::setWhoAmI()
997{ 996{
998 KABC::Addressee::List addrList = mViewManager->selectedAddressees(); 997 KABC::Addressee::List addrList = mViewManager->selectedAddressees();
999 998
1000 if ( addrList.count() > 1 ) { 999 if ( addrList.count() > 1 ) {
1001 KMessageBox::sorry( this, i18n( "Please select only one contact." ) ); 1000 KMessageBox::sorry( this, i18n( "Please select only one contact." ) );
1002 return; 1001 return;
1003 } 1002 }
1004 1003
1005 QString text( i18n( "<qt>Do you really want to use <b>%1</b> as your new personal contact?</qt>" ) ); 1004 QString text( i18n( "<qt>Do you really want to use <b>%1</b> as your new personal contact?</qt>" ) );
1006 if ( KMessageBox::questionYesNo( this, text.arg( addrList[ 0 ].assembledName() ) ) == KMessageBox::Yes ) 1005 if ( KMessageBox::questionYesNo( this, text.arg( addrList[ 0 ].assembledName() ) ) == KMessageBox::Yes )
1007 static_cast<KABC::StdAddressBook*>( KABC::StdAddressBook::self() )->setWhoAmI( addrList[ 0 ] ); 1006 static_cast<KABC::StdAddressBook*>( KABC::StdAddressBook::self() )->setWhoAmI( addrList[ 0 ] );
1008} 1007}
1009void KABCore::editCategories() 1008void KABCore::editCategories()
1010{ 1009{
1011 KPIM::CategoryEditDialog dlg ( KABPrefs::instance(), this, "", true ); 1010 KPIM::CategoryEditDialog dlg ( KABPrefs::instance(), this, "", true );
1012 dlg.exec(); 1011 dlg.exec();
1013} 1012}
1014void KABCore::setCategories() 1013void KABCore::setCategories()
1015{ 1014{
1015
1016 QStringList uids;
1017 XXPortSelectDialog dlgx( this, false, this );
1018 if ( dlgx.exec() )
1019 uids = dlgx.uids();
1020 else
1021 return;
1022 if ( uids.isEmpty() )
1023 return;
1024 // qDebug("count %d ", uids.count());
1025
1026
1016 KPIM::CategorySelectDialog dlg( KABPrefs::instance(), this, "", true ); 1027 KPIM::CategorySelectDialog dlg( KABPrefs::instance(), this, "", true );
1017 if ( !dlg.exec() ) { 1028 if ( !dlg.exec() ) {
1018 message( i18n("Setting categories cancelled") ); 1029 message( i18n("Setting categories cancelled") );
1019 return; 1030 return;
1020 } 1031 }
1021 bool merge = false; 1032 bool merge = false;
1022 QString msg = i18n( "Merge with existing categories?" ); 1033 QString msg = i18n( "Merge with existing categories?" );
1023 if ( KMessageBox::questionYesNo( this, msg ) == KMessageBox::Yes ) 1034 if ( KMessageBox::questionYesNo( this, msg ) == KMessageBox::Yes )
1024 merge = true; 1035 merge = true;
1025 1036
1026 message( i18n("Setting categories ... please wait!") ); 1037 message( i18n("Setting categories ... please wait!") );
1027 QStringList categories = dlg.selectedCategories(); 1038 QStringList categories = dlg.selectedCategories();
1028 1039
1029 QStringList uids = mViewManager->selectedUids(); 1040 //QStringList uids = mViewManager->selectedUids();
1030 QStringList::Iterator it; 1041 QStringList::Iterator it;
1031 for ( it = uids.begin(); it != uids.end(); ++it ) { 1042 for ( it = uids.begin(); it != uids.end(); ++it ) {
1032 KABC::Addressee addr = mAddressBook->findByUid( *it ); 1043 KABC::Addressee addr = mAddressBook->findByUid( *it );
1033 if ( !addr.isEmpty() ) { 1044 if ( !addr.isEmpty() ) {
1034 if ( !merge ) 1045 if ( !merge )
1035 addr.setCategories( categories ); 1046 addr.setCategories( categories );
1036 else { 1047 else {
1037 QStringList addrCategories = addr.categories(); 1048 QStringList addrCategories = addr.categories();
1038 QStringList::Iterator catIt; 1049 QStringList::Iterator catIt;
1039 for ( catIt = categories.begin(); catIt != categories.end(); ++catIt ) { 1050 for ( catIt = categories.begin(); catIt != categories.end(); ++catIt ) {
1040 if ( !addrCategories.contains( *catIt ) ) 1051 if ( !addrCategories.contains( *catIt ) )
1041 addrCategories.append( *catIt ); 1052 addrCategories.append( *catIt );
1042 } 1053 }
1043 addr.setCategories( addrCategories ); 1054 addr.setCategories( addrCategories );
1044 } 1055 }
1045 mAddressBook->insertAddressee( addr ); 1056 mAddressBook->insertAddressee( addr );
1046 } 1057 }
1047 } 1058 }
1048 1059
1049 if ( uids.count() > 0 ) 1060 if ( uids.count() > 0 )
1050 setModified( true ); 1061 setModified( true );
1051 message( i18n("Setting categories completed!") ); 1062 message( i18n("Setting categories completed!") );
1052} 1063}
1053 1064
1054void KABCore::setSearchFields( const KABC::Field::List &fields ) 1065void KABCore::setSearchFields( const KABC::Field::List &fields )
1055{ 1066{
1056 mIncSearchWidget->setFields( fields ); 1067 mIncSearchWidget->setFields( fields );
1057} 1068}
1058 1069
1059void KABCore::incrementalSearch( const QString& text ) 1070void KABCore::incrementalSearch( const QString& text )
1060{ 1071{
1061 mViewManager->doSearch( text, mIncSearchWidget->currentField() ); 1072 mViewManager->doSearch( text, mIncSearchWidget->currentField() );
1062} 1073}
1063 1074
1064void KABCore::setModified() 1075void KABCore::setModified()
1065{ 1076{
1066 setModified( true ); 1077 setModified( true );
1067} 1078}
1068 1079
1069void KABCore::setModifiedWOrefresh() 1080void KABCore::setModifiedWOrefresh()
1070{ 1081{
1071 // qDebug("KABCore::setModifiedWOrefresh() "); 1082 // qDebug("KABCore::setModifiedWOrefresh() ");
1072 mModified = true; 1083 mModified = true;
1073 mActionSave->setEnabled( mModified ); 1084 mActionSave->setEnabled( mModified );
1074#ifdef DESKTOP_VERSION 1085#ifdef DESKTOP_VERSION
1075 mDetails->refreshView(); 1086 mDetails->refreshView();
1076#endif 1087#endif
1077 1088
1078} 1089}
1079void KABCore::setModified( bool modified ) 1090void KABCore::setModified( bool modified )
1080{ 1091{
1081 mModified = modified; 1092 mModified = modified;
1082 mActionSave->setEnabled( mModified ); 1093 mActionSave->setEnabled( mModified );
1083 1094
1084 if ( modified ) 1095 if ( modified )
1085 mJumpButtonBar->recreateButtons(); 1096 mJumpButtonBar->recreateButtons();
1086 1097
1087 mViewManager->refreshView(); 1098 mViewManager->refreshView();
1088 mDetails->refreshView(); 1099 mDetails->refreshView();
1089 1100
1090} 1101}
1091 1102
1092bool KABCore::modified() const 1103bool KABCore::modified() const
1093{ 1104{
1094 return mModified; 1105 return mModified;
1095} 1106}
1096 1107
1097void KABCore::contactModified( const KABC::Addressee &addr ) 1108void KABCore::contactModified( const KABC::Addressee &addr )
1098{ 1109{
1099 1110
1100 Command *command = 0; 1111 Command *command = 0;
1101 QString uid; 1112 QString uid;
1102 1113
1103 // check if it exists already 1114 // check if it exists already
1104 KABC::Addressee origAddr = mAddressBook->findByUid( addr.uid() ); 1115 KABC::Addressee origAddr = mAddressBook->findByUid( addr.uid() );
1105 if ( origAddr.isEmpty() ) 1116 if ( origAddr.isEmpty() )
1106 command = new PwNewCommand( mAddressBook, addr ); 1117 command = new PwNewCommand( mAddressBook, addr );
1107 else { 1118 else {
1108 command = new PwEditCommand( mAddressBook, origAddr, addr ); 1119 command = new PwEditCommand( mAddressBook, origAddr, addr );
1109 uid = addr.uid(); 1120 uid = addr.uid();
1110 } 1121 }
1111 1122
1112 UndoStack::instance()->push( command ); 1123 UndoStack::instance()->push( command );
1113 RedoStack::instance()->clear(); 1124 RedoStack::instance()->clear();
1114 1125
1115 setModified( true ); 1126 setModified( true );
1116} 1127}
1117 1128
1118void KABCore::newContact() 1129void KABCore::newContact()
1119{ 1130{
1120 1131
1121 1132
1122 QPtrList<KABC::Resource> kabcResources = mAddressBook->resources(); 1133 QPtrList<KABC::Resource> kabcResources = mAddressBook->resources();
1123 1134
1124 QPtrList<KRES::Resource> kresResources; 1135 QPtrList<KRES::Resource> kresResources;
1125 QPtrListIterator<KABC::Resource> it( kabcResources ); 1136 QPtrListIterator<KABC::Resource> it( kabcResources );
1126 KABC::Resource *resource; 1137 KABC::Resource *resource;
1127 while ( ( resource = it.current() ) != 0 ) { 1138 while ( ( resource = it.current() ) != 0 ) {
1128 ++it; 1139 ++it;
1129 if ( !resource->readOnly() ) { 1140 if ( !resource->readOnly() ) {
1130 KRES::Resource *res = static_cast<KRES::Resource*>( resource ); 1141 KRES::Resource *res = static_cast<KRES::Resource*>( resource );
1131 if ( res ) 1142 if ( res )
1132 kresResources.append( res ); 1143 kresResources.append( res );
1133 } 1144 }
1134 } 1145 }
1135 1146
1136 KRES::Resource *res = KRES::SelectDialog::getResource( kresResources, this ); 1147 KRES::Resource *res = KRES::SelectDialog::getResource( kresResources, this );
1137 resource = static_cast<KABC::Resource*>( res ); 1148 resource = static_cast<KABC::Resource*>( res );
1138 1149
1139 if ( resource ) { 1150 if ( resource ) {
1140 KABC::Addressee addr; 1151 KABC::Addressee addr;
1141 addr.setResource( resource ); 1152 addr.setResource( resource );
1142 mEditorDialog->setAddressee( addr ); 1153 mEditorDialog->setAddressee( addr );
1143 KApplication::execDialog ( mEditorDialog ); 1154 KApplication::execDialog ( mEditorDialog );
1144 1155
1145 } else 1156 } else
1146 return; 1157 return;
1147 1158
1148 // mEditorDict.insert( dialog->addressee().uid(), dialog ); 1159 // mEditorDict.insert( dialog->addressee().uid(), dialog );
1149 1160
1150 1161
1151} 1162}
1152 1163
1153void KABCore::addEmail( QString aStr ) 1164void KABCore::addEmail( QString aStr )
1154{ 1165{
1155#ifndef KAB_EMBEDDED 1166#ifndef KAB_EMBEDDED
1156 QString fullName, email; 1167 QString fullName, email;
1157 1168
1158 KABC::Addressee::parseEmailAddress( aStr, fullName, email ); 1169 KABC::Addressee::parseEmailAddress( aStr, fullName, email );
1159 1170
1160 // Try to lookup the addressee matching the email address 1171 // Try to lookup the addressee matching the email address
1161 bool found = false; 1172 bool found = false;
1162 QStringList emailList; 1173 QStringList emailList;
1163 KABC::AddressBook::Iterator it; 1174 KABC::AddressBook::Iterator it;
1164 for ( it = mAddressBook->begin(); !found && (it != mAddressBook->end()); ++it ) { 1175 for ( it = mAddressBook->begin(); !found && (it != mAddressBook->end()); ++it ) {
1165 emailList = (*it).emails(); 1176 emailList = (*it).emails();
1166 if ( emailList.contains( email ) > 0 ) { 1177 if ( emailList.contains( email ) > 0 ) {
1167 found = true; 1178 found = true;
1168 (*it).setNameFromString( fullName ); 1179 (*it).setNameFromString( fullName );
1169 editContact( (*it).uid() ); 1180 editContact( (*it).uid() );
1170 } 1181 }
1171 } 1182 }
1172 1183
1173 if ( !found ) { 1184 if ( !found ) {
1174 KABC::Addressee addr; 1185 KABC::Addressee addr;
1175 addr.setNameFromString( fullName ); 1186 addr.setNameFromString( fullName );
1176 addr.insertEmail( email, true ); 1187 addr.insertEmail( email, true );
1177 1188
1178 mAddressBook->insertAddressee( addr ); 1189 mAddressBook->insertAddressee( addr );
1179 mViewManager->refreshView( addr.uid() ); 1190 mViewManager->refreshView( addr.uid() );
1180 editContact( addr.uid() ); 1191 editContact( addr.uid() );
1181 } 1192 }
1182#else //KAB_EMBEDDED 1193#else //KAB_EMBEDDED
1183 qDebug("KABCore::addEmail finsih method"); 1194 qDebug("KABCore::addEmail finsih method");
1184#endif //KAB_EMBEDDED 1195#endif //KAB_EMBEDDED
1185} 1196}
1186 1197
1187void KABCore::importVCard( const KURL &url, bool showPreview ) 1198void KABCore::importVCard( const KURL &url, bool showPreview )
1188{ 1199{
1189 mXXPortManager->importVCard( url, showPreview ); 1200 mXXPortManager->importVCard( url, showPreview );
1190} 1201}
1191void KABCore::importFromOL() 1202void KABCore::importFromOL()
1192{ 1203{
1193#ifdef _WIN32_ 1204#ifdef _WIN32_
1194 KAImportOLdialog* idgl = new KAImportOLdialog( i18n("Import Contacts from OL"), mAddressBook, this ); 1205 KAImportOLdialog* idgl = new KAImportOLdialog( i18n("Import Contacts from OL"), mAddressBook, this );
1195 idgl->exec(); 1206 idgl->exec();
1196 KABC::Addressee::List list = idgl->getAddressList(); 1207 KABC::Addressee::List list = idgl->getAddressList();
1197 if ( list.count() > 0 ) { 1208 if ( list.count() > 0 ) {
1198 KABC::Addressee::List listNew; 1209 KABC::Addressee::List listNew;
1199 KABC::Addressee::List listExisting; 1210 KABC::Addressee::List listExisting;
1200 KABC::Addressee::List::Iterator it; 1211 KABC::Addressee::List::Iterator it;
1201 KABC::AddressBook::Iterator iter; 1212 KABC::AddressBook::Iterator iter;
1202 for ( it = list.begin(); it != list.end(); ++it ) { 1213 for ( it = list.begin(); it != list.end(); ++it ) {
1203 if ( mAddressBook->findByUid((*it).uid() ).isEmpty()) 1214 if ( mAddressBook->findByUid((*it).uid() ).isEmpty())
1204 listNew.append( (*it) ); 1215 listNew.append( (*it) );
1205 else 1216 else
1206 listExisting.append( (*it) ); 1217 listExisting.append( (*it) );
1207 } 1218 }
1208 if ( listExisting.count() > 0 ) 1219 if ( listExisting.count() > 0 )
1209 KMessageBox::information( this, i18n("%1 contacts not added to addressbook\nbecause they were already in the addressbook!").arg( listExisting.count() )); 1220 KMessageBox::information( this, i18n("%1 contacts not added to addressbook\nbecause they were already in the addressbook!").arg( listExisting.count() ));
1210 if ( listNew.count() > 0 ) { 1221 if ( listNew.count() > 0 ) {
1211 pasteWithNewUid = false; 1222 pasteWithNewUid = false;
1212 pasteContacts( listNew ); 1223 pasteContacts( listNew );
1213 pasteWithNewUid = true; 1224 pasteWithNewUid = true;
1214 } 1225 }
1215 } 1226 }
1216 delete idgl; 1227 delete idgl;
1217#endif 1228#endif
1218} 1229}
1219 1230
1220void KABCore::importVCard( const QString &vCard, bool showPreview ) 1231void KABCore::importVCard( const QString &vCard, bool showPreview )
1221{ 1232{
1222 mXXPortManager->importVCard( vCard, showPreview ); 1233 mXXPortManager->importVCard( vCard, showPreview );
1223} 1234}
1224 1235
1225//US added a second method without defaultparameter 1236//US added a second method without defaultparameter
1226void KABCore::editContact2() { 1237void KABCore::editContact2() {
1227 editContact( QString::null ); 1238 editContact( QString::null );
1228} 1239}
1229 1240
1230void KABCore::editContact( const QString &uid ) 1241void KABCore::editContact( const QString &uid )
1231{ 1242{
1232 1243
1233 if ( mExtensionManager->isQuickEditVisible() ) 1244 if ( mExtensionManager->isQuickEditVisible() )
1234 return; 1245 return;
1235 1246
1236 // First, locate the contact entry 1247 // First, locate the contact entry
1237 QString localUID = uid; 1248 QString localUID = uid;
1238 if ( localUID.isNull() ) { 1249 if ( localUID.isNull() ) {
1239 QStringList uidList = mViewManager->selectedUids(); 1250 QStringList uidList = mViewManager->selectedUids();
1240 if ( uidList.count() > 0 ) 1251 if ( uidList.count() > 0 )
1241 localUID = *( uidList.at( 0 ) ); 1252 localUID = *( uidList.at( 0 ) );
1242 } 1253 }
1243 1254
1244 KABC::Addressee addr = mAddressBook->findByUid( localUID ); 1255 KABC::Addressee addr = mAddressBook->findByUid( localUID );
1245 if ( !addr.isEmpty() ) { 1256 if ( !addr.isEmpty() ) {
1246 mEditorDialog->setAddressee( addr ); 1257 mEditorDialog->setAddressee( addr );
1247 KApplication::execDialog ( mEditorDialog ); 1258 KApplication::execDialog ( mEditorDialog );
1248 } 1259 }
1249} 1260}
1250 1261
1251/** 1262/**
1252 Shows or edits the detail view for the given uid. If the uid is QString::null, 1263 Shows or edits the detail view for the given uid. If the uid is QString::null,
1253 the method will try to find a selected addressee in the view. 1264 the method will try to find a selected addressee in the view.
1254 */ 1265 */
1255void KABCore::executeContact( const QString &uid /*US = QString::null*/ ) 1266void KABCore::executeContact( const QString &uid /*US = QString::null*/ )
1256{ 1267{
1257 if ( mMultipleViewsAtOnce ) 1268 if ( mMultipleViewsAtOnce )
1258 { 1269 {
1259 editContact( uid ); 1270 editContact( uid );
1260 } 1271 }
1261 else 1272 else
1262 { 1273 {
1263 setDetailsVisible( true ); 1274 setDetailsVisible( true );
1264 mActionDetails->setChecked(true); 1275 mActionDetails->setChecked(true);
1265 } 1276 }
1266 1277
1267} 1278}
1268 1279
1269void KABCore::save() 1280void KABCore::save()
1270{ 1281{
1271 if (syncManager->blockSave()) 1282 if (syncManager->blockSave())
1272 return; 1283 return;
1273 if ( !mModified ) 1284 if ( !mModified )
1274 return; 1285 return;
1275 1286
1276 syncManager->setBlockSave(true); 1287 syncManager->setBlockSave(true);
1277 QString text = i18n( "There was an error while attempting to save\n the " 1288 QString text = i18n( "There was an error while attempting to save\n the "
1278 "address book. Please check that some \nother application is " 1289 "address book. Please check that some \nother application is "
1279 "not using it. " ); 1290 "not using it. " );
1280 message(i18n("Saving addressbook ... ")); 1291 message(i18n("Saving addressbook ... "));
1281#ifndef KAB_EMBEDDED 1292#ifndef KAB_EMBEDDED
1282 KABC::StdAddressBook *b = dynamic_cast<KABC::StdAddressBook*>( mAddressBook ); 1293 KABC::StdAddressBook *b = dynamic_cast<KABC::StdAddressBook*>( mAddressBook );
1283 if ( !b || !b->save() ) { 1294 if ( !b || !b->save() ) {
1284 KMessageBox::error( this, text, i18n( "Unable to Save" ) ); 1295 KMessageBox::error( this, text, i18n( "Unable to Save" ) );
1285 } 1296 }
1286#else //KAB_EMBEDDED 1297#else //KAB_EMBEDDED
1287 KABC::StdAddressBook *b = (KABC::StdAddressBook*)( mAddressBook ); 1298 KABC::StdAddressBook *b = (KABC::StdAddressBook*)( mAddressBook );
1288 if ( !b || !b->save() ) { 1299 if ( !b || !b->save() ) {
1289 QMessageBox::critical( this, i18n( "Unable to Save" ), text, i18n("Ok")); 1300 QMessageBox::critical( this, i18n( "Unable to Save" ), text, i18n("Ok"));
1290 } 1301 }
1291#endif //KAB_EMBEDDED 1302#endif //KAB_EMBEDDED
1292 1303
1293 message(i18n("Addressbook saved!")); 1304 message(i18n("Addressbook saved!"));
1294 setModified( false ); 1305 setModified( false );
1295 syncManager->setBlockSave(false); 1306 syncManager->setBlockSave(false);
1296} 1307}
1297 1308
1298 1309
1299void KABCore::undo() 1310void KABCore::undo()
1300{ 1311{
1301 UndoStack::instance()->undo(); 1312 UndoStack::instance()->undo();
1302 1313
1303 // Refresh the view 1314 // Refresh the view
1304 mViewManager->refreshView(); 1315 mViewManager->refreshView();
1305} 1316}
1306 1317
1307void KABCore::redo() 1318void KABCore::redo()
1308{ 1319{
1309 RedoStack::instance()->redo(); 1320 RedoStack::instance()->redo();
1310 1321
1311 // Refresh the view 1322 // Refresh the view
1312 mViewManager->refreshView(); 1323 mViewManager->refreshView();
1313} 1324}
1314 1325
1315void KABCore::setJumpButtonBarVisible( bool visible ) 1326void KABCore::setJumpButtonBarVisible( bool visible )
1316{ 1327{
1317 if (mMultipleViewsAtOnce) 1328 if (mMultipleViewsAtOnce)
1318 { 1329 {
1319 if ( visible ) 1330 if ( visible )
1320 mJumpButtonBar->show(); 1331 mJumpButtonBar->show();
1321 else 1332 else
1322 mJumpButtonBar->hide(); 1333 mJumpButtonBar->hide();
1323 } 1334 }
1324 else 1335 else
1325 { 1336 {
1326 // show the jumpbar only if "the details are hidden" == "viewmanager are shown" 1337 // show the jumpbar only if "the details are hidden" == "viewmanager are shown"
1327 if (mViewManager->isVisible()) 1338 if (mViewManager->isVisible())
1328 { 1339 {
1329 if ( visible ) 1340 if ( visible )
1330 mJumpButtonBar->show(); 1341 mJumpButtonBar->show();
1331 else 1342 else
1332 mJumpButtonBar->hide(); 1343 mJumpButtonBar->hide();
1333 } 1344 }
1334 else 1345 else
1335 { 1346 {
1336 mJumpButtonBar->hide(); 1347 mJumpButtonBar->hide();
1337 } 1348 }
1338 } 1349 }
1339} 1350}
1340 1351
1341 1352
1342void KABCore::setDetailsToState() 1353void KABCore::setDetailsToState()
1343{ 1354{
1344 setDetailsVisible( mActionDetails->isChecked() ); 1355 setDetailsVisible( mActionDetails->isChecked() );
1345} 1356}
1346void KABCore::setDetailsToggle() 1357void KABCore::setDetailsToggle()
1347{ 1358{
1348 mActionDetails->setChecked( !mActionDetails->isChecked() ); 1359 mActionDetails->setChecked( !mActionDetails->isChecked() );
1349 setDetailsToState(); 1360 setDetailsToState();
1350} 1361}
1351 1362
1352 1363
1353 1364
1354void KABCore::setDetailsVisible( bool visible ) 1365void KABCore::setDetailsVisible( bool visible )
1355{ 1366{
1356 if (visible && mDetails->isHidden()) 1367 if (visible && mDetails->isHidden())
1357 { 1368 {
1358 KABC::Addressee::List addrList = mViewManager->selectedAddressees(); 1369 KABC::Addressee::List addrList = mViewManager->selectedAddressees();
1359 if ( addrList.count() > 0 ) 1370 if ( addrList.count() > 0 )
1360 mDetails->setAddressee( addrList[ 0 ] ); 1371 mDetails->setAddressee( addrList[ 0 ] );
1361 } 1372 }
1362 1373
1363 // mMultipleViewsAtOnce=false: mDetails is always visible. But we switch between 1374 // mMultipleViewsAtOnce=false: mDetails is always visible. But we switch between
1364 // the listview and the detailview. We do that by changing the splitbar size. 1375 // the listview and the detailview. We do that by changing the splitbar size.
1365 if (mMultipleViewsAtOnce) 1376 if (mMultipleViewsAtOnce)
1366 { 1377 {
1367 if ( visible ) 1378 if ( visible )
1368 mDetails->show(); 1379 mDetails->show();
1369 else 1380 else
1370 mDetails->hide(); 1381 mDetails->hide();
1371 } 1382 }
1372 else 1383 else
1373 { 1384 {
1374 if ( visible ) { 1385 if ( visible ) {
1375 mViewManager->hide(); 1386 mViewManager->hide();
1376 mDetails->show(); 1387 mDetails->show();
1377 mIncSearchWidget->setFocus(); 1388 mIncSearchWidget->setFocus();
1378 } 1389 }
1379 else { 1390 else {
1380 mViewManager->show(); 1391 mViewManager->show();
1381 mDetails->hide(); 1392 mDetails->hide();
1382 mViewManager->setFocusAV(); 1393 mViewManager->setFocusAV();
1383 } 1394 }
1384 setJumpButtonBarVisible( !visible ); 1395 setJumpButtonBarVisible( !visible );
1385 } 1396 }
1386 1397
1387} 1398}
1388 1399
1389void KABCore::extensionChanged( int id ) 1400void KABCore::extensionChanged( int id )
1390{ 1401{
1391 //change the details view only for non desktop systems 1402 //change the details view only for non desktop systems
1392#ifndef DESKTOP_VERSION 1403#ifndef DESKTOP_VERSION
1393 1404
1394 if (id == 0) 1405 if (id == 0)
1395 { 1406 {
1396 //the user disabled the extension. 1407 //the user disabled the extension.
1397 1408
1398 if (mMultipleViewsAtOnce) 1409 if (mMultipleViewsAtOnce)
1399 { // enable detailsview again 1410 { // enable detailsview again
1400 setDetailsVisible( true ); 1411 setDetailsVisible( true );
1401 mActionDetails->setChecked( true ); 1412 mActionDetails->setChecked( true );
1402 } 1413 }
1403 else 1414 else
1404 { //go back to the listview 1415 { //go back to the listview
1405 setDetailsVisible( false ); 1416 setDetailsVisible( false );
1406 mActionDetails->setChecked( false ); 1417 mActionDetails->setChecked( false );
1407 mActionDetails->setEnabled(true); 1418 mActionDetails->setEnabled(true);
1408 } 1419 }
1409 1420
1410 } 1421 }
1411 else 1422 else
1412 { 1423 {
1413 //the user enabled the extension. 1424 //the user enabled the extension.
@@ -1727,768 +1738,772 @@ void KABCore::initGUI()
1727 viewSpace->setStretchFactor( mViewManager, 1 ); 1738 viewSpace->setStretchFactor( mViewManager, 1 );
1728 1739
1729 mDetails = new ViewContainer( this ); 1740 mDetails = new ViewContainer( this );
1730 1741
1731 topLayout->addWidget( viewSpace ); 1742 topLayout->addWidget( viewSpace );
1732// topLayout->setStretchFactor( mDetailsSplitter, 100 ); 1743// topLayout->setStretchFactor( mDetailsSplitter, 100 );
1733 topLayout->addWidget( mDetails ); 1744 topLayout->addWidget( mDetails );
1734#endif //KAB_NOSPLITTER 1745#endif //KAB_NOSPLITTER
1735*/ 1746*/
1736 1747
1737 syncManager = new KSyncManager((QWidget*)this, (KSyncInterface*)this, KSyncManager::KAPI, KABPrefs::instance(), syncMenu); 1748 syncManager = new KSyncManager((QWidget*)this, (KSyncInterface*)this, KSyncManager::KAPI, KABPrefs::instance(), syncMenu);
1738 syncManager->setBlockSave(false); 1749 syncManager->setBlockSave(false);
1739 1750
1740 connect(syncManager , SIGNAL( request_file() ), this, SLOT( syncFileRequest() ) ); 1751 connect(syncManager , SIGNAL( request_file() ), this, SLOT( syncFileRequest() ) );
1741 connect(syncManager , SIGNAL( getFile( bool )), this, SLOT(getFile( bool ) ) ); 1752 connect(syncManager , SIGNAL( getFile( bool )), this, SLOT(getFile( bool ) ) );
1742 syncManager->setDefaultFileName( sentSyncFile()); 1753 syncManager->setDefaultFileName( sentSyncFile());
1743 //connect(syncManager , SIGNAL( ), this, SLOT( ) ); 1754 //connect(syncManager , SIGNAL( ), this, SLOT( ) );
1744 1755
1745#endif //KAB_EMBEDDED 1756#endif //KAB_EMBEDDED
1746 initActions(); 1757 initActions();
1747 1758
1748#ifdef KAB_EMBEDDED 1759#ifdef KAB_EMBEDDED
1749 addActionsManually(); 1760 addActionsManually();
1750 //US make sure the export and import menues are initialized before creating the xxPortManager. 1761 //US make sure the export and import menues are initialized before creating the xxPortManager.
1751 mXXPortManager = new XXPortManager( this, this ); 1762 mXXPortManager = new XXPortManager( this, this );
1752 1763
1753 // LR mIncSearchWidget = new IncSearchWidget( mMainWindow->getIconToolBar() ); 1764 // LR mIncSearchWidget = new IncSearchWidget( mMainWindow->getIconToolBar() );
1754 //mMainWindow->toolBar()->insertWidget(-1, 4, mIncSearchWidget); 1765 //mMainWindow->toolBar()->insertWidget(-1, 4, mIncSearchWidget);
1755 // mActionQuit->plug ( mMainWindow->toolBar()); 1766 // mActionQuit->plug ( mMainWindow->toolBar());
1756 //mIncSearchWidget = new IncSearchWidget( mMainWindow->toolBar() ); 1767 //mIncSearchWidget = new IncSearchWidget( mMainWindow->toolBar() );
1757 //mMainWindow->toolBar()->insertWidget(-1, 0, mIncSearchWidget); 1768 //mMainWindow->toolBar()->insertWidget(-1, 0, mIncSearchWidget);
1758 // mIncSearchWidget->hide(); 1769 // mIncSearchWidget->hide();
1759 connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ), 1770 connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ),
1760 SLOT( incrementalSearch( const QString& ) ) ); 1771 SLOT( incrementalSearch( const QString& ) ) );
1761 connect( mIncSearchWidget, SIGNAL( scrollUP() ),mViewManager, SLOT( scrollUP() ) ); 1772 connect( mIncSearchWidget, SIGNAL( scrollUP() ),mViewManager, SLOT( scrollUP() ) );
1762 connect( mIncSearchWidget, SIGNAL( scrollDOWN() ),mViewManager, SLOT( scrollDOWN() ) ); 1773 connect( mIncSearchWidget, SIGNAL( scrollDOWN() ),mViewManager, SLOT( scrollDOWN() ) );
1763 1774
1764 mJumpButtonBar = new JumpButtonBar( this, this ); 1775 mJumpButtonBar = new JumpButtonBar( this, this );
1765 1776
1766 topLayout->addWidget( mJumpButtonBar ); 1777 topLayout->addWidget( mJumpButtonBar );
1767//US topLayout->setStretchFactor( mJumpButtonBar, 10 ); 1778//US topLayout->setStretchFactor( mJumpButtonBar, 10 );
1768 1779
1769// mMainWindow->getIconToolBar()->raise(); 1780// mMainWindow->getIconToolBar()->raise();
1770 1781
1771#endif //KAB_EMBEDDED 1782#endif //KAB_EMBEDDED
1772 1783
1773} 1784}
1774void KABCore::initActions() 1785void KABCore::initActions()
1775{ 1786{
1776//US qDebug("KABCore::initActions(): mIsPart %i", mIsPart); 1787//US qDebug("KABCore::initActions(): mIsPart %i", mIsPart);
1777 1788
1778#ifndef KAB_EMBEDDED 1789#ifndef KAB_EMBEDDED
1779 connect( QApplication::clipboard(), SIGNAL( dataChanged() ), 1790 connect( QApplication::clipboard(), SIGNAL( dataChanged() ),
1780 SLOT( clipboardDataChanged() ) ); 1791 SLOT( clipboardDataChanged() ) );
1781#endif //KAB_EMBEDDED 1792#endif //KAB_EMBEDDED
1782 1793
1783 // file menu 1794 // file menu
1784 if ( mIsPart ) { 1795 if ( mIsPart ) {
1785 mActionMail = new KAction( i18n( "&Mail" ), "mail_generic", 0, this, 1796 mActionMail = new KAction( i18n( "&Mail" ), "mail_generic", 0, this,
1786 SLOT( sendMail() ), actionCollection(), 1797 SLOT( sendMail() ), actionCollection(),
1787 "kaddressbook_mail" ); 1798 "kaddressbook_mail" );
1788 mActionPrint = new KAction( i18n( "&Print" ), "fileprint", CTRL + Key_P, this, 1799 mActionPrint = new KAction( i18n( "&Print" ), "fileprint", CTRL + Key_P, this,
1789 SLOT( print() ), actionCollection(), "kaddressbook_print" ); 1800 SLOT( print() ), actionCollection(), "kaddressbook_print" );
1790 1801
1791 } else { 1802 } else {
1792 mActionMail = KStdAction::mail( this, SLOT( sendMail() ), actionCollection() ); 1803 mActionMail = KStdAction::mail( this, SLOT( sendMail() ), actionCollection() );
1793 mActionPrint = KStdAction::print( this, SLOT( print() ), actionCollection() ); 1804 mActionPrint = KStdAction::print( this, SLOT( print() ), actionCollection() );
1794 } 1805 }
1795 1806
1796 1807
1797 mActionSave = new KAction( i18n( "&Save" ), "filesave", CTRL+Key_S, this, 1808 mActionSave = new KAction( i18n( "&Save" ), "filesave", CTRL+Key_S, this,
1798 SLOT( save() ), actionCollection(), "file_sync" ); 1809 SLOT( save() ), actionCollection(), "file_sync" );
1799 1810
1800 mActionNewContact = new KAction( i18n( "&New Contact..." ), "filenew", CTRL+Key_N, this, 1811 mActionNewContact = new KAction( i18n( "&New Contact..." ), "filenew", CTRL+Key_N, this,
1801 SLOT( newContact() ), actionCollection(), "file_new_contact" ); 1812 SLOT( newContact() ), actionCollection(), "file_new_contact" );
1802 1813
1803 mActionMailVCard = new KAction(i18n("Mail &vCard..."), "mail_post_to", 0, 1814 mActionMailVCard = new KAction(i18n("Mail &vCard..."), "mail_post_to", 0,
1804 this, SLOT( mailVCard() ), 1815 this, SLOT( mailVCard() ),
1805 actionCollection(), "file_mail_vcard"); 1816 actionCollection(), "file_mail_vcard");
1806 1817
1807 mActionExport2phone = new KAction( i18n( "Export to phone" ), "ex2phone", 0, this, 1818 mActionExport2phone = new KAction( i18n( "Export to phone" ), "ex2phone", 0, this,
1808 SLOT( export2phone() ), actionCollection(), 1819 SLOT( export2phone() ), actionCollection(),
1809 "kaddressbook_ex2phone" ); 1820 "kaddressbook_ex2phone" );
1810 1821
1811 mActionBeamVCard = 0; 1822 mActionBeamVCard = 0;
1812 mActionBeam = 0; 1823 mActionBeam = 0;
1813 1824
1814#ifndef DESKTOP_VERSION 1825#ifndef DESKTOP_VERSION
1815 if ( Ir::supported() ) { 1826 if ( Ir::supported() ) {
1816 mActionBeamVCard = new KAction( i18n( "Beam selected v&Card(s)" ), "beam", 0, this, 1827 mActionBeamVCard = new KAction( i18n( "Beam selected v&Card(s)" ), "beam", 0, this,
1817 SLOT( beamVCard() ), actionCollection(), 1828 SLOT( beamVCard() ), actionCollection(),
1818 "kaddressbook_beam_vcard" ); 1829 "kaddressbook_beam_vcard" );
1819 1830
1820 mActionBeam = new KAction( i18n( "&Beam personal vCard" ), "beam", 0, this, 1831 mActionBeam = new KAction( i18n( "&Beam personal vCard" ), "beam", 0, this,
1821 SLOT( beamMySelf() ), actionCollection(), 1832 SLOT( beamMySelf() ), actionCollection(),
1822 "kaddressbook_beam_myself" ); 1833 "kaddressbook_beam_myself" );
1823 } 1834 }
1824#endif 1835#endif
1825 1836
1826 mActionEditAddressee = new KAction( i18n( "&Edit Contact..." ), "edit", 0, 1837 mActionEditAddressee = new KAction( i18n( "&Edit Contact..." ), "edit", 0,
1827 this, SLOT( editContact2() ), 1838 this, SLOT( editContact2() ),
1828 actionCollection(), "file_properties" ); 1839 actionCollection(), "file_properties" );
1829 1840
1830#ifdef KAB_EMBEDDED 1841#ifdef KAB_EMBEDDED
1831 // mActionQuit = KStdAction::quit( mMainWindow, SLOT( exit() ), actionCollection() ); 1842 // mActionQuit = KStdAction::quit( mMainWindow, SLOT( exit() ), actionCollection() );
1832 mActionQuit = new KAction( i18n( "&Exit" ), "exit", 0, 1843 mActionQuit = new KAction( i18n( "&Exit" ), "exit", 0,
1833 mMainWindow, SLOT( exit() ), 1844 mMainWindow, SLOT( exit() ),
1834 actionCollection(), "quit" ); 1845 actionCollection(), "quit" );
1835#endif //KAB_EMBEDDED 1846#endif //KAB_EMBEDDED
1836 1847
1837 // edit menu 1848 // edit menu
1838 if ( mIsPart ) { 1849 if ( mIsPart ) {
1839 mActionCopy = new KAction( i18n( "&Copy" ), "editcopy", CTRL + Key_C, this, 1850 mActionCopy = new KAction( i18n( "&Copy" ), "editcopy", CTRL + Key_C, this,
1840 SLOT( copyContacts() ), actionCollection(), 1851 SLOT( copyContacts() ), actionCollection(),
1841 "kaddressbook_copy" ); 1852 "kaddressbook_copy" );
1842 mActionCut = new KAction( i18n( "Cu&t" ), "editcut", CTRL + Key_X, this, 1853 mActionCut = new KAction( i18n( "Cu&t" ), "editcut", CTRL + Key_X, this,
1843 SLOT( cutContacts() ), actionCollection(), 1854 SLOT( cutContacts() ), actionCollection(),
1844 "kaddressbook_cut" ); 1855 "kaddressbook_cut" );
1845 mActionPaste = new KAction( i18n( "&Paste" ), "editpaste", CTRL + Key_V, this, 1856 mActionPaste = new KAction( i18n( "&Paste" ), "editpaste", CTRL + Key_V, this,
1846 SLOT( pasteContacts() ), actionCollection(), 1857 SLOT( pasteContacts() ), actionCollection(),
1847 "kaddressbook_paste" ); 1858 "kaddressbook_paste" );
1848 mActionSelectAll = new KAction( i18n( "Select &All" ), CTRL + Key_A, this, 1859 mActionSelectAll = new KAction( i18n( "Select &All" ), CTRL + Key_A, this,
1849 SLOT( selectAllContacts() ), actionCollection(), 1860 SLOT( selectAllContacts() ), actionCollection(),
1850 "kaddressbook_select_all" ); 1861 "kaddressbook_select_all" );
1851 mActionUndo = new KAction( i18n( "&Undo" ), "undo", CTRL + Key_Z, this, 1862 mActionUndo = new KAction( i18n( "&Undo" ), "undo", CTRL + Key_Z, this,
1852 SLOT( undo() ), actionCollection(), 1863 SLOT( undo() ), actionCollection(),
1853 "kaddressbook_undo" ); 1864 "kaddressbook_undo" );
1854 mActionRedo = new KAction( i18n( "Re&do" ), "redo", CTRL + SHIFT + Key_Z, 1865 mActionRedo = new KAction( i18n( "Re&do" ), "redo", CTRL + SHIFT + Key_Z,
1855 this, SLOT( redo() ), actionCollection(), 1866 this, SLOT( redo() ), actionCollection(),
1856 "kaddressbook_redo" ); 1867 "kaddressbook_redo" );
1857 } else { 1868 } else {
1858 mActionCopy = KStdAction::copy( this, SLOT( copyContacts() ), actionCollection() ); 1869 mActionCopy = KStdAction::copy( this, SLOT( copyContacts() ), actionCollection() );
1859 mActionCut = KStdAction::cut( this, SLOT( cutContacts() ), actionCollection() ); 1870 mActionCut = KStdAction::cut( this, SLOT( cutContacts() ), actionCollection() );
1860 mActionPaste = KStdAction::paste( this, SLOT( pasteContacts() ), actionCollection() ); 1871 mActionPaste = KStdAction::paste( this, SLOT( pasteContacts() ), actionCollection() );
1861 mActionSelectAll = KStdAction::selectAll( this, SLOT( selectAllContacts() ), actionCollection() ); 1872 mActionSelectAll = KStdAction::selectAll( this, SLOT( selectAllContacts() ), actionCollection() );
1862 mActionUndo = KStdAction::undo( this, SLOT( undo() ), actionCollection() ); 1873 mActionUndo = KStdAction::undo( this, SLOT( undo() ), actionCollection() );
1863 mActionRedo = KStdAction::redo( this, SLOT( redo() ), actionCollection() ); 1874 mActionRedo = KStdAction::redo( this, SLOT( redo() ), actionCollection() );
1864 } 1875 }
1865 1876
1866 mActionDelete = new KAction( i18n( "&Delete Contact" ), "editdelete", 1877 mActionDelete = new KAction( i18n( "&Delete Contact" ), "editdelete",
1867 Key_Delete, this, SLOT( deleteContacts() ), 1878 Key_Delete, this, SLOT( deleteContacts() ),
1868 actionCollection(), "edit_delete" ); 1879 actionCollection(), "edit_delete" );
1869 1880
1870 mActionUndo->setEnabled( false ); 1881 mActionUndo->setEnabled( false );
1871 mActionRedo->setEnabled( false ); 1882 mActionRedo->setEnabled( false );
1872 1883
1873 // settings menu 1884 // settings menu
1874#ifdef KAB_EMBEDDED 1885#ifdef KAB_EMBEDDED
1875//US special menuentry to configure the addressbook resources. On KDE 1886//US special menuentry to configure the addressbook resources. On KDE
1876// you do that through the control center !!! 1887// you do that through the control center !!!
1877 mActionConfigResources = new KAction( i18n( "Configure &Resources..." ), "configure_resources", 0, this, 1888 mActionConfigResources = new KAction( i18n( "Configure &Resources..." ), "configure_resources", 0, this,
1878 SLOT( configureResources() ), actionCollection(), 1889 SLOT( configureResources() ), actionCollection(),
1879 "kaddressbook_configure_resources" ); 1890 "kaddressbook_configure_resources" );
1880#endif //KAB_EMBEDDED 1891#endif //KAB_EMBEDDED
1881 1892
1882 if ( mIsPart ) { 1893 if ( mIsPart ) {
1883 mActionConfigKAddressbook = new KAction( i18n( "&Configure KAddressBook..." ), "configure", 0, this, 1894 mActionConfigKAddressbook = new KAction( i18n( "&Configure KAddressBook..." ), "configure", 0, this,
1884 SLOT( openConfigDialog() ), actionCollection(), 1895 SLOT( openConfigDialog() ), actionCollection(),
1885 "kaddressbook_configure" ); 1896 "kaddressbook_configure" );
1886 1897
1887 //US not implemented yet 1898 //US not implemented yet
1888 //mActionConfigShortcuts = new KAction( i18n( "Configure S&hortcuts..." ), "configure_shortcuts", 0, 1899 //mActionConfigShortcuts = new KAction( i18n( "Configure S&hortcuts..." ), "configure_shortcuts", 0,
1889 // this, SLOT( configureKeyBindings() ), actionCollection(), 1900 // this, SLOT( configureKeyBindings() ), actionCollection(),
1890 // "kaddressbook_configure_shortcuts" ); 1901 // "kaddressbook_configure_shortcuts" );
1891#ifdef KAB_EMBEDDED 1902#ifdef KAB_EMBEDDED
1892 mActionConfigureToolbars = KStdAction::configureToolbars( this, SLOT( mMainWindow->configureToolbars() ), actionCollection() ); 1903 mActionConfigureToolbars = KStdAction::configureToolbars( this, SLOT( mMainWindow->configureToolbars() ), actionCollection() );
1893 mActionConfigureToolbars->setEnabled( false ); 1904 mActionConfigureToolbars->setEnabled( false );
1894#endif //KAB_EMBEDDED 1905#endif //KAB_EMBEDDED
1895 1906
1896 } else { 1907 } else {
1897 mActionConfigKAddressbook = KStdAction::preferences( this, SLOT( openConfigDialog() ), actionCollection() ); 1908 mActionConfigKAddressbook = KStdAction::preferences( this, SLOT( openConfigDialog() ), actionCollection() );
1898 1909
1899 //US not implemented yet 1910 //US not implemented yet
1900 //mActionKeyBindings = KStdAction::keyBindings( this, SLOT( configureKeyBindings() ), actionCollection() ); 1911 //mActionKeyBindings = KStdAction::keyBindings( this, SLOT( configureKeyBindings() ), actionCollection() );
1901 } 1912 }
1902 1913
1903 mActionJumpBar = new KToggleAction( i18n( "Show Jump Bar" ), 0, 0, 1914 mActionJumpBar = new KToggleAction( i18n( "Show Jump Bar" ), 0, 0,
1904 actionCollection(), "options_show_jump_bar" ); 1915 actionCollection(), "options_show_jump_bar" );
1905 connect( mActionJumpBar, SIGNAL( toggled( bool ) ), SLOT( setJumpButtonBarVisible( bool ) ) ); 1916 connect( mActionJumpBar, SIGNAL( toggled( bool ) ), SLOT( setJumpButtonBarVisible( bool ) ) );
1906 1917
1907 mActionDetails = new KToggleAction( i18n( "Show Details" ), "listview", 0, 1918 mActionDetails = new KToggleAction( i18n( "Show Details" ), "listview", 0,
1908 actionCollection(), "options_show_details" ); 1919 actionCollection(), "options_show_details" );
1909 connect( mActionDetails, SIGNAL( toggled( bool ) ), SLOT( setDetailsVisible( bool ) ) ); 1920 connect( mActionDetails, SIGNAL( toggled( bool ) ), SLOT( setDetailsVisible( bool ) ) );
1910 1921
1911 1922
1912 mActionBR = new KToggleAction( i18n( "Beam receive enabled" ), "beam", 0, this, 1923 mActionBR = new KToggleAction( i18n( "Beam receive enabled" ), "beam", 0, this,
1913 SLOT( toggleBeamReceive() ), actionCollection(), 1924 SLOT( toggleBeamReceive() ), actionCollection(),
1914 "kaddressbook_beam_rec" ); 1925 "kaddressbook_beam_rec" );
1915 1926
1916 1927
1917 // misc 1928 // misc
1918 // only enable LDAP lookup if we can handle the protocol 1929 // only enable LDAP lookup if we can handle the protocol
1919#ifndef KAB_EMBEDDED 1930#ifndef KAB_EMBEDDED
1920 if ( KProtocolInfo::isKnownProtocol( KURL( "ldap://localhost" ) ) ) { 1931 if ( KProtocolInfo::isKnownProtocol( KURL( "ldap://localhost" ) ) ) {
1921 new KAction( i18n( "&Lookup Addresses in Directory" ), "find", 0, 1932 new KAction( i18n( "&Lookup Addresses in Directory" ), "find", 0,
1922 this, SLOT( openLDAPDialog() ), actionCollection(), 1933 this, SLOT( openLDAPDialog() ), actionCollection(),
1923 "ldap_lookup" ); 1934 "ldap_lookup" );
1924 } 1935 }
1925#else //KAB_EMBEDDED 1936#else //KAB_EMBEDDED
1926 //qDebug("KABCore::initActions() LDAP has to be implemented"); 1937 //qDebug("KABCore::initActions() LDAP has to be implemented");
1927#endif //KAB_EMBEDDED 1938#endif //KAB_EMBEDDED
1928 1939
1929 1940
1930 mActionWhoAmI = new KAction( i18n( "Set Who Am I" ), "personal", 0, this, 1941 mActionWhoAmI = new KAction( i18n( "Set Who Am I" ), "personal", 0, this,
1931 SLOT( setWhoAmI() ), actionCollection(), 1942 SLOT( setWhoAmI() ), actionCollection(),
1932 "set_personal" ); 1943 "set_personal" );
1933 1944
1934 1945
1935 mActionCategories = new KAction( i18n( "Set Categories" ), 0, this, 1946 mActionCategories = new KAction( i18n( "Set Categories" ), 0, this,
1936 SLOT( setCategories() ), actionCollection(), 1947 SLOT( setCategories() ), actionCollection(),
1937 "edit_set_categories" ); 1948 "edit_set_categories" );
1938 mActionEditCategories = new KAction( i18n( "Edit Categories" ), 0, this, 1949 mActionEditCategories = new KAction( i18n( "Edit Categories" ), 0, this,
1939 SLOT( editCategories() ), actionCollection(), 1950 SLOT( editCategories() ), actionCollection(),
1940 "edit__categories" ); 1951 "edit__categories" );
1941 1952
1942 mActionRemoveVoice = new KAction( i18n( "Remove \"voice\"..." ), 0, this, 1953 mActionRemoveVoice = new KAction( i18n( "Remove \"voice\"..." ), 0, this,
1943 SLOT( removeVoice() ), actionCollection(), 1954 SLOT( removeVoice() ), actionCollection(),
1944 "remove_voice" ); 1955 "remove_voice" );
1945 1956
1946 mActionManageCategories= new KAction( i18n( "Manage new categories..." ), 0, this, 1957 mActionManageCategories= new KAction( i18n( "Manage new categories..." ), 0, this,
1947 SLOT( manageCategories() ), actionCollection(), 1958 SLOT( manageCategories() ), actionCollection(),
1948 "remove_voice" ); 1959 "remove_voice" );
1949 1960
1950 1961
1951 mActionImportOL = new KAction( i18n( "Import from Outlook..." ), 0, this, 1962 mActionImportOL = new KAction( i18n( "Import from Outlook..." ), 0, this,
1952 SLOT( importFromOL() ), actionCollection(), 1963 SLOT( importFromOL() ), actionCollection(),
1953 "import_OL" ); 1964 "import_OL" );
1954#ifdef KAB_EMBEDDED 1965#ifdef KAB_EMBEDDED
1955 mActionLicence = new KAction( i18n( "Licence" ), 0, 1966 mActionLicence = new KAction( i18n( "Licence" ), 0,
1956 this, SLOT( showLicence() ), actionCollection(), 1967 this, SLOT( showLicence() ), actionCollection(),
1957 "licence_about_data" ); 1968 "licence_about_data" );
1958 mActionFaq = new KAction( i18n( "Faq" ), 0, 1969 mActionFaq = new KAction( i18n( "Faq" ), 0,
1959 this, SLOT( faq() ), actionCollection(), 1970 this, SLOT( faq() ), actionCollection(),
1960 "faq_about_data" ); 1971 "faq_about_data" );
1961 mActionWN = new KAction( i18n( "What's New?" ), 0, 1972 mActionWN = new KAction( i18n( "What's New?" ), 0,
1962 this, SLOT( whatsnew() ), actionCollection(), 1973 this, SLOT( whatsnew() ), actionCollection(),
1963 "wn" ); 1974 "wn" );
1964 mActionSyncHowto = new KAction( i18n( "Sync HowTo" ), 0, 1975 mActionSyncHowto = new KAction( i18n( "Sync HowTo" ), 0,
1965 this, SLOT( synchowto() ), actionCollection(), 1976 this, SLOT( synchowto() ), actionCollection(),
1966 "sync" ); 1977 "sync" );
1967 mActionKdeSyncHowto = new KAction( i18n( "Kde Sync HowTo" ), 0, 1978 mActionKdeSyncHowto = new KAction( i18n( "Kde Sync HowTo" ), 0,
1968 this, SLOT( kdesynchowto() ), actionCollection(), 1979 this, SLOT( kdesynchowto() ), actionCollection(),
1969 "kdesync" ); 1980 "kdesync" );
1970 mActionMultiSyncHowto = new KAction( i18n( "Multi Sync HowTo" ), 0, 1981 mActionMultiSyncHowto = new KAction( i18n( "Multi Sync HowTo" ), 0,
1971 this, SLOT( multisynchowto() ), actionCollection(), 1982 this, SLOT( multisynchowto() ), actionCollection(),
1972 "multisync" ); 1983 "multisync" );
1973 1984
1974 mActionAboutKAddressbook = new KAction( i18n( "&About KAddressBook" ), "kaddressbook2", 0, 1985 mActionAboutKAddressbook = new KAction( i18n( "&About KAddressBook" ), "kaddressbook2", 0,
1975 this, SLOT( createAboutData() ), actionCollection(), 1986 this, SLOT( createAboutData() ), actionCollection(),
1976 "kaddressbook_about_data" ); 1987 "kaddressbook_about_data" );
1977#endif //KAB_EMBEDDED 1988#endif //KAB_EMBEDDED
1978 1989
1979 clipboardDataChanged(); 1990 clipboardDataChanged();
1980 connect( UndoStack::instance(), SIGNAL( changed() ), SLOT( updateActionMenu() ) ); 1991 connect( UndoStack::instance(), SIGNAL( changed() ), SLOT( updateActionMenu() ) );
1981 connect( RedoStack::instance(), SIGNAL( changed() ), SLOT( updateActionMenu() ) ); 1992 connect( RedoStack::instance(), SIGNAL( changed() ), SLOT( updateActionMenu() ) );
1982} 1993}
1983 1994
1984//US we need this function, to plug all actions into the correct menues. 1995//US we need this function, to plug all actions into the correct menues.
1985// KDE uses a XML format to plug the actions, but we work her without this overhead. 1996// KDE uses a XML format to plug the actions, but we work her without this overhead.
1986void KABCore::addActionsManually() 1997void KABCore::addActionsManually()
1987{ 1998{
1988//US qDebug("KABCore::initActions(): mIsPart %i", mIsPart); 1999//US qDebug("KABCore::initActions(): mIsPart %i", mIsPart);
1989 2000
1990#ifdef KAB_EMBEDDED 2001#ifdef KAB_EMBEDDED
1991 QPopupMenu *fileMenu = new QPopupMenu( this ); 2002 QPopupMenu *fileMenu = new QPopupMenu( this );
1992 QPopupMenu *editMenu = new QPopupMenu( this ); 2003 QPopupMenu *editMenu = new QPopupMenu( this );
1993 QPopupMenu *helpMenu = new QPopupMenu( this ); 2004 QPopupMenu *helpMenu = new QPopupMenu( this );
1994 2005
1995 KToolBar* tb = mMainWindow->toolBar(); 2006 KToolBar* tb = mMainWindow->toolBar();
1996 2007
1997#ifndef DESKTOP_VERSION 2008#ifndef DESKTOP_VERSION
1998 if ( KABPrefs::instance()->mFullMenuBarVisible ) { 2009 if ( KABPrefs::instance()->mFullMenuBarVisible ) {
1999#endif 2010#endif
2000 QMenuBar* mb = mMainWindow->menuBar(); 2011 QMenuBar* mb = mMainWindow->menuBar();
2001 2012
2002 //US setup menubar. 2013 //US setup menubar.
2003 //Disable the following block if you do not want to have a menubar. 2014 //Disable the following block if you do not want to have a menubar.
2004 mb->insertItem( i18n("&File"), fileMenu ); 2015 mb->insertItem( i18n("&File"), fileMenu );
2005 mb->insertItem( i18n("&Edit"), editMenu ); 2016 mb->insertItem( i18n("&Edit"), editMenu );
2006 mb->insertItem( i18n("&View"), viewMenu ); 2017 mb->insertItem( i18n("&View"), viewMenu );
2007 mb->insertItem( i18n("&Settings"), settingsMenu ); 2018 mb->insertItem( i18n("&Settings"), settingsMenu );
2008 mb->insertItem( i18n("Synchronize"), syncMenu ); 2019 mb->insertItem( i18n("Synchronize"), syncMenu );
2009 //mb->insertItem( i18n("&Change"), changeMenu ); 2020 //mb->insertItem( i18n("&Change"), changeMenu );
2010 mb->insertItem( i18n("&Help"), helpMenu ); 2021 mb->insertItem( i18n("&Help"), helpMenu );
2011 mIncSearchWidget = new IncSearchWidget( tb ); 2022 mIncSearchWidget = new IncSearchWidget( tb );
2012 // tb->insertWidget(-1, 0, mIncSearchWidget); 2023 // tb->insertWidget(-1, 0, mIncSearchWidget);
2013#ifndef DESKTOP_VERSION 2024#ifndef DESKTOP_VERSION
2014 } else { 2025 } else {
2015 //US setup toolbar 2026 //US setup toolbar
2016 QPEMenuBar *menuBarTB = new QPEMenuBar( tb ); 2027 QPEMenuBar *menuBarTB = new QPEMenuBar( tb );
2017 QPopupMenu *popupBarTB = new QPopupMenu( this ); 2028 QPopupMenu *popupBarTB = new QPopupMenu( this );
2018 menuBarTB->insertItem( "ME", popupBarTB); 2029 menuBarTB->insertItem( "ME", popupBarTB);
2019 tb->insertWidget(-1, 0, menuBarTB); 2030 tb->insertWidget(-1, 0, menuBarTB);
2020 mIncSearchWidget = new IncSearchWidget( tb ); 2031 mIncSearchWidget = new IncSearchWidget( tb );
2021 2032
2022 tb->enableMoving(false); 2033 tb->enableMoving(false);
2023 popupBarTB->insertItem( i18n("&File"), fileMenu ); 2034 popupBarTB->insertItem( i18n("&File"), fileMenu );
2024 popupBarTB->insertItem( i18n("&Edit"), editMenu ); 2035 popupBarTB->insertItem( i18n("&Edit"), editMenu );
2025 popupBarTB->insertItem( i18n("&View"), viewMenu ); 2036 popupBarTB->insertItem( i18n("&View"), viewMenu );
2026 popupBarTB->insertItem( i18n("&Settings"), settingsMenu ); 2037 popupBarTB->insertItem( i18n("&Settings"), settingsMenu );
2027 popupBarTB->insertItem( i18n("Synchronize"), syncMenu ); 2038 popupBarTB->insertItem( i18n("Synchronize"), syncMenu );
2028 mViewManager->getFilterAction()->plug ( popupBarTB); 2039 mViewManager->getFilterAction()->plug ( popupBarTB);
2029 //popupBarTB->insertItem( i18n("&Change selected"), changeMenu ); 2040 //popupBarTB->insertItem( i18n("&Change selected"), changeMenu );
2030 popupBarTB->insertItem( i18n("&Help"), helpMenu ); 2041 popupBarTB->insertItem( i18n("&Help"), helpMenu );
2031 if (QApplication::desktop()->width() > 320 ) { 2042 if (QApplication::desktop()->width() > 320 ) {
2032 // mViewManager->getFilterAction()->plug ( tb); 2043 // mViewManager->getFilterAction()->plug ( tb);
2033 } 2044 }
2034 } 2045 }
2035#endif 2046#endif
2036 // mActionQuit->plug ( mMainWindow->toolBar()); 2047 // mActionQuit->plug ( mMainWindow->toolBar());
2037 2048
2038 2049
2039 2050
2040 //US Now connect the actions with the menue entries. 2051 //US Now connect the actions with the menue entries.
2041 mActionPrint->plug( fileMenu ); 2052 mActionPrint->plug( fileMenu );
2042 mActionMail->plug( fileMenu ); 2053 mActionMail->plug( fileMenu );
2043 fileMenu->insertSeparator(); 2054 fileMenu->insertSeparator();
2044 2055
2045 mActionNewContact->plug( fileMenu ); 2056 mActionNewContact->plug( fileMenu );
2046 mActionNewContact->plug( tb ); 2057 mActionNewContact->plug( tb );
2047 2058
2048 mActionEditAddressee->plug( fileMenu ); 2059 mActionEditAddressee->plug( fileMenu );
2049 // if ((KGlobal::getDesktopSize() > KGlobal::Small ) || 2060 // if ((KGlobal::getDesktopSize() > KGlobal::Small ) ||
2050 // (!KABPrefs::instance()->mMultipleViewsAtOnce )) 2061 // (!KABPrefs::instance()->mMultipleViewsAtOnce ))
2051 mActionEditAddressee->plug( tb ); 2062 mActionEditAddressee->plug( tb );
2052 2063
2053 fileMenu->insertSeparator(); 2064 fileMenu->insertSeparator();
2054 mActionSave->plug( fileMenu ); 2065 mActionSave->plug( fileMenu );
2055 fileMenu->insertItem( "&Import", ImportMenu ); 2066 fileMenu->insertItem( "&Import", ImportMenu );
2056 fileMenu->insertItem( "&Export", ExportMenu ); 2067 fileMenu->insertItem( "&Export", ExportMenu );
2057 fileMenu->insertItem( i18n("&Change"), changeMenu ); 2068 fileMenu->insertItem( i18n("&Change"), changeMenu );
2058 fileMenu->insertSeparator(); 2069 fileMenu->insertSeparator();
2059 mActionMailVCard->plug( fileMenu ); 2070 mActionMailVCard->plug( fileMenu );
2060#ifndef DESKTOP_VERSION 2071#ifndef DESKTOP_VERSION
2061 if ( Ir::supported() ) mActionBeamVCard->plug( fileMenu ); 2072 if ( Ir::supported() ) mActionBeamVCard->plug( fileMenu );
2062 if ( Ir::supported() ) mActionBeam->plug(fileMenu ); 2073 if ( Ir::supported() ) mActionBeam->plug(fileMenu );
2063#endif 2074#endif
2064 fileMenu->insertSeparator(); 2075 fileMenu->insertSeparator();
2065 mActionQuit->plug( fileMenu ); 2076 mActionQuit->plug( fileMenu );
2066#ifdef _WIN32_ 2077#ifdef _WIN32_
2067 mActionImportOL->plug( ImportMenu ); 2078 mActionImportOL->plug( ImportMenu );
2068#endif 2079#endif
2069 // edit menu 2080 // edit menu
2070 mActionUndo->plug( editMenu ); 2081 mActionUndo->plug( editMenu );
2071 mActionRedo->plug( editMenu ); 2082 mActionRedo->plug( editMenu );
2072 editMenu->insertSeparator(); 2083 editMenu->insertSeparator();
2073 mActionCut->plug( editMenu ); 2084 mActionCut->plug( editMenu );
2074 mActionCopy->plug( editMenu ); 2085 mActionCopy->plug( editMenu );
2075 mActionPaste->plug( editMenu ); 2086 mActionPaste->plug( editMenu );
2076 mActionDelete->plug( editMenu ); 2087 mActionDelete->plug( editMenu );
2077 editMenu->insertSeparator(); 2088 editMenu->insertSeparator();
2078 mActionSelectAll->plug( editMenu ); 2089 mActionSelectAll->plug( editMenu );
2079 2090
2080 mActionRemoveVoice->plug( changeMenu ); 2091 mActionRemoveVoice->plug( changeMenu );
2081 // settings menu 2092 // settings menu
2082//US special menuentry to configure the addressbook resources. On KDE 2093//US special menuentry to configure the addressbook resources. On KDE
2083// you do that through the control center !!! 2094// you do that through the control center !!!
2084 mActionConfigResources->plug( settingsMenu ); 2095 mActionConfigResources->plug( settingsMenu );
2085 settingsMenu->insertSeparator(); 2096 settingsMenu->insertSeparator();
2086 2097
2087 mActionConfigKAddressbook->plug( settingsMenu ); 2098 mActionConfigKAddressbook->plug( settingsMenu );
2088 2099
2089 if ( mIsPart ) { 2100 if ( mIsPart ) {
2090 //US not implemented yet 2101 //US not implemented yet
2091 //mActionConfigShortcuts->plug( settingsMenu ); 2102 //mActionConfigShortcuts->plug( settingsMenu );
2092 //mActionConfigureToolbars->plug( settingsMenu ); 2103 //mActionConfigureToolbars->plug( settingsMenu );
2093 2104
2094 } else { 2105 } else {
2095 //US not implemented yet 2106 //US not implemented yet
2096 //mActionKeyBindings->plug( settingsMenu ); 2107 //mActionKeyBindings->plug( settingsMenu );
2097 } 2108 }
2098 2109
2099 settingsMenu->insertSeparator(); 2110 settingsMenu->insertSeparator();
2100 2111
2101 mActionJumpBar->plug( settingsMenu ); 2112 mActionJumpBar->plug( settingsMenu );
2102 mActionDetails->plug( settingsMenu ); 2113 mActionDetails->plug( settingsMenu );
2103 //if (!KABPrefs::instance()->mMultipleViewsAtOnce || KGlobal::getDesktopSize() == KGlobal::Desktop ) 2114 //if (!KABPrefs::instance()->mMultipleViewsAtOnce || KGlobal::getDesktopSize() == KGlobal::Desktop )
2104 mActionDetails->plug( tb ); 2115 mActionDetails->plug( tb );
2105 settingsMenu->insertSeparator(); 2116 settingsMenu->insertSeparator();
2106 mActionBR->plug(settingsMenu ); 2117 mActionBR->plug(settingsMenu );
2107 settingsMenu->insertSeparator(); 2118 settingsMenu->insertSeparator();
2108 2119
2109 mActionWhoAmI->plug( settingsMenu ); 2120 mActionWhoAmI->plug( settingsMenu );
2110 mActionEditCategories->plug( settingsMenu ); 2121 mActionEditCategories->plug( settingsMenu );
2122 mActionEditCategories->plug( changeMenu );
2123 mActionCategories->plug( changeMenu );
2124 mActionManageCategories->plug( changeMenu );
2125
2111 mActionCategories->plug( settingsMenu ); 2126 mActionCategories->plug( settingsMenu );
2112 mActionManageCategories->plug( settingsMenu ); 2127 mActionManageCategories->plug( settingsMenu );
2113 2128
2114 2129
2115 mActionWN->plug( helpMenu ); 2130 mActionWN->plug( helpMenu );
2116 mActionSyncHowto->plug( helpMenu ); 2131 mActionSyncHowto->plug( helpMenu );
2117 mActionKdeSyncHowto->plug( helpMenu ); 2132 mActionKdeSyncHowto->plug( helpMenu );
2118 mActionMultiSyncHowto->plug( helpMenu ); 2133 mActionMultiSyncHowto->plug( helpMenu );
2119 mActionFaq->plug( helpMenu ); 2134 mActionFaq->plug( helpMenu );
2120 mActionLicence->plug( helpMenu ); 2135 mActionLicence->plug( helpMenu );
2121 mActionAboutKAddressbook->plug( helpMenu ); 2136 mActionAboutKAddressbook->plug( helpMenu );
2122 2137
2123 if (KGlobal::getDesktopSize() > KGlobal::Small ) { 2138 if (KGlobal::getDesktopSize() > KGlobal::Small ) {
2124 2139
2125 mActionSave->plug( tb ); 2140 mActionSave->plug( tb );
2126 mViewManager->getFilterAction()->plug ( tb); 2141 mViewManager->getFilterAction()->plug ( tb);
2127 if (KGlobal::getDesktopSize() == KGlobal::Desktop ) { 2142 if (KGlobal::getDesktopSize() == KGlobal::Desktop ) {
2128 mActionUndo->plug( tb ); 2143 mActionUndo->plug( tb );
2129 mActionDelete->plug( tb ); 2144 mActionDelete->plug( tb );
2130 mActionRedo->plug( tb ); 2145 mActionRedo->plug( tb );
2131 } 2146 }
2132 } else { 2147 } else {
2133 mActionSave->plug( tb ); 2148 mActionSave->plug( tb );
2134 tb->enableMoving(false); 2149 tb->enableMoving(false);
2135 } 2150 }
2136 //mActionQuit->plug ( tb ); 2151 //mActionQuit->plug ( tb );
2137 // tb->insertWidget(-1, 0, mIncSearchWidget, 6); 2152 // tb->insertWidget(-1, 0, mIncSearchWidget, 6);
2138 2153
2139 //US link the searchwidget first to this. 2154 //US link the searchwidget first to this.
2140 // The real linkage to the toolbar happens later. 2155 // The real linkage to the toolbar happens later.
2141//US mIncSearchWidget->reparent(tb, 0, QPoint(50,0), TRUE); 2156//US mIncSearchWidget->reparent(tb, 0, QPoint(50,0), TRUE);
2142//US tb->insertItem( mIncSearchWidget ); 2157//US tb->insertItem( mIncSearchWidget );
2143/*US 2158/*US
2144 mIncSearchWidget = new IncSearchWidget( tb ); 2159 mIncSearchWidget = new IncSearchWidget( tb );
2145 connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ), 2160 connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ),
2146 SLOT( incrementalSearch( const QString& ) ) ); 2161 SLOT( incrementalSearch( const QString& ) ) );
2147 2162
2148 mJumpButtonBar = new JumpButtonBar( this, this ); 2163 mJumpButtonBar = new JumpButtonBar( this, this );
2149 2164
2150//US topLayout->addWidget( mJumpButtonBar ); 2165//US topLayout->addWidget( mJumpButtonBar );
2151 this->layout()->add( mJumpButtonBar ); 2166 this->layout()->add( mJumpButtonBar );
2152*/ 2167*/
2153 2168
2154#endif //KAB_EMBEDDED 2169#endif //KAB_EMBEDDED
2155 2170
2156 mActionExport2phone->plug( ExportMenu ); 2171 mActionExport2phone->plug( ExportMenu );
2157 connect ( syncMenu, SIGNAL( activated ( int ) ), syncManager, SLOT (slotSyncMenu( int ) ) ); 2172 connect ( syncMenu, SIGNAL( activated ( int ) ), syncManager, SLOT (slotSyncMenu( int ) ) );
2158 syncManager->fillSyncMenu(); 2173 syncManager->fillSyncMenu();
2159 2174
2160} 2175}
2161void KABCore::showLicence() 2176void KABCore::showLicence()
2162{ 2177{
2163 KApplication::showLicence(); 2178 KApplication::showLicence();
2164} 2179}
2165 2180
2166void KABCore::manageCategories( ) 2181void KABCore::manageCategories( )
2167{ 2182{
2168 KABCatPrefs* cp = new KABCatPrefs(); 2183 KABCatPrefs* cp = new KABCatPrefs();
2169 cp->show(); 2184 cp->show();
2170 int w =cp->sizeHint().width() ; 2185 int w =cp->sizeHint().width() ;
2171 int h = cp->sizeHint().height() ; 2186 int h = cp->sizeHint().height() ;
2172 int dw = QApplication::desktop()->width(); 2187 int dw = QApplication::desktop()->width();
2173 int dh = QApplication::desktop()->height(); 2188 int dh = QApplication::desktop()->height();
2174 cp->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 2189 cp->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
2175 if ( !cp->exec() ) { 2190 if ( !cp->exec() ) {
2176 delete cp; 2191 delete cp;
2177 return; 2192 return;
2178 } 2193 }
2179 int count = 0; 2194 int count = 0;
2180 message( i18n("Please wait, processing categories...")); 2195 message( i18n("Please wait, processing categories..."));
2181 if ( cp->addCat() ) { 2196 if ( cp->addCat() ) {
2182 KABC::AddressBook::Iterator it; 2197 KABC::AddressBook::Iterator it;
2183 QStringList catList = KABPrefs::instance()->mCustomCategories; 2198 QStringList catList = KABPrefs::instance()->mCustomCategories;
2184 for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) { 2199 for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) {
2185 QStringList catIncList = (*it).categories(); 2200 QStringList catIncList = (*it).categories();
2186 int i; 2201 int i;
2187 for( i = 0; i< catIncList.count(); ++i ) { 2202 for( i = 0; i< catIncList.count(); ++i ) {
2188 if ( !catList.contains (catIncList[i])) { 2203 if ( !catList.contains (catIncList[i])) {
2189 catList.append( catIncList[i] ); 2204 catList.append( catIncList[i] );
2190 //qDebug("add cat %s ", catIncList[i].latin1()); 2205 //qDebug("add cat %s ", catIncList[i].latin1());
2191 ++count; 2206 ++count;
2192 } 2207 }
2193 } 2208 }
2194 } 2209 }
2195 catList.sort(); 2210 catList.sort();
2196 KABPrefs::instance()->mCustomCategories = catList; 2211 KABPrefs::instance()->mCustomCategories = catList;
2197 KABPrefs::instance()->writeConfig(); 2212 KABPrefs::instance()->writeConfig();
2198 message(QString::number( count )+ i18n(" categories added to list! ")); 2213 message(QString::number( count )+ i18n(" categories added to list! "));
2199 } else { 2214 } else {
2200 QStringList catList = KABPrefs::instance()->mCustomCategories; 2215 QStringList catList = KABPrefs::instance()->mCustomCategories;
2201 QStringList catIncList; 2216 QStringList catIncList;
2202 QStringList newCatList; 2217 QStringList newCatList;
2203 KABC::AddressBook::Iterator it; 2218 KABC::AddressBook::Iterator it;
2204 for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) { 2219 for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) {
2205 QStringList catIncList = (*it).categories(); 2220 QStringList catIncList = (*it).categories();
2206 int i; 2221 int i;
2207 if ( catIncList.count() ) { 2222 if ( catIncList.count() ) {
2208 newCatList.clear(); 2223 newCatList.clear();
2209 for( i = 0; i< catIncList.count(); ++i ) { 2224 for( i = 0; i< catIncList.count(); ++i ) {
2210 if ( catList.contains (catIncList[i])) { 2225 if ( catList.contains (catIncList[i])) {
2211 newCatList.append( catIncList[i] ); 2226 newCatList.append( catIncList[i] );
2212 } 2227 }
2213 } 2228 }
2214 newCatList.sort(); 2229 newCatList.sort();
2215 (*it).setCategories( newCatList ); 2230 (*it).setCategories( newCatList );
2216 mAddressBook->insertAddressee( (*it) ); 2231 mAddressBook->insertAddressee( (*it) );
2217 } 2232 }
2218 } 2233 }
2219 setModified( true ); 2234 setModified( true );
2220 mViewManager->refreshView(); 2235 mViewManager->refreshView();
2221 mDetails->refreshView(); 2236 mDetails->refreshView();
2222 message( i18n("Removing categories done!")); 2237 message( i18n("Removing categories done!"));
2223 } 2238 }
2224 delete cp; 2239 delete cp;
2225} 2240}
2226void KABCore::removeVoice() 2241void KABCore::removeVoice()
2227{ 2242{
2228 if ( KMessageBox::questionYesNo( this, i18n("After importing, phone numbers\nmay have two or more types.\n(E.g. work+voice)\nThese numbers are shown as \"other\".\nClick Yes to remove the voice type\nfrom numbers with more than one type.\n\nRemove voice type?") ) == KMessageBox::No ) 2243 if ( KMessageBox::questionYesNo( this, i18n("After importing, phone numbers\nmay have two or more types.\n(E.g. work+voice)\nThese numbers are shown as \"other\".\nClick Yes to remove the voice type\nfrom numbers with more than one type.\n\nRemove voice type?") ) == KMessageBox::No )
2229 return; 2244 return;
2230 KABC::Addressee::List list; 2245 KABC::Addressee::List list;
2231 XXPortSelectDialog dlg( this, false, this ); 2246 XXPortSelectDialog dlg( this, false, this );
2232 if ( dlg.exec() ) 2247 if ( dlg.exec() )
2233 list = dlg.contacts(); 2248 list = dlg.contacts();
2234 else 2249 else
2235 return; 2250 return;
2236 KABC::Addressee::List::Iterator it; 2251 KABC::Addressee::List::Iterator it;
2237 for ( it = list.begin(); it != list.end(); ++it ) { 2252 for ( it = list.begin(); it != list.end(); ++it ) {
2238 if ( (*it).removeVoice() ) 2253 if ( (*it).removeVoice() )
2239 contactModified((*it) ); 2254 contactModified((*it) );
2240 } 2255 }
2241} 2256}
2242 2257
2243 2258
2244 2259
2245void KABCore::clipboardDataChanged() 2260void KABCore::clipboardDataChanged()
2246{ 2261{
2247 2262
2248 if ( mReadWrite ) 2263 if ( mReadWrite )
2249 mActionPaste->setEnabled( !QApplication::clipboard()->text().isEmpty() ); 2264 mActionPaste->setEnabled( !QApplication::clipboard()->text().isEmpty() );
2250 2265
2251} 2266}
2252 2267
2253void KABCore::updateActionMenu() 2268void KABCore::updateActionMenu()
2254{ 2269{
2255 UndoStack *undo = UndoStack::instance(); 2270 UndoStack *undo = UndoStack::instance();
2256 RedoStack *redo = RedoStack::instance(); 2271 RedoStack *redo = RedoStack::instance();
2257 2272
2258 if ( undo->isEmpty() ) 2273 if ( undo->isEmpty() )
2259 mActionUndo->setText( i18n( "Undo" ) ); 2274 mActionUndo->setText( i18n( "Undo" ) );
2260 else 2275 else
2261 mActionUndo->setText( i18n( "Undo %1" ).arg( undo->top()->name() ) ); 2276 mActionUndo->setText( i18n( "Undo %1" ).arg( undo->top()->name() ) );
2262 2277
2263 mActionUndo->setEnabled( !undo->isEmpty() ); 2278 mActionUndo->setEnabled( !undo->isEmpty() );
2264 2279
2265 if ( !redo->top() ) 2280 if ( !redo->top() )
2266 mActionRedo->setText( i18n( "Redo" ) ); 2281 mActionRedo->setText( i18n( "Redo" ) );
2267 else 2282 else
2268 mActionRedo->setText( i18n( "Redo %1" ).arg( redo->top()->name() ) ); 2283 mActionRedo->setText( i18n( "Redo %1" ).arg( redo->top()->name() ) );
2269 2284
2270 mActionRedo->setEnabled( !redo->isEmpty() ); 2285 mActionRedo->setEnabled( !redo->isEmpty() );
2271} 2286}
2272 2287
2273void KABCore::configureKeyBindings() 2288void KABCore::configureKeyBindings()
2274{ 2289{
2275#ifndef KAB_EMBEDDED 2290#ifndef KAB_EMBEDDED
2276 KKeyDialog::configure( actionCollection(), true ); 2291 KKeyDialog::configure( actionCollection(), true );
2277#else //KAB_EMBEDDED 2292#else //KAB_EMBEDDED
2278 qDebug("KABCore::configureKeyBindings() not implemented"); 2293 qDebug("KABCore::configureKeyBindings() not implemented");
2279#endif //KAB_EMBEDDED 2294#endif //KAB_EMBEDDED
2280} 2295}
2281 2296
2282#ifdef KAB_EMBEDDED 2297#ifdef KAB_EMBEDDED
2283void KABCore::configureResources() 2298void KABCore::configureResources()
2284{ 2299{
2285 KRES::KCMKResources dlg( this, "" , 0 ); 2300 KRES::KCMKResources dlg( this, "" , 0 );
2286 2301
2287 if ( !dlg.exec() ) 2302 if ( !dlg.exec() )
2288 return; 2303 return;
2289 KMessageBox::information( this, i18n("Please restart to get the \nchanged resources (re)loaded!\n") ); 2304 KMessageBox::information( this, i18n("Please restart to get the \nchanged resources (re)loaded!\n") );
2290} 2305}
2291#endif //KAB_EMBEDDED 2306#endif //KAB_EMBEDDED
2292 2307
2293 2308
2294/* this method will be called through the QCop interface from Ko/Pi to select addresses 2309/* this method will be called through the QCop interface from Ko/Pi to select addresses
2295 * for the attendees list of an event. 2310 * for the attendees list of an event.
2296 */ 2311 */
2297void KABCore::requestForNameEmailUidList(const QString& sourceChannel, const QString& uid) 2312void KABCore::requestForNameEmailUidList(const QString& sourceChannel, const QString& uid)
2298{ 2313{
2299 QStringList nameList; 2314 QStringList nameList;
2300 QStringList emailList; 2315 QStringList emailList;
2301 QStringList uidList; 2316 QStringList uidList;
2302 2317
2303 KABC::Addressee::List list = KABC::AddresseeDialog::getAddressees(this); 2318 KABC::Addressee::List list = KABC::AddresseeDialog::getAddressees(this);
2304 uint i=0; 2319 uint i=0;
2305 for (i=0; i < list.count(); i++) 2320 for (i=0; i < list.count(); i++)
2306 { 2321 {
2307 nameList.append(list[i].realName()); 2322 nameList.append(list[i].realName());
2308 emailList.append(list[i].preferredEmail()); 2323 emailList.append(list[i].preferredEmail());
2309 uidList.append(list[i].uid()); 2324 uidList.append(list[i].uid());
2310 } 2325 }
2311 2326
2312 bool res = ExternalAppHandler::instance()->returnNameEmailUidListFromKAPI(sourceChannel, uid, nameList, emailList, uidList); 2327 bool res = ExternalAppHandler::instance()->returnNameEmailUidListFromKAPI(sourceChannel, uid, nameList, emailList, uidList);
2313 2328
2314} 2329}
2315 2330
2316/* this method will be called through the QCop interface from Ko/Pi to select birthdays 2331/* this method will be called through the QCop interface from Ko/Pi to select birthdays
2317 * to put them into the calendar. 2332 * to put them into the calendar.
2318 */ 2333 */
2319void KABCore::requestForBirthdayList(const QString& sourceChannel, const QString& uid) 2334void KABCore::requestForBirthdayList(const QString& sourceChannel, const QString& uid)
2320{ 2335{
2321 // qDebug("KABCore::requestForBirthdayList"); 2336 // qDebug("KABCore::requestForBirthdayList");
2322 QStringList birthdayList; 2337 QStringList birthdayList;
2323 QStringList anniversaryList; 2338 QStringList anniversaryList;
2324 QStringList realNameList; 2339 QStringList realNameList;
2325 QStringList preferredEmailList; 2340 QStringList preferredEmailList;
2326 QStringList assembledNameList; 2341 QStringList assembledNameList;
2327 QStringList uidList; 2342 QStringList uidList;
2328 2343
2329 KABC::AddressBook::Iterator it; 2344 KABC::AddressBook::Iterator it;
2330 2345
2331 int count = 0; 2346 int count = 0;
2332 for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) { 2347 for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) {
2333 ++count; 2348 ++count;
2334 } 2349 }
2335 QProgressBar bar(count,0 ); 2350 QProgressBar bar(count,0 );
2336 int w = 300; 2351 int w = 300;
2337 if ( QApplication::desktop()->width() < 320 ) 2352 if ( QApplication::desktop()->width() < 320 )
2338 w = 220; 2353 w = 220;
2339 int h = bar.sizeHint().height() ; 2354 int h = bar.sizeHint().height() ;
2340 int dw = QApplication::desktop()->width(); 2355 int dw = QApplication::desktop()->width();
2341 int dh = QApplication::desktop()->height(); 2356 int dh = QApplication::desktop()->height();
2342 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 2357 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
2343 bar.show(); 2358 bar.show();
2344 bar.setCaption (i18n("Collecting birthdays - close to abort!") ); 2359 bar.setCaption (i18n("Collecting birthdays - close to abort!") );
2345 qApp->processEvents(); 2360 qApp->processEvents();
2346 2361
2347 QDate bday; 2362 QDate bday;
2348 QString anni; 2363 QString anni;
2349 QString formattedbday; 2364 QString formattedbday;
2350 2365
2351 for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) 2366 for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it )
2352 { 2367 {
2353 if ( ! bar.isVisible() ) 2368 if ( ! bar.isVisible() )
2354 return; 2369 return;
2355 bar.setProgress( count++ ); 2370 bar.setProgress( count++ );
2356 qApp->processEvents(); 2371 qApp->processEvents();
2357 bday = (*it).birthday().date(); 2372 bday = (*it).birthday().date();
2358 anni = (*it).custom("KADDRESSBOOK", "X-Anniversary" ); 2373 anni = (*it).custom("KADDRESSBOOK", "X-Anniversary" );
2359 2374
2360 if ( bday.isValid() || !anni.isEmpty()) 2375 if ( bday.isValid() || !anni.isEmpty())
2361 { 2376 {
2362 if (bday.isValid()) 2377 if (bday.isValid())
2363 formattedbday = KGlobal::locale()->formatDate(bday, true, KLocale::ISODate); 2378 formattedbday = KGlobal::locale()->formatDate(bday, true, KLocale::ISODate);
2364 else 2379 else
2365 formattedbday = "NOTVALID"; 2380 formattedbday = "NOTVALID";
2366 if (anni.isEmpty()) 2381 if (anni.isEmpty())
2367 anni = "INVALID"; 2382 anni = "INVALID";
2368 2383
2369 birthdayList.append(formattedbday); 2384 birthdayList.append(formattedbday);
2370 anniversaryList.append(anni); //should be ISODate 2385 anniversaryList.append(anni); //should be ISODate
2371 realNameList.append((*it).realName()); 2386 realNameList.append((*it).realName());
2372 preferredEmailList.append((*it).preferredEmail()); 2387 preferredEmailList.append((*it).preferredEmail());
2373 assembledNameList.append((*it).assembledName()); 2388 assembledNameList.append((*it).assembledName());
2374 uidList.append((*it).uid()); 2389 uidList.append((*it).uid());
2375 2390
2376 //qDebug("found birthday in KA/Pi: %s,%s,%s,%s: %s, %s", (*it).realName().latin1(), (*it).preferredEmail().latin1(), (*it).assembledName().latin1(), (*it).uid().latin1(), formattedbday.latin1(), anni.latin1() ); 2391 //qDebug("found birthday in KA/Pi: %s,%s,%s,%s: %s, %s", (*it).realName().latin1(), (*it).preferredEmail().latin1(), (*it).assembledName().latin1(), (*it).uid().latin1(), formattedbday.latin1(), anni.latin1() );
2377 } 2392 }
2378 } 2393 }
2379 2394
2380 bool res = ExternalAppHandler::instance()->returnBirthdayListFromKAPI(sourceChannel, uid, birthdayList, anniversaryList, realNameList, preferredEmailList, assembledNameList, uidList); 2395 bool res = ExternalAppHandler::instance()->returnBirthdayListFromKAPI(sourceChannel, uid, birthdayList, anniversaryList, realNameList, preferredEmailList, assembledNameList, uidList);
2381 2396
2382} 2397}
2383 2398
2384/* this method will be called through the QCop interface from other apps to show details of a contact. 2399/* this method will be called through the QCop interface from other apps to show details of a contact.
2385 */ 2400 */
2386void KABCore::requestForDetails(const QString& sourceChannel, const QString& sessionuid, const QString& name, const QString& email, const QString& uid) 2401void KABCore::requestForDetails(const QString& sourceChannel, const QString& sessionuid, const QString& name, const QString& email, const QString& uid)
2387{ 2402{
2388 //qDebug("KABCore::requestForDetails %s %s %s %s %s", sourceChannel.latin1(), sessionuid.latin1(), name.latin1(), email.latin1(), uid.latin1()); 2403 //qDebug("KABCore::requestForDetails %s %s %s %s %s", sourceChannel.latin1(), sessionuid.latin1(), name.latin1(), email.latin1(), uid.latin1());
2389 2404
2390 QString foundUid = QString::null; 2405 QString foundUid = QString::null;
2391 if ( ! uid.isEmpty() ) { 2406 if ( ! uid.isEmpty() ) {
2392 Addressee adrr = mAddressBook->findByUid( uid ); 2407 Addressee adrr = mAddressBook->findByUid( uid );
2393 if ( !adrr.isEmpty() ) { 2408 if ( !adrr.isEmpty() ) {
2394 foundUid = uid; 2409 foundUid = uid;
2395 } 2410 }
2396 if ( email == "sendbacklist" ) { 2411 if ( email == "sendbacklist" ) {
2397 //qDebug("ssssssssssssssssssssssend "); 2412 //qDebug("ssssssssssssssssssssssend ");
2398 QStringList nameList; 2413 QStringList nameList;
2399 QStringList emailList; 2414 QStringList emailList;
2400 QStringList uidList; 2415 QStringList uidList;
2401 nameList.append(adrr.realName()); 2416 nameList.append(adrr.realName());
2402 emailList = adrr.emails(); 2417 emailList = adrr.emails();
2403 uidList.append( adrr.preferredEmail()); 2418 uidList.append( adrr.preferredEmail());
2404 bool res = ExternalAppHandler::instance()->returnNameEmailUidListFromKAPI("QPE/Application/ompi", uid, nameList, emailList, uidList); 2419 bool res = ExternalAppHandler::instance()->returnNameEmailUidListFromKAPI("QPE/Application/ompi", uid, nameList, emailList, uidList);
2405 return; 2420 return;
2406 } 2421 }
2407 2422
2408 } 2423 }
2409 2424
2410 if ( email == "sendbacklist" ) 2425 if ( email == "sendbacklist" )
2411 return; 2426 return;
2412 if (foundUid.isEmpty()) 2427 if (foundUid.isEmpty())
2413 { 2428 {
2414 //find the uid of the person first 2429 //find the uid of the person first
2415 Addressee::List namelist; 2430 Addressee::List namelist;
2416 Addressee::List emaillist; 2431 Addressee::List emaillist;
2417 2432
2418 if (!name.isEmpty()) 2433 if (!name.isEmpty())
2419 namelist = mAddressBook->findByName( name ); 2434 namelist = mAddressBook->findByName( name );
2420 2435
2421 if (!email.isEmpty()) 2436 if (!email.isEmpty())
2422 emaillist = mAddressBook->findByEmail( email ); 2437 emaillist = mAddressBook->findByEmail( email );
2423 //qDebug("count %d %d ", namelist.count(),emaillist.count() ); 2438 //qDebug("count %d %d ", namelist.count(),emaillist.count() );
2424 //check if we have a match in Namelist and Emaillist 2439 //check if we have a match in Namelist and Emaillist
2425 if ((namelist.count() == 0) && (emaillist.count() > 0)) { 2440 if ((namelist.count() == 0) && (emaillist.count() > 0)) {
2426 foundUid = emaillist[0].uid(); 2441 foundUid = emaillist[0].uid();
2427 } 2442 }
2428 else if ((namelist.count() > 0) && (emaillist.count() == 0)) 2443 else if ((namelist.count() > 0) && (emaillist.count() == 0))
2429 foundUid = namelist[0].uid(); 2444 foundUid = namelist[0].uid();
2430 else 2445 else
2431 { 2446 {
2432 for (int i = 0; i < namelist.count(); i++) 2447 for (int i = 0; i < namelist.count(); i++)
2433 { 2448 {
2434 for (int j = 0; j < emaillist.count(); j++) 2449 for (int j = 0; j < emaillist.count(); j++)
2435 { 2450 {
2436 if (namelist[i] == emaillist[j]) 2451 if (namelist[i] == emaillist[j])
2437 { 2452 {
2438 foundUid = namelist[i].uid(); 2453 foundUid = namelist[i].uid();
2439 } 2454 }
2440 } 2455 }
2441 } 2456 }
2442 } 2457 }
2443 } 2458 }
2444 else 2459 else
2445 { 2460 {
2446 foundUid = uid; 2461 foundUid = uid;
2447 } 2462 }
2448 2463
2449 if (!foundUid.isEmpty()) 2464 if (!foundUid.isEmpty())
2450 { 2465 {
2451 2466
2452 // raise Ka/Pi if it is in the background 2467 // raise Ka/Pi if it is in the background
2453#ifndef DESKTOP_VERSION 2468#ifndef DESKTOP_VERSION
2454#ifndef KORG_NODCOP 2469#ifndef KORG_NODCOP
2455 //QCopEnvelope e("QPE/Application/kapi", "raise()"); 2470 //QCopEnvelope e("QPE/Application/kapi", "raise()");
2456#endif 2471#endif
2457#endif 2472#endif
2458 2473
2459 mMainWindow->showMaximized(); 2474 mMainWindow->showMaximized();
2460 mMainWindow-> raise(); 2475 mMainWindow-> raise();
2461 2476
2462 mViewManager->setSelected( "", false); 2477 mViewManager->setSelected( "", false);
2463 mViewManager->refreshView( "" ); 2478 mViewManager->refreshView( "" );
2464 mViewManager->setSelected( foundUid, true ); 2479 mViewManager->setSelected( foundUid, true );
2465 mViewManager->refreshView( foundUid ); 2480 mViewManager->refreshView( foundUid );
2466 2481
2467 if ( !mMultipleViewsAtOnce ) 2482 if ( !mMultipleViewsAtOnce )
2468 { 2483 {
2469 setDetailsVisible( true ); 2484 setDetailsVisible( true );
2470 mActionDetails->setChecked(true); 2485 mActionDetails->setChecked(true);
2471 } 2486 }
2472 } 2487 }
2473} 2488}
2474 2489
2475void KABCore::whatsnew() 2490void KABCore::whatsnew()
2476{ 2491{
2477 KApplication::showFile( "KDE-Pim/Pi Version Info", "kdepim/WhatsNew.txt" ); 2492 KApplication::showFile( "KDE-Pim/Pi Version Info", "kdepim/WhatsNew.txt" );
2478} 2493}
2479void KABCore::synchowto() 2494void KABCore::synchowto()
2480{ 2495{
2481 KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/SyncHowto.txt" ); 2496 KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/SyncHowto.txt" );
2482} 2497}
2483void KABCore::kdesynchowto() 2498void KABCore::kdesynchowto()
2484{ 2499{
2485 KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/Zaurus-KDE_syncHowTo.txt" ); 2500 KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/Zaurus-KDE_syncHowTo.txt" );
2486} 2501}
2487void KABCore::multisynchowto() 2502void KABCore::multisynchowto()
2488{ 2503{
2489 KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/MultiSyncHowTo.txt" ); 2504 KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/MultiSyncHowTo.txt" );
2490} 2505}
2491void KABCore::faq() 2506void KABCore::faq()
2492{ 2507{
2493 KApplication::showFile( "KA/Pi FAQ", "kdepim/kaddressbook/kapiFAQ.txt" ); 2508 KApplication::showFile( "KA/Pi FAQ", "kdepim/kaddressbook/kapiFAQ.txt" );
2494} 2509}
diff --git a/kaddressbook/xxportselectdialog.cpp b/kaddressbook/xxportselectdialog.cpp
index be254c0..ab95d5f 100644
--- a/kaddressbook/xxportselectdialog.cpp
+++ b/kaddressbook/xxportselectdialog.cpp
@@ -1,288 +1,288 @@
1/* 1/*
2 This file is part of KAddressBook. 2 This file is part of KAddressBook.
3 Copyright (c) 2002 Anders Lund <anders.lund@lund.tdcadsl.dk> 3 Copyright (c) 2002 Anders Lund <anders.lund@lund.tdcadsl.dk>
4 Tobias Koenig <tokoe@kde.org> 4 Tobias Koenig <tokoe@kde.org>
5 5
6 This program is free software; you can redistribute it and/or modify 6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by 7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or 8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version. 9 (at your option) any later version.
10 10
11 This program is distributed in the hope that it will be useful, 11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of 12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details. 14 GNU General Public License for more details.
15 15
16 You should have received a copy of the GNU General Public License 16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software 17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 18 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
19 19
20 As a special exception, permission is given to link this program 20 As a special exception, permission is given to link this program
21 with any edition of Qt, and distribute the resulting executable, 21 with any edition of Qt, and distribute the resulting executable,
22 without including the source code for Qt in the source distribution. 22 without including the source code for Qt in the source distribution.
23*/ 23*/
24 24
25/* 25/*
26Enhanced Version of the file for platform independent KDE tools. 26Enhanced Version of the file for platform independent KDE tools.
27Copyright (c) 2004 Ulf Schenk 27Copyright (c) 2004 Ulf Schenk
28 28
29$Id$ 29$Id$
30*/ 30*/
31 31
32#include <kabc/addressbook.h> 32#include <kabc/addressbook.h>
33#include <kapplication.h> 33#include <kapplication.h>
34#include <kcombobox.h> 34#include <kcombobox.h>
35#include <klocale.h> 35#include <klocale.h>
36#include <kglobal.h> 36#include <kglobal.h>
37 37
38#include <qbuttongroup.h> 38#include <qbuttongroup.h>
39#include <qcombobox.h> 39#include <qcombobox.h>
40#include <qheader.h> 40#include <qheader.h>
41#include <qlabel.h> 41#include <qlabel.h>
42#include <qlayout.h> 42#include <qlayout.h>
43#include <qlistview.h> 43#include <qlistview.h>
44#include <qpushbutton.h> 44#include <qpushbutton.h>
45#include <qradiobutton.h> 45#include <qradiobutton.h>
46#include <qstringlist.h> 46#include <qstringlist.h>
47#include <qwhatsthis.h> 47#include <qwhatsthis.h>
48 48
49#include "kabcore.h" 49#include "kabcore.h"
50#include "kabprefs.h" 50#include "kabprefs.h"
51 51
52#include "xxportselectdialog.h" 52#include "xxportselectdialog.h"
53 53
54XXPortSelectDialog::XXPortSelectDialog( KABCore *core, bool sort, 54XXPortSelectDialog::XXPortSelectDialog( KABCore *core, bool sort,
55 QWidget* parent, const char* name ) 55 QWidget* parent, const char* name )
56 : KDialogBase( Plain, i18n( "Choose which contacts to export" ), Help | Ok | Cancel, 56 : KDialogBase( Plain, i18n( "Choose which contacts to select" ), Help | Ok | Cancel,
57 Ok, parent, name, true, true ), mCore( core ), 57 Ok, parent, name, true, true ), mCore( core ),
58 mUseSorting( sort ) 58 mUseSorting( sort )
59{ 59{
60 initGUI(); 60 initGUI();
61 61
62 connect( mFiltersCombo, SIGNAL( activated( int ) ), 62 connect( mFiltersCombo, SIGNAL( activated( int ) ),
63 SLOT( filterChanged( int ) ) ); 63 SLOT( filterChanged( int ) ) );
64 connect( mCategoriesView, SIGNAL( clicked( QListViewItem* ) ), 64 connect( mCategoriesView, SIGNAL( clicked( QListViewItem* ) ),
65 SLOT( categoryClicked( QListViewItem* ) ) ); 65 SLOT( categoryClicked( QListViewItem* ) ) );
66 66
67 // setup filters 67 // setup filters
68#ifndef KAB_EMBEDDED 68#ifndef KAB_EMBEDDED
69 mFilters = Filter::restore( kapp->config(), "Filter" ); 69 mFilters = Filter::restore( kapp->config(), "Filter" );
70 Filter::List::iterator filterIt; 70 Filter::List::iterator filterIt;
71#else //KAB_EMBEDDED 71#else //KAB_EMBEDDED
72 mFilters = Filter::restore( KGlobal::config(), "Filter" ); 72 mFilters = Filter::restore( KGlobal::config(), "Filter" );
73 Filter::List::Iterator filterIt; 73 Filter::List::Iterator filterIt;
74#endif //KAB_EMBEDDED 74#endif //KAB_EMBEDDED
75 QStringList filters; 75 QStringList filters;
76 for ( filterIt = mFilters.begin(); filterIt != mFilters.end(); ++filterIt ) 76 for ( filterIt = mFilters.begin(); filterIt != mFilters.end(); ++filterIt )
77 filters.append( (*filterIt).name() ); 77 filters.append( (*filterIt).name() );
78 78
79 mFiltersCombo->insertStringList( filters ); 79 mFiltersCombo->insertStringList( filters );
80 mUseFilters->setEnabled( filters.count() > 0 ); 80 mUseFilters->setEnabled( filters.count() > 0 );
81 81
82 // setup categories 82 // setup categories
83 QStringList categories = KABPrefs::instance()->mCustomCategories; 83 QStringList categories = KABPrefs::instance()->mCustomCategories;
84 QStringList::Iterator it; 84 QStringList::Iterator it;
85 for ( it = categories.begin(); it != categories.end(); ++it ) 85 for ( it = categories.begin(); it != categories.end(); ++it )
86 new QCheckListItem( mCategoriesView, *it, QCheckListItem::CheckBox ); 86 new QCheckListItem( mCategoriesView, *it, QCheckListItem::CheckBox );
87 mUseCategories->setEnabled( categories.count() > 0 ); 87 mUseCategories->setEnabled( categories.count() > 0 );
88 88
89 int count = mCore->selectedUIDs().count(); 89 int count = mCore->selectedUIDs().count();
90 mUseSelection->setEnabled( count != 0 ); 90 mUseSelection->setEnabled( count != 0 );
91 mUseSelection->setChecked( count > 1 ); 91 mUseSelection->setChecked( count > 1 );
92 92
93 mSortTypeCombo->insertItem( i18n( "Ascending" ) ); 93 mSortTypeCombo->insertItem( i18n( "Ascending" ) );
94 mSortTypeCombo->insertItem( i18n( "Descending" ) ); 94 mSortTypeCombo->insertItem( i18n( "Descending" ) );
95 95
96 mFields = mCore->addressBook()->fields( KABC::Field::All ); 96 mFields = mCore->addressBook()->fields( KABC::Field::All );
97 KABC::Field::List::Iterator fieldIt; 97 KABC::Field::List::Iterator fieldIt;
98 for ( fieldIt = mFields.begin(); fieldIt != mFields.end(); ++fieldIt ) 98 for ( fieldIt = mFields.begin(); fieldIt != mFields.end(); ++fieldIt )
99 mFieldCombo->insertItem( (*fieldIt)->label() ); 99 mFieldCombo->insertItem( (*fieldIt)->label() );
100} 100}
101 101
102QStringList XXPortSelectDialog::uids() 102QStringList XXPortSelectDialog::uids()
103{ 103{
104 QStringList uidlist; 104 QStringList uidlist;
105 KABC::AddresseeList list = contacts(); 105 KABC::AddresseeList list = contacts();
106 KABC::Addressee::List::Iterator it; 106 KABC::Addressee::List::Iterator it;
107 for ( it = list.begin(); it != list.end(); ++it ) 107 for ( it = list.begin(); it != list.end(); ++it )
108 uidlist.append((*it).uid()); 108 uidlist.append((*it).uid());
109 return uidlist; 109 return uidlist;
110} 110}
111KABC::AddresseeList XXPortSelectDialog::contacts() 111KABC::AddresseeList XXPortSelectDialog::contacts()
112{ 112{
113 QStringList selection = mCore->selectedUIDs(); 113 QStringList selection = mCore->selectedUIDs();
114 114
115 KABC::AddresseeList list; 115 KABC::AddresseeList list;
116 if ( mUseSelection->isChecked() ) { 116 if ( mUseSelection->isChecked() ) {
117 QStringList::Iterator it; 117 QStringList::Iterator it;
118 for ( it = selection.begin(); it != selection.end(); ++it ) { 118 for ( it = selection.begin(); it != selection.end(); ++it ) {
119 KABC::Addressee addr = mCore->addressBook()->findByUid( *it ); 119 KABC::Addressee addr = mCore->addressBook()->findByUid( *it );
120 if ( !addr.isEmpty() ) 120 if ( !addr.isEmpty() )
121 list.append( addr ); 121 list.append( addr );
122 } 122 }
123 } else if ( mUseFilters->isChecked() ) { 123 } else if ( mUseFilters->isChecked() ) {
124 // find contacts that can pass selected filter 124 // find contacts that can pass selected filter
125 Filter::List::Iterator filterIt; 125 Filter::List::Iterator filterIt;
126 for ( filterIt = mFilters.begin(); filterIt != mFilters.end(); ++filterIt ) 126 for ( filterIt = mFilters.begin(); filterIt != mFilters.end(); ++filterIt )
127 if ( (*filterIt).name() == mFiltersCombo->currentText() ) 127 if ( (*filterIt).name() == mFiltersCombo->currentText() )
128 break; 128 break;
129 129
130 KABC::AddressBook::Iterator it; 130 KABC::AddressBook::Iterator it;
131 for ( it = mCore->addressBook()->begin(); it != mCore->addressBook()->end(); ++it ) { 131 for ( it = mCore->addressBook()->begin(); it != mCore->addressBook()->end(); ++it ) {
132 if ( (*filterIt).filterAddressee( *it ) ) 132 if ( (*filterIt).filterAddressee( *it ) )
133 list.append( *it ); 133 list.append( *it );
134 } 134 }
135 } else if ( mUseCategories->isChecked() ) { 135 } else if ( mUseCategories->isChecked() ) {
136 QStringList categorieList = categories(); 136 QStringList categorieList = categories();
137 KABC::AddressBook::Iterator it; 137 KABC::AddressBook::Iterator it;
138 for ( it = mCore->addressBook()->begin(); it != mCore->addressBook()->end(); ++it ) { 138 for ( it = mCore->addressBook()->begin(); it != mCore->addressBook()->end(); ++it ) {
139 QStringList tmp( (*it).categories() ); 139 QStringList tmp( (*it).categories() );
140 QStringList::Iterator tmpIt; 140 QStringList::Iterator tmpIt;
141 for ( tmpIt = tmp.begin(); tmpIt != tmp.end(); ++tmpIt ) 141 for ( tmpIt = tmp.begin(); tmpIt != tmp.end(); ++tmpIt )
142 if ( categorieList.contains( *tmpIt ) ) { 142 if ( categorieList.contains( *tmpIt ) ) {
143 list.append( *it ); 143 list.append( *it );
144 break; 144 break;
145 } 145 }
146 } 146 }
147 } else { 147 } else {
148 // create a string list of all entries: 148 // create a string list of all entries:
149 KABC::AddressBook::Iterator it; 149 KABC::AddressBook::Iterator it;
150 for ( it = mCore->addressBook()->begin(); it != mCore->addressBook()->end(); ++it ) 150 for ( it = mCore->addressBook()->begin(); it != mCore->addressBook()->end(); ++it )
151 list.append( *it ); 151 list.append( *it );
152 } 152 }
153 153
154 if ( mUseSorting ) { 154 if ( mUseSorting ) {
155 list.setReverseSorting( mSortTypeCombo->currentItem() == 1 ); 155 list.setReverseSorting( mSortTypeCombo->currentItem() == 1 );
156 uint pos = mFieldCombo->currentItem(); 156 uint pos = mFieldCombo->currentItem();
157 if ( pos < mFields.count() ) 157 if ( pos < mFields.count() )
158 list.sortByField( mFields[ pos ] ); 158 list.sortByField( mFields[ pos ] );
159 } 159 }
160 160
161 return list; 161 return list;
162} 162}
163 163
164QStringList XXPortSelectDialog::categories() const 164QStringList XXPortSelectDialog::categories() const
165{ 165{
166 QStringList list; 166 QStringList list;
167 167
168 QListViewItemIterator it( mCategoriesView ); 168 QListViewItemIterator it( mCategoriesView );
169 for ( ; it.current(); ++it ) { 169 for ( ; it.current(); ++it ) {
170 QCheckListItem* qcli = static_cast<QCheckListItem*>(it.current()); 170 QCheckListItem* qcli = static_cast<QCheckListItem*>(it.current());
171 if ( qcli->isOn() ) 171 if ( qcli->isOn() )
172 list.append( it.current()->text( 0 ) ); 172 list.append( it.current()->text( 0 ) );
173 } 173 }
174 174
175 return list; 175 return list;
176} 176}
177 177
178void XXPortSelectDialog::filterChanged( int ) 178void XXPortSelectDialog::filterChanged( int )
179{ 179{
180 mUseFilters->setChecked( true ); 180 mUseFilters->setChecked( true );
181} 181}
182 182
183void XXPortSelectDialog::categoryClicked( QListViewItem *i ) 183void XXPortSelectDialog::categoryClicked( QListViewItem *i )
184{ 184{
185 QCheckListItem *qcli = static_cast<QCheckListItem*>( i ); 185 QCheckListItem *qcli = static_cast<QCheckListItem*>( i );
186 if ( qcli->isOn() ) 186 if ( qcli->isOn() )
187 mUseCategories->setChecked( true ); 187 mUseCategories->setChecked( true );
188} 188}
189 189
190void XXPortSelectDialog::slotHelp() 190void XXPortSelectDialog::slotHelp()
191{ 191{
192#ifndef KAB_EMBEDDED 192#ifndef KAB_EMBEDDED
193 kapp->invokeHelp( "import-and-export" ); 193 kapp->invokeHelp( "import-and-export" );
194#else //KAB_EMBEDDED 194#else //KAB_EMBEDDED
195 qDebug("XXPortSelectDialog::slotHelp is not implemented yet"); 195 qDebug("XXPortSelectDialog::slotHelp is not implemented yet");
196#endif //KAB_EMBEDDED 196#endif //KAB_EMBEDDED
197 197
198} 198}
199 199
200void XXPortSelectDialog::initGUI() 200void XXPortSelectDialog::initGUI()
201{ 201{
202 QFrame *page = plainPage(); 202 QFrame *page = plainPage();
203 203
204 QVBoxLayout *topLayout = new QVBoxLayout( page, KDialog::marginHint(), 204 QVBoxLayout *topLayout = new QVBoxLayout( page, KDialog::marginHint(),
205 KDialog::spacingHint() ); 205 KDialog::spacingHint() );
206 206
207 QLabel *label = new QLabel( i18n( "Which contacts do you want to export?" ), page ); 207 QLabel *label = new QLabel( i18n( "Which contacts do you want to select?" ), page );
208 topLayout->addWidget( label ); 208 topLayout->addWidget( label );
209 209
210 mButtonGroup = new QButtonGroup( i18n( "Contact Selection" ), page ); 210 mButtonGroup = new QButtonGroup( i18n( "Contact Selection" ), page );
211 mButtonGroup->setColumnLayout( 0, Qt::Vertical ); 211 mButtonGroup->setColumnLayout( 0, Qt::Vertical );
212 mButtonGroup->layout()->setSpacing( KDialog::spacingHint() ); 212 mButtonGroup->layout()->setSpacing( KDialog::spacingHint() );
213 mButtonGroup->layout()->setMargin( KDialog::marginHint() ); 213 mButtonGroup->layout()->setMargin( KDialog::marginHint() );
214 214
215 QGridLayout *groupLayout = new QGridLayout( mButtonGroup->layout() ); 215 QGridLayout *groupLayout = new QGridLayout( mButtonGroup->layout() );
216 groupLayout->setAlignment( Qt::AlignTop ); 216 groupLayout->setAlignment( Qt::AlignTop );
217 217
218 mUseWholeBook = new QRadioButton( i18n( "&All" ), mButtonGroup ); 218 mUseWholeBook = new QRadioButton( i18n( "&All" ), mButtonGroup );
219 mUseWholeBook->setChecked( true ); 219 mUseWholeBook->setChecked( true );
220 QWhatsThis::add( mUseWholeBook, i18n( "Export the entire address book" ) ); 220 QWhatsThis::add( mUseWholeBook, i18n( "Select the entire address book" ) );
221 groupLayout->addWidget( mUseWholeBook, 0, 0 ); 221 groupLayout->addWidget( mUseWholeBook, 0, 0 );
222 222
223 mUseSelection = new QRadioButton( i18n( "&Selected" ), mButtonGroup ); 223 mUseSelection = new QRadioButton( i18n( "&Selected" ), mButtonGroup );
224 QWhatsThis::add( mUseSelection, i18n( "Only export contacts selected in KAddressBook.\n" 224 QWhatsThis::add( mUseSelection, i18n( "Only contacts selected in KAddressBook.\n"
225 "This option is disabled if no contacts are selected." ) ); 225 "This option is disabled if no contacts are selected." ) );
226 groupLayout->addWidget( mUseSelection, 1, 0 ); 226 groupLayout->addWidget( mUseSelection, 1, 0 );
227 227
228 mUseFilters = new QRadioButton( i18n( "By matching &filter" ), mButtonGroup ); 228 mUseFilters = new QRadioButton( i18n( "By matching &filter" ), mButtonGroup );
229 QWhatsThis::add( mUseFilters, i18n( "Only export contacts matching the selected filter.\n" 229 QWhatsThis::add( mUseFilters, i18n( "Only contacts matching the selected filter.\n"
230 "This option is disabled if you haven't defined any filters" ) ); 230 "This option is disabled if you haven't defined any filters" ) );
231 groupLayout->addWidget( mUseFilters, 2, 0 ); 231 groupLayout->addWidget( mUseFilters, 2, 0 );
232 232
233 mUseCategories = new QRadioButton( i18n( "By Cate&gories" ), mButtonGroup ); 233 mUseCategories = new QRadioButton( i18n( "By Cate&gories" ), mButtonGroup );
234 QWhatsThis::add( mUseCategories, i18n( "Only export contacts who are members of a category that is checked on the list to the left.\n" 234 QWhatsThis::add( mUseCategories, i18n( "Only contacts who are members of a category that is checked on the list to the left.\n"
235 "This option is disabled if you have no categories." ) ); 235 "This option is disabled if you have no categories." ) );
236 groupLayout->addWidget( mUseCategories, 3, 0 ); 236 groupLayout->addWidget( mUseCategories, 3, 0 );
237 237
238 mFiltersCombo = new QComboBox( false, mButtonGroup ); 238 mFiltersCombo = new QComboBox( false, mButtonGroup );
239 QWhatsThis::add( mFiltersCombo, i18n( "Select a filter to decide which contacts to export." ) ); 239 QWhatsThis::add( mFiltersCombo, i18n( "Select a filter to decide which contacts to select." ) );
240 groupLayout->addWidget( mFiltersCombo, 2, 1 ); 240 groupLayout->addWidget( mFiltersCombo, 2, 1 );
241 241
242 mCategoriesView = new QListView( mButtonGroup ); 242 mCategoriesView = new QListView( mButtonGroup );
243 mCategoriesView->addColumn( "" ); 243 mCategoriesView->addColumn( "" );
244 mCategoriesView->header()->hide(); 244 mCategoriesView->header()->hide();
245 QWhatsThis::add( mCategoriesView, i18n( "Check the categories whose members you want to export." ) ); 245 QWhatsThis::add( mCategoriesView, i18n( "Check the categories whose members you want to select." ) );
246 groupLayout->addWidget( mCategoriesView, 3, 1 ); 246 groupLayout->addWidget( mCategoriesView, 3, 1 );
247 247
248 topLayout->addWidget( mButtonGroup ); 248 topLayout->addWidget( mButtonGroup );
249 249
250 QButtonGroup *sortingGroup = new QButtonGroup( i18n( "Sorting" ), page ); 250 QButtonGroup *sortingGroup = new QButtonGroup( i18n( "Sorting" ), page );
251 sortingGroup->setColumnLayout( 0, Qt::Vertical ); 251 sortingGroup->setColumnLayout( 0, Qt::Vertical );
252 QGridLayout *sortLayout = new QGridLayout( sortingGroup->layout(), 2, 2, 252 QGridLayout *sortLayout = new QGridLayout( sortingGroup->layout(), 2, 2,
253 KDialog::spacingHint() ); 253 KDialog::spacingHint() );
254 sortLayout->setAlignment( Qt::AlignTop ); 254 sortLayout->setAlignment( Qt::AlignTop );
255 255
256 label = new QLabel( i18n( "Criterion:" ), sortingGroup ); 256 label = new QLabel( i18n( "Criterion:" ), sortingGroup );
257 sortLayout->addWidget( label, 0, 0 ); 257 sortLayout->addWidget( label, 0, 0 );
258 258
259#ifndef KAB_EMBEDDED 259#ifndef KAB_EMBEDDED
260 mFieldCombo = new KComboBox( false, sortingGroup ); 260 mFieldCombo = new KComboBox( false, sortingGroup );
261#else //KAB_EMBEDDED 261#else //KAB_EMBEDDED
262 //US Combobox is not editable anyway 262 //US Combobox is not editable anyway
263 mFieldCombo = new KComboBox( sortingGroup ); 263 mFieldCombo = new KComboBox( sortingGroup );
264#endif //KAB_EMBEDDED 264#endif //KAB_EMBEDDED
265 sortLayout->addWidget( mFieldCombo, 0, 1 ); 265 sortLayout->addWidget( mFieldCombo, 0, 1 );
266 266
267 label = new QLabel( i18n( "Order:" ), sortingGroup ); 267 label = new QLabel( i18n( "Order:" ), sortingGroup );
268 sortLayout->addWidget( label, 1, 0 ); 268 sortLayout->addWidget( label, 1, 0 );
269 269
270#ifndef KAB_EMBEDDED 270#ifndef KAB_EMBEDDED
271 mSortTypeCombo = new KComboBox( false, sortingGroup ); 271 mSortTypeCombo = new KComboBox( false, sortingGroup );
272#else //KAB_EMBEDDED 272#else //KAB_EMBEDDED
273 //US Combobox is not editable anyway 273 //US Combobox is not editable anyway
274 mSortTypeCombo = new KComboBox( sortingGroup ); 274 mSortTypeCombo = new KComboBox( sortingGroup );
275#endif //KAB_EMBEDDED 275#endif //KAB_EMBEDDED
276 sortLayout->addWidget( mSortTypeCombo, 1, 1 ); 276 sortLayout->addWidget( mSortTypeCombo, 1, 1 );
277 277
278 topLayout->addWidget( sortingGroup ); 278 topLayout->addWidget( sortingGroup );
279 279
280 if ( !mUseSorting ) 280 if ( !mUseSorting )
281 sortingGroup->hide(); 281 sortingGroup->hide();
282} 282}
283 283
284#ifndef KAB_EMBEDDED 284#ifndef KAB_EMBEDDED
285#include "xxportselectdialog.moc" 285#include "xxportselectdialog.moc"
286#endif //KAB_EMBEDDED 286#endif //KAB_EMBEDDED
287 287
288 288