author | zautrix <zautrix> | 2005-01-16 12:48:47 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2005-01-16 12:48:47 (UTC) |
commit | 3f61f5a339e9c0c67c17b16214abded0d123f246 (patch) (unidiff) | |
tree | e3e858f70d85f5a8c6e1547113eae924be73c5c3 /kaddressbook/viewmanager.cpp | |
parent | f3f63a1a1363cba9f58790812e43d6eda14f733c (diff) | |
download | kdepimpi-3f61f5a339e9c0c67c17b16214abded0d123f246.zip kdepimpi-3f61f5a339e9c0c67c17b16214abded0d123f246.tar.gz kdepimpi-3f61f5a339e9c0c67c17b16214abded0d123f246.tar.bz2 |
applied AB filters
Diffstat (limited to 'kaddressbook/viewmanager.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | kaddressbook/viewmanager.cpp | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/kaddressbook/viewmanager.cpp b/kaddressbook/viewmanager.cpp index 59bddd9..9c3a641 100644 --- a/kaddressbook/viewmanager.cpp +++ b/kaddressbook/viewmanager.cpp | |||
@@ -573,96 +573,105 @@ void ViewManager::doSearch( const QString& s,KABC::Field *field ) | |||
573 | void ViewManager::setActiveFilter( int index ) | 573 | void ViewManager::setActiveFilter( int index ) |
574 | { | 574 | { |
575 | Filter currentFilter; | 575 | Filter currentFilter; |
576 | 576 | ||
577 | if ( ( index - 1 ) < 0 ) | 577 | if ( ( index - 1 ) < 0 ) |
578 | currentFilter = Filter(); | 578 | currentFilter = Filter(); |
579 | else | 579 | else |
580 | currentFilter = mFilterList[ index - 1 ]; | 580 | currentFilter = mFilterList[ index - 1 ]; |
581 | 581 | ||
582 | // Check if we have a view. Since the filter combo is created before | 582 | // Check if we have a view. Since the filter combo is created before |
583 | // the view, this slot could be called before there is a valid view. | 583 | // the view, this slot could be called before there is a valid view. |
584 | if ( mActiveView ) { | 584 | if ( mActiveView ) { |
585 | mActiveView->setFilter( currentFilter ); | 585 | mActiveView->setFilter( currentFilter ); |
586 | mActiveView->refresh(); | 586 | mActiveView->refresh(); |
587 | emit selected( QString::null ); | 587 | emit selected( QString::null ); |
588 | } | 588 | } |
589 | } | 589 | } |
590 | 590 | ||
591 | void ViewManager::configureFilters() | 591 | void ViewManager::configureFilters() |
592 | { | 592 | { |
593 | FilterDialog dlg( this ); | 593 | FilterDialog dlg( this ); |
594 | 594 | ||
595 | dlg.setFilters( mFilterList ); | 595 | dlg.setFilters( mFilterList ); |
596 | 596 | ||
597 | if ( dlg.exec() ) | 597 | if ( dlg.exec() ) |
598 | mFilterList = dlg.filters(); | 598 | mFilterList = dlg.filters(); |
599 | 599 | ||
600 | uint pos = mActionSelectFilter->currentItem(); | 600 | uint pos = mActionSelectFilter->currentItem(); |
601 | mActionSelectFilter->setItems( filterNames() ); | 601 | mActionSelectFilter->setItems( filterNames() ); |
602 | mActionSelectFilter->setCurrentItem( pos ); | 602 | mActionSelectFilter->setCurrentItem( pos ); |
603 | setActiveFilter( pos ); | 603 | setActiveFilter( pos ); |
604 | int cw = 150; | 604 | int cw = 150; |
605 | if (QApplication::desktop()->width() == 480 ) | 605 | if (QApplication::desktop()->width() == 480 ) |
606 | cw = 0; | 606 | cw = 0; |
607 | mActionSelectFilter->setComboWidth( cw ); | 607 | mActionSelectFilter->setComboWidth( cw ); |
608 | saveSettings(); | 608 | saveSettings(); |
609 | } | 609 | } |
610 | 610 | ||
611 | QStringList ViewManager::filterNames() const | 611 | QStringList ViewManager::filterNames() const |
612 | { | 612 | { |
613 | QStringList names( i18n( "No Filter" ) ); | 613 | QStringList names( i18n( "No Filter" ) ); |
614 | 614 | ||
615 | Filter::List::ConstIterator it; | 615 | Filter::List::ConstIterator it; |
616 | for ( it = mFilterList.begin(); it != mFilterList.end(); ++it ) | 616 | for ( it = mFilterList.begin(); it != mFilterList.end(); ++it ) |
617 | names.append( (*it).name() ); | 617 | names.append( (*it).name() ); |
618 | 618 | ||
619 | return names; | 619 | return names; |
620 | } | 620 | } |
621 | Filter ViewManager::getFilterByName( const QString &name ) const | ||
622 | { | ||
623 | Filter::List::ConstIterator it; | ||
624 | for ( it = mFilterList.begin(); it != mFilterList.end(); ++it ) | ||
625 | if ( name == (*it).name() ) | ||
626 | return (*it); | ||
627 | |||
628 | return Filter(); | ||
629 | } | ||
621 | 630 | ||
622 | int ViewManager::filterPosition( const QString &name ) const | 631 | int ViewManager::filterPosition( const QString &name ) const |
623 | { | 632 | { |
624 | int pos = 0; | 633 | int pos = 0; |
625 | 634 | ||
626 | Filter::List::ConstIterator it; | 635 | Filter::List::ConstIterator it; |
627 | for ( it = mFilterList.begin(); it != mFilterList.end(); ++it, ++pos ) | 636 | for ( it = mFilterList.begin(); it != mFilterList.end(); ++it, ++pos ) |
628 | if ( name == (*it).name() ) | 637 | if ( name == (*it).name() ) |
629 | return pos + 1; | 638 | return pos + 1; |
630 | 639 | ||
631 | return 0; | 640 | return 0; |
632 | } | 641 | } |
633 | 642 | ||
634 | void ViewManager::initActions() | 643 | void ViewManager::initActions() |
635 | { | 644 | { |
636 | //US <ActionList name="view_loadedviews"/> | 645 | //US <ActionList name="view_loadedviews"/> |
637 | //US <Separator/> | 646 | //US <Separator/> |
638 | 647 | ||
639 | #ifdef KAB_EMBEDDED | 648 | #ifdef KAB_EMBEDDED |
640 | QPopupMenu *viewmenu = (QPopupMenu*)mCore->getViewMenu(); | 649 | QPopupMenu *viewmenu = (QPopupMenu*)mCore->getViewMenu(); |
641 | QPopupMenu *settingsmenu = (QPopupMenu*)mCore->getSettingsMenu(); | 650 | QPopupMenu *settingsmenu = (QPopupMenu*)mCore->getSettingsMenu(); |
642 | QPopupMenu *filtermenu = (QPopupMenu*)mCore->getFilterMenu(); | 651 | QPopupMenu *filtermenu = (QPopupMenu*)mCore->getFilterMenu(); |
643 | #endif //KAB_EMBEDDED | 652 | #endif //KAB_EMBEDDED |
644 | 653 | ||
645 | mActionSelectView = new KSelectAction( i18n( "Select View" ), 0, mCore->actionCollection(), "select_view" ); | 654 | mActionSelectView = new KSelectAction( i18n( "Select View" ), 0, mCore->actionCollection(), "select_view" ); |
646 | #if KDE_VERSION >= 309 | 655 | #if KDE_VERSION >= 309 |
647 | mActionSelectView->setMenuAccelsEnabled( false ); | 656 | mActionSelectView->setMenuAccelsEnabled( false ); |
648 | #endif | 657 | #endif |
649 | connect( mActionSelectView, SIGNAL( activated( const QString& ) ), | 658 | connect( mActionSelectView, SIGNAL( activated( const QString& ) ), |
650 | SLOT( setActiveView( const QString& ) ) ); | 659 | SLOT( setActiveView( const QString& ) ) ); |
651 | 660 | ||
652 | 661 | ||
653 | #ifdef KAB_EMBEDDED | 662 | #ifdef KAB_EMBEDDED |
654 | mActionSelectView->plug(viewmenu); | 663 | mActionSelectView->plug(viewmenu); |
655 | viewmenu->insertSeparator(); | 664 | viewmenu->insertSeparator(); |
656 | #endif //KAB_EMBEDDED | 665 | #endif //KAB_EMBEDDED |
657 | 666 | ||
658 | KAction *action; | 667 | KAction *action; |
659 | 668 | ||
660 | action = new KAction( i18n( "Modify View..." ), "configure", 0, this, | 669 | action = new KAction( i18n( "Modify View..." ), "configure", 0, this, |
661 | SLOT( editView() ), mCore->actionCollection(), "view_modify" ); | 670 | SLOT( editView() ), mCore->actionCollection(), "view_modify" ); |
662 | #ifndef KAB_EMBEDDED | 671 | #ifndef KAB_EMBEDDED |
663 | 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 | 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." ) ); |
664 | #else //KAB_EMBEDDED | 673 | #else //KAB_EMBEDDED |
665 | action->plug(viewmenu); | 674 | action->plug(viewmenu); |
666 | #endif //KAB_EMBEDDED | 675 | #endif //KAB_EMBEDDED |
667 | 676 | ||
668 | action = new KAction( i18n( "Add View..." ), "window_new", 0, this, | 677 | action = new KAction( i18n( "Add View..." ), "window_new", 0, this, |