From 75c1bb865d82e84ae2be5e99562627f66ec788a1 Mon Sep 17 00:00:00 2001 From: janbar Date: Fri, 27 Sep 2024 20:48:52 +0200 Subject: [PATCH] prevent issue const copy const with future qt6 container --- simulator/gpxrunner.h | 2 +- simulator/simulator.cpp | 2 +- src/gpxfilemodel.cpp | 8 ++++---- src/gpxfilemodel.h | 14 ++++++++------ 4 files changed, 14 insertions(+), 12 deletions(-) diff --git a/simulator/gpxrunner.h b/simulator/gpxrunner.h index a3126db2..8dadc211 100644 --- a/simulator/gpxrunner.h +++ b/simulator/gpxrunner.h @@ -31,7 +31,7 @@ class GPXRunner : public QThread ~GPXRunner(); bool loadGPX(const QString& fileptah); - const GPXFile * file() { return _gpxfile; } + GPXFile * file() { return _gpxfile; } bool configureRun(int trackid, int tick, double speed, int startpts); bool isRunAborted() { return (_running ? _running->aborted : false); } diff --git a/simulator/simulator.cpp b/simulator/simulator.cpp index abee530e..983a9f13 100644 --- a/simulator/simulator.cpp +++ b/simulator/simulator.cpp @@ -244,7 +244,7 @@ void Simulator::onQuit() void Simulator::onListGPXRequested() { - const GPXFile * f = _gpxrunner.file(); + GPXFile * f = _gpxrunner.file(); if (f == nullptr) return; fprintf(stdout, "Path: %s\nName: %s\n", diff --git a/src/gpxfilemodel.cpp b/src/gpxfilemodel.cpp index dbce09c1..d7c530b1 100644 --- a/src/gpxfilemodel.cpp +++ b/src/gpxfilemodel.cpp @@ -59,22 +59,22 @@ QString GPXFile::description() const return QString::fromUtf8(m_gpx.desc.value_or("").c_str()); } -QList GPXFile::tracks() const +QList GPXFile::tracks() { int i = 0; QList list; - for (const osmscout::gpx::Track& track : m_gpx.tracks) + for (osmscout::gpx::Track& track : m_gpx.tracks) { list << GPXObjectTrack(track, ++i); } return list; } -QList GPXFile::waypoints() const +QList GPXFile::waypoints() { int i = 0; QList list; - for (const osmscout::gpx::Waypoint& waypoint : m_gpx.waypoints) + for (osmscout::gpx::Waypoint& waypoint : m_gpx.waypoints) { list << GPXObjectWayPoint(waypoint, ++i); } diff --git a/src/gpxfilemodel.h b/src/gpxfilemodel.h index 3811b694..142af225 100644 --- a/src/gpxfilemodel.h +++ b/src/gpxfilemodel.h @@ -32,8 +32,8 @@ class GPXFile QString name() const; QString description() const; - QList tracks() const; - QList waypoints() const; + QList tracks(); + QList waypoints(); private: bool m_valid; @@ -63,8 +63,9 @@ class GPXObject : public QObject class GPXObjectTrack : public GPXObject { public: - GPXObjectTrack(const osmscout::gpx::Track& track, int id) : m_track(track), m_id(id) { } + GPXObjectTrack(osmscout::gpx::Track& track, int id) : m_track(track), m_id(id) { } explicit GPXObjectTrack(const GPXObjectTrack& other) : m_track(other.m_track), m_id(other.m_id) { } + GPXObjectTrack& operator=(const GPXObjectTrack& other) { m_track = other.m_track; m_id = other.m_id; return *this; } int id() const override { return m_id; } ObjectType type() const override { return Track; } QString name() const override { return QString::fromUtf8(m_track.name.value_or(std::to_string(m_id)).c_str()); } @@ -74,15 +75,16 @@ class GPXObjectTrack : public GPXObject const osmscout::gpx::Track& data() const { return m_track; }; private: - const osmscout::gpx::Track& m_track; + osmscout::gpx::Track& m_track; int m_id; }; class GPXObjectWayPoint : public GPXObject { public: - GPXObjectWayPoint(const osmscout::gpx::Waypoint& waipoint, int id) : m_waypoint(waipoint), m_id(id) { } + GPXObjectWayPoint(osmscout::gpx::Waypoint& waipoint, int id) : m_waypoint(waipoint), m_id(id) { } explicit GPXObjectWayPoint(const GPXObjectWayPoint& other) : m_waypoint(other.m_waypoint), m_id(other.m_id) { } + GPXObjectWayPoint& operator=(const GPXObjectWayPoint& other) { m_waypoint = other.m_waypoint; m_id = other.m_id; return *this; } int id() const override { return m_id; } ObjectType type() const override { return WayPoint; } QString name() const override { return QString::fromUtf8(m_waypoint.name.value_or(std::to_string(m_id)).c_str()); } @@ -94,7 +96,7 @@ class GPXObjectWayPoint : public GPXObject const osmscout::gpx::Waypoint& data() const { return m_waypoint; }; private: - const osmscout::gpx::Waypoint& m_waypoint; + osmscout::gpx::Waypoint& m_waypoint; int m_id; };