Fix: legends item either have a pixmap or a color, not both

parent a74688d3
......@@ -353,12 +353,10 @@ QString MarbleLegendBrowser::generateSectionsHtml()
styleDiv = "width: " + QString::number(pixmapWidth) + "px; height: " +
QString::number(pixmapHeight) + "px;";
}
// NOTICE. There are some pixmaps without image, so we should
// create just a plain rectangle with set color
QColor color = item->icon()->color();
if ( color.isValid() ) {
else if (item->icon()->color().isValid()) {
const QColor color = item->icon()->color();
styleDiv = "width: " + QString::number(pixmapWidth) + "px; height: " +
QString::number(pixmapHeight) + "px; background-color: " + color.name() + ';';
}
......
......@@ -45,10 +45,11 @@ GeoNode* DgmlIconTagHandler::parse(GeoParser& parser) const
Q_ASSERT(parser.isStartElement() && parser.isValidElement(dgmlTag_Icon));
QString pixmapRelativePath = parser.attribute(dgmlAttr_pixmap).trimmed();
QColor color = QColor( parser.attribute(dgmlAttr_color).trimmed() );
if ( !color.isValid() )
color = Qt::transparent;
QColor color;
if (pixmapRelativePath.isEmpty()) {
color.setNamedColor(parser.attribute(dgmlAttr_color).trimmed());
}
GeoSceneIcon *icon = 0;
......
......@@ -33,7 +33,7 @@ bool DgmlItemTagWriter::write(const GeoNode *node, GeoWriter& writer) const
writer.writeStartElement( dgml::dgmlTag_Icon );
if( !item->icon()->pixmap().isEmpty() ) {
writer.writeAttribute( "pixmap", item->icon()->pixmap() );
} else if( !item->icon()->color().name().isEmpty() ) {
} else if (item->icon()->color().isValid()) {
writer.writeAttribute( "color", item->icon()->color().name() );
}
writer.writeEndElement();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment