Skip to content
Permalink
Browse files
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 6768e6aa45fb76511e65ef5621220d4701d5c122
Showing with 19 additions and 4 deletions.
  1. +3 −1 src/core/qgsbrowsermodel.cpp
  2. +16 −3 src/core/qgsdataitem.cpp
@@ -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 )
@@ -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 )

0 comments on commit 6768e6a

Please sign in to comment.