@@ -271,44 +271,46 @@ void QgsBrowserDockWidget::removeFavorite()
271
271
272
272
void QgsBrowserDockWidget::refresh ()
273
273
{
274
- if ( mModel )
275
- refreshModel ( QModelIndex () );
274
+ refreshModel ( QModelIndex () );
276
275
}
277
276
278
277
void QgsBrowserDockWidget::refreshModel ( const QModelIndex &index )
279
278
{
280
- QgsDataItem *item = mModel ->dataItem ( index );
281
- if ( item )
282
- {
283
- QgsDebugMsg ( " path = " + item->path () );
284
- }
285
- else
286
- {
287
- QgsDebugMsg ( " invalid item" );
288
- }
289
-
290
- if ( item && ( item->capabilities2 () & QgsDataItem::Fertile ) )
291
- {
292
- mModel ->refresh ( index );
293
- }
294
-
295
- for ( int i = 0 ; i < mModel ->rowCount ( index ); i++ )
279
+ if ( mModel && mProxyModel )
296
280
{
297
- QModelIndex idx = mModel ->index ( i, 0 , index );
298
- QModelIndex proxyIdx = mProxyModel ->mapFromSource ( idx );
299
- QgsDataItem *child = mModel ->dataItem ( idx );
300
-
301
- // Check also expanded descendants so that the whole expanded path does not get collapsed if one item is collapsed.
302
- // Fast items (usually root items) are refreshed so that when collapsed, it is obvious they are if empty (no expand symbol).
303
- if ( mBrowserView ->isExpanded ( proxyIdx ) || mBrowserView ->hasExpandedDescendant ( proxyIdx ) || ( child && child->capabilities2 () & QgsDataItem::Fast ) )
281
+ QgsDataItem *item = mModel ->dataItem ( index );
282
+ if ( item )
304
283
{
305
- refreshModel ( idx );
284
+ QgsDebugMsg ( " path = " + item-> path () );
306
285
}
307
286
else
308
287
{
309
- if ( child && ( child->capabilities2 () & QgsDataItem::Fertile ) )
288
+ QgsDebugMsg ( " invalid item" );
289
+ }
290
+
291
+ if ( item && ( item->capabilities2 () & QgsDataItem::Fertile ) )
292
+ {
293
+ mModel ->refresh ( index );
294
+ }
295
+
296
+ for ( int i = 0 ; i < mModel ->rowCount ( index ); i++ )
297
+ {
298
+ QModelIndex idx = mModel ->index ( i, 0 , index );
299
+ QModelIndex proxyIdx = mProxyModel ->mapFromSource ( idx );
300
+ QgsDataItem *child = mModel ->dataItem ( idx );
301
+
302
+ // Check also expanded descendants so that the whole expanded path does not get collapsed if one item is collapsed.
303
+ // Fast items (usually root items) are refreshed so that when collapsed, it is obvious they are if empty (no expand symbol).
304
+ if ( mBrowserView ->isExpanded ( proxyIdx ) || mBrowserView ->hasExpandedDescendant ( proxyIdx ) || ( child && child->capabilities2 () & QgsDataItem::Fast ) )
305
+ {
306
+ refreshModel ( idx );
307
+ }
308
+ else
310
309
{
311
- child->depopulate ();
310
+ if ( child && ( child->capabilities2 () & QgsDataItem::Fertile ) )
311
+ {
312
+ child->depopulate ();
313
+ }
312
314
}
313
315
}
314
316
}
0 commit comments