Diffstat (limited to 'kaddressbook/viewmanager.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | kaddressbook/viewmanager.cpp | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/kaddressbook/viewmanager.cpp b/kaddressbook/viewmanager.cpp index 81e0d99..3d0c275 100644 --- a/kaddressbook/viewmanager.cpp +++ b/kaddressbook/viewmanager.cpp | |||
@@ -77,65 +77,65 @@ ViewManager::ViewManager( KABCore *core, QWidget *parent, const char *name ) | |||
77 | 77 | ||
78 | mViewDict.setAutoDelete( true ); | 78 | mViewDict.setAutoDelete( true ); |
79 | 79 | ||
80 | createViewFactories(); | 80 | createViewFactories(); |
81 | } | 81 | } |
82 | 82 | ||
83 | ViewManager::~ViewManager() | 83 | ViewManager::~ViewManager() |
84 | { | 84 | { |
85 | unloadViews(); | 85 | unloadViews(); |
86 | mViewFactoryDict.clear(); | 86 | mViewFactoryDict.clear(); |
87 | } | 87 | } |
88 | void ViewManager::scrollUP() | 88 | void ViewManager::scrollUP() |
89 | { | 89 | { |
90 | if ( mActiveView ) | 90 | if ( mActiveView ) |
91 | mActiveView->scrollUP(); | 91 | mActiveView->scrollUP(); |
92 | } | 92 | } |
93 | void ViewManager::scrollDOWN() | 93 | void ViewManager::scrollDOWN() |
94 | { | 94 | { |
95 | if ( mActiveView ) | 95 | if ( mActiveView ) |
96 | mActiveView->scrollDOWN(); | 96 | mActiveView->scrollDOWN(); |
97 | } | 97 | } |
98 | void ViewManager::restoreSettings() | 98 | void ViewManager::restoreSettings() |
99 | { | 99 | { |
100 | mViewNameList = KABPrefs::instance()->mViewNames; | 100 | mViewNameList = KABPrefs::instance()->mViewNames; |
101 | QString activeViewName = KABPrefs::instance()->mCurrentView; | 101 | QString activeViewName = KABPrefs::instance()->mCurrentView; |
102 | 102 | ||
103 | mActionSelectView->setItems( mViewNameList ); | 103 | mActionSelectView->setItems( mViewNameList ); |
104 | 104 | ||
105 | // Filter | 105 | // Filter |
106 | mFilterList = Filter::restore( mCore->config(), "Filter" ); | 106 | mFilterList = Filter::restore( mCore->config(), "Filter" ); |
107 | mActionSelectFilter->setItems( filterNames() ); | 107 | mActionSelectFilter->setItems( filterNames() ); |
108 | mActionSelectFilter->setCurrentItem( KABPrefs::instance()->mCurrentFilter ); | 108 | mActionSelectFilter->setCurrentItem( KABPrefs::instance()->mCurrentFilter ); |
109 | 109 | mActionSelectFilter->setComboWidth( 100 ); | |
110 | // Tell the views to reread their config, since they may have | 110 | // Tell the views to reread their config, since they may have |
111 | // been modified by global settings | 111 | // been modified by global settings |
112 | QString _oldgroup = mCore->config()->group(); | 112 | QString _oldgroup = mCore->config()->group(); |
113 | 113 | ||
114 | QDictIterator<KAddressBookView> it( mViewDict ); | 114 | QDictIterator<KAddressBookView> it( mViewDict ); |
115 | for ( it.toFirst(); it.current(); ++it ) { | 115 | for ( it.toFirst(); it.current(); ++it ) { |
116 | KConfigGroupSaver saver( mCore->config(), it.currentKey() ); | 116 | KConfigGroupSaver saver( mCore->config(), it.currentKey() ); |
117 | it.current()->readConfig( mCore->config() ); | 117 | it.current()->readConfig( mCore->config() ); |
118 | } | 118 | } |
119 | setActiveView( activeViewName ); | 119 | setActiveView( activeViewName ); |
120 | 120 | ||
121 | mActionDeleteView->setEnabled( mViewNameList.count() > 1 ); | 121 | mActionDeleteView->setEnabled( mViewNameList.count() > 1 ); |
122 | } | 122 | } |
123 | 123 | ||
124 | void ViewManager::saveSettings() | 124 | void ViewManager::saveSettings() |
125 | { | 125 | { |
126 | QString _oldgroup = mCore->config()->group(); | 126 | QString _oldgroup = mCore->config()->group(); |
127 | 127 | ||
128 | QDictIterator<KAddressBookView> it( mViewDict ); | 128 | QDictIterator<KAddressBookView> it( mViewDict ); |
129 | for ( it.toFirst(); it.current(); ++it ) { | 129 | for ( it.toFirst(); it.current(); ++it ) { |
130 | KConfigGroupSaver saver( mCore->config(), it.currentKey() ); | 130 | KConfigGroupSaver saver( mCore->config(), it.currentKey() ); |
131 | #ifdef DESKTOP_VERSION | 131 | #ifdef DESKTOP_VERSION |
132 | (*it)->writeConfig( mCore->config() ); | 132 | (*it)->writeConfig( mCore->config() ); |
133 | #else | 133 | #else |
134 | (*it).writeConfig( mCore->config() ); | 134 | (*it).writeConfig( mCore->config() ); |
135 | #endif | 135 | #endif |
136 | } | 136 | } |
137 | 137 | ||
138 | Filter::save( mCore->config(), "Filter", mFilterList ); | 138 | Filter::save( mCore->config(), "Filter", mFilterList ); |
139 | KABPrefs::instance()->mCurrentFilter = mActionSelectFilter->currentItem(); | 139 | KABPrefs::instance()->mCurrentFilter = mActionSelectFilter->currentItem(); |
140 | 140 | ||
141 | // write the view name list | 141 | // write the view name list |
@@ -274,65 +274,65 @@ void ViewManager::setActiveView( const QString &name ) | |||
274 | //US qDebug("ViewManager::setActiveView 6" ); | 274 | //US qDebug("ViewManager::setActiveView 6" ); |
275 | 275 | ||
276 | // Update the inc search widget to show the fields in the new active | 276 | // Update the inc search widget to show the fields in the new active |
277 | // view. | 277 | // view. |
278 | mCore->setSearchFields( mActiveView->fields() ); | 278 | mCore->setSearchFields( mActiveView->fields() ); |
279 | 279 | ||
280 | //US performance optimization. setActiveFilter calls also mActiveView->refresh() | 280 | //US performance optimization. setActiveFilter calls also mActiveView->refresh() |
281 | //US mActiveView->refresh(); | 281 | //US mActiveView->refresh(); |
282 | 282 | ||
283 | } | 283 | } |
284 | else | 284 | else |
285 | { | 285 | { |
286 | qDebug("ViewManager::setActiveView: unable to find view" ); | 286 | qDebug("ViewManager::setActiveView: unable to find view" ); |
287 | kdDebug(5720) << "ViewManager::setActiveView: unable to find view\n"; | 287 | kdDebug(5720) << "ViewManager::setActiveView: unable to find view\n"; |
288 | } | 288 | } |
289 | } | 289 | } |
290 | 290 | ||
291 | //US added another method with no parameter, since my moc compiler does not support default parameters. | 291 | //US added another method with no parameter, since my moc compiler does not support default parameters. |
292 | void ViewManager::refreshView() | 292 | void ViewManager::refreshView() |
293 | { | 293 | { |
294 | refreshView( QString::null ); | 294 | refreshView( QString::null ); |
295 | } | 295 | } |
296 | 296 | ||
297 | void ViewManager::refreshView( const QString &uid ) | 297 | void ViewManager::refreshView( const QString &uid ) |
298 | { | 298 | { |
299 | if ( mActiveView ) | 299 | if ( mActiveView ) |
300 | mActiveView->refresh( uid ); | 300 | mActiveView->refresh( uid ); |
301 | } | 301 | } |
302 | 302 | ||
303 | void ViewManager::setFocusAV() | 303 | void ViewManager::setFocusAV() |
304 | { | 304 | { |
305 | if ( mActiveView ) | 305 | if ( mActiveView ) |
306 | mActiveView->setFocus(); | 306 | mActiveView->setFocusAV(); |
307 | } | 307 | } |
308 | void ViewManager::editView() | 308 | void ViewManager::editView() |
309 | { | 309 | { |
310 | if ( !mActiveView ) | 310 | if ( !mActiveView ) |
311 | return; | 311 | return; |
312 | 312 | ||
313 | ViewFactory *factory = mViewFactoryDict.find( mActiveView->type() ); | 313 | ViewFactory *factory = mViewFactoryDict.find( mActiveView->type() ); |
314 | ViewConfigureWidget *wdg = 0; | 314 | ViewConfigureWidget *wdg = 0; |
315 | ViewConfigureDialog* dlg = 0; | 315 | ViewConfigureDialog* dlg = 0; |
316 | if ( factory ) { | 316 | if ( factory ) { |
317 | // Save the filters so the dialog has the latest set | 317 | // Save the filters so the dialog has the latest set |
318 | Filter::save( mCore->config(), "Filter", mFilterList ); | 318 | Filter::save( mCore->config(), "Filter", mFilterList ); |
319 | dlg = new ViewConfigureDialog( 0, mActiveView->caption(), this, "conf_dlg" ); | 319 | dlg = new ViewConfigureDialog( 0, mActiveView->caption(), this, "conf_dlg" ); |
320 | wdg = factory->configureWidget( mCore->addressBook(), dlg,"conf_wid" ); | 320 | wdg = factory->configureWidget( mCore->addressBook(), dlg,"conf_wid" ); |
321 | } else { | 321 | } else { |
322 | qDebug("ViewManager::editView()::cannot find viewfactory "); | 322 | qDebug("ViewManager::editView()::cannot find viewfactory "); |
323 | return; | 323 | return; |
324 | } | 324 | } |
325 | if ( wdg ) { | 325 | if ( wdg ) { |
326 | dlg->setWidget( wdg ); | 326 | dlg->setWidget( wdg ); |
327 | 327 | ||
328 | #ifndef DESKTOP_VERSION | 328 | #ifndef DESKTOP_VERSION |
329 | //dlg.setMaximumSize( 640, 480 ); | 329 | //dlg.setMaximumSize( 640, 480 ); |
330 | //dlg->setGeometry( 40,40, 400, 300); | 330 | //dlg->setGeometry( 40,40, 400, 300); |
331 | dlg->showMaximized(); | 331 | dlg->showMaximized(); |
332 | #endif | 332 | #endif |
333 | 333 | ||
334 | KConfigGroupSaver saver( mCore->config(), mActiveView->caption() ); | 334 | KConfigGroupSaver saver( mCore->config(), mActiveView->caption() ); |
335 | 335 | ||
336 | dlg->restoreSettings( mCore->config() ); | 336 | dlg->restoreSettings( mCore->config() ); |
337 | 337 | ||
338 | if ( dlg->exec() ) { | 338 | if ( dlg->exec() ) { |
@@ -568,64 +568,65 @@ void ViewManager::doSearch( const QString& s,KABC::Field *field ) | |||
568 | } | 568 | } |
569 | void ViewManager::setActiveFilter( int index ) | 569 | void ViewManager::setActiveFilter( int index ) |
570 | { | 570 | { |
571 | Filter currentFilter; | 571 | Filter currentFilter; |
572 | 572 | ||
573 | if ( ( index - 1 ) < 0 ) | 573 | if ( ( index - 1 ) < 0 ) |
574 | currentFilter = Filter(); | 574 | currentFilter = Filter(); |
575 | else | 575 | else |
576 | currentFilter = mFilterList[ index - 1 ]; | 576 | currentFilter = mFilterList[ index - 1 ]; |
577 | 577 | ||
578 | // Check if we have a view. Since the filter combo is created before | 578 | // Check if we have a view. Since the filter combo is created before |
579 | // the view, this slot could be called before there is a valid view. | 579 | // the view, this slot could be called before there is a valid view. |
580 | if ( mActiveView ) { | 580 | if ( mActiveView ) { |
581 | mActiveView->setFilter( currentFilter ); | 581 | mActiveView->setFilter( currentFilter ); |
582 | mActiveView->refresh(); | 582 | mActiveView->refresh(); |
583 | emit selected( QString::null ); | 583 | emit selected( QString::null ); |
584 | } | 584 | } |
585 | } | 585 | } |
586 | 586 | ||
587 | void ViewManager::configureFilters() | 587 | void ViewManager::configureFilters() |
588 | { | 588 | { |
589 | FilterDialog dlg( this ); | 589 | FilterDialog dlg( this ); |
590 | 590 | ||
591 | dlg.setFilters( mFilterList ); | 591 | dlg.setFilters( mFilterList ); |
592 | 592 | ||
593 | if ( dlg.exec() ) | 593 | if ( dlg.exec() ) |
594 | mFilterList = dlg.filters(); | 594 | mFilterList = dlg.filters(); |
595 | 595 | ||
596 | uint pos = mActionSelectFilter->currentItem(); | 596 | uint pos = mActionSelectFilter->currentItem(); |
597 | mActionSelectFilter->setItems( filterNames() ); | 597 | mActionSelectFilter->setItems( filterNames() ); |
598 | mActionSelectFilter->setCurrentItem( pos ); | 598 | mActionSelectFilter->setCurrentItem( pos ); |
599 | setActiveFilter( pos ); | 599 | setActiveFilter( pos ); |
600 | //mActionSelectFilter->setComboWidth( 150 ); | ||
600 | } | 601 | } |
601 | 602 | ||
602 | QStringList ViewManager::filterNames() const | 603 | QStringList ViewManager::filterNames() const |
603 | { | 604 | { |
604 | QStringList names( i18n( "No Filter" ) ); | 605 | QStringList names( i18n( "No Filter" ) ); |
605 | 606 | ||
606 | Filter::List::ConstIterator it; | 607 | Filter::List::ConstIterator it; |
607 | for ( it = mFilterList.begin(); it != mFilterList.end(); ++it ) | 608 | for ( it = mFilterList.begin(); it != mFilterList.end(); ++it ) |
608 | names.append( (*it).name() ); | 609 | names.append( (*it).name() ); |
609 | 610 | ||
610 | return names; | 611 | return names; |
611 | } | 612 | } |
612 | 613 | ||
613 | int ViewManager::filterPosition( const QString &name ) const | 614 | int ViewManager::filterPosition( const QString &name ) const |
614 | { | 615 | { |
615 | int pos = 0; | 616 | int pos = 0; |
616 | 617 | ||
617 | Filter::List::ConstIterator it; | 618 | Filter::List::ConstIterator it; |
618 | for ( it = mFilterList.begin(); it != mFilterList.end(); ++it, ++pos ) | 619 | for ( it = mFilterList.begin(); it != mFilterList.end(); ++it, ++pos ) |
619 | if ( name == (*it).name() ) | 620 | if ( name == (*it).name() ) |
620 | return pos + 1; | 621 | return pos + 1; |
621 | 622 | ||
622 | return 0; | 623 | return 0; |
623 | } | 624 | } |
624 | 625 | ||
625 | void ViewManager::initActions() | 626 | void ViewManager::initActions() |
626 | { | 627 | { |
627 | //US <ActionList name="view_loadedviews"/> | 628 | //US <ActionList name="view_loadedviews"/> |
628 | //US <Separator/> | 629 | //US <Separator/> |
629 | 630 | ||
630 | #ifdef KAB_EMBEDDED | 631 | #ifdef KAB_EMBEDDED |
631 | QPopupMenu *viewmenu = (QPopupMenu*)mCore->getViewMenu(); | 632 | QPopupMenu *viewmenu = (QPopupMenu*)mCore->getViewMenu(); |
@@ -663,56 +664,55 @@ void ViewManager::initActions() | |||
663 | #else //KAB_EMBEDDED | 664 | #else //KAB_EMBEDDED |
664 | action->plug(viewmenu); | 665 | action->plug(viewmenu); |
665 | #endif //KAB_EMBEDDED | 666 | #endif //KAB_EMBEDDED |
666 | 667 | ||
667 | mActionDeleteView = new KAction( i18n( "Delete View" ), "view_remove", 0, | 668 | mActionDeleteView = new KAction( i18n( "Delete View" ), "view_remove", 0, |
668 | this, SLOT( deleteView() ), | 669 | this, SLOT( deleteView() ), |
669 | mCore->actionCollection(), "view_delete" ); | 670 | mCore->actionCollection(), "view_delete" ); |
670 | #ifndef KAB_EMBEDDED | 671 | #ifndef KAB_EMBEDDED |
671 | mActionDeleteView->setWhatsThis( i18n( "By pressing this button you can delete the actual view, which you have added before." ) ); | 672 | mActionDeleteView->setWhatsThis( i18n( "By pressing this button you can delete the actual view, which you have added before." ) ); |
672 | #else //KAB_EMBEDDED | 673 | #else //KAB_EMBEDDED |
673 | mActionDeleteView->plug(viewmenu); | 674 | mActionDeleteView->plug(viewmenu); |
674 | viewmenu->insertSeparator(); | 675 | viewmenu->insertSeparator(); |
675 | #endif //KAB_EMBEDDED | 676 | #endif //KAB_EMBEDDED |
676 | 677 | ||
677 | #ifndef KAB_EMBEDDED | 678 | #ifndef KAB_EMBEDDED |
678 | action = new KAction( i18n( "Refresh View" ), "reload", 0, this, | 679 | action = new KAction( i18n( "Refresh View" ), "reload", 0, this, |
679 | SLOT( refreshView(const QString &) ), mCore->actionCollection(), | 680 | SLOT( refreshView(const QString &) ), mCore->actionCollection(), |
680 | "view_refresh" ); | 681 | "view_refresh" ); |
681 | action->setWhatsThis( i18n( "The view will be refreshed by pressing this button." ) ); | 682 | action->setWhatsThis( i18n( "The view will be refreshed by pressing this button." ) ); |
682 | #else //KAB_EMBEDDED | 683 | #else //KAB_EMBEDDED |
683 | action = new KAction( i18n( "Refresh View" ), "reload", 0, this, | 684 | action = new KAction( i18n( "Refresh View" ), "reload", 0, this, |
684 | SLOT( refreshView()), mCore->actionCollection(), | 685 | SLOT( refreshView()), mCore->actionCollection(), |
685 | "view_refresh" ); | 686 | "view_refresh" ); |
686 | action->plug(viewmenu); | 687 | action->plug(viewmenu); |
687 | viewmenu->insertSeparator(); | 688 | viewmenu->insertSeparator(); |
688 | #endif //KAB_EMBEDDED | 689 | #endif //KAB_EMBEDDED |
689 | 690 | ||
690 | action = new KAction( i18n( "Edit &Filters..." ), "filter", 0, this, | 691 | action = new KAction( i18n( "Edit &Filters..." ), "filter", 0, this, |
691 | SLOT( configureFilters() ), mCore->actionCollection(), | 692 | SLOT( configureFilters() ), mCore->actionCollection(), |
692 | "options_edit_filters" ); | 693 | "options_edit_filters" ); |
693 | 694 | ||
694 | mActionSelectFilter = new KSelectAction( i18n( "Select Filter" ), "filter", mCore->actionCollection(), "select_filter" ); | 695 | mActionSelectFilter = new KSelectAction( i18n( "Select Filter" ), "filter", mCore->actionCollection(), "select_filter" ); |
695 | |||
696 | #if KDE_VERSION >= 309 | 696 | #if KDE_VERSION >= 309 |
697 | mActionSelectFilter->setMenuAccelsEnabled( false ); | 697 | mActionSelectFilter->setMenuAccelsEnabled( false ); |
698 | #endif | 698 | #endif |
699 | connect( mActionSelectFilter, SIGNAL( activated( int ) ), | 699 | connect( mActionSelectFilter, SIGNAL( activated( int ) ), |
700 | SLOT( setActiveFilter( int ) ) ); | 700 | SLOT( setActiveFilter( int ) ) ); |
701 | 701 | ||
702 | #ifdef KAB_EMBEDDED | 702 | #ifdef KAB_EMBEDDED |
703 | action->plug(settingsmenu); | 703 | action->plug(settingsmenu); |
704 | mActionSelectFilter->plug(viewmenu); | 704 | mActionSelectFilter->plug(viewmenu); |
705 | #endif //KAB_EMBEDDED | 705 | #endif //KAB_EMBEDDED |
706 | 706 | ||
707 | } | 707 | } |
708 | 708 | ||
709 | void ViewManager::initGUI() | 709 | void ViewManager::initGUI() |
710 | { | 710 | { |
711 | QHBoxLayout *layout = new QHBoxLayout( this, 0, 0 ); | 711 | QHBoxLayout *layout = new QHBoxLayout( this, 0, 0 ); |
712 | mViewWidgetStack = new QWidgetStack( this ); | 712 | mViewWidgetStack = new QWidgetStack( this ); |
713 | layout->addWidget( mViewWidgetStack ); | 713 | layout->addWidget( mViewWidgetStack ); |
714 | } | 714 | } |
715 | 715 | ||
716 | #ifndef KAB_EMBEDDED | 716 | #ifndef KAB_EMBEDDED |
717 | #include "viewmanager.moc" | 717 | #include "viewmanager.moc" |
718 | #endif //KAB_EMBEDDED | 718 | #endif //KAB_EMBEDDED |