1 /********************************************************************************************** 2 Copyright (C) 2015 Christian Eichler <code@christian-eichler.de> 3 4 This program is free software: you can redistribute it and/or modify 5 it under the terms of the GNU General Public License as published by 6 the Free Software Foundation, either version 3 of the License, or 7 (at your option) any later version. 8 9 This program is distributed in the hope that it will be useful, 10 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 GNU General Public License for more details. 13 14 You should have received a copy of the GNU General Public License 15 along with this program. If not, see <http://www.gnu.org/licenses/>. 16 17 **********************************************************************************************/ 18 19 #ifndef CSLFREADER_H 20 #define CSLFREADER_H 21 22 #include <QDateTime> 23 #include <QDomNode> 24 #include <QString> 25 26 #include "gis/prj/IGisProject.h" 27 28 class CSlfProject; 29 30 class CSlfReader 31 { 32 Q_DECLARE_TR_FUNCTIONS(CSlfReader) 33 public: 34 static void readFile(const QString& file, CSlfProject* proj); 35 36 private: 37 CSlfReader(const QString& filename, CSlfProject* proj); 38 39 void readMarkers(const QDomNode& xml); 40 void readEntries(const QDomNode& xml); 41 void readMetadata(const QDomNode& xml, IGisProject::metadata_t& metadata); 42 43 /** 44 @brief Search for attributes that are not 0-only. 45 46 Sigma Data Center even stores non-used values (as 0) within the .slf file. 47 As we do not want to include those 0-only values as extensions, we need to 48 search for used attributes first. 49 50 @param xmlEntrs List of nodes 51 @return Set of used attributes 52 */ 53 QSet<QString> findUsedAttributes(const QDomNodeList& xmlEntrs); 54 55 static QDateTime parseTimestamp(const QString& ts); 56 57 CSlfProject* proj = nullptr; //< the resulting project after construction 58 QDateTime baseTime; //< the time all entries refer to 59 QList<long> offsetsTime; //< an additional offset, required to take breaks into account 60 QList<long> laps; //< the distances a new lap starts at (a lap is a .slf segment) 61 62 static const QHash<QString, QString> attrToExt; 63 }; 64 65 #endif // CSLFREADER_H 66 67