@@ -229,6 +229,26 @@ class QgsBrowserTreeFilterProxyModel : public QSortFilterProxyModel
229
229
return true ;
230
230
}
231
231
232
+ bool lessThan ( const QModelIndex &left,
233
+ const QModelIndex &right ) const
234
+ {
235
+ // sort file items by name (a file item is not a directory and its parent is a directory)
236
+ // this is necessary because more several providers can add items to a directory and
237
+ // alphabetical sorting is not preserved
238
+ QgsDataItem* leftItem = mModel ->dataItem ( left );
239
+ QgsDataItem* rightItem = mModel ->dataItem ( right );
240
+ if ( leftItem && leftItem->type () != QgsDataItem::Directory &&
241
+ leftItem->parent () && leftItem->parent ()->type () == QgsDataItem::Directory &&
242
+ rightItem && rightItem->type () != QgsDataItem::Directory &&
243
+ rightItem->parent () && rightItem->parent ()->type () == QgsDataItem::Directory )
244
+ {
245
+ return QString::localeAwareCompare ( leftItem->name (), rightItem->name () ) < 0 ;
246
+ }
247
+
248
+ // default is to keep original order
249
+ return left.row () < right.row ();
250
+ }
251
+
232
252
};
233
253
QgsBrowserDockWidget::QgsBrowserDockWidget ( QString name, QWidget * parent ) :
234
254
QDockWidget( parent ), mModel( NULL ), mProxyModel( NULL )
@@ -308,7 +328,7 @@ void QgsBrowserDockWidget::showEvent( QShowEvent * e )
308
328
mBrowserView ->header ()->setResizeMode ( 0 , QHeaderView::ResizeToContents );
309
329
mBrowserView ->header ()->setStretchLastSection ( false );
310
330
311
- // find root favourites item
331
+ // expand root favourites item
312
332
for ( int i = 0 ; i < mModel ->rowCount (); i++ )
313
333
{
314
334
QModelIndex index = mModel ->index ( i, 0 );
0 commit comments