Skip to content

Commit

Permalink
manage issue const copy const with qt6 container
Browse files Browse the repository at this point in the history
  • Loading branch information
janbar committed Sep 27, 2024
1 parent 6c379e7 commit ea745a0
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 12 deletions.
2 changes: 1 addition & 1 deletion simulator/gpxrunner.h
Original file line number Diff line number Diff line change
Expand Up @@ -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); }

Expand Down
2 changes: 1 addition & 1 deletion simulator/simulator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
8 changes: 4 additions & 4 deletions src/gpxfilemodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,22 +59,22 @@ QString GPXFile::description() const
return QString::fromUtf8(m_gpx.desc.value_or("").c_str());
}

QList<GPXObjectTrack> GPXFile::tracks() const
QList<GPXObjectTrack> GPXFile::tracks()
{
int i = 0;
QList<GPXObjectTrack> 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<GPXObjectWayPoint> GPXFile::waypoints() const
QList<GPXObjectWayPoint> GPXFile::waypoints()
{
int i = 0;
QList<GPXObjectWayPoint> list;
for (const osmscout::gpx::Waypoint& waypoint : m_gpx.waypoints)
for (osmscout::gpx::Waypoint& waypoint : m_gpx.waypoints)
{
list << GPXObjectWayPoint(waypoint, ++i);
}
Expand Down
14 changes: 8 additions & 6 deletions src/gpxfilemodel.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ class GPXFile

QString name() const;
QString description() const;
QList<GPXObjectTrack> tracks() const;
QList<GPXObjectWayPoint> waypoints() const;
QList<GPXObjectTrack> tracks();
QList<GPXObjectWayPoint> waypoints();

private:
bool m_valid;
Expand Down Expand Up @@ -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()); }
Expand All @@ -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()); }
Expand All @@ -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;
};

Expand Down

0 comments on commit ea745a0

Please sign in to comment.