Skip to content
Permalink
Browse files

Fixed a problem with incorrectly loaded labeling attributes.

git-svn-id: http://svn.osgeo.org/qgis/trunk@7123 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
wonder
wonder committed Aug 5, 2007
1 parent 4ee8f44 commit 591ccebc00f216b3bfb995740a55edf84b87f982
Showing with 23 additions and 14 deletions.
  1. +23 −14 src/core/qgslabel.cpp
@@ -637,6 +637,15 @@ unsigned char* QgsLabel::labelPoint ( QgsPoint& point, unsigned char* geom)
return nextFeature;
}

static int _elementFieldIndex(QDomElement& el)
{
QString str = el.attribute("field","");
if (str == "")
return -1;
else
return str.toInt();
}

void QgsLabel::readXML( const QDomNode& node )
{
QgsDebugMsg(" called for layer label properties, got node " + node.nodeName());
@@ -658,7 +667,7 @@ void QgsLabel::readXML( const QDomNode& node )
{
el = scratchNode.toElement();
mLabelAttributes->setText ( el.attribute("text","") );
setLabelField ( Text, el.attribute("field","").toInt() );
setLabelField ( Text, _elementFieldIndex(el) );
}

/* Family */
@@ -672,7 +681,7 @@ void QgsLabel::readXML( const QDomNode& node )
{
el = scratchNode.toElement();
mLabelAttributes->setFamily ( el.attribute("name","") );
setLabelField ( Family, el.attribute("field","").toInt() );
setLabelField ( Family, _elementFieldIndex(el) );
}

/* Size */
@@ -687,7 +696,7 @@ void QgsLabel::readXML( const QDomNode& node )
el = scratchNode.toElement();
type = QgsLabelAttributes::unitsCode( el.attribute("units","") );
mLabelAttributes->setSize ( el.attribute("value", "0.0").toDouble(), type );
setLabelField ( Size, el.attribute("field","").toInt() );
setLabelField ( Size, _elementFieldIndex(el) );
}

/* Bold */
@@ -701,7 +710,7 @@ void QgsLabel::readXML( const QDomNode& node )
{
el = scratchNode.toElement();
mLabelAttributes->setBold ( (bool)el.attribute("on","0").toInt() );
setLabelField ( Bold, el.attribute("field","").toInt() );
setLabelField ( Bold, _elementFieldIndex(el) );
}

/* Italic */
@@ -715,7 +724,7 @@ void QgsLabel::readXML( const QDomNode& node )
{
el = scratchNode.toElement();
mLabelAttributes->setItalic ( (bool)el.attribute("on","0").toInt() );
setLabelField ( Italic, el.attribute("field","").toInt() );
setLabelField ( Italic, _elementFieldIndex(el) );
}

/* Underline */
@@ -729,7 +738,7 @@ void QgsLabel::readXML( const QDomNode& node )
{
el = scratchNode.toElement();
mLabelAttributes->setUnderline ( (bool)el.attribute("on","0").toInt() );
setLabelField ( Underline, el.attribute("field","").toInt() );
setLabelField ( Underline, _elementFieldIndex(el) );
}

/* Color */
@@ -749,7 +758,7 @@ void QgsLabel::readXML( const QDomNode& node )

mLabelAttributes->setColor( QColor(red, green, blue) );

setLabelField ( Color, el.attribute("field","").toInt() );
setLabelField ( Color, _elementFieldIndex(el) );
}

/* X */
@@ -762,7 +771,7 @@ void QgsLabel::readXML( const QDomNode& node )
else
{
el = scratchNode.toElement();
setLabelField ( XCoordinate, el.attribute("field","").toInt() );
setLabelField ( XCoordinate, _elementFieldIndex(el) );
}

/* Y */
@@ -775,7 +784,7 @@ void QgsLabel::readXML( const QDomNode& node )
else
{
el = scratchNode.toElement();
setLabelField ( YCoordinate, el.attribute("field","").toInt() );
setLabelField ( YCoordinate, _elementFieldIndex(el) );
}


@@ -812,7 +821,7 @@ void QgsLabel::readXML( const QDomNode& node )
{
el = scratchNode.toElement();
mLabelAttributes->setAngle ( el.attribute("value","0.0").toDouble() );
setLabelField ( Angle, el.attribute("field","0").toInt() );
setLabelField ( Angle, _elementFieldIndex(el) );
}

/* Alignment */
@@ -826,7 +835,7 @@ void QgsLabel::readXML( const QDomNode& node )
{
el = scratchNode.toElement();
mLabelAttributes->setAlignment ( QgsLabelAttributes::alignmentCode(el.attribute("value","")) );
setLabelField ( Alignment, el.attribute("field","").toInt() );
setLabelField ( Alignment, _elementFieldIndex(el) );
}


@@ -846,7 +855,7 @@ void QgsLabel::readXML( const QDomNode& node )
blue = el.attribute("blue","0").toInt();

mLabelAttributes->setBufferColor( QColor(red, green, blue) );
setLabelField ( BufferColor, el.attribute("field","").toInt() );
setLabelField ( BufferColor, _elementFieldIndex(el) );
}

scratchNode = node.namedItem("buffersize");
@@ -861,7 +870,7 @@ void QgsLabel::readXML( const QDomNode& node )

type = QgsLabelAttributes::unitsCode( el.attribute("units","") );
mLabelAttributes->setBufferSize ( el.attribute("value","0.0").toDouble(), type );
setLabelField ( BufferSize, el.attribute("field","").toInt() );
setLabelField ( BufferSize, _elementFieldIndex(el) );
}

scratchNode = node.namedItem("bufferenabled");
@@ -875,7 +884,7 @@ void QgsLabel::readXML( const QDomNode& node )
el = scratchNode.toElement();

mLabelAttributes->setBufferEnabled ( (bool)el.attribute("on","0").toInt() );
setLabelField ( BufferEnabled, el.attribute("field","").toInt() );
setLabelField ( BufferEnabled, _elementFieldIndex(el) );
}

} // QgsLabel::readXML()

0 comments on commit 591cceb

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