Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
sort items in browser dock: sort items by type, so directories are be…
…fore data items, sort top-level provider items by name

Signed-off-by: Tim Sutton <tim@linfiniti.com>
  • Loading branch information
etiennesky authored and timlinux committed Mar 31, 2012
1 parent efac197 commit 6768e6a
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 4 deletions.
4 changes: 3 additions & 1 deletion src/core/qgsbrowsermodel.cpp
Expand Up @@ -54,7 +54,9 @@ void QgsBrowserModel::addRootItems()
}

// Add non file top level items
foreach( QString key, QgsProviderRegistry::instance()->providerList() )
QStringList providersList = QgsProviderRegistry::instance()->providerList();
providersList.sort();
foreach( QString key, providersList )
{
QLibrary *library = QgsProviderRegistry::instance()->providerLibrary( key );
if ( !library )
Expand Down
19 changes: 16 additions & 3 deletions src/core/qgsdataitem.cpp
Expand Up @@ -206,10 +206,23 @@ void QgsDataItem::addChildItem( QgsDataItem * child, bool refresh )
QgsDebugMsg( QString( "add child #%1 - %2" ).arg( mChildren.size() ).arg( child->mName ) );

int i;
for ( i = 0; i < mChildren.size(); i++ )
if ( type() == Directory )
{
if ( mChildren[i]->mName.localeAwareCompare( child->mName ) >= 0 )
break;
for ( i = 0; i < mChildren.size(); i++ )
{
// sort items by type, so directories are before data items
if ( mChildren[i]->mType == child->mType &&
mChildren[i]->mName.localeAwareCompare( child->mName ) >= 0 )
break;
}
}
else
{
for ( i = 0; i < mChildren.size(); i++ )
{
if ( mChildren[i]->mName.localeAwareCompare( child->mName ) >= 0 )
break;
}
}

if ( refresh )
Expand Down

0 comments on commit 6768e6a

Please sign in to comment.