author | ulf69 <ulf69> | 2004-08-20 22:13:00 (UTC) |
---|---|---|
committer | ulf69 <ulf69> | 2004-08-20 22:13:00 (UTC) |
commit | bc33238f8038a03e04f25ea608c53e784616fee6 (patch) (unidiff) | |
tree | 6b0ce40b7f05a62b26df5eca19f9fdf4cc2cffba /kaddressbook/viewmanager.cpp | |
parent | 0b6f4c58076a92ad81085db87358fab8666276d9 (diff) | |
download | kdepimpi-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.cpp | 66 |
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 | |||
@@ -100,9 +100,9 @@ void ViewManager::restoreSettings() | |||
100 | 100 | ||
101 | // Tell the views to reread their config, since they may have | 101 | // Tell the views to reread their config, since they may have |
102 | // been modified by global settings | 102 | // been modified by global settings |
103 | QString _oldgroup = mCore->config()->group(); | 103 | QString _oldgroup = mCore->config()->group(); |
104 | 104 | ||
105 | QDictIterator<KAddressBookView> it( mViewDict ); | 105 | QDictIterator<KAddressBookView> it( mViewDict ); |
106 | for ( it.toFirst(); it.current(); ++it ) { | 106 | for ( it.toFirst(); it.current(); ++it ) { |
107 | KConfigGroupSaver saver( mCore->config(), it.currentKey() ); | 107 | KConfigGroupSaver saver( mCore->config(), it.currentKey() ); |
108 | it.current()->readConfig( mCore->config() ); | 108 | it.current()->readConfig( mCore->config() ); |
@@ -114,9 +114,9 @@ void ViewManager::restoreSettings() | |||
114 | 114 | ||
115 | void ViewManager::saveSettings() | 115 | void ViewManager::saveSettings() |
116 | { | 116 | { |
117 | QString _oldgroup = mCore->config()->group(); | 117 | QString _oldgroup = mCore->config()->group(); |
118 | 118 | ||
119 | QDictIterator<KAddressBookView> it( mViewDict ); | 119 | QDictIterator<KAddressBookView> it( mViewDict ); |
120 | for ( it.toFirst(); it.current(); ++it ) { | 120 | for ( it.toFirst(); it.current(); ++it ) { |
121 | KConfigGroupSaver saver( mCore->config(), it.currentKey() ); | 121 | KConfigGroupSaver saver( mCore->config(), it.currentKey() ); |
122 | #ifdef DESKTOP_VERSION | 122 | #ifdef DESKTOP_VERSION |
@@ -124,9 +124,9 @@ void ViewManager::saveSettings() | |||
124 | #else | 124 | #else |
125 | (*it).writeConfig( mCore->config() ); | 125 | (*it).writeConfig( mCore->config() ); |
126 | #endif | 126 | #endif |
127 | } | 127 | } |
128 | 128 | ||
129 | Filter::save( mCore->config(), "Filter", mFilterList ); | 129 | Filter::save( mCore->config(), "Filter", mFilterList ); |
130 | KABPrefs::instance()->mCurrentFilter = mActionSelectFilter->currentItem(); | 130 | KABPrefs::instance()->mCurrentFilter = mActionSelectFilter->currentItem(); |
131 | 131 | ||
132 | // write the view name list | 132 | // write the view name list |
@@ -165,9 +165,9 @@ KABC::Addressee::List ViewManager::selectedAddressees() const | |||
165 | } | 165 | } |
166 | 166 | ||
167 | return list; | 167 | return list; |
168 | } | 168 | } |
169 | //US added another method with no parameter, since my moc compiler does not support default parameters. | 169 | //US added another method with no parameter, since my moc compiler does not support default parameters. |
170 | void ViewManager::setSelected() | 170 | void ViewManager::setSelected() |
171 | { | 171 | { |
172 | setSelected( QString::null, true ); | 172 | setSelected( QString::null, true ); |
173 | } | 173 | } |
@@ -205,15 +205,15 @@ void ViewManager::setActiveView( const QString &name ) | |||
205 | 205 | ||
206 | KConfigGroupSaver saver( config, name ); | 206 | KConfigGroupSaver saver( config, name ); |
207 | 207 | ||
208 | QString type = config->readEntry( "Type", "Table" ); | 208 | QString type = config->readEntry( "Type", "Table" ); |
209 | 209 | ||
210 | kdDebug(5720) << "ViewManager::setActiveView: creating view - " << name << endl; | 210 | kdDebug(5720) << "ViewManager::setActiveView: creating view - " << name << endl; |
211 | 211 | ||
212 | ViewFactory *factory = mViewFactoryDict.find( type ); | 212 | ViewFactory *factory = mViewFactoryDict.find( type ); |
213 | if ( factory ) | 213 | if ( factory ) |
214 | view = factory->view( mCore->addressBook(), mViewWidgetStack ); | 214 | view = factory->view( mCore->addressBook(), mViewWidgetStack ); |
215 | 215 | ||
216 | if ( view ) { | 216 | if ( view ) { |
217 | view->setCaption( name ); | 217 | view->setCaption( name ); |
218 | mViewDict.insert( name, view ); | 218 | mViewDict.insert( name, view ); |
219 | //US my version needs an int as second parameter to addWidget | 219 | //US my version needs an int as second parameter to addWidget |
@@ -224,19 +224,19 @@ void ViewManager::setActiveView( const QString &name ) | |||
224 | connect( view, SIGNAL( selected( const QString& ) ), | 224 | connect( view, SIGNAL( selected( const QString& ) ), |
225 | SIGNAL( selected( const QString & ) ) ); | 225 | SIGNAL( selected( const QString & ) ) ); |
226 | connect( view, SIGNAL( executed( const QString& ) ), | 226 | connect( view, SIGNAL( executed( const QString& ) ), |
227 | SIGNAL( executed( const QString& ) ) ); | 227 | SIGNAL( executed( const QString& ) ) ); |
228 | 228 | ||
229 | connect( view, SIGNAL( deleteRequest( ) ), | 229 | connect( view, SIGNAL( deleteRequest( ) ), |
230 | SIGNAL( deleteRequest( ) ) ); | 230 | SIGNAL( deleteRequest( ) ) ); |
231 | 231 | ||
232 | connect( view, SIGNAL( modified() ), SIGNAL( modified() ) ); | 232 | connect( view, SIGNAL( modified() ), SIGNAL( modified() ) ); |
233 | connect( view, SIGNAL( dropped( QDropEvent* ) ), | 233 | connect( view, SIGNAL( dropped( QDropEvent* ) ), |
234 | SLOT( dropped( QDropEvent* ) ) ); | 234 | SLOT( dropped( QDropEvent* ) ) ); |
235 | connect( view, SIGNAL( startDrag() ), SLOT( startDrag() ) ); | 235 | connect( view, SIGNAL( startDrag() ), SLOT( startDrag() ) ); |
236 | } | 236 | } |
237 | } | 237 | } |
238 | 238 | ||
239 | // If we found or created the view, raise it and refresh it | 239 | // If we found or created the view, raise it and refresh it |
240 | if ( view ) { | 240 | if ( view ) { |
241 | mActiveView = view; | 241 | mActiveView = view; |
242 | mViewWidgetStack->raiseWidget( view ); | 242 | mViewWidgetStack->raiseWidget( view ); |
@@ -255,14 +255,15 @@ void ViewManager::setActiveView( const QString &name ) | |||
255 | mActionSelectFilter->setCurrentItem( pos ); | 255 | mActionSelectFilter->setCurrentItem( pos ); |
256 | setActiveFilter( pos ); | 256 | setActiveFilter( pos ); |
257 | } | 257 | } |
258 | //US qDebug("ViewManager::setActiveView 6" ); | 258 | //US qDebug("ViewManager::setActiveView 6" ); |
259 | 259 | ||
260 | // Update the inc search widget to show the fields in the new active | 260 | // Update the inc search widget to show the fields in the new active |
261 | // view. | 261 | // view. |
262 | mCore->setSearchFields( mActiveView->fields() ); | 262 | mCore->setSearchFields( mActiveView->fields() ); |
263 | 263 | ||
264 | mActiveView->refresh(); | 264 | //US performance optimization. setActiveFilter calls also mActiveView->refresh() |
265 | //US mActiveView->refresh(); | ||
265 | 266 | ||
266 | } | 267 | } |
267 | else | 268 | else |
268 | { | 269 | { |
@@ -270,9 +271,9 @@ void ViewManager::setActiveView( const QString &name ) | |||
270 | kdDebug(5720) << "ViewManager::setActiveView: unable to find view\n"; | 271 | kdDebug(5720) << "ViewManager::setActiveView: unable to find view\n"; |
271 | } | 272 | } |
272 | } | 273 | } |
273 | 274 | ||
274 | //US added another method with no parameter, since my moc compiler does not support default parameters. | 275 | //US added another method with no parameter, since my moc compiler does not support default parameters. |
275 | void ViewManager::refreshView() | 276 | void ViewManager::refreshView() |
276 | { | 277 | { |
277 | refreshView( QString::null ); | 278 | refreshView( QString::null ); |
278 | } | 279 | } |
@@ -302,22 +303,22 @@ void ViewManager::editView() | |||
302 | } | 303 | } |
303 | if ( wdg ) { | 304 | if ( wdg ) { |
304 | dlg->setWidget( wdg ); | 305 | dlg->setWidget( wdg ); |
305 | 306 | ||
306 | #ifndef DESKTOP_VERSION | 307 | #ifndef DESKTOP_VERSION |
307 | //dlg.setMaximumSize( 640, 480 ); | 308 | //dlg.setMaximumSize( 640, 480 ); |
308 | //dlg->setGeometry( 40,40, 400, 300); | 309 | //dlg->setGeometry( 40,40, 400, 300); |
309 | dlg->showMaximized(); | 310 | dlg->showMaximized(); |
310 | #endif | 311 | #endif |
311 | 312 | ||
312 | KConfigGroupSaver saver( mCore->config(), mActiveView->caption() ); | 313 | KConfigGroupSaver saver( mCore->config(), mActiveView->caption() ); |
313 | 314 | ||
314 | dlg->restoreSettings( mCore->config() ); | 315 | dlg->restoreSettings( mCore->config() ); |
315 | 316 | ||
316 | if ( dlg->exec() ) { | 317 | if ( dlg->exec() ) { |
317 | dlg->saveSettings( mCore->config() ); | 318 | dlg->saveSettings( mCore->config() ); |
318 | mActiveView->readConfig( mCore->config() ); | 319 | mActiveView->readConfig( mCore->config() ); |
319 | 320 | ||
320 | // Set the proper filter in the view. By setting the combo | 321 | // Set the proper filter in the view. By setting the combo |
321 | // box, the activated slot will be called, which will push | 322 | // box, the activated slot will be called, which will push |
322 | // the filter to the view and refresh it. | 323 | // the filter to the view and refresh it. |
323 | if ( mActiveView->defaultFilterType() == KAddressBookView::None ) { | 324 | if ( mActiveView->defaultFilterType() == KAddressBookView::None ) { |
@@ -330,11 +331,12 @@ void ViewManager::editView() | |||
330 | mActionSelectFilter->setCurrentItem( pos ); | 331 | mActionSelectFilter->setCurrentItem( pos ); |
331 | setActiveFilter( pos ); | 332 | setActiveFilter( pos ); |
332 | } | 333 | } |
333 | mCore->setSearchFields( mActiveView->fields() ); | 334 | mCore->setSearchFields( mActiveView->fields() ); |
334 | mActiveView->refresh(); | 335 | //US performance optimization. setActiveFilter calls also mActiveView->refresh() |
336 | //US mActiveView->refresh(); | ||
335 | } | 337 | } |
336 | 338 | ||
337 | } | 339 | } |
338 | delete dlg; | 340 | delete dlg; |
339 | } | 341 | } |
340 | 342 | ||
@@ -343,9 +345,9 @@ void ViewManager::deleteView() | |||
343 | QString text = i18n( "<qt>Are you sure that you want to delete the view <b>%1</b>?</qt>" ) | 345 | QString text = i18n( "<qt>Are you sure that you want to delete the view <b>%1</b>?</qt>" ) |
344 | .arg( mActiveView->caption() ); | 346 | .arg( mActiveView->caption() ); |
345 | QString caption = i18n( "Confirm Delete" ); | 347 | QString caption = i18n( "Confirm Delete" ); |
346 | 348 | ||
347 | 349 | ||
348 | if (QMessageBox::information( this, caption, | 350 | if (QMessageBox::information( this, caption, |
349 | text, | 351 | text, |
350 | i18n("Yes!"), i18n("No"), 0, 0 ) == 0) | 352 | i18n("Yes!"), i18n("No"), 0, 0 ) == 0) |
351 | { | 353 | { |
@@ -394,15 +396,15 @@ void ViewManager::addView() | |||
394 | mViewNameList.append( newName ); | 396 | mViewNameList.append( newName ); |
395 | 397 | ||
396 | // write the view to the config file, | 398 | // write the view to the config file, |
397 | KConfig *config = mCore->config(); | 399 | KConfig *config = mCore->config(); |
398 | 400 | ||
399 | config->deleteGroup( newName ); | 401 | config->deleteGroup( newName ); |
400 | 402 | ||
401 | KConfigGroupSaver saver( config, newName ); | 403 | KConfigGroupSaver saver( config, newName ); |
402 | 404 | ||
403 | config->writeEntry( "Type", type ); | 405 | config->writeEntry( "Type", type ); |
404 | 406 | ||
405 | // try to set the active view | 407 | // try to set the active view |
406 | mActionSelectView->setItems( mViewNameList ); | 408 | mActionSelectView->setItems( mViewNameList ); |
407 | mActionSelectView->setCurrentItem( mViewNameList.findIndex( newName ) ); | 409 | mActionSelectView->setCurrentItem( mViewNameList.findIndex( newName ) ); |
408 | setActiveView( newName ); | 410 | setActiveView( newName ); |
@@ -452,17 +454,17 @@ void ViewManager::createViewFactories() | |||
452 | mViewFactoryDict.insert( viewFactory->type(), viewFactory ); | 454 | mViewFactoryDict.insert( viewFactory->type(), viewFactory ); |
453 | // qDebug("ViewManager::createViewFactories() Loading factory: %s", viewFactory->type().latin1()); | 455 | // qDebug("ViewManager::createViewFactories() Loading factory: %s", viewFactory->type().latin1()); |
454 | 456 | ||
455 | #endif //KAB_EMBEDDED | 457 | #endif //KAB_EMBEDDED |
456 | 458 | ||
457 | } | 459 | } |
458 | 460 | ||
459 | void ViewManager::dropped( QDropEvent *e ) | 461 | void ViewManager::dropped( QDropEvent *e ) |
460 | { | 462 | { |
461 | kdDebug(5720) << "ViewManager::dropped: got a drop event" << endl; | 463 | kdDebug(5720) << "ViewManager::dropped: got a drop event" << endl; |
462 | 464 | ||
463 | #ifndef KAB_EMBEDDED | 465 | #ifndef KAB_EMBEDDED |
464 | 466 | ||
465 | QString clipText, vcards; | 467 | QString clipText, vcards; |
466 | KURL::List urls; | 468 | KURL::List urls; |
467 | 469 | ||
468 | if ( KURLDrag::decode( e, urls) ) { | 470 | if ( KURLDrag::decode( e, urls) ) { |
@@ -495,9 +497,9 @@ void ViewManager::dropped( QDropEvent *e ) | |||
495 | } | 497 | } |
496 | #else //KAB_EMBEDDED | 498 | #else //KAB_EMBEDDED |
497 | qDebug("ViewManager::dropped() has to be changed!!" ); | 499 | qDebug("ViewManager::dropped() has to be changed!!" ); |
498 | #endif //KAB_EMBEDDED | 500 | #endif //KAB_EMBEDDED |
499 | 501 | ||
500 | } | 502 | } |
501 | 503 | ||
502 | void ViewManager::startDrag() | 504 | void ViewManager::startDrag() |
503 | { | 505 | { |
@@ -590,30 +592,30 @@ int ViewManager::filterPosition( const QString &name ) const | |||
590 | } | 592 | } |
591 | 593 | ||
592 | void ViewManager::initActions() | 594 | void ViewManager::initActions() |
593 | { | 595 | { |
594 | //US <ActionList name="view_loadedviews"/> | 596 | //US <ActionList name="view_loadedviews"/> |
595 | //US <Separator/> | 597 | //US <Separator/> |
596 | 598 | ||
597 | #ifdef KAB_EMBEDDED | 599 | #ifdef KAB_EMBEDDED |
598 | QPopupMenu *viewmenu = (QPopupMenu*)mCore->getViewMenu(); | 600 | QPopupMenu *viewmenu = (QPopupMenu*)mCore->getViewMenu(); |
599 | QPopupMenu *settingsmenu = (QPopupMenu*)mCore->getSettingsMenu(); | 601 | QPopupMenu *settingsmenu = (QPopupMenu*)mCore->getSettingsMenu(); |
600 | QPopupMenu *filtermenu = (QPopupMenu*)mCore->getFilterMenu(); | 602 | QPopupMenu *filtermenu = (QPopupMenu*)mCore->getFilterMenu(); |
601 | #endif //KAB_EMBEDDED | 603 | #endif //KAB_EMBEDDED |
602 | 604 | ||
603 | mActionSelectView = new KSelectAction( i18n( "Select View" ), 0, mCore->actionCollection(), "select_view" ); | 605 | mActionSelectView = new KSelectAction( i18n( "Select View" ), 0, mCore->actionCollection(), "select_view" ); |
604 | #if KDE_VERSION >= 309 | 606 | #if KDE_VERSION >= 309 |
605 | mActionSelectView->setMenuAccelsEnabled( false ); | 607 | mActionSelectView->setMenuAccelsEnabled( false ); |
606 | #endif | 608 | #endif |
607 | connect( mActionSelectView, SIGNAL( activated( const QString& ) ), | 609 | connect( mActionSelectView, SIGNAL( activated( const QString& ) ), |
608 | SLOT( setActiveView( const QString& ) ) ); | 610 | SLOT( setActiveView( const QString& ) ) ); |
609 | 611 | ||
610 | 612 | ||
611 | #ifdef KAB_EMBEDDED | 613 | #ifdef KAB_EMBEDDED |
612 | mActionSelectView->plug(viewmenu); | 614 | mActionSelectView->plug(viewmenu); |
613 | viewmenu->insertSeparator(); | 615 | viewmenu->insertSeparator(); |
614 | #endif //KAB_EMBEDDED | 616 | #endif //KAB_EMBEDDED |
615 | 617 | ||
616 | KAction *action; | 618 | KAction *action; |
617 | 619 | ||
618 | action = new KAction( i18n( "Modify View..." ), "configure", 0, this, | 620 | action = new KAction( i18n( "Modify View..." ), "configure", 0, this, |
619 | SLOT( editView() ), mCore->actionCollection(), "view_modify" ); | 621 | SLOT( editView() ), mCore->actionCollection(), "view_modify" ); |
@@ -657,10 +659,10 @@ void ViewManager::initActions() | |||
657 | action = new KAction( i18n( "Edit &Filters..." ), "filter", 0, this, | 659 | action = new KAction( i18n( "Edit &Filters..." ), "filter", 0, this, |
658 | SLOT( configureFilters() ), mCore->actionCollection(), | 660 | SLOT( configureFilters() ), mCore->actionCollection(), |
659 | "options_edit_filters" ); | 661 | "options_edit_filters" ); |
660 | 662 | ||
661 | mActionSelectFilter = new KSelectAction( i18n( "Select Filter" ), "filter", mCore->actionCollection(), "select_filter" ); | 663 | mActionSelectFilter = new KSelectAction( i18n( "Select Filter" ), "filter", mCore->actionCollection(), "select_filter" ); |
662 | 664 | ||
663 | #if KDE_VERSION >= 309 | 665 | #if KDE_VERSION >= 309 |
664 | mActionSelectFilter->setMenuAccelsEnabled( false ); | 666 | mActionSelectFilter->setMenuAccelsEnabled( false ); |
665 | #endif | 667 | #endif |
666 | connect( mActionSelectFilter, SIGNAL( activated( int ) ), | 668 | connect( mActionSelectFilter, SIGNAL( activated( int ) ), |
@@ -669,9 +671,9 @@ void ViewManager::initActions() | |||
669 | #ifdef KAB_EMBEDDED | 671 | #ifdef KAB_EMBEDDED |
670 | action->plug(settingsmenu); | 672 | action->plug(settingsmenu); |
671 | mActionSelectFilter->plug(viewmenu); | 673 | mActionSelectFilter->plug(viewmenu); |
672 | #endif //KAB_EMBEDDED | 674 | #endif //KAB_EMBEDDED |
673 | 675 | ||
674 | } | 676 | } |
675 | 677 | ||
676 | void ViewManager::initGUI() | 678 | void ViewManager::initGUI() |
677 | { | 679 | { |