From e76439bb6e12b0375c18bf7df9e225775ae8f0a8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20T=C5=AFma?= Date: Sat, 14 Oct 2017 22:57:03 +0200 Subject: [PATCH] Added support for TCX multi-sport activities --- src/tcxparser.cpp | 25 ++++++++++++++++++++++++- src/tcxparser.h | 2 ++ 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/src/tcxparser.cpp b/src/tcxparser.cpp index c9abfb1b..10116d34 100644 --- a/src/tcxparser.cpp +++ b/src/tcxparser.cpp @@ -183,7 +183,7 @@ void TCXParser::courses(QList &tracks, QList &waypoints) } } -void TCXParser::activities(QList &tracks) +void TCXParser::sport(QList &tracks) { while (_reader.readNextStartElement()) { if (_reader.name() == "Activity") { @@ -194,6 +194,29 @@ void TCXParser::activities(QList &tracks) } } +void TCXParser::multiSportSession(QList &tracks) +{ + while (_reader.readNextStartElement()) { + if (_reader.name() == "FirstSport" || _reader.name() == "NextSport") + sport(tracks); + else + _reader.skipCurrentElement(); + } +} + +void TCXParser::activities(QList &tracks) +{ + while (_reader.readNextStartElement()) { + if (_reader.name() == "Activity") { + tracks.append(TrackData()); + activity(tracks.back()); + } else if (_reader.name() == "MultiSportSession") + multiSportSession(tracks); + else + _reader.skipCurrentElement(); + } +} + void TCXParser::tcx(QList &tracks, QList &waypoints) { while (_reader.readNextStartElement()) { diff --git a/src/tcxparser.h b/src/tcxparser.h index b1490c65..e5b82d4c 100644 --- a/src/tcxparser.h +++ b/src/tcxparser.h @@ -19,6 +19,8 @@ private: void tcx(QList &tracks, QList &waypoints); void courses(QList &tracks, QList &waypoints); void activities(QList &tracks); + void multiSportSession(QList &tracks); + void sport(QList &tracks); void course(QList &waypoints, TrackData &track); void activity(TrackData &track); void lap(TrackData &track);