Fix : Filling color is not apply to polyline.

This commit is contained in:
Claveau Joshua
2020-10-18 10:45:05 +02:00
parent a65675b53e
commit ec0b92ec1d
5 changed files with 34 additions and 23 deletions

View File

@@ -523,11 +523,16 @@ void CustomElementGraphicPart::stylesFromXml(const QDomElement &qde)
//Check each pair of style //Check each pair of style
QRegularExpression rx("^\\s*([a-z-]+)\\s*:\\s*([a-zA-Z-]+)\\s*$"); QRegularExpression rx("^\\s*([a-z-]+)\\s*:\\s*([a-zA-Z-]+)\\s*$");
foreach (QString style, styles) for (auto style : styles)
{ {
if (rx!=QRegularExpression(style)) continue; auto rx_match = rx.match(style);
QString style_name = rx.namedCaptureGroups().at(1); if (!rx_match.hasMatch()) {
QString style_value = rx.namedCaptureGroups().at(2); continue;
}
auto style_name = rx_match.captured(1);
auto style_value = rx_match.captured(2);
if (style_name == "line-style") if (style_name == "line-style")
{ {
if (style_value == "dashed") _linestyle = DashedStyle; if (style_value == "dashed") _linestyle = DashedStyle;

View File

@@ -61,7 +61,7 @@ PartPolygon::~PartPolygon()
*/ */
void PartPolygon::paint(QPainter *painter, const QStyleOptionGraphicsItem *options, QWidget *widget) void PartPolygon::paint(QPainter *painter, const QStyleOptionGraphicsItem *options, QWidget *widget)
{ {
Q_UNUSED(widget); Q_UNUSED(widget)
applyStylesToQPainter(*painter); applyStylesToQPainter(*painter);

View File

@@ -448,11 +448,15 @@ void StyleEditor::updateForm()
if (part) if (part)
{ {
antialiasing -> setChecked(part -> antialiased()); antialiasing ->setChecked(part -> antialiased());
outline_color -> setCurrentIndex(part -> color()); outline_color ->removeItem(13); //Remove the separator for set the good index at the line below
line_style -> setCurrentIndex(part -> lineStyle()); outline_color ->setCurrentIndex(part->color());
size_weight -> setCurrentIndex(part -> lineWeight()); outline_color ->insertSeparator(13);
filling_color -> setCurrentIndex(part -> filling()); line_style ->setCurrentIndex(part -> lineStyle());
size_weight ->setCurrentIndex(part -> lineWeight());
filling_color ->removeItem(13); //Remove the separator for set the good index at the line below
filling_color ->setCurrentIndex(part -> filling());
filling_color ->insertSeparator(13);
} }
else if (m_part_list.size()) else if (m_part_list.size())
{ {
@@ -463,7 +467,7 @@ void StyleEditor::updateForm()
size_weight -> setCurrentIndex(first_part -> lineWeight()); size_weight -> setCurrentIndex(first_part -> lineWeight());
filling_color -> setCurrentIndex(first_part -> filling()); filling_color -> setCurrentIndex(first_part -> filling());
foreach (CustomElementGraphicPart *cegp, m_part_list) for (auto cegp : m_part_list)
{ {
if (first_part -> antialiased() != cegp -> antialiased()) antialiasing -> setChecked(false); if (first_part -> antialiased() != cegp -> antialiased()) antialiasing -> setChecked(false);
if (first_part -> color() != cegp -> color()) outline_color -> setCurrentIndex(-1); if (first_part -> color() != cegp -> color()) outline_color -> setCurrentIndex(-1);

View File

@@ -90,23 +90,25 @@ bool PolygonEditor::setPart(CustomElementPart *new_part)
{ {
if (!new_part) if (!new_part)
{ {
if (m_part) if (m_part) {
{
disconnectChangeConnections(); disconnectChangeConnections();
m_style->setPart(nullptr);
} }
m_part = nullptr; m_part = nullptr;
return(true); return(true);
} }
if (PartPolygon *part_polygon = dynamic_cast<PartPolygon *>(new_part)) if (PartPolygon *part_polygon = dynamic_cast<PartPolygon *>(new_part))
{ {
if (m_part == part_polygon) return true; if (m_part == part_polygon) {
if (m_part) return true;
{ }
if (m_part) {
disconnectChangeConnections(); disconnectChangeConnections();
} }
m_part = part_polygon; m_part = part_polygon;
updateForm(); updateForm();
setUpChangeConnections(); setUpChangeConnections();
m_style->setPart(m_part);
return(true); return(true);
} }
return(false); return(false);

View File

@@ -488,7 +488,7 @@ void ElementPictureFactory::parsePolygon(const QDomElement &dom, QPainter &paint
void ElementPictureFactory::parseText(const QDomElement &dom, QPainter &painter, ElementPictureFactory::primitives &prim) const void ElementPictureFactory::parseText(const QDomElement &dom, QPainter &painter, ElementPictureFactory::primitives &prim) const
{ {
Q_UNUSED(prim); Q_UNUSED(prim)
if (dom.tagName() != "text") { if (dom.tagName() != "text") {
return; return;
@@ -571,7 +571,8 @@ void ElementPictureFactory::setPainterStyle(const QDomElement &dom, QPainter &pa
#endif #endif
const QStringList styles = dom.attribute("style").split(";", Qt::SkipEmptyParts); const QStringList styles = dom.attribute("style").split(";", Qt::SkipEmptyParts);
#endif #endif
QRegularExpression rx("^(?<name>[a-z-]+):(?<value>[a-z-]+)$");
QRegularExpression rx("^(?<name>[a-z-]+):(?<value>[a-zA-Z-]+)$");
if (!rx.isValid()) if (!rx.isValid())
{ {
qWarning() <<QObject::tr("this is an error in the code") qWarning() <<QObject::tr("this is an error in the code")
@@ -579,12 +580,11 @@ void ElementPictureFactory::setPainterStyle(const QDomElement &dom, QPainter &pa
<< rx.patternErrorOffset(); << rx.patternErrorOffset();
return; return;
} }
for (QString style : styles) { for (auto style : styles)
{
QRegularExpressionMatch match = rx.match(style); QRegularExpressionMatch match = rx.match(style);
if (!match.hasMatch()) if (!match.hasMatch()) {
{ qDebug() << "no Match" << style;
qDebug()<<"no Match"
<<style;
}else { }else {
QString style_name = match.captured("name"); QString style_name = match.captured("name");
QString style_value = match.captured("value"); QString style_value = match.captured("value");