summaryrefslogtreecommitdiffabout
path: root/kaddressbook
authorzautrix <zautrix>2005-01-17 15:26:56 (UTC)
committer zautrix <zautrix>2005-01-17 15:26:56 (UTC)
commit1525820e30e14de83a15533a3c67aa2756a544f4 (patch) (unidiff)
treecb8083c4675c874b5cac9355acc4d746077b6692 /kaddressbook
parent214b82c86bd5365d7a5fc786c8c9c7231ec6dc77 (diff)
downloadkdepimpi-1525820e30e14de83a15533a3c67aa2756a544f4.zip
kdepimpi-1525820e30e14de83a15533a3c67aa2756a544f4.tar.gz
kdepimpi-1525820e30e14de83a15533a3c67aa2756a544f4.tar.bz2
AB fixes
Diffstat (limited to 'kaddressbook') (more/less context) (ignore whitespace changes)
-rw-r--r--kaddressbook/kabcore.cpp4
-rw-r--r--kaddressbook/viewmanager.cpp9
-rw-r--r--kaddressbook/viewmanager.h1
3 files changed, 9 insertions, 5 deletions
diff --git a/kaddressbook/kabcore.cpp b/kaddressbook/kabcore.cpp
index a480baf..9526f23 100644
--- a/kaddressbook/kabcore.cpp
+++ b/kaddressbook/kabcore.cpp
@@ -312,354 +312,354 @@ KABCore::KABCore( KXMLGUIClient *client, bool readWrite, QWidget *parent, const
312#if 0 312#if 0
313 // LP moved to addressbook init method 313 // LP moved to addressbook init method
314 mAddressBook->addCustomField( i18n( "Department" ), KABC::Field::Organization, 314 mAddressBook->addCustomField( i18n( "Department" ), KABC::Field::Organization,
315 "X-Department", "KADDRESSBOOK" ); 315 "X-Department", "KADDRESSBOOK" );
316 mAddressBook->addCustomField( i18n( "Profession" ), KABC::Field::Organization, 316 mAddressBook->addCustomField( i18n( "Profession" ), KABC::Field::Organization,
317 "X-Profession", "KADDRESSBOOK" ); 317 "X-Profession", "KADDRESSBOOK" );
318 mAddressBook->addCustomField( i18n( "Assistant's Name" ), KABC::Field::Organization, 318 mAddressBook->addCustomField( i18n( "Assistant's Name" ), KABC::Field::Organization,
319 "X-AssistantsName", "KADDRESSBOOK" ); 319 "X-AssistantsName", "KADDRESSBOOK" );
320 mAddressBook->addCustomField( i18n( "Manager's Name" ), KABC::Field::Organization, 320 mAddressBook->addCustomField( i18n( "Manager's Name" ), KABC::Field::Organization,
321 "X-ManagersName", "KADDRESSBOOK" ); 321 "X-ManagersName", "KADDRESSBOOK" );
322 mAddressBook->addCustomField( i18n( "Spouse's Name" ), KABC::Field::Personal, 322 mAddressBook->addCustomField( i18n( "Spouse's Name" ), KABC::Field::Personal,
323 "X-SpousesName", "KADDRESSBOOK" ); 323 "X-SpousesName", "KADDRESSBOOK" );
324 mAddressBook->addCustomField( i18n( "Office" ), KABC::Field::Personal, 324 mAddressBook->addCustomField( i18n( "Office" ), KABC::Field::Personal,
325 "X-Office", "KADDRESSBOOK" ); 325 "X-Office", "KADDRESSBOOK" );
326 mAddressBook->addCustomField( i18n( "IM Address" ), KABC::Field::Personal, 326 mAddressBook->addCustomField( i18n( "IM Address" ), KABC::Field::Personal,
327 "X-IMAddress", "KADDRESSBOOK" ); 327 "X-IMAddress", "KADDRESSBOOK" );
328 mAddressBook->addCustomField( i18n( "Anniversary" ), KABC::Field::Personal, 328 mAddressBook->addCustomField( i18n( "Anniversary" ), KABC::Field::Personal,
329 "X-Anniversary", "KADDRESSBOOK" ); 329 "X-Anniversary", "KADDRESSBOOK" );
330 330
331 //US added this field to become compatible with Opie/qtopia addressbook 331 //US added this field to become compatible with Opie/qtopia addressbook
332 // values can be "female" or "male" or "". An empty field represents undefined. 332 // values can be "female" or "male" or "". An empty field represents undefined.
333 mAddressBook->addCustomField( i18n( "Gender" ), KABC::Field::Personal, 333 mAddressBook->addCustomField( i18n( "Gender" ), KABC::Field::Personal,
334 "X-Gender", "KADDRESSBOOK" ); 334 "X-Gender", "KADDRESSBOOK" );
335 mAddressBook->addCustomField( i18n( "Children" ), KABC::Field::Personal, 335 mAddressBook->addCustomField( i18n( "Children" ), KABC::Field::Personal,
336 "X-Children", "KADDRESSBOOK" ); 336 "X-Children", "KADDRESSBOOK" );
337 mAddressBook->addCustomField( i18n( "FreeBusyUrl" ), KABC::Field::Personal, 337 mAddressBook->addCustomField( i18n( "FreeBusyUrl" ), KABC::Field::Personal,
338 "X-FreeBusyUrl", "KADDRESSBOOK" ); 338 "X-FreeBusyUrl", "KADDRESSBOOK" );
339#endif 339#endif
340 initGUI(); 340 initGUI();
341 341
342 mIncSearchWidget->setFocus(); 342 mIncSearchWidget->setFocus();
343 343
344 344
345 connect( mViewManager, SIGNAL( selected( const QString& ) ), 345 connect( mViewManager, SIGNAL( selected( const QString& ) ),
346 SLOT( setContactSelected( const QString& ) ) ); 346 SLOT( setContactSelected( const QString& ) ) );
347 connect( mViewManager, SIGNAL( executed( const QString& ) ), 347 connect( mViewManager, SIGNAL( executed( const QString& ) ),
348 SLOT( executeContact( const QString& ) ) ); 348 SLOT( executeContact( const QString& ) ) );
349 349
350 connect( mViewManager, SIGNAL( deleteRequest( ) ), 350 connect( mViewManager, SIGNAL( deleteRequest( ) ),
351 SLOT( deleteContacts( ) ) ); 351 SLOT( deleteContacts( ) ) );
352 connect( mViewManager, SIGNAL( modified() ), 352 connect( mViewManager, SIGNAL( modified() ),
353 SLOT( setModified() ) ); 353 SLOT( setModified() ) );
354 354
355 connect( mExtensionManager, SIGNAL( modified( const KABC::Addressee::List& ) ), this, SLOT( extensionModified( const KABC::Addressee::List& ) ) ); 355 connect( mExtensionManager, SIGNAL( modified( const KABC::Addressee::List& ) ), this, SLOT( extensionModified( const KABC::Addressee::List& ) ) );
356 connect( mExtensionManager, SIGNAL( changedActiveExtension( int ) ), this, SLOT( extensionChanged( int ) ) ); 356 connect( mExtensionManager, SIGNAL( changedActiveExtension( int ) ), this, SLOT( extensionChanged( int ) ) );
357 357
358 connect( mXXPortManager, SIGNAL( modified() ), 358 connect( mXXPortManager, SIGNAL( modified() ),
359 SLOT( setModified() ) ); 359 SLOT( setModified() ) );
360 360
361 connect( mJumpButtonBar, SIGNAL( jumpToLetter( const QString& ) ), 361 connect( mJumpButtonBar, SIGNAL( jumpToLetter( const QString& ) ),
362 SLOT( incrementalSearch( const QString& ) ) ); 362 SLOT( incrementalSearch( const QString& ) ) );
363 connect( mIncSearchWidget, SIGNAL( fieldChanged() ), 363 connect( mIncSearchWidget, SIGNAL( fieldChanged() ),
364 mJumpButtonBar, SLOT( recreateButtons() ) ); 364 mJumpButtonBar, SLOT( recreateButtons() ) );
365 365
366 connect( mDetails, SIGNAL( sendEmail( const QString& ) ), 366 connect( mDetails, SIGNAL( sendEmail( const QString& ) ),
367 SLOT( sendMail( const QString& ) ) ); 367 SLOT( sendMail( const QString& ) ) );
368 368
369 369
370 connect( ExternalAppHandler::instance(), SIGNAL (requestForNameEmailUidList(const QString&, const QString&)),this, SLOT(requestForNameEmailUidList(const QString&, const QString&))); 370 connect( ExternalAppHandler::instance(), SIGNAL (requestForNameEmailUidList(const QString&, const QString&)),this, SLOT(requestForNameEmailUidList(const QString&, const QString&)));
371 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&))); 371 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&)));
372 connect( ExternalAppHandler::instance(), SIGNAL (requestForBirthdayList(const QString&, const QString&)),this, SLOT(requestForBirthdayList(const QString&, const QString&))); 372 connect( ExternalAppHandler::instance(), SIGNAL (requestForBirthdayList(const QString&, const QString&)),this, SLOT(requestForBirthdayList(const QString&, const QString&)));
373 connect( ExternalAppHandler::instance(), SIGNAL (nextView()),this, SLOT(setDetailsToggle())); 373 connect( ExternalAppHandler::instance(), SIGNAL (nextView()),this, SLOT(setDetailsToggle()));
374 374
375 375
376#ifndef KAB_EMBEDDED 376#ifndef KAB_EMBEDDED
377 connect( mViewManager, SIGNAL( urlDropped( const KURL& ) ), 377 connect( mViewManager, SIGNAL( urlDropped( const KURL& ) ),
378 mXXPortManager, SLOT( importVCard( const KURL& ) ) ); 378 mXXPortManager, SLOT( importVCard( const KURL& ) ) );
379 379
380 connect( mDetails, SIGNAL( browse( const QString& ) ), 380 connect( mDetails, SIGNAL( browse( const QString& ) ),
381 SLOT( browse( const QString& ) ) ); 381 SLOT( browse( const QString& ) ) );
382 382
383 383
384 mAddressBookService = new KAddressBookService( this ); 384 mAddressBookService = new KAddressBookService( this );
385 385
386#endif //KAB_EMBEDDED 386#endif //KAB_EMBEDDED
387 387
388 mMessageTimer = new QTimer( this ); 388 mMessageTimer = new QTimer( this );
389 connect( mMessageTimer, SIGNAL( timeout() ), this, SLOT( setCaptionBack() ) ); 389 connect( mMessageTimer, SIGNAL( timeout() ), this, SLOT( setCaptionBack() ) );
390 mEditorDialog = 0; 390 mEditorDialog = 0;
391 createAddresseeEditorDialog( this ); 391 createAddresseeEditorDialog( this );
392 setModified( false ); 392 setModified( false );
393 mBRdisabled = false; 393 mBRdisabled = false;
394#ifndef DESKTOP_VERSION 394#ifndef DESKTOP_VERSION
395 infrared = 0; 395 infrared = 0;
396#endif 396#endif
397 //toggleBeamReceive( ); 397 //toggleBeamReceive( );
398 //mMainWindow->toolBar()->show(); 398 //mMainWindow->toolBar()->show();
399 // we have a toolbar repainting error on the Zaurus when starting KA/Pi 399 // we have a toolbar repainting error on the Zaurus when starting KA/Pi
400 QTimer::singleShot( 10, this , SLOT ( updateToolBar())); 400 QTimer::singleShot( 10, this , SLOT ( updateToolBar()));
401} 401}
402 402
403void KABCore::updateToolBar() 403void KABCore::updateToolBar()
404{ 404{
405 static int iii = 0; 405 static int iii = 0;
406 ++iii; 406 ++iii;
407 mMainWindow->toolBar()->repaintMe(); 407 mMainWindow->toolBar()->repaintMe();
408 if ( iii < 5 ) 408 if ( iii < 3 )
409 QTimer::singleShot( 10, this , SLOT ( updateToolBar())); 409 QTimer::singleShot( 10, this , SLOT ( updateToolBar()));
410} 410}
411KABCore::~KABCore() 411KABCore::~KABCore()
412{ 412{
413 // save(); 413 // save();
414 //saveSettings(); 414 //saveSettings();
415 //KABPrefs::instance()->writeConfig(); 415 //KABPrefs::instance()->writeConfig();
416 delete AddresseeConfig::instance(); 416 delete AddresseeConfig::instance();
417 mAddressBook = 0; 417 mAddressBook = 0;
418 KABC::StdAddressBook::close(); 418 KABC::StdAddressBook::close();
419 419
420 delete syncManager; 420 delete syncManager;
421#ifndef DESKTOP_VERSION 421#ifndef DESKTOP_VERSION
422 if ( infrared ) 422 if ( infrared )
423 delete infrared; 423 delete infrared;
424#endif 424#endif
425} 425}
426void KABCore::receive( const QCString& cmsg, const QByteArray& data ) 426void KABCore::receive( const QCString& cmsg, const QByteArray& data )
427{ 427{
428 qDebug("KA: QCOP message received: %s ", cmsg.data() ); 428 qDebug("KA: QCOP message received: %s ", cmsg.data() );
429 if ( cmsg == "setDocument(QString)" ) { 429 if ( cmsg == "setDocument(QString)" ) {
430 QDataStream stream( data, IO_ReadOnly ); 430 QDataStream stream( data, IO_ReadOnly );
431 QString fileName; 431 QString fileName;
432 stream >> fileName; 432 stream >> fileName;
433 recieve( fileName ); 433 recieve( fileName );
434 return; 434 return;
435 } 435 }
436} 436}
437void KABCore::toggleBeamReceive( ) 437void KABCore::toggleBeamReceive( )
438{ 438{
439 if ( mBRdisabled ) 439 if ( mBRdisabled )
440 return; 440 return;
441#ifndef DESKTOP_VERSION 441#ifndef DESKTOP_VERSION
442 if ( infrared ) { 442 if ( infrared ) {
443 qDebug("AB disable BeamReceive "); 443 qDebug("AB disable BeamReceive ");
444 delete infrared; 444 delete infrared;
445 infrared = 0; 445 infrared = 0;
446 mActionBR->setChecked(false); 446 mActionBR->setChecked(false);
447 return; 447 return;
448 } 448 }
449 qDebug("AB enable BeamReceive "); 449 qDebug("AB enable BeamReceive ");
450 mActionBR->setChecked(true); 450 mActionBR->setChecked(true);
451 451
452 infrared = new QCopChannel("QPE/Application/addressbook",this, "channelAB" ) ; 452 infrared = new QCopChannel("QPE/Application/addressbook",this, "channelAB" ) ;
453 QObject::connect( infrared, SIGNAL (received ( const QCString &, const QByteArray & )),this, SLOT(receive( const QCString&, const QByteArray& ))); 453 QObject::connect( infrared, SIGNAL (received ( const QCString &, const QByteArray & )),this, SLOT(receive( const QCString&, const QByteArray& )));
454#endif 454#endif
455} 455}
456 456
457 457
458void KABCore::disableBR(bool b) 458void KABCore::disableBR(bool b)
459{ 459{
460#ifndef DESKTOP_VERSION 460#ifndef DESKTOP_VERSION
461 if ( b ) { 461 if ( b ) {
462 if ( infrared ) { 462 if ( infrared ) {
463 toggleBeamReceive( ); 463 toggleBeamReceive( );
464 } 464 }
465 mBRdisabled = true; 465 mBRdisabled = true;
466 } else { 466 } else {
467 if ( mBRdisabled ) { 467 if ( mBRdisabled ) {
468 mBRdisabled = false; 468 mBRdisabled = false;
469 //toggleBeamReceive( ); 469 //toggleBeamReceive( );
470 } 470 }
471 } 471 }
472#endif 472#endif
473 473
474} 474}
475void KABCore::recieve( QString fn ) 475void KABCore::recieve( QString fn )
476{ 476{
477 //qDebug("KABCore::recieve "); 477 //qDebug("KABCore::recieve ");
478 int count = mAddressBook->importFromFile( fn, true ); 478 int count = mAddressBook->importFromFile( fn, true );
479 if ( count ) 479 if ( count )
480 setModified( true ); 480 setModified( true );
481 mViewManager->refreshView(); 481 mViewManager->refreshView();
482 message(i18n("%1 contact(s) received!").arg( count )); 482 message(i18n("%1 contact(s) received!").arg( count ));
483 topLevelWidget()->showMaximized(); 483 topLevelWidget()->showMaximized();
484 topLevelWidget()->raise(); 484 topLevelWidget()->raise();
485} 485}
486void KABCore::restoreSettings() 486void KABCore::restoreSettings()
487{ 487{
488 mMultipleViewsAtOnce = KABPrefs::instance()->mMultipleViewsAtOnce; 488 mMultipleViewsAtOnce = KABPrefs::instance()->mMultipleViewsAtOnce;
489 489
490 bool state; 490 bool state;
491 491
492 if (mMultipleViewsAtOnce) 492 if (mMultipleViewsAtOnce)
493 state = KABPrefs::instance()->mDetailsPageVisible; 493 state = KABPrefs::instance()->mDetailsPageVisible;
494 else 494 else
495 state = false; 495 state = false;
496 496
497 mActionDetails->setChecked( state ); 497 mActionDetails->setChecked( state );
498 setDetailsVisible( state ); 498 setDetailsVisible( state );
499 499
500 state = KABPrefs::instance()->mJumpButtonBarVisible; 500 state = KABPrefs::instance()->mJumpButtonBarVisible;
501 501
502 mActionJumpBar->setChecked( state ); 502 mActionJumpBar->setChecked( state );
503 setJumpButtonBarVisible( state ); 503 setJumpButtonBarVisible( state );
504/*US 504/*US
505 QValueList<int> splitterSize = KABPrefs::instance()->mDetailsSplitter; 505 QValueList<int> splitterSize = KABPrefs::instance()->mDetailsSplitter;
506 if ( splitterSize.count() == 0 ) { 506 if ( splitterSize.count() == 0 ) {
507 splitterSize.append( width() / 2 ); 507 splitterSize.append( width() / 2 );
508 splitterSize.append( width() / 2 ); 508 splitterSize.append( width() / 2 );
509 } 509 }
510 mMiniSplitter->setSizes( splitterSize ); 510 mMiniSplitter->setSizes( splitterSize );
511 if ( mExtensionBarSplitter ) { 511 if ( mExtensionBarSplitter ) {
512 splitterSize = KABPrefs::instance()->mExtensionsSplitter; 512 splitterSize = KABPrefs::instance()->mExtensionsSplitter;
513 if ( splitterSize.count() == 0 ) { 513 if ( splitterSize.count() == 0 ) {
514 splitterSize.append( width() / 2 ); 514 splitterSize.append( width() / 2 );
515 splitterSize.append( width() / 2 ); 515 splitterSize.append( width() / 2 );
516 } 516 }
517 mExtensionBarSplitter->setSizes( splitterSize ); 517 mExtensionBarSplitter->setSizes( splitterSize );
518 518
519 } 519 }
520*/ 520*/
521 mViewManager->restoreSettings(); 521 mViewManager->restoreSettings();
522 mIncSearchWidget->setCurrentItem( KABPrefs::instance()->mCurrentIncSearchField ); 522 mIncSearchWidget->setCurrentItem( KABPrefs::instance()->mCurrentIncSearchField );
523 mExtensionManager->restoreSettings(); 523 mExtensionManager->restoreSettings();
524#ifdef DESKTOP_VERSION 524#ifdef DESKTOP_VERSION
525 int wid = width(); 525 int wid = width();
526 if ( wid < 10 ) 526 if ( wid < 10 )
527 wid = 400; 527 wid = 400;
528#else 528#else
529 int wid = QApplication::desktop()->width(); 529 int wid = QApplication::desktop()->width();
530 if ( wid < 640 ) 530 if ( wid < 640 )
531 wid = QApplication::desktop()->height(); 531 wid = QApplication::desktop()->height();
532#endif 532#endif
533 QValueList<int> splitterSize;// = KABPrefs::instance()->mDetailsSplitter; 533 QValueList<int> splitterSize;// = KABPrefs::instance()->mDetailsSplitter;
534 if ( true /*splitterSize.count() == 0*/ ) { 534 if ( true /*splitterSize.count() == 0*/ ) {
535 splitterSize.append( wid / 2 ); 535 splitterSize.append( wid / 2 );
536 splitterSize.append( wid / 2 ); 536 splitterSize.append( wid / 2 );
537 } 537 }
538 mMiniSplitter->setSizes( splitterSize ); 538 mMiniSplitter->setSizes( splitterSize );
539 if ( mExtensionBarSplitter ) { 539 if ( mExtensionBarSplitter ) {
540 //splitterSize = KABPrefs::instance()->mExtensionsSplitter; 540 //splitterSize = KABPrefs::instance()->mExtensionsSplitter;
541 if ( true /*splitterSize.count() == 0*/ ) { 541 if ( true /*splitterSize.count() == 0*/ ) {
542 splitterSize.append( wid / 2 ); 542 splitterSize.append( wid / 2 );
543 splitterSize.append( wid / 2 ); 543 splitterSize.append( wid / 2 );
544 } 544 }
545 mExtensionBarSplitter->setSizes( splitterSize ); 545 mExtensionBarSplitter->setSizes( splitterSize );
546 546
547 } 547 }
548 548
549 549
550} 550}
551 551
552void KABCore::saveSettings() 552void KABCore::saveSettings()
553{ 553{
554 KABPrefs::instance()->mJumpButtonBarVisible = mActionJumpBar->isChecked(); 554 KABPrefs::instance()->mJumpButtonBarVisible = mActionJumpBar->isChecked();
555 if ( mExtensionBarSplitter ) 555 if ( mExtensionBarSplitter )
556 KABPrefs::instance()->mExtensionsSplitter = mExtensionBarSplitter->sizes(); 556 KABPrefs::instance()->mExtensionsSplitter = mExtensionBarSplitter->sizes();
557 KABPrefs::instance()->mDetailsPageVisible = mActionDetails->isChecked(); 557 KABPrefs::instance()->mDetailsPageVisible = mActionDetails->isChecked();
558 KABPrefs::instance()->mDetailsSplitter = mMiniSplitter->sizes(); 558 KABPrefs::instance()->mDetailsSplitter = mMiniSplitter->sizes();
559#ifndef KAB_EMBEDDED 559#ifndef KAB_EMBEDDED
560 560
561 KABPrefs::instance()->mExtensionsSplitter = mExtensionBarSplitter->sizes(); 561 KABPrefs::instance()->mExtensionsSplitter = mExtensionBarSplitter->sizes();
562 KABPrefs::instance()->mDetailsSplitter = mDetailsSplitter->sizes(); 562 KABPrefs::instance()->mDetailsSplitter = mDetailsSplitter->sizes();
563#endif //KAB_EMBEDDED 563#endif //KAB_EMBEDDED
564 mExtensionManager->saveSettings(); 564 mExtensionManager->saveSettings();
565 mViewManager->saveSettings(); 565 mViewManager->saveSettings();
566 566
567 KABPrefs::instance()->mCurrentIncSearchField = mIncSearchWidget->currentItem(); 567 KABPrefs::instance()->mCurrentIncSearchField = mIncSearchWidget->currentItem();
568 KABPrefs::instance()->writeConfig(); 568 KABPrefs::instance()->writeConfig();
569 qDebug("KABPrefs::instance()->writeConfig() "); 569 qDebug("KABCore::saveSettings() ");
570} 570}
571 571
572KABC::AddressBook *KABCore::addressBook() const 572KABC::AddressBook *KABCore::addressBook() const
573{ 573{
574 return mAddressBook; 574 return mAddressBook;
575} 575}
576 576
577KConfig *KABCore::config() 577KConfig *KABCore::config()
578{ 578{
579#ifndef KAB_EMBEDDED 579#ifndef KAB_EMBEDDED
580 return KABPrefs::instance()->config(); 580 return KABPrefs::instance()->config();
581#else //KAB_EMBEDDED 581#else //KAB_EMBEDDED
582 return KABPrefs::instance()->getConfig(); 582 return KABPrefs::instance()->getConfig();
583#endif //KAB_EMBEDDED 583#endif //KAB_EMBEDDED
584} 584}
585 585
586KActionCollection *KABCore::actionCollection() const 586KActionCollection *KABCore::actionCollection() const
587{ 587{
588 return mGUIClient->actionCollection(); 588 return mGUIClient->actionCollection();
589} 589}
590 590
591KABC::Field *KABCore::currentSearchField() const 591KABC::Field *KABCore::currentSearchField() const
592{ 592{
593 if (mIncSearchWidget) 593 if (mIncSearchWidget)
594 return mIncSearchWidget->currentField(); 594 return mIncSearchWidget->currentField();
595 else 595 else
596 return 0; 596 return 0;
597} 597}
598 598
599QStringList KABCore::selectedUIDs() const 599QStringList KABCore::selectedUIDs() const
600{ 600{
601 return mViewManager->selectedUids(); 601 return mViewManager->selectedUids();
602} 602}
603 603
604KABC::Resource *KABCore::requestResource( QWidget *parent ) 604KABC::Resource *KABCore::requestResource( QWidget *parent )
605{ 605{
606 QPtrList<KABC::Resource> kabcResources = addressBook()->resources(); 606 QPtrList<KABC::Resource> kabcResources = addressBook()->resources();
607 607
608 QPtrList<KRES::Resource> kresResources; 608 QPtrList<KRES::Resource> kresResources;
609 QPtrListIterator<KABC::Resource> resIt( kabcResources ); 609 QPtrListIterator<KABC::Resource> resIt( kabcResources );
610 KABC::Resource *resource; 610 KABC::Resource *resource;
611 while ( ( resource = resIt.current() ) != 0 ) { 611 while ( ( resource = resIt.current() ) != 0 ) {
612 ++resIt; 612 ++resIt;
613 if ( !resource->readOnly() ) { 613 if ( !resource->readOnly() ) {
614 KRES::Resource *res = static_cast<KRES::Resource*>( resource ); 614 KRES::Resource *res = static_cast<KRES::Resource*>( resource );
615 if ( res ) 615 if ( res )
616 kresResources.append( res ); 616 kresResources.append( res );
617 } 617 }
618 } 618 }
619 619
620 KRES::Resource *res = KRES::SelectDialog::getResource( kresResources, parent ); 620 KRES::Resource *res = KRES::SelectDialog::getResource( kresResources, parent );
621 return static_cast<KABC::Resource*>( res ); 621 return static_cast<KABC::Resource*>( res );
622} 622}
623 623
624#ifndef KAB_EMBEDDED 624#ifndef KAB_EMBEDDED
625KAboutData *KABCore::createAboutData() 625KAboutData *KABCore::createAboutData()
626#else //KAB_EMBEDDED 626#else //KAB_EMBEDDED
627void KABCore::createAboutData() 627void KABCore::createAboutData()
628#endif //KAB_EMBEDDED 628#endif //KAB_EMBEDDED
629{ 629{
630#ifndef KAB_EMBEDDED 630#ifndef KAB_EMBEDDED
631 KAboutData *about = new KAboutData( "kaddressbook", I18N_NOOP( "KAddressBook" ), 631 KAboutData *about = new KAboutData( "kaddressbook", I18N_NOOP( "KAddressBook" ),
632 "3.1", I18N_NOOP( "The KDE Address Book" ), 632 "3.1", I18N_NOOP( "The KDE Address Book" ),
633 KAboutData::License_GPL_V2, 633 KAboutData::License_GPL_V2,
634 I18N_NOOP( "(c) 1997-2003, The KDE PIM Team" ) ); 634 I18N_NOOP( "(c) 1997-2003, The KDE PIM Team" ) );
635 about->addAuthor( "Tobias Koenig", I18N_NOOP( "Current maintainer " ), "tokoe@kde.org" ); 635 about->addAuthor( "Tobias Koenig", I18N_NOOP( "Current maintainer " ), "tokoe@kde.org" );
636 about->addAuthor( "Don Sanders", I18N_NOOP( "Original author " ) ); 636 about->addAuthor( "Don Sanders", I18N_NOOP( "Original author " ) );
637 about->addAuthor( "Cornelius Schumacher", 637 about->addAuthor( "Cornelius Schumacher",
638 I18N_NOOP( "Co-maintainer, libkabc port, CSV import/export " ), 638 I18N_NOOP( "Co-maintainer, libkabc port, CSV import/export " ),
639 "schumacher@kde.org" ); 639 "schumacher@kde.org" );
640 about->addAuthor( "Mike Pilone", I18N_NOOP( "GUI and framework redesign " ), 640 about->addAuthor( "Mike Pilone", I18N_NOOP( "GUI and framework redesign " ),
641 "mpilone@slac.com" ); 641 "mpilone@slac.com" );
642 about->addAuthor( "Greg Stern", I18N_NOOP( "DCOP interface" ) ); 642 about->addAuthor( "Greg Stern", I18N_NOOP( "DCOP interface" ) );
643 about->addAuthor( "Mark Westcott", I18N_NOOP( "Contact pinning" ) ); 643 about->addAuthor( "Mark Westcott", I18N_NOOP( "Contact pinning" ) );
644 about->addAuthor( "Michel Boyer de la Giroday", I18N_NOOP( "LDAP Lookup\n" ), 644 about->addAuthor( "Michel Boyer de la Giroday", I18N_NOOP( "LDAP Lookup\n" ),
645 "michel@klaralvdalens-datakonsult.se" ); 645 "michel@klaralvdalens-datakonsult.se" );
646 about->addAuthor( "Steffen Hansen", I18N_NOOP( "LDAP Lookup " ), 646 about->addAuthor( "Steffen Hansen", I18N_NOOP( "LDAP Lookup " ),
647 "hansen@kde.org" ); 647 "hansen@kde.org" );
648 648
649 return about; 649 return about;
650#endif //KAB_EMBEDDED 650#endif //KAB_EMBEDDED
651 651
652 QString version; 652 QString version;
653#include <../version> 653#include <../version>
654 QMessageBox::about( this, "About KAddressbook/Pi", 654 QMessageBox::about( this, "About KAddressbook/Pi",
655 "KAddressbook/Platform-independent\n" 655 "KAddressbook/Platform-independent\n"
656 "(KA/Pi) " +version + " - " + 656 "(KA/Pi) " +version + " - " +
657#ifdef DESKTOP_VERSION 657#ifdef DESKTOP_VERSION
658 "Desktop Edition\n" 658 "Desktop Edition\n"
659#else 659#else
660 "PDA-Edition\n" 660 "PDA-Edition\n"
661 "for: Zaurus 5500 / 7x0 / 8x0\n" 661 "for: Zaurus 5500 / 7x0 / 8x0\n"
662#endif 662#endif
663 663
664 "(c) 2004 Ulf Schenk\n" 664 "(c) 2004 Ulf Schenk\n"
665 "(c) 2004 Lutz Rogowski\n" 665 "(c) 2004 Lutz Rogowski\n"
diff --git a/kaddressbook/viewmanager.cpp b/kaddressbook/viewmanager.cpp
index 4be860e..04759a7 100644
--- a/kaddressbook/viewmanager.cpp
+++ b/kaddressbook/viewmanager.cpp
@@ -111,272 +111,276 @@ void ViewManager::restoreSettings()
111 if (QApplication::desktop()->width() == 480 ) 111 if (QApplication::desktop()->width() == 480 )
112 cw = 0; 112 cw = 0;
113 mActionSelectFilter->setComboWidth( cw ); 113 mActionSelectFilter->setComboWidth( cw );
114 // Tell the views to reread their config, since they may have 114 // Tell the views to reread their config, since they may have
115 // been modified by global settings 115 // been modified by global settings
116 QString _oldgroup = mCore->config()->group(); 116 QString _oldgroup = mCore->config()->group();
117 117
118 QDictIterator<KAddressBookView> it( mViewDict ); 118 QDictIterator<KAddressBookView> it( mViewDict );
119 for ( it.toFirst(); it.current(); ++it ) { 119 for ( it.toFirst(); it.current(); ++it ) {
120 KConfigGroupSaver saver( mCore->config(), it.currentKey() ); 120 KConfigGroupSaver saver( mCore->config(), it.currentKey() );
121 it.current()->readConfig( mCore->config() ); 121 it.current()->readConfig( mCore->config() );
122 } 122 }
123 setActiveView( activeViewName ); 123 setActiveView( activeViewName );
124 124
125 mActionDeleteView->setEnabled( mViewNameList.count() > 1 ); 125 mActionDeleteView->setEnabled( mViewNameList.count() > 1 );
126} 126}
127 127
128void ViewManager::saveSettings() 128void ViewManager::saveSettings()
129{ 129{
130 QString _oldgroup = mCore->config()->group(); 130 QString _oldgroup = mCore->config()->group();
131 131
132 QDictIterator<KAddressBookView> it( mViewDict ); 132 QDictIterator<KAddressBookView> it( mViewDict );
133 for ( it.toFirst(); it.current(); ++it ) { 133 for ( it.toFirst(); it.current(); ++it ) {
134 KConfigGroupSaver saver( mCore->config(), it.currentKey() ); 134 KConfigGroupSaver saver( mCore->config(), it.currentKey() );
135#ifdef DESKTOP_VERSION 135#ifdef DESKTOP_VERSION
136 (*it)->writeConfig( mCore->config() ); 136 (*it)->writeConfig( mCore->config() );
137#else 137#else
138 (*it).writeConfig( mCore->config() ); 138 (*it).writeConfig( mCore->config() );
139#endif 139#endif
140 } 140 }
141 141
142 Filter::save( mCore->config(), "Filter", mFilterList ); 142 Filter::save( mCore->config(), "Filter", mFilterList );
143 KABPrefs::instance()->mCurrentFilter = mActionSelectFilter->currentItem(); 143 KABPrefs::instance()->mCurrentFilter = mActionSelectFilter->currentItem();
144 144
145 // write the view name list 145 // write the view name list
146 KABPrefs::instance()->mViewNames = mViewNameList; 146 KABPrefs::instance()->mViewNames = mViewNameList;
147 KABPrefs::instance()->mCurrentView = mActiveView->caption(); 147 KABPrefs::instance()->mCurrentView = mActiveView->caption();
148 148
149} 149}
150 150
151QStringList ViewManager::selectedUids() const 151QStringList ViewManager::selectedUids() const
152{ 152{
153 if ( mActiveView ) 153 if ( mActiveView )
154 return mActiveView->selectedUids(); 154 return mActiveView->selectedUids();
155 else 155 else
156 return QStringList(); 156 return QStringList();
157} 157}
158 158
159QStringList ViewManager::selectedEmails() const 159QStringList ViewManager::selectedEmails() const
160{ 160{
161 if ( mActiveView ) 161 if ( mActiveView )
162 return mActiveView->selectedEmails(); 162 return mActiveView->selectedEmails();
163 else 163 else
164 return QStringList(); 164 return QStringList();
165} 165}
166 166
167KABC::Addressee::List ViewManager::selectedAddressees() const 167KABC::Addressee::List ViewManager::selectedAddressees() const
168{ 168{
169 KABC::Addressee::List list; 169 KABC::Addressee::List list;
170 if ( mActiveView ) { 170 if ( mActiveView ) {
171 QStringList uids = mActiveView->selectedUids(); 171 QStringList uids = mActiveView->selectedUids();
172 QStringList::Iterator it; 172 QStringList::Iterator it;
173 for ( it = uids.begin(); it != uids.end(); ++it ) { 173 for ( it = uids.begin(); it != uids.end(); ++it ) {
174 KABC::Addressee addr = mCore->addressBook()->findByUid( *it ); 174 KABC::Addressee addr = mCore->addressBook()->findByUid( *it );
175 if ( !addr.isEmpty() ) 175 if ( !addr.isEmpty() )
176 list.append( addr ); 176 list.append( addr );
177 } 177 }
178 } 178 }
179 179
180 return list; 180 return list;
181} 181}
182//US added another method with no parameter, since my moc compiler does not support default parameters. 182//US added another method with no parameter, since my moc compiler does not support default parameters.
183void ViewManager::setSelected() 183void ViewManager::setSelected()
184{ 184{
185 setSelected( QString::null, true ); 185 setSelected( QString::null, true );
186} 186}
187 187
188void ViewManager::setSelected( const QString &uid, bool selected ) 188void ViewManager::setSelected( const QString &uid, bool selected )
189{ 189{
190 if ( mActiveView ) 190 if ( mActiveView )
191 mActiveView->setSelected( uid, selected ); 191 mActiveView->setSelected( uid, selected );
192} 192}
193 193
194void ViewManager::setListSelected(QStringList list) 194void ViewManager::setListSelected(QStringList list)
195{ 195{
196 int i, count = list.count(); 196 int i, count = list.count();
197 for ( i = 0; i < count;++i ) 197 for ( i = 0; i < count;++i )
198 setSelected( list[i], true ); 198 setSelected( list[i], true );
199 199
200} 200}
201void ViewManager::unloadViews() 201void ViewManager::unloadViews()
202{ 202{
203 mViewDict.clear(); 203 mViewDict.clear();
204 mActiveView = 0; 204 mActiveView = 0;
205} 205}
206 206
207void ViewManager::selectView( const QString &name )
208{
209 setActiveView( name );
210 mCore->saveSettings();
211}
207void ViewManager::setActiveView( const QString &name ) 212void ViewManager::setActiveView( const QString &name )
208{ 213{
209 KAddressBookView *view = 0; 214 KAddressBookView *view = 0;
210 215
211 // Check that this isn't the same as the current active view 216 // Check that this isn't the same as the current active view
212 if ( mActiveView && ( mActiveView->caption() == name ) ) 217 if ( mActiveView && ( mActiveView->caption() == name ) )
213 return; 218 return;
214 219
215 // At this point we know the view that should be active is not 220 // At this point we know the view that should be active is not
216 // currently active. We will try to find the new on in the list. If 221 // currently active. We will try to find the new on in the list. If
217 // we can't find it, it means it hasn't been instantiated, so we will 222 // we can't find it, it means it hasn't been instantiated, so we will
218 // create it on demand. 223 // create it on demand.
219 224
220 view = mViewDict.find( name ); 225 view = mViewDict.find( name );
221 226
222 // Check if we found the view. If we didn't, then we need to create it 227 // Check if we found the view. If we didn't, then we need to create it
223 if ( view == 0 ) { 228 if ( view == 0 ) {
224 KConfig *config = mCore->config(); 229 KConfig *config = mCore->config();
225 230
226 KConfigGroupSaver saver( config, name ); 231 KConfigGroupSaver saver( config, name );
227 232
228 QString type = config->readEntry( "Type", "Table" ); 233 QString type = config->readEntry( "Type", "Table" );
229 234
230 kdDebug(5720) << "ViewManager::setActiveView: creating view - " << name << endl; 235 kdDebug(5720) << "ViewManager::setActiveView: creating view - " << name << endl;
231 236
232 ViewFactory *factory = mViewFactoryDict.find( type ); 237 ViewFactory *factory = mViewFactoryDict.find( type );
233 if ( factory ) 238 if ( factory )
234 view = factory->view( mCore->addressBook(), mViewWidgetStack ); 239 view = factory->view( mCore->addressBook(), mViewWidgetStack );
235 240
236 if ( view ) { 241 if ( view ) {
237 view->setCaption( name ); 242 view->setCaption( name );
238 mViewDict.insert( name, view ); 243 mViewDict.insert( name, view );
239//US my version needs an int as second parameter to addWidget 244//US my version needs an int as second parameter to addWidget
240 mViewWidgetStack->addWidget( view, -1 ); 245 mViewWidgetStack->addWidget( view, -1 );
241 view->readConfig( config ); 246 view->readConfig( config );
242 247
243 // The manager just relays the signals 248 // The manager just relays the signals
244 connect( view, SIGNAL( selected( const QString& ) ), 249 connect( view, SIGNAL( selected( const QString& ) ),
245 SIGNAL( selected( const QString & ) ) ); 250 SIGNAL( selected( const QString & ) ) );
246 connect( view, SIGNAL( executed( const QString& ) ), 251 connect( view, SIGNAL( executed( const QString& ) ),
247 SIGNAL( executed( const QString& ) ) ); 252 SIGNAL( executed( const QString& ) ) );
248 253
249 connect( view, SIGNAL( deleteRequest( ) ), 254 connect( view, SIGNAL( deleteRequest( ) ),
250 SIGNAL( deleteRequest( ) ) ); 255 SIGNAL( deleteRequest( ) ) );
251 256
252 connect( view, SIGNAL( modified() ), SIGNAL( modified() ) ); 257 connect( view, SIGNAL( modified() ), SIGNAL( modified() ) );
253 connect( view, SIGNAL( dropped( QDropEvent* ) ), 258 connect( view, SIGNAL( dropped( QDropEvent* ) ),
254 SLOT( dropped( QDropEvent* ) ) ); 259 SLOT( dropped( QDropEvent* ) ) );
255 connect( view, SIGNAL( startDrag() ), SLOT( startDrag() ) ); 260 connect( view, SIGNAL( startDrag() ), SLOT( startDrag() ) );
256 } 261 }
257 } 262 }
258 263
259 // If we found or created the view, raise it and refresh it 264 // If we found or created the view, raise it and refresh it
260 if ( view ) { 265 if ( view ) {
261 mActiveView = view; 266 mActiveView = view;
262 mViewWidgetStack->raiseWidget( view ); 267 mViewWidgetStack->raiseWidget( view );
263 // Set the proper filter in the view. By setting the combo 268 // Set the proper filter in the view. By setting the combo
264 // box, the activated slot will be called, which will push 269 // box, the activated slot will be called, which will push
265 // the filter to the view and refresh it. 270 // the filter to the view and refresh it.
266 271
267 if ( view->defaultFilterType() == KAddressBookView::None ) { 272 if ( view->defaultFilterType() == KAddressBookView::None ) {
268 273
269 mActionSelectFilter->setCurrentItem( 0 ); 274 mActionSelectFilter->setCurrentItem( 0 );
270 setActiveFilter( 0 ); 275 setActiveFilter( 0 );
271 } else if ( view->defaultFilterType() == KAddressBookView::Active ) { 276 } else if ( view->defaultFilterType() == KAddressBookView::Active ) {
272 setActiveFilter( mActionSelectFilter->currentItem() ); 277 setActiveFilter( mActionSelectFilter->currentItem() );
273 } else { 278 } else {
274 uint pos = filterPosition( view->defaultFilterName() ); 279 uint pos = filterPosition( view->defaultFilterName() );
275 mActionSelectFilter->setCurrentItem( pos ); 280 mActionSelectFilter->setCurrentItem( pos );
276 setActiveFilter( pos ); 281 setActiveFilter( pos );
277 } 282 }
278//US qDebug("ViewManager::setActiveView 6" ); 283//US qDebug("ViewManager::setActiveView 6" );
279 284
280 // Update the inc search widget to show the fields in the new active 285 // Update the inc search widget to show the fields in the new active
281 // view. 286 // view.
282 mCore->setSearchFields( mActiveView->fields() ); 287 mCore->setSearchFields( mActiveView->fields() );
283 288
284//US performance optimization. setActiveFilter calls also mActiveView->refresh() 289//US performance optimization. setActiveFilter calls also mActiveView->refresh()
285//US mActiveView->refresh(); 290//US mActiveView->refresh();
286 mCore->saveSettings();
287 } 291 }
288 else 292 else
289 { 293 {
290 qDebug("ViewManager::setActiveView: unable to find view" ); 294 qDebug("ViewManager::setActiveView: unable to find view" );
291 } 295 }
292} 296}
293 297
294//US added another method with no parameter, since my moc compiler does not support default parameters. 298//US added another method with no parameter, since my moc compiler does not support default parameters.
295void ViewManager::refreshView() 299void ViewManager::refreshView()
296{ 300{
297 refreshView( QString::null ); 301 refreshView( QString::null );
298} 302}
299 303
300void ViewManager::refreshView( const QString &uid ) 304void ViewManager::refreshView( const QString &uid )
301{ 305{
302 if ( mActiveView ) 306 if ( mActiveView )
303 mActiveView->refresh( uid ); 307 mActiveView->refresh( uid );
304} 308}
305 309
306void ViewManager::setFocusAV() 310void ViewManager::setFocusAV()
307{ 311{
308 if ( mActiveView ) 312 if ( mActiveView )
309 mActiveView->setFocusAV(); 313 mActiveView->setFocusAV();
310} 314}
311void ViewManager::editView() 315void ViewManager::editView()
312{ 316{
313 if ( !mActiveView ) 317 if ( !mActiveView )
314 return; 318 return;
315 319
316 ViewFactory *factory = mViewFactoryDict.find( mActiveView->type() ); 320 ViewFactory *factory = mViewFactoryDict.find( mActiveView->type() );
317 ViewConfigureWidget *wdg = 0; 321 ViewConfigureWidget *wdg = 0;
318 ViewConfigureDialog* dlg = 0; 322 ViewConfigureDialog* dlg = 0;
319 if ( factory ) { 323 if ( factory ) {
320 // Save the filters so the dialog has the latest set 324 // Save the filters so the dialog has the latest set
321 Filter::save( mCore->config(), "Filter", mFilterList ); 325 Filter::save( mCore->config(), "Filter", mFilterList );
322 dlg = new ViewConfigureDialog( 0, mActiveView->caption(), this, "conf_dlg" ); 326 dlg = new ViewConfigureDialog( 0, mActiveView->caption(), this, "conf_dlg" );
323 wdg = factory->configureWidget( mCore->addressBook(), dlg,"conf_wid" ); 327 wdg = factory->configureWidget( mCore->addressBook(), dlg,"conf_wid" );
324 } else { 328 } else {
325 qDebug("ViewManager::editView()::cannot find viewfactory "); 329 qDebug("ViewManager::editView()::cannot find viewfactory ");
326 return; 330 return;
327 } 331 }
328 if ( wdg ) { 332 if ( wdg ) {
329 dlg->setWidget( wdg ); 333 dlg->setWidget( wdg );
330 334
331#ifndef DESKTOP_VERSION 335#ifndef DESKTOP_VERSION
332 //dlg.setMaximumSize( 640, 480 ); 336 //dlg.setMaximumSize( 640, 480 );
333 //dlg->setGeometry( 40,40, 400, 300); 337 //dlg->setGeometry( 40,40, 400, 300);
334 dlg->showMaximized(); 338 dlg->showMaximized();
335#endif 339#endif
336 340
337 KConfigGroupSaver saver( mCore->config(), mActiveView->caption() ); 341 KConfigGroupSaver saver( mCore->config(), mActiveView->caption() );
338 342
339 dlg->restoreSettings( mCore->config() ); 343 dlg->restoreSettings( mCore->config() );
340 344
341 if ( dlg->exec() ) { 345 if ( dlg->exec() ) {
342 dlg->saveSettings( mCore->config() ); 346 dlg->saveSettings( mCore->config() );
343 mActiveView->readConfig( mCore->config() ); 347 mActiveView->readConfig( mCore->config() );
344 348
345 // Set the proper filter in the view. By setting the combo 349 // Set the proper filter in the view. By setting the combo
346 // box, the activated slot will be called, which will push 350 // box, the activated slot will be called, which will push
347 // the filter to the view and refresh it. 351 // the filter to the view and refresh it.
348 if ( mActiveView->defaultFilterType() == KAddressBookView::None ) { 352 if ( mActiveView->defaultFilterType() == KAddressBookView::None ) {
349 mActionSelectFilter->setCurrentItem( 0 ); 353 mActionSelectFilter->setCurrentItem( 0 );
350 setActiveFilter( 0 ); 354 setActiveFilter( 0 );
351 } else if ( mActiveView->defaultFilterType() == KAddressBookView::Active ) { 355 } else if ( mActiveView->defaultFilterType() == KAddressBookView::Active ) {
352 setActiveFilter( mActionSelectFilter->currentItem() ); 356 setActiveFilter( mActionSelectFilter->currentItem() );
353 } else { 357 } else {
354 uint pos = filterPosition( mActiveView->defaultFilterName() ); 358 uint pos = filterPosition( mActiveView->defaultFilterName() );
355 mActionSelectFilter->setCurrentItem( pos ); 359 mActionSelectFilter->setCurrentItem( pos );
356 setActiveFilter( pos ); 360 setActiveFilter( pos );
357 } 361 }
358 mCore->setSearchFields( mActiveView->fields() ); 362 mCore->setSearchFields( mActiveView->fields() );
359//US performance optimization. setActiveFilter calls also mActiveView->refresh() 363//US performance optimization. setActiveFilter calls also mActiveView->refresh()
360//US mActiveView->refresh(); 364//US mActiveView->refresh();
361 365
362 366
363 //US this is a bugfix, that we get notified if we change a views configuration 367 //US this is a bugfix, that we get notified if we change a views configuration
364 emit modified(); 368 emit modified();
365 369
366 } 370 }
367 371
368 } 372 }
369 delete dlg; 373 delete dlg;
370} 374}
371 375
372void ViewManager::deleteView() 376void ViewManager::deleteView()
373{ 377{
374 QString text = i18n( "<qt>Are you sure that you want to delete the view <b>%1</b>?</qt>" ) 378 QString text = i18n( "<qt>Are you sure that you want to delete the view <b>%1</b>?</qt>" )
375 .arg( mActiveView->caption() ); 379 .arg( mActiveView->caption() );
376 QString caption = i18n( "Confirm Delete" ); 380 QString caption = i18n( "Confirm Delete" );
377 381
378 382
379 if (QMessageBox::information( this, caption, 383 if (QMessageBox::information( this, caption,
380 text, 384 text,
381 i18n("Yes!"), i18n("No"), 0, 0 ) == 0) 385 i18n("Yes!"), i18n("No"), 0, 0 ) == 0)
382 { 386 {
@@ -396,339 +400,338 @@ void ViewManager::deleteView()
396 mActionSelectView->setCurrentItem( 0 ); 400 mActionSelectView->setCurrentItem( 0 );
397 setActiveView( mViewNameList[ 0 ] ); 401 setActiveView( mViewNameList[ 0 ] );
398 } 402 }
399 mActionDeleteView->setEnabled( mViewNameList.count() > 1 ); 403 mActionDeleteView->setEnabled( mViewNameList.count() > 1 );
400 } 404 }
401} 405}
402 406
403void ViewManager::addView() 407void ViewManager::addView()
404{ 408{
405 AddViewDialog dialog( &mViewFactoryDict, this ); 409 AddViewDialog dialog( &mViewFactoryDict, this );
406 410
407 if ( dialog.exec() ) { 411 if ( dialog.exec() ) {
408 QString newName = dialog.viewName(); 412 QString newName = dialog.viewName();
409 QString type = dialog.viewType(); 413 QString type = dialog.viewType();
410 414
411 // Check for name conflicts 415 // Check for name conflicts
412 bool firstConflict = true; 416 bool firstConflict = true;
413 int numTries = 1; 417 int numTries = 1;
414 while ( mViewNameList.contains( newName ) > 0 ) { 418 while ( mViewNameList.contains( newName ) > 0 ) {
415 if ( !firstConflict ) { 419 if ( !firstConflict ) {
416 newName = newName.left( newName.length() - 4 ); 420 newName = newName.left( newName.length() - 4 );
417 firstConflict = false; 421 firstConflict = false;
418 } 422 }
419 423
420 newName = QString( "%1 <%2>" ).arg( newName ).arg( numTries ); 424 newName = QString( "%1 <%2>" ).arg( newName ).arg( numTries );
421 numTries++; 425 numTries++;
422 } 426 }
423 427
424 // Add the new one to the list 428 // Add the new one to the list
425 mViewNameList.append( newName ); 429 mViewNameList.append( newName );
426 430
427 // write the view to the config file, 431 // write the view to the config file,
428 KConfig *config = mCore->config(); 432 KConfig *config = mCore->config();
429 433
430 config->deleteGroup( newName ); 434 config->deleteGroup( newName );
431 435
432 KConfigGroupSaver saver( config, newName ); 436 KConfigGroupSaver saver( config, newName );
433 437
434 config->writeEntry( "Type", type ); 438 config->writeEntry( "Type", type );
435 439
436 // try to set the active view 440 // try to set the active view
437 mActionSelectView->setItems( mViewNameList ); 441 mActionSelectView->setItems( mViewNameList );
438 mActionSelectView->setCurrentItem( mViewNameList.findIndex( newName ) ); 442 mActionSelectView->setCurrentItem( mViewNameList.findIndex( newName ) );
439 setActiveView( newName ); 443 setActiveView( newName );
440 444
441 editView(); 445 editView();
442 446
443 mActionDeleteView->setEnabled( mViewNameList.count() > 1 ); 447 mActionDeleteView->setEnabled( mViewNameList.count() > 1 );
444 } 448 }
445} 449}
446 450
447void ViewManager::createViewFactories() 451void ViewManager::createViewFactories()
448{ 452{
449#ifndef KAB_EMBEDDED 453#ifndef KAB_EMBEDDED
450 KTrader::OfferList plugins = KTrader::self()->query( "KAddressBook/View" ); 454 KTrader::OfferList plugins = KTrader::self()->query( "KAddressBook/View" );
451 KTrader::OfferList::ConstIterator it; 455 KTrader::OfferList::ConstIterator it;
452 for ( it = plugins.begin(); it != plugins.end(); ++it ) { 456 for ( it = plugins.begin(); it != plugins.end(); ++it ) {
453 if ( !(*it)->hasServiceType( "KAddressBook/View" ) ) 457 if ( !(*it)->hasServiceType( "KAddressBook/View" ) )
454 continue; 458 continue;
455 459
456 KLibFactory *factory = KLibLoader::self()->factory( (*it)->library().latin1() ); 460 KLibFactory *factory = KLibLoader::self()->factory( (*it)->library().latin1() );
457 461
458 if ( !factory ) { 462 if ( !factory ) {
459 kdDebug(5720) << "ViewManager::createViewFactories(): Factory creation failed" << endl; 463 kdDebug(5720) << "ViewManager::createViewFactories(): Factory creation failed" << endl;
460 continue; 464 continue;
461 } 465 }
462 466
463 ViewFactory *viewFactory = static_cast<ViewFactory*>( factory ); 467 ViewFactory *viewFactory = static_cast<ViewFactory*>( factory );
464 468
465 if ( !viewFactory ) { 469 if ( !viewFactory ) {
466 kdDebug(5720) << "ViewManager::createViewFactories(): Cast failed" << endl; 470 kdDebug(5720) << "ViewManager::createViewFactories(): Cast failed" << endl;
467 continue; 471 continue;
468 } 472 }
469 473
470 mViewFactoryDict.insert( viewFactory->type(), viewFactory ); 474 mViewFactoryDict.insert( viewFactory->type(), viewFactory );
471 } 475 }
472 476
473#else //KAB_EMBEDDED 477#else //KAB_EMBEDDED
474 ViewFactory* viewFactory = new IconViewFactory(); 478 ViewFactory* viewFactory = new IconViewFactory();
475 mViewFactoryDict.insert( viewFactory->type(), viewFactory ); 479 mViewFactoryDict.insert( viewFactory->type(), viewFactory );
476// qDebug("ViewManager::createViewFactories() Loading factory: %s", viewFactory->type().latin1()); 480// qDebug("ViewManager::createViewFactories() Loading factory: %s", viewFactory->type().latin1());
477 481
478 viewFactory = new TableViewFactory(); 482 viewFactory = new TableViewFactory();
479 mViewFactoryDict.insert( viewFactory->type(), viewFactory ); 483 mViewFactoryDict.insert( viewFactory->type(), viewFactory );
480// qDebug("ViewManager::createViewFactories() Loading factory: %s", viewFactory->type().latin1()); 484// qDebug("ViewManager::createViewFactories() Loading factory: %s", viewFactory->type().latin1());
481 485
482 viewFactory = new CardViewFactory(); 486 viewFactory = new CardViewFactory();
483 mViewFactoryDict.insert( viewFactory->type(), viewFactory ); 487 mViewFactoryDict.insert( viewFactory->type(), viewFactory );
484// qDebug("ViewManager::createViewFactories() Loading factory: %s", viewFactory->type().latin1()); 488// qDebug("ViewManager::createViewFactories() Loading factory: %s", viewFactory->type().latin1());
485 489
486#endif //KAB_EMBEDDED 490#endif //KAB_EMBEDDED
487 491
488} 492}
489 493
490void ViewManager::dropped( QDropEvent *e ) 494void ViewManager::dropped( QDropEvent *e )
491{ 495{
492 kdDebug(5720) << "ViewManager::dropped: got a drop event" << endl;
493 496
494#ifndef KAB_EMBEDDED 497#ifndef KAB_EMBEDDED
495 498
496 QString clipText, vcards; 499 QString clipText, vcards;
497 KURL::List urls; 500 KURL::List urls;
498 501
499 if ( KURLDrag::decode( e, urls) ) { 502 if ( KURLDrag::decode( e, urls) ) {
500 KURL::List::Iterator it = urls.begin(); 503 KURL::List::Iterator it = urls.begin();
501 int c = urls.count(); 504 int c = urls.count();
502 if ( c > 1 ) { 505 if ( c > 1 ) {
503 QString questionString = i18n( "Import one contact into your addressbook?", "Import %n contacts into your addressbook?", c ); 506 QString questionString = i18n( "Import one contact into your addressbook?", "Import %n contacts into your addressbook?", c );
504 if ( KMessageBox::questionYesNo( this, questionString, i18n( "Import Contacts?" ) ) == KMessageBox::Yes ) { 507 if ( KMessageBox::questionYesNo( this, questionString, i18n( "Import Contacts?" ) ) == KMessageBox::Yes ) {
505 for ( ; it != urls.end(); ++it ) 508 for ( ; it != urls.end(); ++it )
506 emit urlDropped( *it ); 509 emit urlDropped( *it );
507 } 510 }
508 } else if ( c == 1 ) 511 } else if ( c == 1 )
509 emit urlDropped( *it ); 512 emit urlDropped( *it );
510 } else if ( KVCardDrag::decode( e, vcards ) ) { 513 } else if ( KVCardDrag::decode( e, vcards ) ) {
511 KABC::Addressee addr; 514 KABC::Addressee addr;
512 KABC::VCardConverter converter; 515 KABC::VCardConverter converter;
513 QStringList list = QStringList::split( "\r\n\r\n", vcards ); 516 QStringList list = QStringList::split( "\r\n\r\n", vcards );
514 QStringList::Iterator it; 517 QStringList::Iterator it;
515 for ( it = list.begin(); it != list.end(); ++it ) { 518 for ( it = list.begin(); it != list.end(); ++it ) {
516 if ( converter.vCardToAddressee( (*it).stripWhiteSpace(), addr ) ) { 519 if ( converter.vCardToAddressee( (*it).stripWhiteSpace(), addr ) ) {
517 KABC::Addressee a = mCore->addressBook()->findByUid( addr.uid() ); 520 KABC::Addressee a = mCore->addressBook()->findByUid( addr.uid() );
518 if ( a.isEmpty() ) { 521 if ( a.isEmpty() ) {
519 mCore->addressBook()->insertAddressee( addr ); 522 mCore->addressBook()->insertAddressee( addr );
520 emit modified(); 523 emit modified();
521 } 524 }
522 } 525 }
523 } 526 }
524 527
525 mActiveView->refresh(); 528 mActiveView->refresh();
526 } 529 }
527#else //KAB_EMBEDDED 530#else //KAB_EMBEDDED
528qDebug("ViewManager::dropped() has to be changed!!" ); 531qDebug("ViewManager::dropped() has to be changed!!" );
529#endif //KAB_EMBEDDED 532#endif //KAB_EMBEDDED
530 533
531} 534}
532 535
533void ViewManager::startDrag() 536void ViewManager::startDrag()
534{ 537{
535 kdDebug(5720) << "ViewManager::startDrag: starting to drag" << endl; 538 kdDebug(5720) << "ViewManager::startDrag: starting to drag" << endl;
536 539
537#ifndef KAB_EMBEDDED 540#ifndef KAB_EMBEDDED
538 541
539 // Get the list of all the selected addressees 542 // Get the list of all the selected addressees
540 KABC::Addressee::List addrList; 543 KABC::Addressee::List addrList;
541 QStringList uidList = selectedUids(); 544 QStringList uidList = selectedUids();
542 QStringList::Iterator iter; 545 QStringList::Iterator iter;
543 for ( iter = uidList.begin(); iter != uidList.end(); ++iter ) 546 for ( iter = uidList.begin(); iter != uidList.end(); ++iter )
544 addrList.append( mCore->addressBook()->findByUid( *iter ) ); 547 addrList.append( mCore->addressBook()->findByUid( *iter ) );
545 548
546 KMultipleDrag *drag = new KMultipleDrag( this ); 549 KMultipleDrag *drag = new KMultipleDrag( this );
547 drag->addDragObject( new QTextDrag( AddresseeUtil::addresseesToClipboard(addrList), this ) ); 550 drag->addDragObject( new QTextDrag( AddresseeUtil::addresseesToClipboard(addrList), this ) );
548 KABC::Addressee::List::Iterator it; 551 KABC::Addressee::List::Iterator it;
549 QStringList vcards; 552 QStringList vcards;
550 for ( it = addrList.begin(); it != addrList.end(); ++it ) { 553 for ( it = addrList.begin(); it != addrList.end(); ++it ) {
551 QString vcard = QString::null; 554 QString vcard = QString::null;
552 KABC::VCardConverter converter; 555 KABC::VCardConverter converter;
553 if ( converter.addresseeToVCard( *it, vcard ) ) 556 if ( converter.addresseeToVCard( *it, vcard ) )
554 vcards.append( vcard ); 557 vcards.append( vcard );
555 } 558 }
556 drag->addDragObject( new KVCardDrag( vcards.join( "\r\n" ), this ) ); 559 drag->addDragObject( new KVCardDrag( vcards.join( "\r\n" ), this ) );
557 560
558 drag->setPixmap( KGlobal::iconLoader()->loadIcon( "vcard", KIcon::Desktop ) ); 561 drag->setPixmap( KGlobal::iconLoader()->loadIcon( "vcard", KIcon::Desktop ) );
559 drag->dragCopy(); 562 drag->dragCopy();
560 563
561#else //KAB_EMBEDDED 564#else //KAB_EMBEDDED
562qDebug("ViewManager::startDrag() has to be changed!!" ); 565qDebug("ViewManager::startDrag() has to be changed!!" );
563#endif //KAB_EMBEDDED 566#endif //KAB_EMBEDDED
564 567
565} 568}
566void ViewManager::doSearch( const QString& s,KABC::Field *field ) 569void ViewManager::doSearch( const QString& s,KABC::Field *field )
567{ 570{
568 if ( mActiveView ) 571 if ( mActiveView )
569 mActiveView->doSearch( s, field ); 572 mActiveView->doSearch( s, field );
570 573
571} 574}
572void ViewManager::setActiveFilter( int index ) 575void ViewManager::setActiveFilter( int index )
573{ 576{
574 Filter currentFilter; 577 Filter currentFilter;
575 578
576 if ( ( index - 1 ) < 0 ) 579 if ( ( index - 1 ) < 0 )
577 currentFilter = Filter(); 580 currentFilter = Filter();
578 else 581 else
579 currentFilter = mFilterList[ index - 1 ]; 582 currentFilter = mFilterList[ index - 1 ];
580 583
581 // Check if we have a view. Since the filter combo is created before 584 // Check if we have a view. Since the filter combo is created before
582 // the view, this slot could be called before there is a valid view. 585 // the view, this slot could be called before there is a valid view.
583 if ( mActiveView ) { 586 if ( mActiveView ) {
584 mActiveView->setFilter( currentFilter ); 587 mActiveView->setFilter( currentFilter );
585 mActiveView->refresh(); 588 mActiveView->refresh();
586 emit selected( QString::null ); 589 emit selected( QString::null );
587 } 590 }
588} 591}
589 592
590void ViewManager::configureFilters() 593void ViewManager::configureFilters()
591{ 594{
592 FilterDialog dlg( this ); 595 FilterDialog dlg( this );
593 596
594 dlg.setFilters( mFilterList ); 597 dlg.setFilters( mFilterList );
595 598
596 if ( dlg.exec() ) 599 if ( dlg.exec() )
597 mFilterList = dlg.filters(); 600 mFilterList = dlg.filters();
598 601
599 uint pos = mActionSelectFilter->currentItem(); 602 uint pos = mActionSelectFilter->currentItem();
600 mActionSelectFilter->setItems( filterNames() ); 603 mActionSelectFilter->setItems( filterNames() );
601 mActionSelectFilter->setCurrentItem( pos ); 604 mActionSelectFilter->setCurrentItem( pos );
602 setActiveFilter( pos ); 605 setActiveFilter( pos );
603 int cw = 150; 606 int cw = 150;
604 if (QApplication::desktop()->width() == 480 ) 607 if (QApplication::desktop()->width() == 480 )
605 cw = 0; 608 cw = 0;
606 mActionSelectFilter->setComboWidth( cw ); 609 mActionSelectFilter->setComboWidth( cw );
607 saveSettings(); 610 saveSettings();
608} 611}
609 612
610QStringList ViewManager::filterNames() const 613QStringList ViewManager::filterNames() const
611{ 614{
612 QStringList names( i18n( "No Filter" ) ); 615 QStringList names( i18n( "No Filter" ) );
613 616
614 Filter::List::ConstIterator it; 617 Filter::List::ConstIterator it;
615 for ( it = mFilterList.begin(); it != mFilterList.end(); ++it ) 618 for ( it = mFilterList.begin(); it != mFilterList.end(); ++it )
616 names.append( (*it).name() ); 619 names.append( (*it).name() );
617 620
618 return names; 621 return names;
619} 622}
620Filter ViewManager::getFilterByName( const QString &name ) const 623Filter ViewManager::getFilterByName( const QString &name ) const
621{ 624{
622 Filter::List::ConstIterator it; 625 Filter::List::ConstIterator it;
623 for ( it = mFilterList.begin(); it != mFilterList.end(); ++it ) 626 for ( it = mFilterList.begin(); it != mFilterList.end(); ++it )
624 if ( name == (*it).name() ) 627 if ( name == (*it).name() )
625 return (*it); 628 return (*it);
626 629
627 return Filter(); 630 return Filter();
628} 631}
629 632
630int ViewManager::filterPosition( const QString &name ) const 633int ViewManager::filterPosition( const QString &name ) const
631{ 634{
632 int pos = 0; 635 int pos = 0;
633 636
634 Filter::List::ConstIterator it; 637 Filter::List::ConstIterator it;
635 for ( it = mFilterList.begin(); it != mFilterList.end(); ++it, ++pos ) 638 for ( it = mFilterList.begin(); it != mFilterList.end(); ++it, ++pos )
636 if ( name == (*it).name() ) 639 if ( name == (*it).name() )
637 return pos + 1; 640 return pos + 1;
638 641
639 return 0; 642 return 0;
640} 643}
641 644
642void ViewManager::initActions() 645void ViewManager::initActions()
643{ 646{
644//US <ActionList name="view_loadedviews"/> 647//US <ActionList name="view_loadedviews"/>
645//US <Separator/> 648//US <Separator/>
646 649
647#ifdef KAB_EMBEDDED 650#ifdef KAB_EMBEDDED
648 QPopupMenu *viewmenu = (QPopupMenu*)mCore->getViewMenu(); 651 QPopupMenu *viewmenu = (QPopupMenu*)mCore->getViewMenu();
649 QPopupMenu *settingsmenu = (QPopupMenu*)mCore->getSettingsMenu(); 652 QPopupMenu *settingsmenu = (QPopupMenu*)mCore->getSettingsMenu();
650 QPopupMenu *filtermenu = (QPopupMenu*)mCore->getFilterMenu(); 653 QPopupMenu *filtermenu = (QPopupMenu*)mCore->getFilterMenu();
651#endif //KAB_EMBEDDED 654#endif //KAB_EMBEDDED
652 655
653 mActionSelectView = new KSelectAction( i18n( "Select View" ), 0, mCore->actionCollection(), "select_view" ); 656 mActionSelectView = new KSelectAction( i18n( "Select View" ), 0, mCore->actionCollection(), "select_view" );
654#if KDE_VERSION >= 309 657#if KDE_VERSION >= 309
655 mActionSelectView->setMenuAccelsEnabled( false ); 658 mActionSelectView->setMenuAccelsEnabled( false );
656#endif 659#endif
657 connect( mActionSelectView, SIGNAL( activated( const QString& ) ), 660 connect( mActionSelectView, SIGNAL( activated( const QString& ) ),
658 SLOT( setActiveView( const QString& ) ) ); 661 SLOT( selectView( const QString& ) ) );
659 662
660 663
661#ifdef KAB_EMBEDDED 664#ifdef KAB_EMBEDDED
662 mActionSelectView->plug(viewmenu); 665 mActionSelectView->plug(viewmenu);
663 viewmenu->insertSeparator(); 666 viewmenu->insertSeparator();
664#endif //KAB_EMBEDDED 667#endif //KAB_EMBEDDED
665 668
666 KAction *action; 669 KAction *action;
667 670
668 action = new KAction( i18n( "Modify View..." ), "configure", 0, this, 671 action = new KAction( i18n( "Modify View..." ), "configure", 0, this,
669 SLOT( editView() ), mCore->actionCollection(), "view_modify" ); 672 SLOT( editView() ), mCore->actionCollection(), "view_modify" );
670#ifndef KAB_EMBEDDED 673#ifndef KAB_EMBEDDED
671 action->setWhatsThis( i18n( "By pressing this button a dialog opens that allows you to modify the view of the addressbook. There you can add or remove fields that you want to be shown or hidden in the addressbook like the name for example." ) ); 674 action->setWhatsThis( i18n( "By pressing this button a dialog opens that allows you to modify the view of the addressbook. There you can add or remove fields that you want to be shown or hidden in the addressbook like the name for example." ) );
672#else //KAB_EMBEDDED 675#else //KAB_EMBEDDED
673 action->plug(viewmenu); 676 action->plug(viewmenu);
674#endif //KAB_EMBEDDED 677#endif //KAB_EMBEDDED
675 678
676 action = new KAction( i18n( "Add View..." ), "window_new", 0, this, 679 action = new KAction( i18n( "Add View..." ), "window_new", 0, this,
677 SLOT( addView() ), mCore->actionCollection(), "view_add" ); 680 SLOT( addView() ), mCore->actionCollection(), "view_add" );
678#ifndef KAB_EMBEDDED 681#ifndef KAB_EMBEDDED
679 action->setWhatsThis( i18n( "You can add a new view by choosing one of the dialog that appears after pressing the button. You have to give the view a name, so that you can distinguish between the different views." ) ); 682 action->setWhatsThis( i18n( "You can add a new view by choosing one of the dialog that appears after pressing the button. You have to give the view a name, so that you can distinguish between the different views." ) );
680#else //KAB_EMBEDDED 683#else //KAB_EMBEDDED
681 action->plug(viewmenu); 684 action->plug(viewmenu);
682#endif //KAB_EMBEDDED 685#endif //KAB_EMBEDDED
683 686
684 mActionDeleteView = new KAction( i18n( "Delete View" ), "view_remove", 0, 687 mActionDeleteView = new KAction( i18n( "Delete View" ), "view_remove", 0,
685 this, SLOT( deleteView() ), 688 this, SLOT( deleteView() ),
686 mCore->actionCollection(), "view_delete" ); 689 mCore->actionCollection(), "view_delete" );
687#ifndef KAB_EMBEDDED 690#ifndef KAB_EMBEDDED
688 mActionDeleteView->setWhatsThis( i18n( "By pressing this button you can delete the actual view, which you have added before." ) ); 691 mActionDeleteView->setWhatsThis( i18n( "By pressing this button you can delete the actual view, which you have added before." ) );
689#else //KAB_EMBEDDED 692#else //KAB_EMBEDDED
690 mActionDeleteView->plug(viewmenu); 693 mActionDeleteView->plug(viewmenu);
691 viewmenu->insertSeparator(); 694 viewmenu->insertSeparator();
692#endif //KAB_EMBEDDED 695#endif //KAB_EMBEDDED
693 696
694#ifndef KAB_EMBEDDED 697#ifndef KAB_EMBEDDED
695 action = new KAction( i18n( "Refresh View" ), "reload", 0, this, 698 action = new KAction( i18n( "Refresh View" ), "reload", 0, this,
696 SLOT( refreshView(const QString &) ), mCore->actionCollection(), 699 SLOT( refreshView(const QString &) ), mCore->actionCollection(),
697 "view_refresh" ); 700 "view_refresh" );
698 action->setWhatsThis( i18n( "The view will be refreshed by pressing this button." ) ); 701 action->setWhatsThis( i18n( "The view will be refreshed by pressing this button." ) );
699#else //KAB_EMBEDDED 702#else //KAB_EMBEDDED
700 action = new KAction( i18n( "Refresh View" ), "reload", 0, this, 703 action = new KAction( i18n( "Refresh View" ), "reload", 0, this,
701 SLOT( refreshView()), mCore->actionCollection(), 704 SLOT( refreshView()), mCore->actionCollection(),
702 "view_refresh" ); 705 "view_refresh" );
703 action->plug(viewmenu); 706 action->plug(viewmenu);
704 viewmenu->insertSeparator(); 707 viewmenu->insertSeparator();
705#endif //KAB_EMBEDDED 708#endif //KAB_EMBEDDED
706 709
707 action = new KAction( i18n( "Edit &Filters..." ), "filter", 0, this, 710 action = new KAction( i18n( "Edit &Filters..." ), "filter", 0, this,
708 SLOT( configureFilters() ), mCore->actionCollection(), 711 SLOT( configureFilters() ), mCore->actionCollection(),
709 "options_edit_filters" ); 712 "options_edit_filters" );
710 713
711 mActionSelectFilter = new KSelectAction( i18n( "Select Filter" ), "filter", mCore->actionCollection(), "select_filter" ); 714 mActionSelectFilter = new KSelectAction( i18n( "Select Filter" ), "filter", mCore->actionCollection(), "select_filter" );
712#if KDE_VERSION >= 309 715#if KDE_VERSION >= 309
713 mActionSelectFilter->setMenuAccelsEnabled( false ); 716 mActionSelectFilter->setMenuAccelsEnabled( false );
714#endif 717#endif
715 connect( mActionSelectFilter, SIGNAL( activated( int ) ), 718 connect( mActionSelectFilter, SIGNAL( activated( int ) ),
716 SLOT( setActiveFilter( int ) ) ); 719 SLOT( setActiveFilter( int ) ) );
717 720
718#ifdef KAB_EMBEDDED 721#ifdef KAB_EMBEDDED
719 action->plug(settingsmenu); 722 action->plug(settingsmenu);
720 mActionSelectFilter->plug(viewmenu); 723 mActionSelectFilter->plug(viewmenu);
721#endif //KAB_EMBEDDED 724#endif //KAB_EMBEDDED
722 725
723} 726}
724 727
725void ViewManager::initGUI() 728void ViewManager::initGUI()
726{ 729{
727 QHBoxLayout *layout = new QHBoxLayout( this, 0, 0 ); 730 QHBoxLayout *layout = new QHBoxLayout( this, 0, 0 );
728 mViewWidgetStack = new QWidgetStack( this ); 731 mViewWidgetStack = new QWidgetStack( this );
729 layout->addWidget( mViewWidgetStack ); 732 layout->addWidget( mViewWidgetStack );
730} 733}
731 734
732#ifndef KAB_EMBEDDED 735#ifndef KAB_EMBEDDED
733#include "viewmanager.moc" 736#include "viewmanager.moc"
734#endif //KAB_EMBEDDED 737#endif //KAB_EMBEDDED
diff --git a/kaddressbook/viewmanager.h b/kaddressbook/viewmanager.h
index dff9998..ab5d372 100644
--- a/kaddressbook/viewmanager.h
+++ b/kaddressbook/viewmanager.h
@@ -33,128 +33,129 @@
33class KAction; 33class KAction;
34class KSelectAction; 34class KSelectAction;
35 35
36class KABCore; 36class KABCore;
37class QWidgetStack; 37class QWidgetStack;
38class QDropEvent; 38class QDropEvent;
39 39
40namespace KABC { class AddressBook; } 40namespace KABC { class AddressBook; }
41 41
42/** 42/**
43 The view manager manages the views and everything related to them. The 43 The view manager manages the views and everything related to them. The
44 manager will load the views at startup and display a view when told to 44 manager will load the views at startup and display a view when told to
45 make one active. 45 make one active.
46 46
47 The view manager will also create and manage all dialogs directly related to 47 The view manager will also create and manage all dialogs directly related to
48 views (ie: AddView, ConfigureView, DeleteView, etc). 48 views (ie: AddView, ConfigureView, DeleteView, etc).
49 */ 49 */
50class ViewManager : public QWidget 50class ViewManager : public QWidget
51{ 51{
52 Q_OBJECT 52 Q_OBJECT
53 public: 53 public:
54 ViewManager( KABCore *core, QWidget *parent, const char *name = 0 ); 54 ViewManager( KABCore *core, QWidget *parent, const char *name = 0 );
55 ~ViewManager(); 55 ~ViewManager();
56 56
57 void restoreSettings(); 57 void restoreSettings();
58 void saveSettings(); 58 void saveSettings();
59 void doSearch( const QString& s ,KABC::Field *field ); 59 void doSearch( const QString& s ,KABC::Field *field );
60 60
61 void unloadViews(); 61 void unloadViews();
62 KSelectAction * getFilterAction() { return mActionSelectFilter; } 62 KSelectAction * getFilterAction() { return mActionSelectFilter; }
63 Filter getFilterByName( const QString &name ) const; 63 Filter getFilterByName( const QString &name ) const;
64 64
65 QStringList selectedUids() const; 65 QStringList selectedUids() const;
66 QStringList selectedEmails() const; 66 QStringList selectedEmails() const;
67 KABC::Addressee::List selectedAddressees() const; 67 KABC::Addressee::List selectedAddressees() const;
68 void setListSelected(QStringList); 68 void setListSelected(QStringList);
69 void setFocusAV(); 69 void setFocusAV();
70 70
71 public slots: 71 public slots:
72 void printView() { if (mActiveView) mActiveView->printMyView() ;} 72 void printView() { if (mActiveView) mActiveView->printMyView() ;}
73 void scrollUP(); 73 void scrollUP();
74 void scrollDOWN(); 74 void scrollDOWN();
75 75
76//US void setSelected( const QString &uid = QString::null, bool selected = true ); 76//US void setSelected( const QString &uid = QString::null, bool selected = true );
77 void setSelected( const QString &uid, bool); 77 void setSelected( const QString &uid, bool);
78//US added another method with no parameter, since my moc compiler does not support default parameters. 78//US added another method with no parameter, since my moc compiler does not support default parameters.
79 void setSelected(); 79 void setSelected();
80 80
81 81
82 82
83//US added another method with no parameter, since my moc compiler does not support default parameters. 83//US added another method with no parameter, since my moc compiler does not support default parameters.
84 void refreshView(); 84 void refreshView();
85 void refreshView( const QString &uid); 85 void refreshView( const QString &uid);
86 86
87 void editView(); 87 void editView();
88 void deleteView(); 88 void deleteView();
89 void addView(); 89 void addView();
90 90
91 protected slots: 91 protected slots:
92 /** 92 /**
93 Called whenever the user drops something in the active view. 93 Called whenever the user drops something in the active view.
94 This method will try to decode what was dropped, and if it was 94 This method will try to decode what was dropped, and if it was
95 a valid addressee, add it to the addressbook. 95 a valid addressee, add it to the addressbook.
96 */ 96 */
97 void dropped( QDropEvent* ); 97 void dropped( QDropEvent* );
98 98
99 /** 99 /**
100 Called whenever the user attempts to start a drag in the view. 100 Called whenever the user attempts to start a drag in the view.
101 This method will convert all the selected addressees into text (vcard) 101 This method will convert all the selected addressees into text (vcard)
102 and create a drag object. 102 and create a drag object.
103 */ 103 */
104 void startDrag(); 104 void startDrag();
105 105
106 signals: 106 signals:
107 /** 107 /**
108 Emitted whenever the user selects an entry in the view. 108 Emitted whenever the user selects an entry in the view.
109 */ 109 */
110 void selected( const QString &uid ); 110 void selected( const QString &uid );
111 void deleteRequest( ); 111 void deleteRequest( );
112 112
113 /** 113 /**
114 Emitted whenever the user activates an entry in the view. 114 Emitted whenever the user activates an entry in the view.
115 */ 115 */
116 void executed( const QString &uid ); 116 void executed( const QString &uid );
117 117
118 /** 118 /**
119 Emitted whenever the address book is modified in some way. 119 Emitted whenever the address book is modified in some way.
120 */ 120 */
121 void modified(); 121 void modified();
122 122
123 /** 123 /**
124 Emitted whenever a url is dragged on a view. 124 Emitted whenever a url is dragged on a view.
125 */ 125 */
126 void urlDropped( const KURL& ); 126 void urlDropped( const KURL& );
127 127
128 private slots: 128 private slots:
129 void selectView( const QString &name );
129 void setActiveView( const QString &name ); 130 void setActiveView( const QString &name );
130 void setActiveFilter( int index ); 131 void setActiveFilter( int index );
131 void configureFilters(); 132 void configureFilters();
132 133
133 private: 134 private:
134 void createViewFactories(); 135 void createViewFactories();
135 QStringList filterNames() const; 136 QStringList filterNames() const;
136 int filterPosition( const QString &name ) const; 137 int filterPosition( const QString &name ) const;
137 QStringList viewNames() const; 138 QStringList viewNames() const;
138 int viewPosition( const QString &name ) const; 139 int viewPosition( const QString &name ) const;
139 void initActions(); 140 void initActions();
140 void initGUI(); 141 void initGUI();
141 142
142 KABCore *mCore; 143 KABCore *mCore;
143 144
144 Filter mCurrentFilter; 145 Filter mCurrentFilter;
145 Filter::List mFilterList; 146 Filter::List mFilterList;
146 147
147 QDict<KAddressBookView> mViewDict; 148 QDict<KAddressBookView> mViewDict;
148 QDict<ViewFactory> mViewFactoryDict; 149 QDict<ViewFactory> mViewFactoryDict;
149 QStringList mViewNameList; 150 QStringList mViewNameList;
150 151
151 QWidgetStack *mViewWidgetStack; 152 QWidgetStack *mViewWidgetStack;
152 KAddressBookView *mActiveView; 153 KAddressBookView *mActiveView;
153 154
154 KAction *mActionDeleteView; 155 KAction *mActionDeleteView;
155 KSelectAction *mActionSelectFilter; 156 KSelectAction *mActionSelectFilter;
156 KSelectAction *mActionSelectView; 157 KSelectAction *mActionSelectView;
157 158
158}; 159};
159 160
160#endif 161#endif