From 70ddd831541bd03853625c98b71e3a3fc81c59eb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20T=C5=AFma?= Date: Thu, 7 Nov 2024 18:40:25 +0100 Subject: [PATCH] Code cleanup --- src/map/mapsforge/style.cpp | 20 +++++--------------- src/map/mapsforge/style.h | 6 ++++++ 2 files changed, 11 insertions(+), 15 deletions(-) diff --git a/src/map/mapsforge/style.cpp b/src/map/mapsforge/style.cpp index f0c62b67..178d172f 100644 --- a/src/map/mapsforge/style.cpp +++ b/src/map/mapsforge/style.cpp @@ -77,16 +77,6 @@ static QList valList(const QList &in) return out; } -static bool symbolCmp(const Style::Symbol &a, const Style::Symbol &b) -{ - return a.priority() > b.priority(); -} - -static bool labelCmp(const Style::TextRender &a, const Style::TextRender &b) -{ - return a.priority() > b.priority(); -} - const Style::Menu::Layer *Style::Menu::findLayer(const QString &id) const { for (int i = 0; i < _layers.size(); i++) @@ -770,11 +760,11 @@ void Style::load(const MapData &data, qreal ratio) if (!QFileInfo::exists(path) || !loadXml(path, data, ratio)) loadXml(":/mapsforge/default.xml", data, ratio); - std::sort(_symbols.begin(), _symbols.end(), symbolCmp); - std::sort(_lineSymbols.begin(), _lineSymbols.end(), symbolCmp); - std::stable_sort(_pointLabels.begin(), _pointLabels.end(), labelCmp); - std::stable_sort(_areaLabels.begin(), _areaLabels.end(), labelCmp); - std::stable_sort(_pathLabels.begin(), _pathLabels.end(), labelCmp); + std::sort(_symbols.begin(), _symbols.end()); + std::sort(_lineSymbols.begin(), _lineSymbols.end()); + std::stable_sort(_pointLabels.begin(), _pointLabels.end()); + std::stable_sort(_areaLabels.begin(), _areaLabels.end()); + std::stable_sort(_pathLabels.begin(), _pathLabels.end()); } void Style::clear() diff --git a/src/map/mapsforge/style.h b/src/map/mapsforge/style.h index 84ecc93c..bde3a7db 100644 --- a/src/map/mapsforge/style.h +++ b/src/map/mapsforge/style.h @@ -217,6 +217,9 @@ public: unsigned key() const {return _key;} int priority() const {return _priority;} + bool operator<(const TextRender &other) const + {return _priority > other._priority;} + private: friend class Style; @@ -239,6 +242,9 @@ public: bool rotate() const {return _rotate;} int priority() const {return _priority;} + bool operator<(const Symbol &other) const + {return _priority > other._priority;} + private: friend class Style;