Skip to content

Commit 59c88cc

Browse files
committed
browser sorting fix
1 parent 302480d commit 59c88cc

File tree

3 files changed

+3
-23
lines changed

3 files changed

+3
-23
lines changed

src/app/qgsbrowserdockwidget.cpp

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -228,27 +228,6 @@ class QgsBrowserTreeFilterProxyModel : public QSortFilterProxyModel
228228
// accept anything else
229229
return true;
230230
}
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-
252231
};
253232
QgsBrowserDockWidget::QgsBrowserDockWidget( QString name, QWidget * parent ) :
254233
QDockWidget( parent ), mModel( NULL ), mProxyModel( NULL )
@@ -321,7 +300,6 @@ void QgsBrowserDockWidget::showEvent( QShowEvent * e )
321300

322301
mProxyModel = new QgsBrowserTreeFilterProxyModel( this );
323302
mProxyModel->setBrowserModel( mModel );
324-
mProxyModel->sort( 0 );
325303
mBrowserView->setModel( mProxyModel );
326304
// provide a horizontal scroll bar instead of using ellipse (...) for longer items
327305
mBrowserView->setTextElideMode( Qt::ElideNone );

src/core/qgsdataitem.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,7 @@ void QgsDataItem::addChildItem( QgsDataItem * child, bool refresh )
223223
{
224224
// sort items by type, so directories are before data items
225225
if ( mChildren[i]->mType == child->mType &&
226-
mChildren[i]->mName.localeAwareCompare( child->mName ) >= 0 )
226+
mChildren[i]->mName.localeAwareCompare( child->mName ) > 0 )
227227
break;
228228
}
229229
}

src/providers/grass/qgsgrassprovidermodule.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ QgsGrassLocationItem::QgsGrassLocationItem( QgsDataItem* parent, QString path )
2828
QFileInfo fi( path );
2929
mName = fi.baseName();
3030
mIcon = QIcon( QgsApplication::getThemePixmap( "grass_location.png" ) );
31+
// set Directory type so that when sorted it gets into dirs (after the dir it represents)
32+
mType = QgsDataItem::Directory;
3133
}
3234
QgsGrassLocationItem::~QgsGrassLocationItem() {}
3335

0 commit comments

Comments
 (0)