summaryrefslogtreecommitdiffabout
path: root/kaddressbook/viewmanager.cpp
authorulf69 <ulf69>2004-08-20 22:13:00 (UTC)
committer ulf69 <ulf69>2004-08-20 22:13:00 (UTC)
commitbc33238f8038a03e04f25ea608c53e784616fee6 (patch) (side-by-side diff)
tree6b0ce40b7f05a62b26df5eca19f9fdf4cc2cffba /kaddressbook/viewmanager.cpp
parent0b6f4c58076a92ad81085db87358fab8666276d9 (diff)
downloadkdepimpi-bc33238f8038a03e04f25ea608c53e784616fee6.zip
kdepimpi-bc33238f8038a03e04f25ea608c53e784616fee6.tar.gz
kdepimpi-bc33238f8038a03e04f25ea608c53e784616fee6.tar.bz2
performanceenhancements by removing unnecessary refreshs
Diffstat (limited to 'kaddressbook/viewmanager.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--kaddressbook/viewmanager.cpp66
1 files changed, 34 insertions, 32 deletions
diff --git a/kaddressbook/viewmanager.cpp b/kaddressbook/viewmanager.cpp
index e8c5b45..bec1862 100644
--- a/kaddressbook/viewmanager.cpp
+++ b/kaddressbook/viewmanager.cpp
@@ -96,41 +96,41 @@ void ViewManager::restoreSettings()
// Filter
mFilterList = Filter::restore( mCore->config(), "Filter" );
mActionSelectFilter->setItems( filterNames() );
mActionSelectFilter->setCurrentItem( KABPrefs::instance()->mCurrentFilter );
// Tell the views to reread their config, since they may have
// been modified by global settings
QString _oldgroup = mCore->config()->group();
-
+
QDictIterator<KAddressBookView> it( mViewDict );
for ( it.toFirst(); it.current(); ++it ) {
KConfigGroupSaver saver( mCore->config(), it.currentKey() );
it.current()->readConfig( mCore->config() );
}
setActiveView( activeViewName );
mActionDeleteView->setEnabled( mViewNameList.count() > 1 );
}
void ViewManager::saveSettings()
{
QString _oldgroup = mCore->config()->group();
-
+
QDictIterator<KAddressBookView> it( mViewDict );
for ( it.toFirst(); it.current(); ++it ) {
KConfigGroupSaver saver( mCore->config(), it.currentKey() );
#ifdef DESKTOP_VERSION
(*it)->writeConfig( mCore->config() );
#else
(*it).writeConfig( mCore->config() );
#endif
}
-
+
Filter::save( mCore->config(), "Filter", mFilterList );
KABPrefs::instance()->mCurrentFilter = mActionSelectFilter->currentItem();
// write the view name list
KABPrefs::instance()->mViewNames = mViewNameList;
KABPrefs::instance()->mCurrentView = mActiveView->caption();
}
@@ -161,17 +161,17 @@ KABC::Addressee::List ViewManager::selectedAddressees() const
KABC::Addressee addr = mCore->addressBook()->findByUid( *it );
if ( !addr.isEmpty() )
list.append( addr );
}
}
return list;
}
-//US added another method with no parameter, since my moc compiler does not support default parameters.
+//US added another method with no parameter, since my moc compiler does not support default parameters.
void ViewManager::setSelected()
{
setSelected( QString::null, true );
}
void ViewManager::setSelected( const QString &uid, bool selected )
{
if ( mActiveView )
@@ -201,46 +201,46 @@ void ViewManager::setActiveView( const QString &name )
// Check if we found the view. If we didn't, then we need to create it
if ( view == 0 ) {
KConfig *config = mCore->config();
KConfigGroupSaver saver( config, name );
QString type = config->readEntry( "Type", "Table" );
-
+
kdDebug(5720) << "ViewManager::setActiveView: creating view - " << name << endl;
ViewFactory *factory = mViewFactoryDict.find( type );
if ( factory )
view = factory->view( mCore->addressBook(), mViewWidgetStack );
-
+
if ( view ) {
view->setCaption( name );
mViewDict.insert( name, view );
//US my version needs an int as second parameter to addWidget
mViewWidgetStack->addWidget( view, -1 );
view->readConfig( config );
// The manager just relays the signals
connect( view, SIGNAL( selected( const QString& ) ),
SIGNAL( selected( const QString & ) ) );
connect( view, SIGNAL( executed( const QString& ) ),
SIGNAL( executed( const QString& ) ) );
-
+
connect( view, SIGNAL( deleteRequest( ) ),
SIGNAL( deleteRequest( ) ) );
-
+
connect( view, SIGNAL( modified() ), SIGNAL( modified() ) );
connect( view, SIGNAL( dropped( QDropEvent* ) ),
SLOT( dropped( QDropEvent* ) ) );
connect( view, SIGNAL( startDrag() ), SLOT( startDrag() ) );
}
}
-
+
// If we found or created the view, raise it and refresh it
if ( view ) {
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.
@@ -251,32 +251,33 @@ void ViewManager::setActiveView( const QString &name )
} 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() );
- mActiveView->refresh();
+//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.
+//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 )
@@ -298,58 +299,59 @@ void ViewManager::editView()
wdg = factory->configureWidget( mCore->addressBook(), dlg,"conf_wid" );
} else {
qDebug("ViewManager::editView()::cannot find viewfactory ");
return;
}
if ( wdg ) {
dlg->setWidget( wdg );
-#ifndef DESKTOP_VERSION
+#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() );
- mActiveView->refresh();
+//US performance optimization. setActiveFilter calls also mActiveView->refresh()
+//US mActiveView->refresh();
}
-
+
}
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();
@@ -390,23 +392,23 @@ void ViewManager::addView()
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 );
@@ -448,25 +450,25 @@ void ViewManager::createViewFactories()
mViewFactoryDict.insert( viewFactory->type(), viewFactory );
// qDebug("ViewManager::createViewFactories() Loading factory: %s", viewFactory->type().latin1());
viewFactory = new CardViewFactory();
mViewFactoryDict.insert( viewFactory->type(), viewFactory );
// qDebug("ViewManager::createViewFactories() Loading factory: %s", viewFactory->type().latin1());
#endif //KAB_EMBEDDED
-
+
}
void ViewManager::dropped( QDropEvent *e )
{
kdDebug(5720) << "ViewManager::dropped: got a drop event" << endl;
#ifndef KAB_EMBEDDED
-
+
QString clipText, vcards;
KURL::List urls;
if ( KURLDrag::decode( e, urls) ) {
KURL::List::Iterator it = urls.begin();
int c = urls.count();
if ( c > 1 ) {
QString questionString = i18n( "Import one contact into your addressbook?", "Import %n contacts into your addressbook?", c );
@@ -491,17 +493,17 @@ void ViewManager::dropped( QDropEvent *e )
}
}
mActiveView->refresh();
}
#else //KAB_EMBEDDED
qDebug("ViewManager::dropped() has to be changed!!" );
#endif //KAB_EMBEDDED
-
+
}
void ViewManager::startDrag()
{
kdDebug(5720) << "ViewManager::startDrag: starting to drag" << endl;
#ifndef KAB_EMBEDDED
@@ -586,38 +588,38 @@ int ViewManager::filterPosition( const QString &name ) const
if ( name == (*it).name() )
return pos + 1;
return 0;
}
void ViewManager::initActions()
{
-//US <ActionList name="view_loadedviews"/>
+//US <ActionList name="view_loadedviews"/>
//US <Separator/>
#ifdef KAB_EMBEDDED
QPopupMenu *viewmenu = (QPopupMenu*)mCore->getViewMenu();
QPopupMenu *settingsmenu = (QPopupMenu*)mCore->getSettingsMenu();
QPopupMenu *filtermenu = (QPopupMenu*)mCore->getFilterMenu();
#endif //KAB_EMBEDDED
-
+
mActionSelectView = new KSelectAction( i18n( "Select View" ), 0, mCore->actionCollection(), "select_view" );
#if KDE_VERSION >= 309
mActionSelectView->setMenuAccelsEnabled( false );
#endif
connect( mActionSelectView, SIGNAL( activated( const QString& ) ),
SLOT( setActiveView( const QString& ) ) );
-
+
#ifdef KAB_EMBEDDED
mActionSelectView->plug(viewmenu);
viewmenu->insertSeparator();
#endif //KAB_EMBEDDED
-
+
KAction *action;
action = new KAction( i18n( "Modify View..." ), "configure", 0, this,
SLOT( editView() ), mCore->actionCollection(), "view_modify" );
#ifndef KAB_EMBEDDED
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." ) );
#else //KAB_EMBEDDED
action->plug(viewmenu);
@@ -653,29 +655,29 @@ void ViewManager::initActions()
action->plug(viewmenu);
viewmenu->insertSeparator();
#endif //KAB_EMBEDDED
action = new KAction( i18n( "Edit &Filters..." ), "filter", 0, this,
SLOT( configureFilters() ), mCore->actionCollection(),
"options_edit_filters" );
- mActionSelectFilter = new KSelectAction( i18n( "Select Filter" ), "filter", mCore->actionCollection(), "select_filter" );
-
+ mActionSelectFilter = new KSelectAction( i18n( "Select Filter" ), "filter", mCore->actionCollection(), "select_filter" );
+
#if KDE_VERSION >= 309
mActionSelectFilter->setMenuAccelsEnabled( false );
#endif
connect( mActionSelectFilter, SIGNAL( activated( int ) ),
SLOT( setActiveFilter( int ) ) );
#ifdef KAB_EMBEDDED
action->plug(settingsmenu);
mActionSelectFilter->plug(viewmenu);
#endif //KAB_EMBEDDED
-
+
}
void ViewManager::initGUI()
{
QHBoxLayout *layout = new QHBoxLayout( this, 0, 0 );
mViewWidgetStack = new QWidgetStack( this );
layout->addWidget( mViewWidgetStack );
}