Skip to content
Permalink
Browse files

Fix labeling-ng with utf-8 layers (ticket #3854)

  • Loading branch information
mhugent committed Jul 2, 2011
1 parent b55a00e commit 6cbb9f0f696d8e225938a278da4f82fdd3c64efa
Showing with 8 additions and 6 deletions.
  1. +8 −6 src/core/qgspallabeling.cpp
@@ -726,7 +726,7 @@ int QgsPalLabeling::prepareLayer( QgsVectorLayer* layer, QSet<int>& attrIndices,
max_scale = lyr.scaleMax;
}

Layer* l = mPal->addLayer( layer->id().toLocal8Bit().data(),
Layer* l = mPal->addLayer( layer->id().toUtf8().data(),
min_scale, max_scale, arrangement,
METER, priority, lyr.obstacle, true, true );

@@ -763,7 +763,7 @@ int QgsPalLabeling::prepareLayer( QgsVectorLayer* layer, QSet<int>& attrIndices,

int QgsPalLabeling::addDiagramLayer( QgsVectorLayer* layer, QgsDiagramLayerSettings *s )
{
Layer* l = mPal->addLayer( layer->id().append( "d" ).toLocal8Bit().data(), -1, -1, pal::Arrangement( s->placement ), METER, s->priority, s->obstacle, true, true );
Layer* l = mPal->addLayer( layer->id().append( "d" ).toUtf8().data(), -1, -1, pal::Arrangement( s->placement ), METER, s->priority, s->obstacle, true, true );
l->setArrangementFlags( s->placementFlags );

s->palLayer = l;
@@ -1003,13 +1003,15 @@ void QgsPalLabeling::drawLabeling( QgsRenderContext& context )
continue;
}

//layer names
QString layerNameUtf8 = QString::fromUtf8(( *it )->getLayerName() );
if ( palGeometry->isDiagram() )
{
//render diagram
QHash<QgsVectorLayer*, QgsDiagramLayerSettings>::iterator dit = mActiveDiagramLayers.begin();
for ( dit = mActiveDiagramLayers.begin(); dit != mActiveDiagramLayers.end(); ++dit )
{
if ( dit.key() && dit.key()->id().append( "d" ) == ( *it )->getLayerName() )
if ( dit.key() && dit.key()->id().append( "d" ) == layerNameUtf8 )
{
QgsPoint outPt = xform->transform(( *it )->getX(), ( *it )->getY() );
dit.value().renderer->renderDiagram( palGeometry->diagramAttributes(), context, QPointF( outPt.x(), outPt.y() ) );
@@ -1020,14 +1022,14 @@ void QgsPalLabeling::drawLabeling( QgsRenderContext& context )
if ( mLabelSearchTree )
{
//for diagrams, remove the additional 'd' at the end of the layer id
QString layerId = ( *it )->getLayerName();
QString layerId = layerNameUtf8;
layerId.chop( 1 );
mLabelSearchTree->insertLabel( *it, QString( palGeometry->strId() ).toInt(), layerId, true );
}
continue;
}

const QgsPalLayerSettings& lyr = layer(( *it )->getLayerName() );
const QgsPalLayerSettings& lyr = layer( layerNameUtf8 );
QFont fontForLabel = lyr.textFont;
QColor fontColor = lyr.textColor;
double bufferSize = lyr.bufferSize;
@@ -1206,7 +1208,7 @@ void QgsPalLabeling::drawLabel( pal::LabelPosition* label, QPainter* painter, co
QgsPoint outPt = xform->transform( label->getX(), label->getY() );

// TODO: optimize access :)
const QgsPalLayerSettings& lyr = layer( label->getLayerName() );
const QgsPalLayerSettings& lyr = layer( QString::fromUtf8( label->getLayerName() ) );

QString text = (( QgsPalGeometry* )label->getFeaturePart()->getUserGeometry() )->text();
QString txt = ( label->getPartId() == -1 ? text : QString( text[label->getPartId()] ) );

0 comments on commit 6cbb9f0

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