summaryrefslogtreecommitdiffabout
path: root/kaddressbook/viewmanager.cpp
authorzautrix <zautrix>2005-01-17 12:18:59 (UTC)
committer zautrix <zautrix>2005-01-17 12:18:59 (UTC)
commit6b166ece0a576e9be9c71a61fab5424d75a9301f (patch) (unidiff)
treeb88bf3e82cafc0ac279eb46b8ebc61f112083032 /kaddressbook/viewmanager.cpp
parent376ffdba71ab4d7d7988229f38678394a54e5576 (diff)
downloadkdepimpi-6b166ece0a576e9be9c71a61fab5424d75a9301f.zip
kdepimpi-6b166ece0a576e9be9c71a61fab5424d75a9301f.tar.gz
kdepimpi-6b166ece0a576e9be9c71a61fab5424d75a9301f.tar.bz2
many AB fixes
Diffstat (limited to 'kaddressbook/viewmanager.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--kaddressbook/viewmanager.cpp3
1 files changed, 1 insertions, 2 deletions
diff --git a/kaddressbook/viewmanager.cpp b/kaddressbook/viewmanager.cpp
index 9c3a641..4be860e 100644
--- a/kaddressbook/viewmanager.cpp
+++ b/kaddressbook/viewmanager.cpp
@@ -222,134 +222,133 @@ void ViewManager::setActiveView( const QString &name )
222 // Check if we found the view. If we didn't, then we need to create it 222 // Check if we found the view. If we didn't, then we need to create it
223 if ( view == 0 ) { 223 if ( view == 0 ) {
224 KConfig *config = mCore->config(); 224 KConfig *config = mCore->config();
225 225
226 KConfigGroupSaver saver( config, name ); 226 KConfigGroupSaver saver( config, name );
227 227
228 QString type = config->readEntry( "Type", "Table" ); 228 QString type = config->readEntry( "Type", "Table" );
229 229
230 kdDebug(5720) << "ViewManager::setActiveView: creating view - " << name << endl; 230 kdDebug(5720) << "ViewManager::setActiveView: creating view - " << name << endl;
231 231
232 ViewFactory *factory = mViewFactoryDict.find( type ); 232 ViewFactory *factory = mViewFactoryDict.find( type );
233 if ( factory ) 233 if ( factory )
234 view = factory->view( mCore->addressBook(), mViewWidgetStack ); 234 view = factory->view( mCore->addressBook(), mViewWidgetStack );
235 235
236 if ( view ) { 236 if ( view ) {
237 view->setCaption( name ); 237 view->setCaption( name );
238 mViewDict.insert( name, view ); 238 mViewDict.insert( name, view );
239//US my version needs an int as second parameter to addWidget 239//US my version needs an int as second parameter to addWidget
240 mViewWidgetStack->addWidget( view, -1 ); 240 mViewWidgetStack->addWidget( view, -1 );
241 view->readConfig( config ); 241 view->readConfig( config );
242 242
243 // The manager just relays the signals 243 // The manager just relays the signals
244 connect( view, SIGNAL( selected( const QString& ) ), 244 connect( view, SIGNAL( selected( const QString& ) ),
245 SIGNAL( selected( const QString & ) ) ); 245 SIGNAL( selected( const QString & ) ) );
246 connect( view, SIGNAL( executed( const QString& ) ), 246 connect( view, SIGNAL( executed( const QString& ) ),
247 SIGNAL( executed( const QString& ) ) ); 247 SIGNAL( executed( const QString& ) ) );
248 248
249 connect( view, SIGNAL( deleteRequest( ) ), 249 connect( view, SIGNAL( deleteRequest( ) ),
250 SIGNAL( deleteRequest( ) ) ); 250 SIGNAL( deleteRequest( ) ) );
251 251
252 connect( view, SIGNAL( modified() ), SIGNAL( modified() ) ); 252 connect( view, SIGNAL( modified() ), SIGNAL( modified() ) );
253 connect( view, SIGNAL( dropped( QDropEvent* ) ), 253 connect( view, SIGNAL( dropped( QDropEvent* ) ),
254 SLOT( dropped( QDropEvent* ) ) ); 254 SLOT( dropped( QDropEvent* ) ) );
255 connect( view, SIGNAL( startDrag() ), SLOT( startDrag() ) ); 255 connect( view, SIGNAL( startDrag() ), SLOT( startDrag() ) );
256 } 256 }
257 } 257 }
258 258
259 // If we found or created the view, raise it and refresh it 259 // If we found or created the view, raise it and refresh it
260 if ( view ) { 260 if ( view ) {
261 mActiveView = view; 261 mActiveView = view;
262 mViewWidgetStack->raiseWidget( view ); 262 mViewWidgetStack->raiseWidget( view );
263 // Set the proper filter in the view. By setting the combo 263 // Set the proper filter in the view. By setting the combo
264 // box, the activated slot will be called, which will push 264 // box, the activated slot will be called, which will push
265 // the filter to the view and refresh it. 265 // the filter to the view and refresh it.
266 266
267 if ( view->defaultFilterType() == KAddressBookView::None ) { 267 if ( view->defaultFilterType() == KAddressBookView::None ) {
268 268
269 mActionSelectFilter->setCurrentItem( 0 ); 269 mActionSelectFilter->setCurrentItem( 0 );
270 setActiveFilter( 0 ); 270 setActiveFilter( 0 );
271 } else if ( view->defaultFilterType() == KAddressBookView::Active ) { 271 } else if ( view->defaultFilterType() == KAddressBookView::Active ) {
272 setActiveFilter( mActionSelectFilter->currentItem() ); 272 setActiveFilter( mActionSelectFilter->currentItem() );
273 } else { 273 } else {
274 uint pos = filterPosition( view->defaultFilterName() ); 274 uint pos = filterPosition( view->defaultFilterName() );
275 mActionSelectFilter->setCurrentItem( pos ); 275 mActionSelectFilter->setCurrentItem( pos );
276 setActiveFilter( pos ); 276 setActiveFilter( pos );
277 } 277 }
278//US qDebug("ViewManager::setActiveView 6" ); 278//US qDebug("ViewManager::setActiveView 6" );
279 279
280 // Update the inc search widget to show the fields in the new active 280 // Update the inc search widget to show the fields in the new active
281 // view. 281 // view.
282 mCore->setSearchFields( mActiveView->fields() ); 282 mCore->setSearchFields( mActiveView->fields() );
283 283
284//US performance optimization. setActiveFilter calls also mActiveView->refresh() 284//US performance optimization. setActiveFilter calls also mActiveView->refresh()
285//US mActiveView->refresh(); 285//US mActiveView->refresh();
286 286 mCore->saveSettings();
287 } 287 }
288 else 288 else
289 { 289 {
290 qDebug("ViewManager::setActiveView: unable to find view" ); 290 qDebug("ViewManager::setActiveView: unable to find view" );
291 kdDebug(5720) << "ViewManager::setActiveView: unable to find view\n";
292 } 291 }
293} 292}
294 293
295//US added another method with no parameter, since my moc compiler does not support default parameters. 294//US added another method with no parameter, since my moc compiler does not support default parameters.
296void ViewManager::refreshView() 295void ViewManager::refreshView()
297{ 296{
298 refreshView( QString::null ); 297 refreshView( QString::null );
299} 298}
300 299
301void ViewManager::refreshView( const QString &uid ) 300void ViewManager::refreshView( const QString &uid )
302{ 301{
303 if ( mActiveView ) 302 if ( mActiveView )
304 mActiveView->refresh( uid ); 303 mActiveView->refresh( uid );
305} 304}
306 305
307void ViewManager::setFocusAV() 306void ViewManager::setFocusAV()
308{ 307{
309 if ( mActiveView ) 308 if ( mActiveView )
310 mActiveView->setFocusAV(); 309 mActiveView->setFocusAV();
311} 310}
312void ViewManager::editView() 311void ViewManager::editView()
313{ 312{
314 if ( !mActiveView ) 313 if ( !mActiveView )
315 return; 314 return;
316 315
317 ViewFactory *factory = mViewFactoryDict.find( mActiveView->type() ); 316 ViewFactory *factory = mViewFactoryDict.find( mActiveView->type() );
318 ViewConfigureWidget *wdg = 0; 317 ViewConfigureWidget *wdg = 0;
319 ViewConfigureDialog* dlg = 0; 318 ViewConfigureDialog* dlg = 0;
320 if ( factory ) { 319 if ( factory ) {
321 // Save the filters so the dialog has the latest set 320 // Save the filters so the dialog has the latest set
322 Filter::save( mCore->config(), "Filter", mFilterList ); 321 Filter::save( mCore->config(), "Filter", mFilterList );
323 dlg = new ViewConfigureDialog( 0, mActiveView->caption(), this, "conf_dlg" ); 322 dlg = new ViewConfigureDialog( 0, mActiveView->caption(), this, "conf_dlg" );
324 wdg = factory->configureWidget( mCore->addressBook(), dlg,"conf_wid" ); 323 wdg = factory->configureWidget( mCore->addressBook(), dlg,"conf_wid" );
325 } else { 324 } else {
326 qDebug("ViewManager::editView()::cannot find viewfactory "); 325 qDebug("ViewManager::editView()::cannot find viewfactory ");
327 return; 326 return;
328 } 327 }
329 if ( wdg ) { 328 if ( wdg ) {
330 dlg->setWidget( wdg ); 329 dlg->setWidget( wdg );
331 330
332#ifndef DESKTOP_VERSION 331#ifndef DESKTOP_VERSION
333 //dlg.setMaximumSize( 640, 480 ); 332 //dlg.setMaximumSize( 640, 480 );
334 //dlg->setGeometry( 40,40, 400, 300); 333 //dlg->setGeometry( 40,40, 400, 300);
335 dlg->showMaximized(); 334 dlg->showMaximized();
336#endif 335#endif
337 336
338 KConfigGroupSaver saver( mCore->config(), mActiveView->caption() ); 337 KConfigGroupSaver saver( mCore->config(), mActiveView->caption() );
339 338
340 dlg->restoreSettings( mCore->config() ); 339 dlg->restoreSettings( mCore->config() );
341 340
342 if ( dlg->exec() ) { 341 if ( dlg->exec() ) {
343 dlg->saveSettings( mCore->config() ); 342 dlg->saveSettings( mCore->config() );
344 mActiveView->readConfig( mCore->config() ); 343 mActiveView->readConfig( mCore->config() );
345 344
346 // Set the proper filter in the view. By setting the combo 345 // Set the proper filter in the view. By setting the combo
347 // box, the activated slot will be called, which will push 346 // box, the activated slot will be called, which will push
348 // the filter to the view and refresh it. 347 // the filter to the view and refresh it.
349 if ( mActiveView->defaultFilterType() == KAddressBookView::None ) { 348 if ( mActiveView->defaultFilterType() == KAddressBookView::None ) {
350 mActionSelectFilter->setCurrentItem( 0 ); 349 mActionSelectFilter->setCurrentItem( 0 );
351 setActiveFilter( 0 ); 350 setActiveFilter( 0 );
352 } else if ( mActiveView->defaultFilterType() == KAddressBookView::Active ) { 351 } else if ( mActiveView->defaultFilterType() == KAddressBookView::Active ) {
353 setActiveFilter( mActionSelectFilter->currentItem() ); 352 setActiveFilter( mActionSelectFilter->currentItem() );
354 } else { 353 } else {
355 uint pos = filterPosition( mActiveView->defaultFilterName() ); 354 uint pos = filterPosition( mActiveView->defaultFilterName() );