commit 4b0fd01beae8abe6510254f88d223afe50bca9a3 Author: birkeh Date: Thu Apr 28 10:06:43 2011 +0200 Initial release diff --git a/cactivity.cpp b/cactivity.cpp new file mode 100644 index 0000000..34b59ea --- /dev/null +++ b/cactivity.cpp @@ -0,0 +1,90 @@ +#include "cactivity.h" +#include + + +cActivity::cActivity() +{ + m_dwValid = 0; +} + +cActivity::cActivity(const cActivity& rhs) +{ + this->m_dwValid = rhs.m_dwValid; + this->m_iActivityType = rhs.m_iActivityType; + this->m_LapList = rhs.m_LapList; + this->m_szName = rhs.m_szName; +} + +cActivity::cActivity(enum ActivityType iActivityType, const QString& szName) +{ + m_dwValid = 0; + setActivityType(iActivityType); + setName(szName); +} + +bool cActivity::setActivityType(enum ActivityType iActivityType) +{ + if(iActivityType < ActivityTypeUnknown || iActivityType > ActivityTypeNone) + return(false); + m_iActivityType = iActivityType; + m_dwValid |= VALID_ACTIVITYTYPE; + return(true); +} + +enum cActivity::ActivityType cActivity::getActivityType() +{ + if(m_dwValid & VALID_ACTIVITYTYPE) + return(m_iActivityType); + else + return(ActivityTypeUnknown); +} + +bool cActivity::setName(const QString& szName) +{ + if(!szName.length()) + return(false); + + m_szName = szName; + m_dwValid |= VALID_NAME; + return(true); +} + +QString cActivity::getName() +{ + if(m_dwValid & VALID_NAME) + return(m_szName); + return(""); +} + +cLap* cActivity::addLap(const QDateTime& StartTime) +{ + return(m_LapList.add(this, StartTime)); +} + +cLapList cActivity::getLapList() +{ + return(m_LapList); +} + +cActivity& cActivity::operator=(const cActivity& rhs) +{ + if(this != &rhs) + { + this->m_dwValid = rhs.m_dwValid; + this->m_iActivityType = rhs.m_iActivityType; + this->m_LapList = rhs.m_LapList; + this->m_szName = rhs.m_szName; + } + return(*this); +} + +cActivityList::cActivityList() +{ +} + +cActivity* cActivityList::add(enum cActivity::ActivityType iActivityType, const QString& szName) +{ + cActivity* lpActivity = new cActivity(iActivityType, szName); + this->append(lpActivity); + return(lpActivity); +} diff --git a/cactivity.h b/cactivity.h new file mode 100644 index 0000000..04dea1c --- /dev/null +++ b/cactivity.h @@ -0,0 +1,56 @@ +#ifndef CACTIVITY_H +#define CACTIVITY_H + + +#include +#include +#include + +#include "common.h" +#include "clap.h" + + +class cActivity +{ +public: + enum ActivityType + { + ActivityTypeUnknown, + ActivityTypeRunning, + ActivityTypeBiking, + ActivityTypeSwimming, + ActivityTypeNone, + }; + + cActivity(); + cActivity(const cActivity& rhs); + cActivity(enum ActivityType iActivityType, const QString& szName); + + bool setActivityType(enum ActivityType iActivityType); + enum ActivityType getActivityType(); + + bool setName(const QString& szName); + QString getName(); + + cLap* addLap(const QDateTime& StartTime); + cLapList getLapList(); + + cActivity& operator=(const cActivity& rhs); +protected: + uint64_t m_dwValid; + enum ActivityType m_iActivityType; + QString m_szName; + + cLapList m_LapList; +}; + +Q_DECLARE_METATYPE(cActivity); + +class cActivityList : public QList +{ +public: + cActivityList(); + cActivity* add(enum cActivity::ActivityType iActivityType, const QString& szName); +}; + +#endif // CACTIVITY_H diff --git a/cimport.h b/cimport.h new file mode 100644 index 0000000..7846f9d --- /dev/null +++ b/cimport.h @@ -0,0 +1,44 @@ +#ifndef CIMPORT_H +#define CIMPORT_H + + +#include +#include +#include +#include +#include + +#include "cactivity.h" +#include "clap.h" +#include "ctrackpoint.h" + + +class cImport +{ +public: + enum IMPORT_ERROR + { + NO_ERROR = 0, + FILE_NOT_EXIST = 1, + FILE_NOT_SUPPORTED = 2, + FILE_NOT_READABLE = 3, + FILE_WRONG_FORMAT = 4, + }; + + cImport(); + + virtual QString getName(); + virtual QString getVersion(); + virtual QString getExtension(); + virtual cActivityList getActivityList(); + + virtual int32_t load(const QString& szFileName); + +protected: + cActivityList m_ActivityList; +}; + +typedef cImport* create_t(); +typedef void destroy_t(cImport* lpImport); + +#endif // CIMPORT_H diff --git a/clap.cpp b/clap.cpp new file mode 100644 index 0000000..62c3423 --- /dev/null +++ b/clap.cpp @@ -0,0 +1,172 @@ +#include "clap.h" +#include + + +cLap::cLap(cActivity* lpParent) +{ + m_dwValid = 0; + m_lpParent = lpParent; +} + +cLap::cLap(cActivity* lpParent, const QDateTime &StartTime) +{ + m_dwValid = 0; + m_lpParent = lpParent; + setStartTime(StartTime); +} + +cActivity* cLap::getParent() +{ + return(m_lpParent); +} + +bool cLap::setStartTime(const QDateTime &StartTime) +{ + if(!StartTime.isValid()) + return(false); + + m_StartTime = StartTime; + m_dwValid |= VALID_STARTTIME; + return(true); +} + +QDateTime cLap::getStartTime() +{ + if(m_dwValid & VALID_STARTTIME) + return(m_StartTime); + return(QDateTime(QDate(1980, 1, 1), QTime(0, 0))); +} + +bool cLap::setTotalTime(double dTotalTime) +{ + m_dTotalTime = dTotalTime; + m_dwValid |= VALID_TOTALTIME; + return(true); +} + +double cLap::getTotalTime() +{ + if(m_dwValid & VALID_TOTALTIME) + return(m_dTotalTime); + return(0); +} + +bool cLap::setTotalDistance(double dTotalDistance) +{ + m_dTotalDistance = dTotalDistance; + m_dwValid |= VALID_TOTALDISTANCE; + return(true); +} + +double cLap::getTotalDistance() +{ + if(m_dwValid & VALID_TOTALDISTANCE) + return(m_dTotalDistance); + return(0); +} + +bool cLap::setMaximumSpeed(double dMaximumSpeed) +{ + m_dMaximumSpeed = dMaximumSpeed; + m_dwValid |= VALID_MAXIMUMSPEED; + return(true); +} + +double cLap::getMaximumSpeed() +{ + if(m_dwValid & VALID_MAXIMUMSPEED) + return(m_dMaximumSpeed); + return(0); +} + +bool cLap::setCalories(double dCalories) +{ + m_dCalories = dCalories; + m_dwValid |= VALID_CALORIES; + return(true); +} + +double cLap::getCalories() +{ + if(m_dwValid & VALID_CALORIES) + return(m_dCalories); + return(0); +} + +bool cLap::setAvgHeartrate(double dAvgHeartrate) +{ + m_dAvgHeartrate = dAvgHeartrate; + m_dwValid |= VALID_AVGHEARTRATE; + return(true); +} + +double cLap::getAvgHeartrate() +{ + if(m_dwValid & VALID_AVGHEARTRATE) + return(m_dAvgHeartrate); + return(0); +} + +bool cLap::setMaxHeartrate(double dMaxHeartrate) +{ + m_dMaxHeartrate = dMaxHeartrate; + m_dwValid |= VALID_MAXHEARTRATE; + return(true); +} + +double cLap::getMaxHeartrate() +{ + if(m_dwValid & VALID_MAXHEARTRATE) + return(m_dMaxHeartrate); + return(0); +} + +bool cLap::setIntensity(enum Intensity iIntensity) +{ + if(iIntensity < IntensityUnknown || iIntensity > IntensityNone) + return(false); + m_iIntensity = iIntensity; + m_dwValid |= VALID_INTENSITY; + return(true); +} + +enum cLap::Intensity cLap::getIntensity() +{ + if(m_dwValid & VALID_INTENSITY) + return(m_iIntensity); + else + return(cLap::IntensityNone); +} + +bool cLap::setTriggerMethod(enum TriggerMethod iTriggerMethod) +{ + if(iTriggerMethod < TriggerMethodUnknown || iTriggerMethod > TriggerMethodNone) + return(false); + m_iTriggerMethod = iTriggerMethod; + m_dwValid |= VALID_TRIGGERMETHOD; + return(true); +} + +enum cLap::TriggerMethod cLap::getTriggerMethod() +{ + if(m_dwValid & VALID_TRIGGERMETHOD) + return(m_iTriggerMethod); + else + return(cLap::TriggerMethodNone); +} + +cTrackpoint* cLap::addTrackpoint(uint32_t dwTime) +{ + return(m_TrackpointList.add(this, dwTime)); +} + +cLapList::cLapList() +{ +} + +cLap* cLapList::add(cActivity* lpParent, const QDateTime &StartTime) +{ + cLap* lpLap = new cLap(lpParent, StartTime); + this->append(lpLap); + return(lpLap); +} diff --git a/clap.h b/clap.h new file mode 100644 index 0000000..d6253b2 --- /dev/null +++ b/clap.h @@ -0,0 +1,92 @@ +#ifndef CLAP_H +#define CLAP_H + + +#include +#include +#include +#include + +#include "common.h" + +#include "ctrackpoint.h" + + +class cActivity; + +class cLap +{ +public: + enum Intensity + { + IntensityUnknown, + IntensityActive, + IntensityNone, + }; + + enum TriggerMethod + { + TriggerMethodUnknown, + TriggerMethodManual, + TriggerMethodAuto, + TriggerMethodNone, + }; + + cLap(cActivity* lpParent = 0); + cLap(cActivity* lpParent, const QDateTime& StartTime); + + cActivity* getParent(); + + bool setStartTime(const QDateTime& StartTime); + QDateTime getStartTime(); + + bool setTotalTime(double dTotalTime); + double getTotalTime(); + + bool setTotalDistance(double dTotalDistance); + double getTotalDistance(); + + bool setMaximumSpeed(double dMaximumSpeed); + double getMaximumSpeed(); + + bool setCalories(double dCalories); + double getCalories(); + + bool setAvgHeartrate(double dAvgHeartrate); + double getAvgHeartrate(); + + bool setMaxHeartrate(double dMaxHeartrate); + double getMaxHeartrate(); + + bool setIntensity(enum Intensity iIntensity); + enum Intensity getIntensity(); + + bool setTriggerMethod(enum TriggerMethod iTriggerMethod); + enum TriggerMethod getTriggerMethod(); + + cTrackpoint* addTrackpoint(uint32_t dwTime); +protected: + uint64_t m_dwValid; + cActivity* m_lpParent; + QDateTime m_StartTime; + double m_dTotalTime; + double m_dTotalDistance; + double m_dMaximumSpeed; + double m_dCalories; + double m_dAvgHeartrate; + double m_dMaxHeartrate; + enum Intensity m_iIntensity; + enum TriggerMethod m_iTriggerMethod; + cTrackpointList m_TrackpointList; +}; + +Q_DECLARE_METATYPE(cLap); + +class cLapList : public QList +{ +public: + cLapList(); + cLap* add(cActivity* lpParent, const QDateTime& StartTime); +}; + +#endif // CLAP_H diff --git a/cmainwindow.cpp b/cmainwindow.cpp new file mode 100644 index 0000000..9a9a230 --- /dev/null +++ b/cmainwindow.cpp @@ -0,0 +1,15 @@ +#include "cmainwindow.h" +#include "ui_cmainwindow.h" + + +cMainWindow::cMainWindow(QWidget *parent) : + QMainWindow(parent), + ui(new Ui::cMainWindow) +{ + ui->setupUi(this); +} + +cMainWindow::~cMainWindow() +{ + delete ui; +} diff --git a/cmainwindow.h b/cmainwindow.h new file mode 100644 index 0000000..5d82d32 --- /dev/null +++ b/cmainwindow.h @@ -0,0 +1,22 @@ +#ifndef CMAINWINDOW_H +#define CMAINWINDOW_H + +#include + +namespace Ui { + class cMainWindow; +} + +class cMainWindow : public QMainWindow +{ + Q_OBJECT + +public: + explicit cMainWindow(QWidget *parent = 0); + ~cMainWindow(); + +private: + Ui::cMainWindow *ui; +}; + +#endif // CMAINWINDOW_H diff --git a/cmainwindow.ui b/cmainwindow.ui new file mode 100644 index 0000000..2f025dc --- /dev/null +++ b/cmainwindow.ui @@ -0,0 +1,24 @@ + + cMainWindow + + + + 0 + 0 + 400 + 300 + + + + cMainWindow + + + + + + + + + + + diff --git a/common.h b/common.h new file mode 100644 index 0000000..6a6c422 --- /dev/null +++ b/common.h @@ -0,0 +1,22 @@ +#ifndef COMMON_H +#define COMMON_H + + +#define VALID_NAME 0x00000000000000000000000000000001LL +#define VALID_STARTTIME 0x00000000000000000000000000000002LL +#define VALID_TOTALTIME 0x00000000000000000000000000000004LL +#define VALID_TOTALDISTANCE 0x00000000000000000000000000000008LL +#define VALID_MAXIMUMSPEED 0x00000000000000000000000000000010LL +#define VALID_CALORIES 0x00000000000000000000000000000020LL +#define VALID_AVGHEARTRATE 0x00000000000000000000000000000040LL +#define VALID_MAXHEARTRATE 0x00000000000000000000000000000080LL +#define VALID_ACTIVITYTYPE 0x00000000000000000000000000000100LL +#define VALID_INTENSITY 0x00000000000000000000000000000200LL +#define VALID_TRIGGERMETHOD 0x00000000000000000000000000000400LL +#define VALID_TIME 0x00000000000000000000000000000800LL +#define VALID_POSITION 0x00000000000000000000000000001000LL +#define VALID_DISTANCE 0x00000000000000000000000000002000LL +#define VALID_HEARTRATE 0x00000000000000000000000000004000LL + + +#endif // COMMON_H diff --git a/cposition.cpp b/cposition.cpp new file mode 100644 index 0000000..067aea5 --- /dev/null +++ b/cposition.cpp @@ -0,0 +1,42 @@ +#include "cposition.h" + + +cPosition::cPosition(const cPosition& rhs) +{ + this->m_dLatitude = rhs.m_dLatitude; + this->m_dLongitude = rhs.m_dLongitude; + this->m_dElevation = rhs.m_dElevation; +} + +cPosition::cPosition(double dLatitude, double dLongitude, double dElevation) +{ + m_dLatitude = dLatitude; + m_dLongitude = dLongitude; + m_dElevation = dElevation; +} + +double cPosition::getLatitude() +{ + return(m_dLatitude); +} + +double cPosition::getLongitude() +{ + return(m_dLongitude); +} + +double cPosition::getElevation() +{ + return(m_dElevation); +} + +cPosition &cPosition::operator=(const cPosition &rhs) +{ + if(this != &rhs) + { + this->m_dLatitude = rhs.m_dLatitude; + this->m_dLongitude = rhs.m_dLongitude; + this->m_dElevation = rhs.m_dElevation; + } + return(*this); +} diff --git a/cposition.h b/cposition.h new file mode 100644 index 0000000..4eebd23 --- /dev/null +++ b/cposition.h @@ -0,0 +1,20 @@ +#ifndef CPOSITION_H +#define CPOSITION_H + + +class cPosition +{ +public: + cPosition(const cPosition& rhs); + cPosition(double dLatitude = 0, double dLongitude = 0, double dElevation = 0); + double getLatitude(); + double getLongitude(); + double getElevation(); + cPosition& operator=(const cPosition& rhs); +protected: + double m_dLatitude; + double m_dLongitude; + double m_dElevation; +}; + +#endif // CPOSITION_H diff --git a/main.cpp b/main.cpp new file mode 100644 index 0000000..0900a00 --- /dev/null +++ b/main.cpp @@ -0,0 +1,11 @@ +#include +#include "cmainwindow.h" + +int main(int argc, char *argv[]) +{ + QApplication a(argc, argv); + cMainWindow w; + w.show(); + + return a.exec(); +} diff --git a/plugins/import/ImportTCX/Import.pro b/plugins/import/ImportTCX/Import.pro new file mode 100644 index 0000000..c865eb9 --- /dev/null +++ b/plugins/import/ImportTCX/Import.pro @@ -0,0 +1,49 @@ +#------------------------------------------------- +# +# Project created by QtCreator 2011-04-21T09:04:50 +# +#------------------------------------------------- + +QT += xml xmlpatterns + +QT -= gui + +TARGET = ImportTCX +TEMPLATE = lib + +DEFINES += IMPORT_LIBRARY + +SOURCES += cimport.cpp \ + cactivity.cpp \ + clap.cpp \ + ctrackpoint.cpp \ + cposition.cpp + +HEADERS += cimport.h\ + cactivity.h \ + clap.h \ + common.h \ + ctrackpoint.h \ + cposition.h + +symbian { + #Symbian specific definitions + MMP_RULES += EXPORTUNFROZEN + TARGET.UID3 = 0xE4D9395A + TARGET.CAPABILITY = + TARGET.EPOCALLOWDLLDATA = 1 + addFiles.sources = Import.dll + addFiles.path = !:/sys/bin + DEPLOYMENT += addFiles +} + +unix:!symbian { + maemo5 { + target.path = /opt/usr/lib + } else { + target.path = /usr/local/lib + } + INSTALLS += target +} + +LIBS += -shared -fPIC diff --git a/plugins/import/ImportTCX/Import.pro.user b/plugins/import/ImportTCX/Import.pro.user new file mode 100644 index 0000000..0c59519 --- /dev/null +++ b/plugins/import/ImportTCX/Import.pro.user @@ -0,0 +1,165 @@ + + + + ProjectExplorer.Project.ActiveTarget + 0 + + + ProjectExplorer.Project.EditorSettings + + Default + + + + ProjectExplorer.Project.Target.0 + + Desktop + + Qt4ProjectManager.Target.DesktopTarget + 1 + 0 + 0 + + + + qmake + + QtProjectManager.QMakeBuildStep + + false + + + Make + + Qt4ProjectManager.MakeStep + false + + + + 2 + Build + + ProjectExplorer.BuildSteps.Build + + + + Make + + Qt4ProjectManager.MakeStep + true + + clean + + + + 1 + Clean + + ProjectExplorer.BuildSteps.Clean + + 2 + false + + Debug + + Qt4ProjectManager.Qt4BuildConfiguration + 2 + /data/Projects/QTCreator/TrainingChart/Import-build-desktop + 2 + 0 + false + + + + + qmake + + QtProjectManager.QMakeBuildStep + + false + + + Make + + Qt4ProjectManager.MakeStep + false + + + + 2 + Build + + ProjectExplorer.BuildSteps.Build + + + + Make + + Qt4ProjectManager.MakeStep + true + + clean + + + + 1 + Clean + + ProjectExplorer.BuildSteps.Clean + + 2 + false + + Release + + Qt4ProjectManager.Qt4BuildConfiguration + 0 + /data/Projects/QTCreator/TrainingChart/Import-build-desktop + 2 + 0 + false + + 2 + + + 0 + Deploy + + ProjectExplorer.BuildSteps.Deploy + + 1 + No deployment + + ProjectExplorer.DefaultDeployConfiguration + + 1 + + + 2 + + false + + $BUILDDIR + Custom Executable + + ProjectExplorer.CustomExecutableRunConfiguration + 3768 + true + false + + 1 + + + + ProjectExplorer.Project.TargetCount + 1 + + + ProjectExplorer.Project.Updater.EnvironmentId + {7ffca601-cf8d-4c1d-9b60-0a68859cdd79} + + + ProjectExplorer.Project.Updater.FileVersion + 8 + + diff --git a/plugins/import/ImportTCX/Makefile b/plugins/import/ImportTCX/Makefile new file mode 100644 index 0000000..935cd1c --- /dev/null +++ b/plugins/import/ImportTCX/Makefile @@ -0,0 +1,275 @@ +############################################################################# +# Makefile for building: libImportTCX.so.1.0.0 +# Generated by qmake (2.01a) (Qt 4.7.2) on: Wed Apr 27 13:38:05 2011 +# Project: Import.pro +# Template: lib +# Command: /usr/bin/qmake-qt4 -spec /usr/share/qt4/mkspecs/linux-g++ QMLJSDEBUGGER_PATH=/usr/share/qtcreator/qml/qmljsdebugger -o Makefile Import.pro +############################################################################# + +####### Compiler, tools and options + +CC = gcc +CXX = g++ +DEFINES = -DIMPORT_LIBRARY -DQT_NO_DEBUG -DQT_XMLPATTERNS_LIB -DQT_XML_LIB -DQT_CORE_LIB -DQT_SHARED +CFLAGS = -pipe -O2 -Wall -W -D_REENTRANT -fPIC $(DEFINES) +CXXFLAGS = -pipe -O2 -Wall -W -D_REENTRANT -fPIC $(DEFINES) +INCPATH = -I/usr/share/qt4/mkspecs/linux-g++ -I. -I/usr/include/qt4/QtCore -I/usr/include/qt4/QtXml -I/usr/include/qt4/QtXmlPatterns -I/usr/include/qt4 -I. +LINK = g++ +LFLAGS = -Wl,-O1 -shared -Wl,-soname,libImportTCX.so.1 +LIBS = $(SUBLIBS) -L/usr/lib -shared -fPIC -lQtXmlPatterns -lQtXml -lQtCore -lpthread +AR = ar cqs +RANLIB = +QMAKE = /usr/bin/qmake-qt4 +TAR = tar -cf +COMPRESS = gzip -9f +COPY = cp -f +SED = sed +COPY_FILE = $(COPY) +COPY_DIR = $(COPY) -r +STRIP = strip +INSTALL_FILE = install -m 644 -p +INSTALL_DIR = $(COPY_DIR) +INSTALL_PROGRAM = install -m 755 -p +DEL_FILE = rm -f +SYMLINK = ln -f -s +DEL_DIR = rmdir +MOVE = mv -f +CHK_DIR_EXISTS= test -d +MKDIR = mkdir -p + +####### Output directory + +OBJECTS_DIR = ./ + +####### Files + +SOURCES = cimport.cpp \ + cactivity.cpp \ + clap.cpp \ + ctrackpoint.cpp \ + cposition.cpp +OBJECTS = cimport.o \ + cactivity.o \ + clap.o \ + ctrackpoint.o \ + cposition.o +DIST = /usr/share/qt4/mkspecs/common/g++.conf \ + /usr/share/qt4/mkspecs/common/unix.conf \ + /usr/share/qt4/mkspecs/common/linux.conf \ + /usr/share/qt4/mkspecs/qconfig.pri \ + /usr/share/qt4/mkspecs/modules/qt_phonon.pri \ + /usr/share/qt4/mkspecs/modules/qt_webkit_version.pri \ + /usr/share/qt4/mkspecs/features/qt_functions.prf \ + /usr/share/qt4/mkspecs/features/qt_config.prf \ + /usr/share/qt4/mkspecs/features/exclusive_builds.prf \ + /usr/share/qt4/mkspecs/features/default_pre.prf \ + /usr/share/qt4/mkspecs/features/release.prf \ + /usr/share/qt4/mkspecs/features/default_post.prf \ + /usr/share/qt4/mkspecs/features/warn_on.prf \ + /usr/share/qt4/mkspecs/features/qt.prf \ + /usr/share/qt4/mkspecs/features/unix/thread.prf \ + /usr/share/qt4/mkspecs/features/moc.prf \ + /usr/share/qt4/mkspecs/features/resources.prf \ + /usr/share/qt4/mkspecs/features/uic.prf \ + /usr/share/qt4/mkspecs/features/yacc.prf \ + /usr/share/qt4/mkspecs/features/lex.prf \ + /usr/share/qt4/mkspecs/features/include_source_dir.prf \ + Import.pro +QMAKE_TARGET = ImportTCX +DESTDIR = +TARGET = libImportTCX.so.1.0.0 +TARGETA = libImportTCX.a +TARGETD = libImportTCX.so.1.0.0 +TARGET0 = libImportTCX.so +TARGET1 = libImportTCX.so.1 +TARGET2 = libImportTCX.so.1.0 + +first: all +####### Implicit rules + +.SUFFIXES: .o .c .cpp .cc .cxx .C + +.cpp.o: + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o "$@" "$<" + +.cc.o: + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o "$@" "$<" + +.cxx.o: + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o "$@" "$<" + +.C.o: + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o "$@" "$<" + +.c.o: + $(CC) -c $(CFLAGS) $(INCPATH) -o "$@" "$<" + +####### Build rules + +all: Makefile $(TARGET) + +$(TARGET): $(OBJECTS) $(SUBLIBS) $(OBJCOMP) + -$(DEL_FILE) $(TARGET) $(TARGET0) $(TARGET1) $(TARGET2) + $(LINK) $(LFLAGS) -o $(TARGET) $(OBJECTS) $(LIBS) $(OBJCOMP) + -ln -s $(TARGET) $(TARGET0) + -ln -s $(TARGET) $(TARGET1) + -ln -s $(TARGET) $(TARGET2) + + + +staticlib: $(TARGETA) + +$(TARGETA): $(OBJECTS) $(OBJCOMP) + -$(DEL_FILE) $(TARGETA) + $(AR) $(TARGETA) $(OBJECTS) + +Makefile: Import.pro /usr/share/qt4/mkspecs/linux-g++/qmake.conf /usr/share/qt4/mkspecs/common/g++.conf \ + /usr/share/qt4/mkspecs/common/unix.conf \ + /usr/share/qt4/mkspecs/common/linux.conf \ + /usr/share/qt4/mkspecs/qconfig.pri \ + /usr/share/qt4/mkspecs/modules/qt_phonon.pri \ + /usr/share/qt4/mkspecs/modules/qt_webkit_version.pri \ + /usr/share/qt4/mkspecs/features/qt_functions.prf \ + /usr/share/qt4/mkspecs/features/qt_config.prf \ + /usr/share/qt4/mkspecs/features/exclusive_builds.prf \ + /usr/share/qt4/mkspecs/features/default_pre.prf \ + /usr/share/qt4/mkspecs/features/release.prf \ + /usr/share/qt4/mkspecs/features/default_post.prf \ + /usr/share/qt4/mkspecs/features/warn_on.prf \ + /usr/share/qt4/mkspecs/features/qt.prf \ + /usr/share/qt4/mkspecs/features/unix/thread.prf \ + /usr/share/qt4/mkspecs/features/moc.prf \ + /usr/share/qt4/mkspecs/features/resources.prf \ + /usr/share/qt4/mkspecs/features/uic.prf \ + /usr/share/qt4/mkspecs/features/yacc.prf \ + /usr/share/qt4/mkspecs/features/lex.prf \ + /usr/share/qt4/mkspecs/features/include_source_dir.prf \ + /usr/lib/libQtXmlPatterns.prl \ + /usr/lib/libQtXml.prl \ + /usr/lib/libQtCore.prl + $(QMAKE) -spec /usr/share/qt4/mkspecs/linux-g++ QMLJSDEBUGGER_PATH=/usr/share/qtcreator/qml/qmljsdebugger -o Makefile Import.pro +/usr/share/qt4/mkspecs/common/g++.conf: +/usr/share/qt4/mkspecs/common/unix.conf: +/usr/share/qt4/mkspecs/common/linux.conf: +/usr/share/qt4/mkspecs/qconfig.pri: +/usr/share/qt4/mkspecs/modules/qt_phonon.pri: +/usr/share/qt4/mkspecs/modules/qt_webkit_version.pri: +/usr/share/qt4/mkspecs/features/qt_functions.prf: +/usr/share/qt4/mkspecs/features/qt_config.prf: +/usr/share/qt4/mkspecs/features/exclusive_builds.prf: +/usr/share/qt4/mkspecs/features/default_pre.prf: +/usr/share/qt4/mkspecs/features/release.prf: +/usr/share/qt4/mkspecs/features/default_post.prf: +/usr/share/qt4/mkspecs/features/warn_on.prf: +/usr/share/qt4/mkspecs/features/qt.prf: +/usr/share/qt4/mkspecs/features/unix/thread.prf: +/usr/share/qt4/mkspecs/features/moc.prf: +/usr/share/qt4/mkspecs/features/resources.prf: +/usr/share/qt4/mkspecs/features/uic.prf: +/usr/share/qt4/mkspecs/features/yacc.prf: +/usr/share/qt4/mkspecs/features/lex.prf: +/usr/share/qt4/mkspecs/features/include_source_dir.prf: +/usr/lib/libQtXmlPatterns.prl: +/usr/lib/libQtXml.prl: +/usr/lib/libQtCore.prl: +qmake: FORCE + @$(QMAKE) -spec /usr/share/qt4/mkspecs/linux-g++ QMLJSDEBUGGER_PATH=/usr/share/qtcreator/qml/qmljsdebugger -o Makefile Import.pro + +dist: + @$(CHK_DIR_EXISTS) .tmp/ImportTCX1.0.0 || $(MKDIR) .tmp/ImportTCX1.0.0 + $(COPY_FILE) --parents $(SOURCES) $(DIST) .tmp/ImportTCX1.0.0/ && $(COPY_FILE) --parents cimport.h Import_global.h cactivity.h clap.h common.h ctrackpoint.h cposition.h .tmp/ImportTCX1.0.0/ && $(COPY_FILE) --parents cimport.cpp cactivity.cpp clap.cpp ctrackpoint.cpp cposition.cpp .tmp/ImportTCX1.0.0/ && (cd `dirname .tmp/ImportTCX1.0.0` && $(TAR) ImportTCX1.0.0.tar ImportTCX1.0.0 && $(COMPRESS) ImportTCX1.0.0.tar) && $(MOVE) `dirname .tmp/ImportTCX1.0.0`/ImportTCX1.0.0.tar.gz . && $(DEL_FILE) -r .tmp/ImportTCX1.0.0 + + +clean:compiler_clean + -$(DEL_FILE) $(OBJECTS) + -$(DEL_FILE) *~ core *.core + + +####### Sub-libraries + +distclean: clean + -$(DEL_FILE) $(TARGET) + -$(DEL_FILE) $(TARGET0) $(TARGET1) $(TARGET2) $(TARGETA) + -$(DEL_FILE) Makefile + + +check: first + +mocclean: compiler_moc_header_clean compiler_moc_source_clean + +mocables: compiler_moc_header_make_all compiler_moc_source_make_all + +compiler_moc_header_make_all: +compiler_moc_header_clean: +compiler_rcc_make_all: +compiler_rcc_clean: +compiler_image_collection_make_all: qmake_image_collection.cpp +compiler_image_collection_clean: + -$(DEL_FILE) qmake_image_collection.cpp +compiler_moc_source_make_all: +compiler_moc_source_clean: +compiler_uic_make_all: +compiler_uic_clean: +compiler_yacc_decl_make_all: +compiler_yacc_decl_clean: +compiler_yacc_impl_make_all: +compiler_yacc_impl_clean: +compiler_lex_make_all: +compiler_lex_clean: +compiler_clean: + +####### Compile + +cimport.o: cimport.cpp cimport.h \ + cactivity.h \ + common.h \ + clap.h \ + ctrackpoint.h \ + cposition.h + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o cimport.o cimport.cpp + +cactivity.o: cactivity.cpp cactivity.h \ + common.h \ + clap.h \ + ctrackpoint.h \ + cposition.h + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o cactivity.o cactivity.cpp + +clap.o: clap.cpp clap.h \ + common.h \ + ctrackpoint.h \ + cposition.h + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o clap.o clap.cpp + +ctrackpoint.o: ctrackpoint.cpp ctrackpoint.h \ + common.h \ + cposition.h + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o ctrackpoint.o ctrackpoint.cpp + +cposition.o: cposition.cpp cposition.h + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o cposition.o cposition.cpp + +####### Install + +install_target: first FORCE + @$(CHK_DIR_EXISTS) $(INSTALL_ROOT)/usr/local/lib/ || $(MKDIR) $(INSTALL_ROOT)/usr/local/lib/ + -$(INSTALL_PROGRAM) "$(TARGET)" "$(INSTALL_ROOT)/usr/local/lib/$(TARGET)" + -$(STRIP) --strip-unneeded "$(INSTALL_ROOT)/usr/local/lib/$(TARGET)" + -$(SYMLINK) "$(TARGET)" "$(INSTALL_ROOT)/usr/local/lib/$(TARGET0)" + -$(SYMLINK) "$(TARGET)" "$(INSTALL_ROOT)/usr/local/lib/$(TARGET1)" + -$(SYMLINK) "$(TARGET)" "$(INSTALL_ROOT)/usr/local/lib/$(TARGET2)" + +uninstall_target: FORCE + -$(DEL_FILE) "$(INSTALL_ROOT)/usr/local/lib/$(TARGET)" + -$(DEL_FILE) "$(INSTALL_ROOT)/usr/local/lib/$(TARGET0)" + -$(DEL_FILE) "$(INSTALL_ROOT)/usr/local/lib/$(TARGET1)" + -$(DEL_FILE) "$(INSTALL_ROOT)/usr/local/lib/$(TARGET2)" + -$(DEL_DIR) $(INSTALL_ROOT)/usr/local/lib/ + + +install: install_target FORCE + +uninstall: uninstall_target FORCE + +FORCE: + diff --git a/plugins/import/ImportTCX/cactivity.cpp b/plugins/import/ImportTCX/cactivity.cpp new file mode 100644 index 0000000..34b59ea --- /dev/null +++ b/plugins/import/ImportTCX/cactivity.cpp @@ -0,0 +1,90 @@ +#include "cactivity.h" +#include + + +cActivity::cActivity() +{ + m_dwValid = 0; +} + +cActivity::cActivity(const cActivity& rhs) +{ + this->m_dwValid = rhs.m_dwValid; + this->m_iActivityType = rhs.m_iActivityType; + this->m_LapList = rhs.m_LapList; + this->m_szName = rhs.m_szName; +} + +cActivity::cActivity(enum ActivityType iActivityType, const QString& szName) +{ + m_dwValid = 0; + setActivityType(iActivityType); + setName(szName); +} + +bool cActivity::setActivityType(enum ActivityType iActivityType) +{ + if(iActivityType < ActivityTypeUnknown || iActivityType > ActivityTypeNone) + return(false); + m_iActivityType = iActivityType; + m_dwValid |= VALID_ACTIVITYTYPE; + return(true); +} + +enum cActivity::ActivityType cActivity::getActivityType() +{ + if(m_dwValid & VALID_ACTIVITYTYPE) + return(m_iActivityType); + else + return(ActivityTypeUnknown); +} + +bool cActivity::setName(const QString& szName) +{ + if(!szName.length()) + return(false); + + m_szName = szName; + m_dwValid |= VALID_NAME; + return(true); +} + +QString cActivity::getName() +{ + if(m_dwValid & VALID_NAME) + return(m_szName); + return(""); +} + +cLap* cActivity::addLap(const QDateTime& StartTime) +{ + return(m_LapList.add(this, StartTime)); +} + +cLapList cActivity::getLapList() +{ + return(m_LapList); +} + +cActivity& cActivity::operator=(const cActivity& rhs) +{ + if(this != &rhs) + { + this->m_dwValid = rhs.m_dwValid; + this->m_iActivityType = rhs.m_iActivityType; + this->m_LapList = rhs.m_LapList; + this->m_szName = rhs.m_szName; + } + return(*this); +} + +cActivityList::cActivityList() +{ +} + +cActivity* cActivityList::add(enum cActivity::ActivityType iActivityType, const QString& szName) +{ + cActivity* lpActivity = new cActivity(iActivityType, szName); + this->append(lpActivity); + return(lpActivity); +} diff --git a/plugins/import/ImportTCX/cactivity.h b/plugins/import/ImportTCX/cactivity.h new file mode 100644 index 0000000..04dea1c --- /dev/null +++ b/plugins/import/ImportTCX/cactivity.h @@ -0,0 +1,56 @@ +#ifndef CACTIVITY_H +#define CACTIVITY_H + + +#include +#include +#include + +#include "common.h" +#include "clap.h" + + +class cActivity +{ +public: + enum ActivityType + { + ActivityTypeUnknown, + ActivityTypeRunning, + ActivityTypeBiking, + ActivityTypeSwimming, + ActivityTypeNone, + }; + + cActivity(); + cActivity(const cActivity& rhs); + cActivity(enum ActivityType iActivityType, const QString& szName); + + bool setActivityType(enum ActivityType iActivityType); + enum ActivityType getActivityType(); + + bool setName(const QString& szName); + QString getName(); + + cLap* addLap(const QDateTime& StartTime); + cLapList getLapList(); + + cActivity& operator=(const cActivity& rhs); +protected: + uint64_t m_dwValid; + enum ActivityType m_iActivityType; + QString m_szName; + + cLapList m_LapList; +}; + +Q_DECLARE_METATYPE(cActivity); + +class cActivityList : public QList +{ +public: + cActivityList(); + cActivity* add(enum cActivity::ActivityType iActivityType, const QString& szName); +}; + +#endif // CACTIVITY_H diff --git a/plugins/import/ImportTCX/cimport.cpp b/plugins/import/ImportTCX/cimport.cpp new file mode 100644 index 0000000..c14e9c0 --- /dev/null +++ b/plugins/import/ImportTCX/cimport.cpp @@ -0,0 +1,289 @@ +#include "cimport.h" +#include + + +bool attributeString(const QDomElement& Element, const QString& szName, QString& szValue) +{ + QDomNamedNodeMap Attributes = Element.attributes(); + + for(int z = 0;z < Attributes.count();z++) + { + QDomNode Node = Attributes.item(z); + if(!Node.toAttr().name().compare(szName, Qt::CaseInsensitive)) + { + szValue = Node.toAttr().nodeValue(); + return(true); + } + } + return(false); +} + +QDateTime toDateTime(const QString& szDateTime) +{ + QDateTime DateTime = QDateTime::fromString(szDateTime, "yyyy-MM-ddTHH:mm:ss.000Z"); // 2011-04-17T07:04:35.000Z + return(DateTime); +} + +double toDouble(const QString& szDouble) +{ + QString sz = szDouble; + bool bOk; + double x; + + sz.replace(",", "."); + x = sz.toDouble(&bOk); + if(!bOk) + { + sz.replace(".", ","); + x = sz.toDouble(&bOk); + } + return(x); +} + +cImport::cImport() +{ +} + +QString cImport::getName() +{ + return("ImportTCX"); +} + +QString cImport::getVersion() +{ + return("1.0"); +} + +QString cImport::getExtension() +{ + return("Garmin Workouts (*.tcx)"); +} + +cActivityList cImport::getActivityList() +{ + return(m_ActivityList); +} + +int32_t cImport::load(const QString &szFileName) +{ + if(!szFileName.contains(".tcx", Qt::CaseInsensitive)) + return(FILE_NOT_SUPPORTED); + + QFile File(szFileName); + if(!File.exists()) + return(FILE_NOT_EXIST); + + if(!szFileName.toLower().contains(".tcx")) + return(FILE_WRONG_FORMAT); + + if(!File.open(QFile::ReadOnly | QFile::Text)) + return(FILE_NOT_READABLE); + + QDomDocument Doc; + QString errorStr; + int errorLine; + int errorColumn; + if(!Doc.setContent(&File, false, &errorStr, &errorLine, &errorColumn)) + { + File.close(); + return(FILE_WRONG_FORMAT); + } + File.close(); + + QDomElement Root = Doc.documentElement(); + + if(Root.tagName().toLower() != "trainingcenterdatabase") + return(FILE_WRONG_FORMAT); + + QDomNode Child = Root.firstChild(); + + while(!Child.isNull()) + { + if(!Child.toElement().tagName().compare("activities", Qt::CaseInsensitive)) + parseActivities(Child.toElement()); + else if(!Child.toElement().tagName().compare("author", Qt::CaseInsensitive)) + parseAuthor(Child.toElement()); + + Child = Child.nextSibling(); + } + + return(NO_ERROR); +} + +void cImport::parseActivities(const QDomElement& Element) +{ + QDomNode Child = Element.firstChild(); + + while(!Child.isNull()) + { + if(!Child.toElement().tagName().compare("activity", Qt::CaseInsensitive)) + { + QString szSport; + if(attributeString(Child.toElement(), "sport", szSport)) + parseActivity(Child.toElement(), szSport); + } + + Child = Child.nextSibling(); + } +} + +void cImport::parseActivity(const QDomElement& Element, const QString& szSport) +{ + QDomNode Child = Element.firstChild(); + cActivity* lpActivity = 0; + cActivity::ActivityType iActivityType = cActivity::ActivityTypeUnknown; + + if(!szSport.compare("running", Qt::CaseInsensitive)) + iActivityType = cActivity::ActivityTypeRunning; + else if(!szSport.compare("biking", Qt::CaseInsensitive)) + iActivityType = cActivity::ActivityTypeBiking; + + while(!Child.isNull()) + { + if(!Child.toElement().tagName().compare("id", Qt::CaseInsensitive)) + { + if(lpActivity) + lpActivity->setName(Child.toElement().text()); + else + lpActivity = m_ActivityList.add(iActivityType, Child.toElement().text()); + } + else if(!Child.toElement().tagName().compare("lap", Qt::CaseInsensitive)) + { + QString szStartTime; + if(attributeString(Child.toElement(), "starttime", szStartTime)) + { + if(!lpActivity) + lpActivity = m_ActivityList.add(iActivityType, "EMPTY"); + cLap* lpLap = lpActivity->addLap(toDateTime(szStartTime)); + + parseLap(Child.toElement(), lpLap); + } + } + Child = Child.nextSibling(); + } +} + +void cImport::parseLap(const QDomElement& Element, cLap* lpLap) +{ + QDomNode Child = Element.firstChild(); + + while(!Child.isNull()) + { + if(!Child.toElement().tagName().compare("totaltimeseconds",Qt::CaseInsensitive)) + lpLap->setTotalTime(toDouble(Child.toElement().text())); + else if(!Child.toElement().tagName().compare("distancemeters",Qt::CaseInsensitive)) + lpLap->setTotalDistance(toDouble(Child.toElement().text())); + else if(!Child.toElement().tagName().compare("maximumspeed",Qt::CaseInsensitive)) + lpLap->setMaximumSpeed(toDouble(Child.toElement().text())); + else if(!Child.toElement().tagName().compare("calories",Qt::CaseInsensitive)) + lpLap->setCalories(toDouble(Child.toElement().text())); + else if(!Child.toElement().tagName().compare("averageheartratebpm",Qt::CaseInsensitive)) + { + QDomNode SubChild = Child.toElement().firstChild(); + if(!SubChild.isNull()) + lpLap->setAvgHeartrate(toDouble(SubChild.toElement().text())); + } + else if(!Child.toElement().tagName().compare("maximumheartratebpm",Qt::CaseInsensitive)) + { + QDomNode SubChild = Child.toElement().firstChild(); + if(!SubChild.isNull()) + lpLap->setMaxHeartrate(toDouble(SubChild.toElement().text())); + } + else if(!Child.toElement().tagName().compare("intensity",Qt::CaseInsensitive)) + { + QString sz = Child.toElement().text(); + if(!sz.compare("active", Qt::CaseInsensitive)) + lpLap->setIntensity(cLap::IntensityActive); + else + lpLap->setIntensity(cLap::IntensityNone); + } + else if(!Child.toElement().tagName().compare("triggermethod",Qt::CaseInsensitive)) + { + QString sz = Child.toElement().text(); + if(!sz.compare("manual", Qt::CaseInsensitive)) + lpLap->setTriggerMethod(cLap::TriggerMethodManual); + else + lpLap->setTriggerMethod(cLap::TriggerMethodNone); + } + else if(!Child.toElement().tagName().compare("track",Qt::CaseInsensitive)) + parseTrack(Child.toElement(), lpLap); + + Child = Child.nextSibling(); + } +} + +void cImport::parseTrack(const QDomElement& Element, cLap* lpLap) +{ + QDomNode Child = Element.firstChild(); + + while(!Child.isNull()) + { + if(!Child.toElement().tagName().compare("trackpoint", Qt::CaseInsensitive)) + { + cTrackpoint* lpTrackpoint = lpLap->addTrackpoint(0); + parseTrackpoint(Child.toElement(), lpTrackpoint); + } + + Child = Child.nextSibling(); + } +} + +void cImport::parseTrackpoint(const QDomElement& Element, cTrackpoint* lpTrackpoint) +{ + QDomNode Child = Element.firstChild(); + double dLatitude = 0; + double dLongitude = 0; + double dElevation = 0; + + while(!Child.isNull()) + { + if(!Child.toElement().tagName().compare("time", Qt::CaseInsensitive)) + { + cLap* lpLap = lpTrackpoint->getParent(); + if(lpLap) + lpTrackpoint->setTime(toDateTime(Child.toElement().text()).toTime_t()-lpLap->getStartTime().toTime_t()); + } + else if(!Child.toElement().tagName().compare("position", Qt::CaseInsensitive)) + { + QDomNode subChild = Child.toElement().firstChild(); + while(!subChild.isNull()) + { + if(!subChild.toElement().tagName().compare("latitudedegrees", Qt::CaseInsensitive)) + dLatitude = toDouble(subChild.toElement().text()); + else if(!subChild.toElement().tagName().compare("longitudedegrees", Qt::CaseInsensitive)) + dLongitude = toDouble(subChild.toElement().text()); + subChild = subChild.nextSibling(); + } + } + else if(!Child.toElement().tagName().compare("altitudemeters", Qt::CaseInsensitive)) + dElevation = toDouble(Child.toElement().text()); + else if(!Child.toElement().tagName().compare("distancemeters", Qt::CaseInsensitive)) + lpTrackpoint->setDistance(toDouble(Child.toElement().text())); + else if(!Child.toElement().tagName().compare("heartratebpm", Qt::CaseInsensitive)) + { + QDomNode SubChild = Child.toElement().firstChild(); + if(!SubChild.isNull()) + lpTrackpoint->setHeartRate(toDouble(SubChild.toElement().text())); + } + + Child = Child.nextSibling(); + } + lpTrackpoint->setPosition(cPosition(dLatitude, dLongitude, dElevation)); +} + +void cImport::parseAuthor(const QDomElement& Element) +{ +} + +extern "C" +{ + cImport* create() + { + return(new cImport); + } + + void destroy(cImport* p) + { + delete p; + } +} diff --git a/plugins/import/ImportTCX/cimport.h b/plugins/import/ImportTCX/cimport.h new file mode 100644 index 0000000..3773f45 --- /dev/null +++ b/plugins/import/ImportTCX/cimport.h @@ -0,0 +1,51 @@ +#ifndef CIMPORT_H +#define CIMPORT_H + + +#include +#include +#include +#include +#include + +#include "cactivity.h" +#include "clap.h" +#include "ctrackpoint.h" + + +class cImport +{ +public: + enum IMPORT_ERROR + { + NO_ERROR = 0, + FILE_NOT_EXIST = 1, + FILE_NOT_SUPPORTED = 2, + FILE_NOT_READABLE = 3, + FILE_WRONG_FORMAT = 4, + }; + + cImport(); + + virtual QString getName(); + virtual QString getVersion(); + virtual QString getExtension(); + virtual cActivityList getActivityList(); + + virtual int32_t load(const QString& szFileName); + +protected: + void parseActivities(const QDomElement& Element); + void parseActivity(const QDomElement& Element, const QString& szSport); + void parseLap(const QDomElement& Element, cLap* lpLap); + void parseTrack(const QDomElement& Element, cLap* lpLap); + void parseTrackpoint(const QDomElement& Element, cTrackpoint* lpTrackpoint); + void parseAuthor(const QDomElement& Element); + + cActivityList m_ActivityList; +}; + +typedef cImport* create_t(); +typedef void destroy_t(cImport* lpImport); + +#endif // CIMPORT_H diff --git a/plugins/import/ImportTCX/clap.cpp b/plugins/import/ImportTCX/clap.cpp new file mode 100644 index 0000000..62c3423 --- /dev/null +++ b/plugins/import/ImportTCX/clap.cpp @@ -0,0 +1,172 @@ +#include "clap.h" +#include + + +cLap::cLap(cActivity* lpParent) +{ + m_dwValid = 0; + m_lpParent = lpParent; +} + +cLap::cLap(cActivity* lpParent, const QDateTime &StartTime) +{ + m_dwValid = 0; + m_lpParent = lpParent; + setStartTime(StartTime); +} + +cActivity* cLap::getParent() +{ + return(m_lpParent); +} + +bool cLap::setStartTime(const QDateTime &StartTime) +{ + if(!StartTime.isValid()) + return(false); + + m_StartTime = StartTime; + m_dwValid |= VALID_STARTTIME; + return(true); +} + +QDateTime cLap::getStartTime() +{ + if(m_dwValid & VALID_STARTTIME) + return(m_StartTime); + return(QDateTime(QDate(1980, 1, 1), QTime(0, 0))); +} + +bool cLap::setTotalTime(double dTotalTime) +{ + m_dTotalTime = dTotalTime; + m_dwValid |= VALID_TOTALTIME; + return(true); +} + +double cLap::getTotalTime() +{ + if(m_dwValid & VALID_TOTALTIME) + return(m_dTotalTime); + return(0); +} + +bool cLap::setTotalDistance(double dTotalDistance) +{ + m_dTotalDistance = dTotalDistance; + m_dwValid |= VALID_TOTALDISTANCE; + return(true); +} + +double cLap::getTotalDistance() +{ + if(m_dwValid & VALID_TOTALDISTANCE) + return(m_dTotalDistance); + return(0); +} + +bool cLap::setMaximumSpeed(double dMaximumSpeed) +{ + m_dMaximumSpeed = dMaximumSpeed; + m_dwValid |= VALID_MAXIMUMSPEED; + return(true); +} + +double cLap::getMaximumSpeed() +{ + if(m_dwValid & VALID_MAXIMUMSPEED) + return(m_dMaximumSpeed); + return(0); +} + +bool cLap::setCalories(double dCalories) +{ + m_dCalories = dCalories; + m_dwValid |= VALID_CALORIES; + return(true); +} + +double cLap::getCalories() +{ + if(m_dwValid & VALID_CALORIES) + return(m_dCalories); + return(0); +} + +bool cLap::setAvgHeartrate(double dAvgHeartrate) +{ + m_dAvgHeartrate = dAvgHeartrate; + m_dwValid |= VALID_AVGHEARTRATE; + return(true); +} + +double cLap::getAvgHeartrate() +{ + if(m_dwValid & VALID_AVGHEARTRATE) + return(m_dAvgHeartrate); + return(0); +} + +bool cLap::setMaxHeartrate(double dMaxHeartrate) +{ + m_dMaxHeartrate = dMaxHeartrate; + m_dwValid |= VALID_MAXHEARTRATE; + return(true); +} + +double cLap::getMaxHeartrate() +{ + if(m_dwValid & VALID_MAXHEARTRATE) + return(m_dMaxHeartrate); + return(0); +} + +bool cLap::setIntensity(enum Intensity iIntensity) +{ + if(iIntensity < IntensityUnknown || iIntensity > IntensityNone) + return(false); + m_iIntensity = iIntensity; + m_dwValid |= VALID_INTENSITY; + return(true); +} + +enum cLap::Intensity cLap::getIntensity() +{ + if(m_dwValid & VALID_INTENSITY) + return(m_iIntensity); + else + return(cLap::IntensityNone); +} + +bool cLap::setTriggerMethod(enum TriggerMethod iTriggerMethod) +{ + if(iTriggerMethod < TriggerMethodUnknown || iTriggerMethod > TriggerMethodNone) + return(false); + m_iTriggerMethod = iTriggerMethod; + m_dwValid |= VALID_TRIGGERMETHOD; + return(true); +} + +enum cLap::TriggerMethod cLap::getTriggerMethod() +{ + if(m_dwValid & VALID_TRIGGERMETHOD) + return(m_iTriggerMethod); + else + return(cLap::TriggerMethodNone); +} + +cTrackpoint* cLap::addTrackpoint(uint32_t dwTime) +{ + return(m_TrackpointList.add(this, dwTime)); +} + +cLapList::cLapList() +{ +} + +cLap* cLapList::add(cActivity* lpParent, const QDateTime &StartTime) +{ + cLap* lpLap = new cLap(lpParent, StartTime); + this->append(lpLap); + return(lpLap); +} diff --git a/plugins/import/ImportTCX/clap.h b/plugins/import/ImportTCX/clap.h new file mode 100644 index 0000000..d6253b2 --- /dev/null +++ b/plugins/import/ImportTCX/clap.h @@ -0,0 +1,92 @@ +#ifndef CLAP_H +#define CLAP_H + + +#include +#include +#include +#include + +#include "common.h" + +#include "ctrackpoint.h" + + +class cActivity; + +class cLap +{ +public: + enum Intensity + { + IntensityUnknown, + IntensityActive, + IntensityNone, + }; + + enum TriggerMethod + { + TriggerMethodUnknown, + TriggerMethodManual, + TriggerMethodAuto, + TriggerMethodNone, + }; + + cLap(cActivity* lpParent = 0); + cLap(cActivity* lpParent, const QDateTime& StartTime); + + cActivity* getParent(); + + bool setStartTime(const QDateTime& StartTime); + QDateTime getStartTime(); + + bool setTotalTime(double dTotalTime); + double getTotalTime(); + + bool setTotalDistance(double dTotalDistance); + double getTotalDistance(); + + bool setMaximumSpeed(double dMaximumSpeed); + double getMaximumSpeed(); + + bool setCalories(double dCalories); + double getCalories(); + + bool setAvgHeartrate(double dAvgHeartrate); + double getAvgHeartrate(); + + bool setMaxHeartrate(double dMaxHeartrate); + double getMaxHeartrate(); + + bool setIntensity(enum Intensity iIntensity); + enum Intensity getIntensity(); + + bool setTriggerMethod(enum TriggerMethod iTriggerMethod); + enum TriggerMethod getTriggerMethod(); + + cTrackpoint* addTrackpoint(uint32_t dwTime); +protected: + uint64_t m_dwValid; + cActivity* m_lpParent; + QDateTime m_StartTime; + double m_dTotalTime; + double m_dTotalDistance; + double m_dMaximumSpeed; + double m_dCalories; + double m_dAvgHeartrate; + double m_dMaxHeartrate; + enum Intensity m_iIntensity; + enum TriggerMethod m_iTriggerMethod; + cTrackpointList m_TrackpointList; +}; + +Q_DECLARE_METATYPE(cLap); + +class cLapList : public QList +{ +public: + cLapList(); + cLap* add(cActivity* lpParent, const QDateTime& StartTime); +}; + +#endif // CLAP_H diff --git a/plugins/import/ImportTCX/common.h b/plugins/import/ImportTCX/common.h new file mode 100644 index 0000000..6a6c422 --- /dev/null +++ b/plugins/import/ImportTCX/common.h @@ -0,0 +1,22 @@ +#ifndef COMMON_H +#define COMMON_H + + +#define VALID_NAME 0x00000000000000000000000000000001LL +#define VALID_STARTTIME 0x00000000000000000000000000000002LL +#define VALID_TOTALTIME 0x00000000000000000000000000000004LL +#define VALID_TOTALDISTANCE 0x00000000000000000000000000000008LL +#define VALID_MAXIMUMSPEED 0x00000000000000000000000000000010LL +#define VALID_CALORIES 0x00000000000000000000000000000020LL +#define VALID_AVGHEARTRATE 0x00000000000000000000000000000040LL +#define VALID_MAXHEARTRATE 0x00000000000000000000000000000080LL +#define VALID_ACTIVITYTYPE 0x00000000000000000000000000000100LL +#define VALID_INTENSITY 0x00000000000000000000000000000200LL +#define VALID_TRIGGERMETHOD 0x00000000000000000000000000000400LL +#define VALID_TIME 0x00000000000000000000000000000800LL +#define VALID_POSITION 0x00000000000000000000000000001000LL +#define VALID_DISTANCE 0x00000000000000000000000000002000LL +#define VALID_HEARTRATE 0x00000000000000000000000000004000LL + + +#endif // COMMON_H diff --git a/plugins/import/ImportTCX/cposition.cpp b/plugins/import/ImportTCX/cposition.cpp new file mode 100644 index 0000000..067aea5 --- /dev/null +++ b/plugins/import/ImportTCX/cposition.cpp @@ -0,0 +1,42 @@ +#include "cposition.h" + + +cPosition::cPosition(const cPosition& rhs) +{ + this->m_dLatitude = rhs.m_dLatitude; + this->m_dLongitude = rhs.m_dLongitude; + this->m_dElevation = rhs.m_dElevation; +} + +cPosition::cPosition(double dLatitude, double dLongitude, double dElevation) +{ + m_dLatitude = dLatitude; + m_dLongitude = dLongitude; + m_dElevation = dElevation; +} + +double cPosition::getLatitude() +{ + return(m_dLatitude); +} + +double cPosition::getLongitude() +{ + return(m_dLongitude); +} + +double cPosition::getElevation() +{ + return(m_dElevation); +} + +cPosition &cPosition::operator=(const cPosition &rhs) +{ + if(this != &rhs) + { + this->m_dLatitude = rhs.m_dLatitude; + this->m_dLongitude = rhs.m_dLongitude; + this->m_dElevation = rhs.m_dElevation; + } + return(*this); +} diff --git a/plugins/import/ImportTCX/cposition.h b/plugins/import/ImportTCX/cposition.h new file mode 100644 index 0000000..4eebd23 --- /dev/null +++ b/plugins/import/ImportTCX/cposition.h @@ -0,0 +1,20 @@ +#ifndef CPOSITION_H +#define CPOSITION_H + + +class cPosition +{ +public: + cPosition(const cPosition& rhs); + cPosition(double dLatitude = 0, double dLongitude = 0, double dElevation = 0); + double getLatitude(); + double getLongitude(); + double getElevation(); + cPosition& operator=(const cPosition& rhs); +protected: + double m_dLatitude; + double m_dLongitude; + double m_dElevation; +}; + +#endif // CPOSITION_H diff --git a/plugins/import/ImportTCX/ctrackpoint.cpp b/plugins/import/ImportTCX/ctrackpoint.cpp new file mode 100644 index 0000000..dc3d0fb --- /dev/null +++ b/plugins/import/ImportTCX/ctrackpoint.cpp @@ -0,0 +1,91 @@ +#include "ctrackpoint.h" + + +cTrackpoint::cTrackpoint(cLap* lpParent) +{ + m_dwValid = 0; + m_lpParent = lpParent; +} + +cTrackpoint::cTrackpoint(cLap* lpParent, uint32_t dwTime) +{ + m_dwValid = 0; + m_lpParent = lpParent; + setTime(dwTime); +} + +cLap* cTrackpoint::getParent() +{ + return(m_lpParent); +} + +bool cTrackpoint::setTime(uint32_t dwTime) +{ + m_dwTime = dwTime; + m_dwValid |= VALID_TIME; + return(true); +} + +uint32_t cTrackpoint::getTime() +{ + if(m_dwValid & VALID_TIME) + return(m_dwTime); + return(0); +} + +bool cTrackpoint::setPosition(const cPosition& Position) +{ + m_Position = Position; + m_dwValid |= VALID_POSITION; + return(true); +} + +cPosition cTrackpoint::getPosition() +{ + if(m_dwValid & VALID_POSITION) + return(m_Position); + return(cPosition(0, 0)); +} + +bool cTrackpoint::setDistance(double dDistance) +{ + m_dDistance = dDistance; + m_dwValid |= VALID_DISTANCE; + return(true); +} + +double cTrackpoint::getDistance() +{ + if(m_dwValid & VALID_DISTANCE) + return(m_dDistance); + else + return(0); +} + +bool cTrackpoint::setHeartRate(uint16_t dwHeartRate) +{ + if(!dwHeartRate) + return(false); + + m_dwHeartRate = dwHeartRate; + m_dwValid |= VALID_HEARTRATE; + return(true); +} + +uint16_t cTrackpoint::getHeartRate() +{ + if(m_dwValid & VALID_HEARTRATE) + return(m_dwHeartRate); + return(0); +} + +cTrackpointList::cTrackpointList() +{ +} + +cTrackpoint* cTrackpointList::add(cLap* lpParent, uint32_t dwTime) +{ + cTrackpoint* lpTrackpoint = new cTrackpoint(lpParent, dwTime); + this->append(lpTrackpoint); + return(lpTrackpoint); +} diff --git a/plugins/import/ImportTCX/ctrackpoint.h b/plugins/import/ImportTCX/ctrackpoint.h new file mode 100644 index 0000000..e326546 --- /dev/null +++ b/plugins/import/ImportTCX/ctrackpoint.h @@ -0,0 +1,53 @@ +#ifndef CTRACKPOINT_H +#define CTRACKPOINT_H + + +#include +#include +#include +#include + +#include "common.h" + +#include "cposition.h" + + +class cLap; + +class cTrackpoint +{ +public: + cTrackpoint(cLap* lpParent = 0); + cTrackpoint(cLap* lpParent, uint32_t dwTime); + + cLap* getParent(); + + bool setTime(uint32_t dwTime); + uint32_t getTime(); + + bool setPosition(const cPosition& Position); + cPosition getPosition(); + + bool setDistance(double dDistance); + double getDistance(); + + bool setHeartRate(uint16_t dwHeartRate); + uint16_t getHeartRate(); +protected: + uint64_t m_dwValid; + cLap* m_lpParent; + uint32_t m_dwTime; + cPosition m_Position; + double m_dDistance; + uint16_t m_dwHeartRate; +}; + +Q_DECLARE_METATYPE(cTrackpoint); + +class cTrackpointList : public QList +{ +public: + cTrackpointList(); + cTrackpoint* add(cLap* lpParent, uint32_t dwTime); +}; +#endif // CTRACKPOINT_H diff --git a/qtTrainingChart.pro b/qtTrainingChart.pro new file mode 100644 index 0000000..a64f979 --- /dev/null +++ b/qtTrainingChart.pro @@ -0,0 +1,18 @@ +#------------------------------------------------- +# +# Project created by QtCreator 2011-04-28T09:26:30 +# +#------------------------------------------------- + +QT += core gui + +TARGET = qtTrainingChart +TEMPLATE = app + + +SOURCES += main.cpp\ + cmainwindow.cpp + +HEADERS += cmainwindow.h + +FORMS += cmainwindow.ui diff --git a/qtTrainingChart.pro.user b/qtTrainingChart.pro.user new file mode 100644 index 0000000..0db84eb --- /dev/null +++ b/qtTrainingChart.pro.user @@ -0,0 +1,167 @@ + + + + ProjectExplorer.Project.ActiveTarget + 0 + + + ProjectExplorer.Project.EditorSettings + + Default + + + + ProjectExplorer.Project.Target.0 + + Desktop + + Qt4ProjectManager.Target.DesktopTarget + 1 + 0 + 0 + + + + qmake + + QtProjectManager.QMakeBuildStep + + false + + + Make + + Qt4ProjectManager.MakeStep + false + + + + 2 + Build + + ProjectExplorer.BuildSteps.Build + + + + Make + + Qt4ProjectManager.MakeStep + true + + clean + + + + 1 + Clean + + ProjectExplorer.BuildSteps.Clean + + 2 + false + + Debug + + Qt4ProjectManager.Qt4BuildConfiguration + 2 + /data/Projects/QTCreator/TrainingChart/qtTrainingChart-build-desktop + 2 + 0 + false + + + + + qmake + + QtProjectManager.QMakeBuildStep + + false + + + Make + + Qt4ProjectManager.MakeStep + false + + + + 2 + Build + + ProjectExplorer.BuildSteps.Build + + + + Make + + Qt4ProjectManager.MakeStep + true + + clean + + + + 1 + Clean + + ProjectExplorer.BuildSteps.Clean + + 2 + false + + Release + + Qt4ProjectManager.Qt4BuildConfiguration + 0 + /data/Projects/QTCreator/TrainingChart/qtTrainingChart-build-desktop + 2 + 0 + false + + 2 + + + 0 + Deploy + + ProjectExplorer.BuildSteps.Deploy + + 1 + No deployment + + ProjectExplorer.DefaultDeployConfiguration + + 1 + + qtTrainingChart + + Qt4ProjectManager.Qt4RunConfiguration + 2 + + qtTrainingChart.pro + false + false + + false + + 3768 + true + false + + 1 + + + + ProjectExplorer.Project.TargetCount + 1 + + + ProjectExplorer.Project.Updater.EnvironmentId + {7ffca601-cf8d-4c1d-9b60-0a68859cdd79} + + + ProjectExplorer.Project.Updater.FileVersion + 8 + +