Diffstat (limited to 'kaddressbook/viewmanager.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | kaddressbook/viewmanager.cpp | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/kaddressbook/viewmanager.cpp b/kaddressbook/viewmanager.cpp index c738ad8..b5d9419 100644 --- a/kaddressbook/viewmanager.cpp +++ b/kaddressbook/viewmanager.cpp | |||
@@ -196,145 +196,152 @@ void ViewManager::setSelected( const QString &uid, bool selected ) | |||
196 | void ViewManager::setListSelected(QStringList list) | 196 | void ViewManager::setListSelected(QStringList list) |
197 | { | 197 | { |
198 | int i, count = list.count(); | 198 | int i, count = list.count(); |
199 | for ( i = 0; i < count;++i ) | 199 | for ( i = 0; i < count;++i ) |
200 | setSelected( list[i], true ); | 200 | setSelected( list[i], true ); |
201 | 201 | ||
202 | } | 202 | } |
203 | void ViewManager::unloadViews() | 203 | void ViewManager::unloadViews() |
204 | { | 204 | { |
205 | mViewDict.clear(); | 205 | mViewDict.clear(); |
206 | mActiveView = 0; | 206 | mActiveView = 0; |
207 | } | 207 | } |
208 | 208 | ||
209 | void ViewManager::selectView( const QString &name ) | 209 | void ViewManager::selectView( const QString &name ) |
210 | { | 210 | { |
211 | setActiveView( name ); | 211 | setActiveView( name ); |
212 | mCore->saveSettings(); | 212 | mCore->saveSettings(); |
213 | } | 213 | } |
214 | void ViewManager::setActiveView( const QString &name ) | 214 | void ViewManager::setActiveView( const QString &name ) |
215 | { | 215 | { |
216 | KAddressBookView *view = 0; | 216 | KAddressBookView *view = 0; |
217 | 217 | ||
218 | // Check that this isn't the same as the current active view | 218 | // Check that this isn't the same as the current active view |
219 | if ( mActiveView && ( mActiveView->caption() == name ) ) | 219 | if ( mActiveView && ( mActiveView->caption() == name ) ) |
220 | return; | 220 | return; |
221 | 221 | ||
222 | // At this point we know the view that should be active is not | 222 | // At this point we know the view that should be active is not |
223 | // currently active. We will try to find the new on in the list. If | 223 | // currently active. We will try to find the new on in the list. If |
224 | // we can't find it, it means it hasn't been instantiated, so we will | 224 | // we can't find it, it means it hasn't been instantiated, so we will |
225 | // create it on demand. | 225 | // create it on demand. |
226 | 226 | ||
227 | view = mViewDict.find( name ); | 227 | view = mViewDict.find( name ); |
228 | 228 | ||
229 | // Check if we found the view. If we didn't, then we need to create it | 229 | // Check if we found the view. If we didn't, then we need to create it |
230 | if ( view == 0 ) { | 230 | if ( view == 0 ) { |
231 | KConfig *config = mCore->config(); | 231 | KConfig *config = mCore->config(); |
232 | 232 | ||
233 | KConfigGroupSaver saver( config, name ); | 233 | KConfigGroupSaver saver( config, name ); |
234 | 234 | ||
235 | QString type = config->readEntry( "Type", "Table" ); | 235 | QString type = config->readEntry( "Type", "Table" ); |
236 | 236 | ||
237 | kdDebug(5720) << "ViewManager::setActiveView: creating view - " << name << endl; | 237 | kdDebug(5720) << "ViewManager::setActiveView: creating view - " << name << endl; |
238 | 238 | ||
239 | ViewFactory *factory = mViewFactoryDict.find( type ); | 239 | ViewFactory *factory = mViewFactoryDict.find( type ); |
240 | if ( factory ) | 240 | if ( factory ) |
241 | view = factory->view( mCore->addressBook(), mViewWidgetStack ); | 241 | view = factory->view( mCore->addressBook(), mViewWidgetStack ); |
242 | 242 | ||
243 | if ( view ) { | 243 | if ( view ) { |
244 | if ( !mViewNameList.contains( name ) ) { | ||
245 | mViewNameList.append( name ); | ||
246 | } | ||
244 | view->setCaption( name ); | 247 | view->setCaption( name ); |
245 | mViewDict.insert( name, view ); | 248 | mViewDict.insert( name, view ); |
246 | //US my version needs an int as second parameter to addWidget | 249 | //US my version needs an int as second parameter to addWidget |
247 | mViewWidgetStack->addWidget( view, -1 ); | 250 | mViewWidgetStack->addWidget( view, -1 ); |
248 | view->readConfig( config ); | 251 | view->readConfig( config ); |
249 | 252 | ||
250 | // The manager just relays the signals | 253 | // The manager just relays the signals |
251 | connect( view, SIGNAL( selected( const QString& ) ), | 254 | connect( view, SIGNAL( selected( const QString& ) ), |
252 | SIGNAL( selected( const QString & ) ) ); | 255 | SIGNAL( selected( const QString & ) ) ); |
253 | connect( view, SIGNAL( executed( const QString& ) ), | 256 | connect( view, SIGNAL( executed( const QString& ) ), |
254 | SIGNAL( executed( const QString& ) ) ); | 257 | SIGNAL( executed( const QString& ) ) ); |
255 | 258 | ||
256 | connect( view, SIGNAL( deleteRequest( ) ), | 259 | connect( view, SIGNAL( deleteRequest( ) ), |
257 | SIGNAL( deleteRequest( ) ) ); | 260 | SIGNAL( deleteRequest( ) ) ); |
258 | 261 | ||
259 | connect( view, SIGNAL( modified() ), SIGNAL( modified() ) ); | 262 | connect( view, SIGNAL( modified() ), SIGNAL( modified() ) ); |
260 | connect( view, SIGNAL( dropped( QDropEvent* ) ), | 263 | connect( view, SIGNAL( dropped( QDropEvent* ) ), |
261 | SLOT( dropped( QDropEvent* ) ) ); | 264 | SLOT( dropped( QDropEvent* ) ) ); |
262 | connect( view, SIGNAL( startDrag() ), SLOT( startDrag() ) ); | 265 | connect( view, SIGNAL( startDrag() ), SLOT( startDrag() ) ); |
263 | } | 266 | } |
264 | } | 267 | } |
265 | 268 | ||
266 | // If we found or created the view, raise it and refresh it | 269 | // If we found or created the view, raise it and refresh it |
267 | if ( view ) { | 270 | if ( view ) { |
268 | mActiveView = view; | 271 | mActiveView = view; |
269 | mViewWidgetStack->raiseWidget( view ); | 272 | mViewWidgetStack->raiseWidget( view ); |
270 | // Set the proper filter in the view. By setting the combo | 273 | // Set the proper filter in the view. By setting the combo |
271 | // box, the activated slot will be called, which will push | 274 | // box, the activated slot will be called, which will push |
272 | // the filter to the view and refresh it. | 275 | // the filter to the view and refresh it. |
273 | 276 | ||
274 | if ( view->defaultFilterType() == KAddressBookView::None ) { | 277 | if ( view->defaultFilterType() == KAddressBookView::None ) { |
275 | 278 | ||
276 | mActionSelectFilter->setCurrentItem( 0 ); | 279 | mActionSelectFilter->setCurrentItem( 0 ); |
277 | setActiveFilter( 0 ); | 280 | setActiveFilter( 0 ); |
278 | } else if ( view->defaultFilterType() == KAddressBookView::Active ) { | 281 | } else if ( view->defaultFilterType() == KAddressBookView::Active ) { |
279 | setActiveFilter( mActionSelectFilter->currentItem() ); | 282 | setActiveFilter( mActionSelectFilter->currentItem() ); |
280 | } else { | 283 | } else { |
281 | uint pos = filterPosition( view->defaultFilterName() ); | 284 | uint pos = filterPosition( view->defaultFilterName() ); |
282 | mActionSelectFilter->setCurrentItem( pos ); | 285 | mActionSelectFilter->setCurrentItem( pos ); |
283 | setActiveFilter( pos ); | 286 | setActiveFilter( pos ); |
284 | } | 287 | } |
285 | //US qDebug("ViewManager::setActiveView 6" ); | 288 | //US qDebug("ViewManager::setActiveView 6" ); |
286 | 289 | ||
287 | // Update the inc search widget to show the fields in the new active | 290 | // Update the inc search widget to show the fields in the new active |
288 | // view. | 291 | // view. |
289 | mCore->setSearchFields( mActiveView->fields() ); | 292 | mCore->setSearchFields( mActiveView->fields() ); |
290 | 293 | ||
291 | //US performance optimization. setActiveFilter calls also mActiveView->refresh() | 294 | //US performance optimization. setActiveFilter calls also mActiveView->refresh() |
292 | //US mActiveView->refresh(); | 295 | //US mActiveView->refresh(); |
296 | |||
297 | mActionSelectView->setItems( mViewNameList ); | ||
298 | mActionSelectView->setCurrentItem( mViewNameList.findIndex( mActiveView->caption() ) ); | ||
299 | |||
293 | } | 300 | } |
294 | else | 301 | else |
295 | { | 302 | { |
296 | qDebug("ViewManager::setActiveView: unable to find view" ); | 303 | qDebug("ViewManager::setActiveView: unable to find view" ); |
297 | } | 304 | } |
298 | } | 305 | } |
299 | 306 | ||
300 | //US added another method with no parameter, since my moc compiler does not support default parameters. | 307 | //US added another method with no parameter, since my moc compiler does not support default parameters. |
301 | void ViewManager::refreshView() | 308 | void ViewManager::refreshView() |
302 | { | 309 | { |
303 | refreshView( QString::null ); | 310 | refreshView( QString::null ); |
304 | } | 311 | } |
305 | 312 | ||
306 | void ViewManager::refreshView( const QString &uid ) | 313 | void ViewManager::refreshView( const QString &uid ) |
307 | { | 314 | { |
308 | if ( mActiveView ) | 315 | if ( mActiveView ) |
309 | mActiveView->refresh( uid ); | 316 | mActiveView->refresh( uid ); |
310 | } | 317 | } |
311 | 318 | ||
312 | void ViewManager::setFocusAV() | 319 | void ViewManager::setFocusAV() |
313 | { | 320 | { |
314 | if ( mActiveView ) | 321 | if ( mActiveView ) |
315 | mActiveView->setFocusAV(); | 322 | mActiveView->setFocusAV(); |
316 | } | 323 | } |
317 | void ViewManager::editView() | 324 | void ViewManager::editView() |
318 | { | 325 | { |
319 | if ( !mActiveView ) | 326 | if ( !mActiveView ) |
320 | return; | 327 | return; |
321 | 328 | ||
322 | ViewFactory *factory = mViewFactoryDict.find( mActiveView->type() ); | 329 | ViewFactory *factory = mViewFactoryDict.find( mActiveView->type() ); |
323 | ViewConfigureWidget *wdg = 0; | 330 | ViewConfigureWidget *wdg = 0; |
324 | ViewConfigureDialog* dlg = 0; | 331 | ViewConfigureDialog* dlg = 0; |
325 | if ( factory ) { | 332 | if ( factory ) { |
326 | // Save the filters so the dialog has the latest set | 333 | // Save the filters so the dialog has the latest set |
327 | Filter::save( mCore->config(), "Filter", mFilterList ); | 334 | Filter::save( mCore->config(), "Filter", mFilterList ); |
328 | dlg = new ViewConfigureDialog( 0, mActiveView->caption(), this, "conf_dlg" ); | 335 | dlg = new ViewConfigureDialog( 0, mActiveView->caption(), this, "conf_dlg" ); |
329 | wdg = factory->configureWidget( mCore->addressBook(), dlg,"conf_wid" ); | 336 | wdg = factory->configureWidget( mCore->addressBook(), dlg,"conf_wid" ); |
330 | } else { | 337 | } else { |
331 | qDebug("ViewManager::editView()::cannot find viewfactory "); | 338 | qDebug("ViewManager::editView()::cannot find viewfactory "); |
332 | return; | 339 | return; |
333 | } | 340 | } |
334 | if ( wdg ) { | 341 | if ( wdg ) { |
335 | dlg->setWidget( wdg ); | 342 | dlg->setWidget( wdg ); |
336 | 343 | ||
337 | #ifndef DESKTOP_VERSION | 344 | #ifndef DESKTOP_VERSION |
338 | //dlg.setMaximumSize( 640, 480 ); | 345 | //dlg.setMaximumSize( 640, 480 ); |
339 | //dlg->setGeometry( 40,40, 400, 300); | 346 | //dlg->setGeometry( 40,40, 400, 300); |
340 | dlg->showMaximized(); | 347 | dlg->showMaximized(); |