Skip to content
Permalink
Browse files

sort QgsRasterRendererRegistry entity names in a logical order, for u…

…se in raster properties dialog
  • Loading branch information
etiennesky committed Jul 14, 2012
1 parent dbce353 commit 87bdff9314e9cedc662fdd0c8f73813f805f1143
@@ -274,11 +274,13 @@ QgsRasterLayerProperties::QgsRasterLayerProperties( QgsMapLayer* lyr, QgsMapCanv
QgsRasterRendererRegistry::instance()->insertWidgetFunction( "singlebandgray", QgsSingleBandGrayRendererWidget::create );

//fill available renderers into combo box
QList< QgsRasterRendererRegistryEntry > rendererEntries = QgsRasterRendererRegistry::instance()->entries();
QList< QgsRasterRendererRegistryEntry >::const_iterator rendererIt = rendererEntries.constBegin();
for ( ; rendererIt != rendererEntries.constEnd(); ++rendererIt )
QgsRasterRendererRegistryEntry entry;
foreach( QString name, QgsRasterRendererRegistry::instance()->renderersList() )
{
mRenderTypeComboBox->addItem( rendererIt->visibleName, rendererIt->name );
if ( QgsRasterRendererRegistry::instance()->rendererData( name, entry ) )
{
mRenderTypeComboBox->addItem( entry.visibleName, entry.name );
}
}

if ( renderer )
@@ -48,13 +48,14 @@ QgsRasterRendererRegistry* QgsRasterRendererRegistry::instance()

QgsRasterRendererRegistry::QgsRasterRendererRegistry()
{
insert( QgsRasterRendererRegistryEntry( "paletted", QObject::tr( "Paletted" ), QgsPalettedRasterRenderer::create, 0 ) );
// insert items in a particular order, which is returned in renderersList()
insert( QgsRasterRendererRegistryEntry( "multibandcolor", QObject::tr( "Multiband color" ),
QgsMultiBandColorRenderer::create, 0 ) );
insert( QgsRasterRendererRegistryEntry( "singlebandpseudocolor", QObject::tr( "Singleband pseudocolor" ),
QgsSingleBandPseudoColorRenderer::create, 0 ) );
insert( QgsRasterRendererRegistryEntry( "paletted", QObject::tr( "Paletted" ), QgsPalettedRasterRenderer::create, 0 ) );
insert( QgsRasterRendererRegistryEntry( "singlebandgray", QObject::tr( "Singleband gray" ),
QgsSingleBandGrayRenderer::create, 0 ) );
insert( QgsRasterRendererRegistryEntry( "singlebandpseudocolor", QObject::tr( "Singleband pseudocolor" ),
QgsSingleBandPseudoColorRenderer::create, 0 ) );
insert( QgsRasterRendererRegistryEntry( "singlebandcolordata", QObject::tr( "Singleband color data" ),
QgsSingleBandColorDataRenderer::create, 0 ) );
}
@@ -66,6 +67,7 @@ QgsRasterRendererRegistry::~QgsRasterRendererRegistry()
void QgsRasterRendererRegistry::insert( QgsRasterRendererRegistryEntry entry )
{
mEntries.insert( entry.name, entry );
mSortedEntries.append( entry.name );
}

void QgsRasterRendererRegistry::insertWidgetFunction( const QString& rendererName, QgsRasterRendererWidgetCreateFunc func )
@@ -90,7 +92,8 @@ bool QgsRasterRendererRegistry::rendererData( const QString& rendererName, QgsRa

QStringList QgsRasterRendererRegistry::renderersList() const
{
return QStringList( mEntries.keys() );
// return QStringList( mEntries.keys() );
return mSortedEntries;
}

QList< QgsRasterRendererRegistryEntry > QgsRasterRendererRegistry::entries() const
@@ -64,6 +64,7 @@ class CORE_EXPORT QgsRasterRendererRegistry
private:
static QgsRasterRendererRegistry* mInstance;
QHash< QString, QgsRasterRendererRegistryEntry > mEntries;
QStringList mSortedEntries;

//read min/max values from
bool minMaxValuesForBand( int band, QgsRasterDataProvider* provider, double& minValue, double& maxValue ) const;

0 comments on commit 87bdff9

Please sign in to comment.
You can’t perform that action at this time.