Skip to content

Commit

Permalink
[BACKPORT] sort layers and fields alphabetically in fTools (fix #4412)
Browse files Browse the repository at this point in the history
  • Loading branch information
alexbruy committed Dec 14, 2011
1 parent 650a6bb commit 4d80762
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions python/plugins/fTools/tools/ftools_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@
from qgis.core import *
from qgis.gui import *

import locale

# From two input attribute maps, create single attribute map
def combineVectorAttributes( atMapA, atMapB ):
attribA = atMapA.values()
Expand Down Expand Up @@ -183,7 +185,7 @@ def getLayerNames( vTypes ):
elif layer.type() == QgsMapLayer.RasterLayer:
if "Raster" in vTypes:
layerlist.append( unicode( layer.name() ) )
return layerlist
return sorted( layerlist, cmp=locale.strcoll )

# Return list of names of all fields from input QgsVectorLayer
def getFieldNames( vlayer ):
Expand All @@ -192,7 +194,7 @@ def getFieldNames( vlayer ):
for name, field in fieldmap.iteritems():
if not field.name() in fieldlist:
fieldlist.append( unicode( field.name() ) )
return fieldlist
return sorted( fieldlist, cmp=locale.strcoll )

# Return QgsVectorLayer from a layer name ( as string )
def getVectorLayerByName( myName ):
Expand Down

0 comments on commit 4d80762

Please sign in to comment.