From 26d2bc4f5d8937353c75aa1ba8e5507d846b5399 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20T=C5=AFma?= Date: Fri, 7 Oct 2022 21:54:39 +0200 Subject: [PATCH] Preserve the configured path line style when no style is provided in the data --- src/GUI/pathitem.cpp | 3 ++- src/data/geojsonparser.cpp | 2 +- src/data/kmlparser.cpp | 4 ++-- src/data/style.h | 9 ++++++--- 4 files changed, 11 insertions(+), 7 deletions(-) diff --git a/src/GUI/pathitem.cpp b/src/GUI/pathitem.cpp index 3ef21de3..c8e1da36 100644 --- a/src/GUI/pathitem.cpp +++ b/src/GUI/pathitem.cpp @@ -200,7 +200,8 @@ void PathItem::updateWidth() Qt::PenStyle PathItem::penStyle() const { - return _useStyle ? Qt::SolidLine : _penStyle; + return (_useStyle && _path.style().style() != Qt::NoPen) + ? _path.style().style() : _penStyle; } void PathItem::setPenStyle(Qt::PenStyle style) diff --git a/src/data/geojsonparser.cpp b/src/data/geojsonparser.cpp index d1ad1e85..9fde2172 100644 --- a/src/data/geojsonparser.cpp +++ b/src/data/geojsonparser.cpp @@ -74,7 +74,7 @@ static void setTrackProperties(TrackData &track, const QJsonValue &properties) width = o["stroke-width"].toDouble(); } - track.setStyle(LineStyle(color, width)); + track.setStyle(LineStyle(color, width, Qt::SolidLine)); } static void setWaypointProperties(Waypoint &waypoint, diff --git a/src/data/kmlparser.cpp b/src/data/kmlparser.cpp index 97b3173e..c8a40d16 100644 --- a/src/data/kmlparser.cpp +++ b/src/data/kmlparser.cpp @@ -691,7 +691,7 @@ void KMLParser::placemark(const Ctx &ctx, QList &tracks, t.setName(name); t.setDescription(desc); t.setStyle(lit == lineStyles.end() - ? LineStyle(QColor(0x55, 0x55, 0x55), 2) : *lit); + ? LineStyle(QColor(0x55, 0x55, 0x55), 2, Qt::SolidLine) : *lit); } for (int i = areaIdx; i < areas.size(); i++) { Area &a = areas[i]; @@ -790,7 +790,7 @@ void KMLParser::lineStyle(const QString &id, LineStyleMap &styles) _reader.skipCurrentElement(); } - styles.insert(id, LineStyle(c, width)); + styles.insert(id, LineStyle(c, width, Qt::SolidLine)); } void KMLParser::styleMapPair(const QString &id, QMap &map) diff --git a/src/data/style.h b/src/data/style.h index 5b26f4e0..776c9278 100644 --- a/src/data/style.h +++ b/src/data/style.h @@ -44,16 +44,19 @@ private: class LineStyle { public: - LineStyle() : _width(-1) {} - LineStyle(const QColor &color, qreal width = -1) - : _color(color), _width(width) {} + LineStyle() : _width(-1), _style(Qt::NoPen) {} + LineStyle(const QColor &color, qreal width = -1, + Qt::PenStyle style = Qt::NoPen) + : _color(color), _width(width), _style(style) {} const QColor &color() const {return _color;} qreal width() const {return _width;} + Qt::PenStyle style() const {return _style;} private: QColor _color; qreal _width; + Qt::PenStyle _style; }; #endif // STYLE_H