-rw-r--r-- | kaddressbook/viewmanager.cpp | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/kaddressbook/viewmanager.cpp b/kaddressbook/viewmanager.cpp index bec1862..45c7b55 100644 --- a/kaddressbook/viewmanager.cpp +++ b/kaddressbook/viewmanager.cpp @@ -241,192 +241,197 @@ void ViewManager::setActiveView( const QString &name ) mActiveView = view; mViewWidgetStack->raiseWidget( view ); // Set the proper filter in the view. By setting the combo // box, the activated slot will be called, which will push // the filter to the view and refresh it. if ( view->defaultFilterType() == KAddressBookView::None ) { mActionSelectFilter->setCurrentItem( 0 ); setActiveFilter( 0 ); } else if ( view->defaultFilterType() == KAddressBookView::Active ) { setActiveFilter( mActionSelectFilter->currentItem() ); } else { uint pos = filterPosition( view->defaultFilterName() ); mActionSelectFilter->setCurrentItem( pos ); setActiveFilter( pos ); } //US qDebug("ViewManager::setActiveView 6" ); // Update the inc search widget to show the fields in the new active // view. mCore->setSearchFields( mActiveView->fields() ); //US performance optimization. setActiveFilter calls also mActiveView->refresh() //US mActiveView->refresh(); } else { qDebug("ViewManager::setActiveView: unable to find view" ); kdDebug(5720) << "ViewManager::setActiveView: unable to find view\n"; } } //US added another method with no parameter, since my moc compiler does not support default parameters. void ViewManager::refreshView() { refreshView( QString::null ); } void ViewManager::refreshView( const QString &uid ) { if ( mActiveView ) mActiveView->refresh( uid ); } void ViewManager::editView() { if ( !mActiveView ) return; ViewFactory *factory = mViewFactoryDict.find( mActiveView->type() ); ViewConfigureWidget *wdg = 0; ViewConfigureDialog* dlg = 0; if ( factory ) { // Save the filters so the dialog has the latest set Filter::save( mCore->config(), "Filter", mFilterList ); dlg = new ViewConfigureDialog( 0, mActiveView->caption(), this, "conf_dlg" ); wdg = factory->configureWidget( mCore->addressBook(), dlg,"conf_wid" ); } else { qDebug("ViewManager::editView()::cannot find viewfactory "); return; } if ( wdg ) { dlg->setWidget( wdg ); #ifndef DESKTOP_VERSION //dlg.setMaximumSize( 640, 480 ); //dlg->setGeometry( 40,40, 400, 300); dlg->showMaximized(); #endif KConfigGroupSaver saver( mCore->config(), mActiveView->caption() ); dlg->restoreSettings( mCore->config() ); if ( dlg->exec() ) { dlg->saveSettings( mCore->config() ); mActiveView->readConfig( mCore->config() ); // Set the proper filter in the view. By setting the combo // box, the activated slot will be called, which will push // the filter to the view and refresh it. if ( mActiveView->defaultFilterType() == KAddressBookView::None ) { mActionSelectFilter->setCurrentItem( 0 ); setActiveFilter( 0 ); } else if ( mActiveView->defaultFilterType() == KAddressBookView::Active ) { setActiveFilter( mActionSelectFilter->currentItem() ); } else { uint pos = filterPosition( mActiveView->defaultFilterName() ); mActionSelectFilter->setCurrentItem( pos ); setActiveFilter( pos ); } mCore->setSearchFields( mActiveView->fields() ); //US performance optimization. setActiveFilter calls also mActiveView->refresh() //US mActiveView->refresh(); + + + //US this is a bugfix, that we get notified if we change a views configuration + emit modified(); + } } delete dlg; } void ViewManager::deleteView() { QString text = i18n( "<qt>Are you sure that you want to delete the view <b>%1</b>?</qt>" ) .arg( mActiveView->caption() ); QString caption = i18n( "Confirm Delete" ); if (QMessageBox::information( this, caption, text, i18n("Yes!"), i18n("No"), 0, 0 ) == 0) { mViewNameList.remove( mActiveView->caption() ); // remove the view from the config file KConfig *config = mCore->config(); config->deleteGroup( mActiveView->caption() ); mViewDict.remove( mActiveView->caption() ); mActiveView = 0; // we are in an invalid state now, but that should be fixed after // we emit the signal mActionSelectView->setItems( mViewNameList ); if ( mViewNameList.count() > 0 ) { mActionSelectView->setCurrentItem( 0 ); setActiveView( mViewNameList[ 0 ] ); } mActionDeleteView->setEnabled( mViewNameList.count() > 1 ); } } void ViewManager::addView() { AddViewDialog dialog( &mViewFactoryDict, this ); if ( dialog.exec() ) { QString newName = dialog.viewName(); QString type = dialog.viewType(); // Check for name conflicts bool firstConflict = true; int numTries = 1; while ( mViewNameList.contains( newName ) > 0 ) { if ( !firstConflict ) { newName = newName.left( newName.length() - 4 ); firstConflict = false; } newName = QString( "%1 <%2>" ).arg( newName ).arg( numTries ); numTries++; } // Add the new one to the list mViewNameList.append( newName ); // write the view to the config file, KConfig *config = mCore->config(); config->deleteGroup( newName ); KConfigGroupSaver saver( config, newName ); config->writeEntry( "Type", type ); // try to set the active view mActionSelectView->setItems( mViewNameList ); mActionSelectView->setCurrentItem( mViewNameList.findIndex( newName ) ); setActiveView( newName ); editView(); mActionDeleteView->setEnabled( mViewNameList.count() > 1 ); } } void ViewManager::createViewFactories() { #ifndef KAB_EMBEDDED KTrader::OfferList plugins = KTrader::self()->query( "KAddressBook/View" ); KTrader::OfferList::ConstIterator it; for ( it = plugins.begin(); it != plugins.end(); ++it ) { if ( !(*it)->hasServiceType( "KAddressBook/View" ) ) continue; KLibFactory *factory = KLibLoader::self()->factory( (*it)->library().latin1() ); if ( !factory ) { kdDebug(5720) << "ViewManager::createViewFactories(): Factory creation failed" << endl; continue; } |