summaryrefslogtreecommitdiffabout
path: root/kaddressbook/viewmanager.cpp
Unidiff
Diffstat (limited to 'kaddressbook/viewmanager.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--kaddressbook/viewmanager.cpp5
1 files changed, 5 insertions, 0 deletions
diff --git a/kaddressbook/viewmanager.cpp b/kaddressbook/viewmanager.cpp
index c93d51a..c6baeac 100644
--- a/kaddressbook/viewmanager.cpp
+++ b/kaddressbook/viewmanager.cpp
@@ -453,193 +453,198 @@ void ViewManager::createViewFactories()
453 mViewFactoryDict.insert( viewFactory->type(), viewFactory ); 453 mViewFactoryDict.insert( viewFactory->type(), viewFactory );
454 } 454 }
455 455
456#else //KAB_EMBEDDED 456#else //KAB_EMBEDDED
457 ViewFactory* viewFactory = new IconViewFactory(); 457 ViewFactory* viewFactory = new IconViewFactory();
458 mViewFactoryDict.insert( viewFactory->type(), viewFactory ); 458 mViewFactoryDict.insert( viewFactory->type(), viewFactory );
459// qDebug("ViewManager::createViewFactories() Loading factory: %s", viewFactory->type().latin1()); 459// qDebug("ViewManager::createViewFactories() Loading factory: %s", viewFactory->type().latin1());
460 460
461 viewFactory = new TableViewFactory(); 461 viewFactory = new TableViewFactory();
462 mViewFactoryDict.insert( viewFactory->type(), viewFactory ); 462 mViewFactoryDict.insert( viewFactory->type(), viewFactory );
463// qDebug("ViewManager::createViewFactories() Loading factory: %s", viewFactory->type().latin1()); 463// qDebug("ViewManager::createViewFactories() Loading factory: %s", viewFactory->type().latin1());
464 464
465 viewFactory = new CardViewFactory(); 465 viewFactory = new CardViewFactory();
466 mViewFactoryDict.insert( viewFactory->type(), viewFactory ); 466 mViewFactoryDict.insert( viewFactory->type(), viewFactory );
467// qDebug("ViewManager::createViewFactories() Loading factory: %s", viewFactory->type().latin1()); 467// qDebug("ViewManager::createViewFactories() Loading factory: %s", viewFactory->type().latin1());
468 468
469#endif //KAB_EMBEDDED 469#endif //KAB_EMBEDDED
470 470
471} 471}
472 472
473void ViewManager::dropped( QDropEvent *e ) 473void ViewManager::dropped( QDropEvent *e )
474{ 474{
475 kdDebug(5720) << "ViewManager::dropped: got a drop event" << endl; 475 kdDebug(5720) << "ViewManager::dropped: got a drop event" << endl;
476 476
477#ifndef KAB_EMBEDDED 477#ifndef KAB_EMBEDDED
478 478
479 QString clipText, vcards; 479 QString clipText, vcards;
480 KURL::List urls; 480 KURL::List urls;
481 481
482 if ( KURLDrag::decode( e, urls) ) { 482 if ( KURLDrag::decode( e, urls) ) {
483 KURL::List::Iterator it = urls.begin(); 483 KURL::List::Iterator it = urls.begin();
484 int c = urls.count(); 484 int c = urls.count();
485 if ( c > 1 ) { 485 if ( c > 1 ) {
486 QString questionString = i18n( "Import one contact into your addressbook?", "Import %n contacts into your addressbook?", c ); 486 QString questionString = i18n( "Import one contact into your addressbook?", "Import %n contacts into your addressbook?", c );
487 if ( KMessageBox::questionYesNo( this, questionString, i18n( "Import Contacts?" ) ) == KMessageBox::Yes ) { 487 if ( KMessageBox::questionYesNo( this, questionString, i18n( "Import Contacts?" ) ) == KMessageBox::Yes ) {
488 for ( ; it != urls.end(); ++it ) 488 for ( ; it != urls.end(); ++it )
489 emit urlDropped( *it ); 489 emit urlDropped( *it );
490 } 490 }
491 } else if ( c == 1 ) 491 } else if ( c == 1 )
492 emit urlDropped( *it ); 492 emit urlDropped( *it );
493 } else if ( KVCardDrag::decode( e, vcards ) ) { 493 } else if ( KVCardDrag::decode( e, vcards ) ) {
494 KABC::Addressee addr; 494 KABC::Addressee addr;
495 KABC::VCardConverter converter; 495 KABC::VCardConverter converter;
496 QStringList list = QStringList::split( "\r\n\r\n", vcards ); 496 QStringList list = QStringList::split( "\r\n\r\n", vcards );
497 QStringList::Iterator it; 497 QStringList::Iterator it;
498 for ( it = list.begin(); it != list.end(); ++it ) { 498 for ( it = list.begin(); it != list.end(); ++it ) {
499 if ( converter.vCardToAddressee( (*it).stripWhiteSpace(), addr ) ) { 499 if ( converter.vCardToAddressee( (*it).stripWhiteSpace(), addr ) ) {
500 KABC::Addressee a = mCore->addressBook()->findByUid( addr.uid() ); 500 KABC::Addressee a = mCore->addressBook()->findByUid( addr.uid() );
501 if ( a.isEmpty() ) { 501 if ( a.isEmpty() ) {
502 mCore->addressBook()->insertAddressee( addr ); 502 mCore->addressBook()->insertAddressee( addr );
503 emit modified(); 503 emit modified();
504 } 504 }
505 } 505 }
506 } 506 }
507 507
508 mActiveView->refresh(); 508 mActiveView->refresh();
509 } 509 }
510#else //KAB_EMBEDDED 510#else //KAB_EMBEDDED
511qDebug("ViewManager::dropped() has to be changed!!" ); 511qDebug("ViewManager::dropped() has to be changed!!" );
512#endif //KAB_EMBEDDED 512#endif //KAB_EMBEDDED
513 513
514} 514}
515 515
516void ViewManager::startDrag() 516void ViewManager::startDrag()
517{ 517{
518 kdDebug(5720) << "ViewManager::startDrag: starting to drag" << endl; 518 kdDebug(5720) << "ViewManager::startDrag: starting to drag" << endl;
519 519
520#ifndef KAB_EMBEDDED 520#ifndef KAB_EMBEDDED
521 521
522 // Get the list of all the selected addressees 522 // Get the list of all the selected addressees
523 KABC::Addressee::List addrList; 523 KABC::Addressee::List addrList;
524 QStringList uidList = selectedUids(); 524 QStringList uidList = selectedUids();
525 QStringList::Iterator iter; 525 QStringList::Iterator iter;
526 for ( iter = uidList.begin(); iter != uidList.end(); ++iter ) 526 for ( iter = uidList.begin(); iter != uidList.end(); ++iter )
527 addrList.append( mCore->addressBook()->findByUid( *iter ) ); 527 addrList.append( mCore->addressBook()->findByUid( *iter ) );
528 528
529 KMultipleDrag *drag = new KMultipleDrag( this ); 529 KMultipleDrag *drag = new KMultipleDrag( this );
530 drag->addDragObject( new QTextDrag( AddresseeUtil::addresseesToClipboard(addrList), this ) ); 530 drag->addDragObject( new QTextDrag( AddresseeUtil::addresseesToClipboard(addrList), this ) );
531 KABC::Addressee::List::Iterator it; 531 KABC::Addressee::List::Iterator it;
532 QStringList vcards; 532 QStringList vcards;
533 for ( it = addrList.begin(); it != addrList.end(); ++it ) { 533 for ( it = addrList.begin(); it != addrList.end(); ++it ) {
534 QString vcard = QString::null; 534 QString vcard = QString::null;
535 KABC::VCardConverter converter; 535 KABC::VCardConverter converter;
536 if ( converter.addresseeToVCard( *it, vcard ) ) 536 if ( converter.addresseeToVCard( *it, vcard ) )
537 vcards.append( vcard ); 537 vcards.append( vcard );
538 } 538 }
539 drag->addDragObject( new KVCardDrag( vcards.join( "\r\n" ), this ) ); 539 drag->addDragObject( new KVCardDrag( vcards.join( "\r\n" ), this ) );
540 540
541 drag->setPixmap( KGlobal::iconLoader()->loadIcon( "vcard", KIcon::Desktop ) ); 541 drag->setPixmap( KGlobal::iconLoader()->loadIcon( "vcard", KIcon::Desktop ) );
542 drag->dragCopy(); 542 drag->dragCopy();
543 543
544#else //KAB_EMBEDDED 544#else //KAB_EMBEDDED
545qDebug("ViewManager::startDrag() has to be changed!!" ); 545qDebug("ViewManager::startDrag() has to be changed!!" );
546#endif //KAB_EMBEDDED 546#endif //KAB_EMBEDDED
547 547
548} 548}
549void ViewManager::doSearch( const QString& s,KABC::Field *field )
550{
551 if ( mActiveView )
552 mActiveView->doSearch( s, field );
549 553
554}
550void ViewManager::setActiveFilter( int index ) 555void ViewManager::setActiveFilter( int index )
551{ 556{
552 Filter currentFilter; 557 Filter currentFilter;
553 558
554 if ( ( index - 1 ) < 0 ) 559 if ( ( index - 1 ) < 0 )
555 currentFilter = Filter(); 560 currentFilter = Filter();
556 else 561 else
557 currentFilter = mFilterList[ index - 1 ]; 562 currentFilter = mFilterList[ index - 1 ];
558 563
559 // Check if we have a view. Since the filter combo is created before 564 // Check if we have a view. Since the filter combo is created before
560 // the view, this slot could be called before there is a valid view. 565 // the view, this slot could be called before there is a valid view.
561 if ( mActiveView ) { 566 if ( mActiveView ) {
562 mActiveView->setFilter( currentFilter ); 567 mActiveView->setFilter( currentFilter );
563 mActiveView->refresh(); 568 mActiveView->refresh();
564 emit selected( QString::null ); 569 emit selected( QString::null );
565 } 570 }
566} 571}
567 572
568void ViewManager::configureFilters() 573void ViewManager::configureFilters()
569{ 574{
570 FilterDialog dlg( this ); 575 FilterDialog dlg( this );
571 576
572 dlg.setFilters( mFilterList ); 577 dlg.setFilters( mFilterList );
573 578
574 if ( dlg.exec() ) 579 if ( dlg.exec() )
575 mFilterList = dlg.filters(); 580 mFilterList = dlg.filters();
576 581
577 uint pos = mActionSelectFilter->currentItem(); 582 uint pos = mActionSelectFilter->currentItem();
578 mActionSelectFilter->setItems( filterNames() ); 583 mActionSelectFilter->setItems( filterNames() );
579 mActionSelectFilter->setCurrentItem( pos ); 584 mActionSelectFilter->setCurrentItem( pos );
580 setActiveFilter( pos ); 585 setActiveFilter( pos );
581} 586}
582 587
583QStringList ViewManager::filterNames() const 588QStringList ViewManager::filterNames() const
584{ 589{
585 QStringList names( i18n( "No Filter" ) ); 590 QStringList names( i18n( "No Filter" ) );
586 591
587 Filter::List::ConstIterator it; 592 Filter::List::ConstIterator it;
588 for ( it = mFilterList.begin(); it != mFilterList.end(); ++it ) 593 for ( it = mFilterList.begin(); it != mFilterList.end(); ++it )
589 names.append( (*it).name() ); 594 names.append( (*it).name() );
590 595
591 return names; 596 return names;
592} 597}
593 598
594int ViewManager::filterPosition( const QString &name ) const 599int ViewManager::filterPosition( const QString &name ) const
595{ 600{
596 int pos = 0; 601 int pos = 0;
597 602
598 Filter::List::ConstIterator it; 603 Filter::List::ConstIterator it;
599 for ( it = mFilterList.begin(); it != mFilterList.end(); ++it, ++pos ) 604 for ( it = mFilterList.begin(); it != mFilterList.end(); ++it, ++pos )
600 if ( name == (*it).name() ) 605 if ( name == (*it).name() )
601 return pos + 1; 606 return pos + 1;
602 607
603 return 0; 608 return 0;
604} 609}
605 610
606void ViewManager::initActions() 611void ViewManager::initActions()
607{ 612{
608//US <ActionList name="view_loadedviews"/> 613//US <ActionList name="view_loadedviews"/>
609//US <Separator/> 614//US <Separator/>
610 615
611#ifdef KAB_EMBEDDED 616#ifdef KAB_EMBEDDED
612 QPopupMenu *viewmenu = (QPopupMenu*)mCore->getViewMenu(); 617 QPopupMenu *viewmenu = (QPopupMenu*)mCore->getViewMenu();
613 QPopupMenu *settingsmenu = (QPopupMenu*)mCore->getSettingsMenu(); 618 QPopupMenu *settingsmenu = (QPopupMenu*)mCore->getSettingsMenu();
614 QPopupMenu *filtermenu = (QPopupMenu*)mCore->getFilterMenu(); 619 QPopupMenu *filtermenu = (QPopupMenu*)mCore->getFilterMenu();
615#endif //KAB_EMBEDDED 620#endif //KAB_EMBEDDED
616 621
617 mActionSelectView = new KSelectAction( i18n( "Select View" ), 0, mCore->actionCollection(), "select_view" ); 622 mActionSelectView = new KSelectAction( i18n( "Select View" ), 0, mCore->actionCollection(), "select_view" );
618#if KDE_VERSION >= 309 623#if KDE_VERSION >= 309
619 mActionSelectView->setMenuAccelsEnabled( false ); 624 mActionSelectView->setMenuAccelsEnabled( false );
620#endif 625#endif
621 connect( mActionSelectView, SIGNAL( activated( const QString& ) ), 626 connect( mActionSelectView, SIGNAL( activated( const QString& ) ),
622 SLOT( setActiveView( const QString& ) ) ); 627 SLOT( setActiveView( const QString& ) ) );
623 628
624 629
625#ifdef KAB_EMBEDDED 630#ifdef KAB_EMBEDDED
626 mActionSelectView->plug(viewmenu); 631 mActionSelectView->plug(viewmenu);
627 viewmenu->insertSeparator(); 632 viewmenu->insertSeparator();
628#endif //KAB_EMBEDDED 633#endif //KAB_EMBEDDED
629 634
630 KAction *action; 635 KAction *action;
631 636
632 action = new KAction( i18n( "Modify View..." ), "configure", 0, this, 637 action = new KAction( i18n( "Modify View..." ), "configure", 0, this,
633 SLOT( editView() ), mCore->actionCollection(), "view_modify" ); 638 SLOT( editView() ), mCore->actionCollection(), "view_modify" );
634#ifndef KAB_EMBEDDED 639#ifndef KAB_EMBEDDED
635 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." ) ); 640 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." ) );
636#else //KAB_EMBEDDED 641#else //KAB_EMBEDDED
637 action->plug(viewmenu); 642 action->plug(viewmenu);
638#endif //KAB_EMBEDDED 643#endif //KAB_EMBEDDED
639 644
640 action = new KAction( i18n( "Add View..." ), "window_new", 0, this, 645 action = new KAction( i18n( "Add View..." ), "window_new", 0, this,
641 SLOT( addView() ), mCore->actionCollection(), "view_add" ); 646 SLOT( addView() ), mCore->actionCollection(), "view_add" );
642#ifndef KAB_EMBEDDED 647#ifndef KAB_EMBEDDED
643 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." ) ); 648 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." ) );
644#else //KAB_EMBEDDED 649#else //KAB_EMBEDDED
645 action->plug(viewmenu); 650 action->plug(viewmenu);