commit c60b275f7058d8b24dd091c964dd1b94a0ce0276 Author: birkeh Date: Wed Oct 19 19:17:40 2016 +0200 first commit diff --git a/Halbmarathon.qtp b/Halbmarathon.qtp new file mode 100644 index 0000000..cc097aa --- /dev/null +++ b/Halbmarathon.qtp @@ -0,0 +1,639 @@ + + + + Herwig + Birke + 19680524 + 172 + 71 + + + true + 195 +
+ Grundlagen Ausdauer 1 + 60 + 70 + +
+ Grundlagen Ausdauer 2 + 70 + 75 + +
+ Kraft Ausdauer + 75 + 80 + +
+ Schnellkraft + 80 + 90 + +
+ 90 + 100 + +
+ Halbmarathon - 1:30 + 20100816 + + Intervall RT + + Running + Intervall RT + + Aufwärmen + 1 + 2000 +
GA 1 (117 - 136) + 328 + +
+ + Intervall + 4 + 2000 +
SK (156 - 175) + 248 + + 700 + GA 1 (117 - 136) + 360 + 252 +
+ + Auslaufen + 1 + 2000 +
GA 1 (117 - 136) + 328 + +
+
+
+ + Ruhiger Dauerlauf + + Running + Ruhiger Dauerlauf + + Dauerlauf + 1 + 12000 +
GA 2 (136 - 146) + 305 + +
+
+
+ + Tempolauf + + Running + Tempolauf + + Aufwärmen + 1 + 3000 +
GA 1 (117 - 136) + 360 + +
+ + Tempolauf + 1 + 10000 +
SK (156 - 175) + 265 + +
+ + Auslaufen + 1 + 2000 +
GA 1 (117 - 136) + 360 + +
+
+
+ + Ruhiger DL + + Running + Ruhiger DL + + Dauerlauf + 1 + 12000 +
GA 2 (136 - 146) + 300 + +
+
+
+ + Langer DL + + Running + Langer DL + + Dauerlauf + 1 + 19000 +
GA 1 (117 - 136) + 345 + +
+
+
+ + Intervall + + Running + Intervall + + Aufwärmen + 1 + 3000 +
GA 1 (117 - 136) + 360 + +
+ + Intervall + 4 + 1000 +
SK (156 - 175) + 231 + + 400 + GA 1 (117 - 136) + 360 + 144 +
+ + Auslaufen + 1 + 3000 +
GA 1 (117 - 136) + 360 + +
+
+
+ + Ruhiger DL + + Running + Ruhiger DL + + Dauerlauf + 1 + 12000 +
GA 1 (117 - 136) + 300 + +
+
+
+ + Tempolauf + + Running + Tempolauf + + Aufwärmen + 1 + 3000 +
GA 1 (117 - 136) + 360 + +
+ + Tempolauf + 1 + 10000 +
SK (156 - 175) + 265 + +
+ + Auslaufen + 1 + 2000 +
GA 1 (117 - 136) + 360 + +
+
+
+ + Ruhiger DL + + Running + Ruhiger DL + + Dauerlauf + 1 + 12000 +
GA 1 (117 - 136) + 300 + +
+
+
+ + Langer DL + + Running + Langer DL + + Dauerlauf + 1 + 21000 +
GA 1 (117 - 136) + 345 + +
+
+
+ + Intervall RT + + Running + Intervall RT + + Aufwärmen + 1 + 2000 +
GA 1 (117 - 136) + 328 + +
+ + Intervall + 4 + 2000 +
SK (156 - 175) + 248 + + 700 + GA 1 (117 - 136) + 360 + 252 +
+ + Auslaufen + 1 + 2000 +
GA 1 (117 - 136) + 328 + +
+
+
+ + Ruhiger DL + + Running + Ruhiger DL + + Dauerlauf + 1 + 12000 +
GA 1 (117 - 136) + 300 + +
+
+
+ + Tempolauf + + Running + Tempolauf + + Aufwärmen + 1 + 3000 +
GA 1 (117 - 136) + 360 + +
+ + Tempolauf + 1 + 10000 +
SK (156 - 175) + 265 + +
+ + Auslaufen + 1 + 2000 +
GA 1 (117 - 136) + 360 + +
+
+
+ + Ruhiger DL + + Running + Ruhiger DL + + Dauerlauf + 1 + 12000 +
GA 1 (117 - 136) + 300 + +
+
+
+ + Langer DL + + Running + Langer DL + + Dauerlauf + 1 + 23000 +
GA 1 (117 - 136) + 345 + +
+
+
+ + Intervall + + Running + Intervall + + Aufwärmen + 1 + 3000 +
GA 1 (117 - 136) + 360 + +
+ + Intervall + 5 + 1000 +
SK (156 - 175) + 231 + + 400 + GA 1 (117 - 136) + 360 + 144 +
+ + Auslaufen + 1 + 3000 +
GA 1 (117 - 136) + 360 + +
+
+
+ + Ruhiger DL + + Running + Ruhiger DL + + Dauerlauf + 1 + 12000 +
GA 1 (117 - 136) + 300 + +
+
+
+ + Jogging Steigerungen + + Running + Jogging Steigerungen + + Jogging Steigerungen + 1 + 8000 +
GA 1 (117 - 136) + 360 + +
+
+
+ + Speed Up + + Running + Jogging Steigerungen + + Jogging Steigerungen + 1 + 5000 +
GA 1 (117 - 136) + 360 + +
+
+
+ + Rennen 10km + + Running + Rennen 10km + + Rennen + 1 + 10000 +
SWA (175 - 195) + 235 + +
+
+
+ + Jogging + + Running + Jogging + + Jogging + 1 + 16000 +
GA 1 (117 - 136) + 345 + +
+
+
+ + Ruhiger DL + + Running + Ruhiger DL + + Ruhiger DL + 1 + 14000 +
GA 1 (117 - 136) + 300 + +
+
+
+ + Kurzer Tempolauf + + Running + Kurzer Tempolauf + + Aufwärmen + 1 + 3000 +
GA 1 (117 - 136) + 360 + +
+ + Tempolauf + 1 + 5000 +
SK (156 - 175) + 265 + +
+ + Auslaufen + 1 + 2000 +
GA 1 (117 - 136) + 360 + +
+
+
+ + Langer DL + + Running + Langer DL + + Dauerlauf + 1 + 19000 +
GA 1 (117 - 136) + 345 + +
+
+
+ + Jogging + + Running + Jogging + + Jogging + 1 + 11000 +
GA 1 (117 - 136) + 345 + +
+
+
+ + Intervall RT + + Running + Intervall RT + + Aufwärmen + 1 + 2000 +
GA 1 (117 - 136) + 328 + +
+ + Intervall + 3 + 3000 +
SK (156 - 175) + 248 + + 1000 + GA 1 (117 - 136) + 360 + 360 +
+ + Auslaufen + 1 + 2000 +
GA 1 (117 - 136) + 328 + +
+
+
+ + Jogging + + Running + Jogging + + Jogging + 1 + 8000 +
GA 1 (117 - 136) + 345 + +
+
+
+ + peed Up + + Running + Jogging Steigerungen + + Jogging Steigerungen + 1 + 5000 +
GA 1 (117 - 136) + 360 + +
+
+
+ + Halbmarathon + + Running + Halbmarathon + + Halbmarathon + 1 + 21100 +
SWA (175 - 195) + 247 + +
+
+
+
diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..0d8b6a3 --- /dev/null +++ b/Makefile @@ -0,0 +1,416 @@ +############################################################################# +# Makefile for building: qtTrainingPlan +# Generated by qmake (2.01a) (Qt 4.6.2) on: Mon May 31 07:25:13 2010 +# Project: qtTrainingPlan.pro +# Template: app +# Command: /usr/bin/qmake-qt4 -spec /usr/share/qt4/mkspecs/linux-g++ -unix CONFIG+=debug -o Makefile qtTrainingPlan.pro +############################################################################# + +####### Compiler, tools and options + +CC = gcc +CXX = g++ +DEFINES = -DQT_WEBKIT_LIB -DQT_XML_LIB -DQT_GUI_LIB -DQT_CORE_LIB -DQT_SHARED +CFLAGS = -pipe -g -Wall -W -D_REENTRANT $(DEFINES) +CXXFLAGS = -pipe -g -Wall -W -D_REENTRANT $(DEFINES) +INCPATH = -I/usr/share/qt4/mkspecs/linux-g++ -I. -I/usr/include/qt4/QtCore -I/usr/include/qt4/QtGui -I/usr/include/qt4/QtXml -I/usr/include/qt4/QtWebKit -I/usr/include/qt4 -I. -I. +LINK = g++ +LFLAGS = +LIBS = $(SUBLIBS) -L/usr/lib -lQtWebKit -lQtXml -lQtGui -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 = main.cpp \ + mainwindow.cpp \ + ctraining.cpp \ + common.cpp \ + ctime.cpp \ + cclientdata.cpp \ + cedittraining.cpp \ + ceditday.cpp \ + ceditsession.cpp \ + cedittask.cpp \ + cedittasks.cpp \ + cexportpdf.cpp \ + ceditsport.cpp \ + cedithr.cpp moc_mainwindow.cpp \ + moc_cedittraining.cpp \ + moc_ceditday.cpp \ + moc_ceditsession.cpp \ + moc_cedittask.cpp \ + moc_cedittasks.cpp \ + moc_cexportpdf.cpp \ + moc_ceditsport.cpp \ + moc_cedithr.cpp +OBJECTS = main.o \ + mainwindow.o \ + ctraining.o \ + common.o \ + ctime.o \ + cclientdata.o \ + cedittraining.o \ + ceditday.o \ + ceditsession.o \ + cedittask.o \ + cedittasks.o \ + cexportpdf.o \ + ceditsport.o \ + cedithr.o \ + moc_mainwindow.o \ + moc_cedittraining.o \ + moc_ceditday.o \ + moc_ceditsession.o \ + moc_cedittask.o \ + moc_cedittasks.o \ + moc_cexportpdf.o \ + moc_ceditsport.o \ + moc_cedithr.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/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/debug.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 \ + qtTrainingPlan.pro +QMAKE_TARGET = qtTrainingPlan +DESTDIR = +TARGET = qtTrainingPlan + +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): ui_mainwindow.h ui_cedittraining.h ui_ceditday.h ui_ceditsession.h ui_cedittask.h ui_cedittasks.h ui_cexportpdf.h ui_ceditsport.h ui_cedithr.h $(OBJECTS) + $(LINK) $(LFLAGS) -o $(TARGET) $(OBJECTS) $(OBJCOMP) $(LIBS) + +Makefile: qtTrainingPlan.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/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/debug.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/libQtWebKit.prl \ + /usr/lib/libQtXml.prl \ + /usr/lib/libQtGui.prl \ + /usr/lib/libQtCore.prl + $(QMAKE) -spec /usr/share/qt4/mkspecs/linux-g++ -unix CONFIG+=debug -o Makefile qtTrainingPlan.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/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/debug.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/libQtWebKit.prl: +/usr/lib/libQtXml.prl: +/usr/lib/libQtGui.prl: +/usr/lib/libQtCore.prl: +qmake: FORCE + @$(QMAKE) -spec /usr/share/qt4/mkspecs/linux-g++ -unix CONFIG+=debug -o Makefile qtTrainingPlan.pro + +dist: + @$(CHK_DIR_EXISTS) .tmp/qtTrainingPlan1.0.0 || $(MKDIR) .tmp/qtTrainingPlan1.0.0 + $(COPY_FILE) --parents $(SOURCES) $(DIST) .tmp/qtTrainingPlan1.0.0/ && $(COPY_FILE) --parents mainwindow.h ctraining.h common.h ctime.h cclientdata.h cedittraining.h ceditday.h ceditsession.h cedittask.h cedittasks.h cexportpdf.h ceditsport.h cedithr.h .tmp/qtTrainingPlan1.0.0/ && $(COPY_FILE) --parents main.cpp mainwindow.cpp ctraining.cpp common.cpp ctime.cpp cclientdata.cpp cedittraining.cpp ceditday.cpp ceditsession.cpp cedittask.cpp cedittasks.cpp cexportpdf.cpp ceditsport.cpp cedithr.cpp .tmp/qtTrainingPlan1.0.0/ && $(COPY_FILE) --parents mainwindow.ui cedittraining.ui ceditday.ui ceditsession.ui cedittask.ui cedittasks.ui cexportpdf.ui ceditsport.ui cedithr.ui .tmp/qtTrainingPlan1.0.0/ && $(COPY_FILE) --parents qtTrainingPlan_de_AT.ts qtTrainingPlan_de_DE.ts .tmp/qtTrainingPlan1.0.0/ && (cd `dirname .tmp/qtTrainingPlan1.0.0` && $(TAR) qtTrainingPlan1.0.0.tar qtTrainingPlan1.0.0 && $(COMPRESS) qtTrainingPlan1.0.0.tar) && $(MOVE) `dirname .tmp/qtTrainingPlan1.0.0`/qtTrainingPlan1.0.0.tar.gz . && $(DEL_FILE) -r .tmp/qtTrainingPlan1.0.0 + + +clean:compiler_clean + -$(DEL_FILE) $(OBJECTS) + -$(DEL_FILE) *~ core *.core + + +####### Sub-libraries + +distclean: clean + -$(DEL_FILE) $(TARGET) + -$(DEL_FILE) Makefile + + +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: moc_mainwindow.cpp moc_cedittraining.cpp moc_ceditday.cpp moc_ceditsession.cpp moc_cedittask.cpp moc_cedittasks.cpp moc_cexportpdf.cpp moc_ceditsport.cpp moc_cedithr.cpp +compiler_moc_header_clean: + -$(DEL_FILE) moc_mainwindow.cpp moc_cedittraining.cpp moc_ceditday.cpp moc_ceditsession.cpp moc_cedittask.cpp moc_cedittasks.cpp moc_cexportpdf.cpp moc_ceditsport.cpp moc_cedithr.cpp +moc_mainwindow.cpp: cclientdata.h \ + ctime.h \ + common.h \ + ctraining.h \ + mainwindow.h + /usr/bin/moc-qt4 $(DEFINES) $(INCPATH) mainwindow.h -o moc_mainwindow.cpp + +moc_cedittraining.cpp: cedittraining.h + /usr/bin/moc-qt4 $(DEFINES) $(INCPATH) cedittraining.h -o moc_cedittraining.cpp + +moc_ceditday.cpp: ceditday.h + /usr/bin/moc-qt4 $(DEFINES) $(INCPATH) ceditday.h -o moc_ceditday.cpp + +moc_ceditsession.cpp: ceditsession.h + /usr/bin/moc-qt4 $(DEFINES) $(INCPATH) ceditsession.h -o moc_ceditsession.cpp + +moc_cedittask.cpp: ctime.h \ + common.h \ + cedittask.h + /usr/bin/moc-qt4 $(DEFINES) $(INCPATH) cedittask.h -o moc_cedittask.cpp + +moc_cedittasks.cpp: ctime.h \ + common.h \ + cedittasks.h + /usr/bin/moc-qt4 $(DEFINES) $(INCPATH) cedittasks.h -o moc_cedittasks.cpp + +moc_cexportpdf.cpp: cexportpdf.h + /usr/bin/moc-qt4 $(DEFINES) $(INCPATH) cexportpdf.h -o moc_cexportpdf.cpp + +moc_ceditsport.cpp: ceditsport.h + /usr/bin/moc-qt4 $(DEFINES) $(INCPATH) ceditsport.h -o moc_ceditsport.cpp + +moc_cedithr.cpp: cedithr.h + /usr/bin/moc-qt4 $(DEFINES) $(INCPATH) cedithr.h -o moc_cedithr.cpp + +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: ui_mainwindow.h ui_cedittraining.h ui_ceditday.h ui_ceditsession.h ui_cedittask.h ui_cedittasks.h ui_cexportpdf.h ui_ceditsport.h ui_cedithr.h +compiler_uic_clean: + -$(DEL_FILE) ui_mainwindow.h ui_cedittraining.h ui_ceditday.h ui_ceditsession.h ui_cedittask.h ui_cedittasks.h ui_cexportpdf.h ui_ceditsport.h ui_cedithr.h +ui_mainwindow.h: mainwindow.ui + /usr/bin/uic-qt4 mainwindow.ui -o ui_mainwindow.h + +ui_cedittraining.h: cedittraining.ui + /usr/bin/uic-qt4 cedittraining.ui -o ui_cedittraining.h + +ui_ceditday.h: ceditday.ui + /usr/bin/uic-qt4 ceditday.ui -o ui_ceditday.h + +ui_ceditsession.h: ceditsession.ui + /usr/bin/uic-qt4 ceditsession.ui -o ui_ceditsession.h + +ui_cedittask.h: cedittask.ui + /usr/bin/uic-qt4 cedittask.ui -o ui_cedittask.h + +ui_cedittasks.h: cedittasks.ui + /usr/bin/uic-qt4 cedittasks.ui -o ui_cedittasks.h + +ui_cexportpdf.h: cexportpdf.ui + /usr/bin/uic-qt4 cexportpdf.ui -o ui_cexportpdf.h + +ui_ceditsport.h: ceditsport.ui + /usr/bin/uic-qt4 ceditsport.ui -o ui_ceditsport.h + +ui_cedithr.h: cedithr.ui + /usr/bin/uic-qt4 cedithr.ui -o ui_cedithr.h + +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: compiler_moc_header_clean compiler_uic_clean + +####### Compile + +main.o: main.cpp mainwindow.h \ + cclientdata.h \ + ctime.h \ + common.h \ + ctraining.h + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o main.o main.cpp + +mainwindow.o: mainwindow.cpp mainwindow.h \ + cclientdata.h \ + ctime.h \ + common.h \ + ctraining.h \ + ui_mainwindow.h \ + ceditsport.h \ + cedittraining.h \ + ceditday.h \ + ceditsession.h \ + cedittask.h \ + cedittasks.h \ + cexportpdf.h + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o mainwindow.o mainwindow.cpp + +ctraining.o: ctraining.cpp ctraining.h \ + common.h \ + ctime.h + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o ctraining.o ctraining.cpp + +common.o: common.cpp common.h \ + ctime.h + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o common.o common.cpp + +ctime.o: ctime.cpp ctime.h \ + common.h + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o ctime.o ctime.cpp + +cclientdata.o: cclientdata.cpp cclientdata.h \ + ctime.h \ + common.h + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o cclientdata.o cclientdata.cpp + +cedittraining.o: cedittraining.cpp cedittraining.h \ + ui_cedittraining.h \ + common.h \ + ctime.h + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o cedittraining.o cedittraining.cpp + +ceditday.o: ceditday.cpp ceditday.h \ + ui_ceditday.h \ + common.h \ + ctime.h + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o ceditday.o ceditday.cpp + +ceditsession.o: ceditsession.cpp ceditsession.h \ + ui_ceditsession.h \ + common.h \ + ctime.h + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o ceditsession.o ceditsession.cpp + +cedittask.o: cedittask.cpp cedittask.h \ + ctime.h \ + common.h \ + ui_cedittask.h + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o cedittask.o cedittask.cpp + +cedittasks.o: cedittasks.cpp cedittasks.h \ + ctime.h \ + common.h \ + ui_cedittasks.h + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o cedittasks.o cedittasks.cpp + +cexportpdf.o: cexportpdf.cpp cexportpdf.h \ + ui_cexportpdf.h + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o cexportpdf.o cexportpdf.cpp + +ceditsport.o: ceditsport.cpp ceditsport.h \ + ui_ceditsport.h \ + common.h \ + ctime.h + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o ceditsport.o ceditsport.cpp + +cedithr.o: cedithr.cpp cedithr.h \ + ui_cedithr.h + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o cedithr.o cedithr.cpp + +moc_mainwindow.o: moc_mainwindow.cpp + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o moc_mainwindow.o moc_mainwindow.cpp + +moc_cedittraining.o: moc_cedittraining.cpp + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o moc_cedittraining.o moc_cedittraining.cpp + +moc_ceditday.o: moc_ceditday.cpp + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o moc_ceditday.o moc_ceditday.cpp + +moc_ceditsession.o: moc_ceditsession.cpp + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o moc_ceditsession.o moc_ceditsession.cpp + +moc_cedittask.o: moc_cedittask.cpp + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o moc_cedittask.o moc_cedittask.cpp + +moc_cedittasks.o: moc_cedittasks.cpp + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o moc_cedittasks.o moc_cedittasks.cpp + +moc_cexportpdf.o: moc_cexportpdf.cpp + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o moc_cexportpdf.o moc_cexportpdf.cpp + +moc_ceditsport.o: moc_ceditsport.cpp + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o moc_ceditsport.o moc_ceditsport.cpp + +moc_cedithr.o: moc_cedithr.cpp + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o moc_cedithr.o moc_cedithr.cpp + +####### Install + +install: FORCE + +uninstall: FORCE + +FORCE: + diff --git a/README.md b/README.md new file mode 100644 index 0000000..95ac558 Binary files /dev/null and b/README.md differ diff --git a/cclientdata.cpp b/cclientdata.cpp new file mode 100644 index 0000000..11a5bd6 --- /dev/null +++ b/cclientdata.cpp @@ -0,0 +1,479 @@ +#include "cclientdata.h" + +// DAY +CClientData::CClientData(int iDay, const QString& szDesc) +{ + Clear(false); + m_lpDay = new DATA_DAY; + m_lpDay->iNum = iDay; + m_lpDay->szDesc = szDesc; +} + +// SESSION +CClientData::CClientData(int iSession, const QString& szDesc, const QString& szSport) +{ + Clear(false); + m_lpSession = new DATA_SESSION; + m_lpSession->iNum = iSession; + m_lpSession->szDesc = szDesc; + m_lpSession->szSport = szSport; +} + +// TASK +CClientData::CClientData(int iTask, const QString& szDesc, uint32_t dwCount, CTime Time, uint32_t dwDist, const QString& szHR, uint32_t dwPace, CTime PauseTime, uint32_t dwPauseDist, const QString& szPauseHR, uint32_t dwPausePace) +{ + Clear(false); + m_lpTask = new DATA_TASK; + m_lpTask->iNum = iTask; + m_lpTask->szDesc = szDesc; + m_lpTask->dwCount = dwCount; + m_lpTask->Time = Time; + m_lpTask->dwDist = dwDist; + m_lpTask->szHR = szHR; + m_lpTask->dwPace = dwPace; + m_lpTask->PauseTime = PauseTime; + m_lpTask->dwPauseDist = dwPauseDist; + m_lpTask->szPauseHR = szPauseHR; + m_lpTask->dwPausePace = dwPausePace; +} + +// SPORT +CClientData::CClientData(const QString& szSport, uint32_t dwMaxHR, bool bPace) +{ + Clear(false); + m_lpSport = new DATA_SPORT; + m_lpSport->szName = szSport; + m_lpSport->dwMaxHR = dwMaxHR; + m_lpSport->bPace = bPace; +} + +// +CClientData::CClientData(const QString& szName, const QString& szDesc, uint32_t dwMin, uint32_t dwMax) +{ + Clear(false); + m_lpHR = new DATA_HR; + m_lpHR->szName = szName; + m_lpHR->szDesc = szDesc; + m_lpHR->dwMin = dwMin; + m_lpHR->dwMax = dwMax; +} + +CClientData::CClientData(const QString& szFirstName, const QString& szLastName, const QDate& DayOfBirth, uint32_t dwHeight, uint32_t dwWeight) +{ + Clear(false); + m_lpPerson = new DATA_PERSON; + m_lpPerson->szFirstName = szFirstName; + m_lpPerson->szLastName = szLastName; + m_lpPerson->DayOfBirth = DayOfBirth; + m_lpPerson->dwHeight = dwHeight; + m_lpPerson->dwWeight = dwWeight; +} + +CClientData::~CClientData() +{ + Clear(); +} + +void CClientData::Clear(bool bDelete) +{ + if(bDelete) + { + DELETE(m_lpDay); + DELETE(m_lpSession); + DELETE(m_lpTask); + DELETE(m_lpSport); + DELETE(m_lpHR); + DELETE(m_lpPerson); + } + m_lpDay = 0; + m_lpSession = 0; + m_lpTask = 0; + m_lpSport = 0; + m_lpHR = 0; + m_lpPerson = 0; +} + +void CClientData::SetDay(int iDay) +{ + if(m_lpDay) + m_lpDay->iNum = iDay; +} + +void CClientData::SetDayDesc(const QString& szDesc) +{ + if(m_lpDay) + m_lpDay->szDesc = szDesc; +} + +void CClientData::SetSession(int iSession) +{ + if(m_lpSession) + m_lpSession->iNum = iSession; +} + +void CClientData::SetSessionDesc(const QString& szDesc) +{ + if(m_lpSession) + m_lpSession->szDesc = szDesc; +} + +void CClientData::SetSessionSport(const QString& szSport) +{ + if(m_lpSession) + m_lpSession->szSport = szSport; +} + +void CClientData::SetTask(int iTask) +{ + if(m_lpTask) + m_lpTask->iNum = iTask; +} + +void CClientData::SetTaskDesc(const QString& szDesc) +{ + if(m_lpTask) + m_lpTask->szDesc = szDesc; +} +void CClientData::SetTaskCount(uint32_t dwCount) +{ + if(m_lpTask) + m_lpTask->dwCount = dwCount; +} + +void CClientData::SetTaskTime(const CTime& Time) +{ + if(m_lpTask) + m_lpTask->Time = Time; +} + +void CClientData::SetTaskDist(uint32_t dwDist) +{ + if(m_lpTask) + m_lpTask->dwDist = dwDist; +} + +void CClientData::SetTaskHR(const QString& szHR) +{ + if(m_lpTask) + m_lpTask->szHR = szHR; +} + +void CClientData::SetTaskPace(uint32_t dwPace) +{ + if(m_lpTask) + m_lpTask->dwPace = dwPace; +} + +void CClientData::SetTaskPauseTime(const CTime& PauseTime) +{ + if(m_lpTask && m_lpTask->dwCount > 1) + m_lpTask->PauseTime = PauseTime; +} + +void CClientData::SetTaskPauseDist(uint32_t dwPauseDist) +{ + if(m_lpTask && m_lpTask->dwCount > 1) + m_lpTask->dwPauseDist = dwPauseDist; +} + +void CClientData::SetTaskPauseHR(const QString& szPauseHR) +{ + if(m_lpTask && m_lpTask->dwCount > 1) + m_lpTask->szPauseHR = szPauseHR; +} + +void CClientData::SetTaskPausePace(uint32_t dwPausePace) +{ + if(m_lpTask && m_lpTask->dwCount > 1) + m_lpTask->dwPausePace = dwPausePace; +} + +void CClientData::SetSportName(const QString& szName) +{ + if(m_lpSport) + m_lpSport->szName = szName; +} + +void CClientData::SetSportMaxHR(uint32_t dwMaxHR) +{ + if(m_lpSport) + m_lpSport->dwMaxHR = dwMaxHR; +} + +void CClientData::SetSportPace(bool bPace) +{ + if(m_lpSport) + m_lpSport->bPace = bPace; +} + +void CClientData::SetHRName(const QString& szName) +{ + if(m_lpHR) + m_lpHR->szName = szName; +} + +void CClientData::SetHRDesc(const QString& szDesc) +{ + if(m_lpHR) + m_lpHR->szDesc = szDesc; +} + +void CClientData::SetHRMin(uint32_t dwMin) +{ + if(m_lpHR) + m_lpHR->dwMin = dwMin; +} + +void CClientData::SetHRMax(uint32_t dwMax) +{ + if(m_lpHR) + m_lpHR->dwMax = dwMax; +} + +void CClientData::SetPersonFirstName(const QString& szFirstName) +{ + if(m_lpPerson) + m_lpPerson->szFirstName = szFirstName; +} + +void CClientData::SetPersonLastName(const QString& szLastName) +{ + if(m_lpPerson) + m_lpPerson->szLastName = szLastName; +} + +void CClientData::SetPersonDayOfBirth(const QDate& DayOfBirth) +{ + if(m_lpPerson) + m_lpPerson->DayOfBirth = DayOfBirth; +} + +void CClientData::SetPersonHeight(uint32_t dwHeight) +{ + if(m_lpPerson) + m_lpPerson->dwHeight = dwHeight; +} + +void CClientData::SetPersonWeight(uint32_t dwWeight) +{ + if(m_lpPerson) + m_lpPerson->dwWeight = dwWeight; +} + +int CClientData::GetDay() +{ + if(m_lpDay) + return(m_lpDay->iNum); + return(-1); +} + +QString CClientData::GetDayDesc(bool bWithDayNum) +{ + if(m_lpDay) + { + if(bWithDayNum) + return(m_lpDay->szDesc); + else + return(m_lpDay->szDesc.mid(m_lpDay->szDesc.indexOf(")")+1)); + } + return(QString("")); +} + +int CClientData::GetSession() +{ + if(m_lpSession) + return(m_lpSession->iNum); + return(-1); +} + +QString CClientData::GetSessionDesc() +{ + if(m_lpSession) + return(m_lpSession->szDesc); + return(QString("")); +} + +QString CClientData::GetSessionSport() +{ + if(m_lpSession) + return(m_lpSession->szSport); + return(QString("")); +} + +int CClientData::GetTask() +{ + if(m_lpTask) + return(m_lpTask->iNum); + return(-1); +} + +QString CClientData::GetTaskDesc() +{ + if(m_lpTask) + return(m_lpTask->szDesc); + return(QString("")); +} + +uint32_t CClientData::GetTaskCount() +{ + if(m_lpTask) + return(m_lpTask->dwCount); + return(0); +} + +CTime CClientData::GetTaskTime() +{ + if(m_lpTask) + return(m_lpTask->Time); + return(CTime(0, 0, 0)); +} + +uint32_t CClientData::GetTaskDist() +{ + if(m_lpTask) + return(m_lpTask->dwDist); + return(0); +} + +QString CClientData::GetTaskHR() +{ + if(m_lpTask) + return(m_lpTask->szHR); + return(QString("")); +} + +uint32_t CClientData::GetTaskPace() +{ + if(m_lpTask) + return(m_lpTask->dwPace); + return(0); +} + +CTime CClientData::GetTaskPauseTime() +{ + if(m_lpTask && m_lpTask->dwCount > 1) + return(m_lpTask->PauseTime); + return(CTime(0, 0, 0)); +} + +uint32_t CClientData::GetTaskPauseDist() +{ + if(m_lpTask && m_lpTask->dwCount > 1) + return(m_lpTask->dwPauseDist); + return(0); +} + +QString CClientData::GetTaskPauseHR() +{ + if(m_lpTask && m_lpTask->dwCount > 1) + return(m_lpTask->szPauseHR); + return(QString("")); +} + +uint32_t CClientData::GetTaskPausePace() +{ + if(m_lpTask && m_lpTask->dwCount > 1) + return(m_lpTask->dwPausePace); + return(0); +} + +QString CClientData::GetSportName() +{ + if(m_lpSport) + return(m_lpSport->szName); + return(QString("")); +} + +uint32_t CClientData::GetSportMaxHR() +{ + if(m_lpSport) + return(m_lpSport->dwMaxHR); + return(0); +} + +bool CClientData::GetSportPace() +{ + if(m_lpSport) + return(m_lpSport->bPace); + return(0); +} + +QString CClientData::GetHRName() +{ + if(m_lpHR) + return(m_lpHR->szName); + return(QString("")); +} + +QString CClientData::GetHRDesc() +{ + if(m_lpHR) + return(m_lpHR->szDesc); + return(QString("")); +} + +uint32_t CClientData::GetHRMin() +{ + if(m_lpHR) + return(m_lpHR->dwMin); + return(0); +} + +uint32_t CClientData::GetHRMax() +{ + if(m_lpHR) + return(m_lpHR->dwMax); + return(0); +} + +QString CClientData::GetPersonFirstName() +{ + if(m_lpPerson) + return(m_lpPerson->szFirstName); + return(QString("")); +} + +QString CClientData::GetPersonLastName() +{ + if(m_lpPerson) + return(m_lpPerson->szLastName); + return(QString("")); +} + +QDate CClientData::GetPersonDayOfBirth() +{ + if(m_lpPerson) + return(m_lpPerson->DayOfBirth); + return(QDate(0, 0, 0)); +} + +uint32_t CClientData::GetPersonHeight() +{ + if(m_lpPerson) + return(m_lpPerson->dwHeight); + return(0); +} + +uint32_t CClientData::GetPersonWeight() +{ + if(m_lpPerson) + return(m_lpPerson->dwWeight); + return(0); +} + +int CClientData::GetType() +{ + if(m_lpTask) + return(CClientData::TASK); + else if(m_lpSession) + return(CClientData::SESSION); + else if(m_lpDay) + return(CClientData::DAY); + else if(m_lpSport) + return(CClientData::SPORT); + else if(m_lpHR) + return(CClientData::HR); + else if(m_lpPerson) + return(CClientData::PERSON); + return(0); +} diff --git a/cclientdata.h b/cclientdata.h new file mode 100644 index 0000000..c85fa61 --- /dev/null +++ b/cclientdata.h @@ -0,0 +1,153 @@ +#ifndef CCLIENTDATA_H +#define CCLIENTDATA_H + + +#include "ctime.h" +#include "common.h" + + +typedef struct _DATA_PERSON +{ + QString szFirstName; + QString szLastName; + QDate DayOfBirth; + uint32_t dwHeight; + uint32_t dwWeight; +} DATA_PERSON, *LPDATA_PERSON; + +typedef struct _DATA_HR +{ + QString szName; + QString szDesc; + uint32_t dwMin; + uint32_t dwMax; +} DATA_HR, *LPDATA_HR; + +typedef struct _DATA_SPORT +{ + QString szName; + uint32_t dwMaxHR; + bool bPace; +} DATA_SPORT, *LPDATA_SPORT; + +typedef struct _DATA_DAY +{ + int iNum; + QString szDesc; +} DATA_DAY, *LPDATA_DAY; + +typedef struct _DATA_SESSION +{ + int iNum; + QString szDesc; + QString szSport; +} DATA_SESSION, *LPDATA_SESSION; + +typedef struct _DATA_TASK +{ + int iNum; + QString szDesc; + uint32_t dwCount; + CTime Time; + uint32_t dwDist; + QString szHR; + uint32_t dwPace; + CTime PauseTime; + uint32_t dwPauseDist; + QString szPauseHR; + uint32_t dwPausePace; +} DATA_TASK, *LPDATA_TASK; + +class CClientData +{ +public: + enum FLAGS + { + DAY = 1, + SESSION = 2, + TASK = 3, + SPORT = 4, + HR = 5, + PERSON = 6 + }; + // DAY + CClientData(int iDay, const QString& szDesc); + // SESSION + CClientData(int iSession, const QString& szDesc, const QString& szSport); + // TASK + CClientData(int iTask, const QString& szDesc, uint32_t dwCount, CTime Time, uint32_t dwDist, const QString& szHR, uint32_t dwPace, CTime PauseTime = CTime(0, 0, 0), uint32_t dwPauseDist = 0, const QString& szPauseHR = QString(""), uint32_t dwPausePace = 0); + // SPORT + CClientData(const QString& szSport, uint32_t dwMaxHR, bool bPace); + // + CClientData(const QString& szName, const QString& szDesc, uint32_t dwMin, uint32_t dwMax); + CClientData(const QString& szFirstName, const QString& szLastName, const QDate& DayOfBirth, uint32_t dwHeight, uint32_t dwWeight); + ~CClientData(); + + void Clear(bool bDelete = true); + void SetDay(int iDay); + void SetDayDesc(const QString& szDesc); + void SetSession(int iSession); + void SetSessionDesc(const QString& szDesc); + void SetSessionSport(const QString& szSport); + void SetTask(int iTask); + void SetTaskDesc(const QString& szDesc); + void SetTaskCount(uint32_t dwCount); + void SetTaskTime(const CTime& Time); + void SetTaskDist(uint32_t dwDist); + void SetTaskHR(const QString& szHR); + void SetTaskPace(uint32_t dwPace); + void SetTaskPauseTime(const CTime& PauseTime); + void SetTaskPauseDist(uint32_t dwPauseDist); + void SetTaskPauseHR(const QString& szPauseHR); + void SetTaskPausePace(uint32_t dwPausePace); + void SetSportName(const QString& szName); + void SetSportMaxHR(uint32_t dwMaxHR); + void SetSportPace(bool bPace); + void SetHRName(const QString& szName); + void SetHRDesc(const QString& szDesc); + void SetHRMin(uint32_t dwMin); + void SetHRMax(uint32_t dwMax); + void SetPersonFirstName(const QString& szFirstName); + void SetPersonLastName(const QString& szLastName); + void SetPersonDayOfBirth(const QDate& DayOfBirth); + void SetPersonHeight(uint32_t dwHeight); + void SetPersonWeight(uint32_t dwWeight); + int GetDay(); + QString GetDayDesc(bool bWithDayNum = true); + int GetSession(); + QString GetSessionDesc(); + QString GetSessionSport(); + int GetTask(); + QString GetTaskDesc(); + uint32_t GetTaskCount(); + CTime GetTaskTime(); + uint32_t GetTaskDist(); + QString GetTaskHR(); + uint32_t GetTaskPace(); + CTime GetTaskPauseTime(); + uint32_t GetTaskPauseDist(); + QString GetTaskPauseHR(); + uint32_t GetTaskPausePace(); + QString GetSportName(); + uint32_t GetSportMaxHR(); + bool GetSportPace(); + QString GetHRName(); + QString GetHRDesc(); + uint32_t GetHRMin(); + uint32_t GetHRMax(); + QString GetPersonFirstName(); + QString GetPersonLastName(); + QDate GetPersonDayOfBirth(); + uint32_t GetPersonHeight(); + uint32_t GetPersonWeight(); + int GetType(); +protected: + LPDATA_DAY m_lpDay; + LPDATA_SESSION m_lpSession; + LPDATA_TASK m_lpTask; + LPDATA_SPORT m_lpSport; + LPDATA_HR m_lpHR; + LPDATA_PERSON m_lpPerson; +}; + +#endif // CCLIENTDATA_H diff --git a/ceditday.cpp b/ceditday.cpp new file mode 100644 index 0000000..6be80a6 --- /dev/null +++ b/ceditday.cpp @@ -0,0 +1,58 @@ +#include "ceditday.h" +#include "ui_ceditday.h" +#include "common.h" + +CEditDay::CEditDay(QWidget *parent) : + QDialog(parent), + m_ui(new Ui::CEditDay) +{ + m_ui->setupUi(this); +} + +CEditDay::~CEditDay() +{ + delete m_ui; +} + +void CEditDay::changeEvent(QEvent *e) +{ + QDialog::changeEvent(e); + switch (e->type()) { + case QEvent::LanguageChange: + m_ui->retranslateUi(this); + break; + default: + break; + } +} + +void CEditDay::on_buttonBox_accepted() +{ + if(!m_ui->m_lpDesc->text().length()) + { + MESSAGE(tr("Description is empty!")); + return; + } + accept(); +} + +void CEditDay::on_buttonBox_rejected() +{ + reject(); +} + +int CEditDay::GetDay() +{ + return(m_ui->m_lpDay->value()); +} + +QString CEditDay::GetDesc() +{ + return(m_ui->m_lpDesc->text()); +} + +void CEditDay::Set(int iDay, const QString& szDesc) +{ + m_ui->m_lpDay->setValue(iDay); + m_ui->m_lpDesc->setText(szDesc); +} diff --git a/ceditday.h b/ceditday.h new file mode 100644 index 0000000..9cf9083 --- /dev/null +++ b/ceditday.h @@ -0,0 +1,31 @@ +#ifndef CEDITDAY_H +#define CEDITDAY_H + +#include + +namespace Ui { + class CEditDay; +} + +class CEditDay : public QDialog { + Q_OBJECT +public: + CEditDay(QWidget *parent = 0); + ~CEditDay(); + + int GetDay(); + QString GetDesc(); + void Set(int iDay, const QString& szDesc); + +protected: + void changeEvent(QEvent *e); + +private: + Ui::CEditDay *m_ui; + +private slots: + void on_buttonBox_rejected(); + void on_buttonBox_accepted(); +}; + +#endif // CEDITDAY_H diff --git a/ceditday.ui b/ceditday.ui new file mode 100644 index 0000000..aa89f4f --- /dev/null +++ b/ceditday.ui @@ -0,0 +1,112 @@ + + + CEditDay + + + + 0 + 0 + 268 + 116 + + + + Day + + + + + + + + Day: + + + + + + + 1 + + + 999 + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + + + Description: + + + + + + + + + + + + Qt::Horizontal + + + QDialogButtonBox::Cancel|QDialogButtonBox::Ok + + + + + + + + + buttonBox + accepted() + CEditDay + accept() + + + 248 + 254 + + + 157 + 274 + + + + + buttonBox + rejected() + CEditDay + reject() + + + 316 + 260 + + + 286 + 274 + + + + + diff --git a/cedithr.cpp b/cedithr.cpp new file mode 100644 index 0000000..b12cb02 --- /dev/null +++ b/cedithr.cpp @@ -0,0 +1,70 @@ +#include "common.h" +#include "cedithr.h" +#include "ui_cedithr.h" + +CEditHR::CEditHR(QWidget *parent) : + QDialog(parent), + ui(new Ui::CEditHR) +{ + ui->setupUi(this); +} + +CEditHR::~CEditHR() +{ + delete ui; +} + +void CEditHR::changeEvent(QEvent *e) +{ + QDialog::changeEvent(e); + switch (e->type()) { + case QEvent::LanguageChange: + ui->retranslateUi(this); + break; + default: + break; + } +} + +QString CEditHR::GetName() +{ + return(ui->m_lpName->text()); +} + +QString CEditHR::GetDesc() +{ + return(ui->m_lpDesc->text()); +} + +uint32_t CEditHR::GetMin() +{ + return(ui->m_lpMinHR->value()); +} + +uint32_t CEditHR::GetMax() +{ + return(ui->m_lpMaxHR->value()); +} + +void CEditHR::Set(const QString& szName, const QString& szDesc, uint32_t dwMin, uint32_t dwMax) +{ + ui->m_lpName->setText(szName); + ui->m_lpDesc->setText(szDesc); + ui->m_lpMinHR->setValue(dwMin); + ui->m_lpMaxHR->setValue(dwMax); +} + +void CEditHR::on_buttonBox_accepted() +{ + if(!ui->m_lpName->text().length()) + { + MESSAGE(tr("Name is empty!")); + return; + } + accept(); +} + +void CEditHR::on_buttonBox_rejected() +{ + reject(); +} diff --git a/cedithr.h b/cedithr.h new file mode 100644 index 0000000..aa021a5 --- /dev/null +++ b/cedithr.h @@ -0,0 +1,34 @@ +#ifndef CEDITHR_H +#define CEDITHR_H + +#include +#include + + +namespace Ui { + class CEditHR; +} + +class CEditHR : public QDialog { + Q_OBJECT +public: + CEditHR(QWidget *parent = 0); + ~CEditHR(); + + QString GetName(); + QString GetDesc(); + uint32_t GetMin(); + uint32_t GetMax(); + void Set(const QString& szName, const QString& szDesc, uint32_t dwMin, uint32_t dwMax); +protected: + void changeEvent(QEvent *e); + +private: + Ui::CEditHR *ui; + +private slots: + void on_buttonBox_rejected(); + void on_buttonBox_accepted(); +}; + +#endif // CEDITHR_H diff --git a/cedithr.ui b/cedithr.ui new file mode 100644 index 0000000..42e5c36 --- /dev/null +++ b/cedithr.ui @@ -0,0 +1,132 @@ + + + CEditHR + + + + 0 + 0 + 286 + 184 + + + + Heartrate + + + + + + + + Name: + + + + + + + + + + + + + + Desc: + + + + + + + + + + + + Heartrate + + + + + + Min (%): + + + + + + + 100 + + + 1 + + + + + + + Max (%): + + + + + + + 100 + + + + + + + + + + Qt::Horizontal + + + QDialogButtonBox::Cancel|QDialogButtonBox::Ok + + + + + + + + + buttonBox + accepted() + CEditHR + accept() + + + 248 + 254 + + + 157 + 274 + + + + + buttonBox + rejected() + CEditHR + reject() + + + 316 + 260 + + + 286 + 274 + + + + + diff --git a/ceditsession.cpp b/ceditsession.cpp new file mode 100644 index 0000000..0e541ce --- /dev/null +++ b/ceditsession.cpp @@ -0,0 +1,82 @@ +#include "ceditsession.h" +#include "ui_ceditsession.h" +#include "common.h" + +CEditSession::CEditSession(QWidget *parent) : + QDialog(parent), + m_ui(new Ui::CEditSession) +{ + m_ui->setupUi(this); +} + +CEditSession::~CEditSession() +{ + delete m_ui; +} + +void CEditSession::changeEvent(QEvent *e) +{ + QDialog::changeEvent(e); + switch (e->type()) { + case QEvent::LanguageChange: + m_ui->retranslateUi(this); + break; + default: + break; + } +} + +void CEditSession::on_buttonBox_accepted() +{ + if(!m_ui->m_lpDesc->text().length()) + { + MESSAGE(tr("Description is empty!")); + return; + } + if(!m_ui->m_lpDay->currentText().length()) + { + MESSAGE(tr("No day selected!")); + return; + } + if(!m_ui->m_lpSport->currentText().length()) + { + MESSAGE(tr("No sport selected!")); + return; + } + accept(); +} + +void CEditSession::on_buttonBox_rejected() +{ + reject(); +} + +QString CEditSession::GetDay() +{ + return(m_ui->m_lpDay->currentText()); +} + +QString CEditSession::GetDesc() +{ + return(m_ui->m_lpDesc->text()); +} + +QString CEditSession::GetSport() +{ + return(m_ui->m_lpSport->currentText()); +} + +void CEditSession::Set(const QStringList& DayList, const QStringList& SportList, const QString& szDay, const QString& szDesc, const QString& szSport) +{ + int i; + + for(i = 0;i < DayList.size();i++) + m_ui->m_lpDay->addItem(DayList.at(i)); + + for(i = 0;i < SportList.size();i++) + m_ui->m_lpSport->addItem(SportList.at(i)); + + m_ui->m_lpDay->setCurrentIndex(m_ui->m_lpDay->findText(szDay)); + m_ui->m_lpDesc->setText(szDesc); + m_ui->m_lpSport->setCurrentIndex(m_ui->m_lpSport->findText(szSport)); +} diff --git a/ceditsession.h b/ceditsession.h new file mode 100644 index 0000000..ee865c6 --- /dev/null +++ b/ceditsession.h @@ -0,0 +1,32 @@ +#ifndef CEDITSESSION_H +#define CEDITSESSION_H + +#include + +namespace Ui { + class CEditSession; +} + +class CEditSession : public QDialog { + Q_OBJECT +public: + CEditSession(QWidget *parent = 0); + ~CEditSession(); + + QString GetDay(); + QString GetDesc(); + QString GetSport(); + void Set(const QStringList& DayList, const QStringList& SportList, const QString& szDay, const QString& szDesc, const QString& szSport); + +protected: + void changeEvent(QEvent *e); + +private: + Ui::CEditSession *m_ui; + +private slots: + void on_buttonBox_accepted(); + void on_buttonBox_rejected(); +}; + +#endif // CEDITSESSION_H diff --git a/ceditsession.ui b/ceditsession.ui new file mode 100644 index 0000000..cc0c8f8 --- /dev/null +++ b/ceditsession.ui @@ -0,0 +1,70 @@ + + + CEditSession + + + + 0 + 0 + 194 + 150 + + + + Session + + + + + + + + Description: + + + + + + + + + + + + + + Day: + + + + + + + + + + + + + + Sport: + + + + + + + + + + + + QDialogButtonBox::Cancel|QDialogButtonBox::Ok + + + + + + + + diff --git a/ceditsport.cpp b/ceditsport.cpp new file mode 100644 index 0000000..ced5b2f --- /dev/null +++ b/ceditsport.cpp @@ -0,0 +1,66 @@ +#include "ceditsport.h" +#include "ui_ceditsport.h" +#include "common.h" + +CEditSport::CEditSport(QWidget *parent) : + QDialog(parent), + ui(new Ui::CEditSport) +{ + ui->setupUi(this); + ui->m_lpPace->setChecked(true); +} + +CEditSport::~CEditSport() +{ + delete ui; +} + +void CEditSport::changeEvent(QEvent *e) +{ + QDialog::changeEvent(e); + switch (e->type()) { + case QEvent::LanguageChange: + ui->retranslateUi(this); + break; + default: + break; + } +} + +void CEditSport::on_buttonBox_accepted() +{ + if(!ui->m_lpName->text().length()) + { + MESSAGE(tr("Name is empty!")); + return; + } + accept(); +} + +void CEditSport::on_buttonBox_rejected() +{ + reject(); +} + +QString CEditSport::GetName() +{ + return(ui->m_lpName->text()); +} + +int CEditSport::GetMaxHR() +{ + return(ui->m_lpMaxHR->value()); +} + +bool CEditSport::GetPace() +{ + return(ui->m_lpPace->isChecked()); +} + +void CEditSport::Set(const QString& szName, int iMaxHR, bool bPace) +{ + ui->m_lpName->setText(szName); + ui->m_lpMaxHR->setValue(iMaxHR); + ui->m_lpPace->setChecked(bPace); + ui->m_lpSpeed->setChecked(!bPace); +} diff --git a/ceditsport.h b/ceditsport.h new file mode 100644 index 0000000..ecf24ed --- /dev/null +++ b/ceditsport.h @@ -0,0 +1,31 @@ +#ifndef CEDITSPORT_H +#define CEDITSPORT_H + +#include + +namespace Ui { + class CEditSport; +} + +class CEditSport : public QDialog { + Q_OBJECT +public: + CEditSport(QWidget *parent = 0); + ~CEditSport(); + + QString GetName(); + int GetMaxHR(); + bool GetPace(); + void Set(const QString& szName, int iMaxHR, bool bPace); +protected: + void changeEvent(QEvent *e); + +private: + Ui::CEditSport *ui; + +private slots: + void on_buttonBox_rejected(); + void on_buttonBox_accepted(); +}; + +#endif // CEDITSPORT_H diff --git a/ceditsport.ui b/ceditsport.ui new file mode 100644 index 0000000..c0ded26 --- /dev/null +++ b/ceditsport.ui @@ -0,0 +1,120 @@ + + + CEditSport + + + + 0 + 0 + 194 + 145 + + + + Sport + + + + + + + + Name: + + + + + + + + + + + + + + Max. HR: + + + + + + + 1 + + + 250 + + + 180 + + + + + + + + + + + Pace + + + + + + + Speed + + + + + + + + + Qt::Horizontal + + + QDialogButtonBox::Cancel|QDialogButtonBox::Ok + + + + + + + + + buttonBox + accepted() + CEditSport + accept() + + + 248 + 254 + + + 157 + 274 + + + + + buttonBox + rejected() + CEditSport + reject() + + + 316 + 260 + + + 286 + 274 + + + + + diff --git a/cedittask.cpp b/cedittask.cpp new file mode 100644 index 0000000..73a8e9d --- /dev/null +++ b/cedittask.cpp @@ -0,0 +1,351 @@ +#include "cedittask.h" +#include "ui_cedittask.h" +#include "common.h" +#include "ctime.h" + +CEditTask::CEditTask(QWidget *parent) : + QDialog(parent), + m_ui(new Ui::CEditTask) +{ + m_bChanging = false; + m_ui->setupUi(this); + m_ui->m_lpGroupPause->setVisible(false); +} + +CEditTask::~CEditTask() +{ + delete m_ui; +} + +void CEditTask::changeEvent(QEvent *e) +{ + QDialog::changeEvent(e); + switch (e->type()) { + case QEvent::LanguageChange: + m_ui->retranslateUi(this); + break; + default: + break; + } +} + +void CEditTask::on_buttonBox_accepted() +{ + if(!m_ui->m_lpDesc->text().length()) + { + MESSAGE(tr("Description is empty!")); + return; + } + if(!m_ui->m_lpHR->currentText().length()) + { + MESSAGE(tr("No heart rate selected!")); + return; + } + if(m_ui->m_lpCount->value() > 1 && !m_ui->m_lpPauseHR->currentText().length()) + { + MESSAGE(tr("No pause heart rate selected!")); + return; + } + accept(); +} + +void CEditTask::on_buttonBox_rejected() +{ + reject(); +} + + +void CEditTask::on_m_lpCount_valueChanged(int iCount) +{ + if(iCount > 1) + m_ui->m_lpGroupPause->setVisible(true); + else + m_ui->m_lpGroupPause->setVisible(false); + + CalcTotal(); +} + +QString CEditTask::GetDesc() +{ + return(m_ui->m_lpDesc->text()); +} + +uint32_t CEditTask::GetCount() +{ + return(m_ui->m_lpCount->value()); +} + +CTime CEditTask::GetTime() +{ + return((CTime)m_ui->m_lpTime->time()); +} + +uint32_t CEditTask::GetDist() +{ + return(m_ui->m_lpDist->value()); +} + +QString CEditTask::GetHR() +{ + return(m_ui->m_lpHR->currentText()); +} + +uint32_t CEditTask::GetPace() +{ + QTime Time = m_ui->m_lpPace->time(); + return((uint32_t)Time.hour()*3600+(uint32_t)Time.minute()*60+(uint32_t)Time.second()); +} + +CTime CEditTask::GetPauseTime() +{ + return(m_ui->m_lpPauseTime->time()); +} + +uint32_t CEditTask::GetPauseDist() +{ + return(m_ui->m_lpPauseDist->value()); +} + +QString CEditTask::GetPauseHR() +{ + return(m_ui->m_lpPauseHR->currentText()); +} + +uint32_t CEditTask::GetPausePace() +{ + QTime Time = m_ui->m_lpPausePace->time(); + return((uint32_t)Time.hour()*3600+(uint32_t)Time.minute()*60+(uint32_t)Time.second()); +} + +void CEditTask::Set(const QStringList& HRList, const QString& szDesc, uint32_t dwCount, const QTime& Time, uint32_t dwDist, const QString& szHR, uint32_t dwPace, const QTime& PauseTime, uint32_t dwPauseDist, const QString& szPauseHR, uint32_t dwPausePace) +{ + int i; + + for(i = 0;i < HRList.size();i++) + { + m_ui->m_lpHR->addItem(HRList.at(i)); + m_ui->m_lpPauseHR->addItem(HRList.at(i)); + } + + m_ui->m_lpDesc->setText(szDesc); + m_ui->m_lpCount->setValue(dwCount); + m_ui->m_lpTime->setTime(Time); + m_ui->m_lpDist->setValue(dwDist); + m_ui->m_lpHR->setCurrentIndex(m_ui->m_lpHR->findText(szHR)); + m_ui->m_lpPace->setTime(QTime(HOURS(dwPace), MINUTES(dwPace), SECONDS(dwPace))); + if(dwCount > 1) + { + m_ui->m_lpGroupPause->setVisible(true); + m_ui->m_lpPauseTime->setTime(PauseTime); + m_ui->m_lpPauseDist->setValue(dwPauseDist); + m_ui->m_lpPauseHR->setCurrentIndex(m_ui->m_lpHR->findText(szPauseHR)); + m_ui->m_lpPausePace->setTime(QTime(HOURS(dwPausePace), MINUTES(dwPausePace), SECONDS(dwPausePace))); + } + + CalcTotal(); +} + +void CEditTask::on_m_lpTime_timeChanged(QTime time) +{ + if(m_bChanging) + { + m_bChanging = false; + return; + } + uint32_t dwTime = CTime(time).toDWORD(); + uint32_t dwDist = m_ui->m_lpDist->value(); + uint32_t dwPace = CTime(m_ui->m_lpPace->time()).toDWORD(); + + if(!dwTime) + return; + + if(dwDist) + { + m_bChanging = true; + dwPace = dwTime*1000/dwDist; + m_ui->m_lpPace->setTime(QTime(HOURS(dwPace), MINUTES(dwPace), SECONDS(dwPace))); + } + else if(dwPace) + { + m_bChanging = true; + dwDist = dwPace*dwTime*1000; + m_ui->m_lpDist->setValue(dwDist); + } + + CalcTotal(); +} + +void CEditTask::on_m_lpDist_valueChanged(int dist) +{ + if(m_bChanging) + { + m_bChanging = false; + return; + } + uint32_t dwTime = CTime(m_ui->m_lpTime->time()).toDWORD(); + uint32_t dwDist = dist; + uint32_t dwPace = CTime(m_ui->m_lpPace->time()).toDWORD(); + + if(!dwDist) + return; + + if(dwTime) + { + m_bChanging = true; + dwPace = dwTime*1000/dwDist; + m_ui->m_lpPace->setTime(QTime(HOURS(dwPace), MINUTES(dwPace), SECONDS(dwPace))); + } + else if(dwPace) + { + m_bChanging = true; + dwDist = dwPace*dwTime*1000; + m_ui->m_lpDist->setValue(dwDist); + } + + CalcTotal(); +} + +void CEditTask::on_m_lpPace_timeChanged(QTime time) +{ + if(m_bChanging) + { + m_bChanging = false; + return; + } + uint32_t dwTime = CTime(m_ui->m_lpTime->time()).toDWORD(); + uint32_t dwDist = m_ui->m_lpDist->value(); + uint32_t dwPace = CTime(time).toDWORD(); + + if(!dwPace) + return; + + if(dwDist) + { + m_bChanging = true; + dwTime = dwPace*dwDist/1000; + m_ui->m_lpTime->setTime(QTime(HOURS(dwTime), MINUTES(dwTime), SECONDS(dwTime))); + } + else if(dwTime) + { + m_bChanging = true; + dwDist = dwTime*dwPace*1000; + m_ui->m_lpDist->setValue(dwDist); + } + + CalcTotal(); +} + +void CEditTask::on_m_lpPauseTime_timeChanged(QTime time) +{ + if(m_bChanging) + { + m_bChanging = false; + return; + } + uint32_t dwTime = CTime(time).toDWORD(); + uint32_t dwDist = m_ui->m_lpPauseDist->value(); + uint32_t dwPace = CTime(m_ui->m_lpPausePace->time()).toDWORD(); + + if(!dwTime) + return; + + if(dwDist) + { + m_bChanging = true; + dwPace = dwTime*1000/dwDist; + m_ui->m_lpPausePace->setTime(QTime(HOURS(dwPace), MINUTES(dwPace), SECONDS(dwPace))); + } + else if(dwPace) + { + m_bChanging = true; + dwDist = dwPace*dwTime*1000; + m_ui->m_lpPauseDist->setValue(dwDist); + } + + CalcTotal(); +} + +void CEditTask::on_m_lpPauseDist_valueChanged(int dist) +{ + if(m_bChanging) + { + m_bChanging = false; + return; + } + uint32_t dwTime = CTime(m_ui->m_lpPauseTime->time()).toDWORD(); + uint32_t dwDist = dist; + uint32_t dwPace = CTime(m_ui->m_lpPausePace->time()).toDWORD(); + + if(!dwDist) + return; + + if(dwTime) + { + m_bChanging = true; + dwPace = dwTime*1000/dwDist; + m_ui->m_lpPausePace->setTime(QTime(HOURS(dwPace), MINUTES(dwPace), SECONDS(dwPace))); + } + else if(dwPace) + { + m_bChanging = true; + dwDist = dwPace*dwTime*1000; + m_ui->m_lpPauseDist->setValue(dwDist); + } + + CalcTotal(); +} + +void CEditTask::on_m_lpPausePace_timeChanged(QTime time) +{ + if(m_bChanging) + { + m_bChanging = false; + return; + } + uint32_t dwTime = CTime(m_ui->m_lpPauseTime->time()).toDWORD(); + uint32_t dwDist = m_ui->m_lpPauseDist->value(); + uint32_t dwPace = CTime(time).toDWORD(); + + if(!dwPace) + return; + + if(dwDist) + { + m_bChanging = true; + dwTime = dwPace*dwDist/1000; + m_ui->m_lpPauseTime->setTime(QTime(HOURS(dwTime), MINUTES(dwTime), SECONDS(dwTime))); + } + else if(dwTime) + { + m_bChanging = true; + dwDist = dwTime*dwPace*1000; + m_ui->m_lpPauseDist->setValue(dwDist); + } + + CalcTotal(); +} + +void CEditTask::CalcTotal() +{ + int iCount = m_ui->m_lpCount->value(); + uint32_t dwTime = CTime(m_ui->m_lpTime->time()).toDWORD(); + uint32_t dwDist = m_ui->m_lpDist->value(); + uint32_t dwPauseTime = CTime(m_ui->m_lpPauseTime->time()).toDWORD(); + uint32_t dwPauseDist = m_ui->m_lpPauseDist->value(); + uint32_t dwTotalTime; + uint32_t dwTotalDist; + + dwTotalTime = dwTime*iCount; + dwTotalDist = dwDist*iCount; + if(iCount > 1) + { + dwTotalTime += dwPauseTime*(iCount-1); + dwTotalDist += dwPauseDist*(iCount-1); + } + m_ui->m_lpTotalDist->setText(QString(tr("%1")).arg(dwTotalDist)); + + uint32_t h = HOURS(dwTotalTime); + uint32_t m = MINUTES(dwTotalTime); + uint32_t s = SECONDS(dwTotalTime); + m_ui->m_lpTotalTime->setTime(QTime(h, m, s)); +} diff --git a/cedittask.h b/cedittask.h new file mode 100644 index 0000000..08cf1af --- /dev/null +++ b/cedittask.h @@ -0,0 +1,49 @@ +#ifndef CEDITTASK_H +#define CEDITTASK_H + +#include +#include "ctime.h" + +namespace Ui { + class CEditTask; +} + +class CEditTask : public QDialog { + Q_OBJECT +public: + CEditTask(QWidget *parent = 0); + ~CEditTask(); + + QString GetDesc(); + uint32_t GetCount(); + CTime GetTime(); + uint32_t GetDist(); + QString GetHR(); + uint32_t GetPace(); + CTime GetPauseTime(); + uint32_t GetPauseDist(); + QString GetPauseHR(); + uint32_t GetPausePace(); + void Set(const QStringList& HRList, const QString& szDesc, uint32_t dwCount, const QTime& Time, uint32_t dwDist, const QString& szHR, uint32_t dwPace, const QTime& PauseTime, uint32_t dwPauseDist, const QString& szPauseHR, uint32_t dwPausePace); +protected: + void changeEvent(QEvent *e); + + void CalcTotal(); + bool m_bChanging; + +private: + Ui::CEditTask *m_ui; + +private slots: + void on_m_lpTime_timeChanged(QTime date); + void on_m_lpDist_valueChanged(int ); + void on_m_lpPace_timeChanged(QTime date); + void on_m_lpPauseTime_timeChanged(QTime date); + void on_m_lpPauseDist_valueChanged(int ); + void on_m_lpPausePace_timeChanged(QTime date); + void on_m_lpCount_valueChanged(int ); + void on_buttonBox_accepted(); + void on_buttonBox_rejected(); +}; + +#endif // CEDITTASK_H diff --git a/cedittask.ui b/cedittask.ui new file mode 100644 index 0000000..e980d95 --- /dev/null +++ b/cedittask.ui @@ -0,0 +1,320 @@ + + + CEditTask + + + + 0 + 0 + 366 + 332 + + + + Task + + + + + + + + Description: + + + + + + + + + + + + + + + + Count: + + + + + + + 1 + + + 999 + + + + + + + + + + + Tot. Time: + + + + + + + true + + + hh:mm:ss + + + + + + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + Tot. Dist.: + + + + + + + true + + + + + + + + + + + + + Basic + + + + + + + + Time: + + + + + + + hh:mm:ss + + + + + + + + + + + Distance: + + + + + + + 999999 + + + + + + + + + + + HR: + + + + + + + + + + + + + + Pace: + + + + + + + mm:ss + + + + + + + + + + + + true + + + Pause + + + + + + + + Time: + + + + + + + hh:mm:ss + + + + + + + + + + + Distance: + + + + + + + 999999 + + + + + + + + + + + HR: + + + + + + + + + + + + + + Pace: + + + + + + + mm:ss + + + + + + + + + + + + + + Qt::Horizontal + + + QDialogButtonBox::Cancel|QDialogButtonBox::Ok + + + + + + + + + buttonBox + accepted() + CEditTask + accept() + + + 248 + 254 + + + 157 + 274 + + + + + buttonBox + rejected() + CEditTask + reject() + + + 316 + 260 + + + 286 + 274 + + + + + diff --git a/cedittasks.cpp b/cedittasks.cpp new file mode 100644 index 0000000..b358660 --- /dev/null +++ b/cedittasks.cpp @@ -0,0 +1,352 @@ +#include "cedittasks.h" +#include "ui_cedittasks.h" + +CEditTaskS::CEditTaskS(QWidget *parent) : + QDialog(parent), + m_ui(new Ui::CEditTaskS) +{ + m_bChanging = false; + m_ui->setupUi(this); + m_ui->m_lpGroupPause->setVisible(false); +} + +CEditTaskS::~CEditTaskS() +{ + delete m_ui; +} + +void CEditTaskS::changeEvent(QEvent *e) +{ + QDialog::changeEvent(e); + switch (e->type()) { + case QEvent::LanguageChange: + m_ui->retranslateUi(this); + break; + default: + break; + } +} + +void CEditTaskS::on_buttonBox_accepted() +{ + if(!m_ui->m_lpDesc->text().length()) + { + MESSAGE(tr("Description is empty!")); + return; + } + if(!m_ui->m_lpHR->currentText().length()) + { + MESSAGE(tr("No heart rate selected!")); + return; + } + if(m_ui->m_lpCount->value() > 1 && !m_ui->m_lpPauseHR->currentText().length()) + { + MESSAGE(tr("No pause heart rate selected!")); + return; + } + accept(); +} + +void CEditTaskS::on_buttonBox_rejected() +{ + reject(); +} + +void CEditTaskS::on_m_lpCount_valueChanged(int iCount) +{ + if(iCount > 1) + m_ui->m_lpGroupPause->setVisible(true); + else + m_ui->m_lpGroupPause->setVisible(false); + + CalcTotal(); +} + +QString CEditTaskS::GetDesc() +{ + return(m_ui->m_lpDesc->text()); +} + +uint32_t CEditTaskS::GetCount() +{ + return(m_ui->m_lpCount->value()); +} + +CTime CEditTaskS::GetTime() +{ + return(m_ui->m_lpTime->time()); +} + +uint32_t CEditTaskS::GetDist() +{ + return(m_ui->m_lpDist->value()); +} + +QString CEditTaskS::GetHR() +{ + return(m_ui->m_lpHR->currentText()); +} + +uint32_t CEditTaskS::GetPace() +{ + if(!m_ui->m_lpSpeed->value()) + return(0); + return(3600/m_ui->m_lpSpeed->value()); +} + +CTime CEditTaskS::GetPauseTime() +{ + return(m_ui->m_lpPauseTime->time()); +} + +uint32_t CEditTaskS::GetPauseDist() +{ + return(m_ui->m_lpPauseDist->value()); +} + +QString CEditTaskS::GetPauseHR() +{ + return(m_ui->m_lpPauseHR->currentText()); +} + +uint32_t CEditTaskS::GetPausePace() +{ + if(!m_ui->m_lpPauseSpeed->value()) + return(0); + return(3600/m_ui->m_lpPauseSpeed->value()); +} + +void CEditTaskS::Set(const QStringList& HRList, const QString& szDesc, uint32_t dwCount, const QTime& Time, uint32_t dwDist, const QString& szHR, uint32_t dwPace, const QTime& PauseTime, uint32_t dwPauseDist, const QString& szPauseHR, uint32_t dwPausePace) +{ + int i; + + for(i = 0;i < HRList.size();i++) + { + m_ui->m_lpHR->addItem(HRList.at(i)); + m_ui->m_lpPauseHR->addItem(HRList.at(i)); + } + + m_ui->m_lpDesc->setText(szDesc); + m_ui->m_lpCount->setValue(dwCount); + m_ui->m_lpTime->setTime(Time); + m_ui->m_lpDist->setValue(dwDist); + m_ui->m_lpHR->setCurrentIndex(m_ui->m_lpHR->findText(szHR)); + if(dwPace) + m_ui->m_lpSpeed->setValue(3600/dwPace); + if(dwCount > 1) + { + m_ui->m_lpGroupPause->setVisible(true); + m_ui->m_lpPauseTime->setTime(PauseTime); + m_ui->m_lpPauseDist->setValue(dwPauseDist); + m_ui->m_lpPauseHR->setCurrentIndex(m_ui->m_lpHR->findText(szPauseHR)); + if(dwPausePace) + m_ui->m_lpPauseSpeed->setValue(3600/dwPausePace); + } + + CalcTotal(); +} + +void CEditTaskS::on_m_lpTime_timeChanged(QTime time) +{ + if(m_bChanging) + { + m_bChanging = false; + return; + } + uint32_t dwTime = CTime(time).toDWORD(); + uint32_t dwDist = m_ui->m_lpDist->value(); + uint32_t dwSpeed = m_ui->m_lpSpeed->value(); + + if(!dwTime) + return; + + if(dwDist) + { + m_bChanging = true; + dwSpeed = 3600*dwDist/dwTime/1000; + m_ui->m_lpSpeed->setValue(dwSpeed); + } + else if(dwSpeed) + { + m_bChanging = true; + dwDist = dwSpeed*dwTime*1000/3600; + m_ui->m_lpDist->setValue(dwDist); + } + + CalcTotal(); +} + +void CEditTaskS::on_m_lpDist_valueChanged(int ) +{ + if(m_bChanging) + { + m_bChanging = false; + return; + } + uint32_t dwTime = CTime(m_ui->m_lpTime->time()).toDWORD(); + uint32_t dwDist = m_ui->m_lpDist->value(); + uint32_t dwSpeed = m_ui->m_lpSpeed->value(); + + if(!dwDist) + return; + + if(dwTime) + { + m_bChanging = true; + dwSpeed = 3600*dwDist/dwTime/1000; + m_ui->m_lpSpeed->setValue(dwSpeed); + } + else if(dwSpeed) + { + m_bChanging = true; + dwDist = dwSpeed*dwTime*1000/3600; + m_ui->m_lpDist->setValue(dwDist); + } + + CalcTotal(); +} + +void CEditTaskS::on_m_lpSpeed_valueChanged(int speed) +{ + if(m_bChanging) + { + m_bChanging = false; + return; + } + uint32_t dwTime = CTime(m_ui->m_lpTime->time()).toDWORD(); + uint32_t dwDist = m_ui->m_lpDist->value(); + uint32_t dwSpeed = speed; + + if(!dwSpeed) + return; + + if(dwDist) + { + m_bChanging = true; + dwTime = dwDist*3600/dwSpeed/1000; + m_ui->m_lpTime->setTime(QTime(HOURS(dwTime), MINUTES(dwTime), SECONDS(dwTime))); + } + else if(dwTime) + { + m_bChanging = true; + dwDist = dwSpeed*dwTime*1000/3600; + m_ui->m_lpDist->setValue(dwDist); + } + + CalcTotal(); +} + +void CEditTaskS::on_m_lpPauseTime_timeChanged(QTime time) +{ + if(m_bChanging) + { + m_bChanging = false; + return; + } + uint32_t dwTime = CTime(time).toDWORD(); + uint32_t dwDist = m_ui->m_lpPauseDist->value(); + uint32_t dwSpeed = m_ui->m_lpPauseSpeed->value(); + + if(!dwTime) + return; + + if(dwDist) + { + m_bChanging = true; + dwSpeed = 3600*dwDist/dwTime/1000; + m_ui->m_lpPauseSpeed->setValue(dwSpeed); + } + else if(dwSpeed) + { + m_bChanging = true; + dwDist = dwSpeed*dwTime*1000/3600; + m_ui->m_lpPauseDist->setValue(dwDist); + } + + CalcTotal(); +} + +void CEditTaskS::on_m_lpPauseDist_valueChanged(int ) +{ + if(m_bChanging) + { + m_bChanging = false; + return; + } + uint32_t dwTime = CTime(m_ui->m_lpPauseTime->time()).toDWORD(); + uint32_t dwDist = m_ui->m_lpPauseDist->value(); + uint32_t dwSpeed = m_ui->m_lpPauseSpeed->value(); + + if(!dwDist) + return; + + if(dwTime) + { + m_bChanging = true; + dwSpeed = 3600*dwDist/dwTime/1000; + m_ui->m_lpPauseSpeed->setValue(dwSpeed); + } + else if(dwSpeed) + { + m_bChanging = true; + dwDist = dwSpeed*dwTime*1000/3600; + m_ui->m_lpPauseDist->setValue(dwDist); + } + + CalcTotal(); +} + +void CEditTaskS::on_m_lpPauseSpeed_valueChanged(int speed) +{ + if(m_bChanging) + { + m_bChanging = false; + return; + } + uint32_t dwTime = CTime(m_ui->m_lpPauseTime->time()).toDWORD(); + uint32_t dwDist = m_ui->m_lpPauseDist->value(); + uint32_t dwSpeed = speed; + + if(!dwSpeed) + return; + + if(dwDist) + { + m_bChanging = true; + dwTime = dwDist*3600/dwSpeed/1000; + m_ui->m_lpPauseTime->setTime(QTime(HOURS(dwTime), MINUTES(dwTime), SECONDS(dwTime))); + } + else if(dwTime) + { + m_bChanging = true; + dwDist = dwSpeed*dwTime*1000/3600; + m_ui->m_lpPauseDist->setValue(dwDist); + } + + CalcTotal(); +} + +void CEditTaskS::CalcTotal() +{ + int iCount = m_ui->m_lpCount->value(); + uint32_t dwTime = CTime(m_ui->m_lpTime->time()).toDWORD(); + uint32_t dwDist = m_ui->m_lpDist->value(); + uint32_t dwPauseTime = CTime(m_ui->m_lpPauseTime->time()).toDWORD(); + uint32_t dwPauseDist = m_ui->m_lpPauseDist->value(); + uint32_t dwTotalTime; + uint32_t dwTotalDist; + + dwTotalTime = dwTime*iCount; + dwTotalDist = dwDist*iCount; + if(iCount > 1) + { + dwTotalTime += dwPauseTime*(iCount-1); + dwTotalDist += dwPauseDist*(iCount-1); + } + m_ui->m_lpTotalDist->setText(QString(tr("%1")).arg(dwTotalDist)); + + uint32_t h = HOURS(dwTotalTime); + uint32_t m = MINUTES(dwTotalTime); + uint32_t s = SECONDS(dwTotalTime); + m_ui->m_lpTotalTime->setTime(QTime(h, m, s)); +} diff --git a/cedittasks.h b/cedittasks.h new file mode 100644 index 0000000..d986bfb --- /dev/null +++ b/cedittasks.h @@ -0,0 +1,51 @@ +#ifndef CEDITTASKS_H +#define CEDITTASKS_H + +#include +#include +#include "ctime.h" + +namespace Ui { + class CEditTaskS; +} + +class CEditTaskS : public QDialog { + Q_OBJECT +public: + CEditTaskS(QWidget *parent = 0); + ~CEditTaskS(); + + QString GetDesc(); + uint32_t GetCount(); + CTime GetTime(); + uint32_t GetDist(); + QString GetHR(); + uint32_t GetPace(); + CTime GetPauseTime(); + uint32_t GetPauseDist(); + QString GetPauseHR(); + uint32_t GetPausePace(); + void Set(const QStringList& HRList, const QString& szDesc, uint32_t dwCount, const QTime& Time, uint32_t dwDist, const QString& szHR, uint32_t dwPace, const QTime& PauseTime, uint32_t dwPauseDist, const QString& szPauseHR, uint32_t dwPausePace); + +protected: + void changeEvent(QEvent *e); + + void CalcTotal(); + bool m_bChanging; + +private: + Ui::CEditTaskS *m_ui; + +private slots: + void on_m_lpCount_valueChanged(int ); + void on_m_lpTime_timeChanged(QTime date); + void on_m_lpDist_valueChanged(int ); + void on_m_lpSpeed_valueChanged(int ); + void on_m_lpPauseTime_timeChanged(QTime date); + void on_m_lpPauseDist_valueChanged(int ); + void on_m_lpPauseSpeed_valueChanged(int ); + void on_buttonBox_accepted(); + void on_buttonBox_rejected(); +}; + +#endif // CEDITTASKS_H diff --git a/cedittasks.ui b/cedittasks.ui new file mode 100644 index 0000000..dcc4df4 --- /dev/null +++ b/cedittasks.ui @@ -0,0 +1,312 @@ + + + CEditTaskS + + + + 0 + 0 + 366 + 333 + + + + Task + + + + + + + + Description: + + + + + + + + + + + + + + + + Count: + + + + + + + 1 + + + 999 + + + + + + + + + + + Tot. Time: + + + + + + + true + + + hh:mm:ss + + + + + + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + Tot. Dist.: + + + + + + + true + + + + + + + + + + + + + Basic + + + + + + + + Time: + + + + + + + hh:mm:ss + + + + + + + + + + + Distance: + + + + + + + 999999 + + + + + + + + + + + HR: + + + + + + + + + + + + + + Speed: + + + + + + + + + + + + + + + true + + + Pause + + + + + + + + Time: + + + + + + + hh:mm:ss + + + + + + + + + + + Distance: + + + + + + + 999999 + + + + + + + + + + + HR: + + + + + + + + + + + + + + Speed: + + + + + + + + + + + + + + + + + Qt::Horizontal + + + QDialogButtonBox::Cancel|QDialogButtonBox::Ok + + + + + + + + + buttonBox + accepted() + CEditTaskS + accept() + + + 248 + 254 + + + 157 + 274 + + + + + buttonBox + rejected() + CEditTaskS + reject() + + + 316 + 260 + + + 286 + 274 + + + + + diff --git a/cedittraining.cpp b/cedittraining.cpp new file mode 100644 index 0000000..109df89 --- /dev/null +++ b/cedittraining.cpp @@ -0,0 +1,52 @@ +#include "cedittraining.h" +#include "ui_cedittraining.h" +#include "common.h" + +CEditTraining::CEditTraining(QWidget *parent) : + QDialog(parent), + m_ui(new Ui::CEditTraining) +{ + m_ui->setupUi(this); +} + +CEditTraining::~CEditTraining() +{ + delete m_ui; +} + +void CEditTraining::changeEvent(QEvent *e) +{ + QDialog::changeEvent(e); + switch (e->type()) { + case QEvent::LanguageChange: + m_ui->retranslateUi(this); + break; + default: + break; + } +} + +void CEditTraining::on_buttonBox_accepted() +{ + if(!m_ui->m_lpTraining->text().length()) + { + MESSAGE(tr("Name is empty!")); + return; + } + accept(); +} + +void CEditTraining::on_buttonBox_rejected() +{ + reject(); +} + +QString CEditTraining::GetTraining() +{ + return(m_ui->m_lpTraining->text()); +} + +void CEditTraining::SetTraining(const QString& szTraining) +{ + m_ui->m_lpTraining->setText(szTraining); +} diff --git a/cedittraining.h b/cedittraining.h new file mode 100644 index 0000000..9f08413 --- /dev/null +++ b/cedittraining.h @@ -0,0 +1,30 @@ +#ifndef CEDITTRAINING_H +#define CEDITTRAINING_H + +#include + +namespace Ui { + class CEditTraining; +} + +class CEditTraining : public QDialog { + Q_OBJECT +public: + CEditTraining(QWidget *parent = 0); + ~CEditTraining(); + + QString GetTraining(); + void SetTraining(const QString& szTraining); + +protected: + void changeEvent(QEvent *e); + +private: + Ui::CEditTraining *m_ui; + +private slots: + void on_buttonBox_rejected(); + void on_buttonBox_accepted(); +}; + +#endif // CEDITTRAINING_H diff --git a/cedittraining.ui b/cedittraining.ui new file mode 100644 index 0000000..5368b67 --- /dev/null +++ b/cedittraining.ui @@ -0,0 +1,81 @@ + + + CEditTraining + + + + 0 + 0 + 261 + 80 + + + + Training + + + + + + + + Qt::Horizontal + + + + Training: + + + + + + + + + + + Qt::Horizontal + + + QDialogButtonBox::Cancel|QDialogButtonBox::Ok + + + + + + + + + buttonBox + accepted() + CEditTraining + accept() + + + 248 + 254 + + + 157 + 274 + + + + + buttonBox + rejected() + CEditTraining + reject() + + + 316 + 260 + + + 286 + 274 + + + + + diff --git a/cexportpdf.cpp b/cexportpdf.cpp new file mode 100644 index 0000000..854d9b3 --- /dev/null +++ b/cexportpdf.cpp @@ -0,0 +1,127 @@ +#include +#include "cexportpdf.h" +#include "ui_cexportpdf.h" + + +CExportPDF::CExportPDF(QWidget *parent) : + QDialog(parent), + ui(new Ui::CExportPDF) +{ + ui->setupUi(this); + + ui->m_lpFormat->addItem("A0", QVariant(5)); + ui->m_lpFormat->addItem("A1", QVariant(6)); + ui->m_lpFormat->addItem("A2", QVariant(7)); + ui->m_lpFormat->addItem("A3", QVariant(8)); + ui->m_lpFormat->addItem("A4", QVariant(0)); + ui->m_lpFormat->addItem("A5", QVariant(9)); + ui->m_lpFormat->addItem("A6", QVariant(10)); + ui->m_lpFormat->addItem("A7", QVariant(11)); + ui->m_lpFormat->addItem("A8", QVariant(12)); + ui->m_lpFormat->addItem("A9", QVariant(13)); + ui->m_lpFormat->addItem("B0", QVariant(14)); + ui->m_lpFormat->addItem("B1", QVariant(15)); + ui->m_lpFormat->addItem("B2", QVariant(17)); + ui->m_lpFormat->addItem("B3", QVariant(18)); + ui->m_lpFormat->addItem("B4", QVariant(19)); + ui->m_lpFormat->addItem("B5", QVariant(1)); + ui->m_lpFormat->addItem("B6", QVariant(20)); + ui->m_lpFormat->addItem("B7", QVariant(21)); + ui->m_lpFormat->addItem("B8", QVariant(22)); + ui->m_lpFormat->addItem("B9", QVariant(23)); + ui->m_lpFormat->addItem("B10", QVariant(16)); + ui->m_lpFormat->addItem("C5E", QVariant(24)); + ui->m_lpFormat->addItem("Comm10E", QVariant(25)); + ui->m_lpFormat->addItem("DLE", QVariant(26)); + ui->m_lpFormat->addItem("Executive", QVariant(4)); + ui->m_lpFormat->addItem("Folio", QVariant(27)); + ui->m_lpFormat->addItem("Ledger", QVariant(28)); + ui->m_lpFormat->addItem("Legal", QVariant(3)); + ui->m_lpFormat->addItem("Letter", QVariant(2)); + ui->m_lpFormat->addItem("Tabloid", QVariant(29)); + ui->m_lpFormat->setCurrentIndex(ui->m_lpFormat->findText("A4")); + + ui->m_lpUnit->addItem("Millimeter", QVariant(0)); + ui->m_lpUnit->addItem("Point", QVariant(1)); + ui->m_lpUnit->addItem("Inch", QVariant(2)); + ui->m_lpUnit->addItem("Pica", QVariant(3)); + ui->m_lpUnit->addItem("Didot", QVariant(4)); + ui->m_lpUnit->addItem("Cicero", QVariant(5)); + ui->m_lpUnit->addItem("DevicePixel", QVariant(6)); + ui->m_lpUnit->setCurrentIndex(0); +} + +CExportPDF::~CExportPDF() +{ + delete ui; +} + +void CExportPDF::changeEvent(QEvent *e) +{ + QDialog::changeEvent(e); + switch (e->type()) { + case QEvent::LanguageChange: + ui->retranslateUi(this); + break; + default: + break; + } +} + +int CExportPDF::GetFormat() +{ + return(ui->m_lpFormat->itemData(ui->m_lpFormat->currentIndex(), Qt::UserRole).toInt()); +} + +int CExportPDF::GetWeeks() +{ + return(ui->m_lpWeeksPerSheet->value()); +} + +int CExportPDF::GetUnit() +{ + return(ui->m_lpUnit->itemData(ui->m_lpUnit->currentIndex(), Qt::UserRole).toInt()); +} + +double CExportPDF::GetLeft() +{ + return(ui->m_lpLeft->value()); +} + +double CExportPDF::GetRight() +{ + return(ui->m_lpRight->value()); +} + +double CExportPDF::GetTop() +{ + return(ui->m_lpTop->value()); +} + +double CExportPDF::GetBottom() +{ + return(ui->m_lpBottom->value()); +} + +QString CExportPDF::GetFile() +{ + return(ui->m_lpFileName->text()); +} + +void CExportPDF::on_m_lpFileNameBrowse_clicked() +{ + QString szFileName = QFileDialog::getSaveFileName(this, "Save PDF", QDir::homePath(), tr("PDF (*.pdf)")); + if(szFileName.length()) + ui->m_lpFileName->setText(szFileName); +} + +void CExportPDF::on_m_lpCancel_clicked() +{ + reject(); +} + +void CExportPDF::on_m_lpOK_clicked() +{ + if(ui->m_lpFileName->text().length()) + accept(); +} diff --git a/cexportpdf.h b/cexportpdf.h new file mode 100644 index 0000000..6e14f81 --- /dev/null +++ b/cexportpdf.h @@ -0,0 +1,38 @@ +#ifndef CEXPORTPDF_H +#define CEXPORTPDF_H + +#include +#include + + +namespace Ui { + class CExportPDF; +} + +class CExportPDF : public QDialog { + Q_OBJECT +public: + CExportPDF(QWidget *parent = 0); + ~CExportPDF(); + + int GetFormat(); + int GetWeeks(); + int GetUnit(); + double GetLeft(); + double GetRight(); + double GetTop(); + double GetBottom(); + QString GetFile(); +protected: + void changeEvent(QEvent *e); + +private: + Ui::CExportPDF *ui; + +private slots: + void on_m_lpOK_clicked(); + void on_m_lpCancel_clicked(); + void on_m_lpFileNameBrowse_clicked(); +}; + +#endif // CEXPORTPDF_H diff --git a/cexportpdf.ui b/cexportpdf.ui new file mode 100644 index 0000000..11eb349 --- /dev/null +++ b/cexportpdf.ui @@ -0,0 +1,274 @@ + + + CExportPDF + + + + 0 + 0 + 350 + 256 + + + + Export PDF + + + + + + + + File name: + + + + + + + + + + + 25 + 16777215 + + + + ... + + + + + + + + + + + Format: + + + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + Weeks per Sheet: + + + + + + + 1 + + + 6 + + + + + + + + + Margins + + + + + + + + Unit: + + + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + + + Left: + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + Top: + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + Right: + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + Bottom: + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + 10.000000000000000 + + + + + + + 10.000000000000000 + + + + + + + 10.000000000000000 + + + + + + + 10.000000000000000 + + + + + + + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + &Cancel + + + + + + + &OK + + + true + + + + + + + + + + diff --git a/common.cpp b/common.cpp new file mode 100644 index 0000000..af62b1f --- /dev/null +++ b/common.cpp @@ -0,0 +1,69 @@ +#include "common.h" + +// place your code here +char* DWORD2Time(uint32_t dwTime) +{ + if(!dwTime) + return(strdup("")); + + uint32_t dwHours = dwTime/3600; + uint32_t dwMinutes = (dwTime-(dwHours*3600))/60; + uint32_t dwSeconds = (dwTime-(dwHours*3600)-dwMinutes*60); + char szStr[100]; + + if(dwHours) + sprintf(szStr, "%d:%02d:%02d", dwHours, dwMinutes, dwSeconds); + else + sprintf(szStr, "%d:%02d", dwMinutes, dwSeconds); + + return(strdup(szStr)); +} + +char* DWORD2String(uint32_t dwValue) +{ + if(!dwValue) + return(strdup("")); + + char szStr[100]; + + sprintf(szStr, "%d", dwValue); + return(strdup(szStr)); +} + +uint32_t Time2DWORD(char* lpszTime) +{ + if(!strlen(lpszTime)) + return(0); + + char szHour[100] = {0}; + char szMinute[100] = {0}; + char szSecond[100] = {0}; + char sz[100]; + + strcpy(sz, lpszTime); + if(strrchr(sz, ':')) + { + strcpy(szSecond, strrchr(sz, ':')+1); + *strrchr(sz, ':') = 0; + if(strchr(sz, ':')) + { + strcpy(szMinute, strchr(sz, ':')+1); + *strchr(sz, ':') = 0; + strcpy(szHour, sz); + } + else + strcpy(szMinute, sz); + } + else + strcpy(szSecond, sz); + + + return(atol(szHour)*3600+atol(szMinute)*60+atol(szSecond)); +} + +uint32_t String2DWORD(char* lpszStr) +{ + if(!strlen(lpszStr)) + return(0); + return(atol(lpszStr)); +} diff --git a/common.h b/common.h new file mode 100644 index 0000000..3763564 --- /dev/null +++ b/common.h @@ -0,0 +1,27 @@ +#ifndef COMMON_H +#define COMMON_H + +#include +#include +#include +#include +#include +#include +#include "ctime.h" + +#define DELETE(x) if(x){delete x;x=0;} + +#define MESSAGE(x) QMessageBox::information(this, tr("qtTrainingPlan"), x) +#define MESSAGE_QUESTION(x) QMessageBox::question(this, tr("qtTrainingPlan"), x, QMessageBox::Yes | QMessageBox::No) + +#define HOURS(x) ((x)/3600) +#define MINUTES(x) (((x)/60)%60) +#define SECONDS(x) ((x)%60) + +// place your code here +char* DWORD2Time(uint32_t dwTime); +char* DWORD2String(uint32_t dwValue); +uint32_t String2DWORD(char* lpszStr); +uint32_t Time2DWORD(char* lpszTime); + +#endif // COMMON_H diff --git a/ctime.cpp b/ctime.cpp new file mode 100644 index 0000000..4a66641 --- /dev/null +++ b/ctime.cpp @@ -0,0 +1,79 @@ +#include "ctime.h" + + +CTime::CTime() : QTime() +{ +} + +CTime::CTime(int h, int m, int s, int ms) : QTime(h, m, s, ms) +{ +} + +CTime::CTime(const QTime& param) +{ + setHMS(param.hour(), param.minute(), param.second(), param.msec()); +} + +CTime::CTime(uint32_t dwTime) +{ + setHMS(HOURS(dwTime), MINUTES(dwTime), SECONDS(dwTime)); +} + +CTime::CTime(const QString& time) +{ + QString szHour; + QString szMinute; + QString szSecond; + QString tmp = time; + + if(tmp.contains(":")) + { + szSecond = tmp.mid(tmp.lastIndexOf(":")+1); + tmp = tmp.left(tmp.lastIndexOf(":")); + } + else + { + szSecond = tmp; + tmp = ""; + } + + if(tmp.contains(":")) + { + szMinute = tmp.mid(tmp.lastIndexOf(":")+1); + tmp = tmp.left(tmp.lastIndexOf(":")); + } + else + { + szMinute = tmp; + tmp = ""; + } + szHour = tmp; + setHMS(szHour.toInt(), szMinute.toInt(), szSecond.toInt()); +} + +QString CTime::Format() +{ + if(!hour() && !minute() && !second()) + return(QString("")); + QString szTime; + if(hour()) + szTime = toString(QString("h:mm:ss")); + else + szTime = toString(QString("mm:ss")); + return(szTime); +} + +const CTime& CTime::operator=(const CTime& param) +{ + setHMS(param.hour(), param.minute(), param.second(), param.msec()); + return(*this); +} + +uint32_t CTime::toDWORD() +{ + uint32_t h = hour(); + uint32_t m = minute(); + uint32_t s = second(); + uint32_t t = h*3600+m*60+s; + return(t); +} diff --git a/ctime.h b/ctime.h new file mode 100644 index 0000000..026cb1f --- /dev/null +++ b/ctime.h @@ -0,0 +1,21 @@ +#ifndef CTIME_H +#define CTIME_H + +#include +#include +#include "common.h" + +class CTime : public QTime +{ +public: + CTime(); + CTime(int h, int m = 0, int s = 0, int ms = 0); + CTime(const QTime& param); + CTime(uint32_t dwTime); + CTime(const QString& time); + QString Format(); + const CTime& operator=(const CTime& param); + uint32_t toDWORD(); +}; + +#endif // CTIME_H diff --git a/ctraining.cpp b/ctraining.cpp new file mode 100644 index 0000000..5f5b1bf --- /dev/null +++ b/ctraining.cpp @@ -0,0 +1,791 @@ +#include "ctraining.h" +#include "common.h" + + +CTraining::CTraining() +{ + m_lpPerson = 0; + m_lpSport = 0; + m_lpTrainingPlan = 0; + + m_lpCurSport = 0; + m_lpCurHR = 0; + m_lpCurTrainingPlan = 0; + m_lpCurTrainingDay = 0; + m_lpCurTrainingSession = 0; + m_lpCurTrainingTask = 0; +} + +CTraining::CTraining(const QString& szFileName) +{ + m_lpPerson = 0; + m_lpSport = 0; + m_lpTrainingPlan = 0; + + m_lpCurSport = 0; + m_lpCurHR = 0; + m_lpCurTrainingPlan = 0; + m_lpCurTrainingDay = 0; + m_lpCurTrainingSession = 0; + m_lpCurTrainingTask = 0; + + Load(szFileName); +} + +CTraining::~CTraining() +{ + Clean(); +} + +void CTraining::Clean() +{ + CleanPerson(); + CleanSport(); + CleanTrainingPlan(); +} + +void CTraining::CleanPerson() +{ + DELETE(m_lpPerson); +} + +void CTraining::CleanSport() +{ + DELETE(m_lpSport); +} + +void CTraining::CleanTrainingPlan() +{ + DELETE(m_lpTrainingPlan); +} + +void CTraining::ParsePerson(const QDomElement& Element) +{ + QDomNode Child = Element.firstChild(); + while(!Child.isNull()) + { + if(Child.toElement().tagName().toLower() == "firstname") + { + if(!m_lpPerson) + m_lpPerson = new CPerson; + m_lpPerson->SetFirstName(Child.toElement().text()); + } + else if(Child.toElement().tagName().toLower() == "lastname") + { + if(!m_lpPerson) + m_lpPerson = new CPerson; + m_lpPerson->SetLastName(Child.toElement().text()); + } + else if(Child.toElement().tagName().toLower() == "dayofbirth") + { + if(!m_lpPerson) + m_lpPerson = new CPerson; + m_lpPerson->SetDayOfBirth(QDate::fromString(Child.toElement().text(), "yyyyMMdd")); + } + else if(Child.toElement().tagName().toLower() == "height") + { + if(!m_lpPerson) + m_lpPerson = new CPerson; + m_lpPerson->SetHeight(Child.toElement().text().toInt()); + } + else if(Child.toElement().tagName().toLower() == "weight") + { + if(!m_lpPerson) + m_lpPerson = new CPerson; + m_lpPerson->SetWeight(Child.toElement().text().toInt()); + } + + Child = Child.nextSibling(); + } +} + +CSport* CTraining::ParseSport(const QDomElement& Element, CSport* lpSportDummy) +{ + QDomNode Child = Element.firstChild(); + QDomNode Child1; + CHR* lpHRDummy; + + if(!m_lpSport) + m_lpSport = lpSportDummy = new CSport(Element.attribute("name")); + else + lpSportDummy = lpSportDummy->Add(Element.attribute("name")); + + while(!Child.isNull()) + { + if(Child.toElement().tagName().toLower() == "maxhr") + lpSportDummy->SetMaxHR(Child.toElement().text().toInt()); + else if(Child.toElement().tagName().toLower() == "hr") + { + lpHRDummy = lpSportDummy->AddHR(Child.toElement().attribute("name")); + Child1 = Child.toElement().firstChild(); + while(!Child1.isNull()) + { + if(Child1.toElement().tagName().toLower() == "desc") + lpHRDummy->SetDesc(Child1.toElement().text()); + else if(Child1.toElement().tagName().toLower() == "min") + lpHRDummy->SetMin(Child1.toElement().text().toInt()); + else if(Child1.toElement().tagName().toLower() == "max") + lpHRDummy->SetMax(Child1.toElement().text().toInt()); + Child1 = Child1.nextSibling(); + } + } + else if(Child.toElement().tagName().toLower() == "pace") + { + if(Child.toElement().text().toLower() == "true") + lpSportDummy->SetPace(true); + else + lpSportDummy->SetPace(false); + } + Child = Child.nextSibling(); + } + return(lpSportDummy); +} + +CTrainingDay* CTraining::ParseDay(const QDomElement& Element, CTrainingDay* lpTrainingDayDummy) +{ + QDomNode Child = Element.firstChild(); + int iNum; + CTrainingSession* lpTrainingSessionDummy = 0; + + iNum = Element.attribute("num").toInt(); + if(iNum != -1) + { + lpTrainingDayDummy = m_lpTrainingPlan->AddDay(iNum); + + while(!Child.isNull()) + { + if(Child.toElement().tagName().toLower() == "desc") + lpTrainingDayDummy->SetDesc(Child.toElement().text()); + else if(Child.toElement().tagName().toLower() == "session") + lpTrainingSessionDummy = ParseSession(Child.toElement(), lpTrainingDayDummy, lpTrainingSessionDummy); + + Child = Child.nextSibling(); + } + } + return(lpTrainingDayDummy); +} + +CTrainingSession* CTraining::ParseSession(const QDomElement& Element, CTrainingDay* lpTrainingDay, CTrainingSession* lpTrainingSessionDummy) +{ + QDomNode Child = Element.firstChild(); + int iNum; + CTrainingTask* lpTrainingTaskDummy = 0; + + iNum = Element.attribute("num").toInt(); + if(iNum != -1) + { + lpTrainingSessionDummy = lpTrainingDay->AddTrainingSession(iNum); + + while(!Child.isNull()) + { + if(Child.toElement().tagName().toLower() == "desc") + lpTrainingSessionDummy->SetDesc(Child.toElement().text()); + else if(Child.toElement().tagName().toLower() == "sport") + lpTrainingSessionDummy->SetSport(Child.toElement().text()); + else if(Child.toElement().tagName().toLower() == "task") + lpTrainingTaskDummy = ParseTask(Child.toElement(), lpTrainingSessionDummy, lpTrainingTaskDummy); + + Child = Child.nextSibling(); + } + } + return(lpTrainingSessionDummy); +} + +CTrainingTask* CTraining::ParseTask(const QDomElement& Element, CTrainingSession* lpTrainingSession, CTrainingTask* lpTrainingTaskDummy) +{ + QDomNode Child = Element.firstChild(); + int iNum; + + iNum = Element.attribute("num").toInt(); + if(iNum != -1) + { + lpTrainingTaskDummy = lpTrainingSession->AddTask(iNum); + + while(!Child.isNull()) + { + if(Child.toElement().tagName().toLower() == "desc") + lpTrainingTaskDummy->SetDesc(Child.toElement().text()); + else if(Child.toElement().tagName().toLower() == "count") + lpTrainingTaskDummy->SetCount(Child.toElement().text().toInt()); + else if(Child.toElement().tagName().toLower() == "time") + lpTrainingTaskDummy->SetTime(Child.toElement().text().toInt()); + else if(Child.toElement().tagName().toLower() == "dist") + lpTrainingTaskDummy->SetDist(Child.toElement().text().toInt()); + else if(Child.toElement().tagName().toLower() == "hr") + lpTrainingTaskDummy->SetHR(Child.toElement().text()); + else if(Child.toElement().tagName().toLower() == "pace") + lpTrainingTaskDummy->SetPace(Child.toElement().text().toInt()); + else if(Child.toElement().tagName().toLower() == "pausetime") + lpTrainingTaskDummy->SetPauseTime(Child.toElement().text().toInt()); + else if(Child.toElement().tagName().toLower() == "pausedist") + lpTrainingTaskDummy->SetPauseDist(Child.toElement().text().toInt()); + else if(Child.toElement().tagName().toLower() == "pausehr") + lpTrainingTaskDummy->SetPauseHR(Child.toElement().text()); + else if(Child.toElement().tagName().toLower() == "pausepace") + lpTrainingTaskDummy->SetPausePace(Child.toElement().text().toInt()); + + Child = Child.nextSibling(); + } + } + return(lpTrainingTaskDummy); +} + +bool CTraining::Load(const QString& szFileName) +{ + Clean(); + m_szFileName = szFileName; + + QFile File(szFileName); + if(!File.open(QFile::ReadOnly | QFile::Text)) + return(false); + + QDomDocument Doc; + QString errorStr; + int errorLine; + int errorColumn; + if(!Doc.setContent(&File, false, &errorStr, &errorLine, &errorColumn)) + return(false); + + QDomElement Root = Doc.documentElement(); + if(Root.tagName().toLower() != "trainingplan") + return(false); + + CTrainingDay* lpTrainingDayDummy = 0; + CSport* lpSportDummy = 0; + QDomNode Child = Root.firstChild(); + + while(!Child.isNull()) + { + if(Child.toElement().tagName().toLower() == "person") + ParsePerson(Child.toElement()); + else if(Child.toElement().tagName().toLower() == "sport") + lpSportDummy = ParseSport(Child.toElement(), lpSportDummy); + else if(Child.toElement().tagName().toLower() == "name") + { + if(!m_lpTrainingPlan) + m_lpTrainingPlan = new CTrainingPlan(Child.toElement().text()); + } + else if(Child.toElement().tagName().toLower() == "startdate") + { + if(m_lpTrainingPlan) + m_lpTrainingPlan->SetTrainingStart(QDate::fromString(Child.toElement().text(), "yyyyMMdd")); + } + else if(Child.toElement().tagName().toLower() == "desc") + { + if(m_lpTrainingPlan) + m_lpTrainingPlan->SetDesc(Child.toElement().text()); + } + else if(Child.toElement().tagName().toLower() == "day") + lpTrainingDayDummy = ParseDay(Child.toElement(), lpTrainingDayDummy); + + Child = Child.nextSibling(); + } + + Recalculate(); + return(true); +} + +bool CTraining::Save(const QString& szFileName) +{ + QFile File(szFileName); + if(!File.open(QFile::WriteOnly | QFile::Text)) + return(false); + + QXmlStreamWriter xmlWriter(&File); + xmlWriter.setCodec("UTF-8"); + + xmlWriter.setAutoFormatting(true); + xmlWriter.setAutoFormattingIndent(-1); + xmlWriter.writeStartDocument(); + xmlWriter.writeStartElement("TrainingPlan"); + + if(m_lpPerson) + { + xmlWriter.writeStartElement("Person"); + if(m_lpPerson->GetFirstName().length()) + xmlWriter.writeTextElement("FirstName", m_lpPerson->GetFirstName()); + if(m_lpPerson->GetLastName().length()) + xmlWriter.writeTextElement("LastName", m_lpPerson->GetLastName()); + if(m_lpPerson->GetDayOfBirth().year()) + xmlWriter.writeTextElement("DayOfBirth", m_lpPerson->GetDayOfBirth().toString("yyyyMMdd")); + if(m_lpPerson->GetHeight()) + xmlWriter.writeTextElement("Height", QString("%1").arg(m_lpPerson->GetHeight())); + if(m_lpPerson->GetWeight()) + xmlWriter.writeTextElement("Weight", QString("%1").arg(m_lpPerson->GetWeight())); + xmlWriter.writeEndElement(); + } + + CSport* lpSport = m_lpSport; + while(lpSport) + { + xmlWriter.writeStartElement("Sport"); + xmlWriter.writeAttribute("name", lpSport->GetName()); + xmlWriter.writeTextElement("Pace", lpSport->GetPace() ? "true" : "false"); + if(lpSport->GetMaxHR()) + xmlWriter.writeTextElement("MaxHR", QString("%1").arg(lpSport->GetMaxHR())); + + CHR* lpHR = lpSport->GetHR(); + while(lpHR) + { + xmlWriter.writeStartElement("HR"); + xmlWriter.writeAttribute("name", lpHR->GetName()); + if(lpHR->GetDesc().length()) + xmlWriter.writeTextElement("Desc", lpHR->GetDesc()); + xmlWriter.writeTextElement("Min", QString("%1").arg(lpHR->GetMin())); + xmlWriter.writeTextElement("Max", QString("%1").arg(lpHR->GetMax())); + xmlWriter.writeEndElement(); + lpHR = lpHR->GetChild(); + } + xmlWriter.writeEndElement(); + lpSport = lpSport->GetChild(); + } + + if(m_lpTrainingPlan) + { + xmlWriter.writeTextElement("Name", m_lpTrainingPlan->GetName()); + if(m_lpTrainingPlan->HasDesc()) + xmlWriter.writeTextElement("Desc", m_lpTrainingPlan->GetDesc()); + if(m_lpTrainingPlan->GetTrainingStart().year()) + xmlWriter.writeTextElement("StartDate", m_lpTrainingPlan->GetTrainingStart().toString("yyyyMMdd")); + CTrainingDay* lpDay = m_lpTrainingPlan->GetTrainingDay(); + while(lpDay) + { + xmlWriter.writeStartElement("Day"); + xmlWriter.writeAttribute("num", QString("%1").arg(lpDay->GetNum())); + if(lpDay->HasDesc()) + xmlWriter.writeTextElement("Desc", lpDay->GetDesc()); + CTrainingSession* lpSession = lpDay->GetTrainingSession(); + while(lpSession) + { + xmlWriter.writeStartElement("Session"); + xmlWriter.writeAttribute("num", QString("%1").arg(lpSession->GetNum())); + if(lpSession->HasSport()) + xmlWriter.writeTextElement("Sport", lpSession->GetSport()); + if(lpSession->HasDesc()) + xmlWriter.writeTextElement("Desc", lpSession->GetDesc()); + CTrainingTask* lpTask = lpSession->GetTrainingTask(); + while(lpTask) + { + xmlWriter.writeStartElement("Task"); + xmlWriter.writeAttribute("num", QString("%1").arg(lpTask->GetNum())); + if(lpTask->HasDesc()) + xmlWriter.writeTextElement("Desc", lpTask->GetDesc()); + xmlWriter.writeTextElement("Count", QString("%1").arg(lpTask->GetCount())); + if(lpTask->GetDist()) + xmlWriter.writeTextElement("Dist", QString("%1").arg(lpTask->GetDist())); + if(lpTask->HasHR()) + xmlWriter.writeTextElement("HR", lpTask->GetHR()); + if(lpTask->GetPace()) + xmlWriter.writeTextElement("Pace", QString("%1").arg(lpTask->GetPace())); + if(lpTask->GetTime()) + xmlWriter.writeTextElement("Time", QString("%1").arg(lpTask->GetTime())); + if(lpTask->GetCount() > 1) + { + if(lpTask->GetPauseDist()) + xmlWriter.writeTextElement("PauseDist", QString("%1").arg(lpTask->GetPauseDist())); + if(lpTask->HasPauseHR()) + xmlWriter.writeTextElement("PauseHR", lpTask->GetPauseHR()); + if(lpTask->GetPausePace()) + xmlWriter.writeTextElement("PausePace", QString("%1").arg(lpTask->GetPausePace())); + if(lpTask->GetPauseTime()) + xmlWriter.writeTextElement("PauseTime", QString("%1").arg(lpTask->GetPauseTime())); + } + xmlWriter.writeEndElement(); + lpTask = lpTask->GetChild(); + } + xmlWriter.writeEndElement(); + lpSession = lpSession->GetChild(); + } + xmlWriter.writeEndElement(); + lpDay = lpDay->GetChild(); + } + } + + xmlWriter.writeEndDocument(); + File.close(); + if(File.error()) + return(false); + return(true); +} + +void CTraining::Recalculate() +{ + CTrainingDay* lpTrainingDayDummy; + CTrainingSession* lpTrainingSessionDummy; + CTrainingTask* lpTrainingTaskDummy; + + + if(m_lpTrainingPlan) + { + lpTrainingDayDummy = m_lpTrainingPlan->GetTrainingDay(); + while(lpTrainingDayDummy) + { + lpTrainingSessionDummy = lpTrainingDayDummy->GetTrainingSession(); + while(lpTrainingSessionDummy) + { + lpTrainingTaskDummy = lpTrainingSessionDummy->GetTrainingTask(); + while(lpTrainingTaskDummy) + { + if(!lpTrainingTaskDummy->GetCount()) + lpTrainingTaskDummy->SetCount(1); + + if(lpTrainingTaskDummy->GetTime() && lpTrainingTaskDummy->GetDist()) + lpTrainingTaskDummy->CalcPace(); + else if(lpTrainingTaskDummy->GetDist() && lpTrainingTaskDummy->GetPace()) + lpTrainingTaskDummy->CalcTime(); + else if(lpTrainingTaskDummy->GetTime() && lpTrainingTaskDummy->GetPace()) + lpTrainingTaskDummy->CalcDist(); + + if(lpTrainingTaskDummy->GetCount() > 1) + { + if(lpTrainingTaskDummy->GetPauseTime() && lpTrainingTaskDummy->GetPauseDist()) + lpTrainingTaskDummy->CalcPausePace(); + else if(lpTrainingTaskDummy->GetPauseDist() && lpTrainingTaskDummy->GetPausePace()) + lpTrainingTaskDummy->CalcPauseTime(); + else if(lpTrainingTaskDummy->GetPauseTime() && lpTrainingTaskDummy->GetPausePace()) + lpTrainingTaskDummy->CalcPauseDist(); + } + else + { + lpTrainingTaskDummy->SetPauseTime(0); + lpTrainingTaskDummy->SetPauseDist(0); + lpTrainingTaskDummy->SetPausePace(0); + } + + lpTrainingTaskDummy = lpTrainingTaskDummy->GetChild(); + } + lpTrainingSessionDummy = lpTrainingSessionDummy->GetChild(); + } + lpTrainingDayDummy = lpTrainingDayDummy->GetChild(); + } + } +} + +bool CTraining::GetPerson(QString& szFirstName, QString& szLastName, QDate& DayOfBirth, uint32_t& dwHeight, uint32_t& dwWeight) +{ + if(!m_lpPerson) + return(false); + + szFirstName = m_lpPerson->GetFirstName(); + szLastName = m_lpPerson->GetLastName(); + DayOfBirth = m_lpPerson->GetDayOfBirth(); + dwHeight = m_lpPerson->GetHeight(); + dwWeight = m_lpPerson->GetWeight(); + + return(true); +} + +bool CTraining::GetFirstSport(QString& szName, uint32_t& dwMaxHR, bool& bPace) +{ + m_lpCurHR = 0; + m_lpCurSport = m_lpSport; + if(!m_lpCurSport) + return(false); + + szName = m_lpCurSport->GetName(); + dwMaxHR = m_lpCurSport->GetMaxHR(); + bPace = m_lpCurSport->GetPace(); + + return(true); +} + +bool CTraining::GetNextSport(QString& szName, uint32_t& dwMaxHR, bool& bPace) +{ + m_lpCurHR = 0; + if(!m_lpCurSport) + return(false); + m_lpCurSport = m_lpCurSport->GetChild(); + if(!m_lpCurSport) + return(false); + + szName = m_lpCurSport->GetName(); + dwMaxHR = m_lpCurSport->GetMaxHR(); + bPace = m_lpCurSport->GetPace(); + + return(true); +} + +bool CTraining::GetFirstHR(QString& szName, QString& szDesc, uint32_t& dwMin, uint32_t& dwMax) +{ + if(!m_lpCurSport) + return(false); + m_lpCurHR = m_lpCurSport->GetHR(); + if(!m_lpCurHR) + return(false); + + szName = m_lpCurHR->GetName(); + szDesc = m_lpCurHR->GetDesc(); + dwMin = m_lpCurHR->GetMin(); + dwMax = m_lpCurHR->GetMax(); + + return(true); +} + +bool CTraining::GetNextHR(QString& szName, QString& szDesc, uint32_t& dwMin, uint32_t& dwMax) +{ + if(!m_lpCurHR) + return(false); + m_lpCurHR = m_lpCurHR->GetChild(); + if(!m_lpCurHR) + return(false); + + szName = m_lpCurHR->GetName(); + szDesc = m_lpCurHR->GetDesc(); + dwMin = m_lpCurHR->GetMin(); + dwMax = m_lpCurHR->GetMax(); + + return(true); +} + +bool CTraining::GetFirstTraining(QString& szName, QString& szDesc, QDate& TrainingStart) +{ + m_lpCurTrainingDay = 0; + m_lpCurTrainingSession = 0; + m_lpCurTrainingTask = 0; + m_lpCurTrainingPlan = m_lpTrainingPlan; + if(!m_lpCurTrainingPlan) + return(false); + + szName = m_lpCurTrainingPlan->GetName(); + szDesc = m_lpCurTrainingPlan->GetDesc(); + TrainingStart = m_lpCurTrainingPlan->GetTrainingStart(); + return(true); +} + +bool CTraining::GetNextTraining(QString& szName, QString& szDesc, QDate& TrainingStart) +{ + m_lpCurTrainingDay = 0; + m_lpCurTrainingSession = 0; + m_lpCurTrainingTask = 0; + szName = szName; + szDesc = szDesc; + TrainingStart = TrainingStart; + return(false); +} + +bool CTraining::GetFirstDay(int& iNum, QString& szDesc) +{ + m_lpCurTrainingSession = 0; + m_lpCurTrainingTask = 0; + if(!m_lpCurTrainingPlan) + return(false); + m_lpCurTrainingDay = m_lpCurTrainingPlan->GetTrainingDay(); + if(!m_lpCurTrainingDay) + return(false); + + iNum = m_lpCurTrainingDay->GetNum(); + szDesc = m_lpCurTrainingDay->GetDesc(); + + return(true); +} + +bool CTraining::GetNextDay(int& iNum, QString& szDesc) +{ + m_lpCurTrainingSession = 0; + m_lpCurTrainingTask = 0; + if(!m_lpCurTrainingDay) + return(false); + m_lpCurTrainingDay = m_lpCurTrainingDay->GetChild(); + if(!m_lpCurTrainingDay) + return(false); + + iNum = m_lpCurTrainingDay->GetNum(); + szDesc = m_lpCurTrainingDay->GetDesc(); + + return(true); +} + +bool CTraining::GetFirstSession(int& iNum, QString& szDesc, QString& szSport) +{ + m_lpCurTrainingTask = 0; + if(!m_lpCurTrainingDay) + return(false); + m_lpCurTrainingSession = m_lpCurTrainingDay->GetTrainingSession(); + if(!m_lpCurTrainingSession) + return(false); + + iNum = m_lpCurTrainingSession->GetNum(); + szDesc = m_lpCurTrainingSession->GetDesc(); + szSport = m_lpCurTrainingSession->GetSport(); + + return(true); +} + +bool CTraining::GetNextSession(int& iNum, QString& szDesc, QString& szSport) +{ + m_lpCurTrainingTask = 0; + if(!m_lpCurTrainingSession) + return(false); + m_lpCurTrainingSession = m_lpCurTrainingSession->GetChild(); + if(!m_lpCurTrainingSession) + return(false); + + iNum = m_lpCurTrainingSession->GetNum(); + szDesc = m_lpCurTrainingSession->GetDesc(); + szSport = m_lpCurTrainingSession->GetSport(); + + return(true); +} + +bool CTraining::GetFirstTask(int& iNum, QString& szDesc, uint32_t& dwCount, uint32_t& dwTime, uint32_t& dwDist, QString& szHR, uint32_t& dwPace, uint32_t& dwPauseTime, uint32_t& dwPauseDist, QString& szPauseHR, uint32_t& dwPausePace) +{ + if(!m_lpCurTrainingSession) + return(false); + m_lpCurTrainingTask = m_lpCurTrainingSession->GetTrainingTask(); + if(!m_lpCurTrainingTask) + return(false); + + iNum = m_lpCurTrainingTask->GetNum(); + szDesc = m_lpCurTrainingTask->GetDesc(); + dwCount = m_lpCurTrainingTask->GetCount(); + dwTime = m_lpCurTrainingTask->GetTime(); + dwDist = m_lpCurTrainingTask->GetDist(); + szHR = m_lpCurTrainingTask->GetHR(); + dwPace = m_lpCurTrainingTask->GetPace(); + dwPauseTime = m_lpCurTrainingTask->GetPauseTime(); + dwPauseDist = m_lpCurTrainingTask->GetPauseDist(); + szPauseHR = m_lpCurTrainingTask->GetPauseHR(); + dwPausePace = m_lpCurTrainingTask->GetPausePace(); + + return(true); +} + +bool CTraining::GetNextTask(int& iNum, QString& szDesc, uint32_t& dwCount, uint32_t& dwTime, uint32_t& dwDist, QString& szHR, uint32_t& dwPace, uint32_t& dwPauseTime, uint32_t& dwPauseDist, QString& szPauseHR, uint32_t& dwPausePace) +{ + if(!m_lpCurTrainingTask) + return(false); + m_lpCurTrainingTask = m_lpCurTrainingTask->GetChild(); + if(!m_lpCurTrainingTask) + return(false); + + iNum = m_lpCurTrainingTask->GetNum(); + szDesc = m_lpCurTrainingTask->GetDesc(); + dwCount = m_lpCurTrainingTask->GetCount(); + dwTime = m_lpCurTrainingTask->GetTime(); + dwDist = m_lpCurTrainingTask->GetDist(); + szHR = m_lpCurTrainingTask->GetHR(); + dwPace = m_lpCurTrainingTask->GetPace(); + dwPauseTime = m_lpCurTrainingTask->GetPauseTime(); + dwPauseDist = m_lpCurTrainingTask->GetPauseDist(); + szPauseHR = m_lpCurTrainingTask->GetPauseHR(); + dwPausePace = m_lpCurTrainingTask->GetPausePace(); + + return(true); +} + +void CTraining::SetTraining(QString szTraining, QDate TrainingStart) +{ + if(!m_lpTrainingPlan) + m_lpTrainingPlan = new CTrainingPlan(szTraining); + else + m_lpTrainingPlan->SetName(szTraining); + m_lpTrainingPlan->SetTrainingStart(TrainingStart); +} + +void CTraining::SetPerson(QString szFirstName, QString szLastName, QDate DayOfBirth, uint32_t dwHeight, uint32_t dwWeight) +{ + DELETE(m_lpPerson); + m_lpPerson = new CPerson(szFirstName, szLastName, DayOfBirth, dwHeight, dwWeight); +} + +void CTraining::SetDay(int iDay, int iNewDay, QString szNewDesc) +{ + CTrainingDay* lpOldDay; + CTrainingDay* lpNewDay; + + if(!m_lpTrainingPlan) + return; + + lpOldDay = m_lpTrainingPlan->GetTrainingDay()->Find(iDay); + lpNewDay = m_lpTrainingPlan->GetTrainingDay()->Find(iNewDay); + + if(!lpNewDay) + { + lpOldDay->SetNum(iNewDay); + lpOldDay->SetDesc(szNewDesc); + } + else + { + lpNewDay->AddTrainingSession(lpOldDay->GetTrainingSession()); + lpOldDay->SetTrainingSession(0); + m_lpTrainingPlan->DeleteTrainingDay(iDay); + } +} + +void CTraining::SetSession(int iDay, int iNewDay, int iSession, QString szDesc, QString szSport) +{ + if(!m_lpTrainingPlan) + return; + + CTrainingDay* lpOldDay; + CTrainingDay* lpNewDay; + CTrainingSession* lpSession; + + lpOldDay = m_lpTrainingPlan->GetTrainingDay()->Find(iDay); + if(!lpOldDay) + return; + + lpSession = lpOldDay->GetTrainingSession()->Find(iSession); + if(!lpSession) + return; + + lpSession->SetDesc(szDesc); + lpSession->SetSport(szSport); + + if(iDay == iNewDay) + return; + + lpNewDay = m_lpTrainingPlan->GetTrainingDay()->Find(iNewDay); + if(!lpNewDay) + return; + + lpNewDay->AddTrainingSession(lpSession); + lpOldDay->DeleteTrainingSession(lpSession); +} + +void CTraining::AddSport(QString szName, uint32_t dwMaxHR, bool bPace) +{ + if(!m_lpSport) + m_lpSport = new CSport(szName, dwMaxHR, 0, bPace); + else + m_lpSport->Add(szName, dwMaxHR, 0, bPace); +} + +void CTraining::AddHR(QString szSport, QString szName, QString szDesc, uint32_t dwMin, uint32_t dwMax) +{ + if(!m_lpSport) + return; + CSport* lpSport = m_lpSport->Find(szSport); + if(!lpSport) + return; + lpSport->AddHR(szName, szDesc, dwMin, dwMax); +} + +void CTraining::AddDay(int iDay, QString szDesc) +{ + QString szDescTemp = szDesc; + + if(szDescTemp.indexOf(")")) + szDescTemp = szDescTemp.mid(szDescTemp.indexOf(")")+2); + m_lpTrainingPlan->AddDay(iDay, szDescTemp); +} + +void CTraining::AddSession(int iDay, int iSession, QString szDesc, QString szSport) +{ + CTrainingDay* lpDay = m_lpTrainingPlan->GetTrainingDay()->Find(iDay); + if(!lpDay) + return; + lpDay->AddTrainingSession(iSession, szDesc, szSport); +} + +void CTraining::AddTask(int iDay, int iSession, int iTask, QString szDesc, uint32_t dwCount, uint32_t dwTime, uint32_t dwDist, QString szHR, uint32_t dwPace, uint32_t dwPauseTime, uint32_t dwPauseDist, QString szPauseHR, uint32_t dwPausePace) +{ + CTrainingDay* lpDay = m_lpTrainingPlan->GetTrainingDay()->Find(iDay); + if(!lpDay) + return; + CTrainingSession* lpSession = lpDay->GetTrainingSession()->Find(iSession); + if(!lpSession) + return; + + lpSession->AddTask(iTask, szDesc, dwCount, dwTime, dwDist, szHR, dwPace, dwPauseTime, dwPauseDist, szPauseHR, dwPausePace); +} diff --git a/ctraining.h b/ctraining.h new file mode 100644 index 0000000..89d6794 --- /dev/null +++ b/ctraining.h @@ -0,0 +1,611 @@ +#ifndef CTRAINING_H +#define CTRAINING_H + +#include +#include +#include +#include +#include "common.h" + + +class CPerson +{ +public: + CPerson() + { + m_szFirstName = ""; + m_szLastName = ""; + m_dwWeight = 0; + m_dwWeight = 0; + }; + CPerson(const QString& szFirstName, const QString& szLastName, const QDate& DayOfBirth, uint32_t dwHeight, uint32_t dwWeight) + { + m_szFirstName = ""; + m_szLastName = ""; + Set(szFirstName, szLastName, DayOfBirth, dwHeight, dwWeight); + }; + ~CPerson() + { + }; + void SetFirstName(const QString& szFirstName) { m_szFirstName = szFirstName; } + void SetLastName(const QString& szLastName) { m_szLastName = szLastName; } + void SetDayOfBirth(const QDate& DayOfBirth) { m_DayOfBirth = DayOfBirth; } + void SetHeight(uint32_t dwHeight) { m_dwHeight = dwHeight; } + void SetWeight(uint32_t dwWeight) { m_dwWeight = dwWeight; } + void Set(const QString& szFirstName, const QString& szLastName, const QDate& DayOfBirth, uint32_t dwHeight, uint32_t dwWeight) + { + SetFirstName(szFirstName); + SetLastName(szLastName); + SetDayOfBirth(DayOfBirth); + SetHeight(dwHeight); + SetWeight(dwWeight); + }; + QString GetFirstName() { return(m_szFirstName); }; + QString GetLastName() { return(m_szLastName); }; + QDate GetDayOfBirth() { return(m_DayOfBirth); }; + uint32_t GetHeight() { return(m_dwHeight); }; + uint32_t GetWeight() { return(m_dwWeight); }; +protected: + QString m_szFirstName; + QString m_szLastName; + QDate m_DayOfBirth; + uint32_t m_dwHeight; + uint32_t m_dwWeight; +}; + +class CHR +{ +public: + CHR(const QString& szName, const QString& szDesc = "", uint32_t dwMin = 0, uint32_t dwMax = 0, CHR* lpChild = 0) + { + m_szName = ""; + m_szDesc = ""; + m_lpChild = 0; + Set(szName, szDesc, dwMin, dwMax, lpChild); + }; + ~CHR() + { + DELETE(m_lpChild); + } + CHR* Add(const QString& szName, const QString& szDesc = "", uint32_t dwMin = 0, uint32_t dwMax = 0, CHR* lpChild = 0) + { + if(!m_lpChild) + m_lpChild = new CHR(szName, szDesc, dwMin, dwMax, lpChild); + else + m_lpChild->Set(szName, szDesc, dwMin, dwMax, lpChild); + return(m_lpChild); + }; + void SetName(const QString& szName) { m_szName = szName; }; + void SetDesc(const QString& szDesc) { m_szDesc = szDesc; }; + void SetMin(uint32_t dwMin) { m_dwMin = dwMin; }; + void SetMax(uint32_t dwMax) { m_dwMax = dwMax; }; + void SetChild(CHR* lpChild) { m_lpChild = lpChild; }; + void Set(const QString& szName, const QString& szDesc = "", uint32_t dwMin = 0, uint32_t dwMax = 0, CHR* lpChild = 0) + { + SetName(szName); + SetDesc(szDesc); + SetMin(dwMin); + SetMax(dwMax); + SetChild(lpChild); + }; + QString GetName() { return(m_szName); }; + QString GetDesc() { return(m_szDesc); }; + uint32_t GetMin() { return(m_dwMin); }; + uint32_t GetMax() { return(m_dwMax); }; + CHR* GetChild() { return(m_lpChild); }; + CHR* Find(const QString& szName) + { + if(m_szName == szName) + return(this); + if(m_lpChild) + return(m_lpChild->Find(szName)); + return(0); + }; + bool HasName() { if(m_szName.length()) return(true); return(false); }; + bool HasDesc() { if(m_szDesc.length()) return(true); return(false); }; +protected: + QString m_szName; + QString m_szDesc; + uint32_t m_dwMin; + uint32_t m_dwMax; + CHR* m_lpChild; +}; + +class CSport +{ +public: + CSport(const QString& szName, uint32_t dwMaxHR = 0, CHR* lpHR = 0, bool bPace = true, CSport* lpChild = 0) + { + m_szName = ""; + m_lpHR = 0; + m_lpChild = 0; + Set(szName, dwMaxHR, lpHR, bPace, lpChild); + }; + ~CSport() + { + DELETE(m_lpHR); + DELETE(m_lpChild); + }; + CSport* Add(const QString& szName, uint32_t dwMaxHR = 0, CHR* lpHR = 0, bool bPace = true, CSport* lpChild = 0) + { + if(!m_lpChild) + m_lpChild = new CSport(szName, dwMaxHR, lpHR, bPace, lpChild); + else + m_lpChild->Set(szName, dwMaxHR, lpHR, bPace, lpChild); + return(m_lpChild); + }; + CHR* AddHR(const QString& szName, const QString& szDesc = "", uint32_t dwMin = 0, uint32_t dwMax = 0, CHR* lpChild = 0) + { + CHR* lpHRDummy = m_lpHR; + if(!lpHRDummy) + lpHRDummy = m_lpHR = new CHR(szName, szDesc, dwMin, dwMax, lpChild); + else + { + while(lpHRDummy->GetChild()) + lpHRDummy = lpHRDummy->GetChild(); + lpHRDummy = lpHRDummy->Add(szName, szDesc, dwMin, dwMax, lpChild); + } + return(lpHRDummy); + }; + void SetName(const QString& szName) { m_szName = szName; }; + void SetMaxHR(uint32_t dwMaxHR) { m_dwMaxHR = dwMaxHR; }; + void SetHR(CHR* lpHR) { m_lpHR = lpHR; }; + void SetPace(bool bPace) { m_bPace = bPace; }; + void SetChild(CSport* lpChild) { m_lpChild = lpChild; }; + void Set(const QString& szName, uint32_t dwMaxHR = 0, CHR* lpHR = 0, bool bPace = true, CSport* lpChild = 0) + { + SetName(szName); + SetMaxHR(dwMaxHR); + SetHR(lpHR); + SetPace(bPace); + SetChild(lpChild); + }; + QString GetName() { return(m_szName); }; + uint32_t GetMaxHR() { return(m_dwMaxHR); }; + CHR* GetHR() { return(m_lpHR); }; + bool GetPace() { return(m_bPace); }; + CSport* GetChild() { return(m_lpChild); }; + CSport* Find(const QString& szName) + { + if(m_szName == szName) + return(this); + if(m_lpChild) + return(m_lpChild->Find(szName)); + return(0); + }; + bool HasName() { if(m_szName.length()) return(true); return(false); }; +protected: + QString m_szName; + uint32_t m_dwMaxHR; + CHR* m_lpHR; + bool m_bPace; + CSport* m_lpChild; +}; + +class CTrainingTask +{ +public: + CTrainingTask(int iNum, const QString& szDesc = "", uint32_t dwCount = 0, uint32_t dwTime = 0, uint32_t dwDist = 0, const QString& szHR = "", uint32_t dwPace = 0, uint32_t dwPauseTime = 0, uint32_t dwPauseDist = 0, const QString& szPauseHR = "", uint32_t dwPausePace = 0, CTrainingTask* lpChild = 0) + { + m_szDesc = ""; + m_szHR = ""; + m_szPauseHR = ""; + m_lpChild = 0; + Set(iNum, szDesc, dwCount, dwTime, dwDist, szHR, dwPace, dwPauseTime, dwPauseDist, szPauseHR, dwPausePace, lpChild); + }; + ~CTrainingTask() + { + DELETE(m_lpChild); + }; + CTrainingTask* Add(int iNum, const QString& szDesc = "", uint32_t dwCount = 0, uint32_t dwTime = 0, uint32_t dwDist = 0, const QString& szHR = "", uint32_t dwPace = 0, uint32_t dwPauseTime = 0, uint32_t dwPauseDist = 0, const QString& szPauseHR = "", uint32_t dwPausePace = 0, CTrainingTask* lpChild = 0) + { + if(!m_lpChild) + m_lpChild = new CTrainingTask(iNum, szDesc, dwCount, dwTime, dwDist, szHR, dwPace, dwPauseTime, dwPauseDist, szPauseHR, dwPausePace, lpChild); + else + m_lpChild->Set(iNum, szDesc, dwCount, dwTime, dwDist, szHR, dwPace, dwPauseTime, dwPauseDist, szPauseHR, dwPausePace, lpChild); + return(m_lpChild); + }; + void SetNum(int iNum) { m_iNum = iNum; }; + void SetDesc(const QString& szDesc) { m_szDesc = szDesc; }; + void SetCount(uint32_t dwCount) { m_dwCount = dwCount; }; + void SetTime(uint32_t dwTime) { m_Time = CTime(HOURS(dwTime), MINUTES(dwTime), SECONDS(dwTime)); }; + void SetDist(uint32_t dwDist) { m_dwDist = dwDist; }; + void SetHR(const QString& szHR) { m_szHR = szHR; }; + void SetPace(uint32_t dwPace) { m_dwPace = dwPace; }; + void SetPauseTime(uint32_t dwPauseTime) { m_PauseTime = CTime(HOURS(dwPauseTime), MINUTES(dwPauseTime), SECONDS(dwPauseTime)); }; + void SetPauseDist(uint32_t dwPauseDist) { m_dwPauseDist = dwPauseDist; }; + void SetPauseHR(const QString& szPauseHR) { m_szPauseHR = szPauseHR; }; + void SetPausePace(uint32_t dwPausePace) { m_dwPausePace = dwPausePace; }; + void SetChild(CTrainingTask* lpChild) { m_lpChild = lpChild; }; + void Set(int iNum, const QString& szDesc = "", uint32_t dwCount = 0, uint32_t dwTime = 0, uint32_t dwDist = 0, const QString& szHR = "", uint32_t dwPace = 0, uint32_t dwPauseTime = 0, uint32_t dwPauseDist = 0, const QString& szPauseHR = "", uint32_t dwPausePace = 0, CTrainingTask* lpChild = 0) + { + SetNum(iNum); + SetDesc(szDesc); + SetCount(dwCount); + SetTime(dwTime); + SetDist(dwDist); + SetHR(szHR); + SetPace(dwPace); + SetPauseTime(dwPauseTime); + SetPauseDist(dwPauseDist); + SetPauseHR(szPauseHR); + SetPausePace(dwPausePace); + SetChild(lpChild); + }; + int GetNum() { return(m_iNum); }; + QString GetDesc() { return(m_szDesc); }; + uint32_t GetCount() { return(m_dwCount); }; + uint32_t GetTime() { return(m_Time.toDWORD()); }; + uint32_t GetDist() { return(m_dwDist); }; + QString GetHR() { return(m_szHR); }; + uint32_t GetPace() { return(m_dwPace); }; + uint32_t GetPauseTime() { return(m_PauseTime.toDWORD()); }; + uint32_t GetPauseDist() { return(m_dwPauseDist); }; + QString GetPauseHR() { return(m_szPauseHR); }; + uint32_t GetPausePace() { return(m_dwPausePace); }; + CTrainingTask* GetChild() { return(m_lpChild); }; + void CalcPace() { m_dwPace = m_Time.toDWORD()*1000/m_dwDist; }; + void CalcTime() { uint32_t dwTime = m_dwPace*m_dwDist/1000; m_Time = CTime(HOURS(dwTime), MINUTES(dwTime), SECONDS(dwTime)); }; + void CalcDist() { m_dwDist = m_Time.toDWORD()*1000/m_dwPace; }; + void CalcPausePace() { m_dwPausePace = m_PauseTime.toDWORD()*1000/m_dwPauseDist; }; + void CalcPauseTime() { uint32_t dwTime = m_dwPausePace*m_dwPauseDist/1000; m_PauseTime = CTime(HOURS(dwTime), MINUTES(dwTime), SECONDS(dwTime)); }; + void CalcPauseDist() { m_dwPauseDist = m_PauseTime.toDWORD()*1000/m_dwPausePace; }; + bool HasHR() { if(m_szHR.length()) return(true); return(false); }; + bool HasPauseHR() { if(m_szPauseHR.length()) return(true); return(false); }; + bool HasDesc() { if(m_szDesc.length()) return(true); return(false); }; +protected: + int m_iNum; + QString m_szDesc; + uint32_t m_dwCount; + CTime m_Time; + uint32_t m_dwDist; + QString m_szHR; + uint32_t m_dwPace; + CTime m_PauseTime; + uint32_t m_dwPauseDist; + QString m_szPauseHR; + uint32_t m_dwPausePace; + CTrainingTask* m_lpChild; +}; + +class CTrainingSession +{ +public: + CTrainingSession(int iNum, const QString& szDesc = "", const QString& szSport = "", CTrainingTask* lpTrainingTask = 0, CTrainingSession* lpChild = 0) + { + m_szDesc = ""; + m_szSport = ""; + m_lpTrainingTask = 0; + m_lpChild = 0; + Set(iNum, szDesc, szSport, lpTrainingTask, lpChild); + }; + ~CTrainingSession() + { + DELETE(m_lpTrainingTask); + DELETE(m_lpChild); + }; + CTrainingSession* Add(int iNum, const QString& szDesc = "", const QString& szSport = "", CTrainingTask* lpTrainingTask = 0, CTrainingSession* lpChild = 0) + { + if(!m_lpChild) + m_lpChild = new CTrainingSession(iNum, szDesc, szSport, lpTrainingTask, lpChild); + else + m_lpChild->Set(iNum, szDesc, szSport, lpTrainingTask, lpChild); + return(m_lpChild); + }; + CTrainingTask* AddTask(int iNum, const QString& szDesc = "", uint32_t dwCount = 0, uint32_t dwTime = 0, uint32_t dwDist = 0, const QString& szHR = "", uint32_t dwPace = 0, uint32_t dwPauseTime = 0, uint32_t dwPauseDist = 0, const QString& szPauseHR = "", uint32_t dwPausePace = 0, CTrainingTask* lpChild = 0) + { + CTrainingTask* lpTrainingTaskDummy = m_lpTrainingTask; + if(!m_lpTrainingTask) + m_lpTrainingTask = lpTrainingTaskDummy = new CTrainingTask(iNum, szDesc, dwCount, dwTime, dwDist, szHR, dwPace, dwPauseTime, dwPauseDist, szPauseHR, dwPausePace, lpChild); + else + { + while(lpTrainingTaskDummy->GetChild()) + lpTrainingTaskDummy = lpTrainingTaskDummy->GetChild(); + lpTrainingTaskDummy = lpTrainingTaskDummy->Add(iNum, szDesc, dwCount, dwTime, dwDist, szHR, dwPace, dwPauseTime, dwPauseDist, szPauseHR, dwPausePace, lpChild); + } + return(lpTrainingTaskDummy); + }; + void SetNum(int iNum) { m_iNum = iNum; }; + void SetDesc(const QString& szDesc) { m_szDesc = szDesc; }; + void SetSport(const QString& szSport) { m_szSport = szSport; }; + void SetTrainingTask(CTrainingTask* lpTrainingTask) { m_lpTrainingTask = lpTrainingTask; }; + void SetChild(CTrainingSession* lpChild) { m_lpChild = lpChild; }; + void Set(int iNum, const QString& szDesc, const QString& szSport, CTrainingTask* lpTrainingTask = 0, CTrainingSession* lpChild = 0) + { + SetNum(iNum); + SetDesc(szDesc); + SetSport(szSport); + SetTrainingTask(lpTrainingTask); + SetChild(lpChild); + }; + int GetNum() { return(m_iNum); }; + QString GetDesc() { return(m_szDesc); }; + QString GetSport() { return(m_szSport); }; + CTrainingTask* GetTrainingTask() { return(m_lpTrainingTask); }; + CTrainingSession* GetChild() { return(m_lpChild); }; + bool HasSport() { if(m_szSport.length()) return(true); return(false); }; + bool HasDesc() { if(m_szDesc.length()) return(true); return(false); }; + CTrainingSession* Find(int iSession) + { + if(m_iNum == iSession) + return(this); + if(m_lpChild) + return(m_lpChild->Find(iSession)); + return(0); + }; +protected: + int m_iNum; + QString m_szDesc; + QString m_szSport; + CTrainingTask* m_lpTrainingTask; + CTrainingSession* m_lpChild; +}; + +class CTrainingDay +{ +public: + CTrainingDay(int iNum, const QString& szDesc, CTrainingSession* lpTrainingSession = 0, CTrainingDay* lpChild = 0) + { + m_szDesc = ""; + m_lpTrainingSession = 0; + m_lpChild = 0; + Set(iNum, szDesc, lpTrainingSession, lpChild); + }; + ~CTrainingDay() + { + DELETE(m_lpTrainingSession); + DELETE(m_lpChild); + }; + CTrainingDay* Add(int iNum, const QString& szDesc = "", CTrainingSession* lpTrainingSession = 0, CTrainingDay* lpChild = 0) + { + if(!m_lpChild) + m_lpChild = new CTrainingDay(iNum, szDesc, lpTrainingSession, lpChild); + else + m_lpChild->Set(iNum, szDesc, lpTrainingSession, lpChild); + return(m_lpChild); + }; + CTrainingSession* AddTrainingSession(int iNum, const QString& szDesc = "", const QString& szSport = "", CTrainingTask* lpTrainingTask = 0, CTrainingSession* lpChild = 0) + { + CTrainingSession* lpTrainingSessionDummy = m_lpTrainingSession; + if(!m_lpTrainingSession) + m_lpTrainingSession = lpTrainingSessionDummy = new CTrainingSession(iNum, szDesc, szSport, lpTrainingTask, lpChild); + else + { + while(lpTrainingSessionDummy->GetChild()) + lpTrainingSessionDummy = lpTrainingSessionDummy->GetChild(); + lpTrainingSessionDummy = lpTrainingSessionDummy->Add(iNum, szDesc, szSport, lpTrainingTask, lpChild); + } + return(lpTrainingSessionDummy); + }; + CTrainingSession* AddTrainingSession(CTrainingSession* lpTrainingSession) + { + CTrainingSession* lpTrainingSessionDummy = m_lpTrainingSession; + if(!m_lpTrainingSession) + m_lpTrainingSession = lpTrainingSessionDummy = lpTrainingSession; + else + { + int iNum = 0; + while(lpTrainingSessionDummy->GetChild()) + { + iNum++; + lpTrainingSessionDummy->SetNum(iNum); + lpTrainingSessionDummy = lpTrainingSessionDummy->GetChild(); + } + lpTrainingSessionDummy->SetChild(lpTrainingSession); + if(!iNum) + iNum = 1; + while(lpTrainingSessionDummy->GetChild()) + { + iNum++; + lpTrainingSessionDummy->SetNum(iNum); + lpTrainingSessionDummy = lpTrainingSessionDummy->GetChild(); + } + } + return(lpTrainingSession); + }; + void DeleteTrainingSession(CTrainingSession* lpTrainingSession) + { + CTrainingSession* lpTemp; + CTrainingSession* lpNext = lpTrainingSession->GetChild(); + if(m_lpTrainingSession == lpTrainingSession) + { + m_lpTrainingSession = lpNext; + } + else + { + lpTemp = m_lpTrainingSession; + while(lpTemp->GetChild()) + { + if(lpTemp->GetChild() == lpTrainingSession) + { + lpTemp->SetChild(lpNext); + break; + } + lpTemp = lpTemp->GetChild(); + } + } + }; + void SetNum(int iNum) { m_iNum = iNum; }; + void SetDesc(const QString& szDesc) { m_szDesc = szDesc; }; + void SetTrainingSession(CTrainingSession* lpTrainingSession) { m_lpTrainingSession = lpTrainingSession; }; + void SetChild(CTrainingDay* lpChild) { m_lpChild = lpChild; }; + void Set(int iNum, const QString& szDesc, CTrainingSession* lpTrainingSession = 0, CTrainingDay* lpChild = 0) + { + SetNum(iNum); + SetDesc(szDesc); + SetTrainingSession(lpTrainingSession); + SetChild(lpChild); + }; + int GetNum() { return(m_iNum); }; + QString GetDesc() { return(m_szDesc); }; + CTrainingSession* GetTrainingSession() { return(m_lpTrainingSession); }; + CTrainingDay* GetChild() { return(m_lpChild); }; + bool HasDesc() { if(m_szDesc.length()) return(true); return(false); }; + CTrainingDay* Find(int iDay) + { + if(m_iNum == iDay) + return(this); + if(m_lpChild) + return(m_lpChild->Find(iDay)); + return(0); + }; +protected: + int m_iNum; + QString m_szDesc; + CTrainingSession* m_lpTrainingSession; + CTrainingDay* m_lpChild; +}; + +class CTrainingPlan +{ +public: + CTrainingPlan(const QString& szName, const QString& szDesc = "", CTrainingDay* lpTrainingDay = 0, CTrainingPlan* lpChild = 0) + { + m_szName = szName; + m_szDesc = szDesc; + m_lpTrainingDay = lpTrainingDay; + m_lpChild = lpChild; + + m_TrainingStart = QDate::currentDate(); + }; + ~CTrainingPlan() + { + DELETE(m_lpTrainingDay); + DELETE(m_lpChild); + }; + CTrainingDay* AddDay(int iNum, const QString& szDesc = "", CTrainingSession* lpTrainingSession = 0, CTrainingDay* lpChild = 0) + { + CTrainingDay* lpTrainingDayDummy = m_lpTrainingDay; + if(!m_lpTrainingDay) + m_lpTrainingDay = lpTrainingDayDummy = new CTrainingDay(iNum, szDesc, lpTrainingSession, lpChild); + else + { + while(lpTrainingDayDummy->GetChild()) + lpTrainingDayDummy = lpTrainingDayDummy->GetChild(); + lpTrainingDayDummy = lpTrainingDayDummy->Add(iNum, szDesc, lpTrainingSession, lpChild); + } + return(lpTrainingDayDummy); + }; + void SetName(const QString& szName) { m_szName = szName; }; + void SetDesc(const QString& szDesc) { m_szDesc = szDesc; }; + void SetTrainingDay(CTrainingDay* lpTrainingDay) { m_lpTrainingDay = lpTrainingDay; }; + void SetChild(CTrainingPlan* lpChild) { m_lpChild = lpChild; }; + void SetTrainingStart(const QDate& TrainingStart) { m_TrainingStart = TrainingStart; }; + void Set(const QString& szName, const QString& szDesc = "", CTrainingDay* lpTrainingDay = 0, CTrainingPlan* lpChild = 0) + { + SetName(szName); + SetDesc(szDesc); + SetTrainingDay(lpTrainingDay); + SetChild(lpChild); + }; + QString GetName() { return(m_szName); }; + QString GetDesc() { return(m_szDesc); }; + CTrainingDay* GetTrainingDay() { return(m_lpTrainingDay); }; + CTrainingPlan* GetChild() { return(m_lpChild); }; + QDate& GetTrainingStart() { return(m_TrainingStart); }; + bool HasName() { if(m_szName.length()) return(true); return(false); }; + bool HasDesc() { if(m_szDesc.length()) return(true); return(false); }; + void DeleteTrainingDay(int iDay) + { + CTrainingDay* lpNext; + CTrainingDay* lpPrev = m_lpTrainingDay; + if(lpPrev->GetNum() == iDay) + { + lpNext = lpPrev->GetChild(); + lpPrev->SetChild(0); + delete lpPrev; + m_lpTrainingDay = lpNext; + } + else + { + lpNext = lpPrev->GetChild(); + while(lpNext) + { + if(lpNext->GetNum() == iDay) + { + lpPrev->SetChild(lpNext->GetChild()); + lpNext->SetChild(0); + delete lpNext; + break; + } + lpPrev = lpNext; + lpNext = lpNext->GetChild(); + } + } + }; +protected: + QString m_szName; + QString m_szDesc; + CTrainingDay* m_lpTrainingDay; + CTrainingPlan* m_lpChild; + QDate m_TrainingStart; +}; + + +class CTraining +{ +public: + CTraining(); + CTraining(const QString& szFileName); + ~CTraining(); + + bool Load(const QString& szFileName); + bool Save(const QString& szFileName); + void Recalculate(); + + void ParsePerson(const QDomElement& Element); + CSport* ParseSport(const QDomElement& Element, CSport* lpSportDummy); + CTrainingDay* ParseDay(const QDomElement& Element, CTrainingDay* lpTrainingDayDummy); + CTrainingSession* ParseSession(const QDomElement& Element, CTrainingDay* lpTrainingDay, CTrainingSession* lpTrainingSessionDummy); + CTrainingTask* ParseTask(const QDomElement& Element, CTrainingSession* lpTrainingSession, CTrainingTask* lpTrainingTaskDummy); + + bool GetPerson(QString& szFirstName, QString& szLastName, QDate& DayOfBirth, uint32_t& dwHeight, uint32_t& dwWeight); + + bool GetFirstSport(QString& szName, uint32_t& dwMaxHR, bool& bPace); + bool GetNextSport(QString& szName, uint32_t& dwMaxHR, bool& bPace); + + bool GetFirstHR(QString& szName, QString& szDesc, uint32_t& dwMin, uint32_t& dwMax); + bool GetNextHR(QString& szName, QString& szDesc, uint32_t& dwMin, uint32_t& dwMax); + + bool GetFirstTraining(QString& szName, QString& szDesc, QDate& TrainingStart); + bool GetNextTraining(QString& szName, QString& szDesc, QDate& TrainingStart); + + bool GetFirstDay(int& iNum, QString& szDesc); + bool GetNextDay(int& iNum, QString& szDesc); + + bool GetFirstSession(int& iNum, QString& szDesc, QString& szSport); + bool GetNextSession(int& iNum, QString& szDesc, QString& szSport); + + bool GetFirstTask(int& iNum, QString& szDesc, uint32_t& dwCount, uint32_t& dwTime, uint32_t& dwDist, QString& szHR, uint32_t& dwPace, uint32_t& dwPauseTime, uint32_t& dwPauseDist, QString& szPauseHR, uint32_t& dwPausePace); + bool GetNextTask(int& iNum, QString& szDesc, uint32_t& dwCount, uint32_t& dwTime, uint32_t& dwDist, QString& szHR, uint32_t& dwPace, uint32_t& dwPauseTime, uint32_t& dwPauseDist, QString& szPauseHR, uint32_t& dwPausePace); + + void SetTraining(QString szTraining, QDate TrainingStart); + void SetPerson(QString szFirstName, QString szLastName, QDate DayOfBirth, uint32_t dwHeight, uint32_t dwWeight); + void SetDay(int iDay, int iNewDay, QString szNewDesc); + void SetSession(int iDay, int iNewDay, int iSession, QString szDesc, QString szSport); + + void AddSport(QString szName, uint32_t dwMaxHR, bool bPace); + void AddHR(QString szSport, QString szName, QString szDesc, uint32_t dwMin, uint32_t dwMax); + void AddDay(int iDay, QString szDesc); + void AddSession(int iDay, int iSession, QString szDesc, QString szSport); + void AddTask(int iDay, int iSession, int iTask, QString szDesc, uint32_t dwCount, uint32_t dwTime, uint32_t dwDist, QString szHR, uint32_t dwPace, uint32_t dwPauseTime, uint32_t dwPauseDist, QString szPauseHR, uint32_t dwPausePace); +protected: + QString m_szFileName; + CPerson* m_lpPerson; + CSport* m_lpSport; + CSport* m_lpCurSport; + CHR* m_lpCurHR; + CTrainingPlan* m_lpTrainingPlan; + CTrainingPlan* m_lpCurTrainingPlan; + CTrainingDay* m_lpCurTrainingDay; + CTrainingSession* m_lpCurTrainingSession; + CTrainingTask* m_lpCurTrainingTask; + + void Clean(); + void CleanPerson(); + void CleanSport(); + void CleanTrainingPlan(); +private: +}; + +#endif // CTRAINING_H diff --git a/main.cpp b/main.cpp new file mode 100644 index 0000000..7c23116 --- /dev/null +++ b/main.cpp @@ -0,0 +1,20 @@ +#include +#include +#include "mainwindow.h" +#include "common.h" + +int main(int argc, char *argv[]) +{ + QApplication a(argc, argv); + + QString locale = QLocale::system().name(); + + QTranslator translator; + translator.load(QString("qtTrainingPlan_") + locale); + //translator.load(QString("qtTrainingPlan_de")); + a.installTranslator(&translator); + + MainWindow w; + w.show(); + return a.exec(); +} diff --git a/mainwindow.cpp b/mainwindow.cpp new file mode 100644 index 0000000..dad2e11 --- /dev/null +++ b/mainwindow.cpp @@ -0,0 +1,2059 @@ +#include + +#include "mainwindow.h" +#include "ui_mainwindow.h" + +#include "common.h" +#include "cedithr.h" +#include "ceditsport.h" +#include "cedittraining.h" +#include "ceditday.h" +#include "ceditsession.h" +#include "cedittask.h" +#include "cedittasks.h" +#include "cexportpdf.h" + + +#define COL_DESC 0 +#define COL_SPORT 1 +#define COL_COUNT 2 +#define COL_TIME 3 +#define COL_DIST 4 +#define COL_HR 5 +#define COL_PACESPEED 6 +#define COL_PAUSETIME 7 +#define COL_PAUSEDIST 8 +#define COL_PAUSEHR 9 +#define COL_PAUSEPACESPEED 10 + +#define COL_HRSPORT 0 +#define COL_HRMAXHR 1 +#define COL_HRNAME 0 +#define COL_HRDESC 2 +#define COL_HRMIN 3 +#define COL_HRMAX 4 + +#define TXT_WINDOW_TITLE tr("qtTrainingPlan") +#define TXT_NEW tr("new") + + +enum INDENT_PLAN +{ + INDENT_TRAINING = 0, + INDENT_DAY = 1, + INDENT_SESSION = 2, + INDENT_TASK = 3, +}; + +enum INDENT_SPORT +{ + INDENT_SPORT = 0, + INDENT_HR = 1, +}; + +MainWindow::MainWindow(QWidget *parent) + : QMainWindow(parent), ui(new Ui::MainWindow) +{ + Changed(false); + m_szFileName = ""; + m_lpPlanRoot = 0; + m_bDateChanging = false; + ui->setupUi(this); + setWindowTitle(TXT_WINDOW_TITLE+" - "+TXT_NEW); + + m_lpStatusBar = new QStatusBar; + setStatusBar(m_lpStatusBar); + + showMaximized(); + + InitPlanView(); + InitSportView(); + InitCalendarView(); +} + +MainWindow::~MainWindow() +{ + if(m_lpStatusBar) + delete m_lpStatusBar; + + delete ui; +} + +void MainWindow::on_action_New_triggered() +{ + if(!MayClose()) + return; + Clear(); + setWindowTitle(TXT_WINDOW_TITLE+" - "+TXT_NEW); +} + +void MainWindow::on_actionNew_from_triggered() +{ + if(!MayClose()) + return; + QString szFileName = QFileDialog::getOpenFileName(this, tr("Open Training"), QDir::homePath(), tr("Training Files (*.qtp);;XML Files (*.xml)")); + if(szFileName.length()) + { + Clear(); + m_szFileName = szFileName; + LoadPlan(szFileName, true, true, false); + setWindowTitle(TXT_WINDOW_TITLE+" - "+TXT_NEW+" *"); + } +} + +void MainWindow::on_action_Open_triggered() +{ + if(!MayClose()) + return; + QString szFileName = QFileDialog::getOpenFileName(this, tr("Open Training"), QDir::homePath(), tr("Training Files (*.qtp);;XML Files (*.xml)")); + if(szFileName.length()) + { + Clear(); + m_szFileName = szFileName; + LoadPlan(szFileName); + setWindowTitle(QString(TXT_WINDOW_TITLE+" - ")+m_szFileName); + } +} + +void MainWindow::on_action_Save_triggered() +{ + if(!m_szFileName.length()) + on_actionSave_as_triggered(); + else + SavePlan(m_szFileName); +} + +void MainWindow::on_actionSave_as_triggered() +{ + QString szFileName = QFileDialog::getSaveFileName(this, tr("Save Training"), QDir::homePath(), tr("Training Files (*.qtp);;XML Files (*.xml)")); + if(szFileName.length()) + SavePlan(szFileName); +} + +void MainWindow::on_actionE_xit_triggered() +{ + if(MayClose()) + close(); +} + +void MainWindow::on_m_lpFirstName_textChanged(QString ) +{ + HasChanged(); +} + +void MainWindow::on_m_lpLastName_textChanged(QString ) +{ + HasChanged(); +} + +void MainWindow::on_m_lpDayOfBirth_dateChanged(QDate) +{ + HasChanged(); +} + +void MainWindow::on_m_lpHeight_valueChanged(int ) +{ + HasChanged(); +} + +void MainWindow::on_m_lpWeight_valueChanged(int ) +{ + HasChanged(); +} + +void MainWindow::on_m_lpTrainingStart_dateChanged(QDate date) +{ + if(m_bDateChanging) + { + m_bDateChanging = false; + return; + } + m_bDateChanging = true; + Changed(true); + uint32_t dwDays = GetMaxDays(); + ui->m_lpTargetDate->setDate(date.addDays(dwDays-1)); + DrawCalendar(); +} + +void MainWindow::on_m_lpTargetDate_dateChanged(QDate date) +{ + if(m_bDateChanging) + { + m_bDateChanging = false; + return; + } + m_bDateChanging = true; + Changed(true); + uint32_t dwDays = GetMaxDays(); + ui->m_lpTrainingStart->setDate(date.addDays(-dwDays+1)); + DrawCalendar(); +} + +void MainWindow::on_m_lpCalendar_linkClicked(QUrl url) +{ + QString szDay = ""; + QString szSession = ""; + + szDay = url.path().mid(url.path().indexOf("DAY")+3); + if(url.path().indexOf("SESSION")) + { + szDay = szDay.left(szDay.indexOf("SESSION")); + szSession = url.path().mid(url.path().indexOf("SESSION")+7); + } + + QTreeWidgetItem* lpItem = 0; + if(szSession.length()) + lpItem = FindSession(0, szDay.toLong(), szSession.toLong()); + else + lpItem = FindDay(0, szDay.toLong()); + + if(lpItem) + { + ui->m_lpPlanView->setCurrentItem(lpItem); + ui->m_lpMainTab->setCurrentIndex(0); + } +} + +void MainWindow::on_m_lpSportView_customContextMenuRequested(QPoint pos) +{ + QTreeWidgetItem* lpSelected = ui->m_lpSportView->currentItem(); + QAction* lpAction; + QMenu* lpMenu = new QMenu(tr("test"), this); + int iIndent; + + if(!lpSelected) + { + lpAction = lpMenu->addAction(tr("Add sport..."), this, SLOT(AddSport(bool))); + lpMenu->exec(ui->m_lpSportView->mapToGlobal(pos)); + return; + } + + iIndent = GetIndent(lpSelected); + + switch(iIndent) + { + case INDENT_SPORT: + lpAction = lpMenu->addAction(tr("Add sport..."), this, SLOT(AddSport(bool))); + lpAction = lpMenu->addAction(tr("Edit sport..."), this, SLOT(EditSport(bool))); + lpAction = lpMenu->addAction(tr("Delete sport..."), this, SLOT(DeleteSport(bool))); + lpAction = lpMenu->addSeparator(); + lpAction = lpMenu->addAction(tr("Add hr..."), this, SLOT(AddHR(bool))); + break; + case INDENT_HR: + lpAction = lpMenu->addAction(tr("Add hr..."), this, SLOT(AddHR(bool))); + lpAction = lpMenu->addAction(tr("Edit hr..."), this, SLOT(EditHR(bool))); + lpAction = lpMenu->addAction(tr("Delete hr..."), this, SLOT(DeleteHR(bool))); + break; + } + lpMenu->exec(ui->m_lpSportView->mapToGlobal(pos)); +} + +void MainWindow::on_m_lpPlanView_customContextMenuRequested(QPoint pos) +{ + QTreeWidgetItem* lpSelected = ui->m_lpPlanView->currentItem(); + QAction* lpAction; + QMenu* lpMenu = new QMenu(tr("test"), this); + int iIndent; + + if(!lpSelected && !m_lpPlanRoot) + { + lpAction = lpMenu->addAction(tr("Add training..."), this, SLOT(AddTraining(bool))); + lpMenu->exec(ui->m_lpPlanView->mapToGlobal(pos)); + return; + } + + iIndent = GetIndent(lpSelected); + + switch(iIndent) + { + case INDENT_TRAINING: + lpAction = lpMenu->addAction(tr("Add day..."), this, SLOT(AddDay(bool))); + lpAction = lpMenu->addSeparator(); + lpAction = lpMenu->addAction(tr("Edit training..."), this, SLOT(EditPlan(bool))); + lpAction = lpMenu->addAction(tr("Delete training..."), this, SLOT(DeleteTraining(bool))); + break; + case INDENT_DAY: + lpAction = lpMenu->addAction(tr("Add day..."), this, SLOT(AddDay(bool))); + lpAction = lpMenu->addAction(tr("Edit day..."), this, SLOT(EditPlan(bool))); + lpAction = lpMenu->addAction(tr("Delete day..."), this, SLOT(DeleteDay(bool))); + lpAction = lpMenu->addSeparator(); + lpAction = lpMenu->addAction(tr("Add session..."), this, SLOT(AddSession(bool))); + break; + case INDENT_SESSION: + lpAction = lpMenu->addAction(tr("Add day..."), this, SLOT(AddDay(bool))); + lpAction = lpMenu->addSeparator(); + lpAction = lpMenu->addAction(tr("Add session..."), this, SLOT(AddSession(bool))); + lpAction = lpMenu->addAction(tr("Edit session..."), this, SLOT(EditPlan(bool))); + lpAction = lpMenu->addAction(tr("Delete session..."), this, SLOT(DeleteSession(bool))); + lpAction = lpMenu->addSeparator(); + lpAction = lpMenu->addAction(tr("Add task..."), this, SLOT(AddTask(bool))); + lpAction = lpMenu->addSeparator(); + lpAction = lpMenu->addAction(tr("Move up"), this, SLOT(MoveUp(bool))); + lpAction = lpMenu->addAction(tr("Move down"), this, SLOT(MoveDown(bool))); + break; + case INDENT_TASK: + lpAction = lpMenu->addAction(tr("Add day..."), this, SLOT(AddDay(bool))); + lpAction = lpMenu->addSeparator(); + lpAction = lpMenu->addAction(tr("Add session..."), this, SLOT(AddSession(bool))); + lpAction = lpMenu->addSeparator(); + lpAction = lpMenu->addAction(tr("Add task..."), this, SLOT(AddTask(bool))); + lpAction = lpMenu->addAction(tr("Edit task..."), this, SLOT(EditPlan(bool))); + lpAction = lpMenu->addAction(tr("Delete task..."), this, SLOT(DeleteTask(bool))); + lpAction = lpMenu->addSeparator(); + lpAction = lpMenu->addAction(tr("Move up"), this, SLOT(MoveUp(bool))); + lpAction = lpMenu->addAction(tr("Move down"), this, SLOT(MoveDown(bool))); + break; + } + lpMenu->exec(ui->m_lpPlanView->mapToGlobal(pos)); +} + +void MainWindow::on_m_lpPlanView_itemDoubleClicked(QTreeWidgetItem* item, int ) +{ + EditPlan(item); +} + +void MainWindow::closeEvent(QCloseEvent *event) +{ + if(MayClose()) + event->accept(); + else + event->ignore(); +} + +bool MainWindow::MayClose() +{ + if(m_bHasChanged) + { + int ret = QMessageBox::question(this, TXT_WINDOW_TITLE, tr("Training has been changed. Dou you want to save?"), QMessageBox::Yes | QMessageBox::No | QMessageBox::Cancel); + if(ret == QMessageBox::Yes) + on_action_Save_triggered(); + else if(ret == QMessageBox::Cancel) + return(false); + } + return(true); +} + +void MainWindow::Clear() +{ + ui->m_lpSportView->clear(); + ui->m_lpPlanView->clear(); + m_lpPlanRoot = 0; + + ui->m_lpFirstName->setText(""); + ui->m_lpLastName->setText(""); + ui->m_lpDayOfBirth->setDate(QDate::currentDate()); + ui->m_lpHeight->setValue(0); + ui->m_lpWeight->setValue(0); + + ui->m_lpCalendar->setHtml(""); + + Changed(false); +} + +void MainWindow::InitPlanView() +{ + QStringList szLabels; + szLabels << tr("Description") << tr("Sport") << tr("Count") << tr("Time") << tr("Dist") << tr("HR") << tr("Pace/Speed") << tr("P.Time") << tr("P.Dist") << tr("P.HR") << tr("P.Pace/Speed"); + ui->m_lpPlanView->setHeaderLabels(szLabels); + + QHeaderView* lpHeader = ui->m_lpPlanView->header(); + lpHeader->setStretchLastSection(false); + lpHeader->setSectionResizeMode( 0, QHeaderView::Stretch); + lpHeader->setSectionResizeMode( 1, QHeaderView::ResizeToContents); + lpHeader->setSectionResizeMode( 2, QHeaderView::ResizeToContents); + lpHeader->setSectionResizeMode( 3, QHeaderView::ResizeToContents); + lpHeader->setSectionResizeMode( 4, QHeaderView::ResizeToContents); + lpHeader->setSectionResizeMode( 5, QHeaderView::ResizeToContents); + lpHeader->setSectionResizeMode( 6, QHeaderView::ResizeToContents); + lpHeader->setSectionResizeMode( 7, QHeaderView::ResizeToContents); + lpHeader->setSectionResizeMode( 8, QHeaderView::ResizeToContents); + lpHeader->setSectionResizeMode( 9, QHeaderView::ResizeToContents); + lpHeader->setSectionResizeMode(10, QHeaderView::ResizeToContents); +} + +void MainWindow::InitSportView() +{ + QStringList szLabels; + szLabels << tr("Sport") << tr("MaxHR") << tr("HR") << tr("Min-Max (%)") << tr("Min-Max"); + ui->m_lpSportView->setHeaderLabels(szLabels); + + QHeaderView* lpHeader = ui->m_lpSportView->header(); + lpHeader->setStretchLastSection(false); + lpHeader->setSectionResizeMode( 0, QHeaderView::ResizeToContents); + lpHeader->setSectionResizeMode( 1, QHeaderView::ResizeToContents); + lpHeader->setSectionResizeMode( 2, QHeaderView::Stretch); + lpHeader->setSectionResizeMode( 4, QHeaderView::ResizeToContents); + //lpHeader->setSectionResizeMode( 5, QHeaderView::ResizeToContents); +} + +void MainWindow::InitCalendarView() +{ + ui->m_lpCalendar->page()->setLinkDelegationPolicy(QWebPage::DelegateAllLinks); +} + +bool MainWindow::LoadPlan(const QString& szFile, bool bPerson, bool bSport, bool bPlan) +{ + CTraining* lpTraining = new CTraining(szFile.toLatin1().data()); + + if(bPerson) + LoadPerson(lpTraining); + if(bSport) + LoadSport(lpTraining); + if(bPlan) + LoadPlan(lpTraining); + + Changed(false); + + m_bDateChanging = true; + uint32_t dwDays = GetMaxDays(); + ui->m_lpTargetDate->setDate(ui->m_lpTrainingStart->date().addDays(dwDays-1)); + + DrawCalendar(); + return(true); +} + +bool MainWindow::LoadPerson(CTraining* lpTraining) +{ + QString szFirstName; + QString szLastName; + QDate DayOfBirth; + uint32_t dwHeight; + uint32_t dwWeight; + + if(lpTraining->GetPerson(szFirstName, szLastName, DayOfBirth, dwHeight, dwWeight)) + { + ui->m_lpFirstName->setText(szFirstName); + ui->m_lpLastName->setText(szLastName); + ui->m_lpDayOfBirth->setDate(DayOfBirth); + ui->m_lpHeight->setValue(dwHeight); + ui->m_lpWeight->setValue(dwWeight); + } + return(true); +} + +bool MainWindow::LoadSport(CTraining* lpTraining) +{ + QString szSport; + uint32_t dwMaxHR; + bool bPace; + QString szName; + QString szDesc; + uint32_t dwMin; + uint32_t dwMax; + + if(lpTraining->GetFirstSport(szSport, dwMaxHR, bPace)) + { + do + { + QTreeWidgetItem* lpSport = AddSport(szSport, dwMaxHR, bPace); + if(lpTraining->GetFirstHR(szName, szDesc, dwMin, dwMax)) + { + do + { + /*QTreeWidgetItem* lpHR = */AddHR(lpSport, szName, szDesc, dwMaxHR, dwMin, dwMax); + } while(lpTraining->GetNextHR(szName, szDesc, dwMin, dwMax)); + } + } while(lpTraining->GetNextSport(szSport, dwMaxHR, bPace)); + } + return(true); +} + +bool MainWindow::LoadPlan(CTraining* lpTraining) +{ + QString szName; + QString szDesc; + QString szSport; + QString szHR; + int iTraining; + int iDay; + int iSession; + int iTask; + uint32_t dwCount; + uint32_t dwTime; + uint32_t dwDist; + uint32_t dwPace; + uint32_t dwPauseTime; + uint32_t dwPauseDist; + QString szPauseHR; + uint32_t dwPausePace; + QDate TrainingStart; + + + if(lpTraining->GetFirstTraining(szName, szDesc, TrainingStart)) + { + iTraining = 1; + ui->m_lpTrainingStart->setDate(TrainingStart); + + AddTraining(iTraining, szName); + if(lpTraining->GetFirstDay(iDay, szDesc)) + { + do + { + AddDay(iTraining, iDay, QString("(%1) %2").arg(iDay).arg(szDesc)); + if(lpTraining->GetFirstSession(iSession, szDesc, szSport)) + { + do + { + AddSession(iTraining, iDay, iSession, szDesc, szSport); + if(lpTraining->GetFirstTask(iTask, szDesc, dwCount, dwTime, dwDist, szHR, dwPace, dwPauseTime, dwPauseDist, szPauseHR, dwPausePace)) + { + do + { + AddTask(iTraining, iDay, iSession, iTask, szDesc, szSport, dwCount, dwTime, dwDist, szHR, dwPace, dwPauseTime, dwPauseDist, szPauseHR, dwPausePace); + } while(lpTraining->GetNextTask(iTask, szDesc, dwCount, dwTime, dwDist, szHR, dwPace, dwPauseTime, dwPauseDist, szPauseHR, dwPausePace)); + } + } while(lpTraining->GetNextSession(iSession, szDesc, szSport)); + } + } while(lpTraining->GetNextDay(iDay, szDesc)); + } + } + return(true); +} + +CClientData* MainWindow::GetClientData(QTreeWidgetItem* lpItem) +{ + QVariant data = lpItem->data(0, Qt::UserRole); + CClientData* lpData = (CClientData*)data.toInt(); + return(lpData); +} + +QTreeWidgetItem* MainWindow::AddChild(QTreeWidgetItem* lpRoot, const QString& szText, CClientData* lpClientData, Qt::AlignmentFlag iAlign, const QColor& Color, const QColor& BGColor, int iPos) +{ + if(!lpRoot) + return(0); + + QVariant data((qlonglong)lpClientData); + QTreeWidgetItem* lpChild; + if(iPos != -1) + { + lpChild = new QTreeWidgetItem(); + lpRoot->insertChild(iPos, lpChild); + } + else + lpChild = new QTreeWidgetItem(lpRoot); + lpChild->setText(0, szText); + lpChild->setData(0, Qt::UserRole, data); + lpChild->setTextAlignment(0, iAlign); + for(int i = 0;i < ui->m_lpPlanView->columnCount();i++) + { + lpChild->setForeground(i, QBrush(Color)); + lpChild->setBackground(i, QBrush(BGColor)); + } + return(lpChild); +} + +QTreeWidgetItem* MainWindow::AddChild(QTreeWidget* lpRoot, const QString& szText, CClientData* lpClientData, Qt::AlignmentFlag iAlign, const QColor& Color, const QColor& BGColor) +{ + if(!lpRoot) + return(0); + + QVariant data((qlonglong)lpClientData); + QTreeWidgetItem* lpChild = new QTreeWidgetItem(lpRoot); + lpChild->setText(0, szText); + lpChild->setData(0, Qt::UserRole, data); + lpChild->setTextAlignment(0, iAlign); + for(int i = 0;i < ui->m_lpPlanView->columnCount();i++) + { + lpChild->setForeground(i, QBrush(Color)); + lpChild->setBackground(i, QBrush(BGColor)); + } + return(lpChild); +} + +QTreeWidgetItem* MainWindow::SetChildText(QTreeWidgetItem* lpItem, int iCol, const QString& szText, Qt::AlignmentFlag iAlign) +{ + lpItem->setText(iCol, szText); + lpItem->setTextAlignment(iCol, iAlign); + return(lpItem); +} + +QTreeWidgetItem* MainWindow::FindSport(const QString& szSport) +{ + for(int i = 0;i < ui->m_lpSportView->topLevelItemCount();i++) + { + QTreeWidgetItem* lpChild = ui->m_lpSportView->topLevelItem(i); + CClientData* lpData = GetClientData(lpChild); + if(lpData->GetSportName() == szSport) + return(lpChild); + } + return(0); +} + +QTreeWidgetItem* MainWindow::FindHR(const QString& szSport, const QString& szHR) +{ + QTreeWidgetItem* lpSport = FindSport(szSport); + if(!lpSport) + return(0); + + for(int i = 0;i < lpSport->childCount();i++) + { + QTreeWidgetItem* lpChild = lpSport->child(i); + CClientData* lpData = GetClientData(lpChild); + if(lpData->GetHRName() == szHR) + return(lpChild); + } + return(0); +} + +QTreeWidgetItem* MainWindow::AddSport(const QString& szSport, uint32_t dwMaxHR, bool bPace) +{ + CClientData* lpClientData; + + lpClientData = new CClientData(szSport, dwMaxHR, bPace); + if(!dwMaxHR) + dwMaxHR = 180; + QTreeWidgetItem* lpSport = AddChild(ui->m_lpSportView, szSport, lpClientData, Qt::AlignLeft, QColor(0, 0, 0), QColor(255, 255, 255)); + ui->m_lpSportView->addTopLevelItem(lpSport); + SetChildText(lpSport, COL_HRMAXHR, QString("%1").arg(dwMaxHR), Qt::AlignRight); + SetChildText(lpSport, COL_HRMAXHR+1, bPace ? tr("Pace") : tr("Speed"), Qt::AlignLeft); + return(lpSport); +} + +QTreeWidgetItem* MainWindow::AddHR(QTreeWidgetItem* lpRoot, const QString& szName, const QString& szDesc, uint32_t dwMaxHR, uint32_t dwMin, uint32_t dwMax) +{ + CClientData* lpClientData; + + lpClientData = new CClientData(szName, szDesc, dwMin, dwMax); + QTreeWidgetItem* lpHR = AddChild(lpRoot, szName, lpClientData, Qt::AlignLeft, QColor(0, 0, 0), QColor(255, 255, 255)); + SetChildText(lpHR, COL_HRDESC, szDesc, Qt::AlignLeft); + SetChildText(lpHR, COL_HRMIN, QString("%1\% - %2\%").arg(dwMin).arg(dwMax), Qt::AlignRight); + SetChildText(lpHR, COL_HRMAX, QString("%1 - %2").arg(dwMaxHR*dwMin/100).arg(dwMaxHR*dwMax/100), Qt::AlignRight); + return(lpHR); +} + +bool MainWindow::AddTraining(int iTraining, const QString& szName) +{ + if(m_lpPlanRoot) + return(false); + + iTraining = iTraining; + m_lpPlanRoot = AddChild(ui->m_lpPlanView, szName, 0, Qt::AlignLeft, QColor(0, 0, 0), QColor(255, 255, 255)); + m_lpPlanRoot->setExpanded(true); + return(true); +} + +QTreeWidgetItem* MainWindow::FindTraining(int iTraining) +{ + iTraining = iTraining; + return(m_lpPlanRoot); +} + +QTreeWidgetItem* MainWindow::FindTraining(const QString& /*szTraining*/) +{ + return(m_lpPlanRoot); +} + +QTreeWidgetItem* MainWindow::AddDay(int iTraining, int iDay, const QString& szDesc) +{ + QTreeWidgetItem* lpTraining = FindTraining(iTraining); + if(!lpTraining) + return(false); + + CClientData* lpClientData = new CClientData(iDay, szDesc); + return(AddChild(lpTraining, szDesc, lpClientData, Qt::AlignLeft, QColor(0, 0, 0), QColor(223, 223, 223))); +} + +QTreeWidgetItem* MainWindow::AddDay(QTreeWidgetItem* lpRoot, int iDay, const QString& szDesc, int iPos) +{ + CClientData* lpClientData = new CClientData(iDay, szDesc); + return(AddChild(lpRoot, szDesc, lpClientData, Qt::AlignLeft, QColor(0, 0, 0), QColor(223, 223, 223), iPos)); +} + +QTreeWidgetItem* MainWindow::FindDay(int iTraining, int iDay) +{ + QTreeWidgetItem* lpTraining = FindTraining(iTraining); + if(!lpTraining) + return(0); + + for(int i = 0;i < lpTraining->childCount();i++) + { + QTreeWidgetItem* lpChild = lpTraining->child(i); + CClientData* lpData = GetClientData(lpChild); + if(lpData->GetDay() == iDay) + return(lpChild); + } + return(0); +} + +QTreeWidgetItem* MainWindow::FindDay(const QString& szTraining, const QString& szDay) +{ + QTreeWidgetItem* lpTraining = FindTraining(szTraining); + if(!lpTraining) + return(0); + + for(int i = 0;i < lpTraining->childCount();i++) + { + QTreeWidgetItem* lpChild = lpTraining->child(i); + CClientData* lpData = GetClientData(lpChild); + if(lpData->GetDayDesc() == szDay || lpChild->text(0) == szDay) + return(lpChild); + } + return(0); +} + +QTreeWidgetItem* MainWindow::AddSession(int iTraining, int iDay, int iSession, const QString& szDesc, const QString& szSport) +{ + QTreeWidgetItem* lpDay = FindDay(iTraining, iDay); + if(!lpDay) + return(0); + + CClientData* lpClientData = new CClientData(iSession, szDesc, szSport); + QTreeWidgetItem* lpChild = AddChild(lpDay, szDesc, lpClientData, Qt::AlignLeft, QColor(0, 0, 255), QColor(255, 255, 255)); + SetChildText(lpChild, COL_SPORT, szSport, Qt::AlignLeft); + + return(lpChild); +} + +QTreeWidgetItem* MainWindow::AddSession(QTreeWidgetItem* lpRoot, int iSession, const QString& szDesc, const QString& szSport) +{ + CClientData* lpClientData = new CClientData(iSession, szDesc, szSport); + QTreeWidgetItem* lpChild = AddChild(lpRoot, szDesc, lpClientData, Qt::AlignLeft, QColor(0, 0, 255), QColor(255, 255, 255)); + SetChildText(lpChild, COL_SPORT, szSport, Qt::AlignLeft); + + return(lpChild); +} + +QTreeWidgetItem* MainWindow::FindSession(int iTraining, int iDay, int iSession) +{ + QTreeWidgetItem* lpDay = FindDay(iTraining, iDay); + if(!lpDay) + return(0); + + for(int i = 0;i < lpDay->childCount();i++) + { + QTreeWidgetItem* lpChild = lpDay->child(i); + CClientData* lpData = GetClientData(lpChild); + if(lpData->GetSession() == iSession) + return(lpChild); + } + return(0); +} + +QTreeWidgetItem* MainWindow::FindSession(const QString& szTraining, const QString& szDay, const QString& szSession) +{ + QTreeWidgetItem* lpDay = FindDay(szTraining, szDay); + if(!lpDay) + return(0); + + for(int i = 0;i < lpDay->childCount();i++) + { + QTreeWidgetItem* lpChild = lpDay->child(i); + CClientData* lpData = GetClientData(lpChild); + if(lpData->GetSessionDesc() == szSession) + return(lpChild); + } + return(0); +} + +QTreeWidgetItem* MainWindow::AddTask(int iTraining, int iDay, int iSession, int iTask, const QString& szDesc, const QString& szSport, uint32_t dwCount, uint32_t dwTime, uint32_t dwDist, const QString& szHR, uint32_t dwPace, uint32_t dwPauseTime, uint32_t dwPauseDist, const QString& szPauseHR, uint32_t dwPausePace) +{ + QTreeWidgetItem* lpSession = FindSession(iTraining, iDay, iSession); + if(!lpSession) + return(false); + + CTime Time(dwTime); + CTime PauseTime(dwPauseTime); + CClientData* lpClientData = new CClientData(iTask, szDesc, dwCount, Time, dwDist, szHR, dwPace, PauseTime, dwPauseDist, szPauseHR, dwPausePace); + QTreeWidgetItem* lpChild = AddChild(lpSession, szDesc, lpClientData, Qt::AlignLeft, QColor(0, 0, 0), QColor(255, 255, 255)); + SetChildText(lpChild, COL_COUNT, QString("%1").arg(dwCount), Qt::AlignRight); + SetChildText(lpChild, COL_TIME, CTime(dwTime).Format(), Qt::AlignRight); + SetChildText(lpChild, COL_DIST, DWORD2String(dwDist), Qt::AlignRight); + SetChildText(lpChild, COL_HR, FormatHR(szSport, szHR), Qt::AlignRight); + SetChildText(lpChild, COL_PACESPEED, FormatPace(szSport, dwPace), Qt::AlignRight); + if(dwCount > 1) + { + SetChildText(lpChild, COL_PAUSETIME, CTime(dwPauseTime).Format(), Qt::AlignRight); + SetChildText(lpChild, COL_PAUSEDIST, DWORD2String(dwPauseDist), Qt::AlignRight); + SetChildText(lpChild, COL_PAUSEHR, FormatHR(szSport, szPauseHR), Qt::AlignRight); + SetChildText(lpChild, COL_PAUSEPACESPEED, FormatPace(szSport, dwPausePace), Qt::AlignRight); + } + + CalculateSession(lpSession); + + return(lpChild); +} + +QTreeWidgetItem* MainWindow::AddTask(QTreeWidgetItem* lpRoot, int iTask, const QString& szDesc, const QString& szSport, uint32_t dwCount, uint32_t dwTime, uint32_t dwDist, const QString& szHR, uint32_t dwPace, uint32_t dwPauseTime, uint32_t dwPauseDist, const QString& szPauseHR, uint32_t dwPausePace) +{ + CTime Time(dwTime); + CTime PauseTime(dwPauseTime); + CClientData* lpClientData = new CClientData(iTask, szDesc, dwCount, Time, dwDist, szHR, dwPace, PauseTime, dwPauseDist, szPauseHR, dwPausePace); + QTreeWidgetItem* lpChild = AddChild(lpRoot, szDesc, lpClientData, Qt::AlignLeft, QColor(0, 0, 0), QColor(255, 255, 255)); + SetChildText(lpChild, COL_COUNT, QString("%1").arg(dwCount), Qt::AlignRight); + SetChildText(lpChild, COL_TIME, CTime(dwTime).Format(), Qt::AlignRight); + SetChildText(lpChild, COL_DIST, DWORD2String(dwDist), Qt::AlignRight); + SetChildText(lpChild, COL_HR, FormatHR(szSport, szHR), Qt::AlignRight); + SetChildText(lpChild, COL_PACESPEED, FormatPace(szSport, dwPace), Qt::AlignRight); + if(dwCount > 1) + { + SetChildText(lpChild, COL_PAUSETIME, CTime(dwPauseTime).Format(), Qt::AlignRight); + SetChildText(lpChild, COL_PAUSEDIST, DWORD2String(dwPauseDist), Qt::AlignRight); + SetChildText(lpChild, COL_PAUSEHR, FormatHR(szSport, szPauseHR), Qt::AlignRight); + SetChildText(lpChild, COL_PAUSEPACESPEED, FormatPace(szSport, dwPausePace), Qt::AlignRight); + } + + CalculateSession(lpRoot); + + return(lpChild); +} + +bool MainWindow::GetTaskData(QTreeWidgetItem* lpItem, QString& szDesc, uint32_t& dwTaskCount, uint32_t& dwTaskTime, uint32_t& dwTaskDist, QString& szTaskHR, uint32_t& dwTaskPace, uint32_t& dwTaskPauseTime, uint32_t& dwTaskPauseDist, QString& szTaskPauseHR, uint32_t& dwTaskPausePace) +{ + szDesc = lpItem->text(0); + dwTaskCount = String2DWORD(lpItem->text(COL_COUNT).toLatin1().data()); + dwTaskTime = CTime(lpItem->text(COL_TIME)).toDWORD(); + dwTaskDist = String2DWORD(lpItem->text(COL_DIST).toLatin1().data()); + szTaskHR = lpItem->text(COL_HR); + dwTaskPace = CTime(lpItem->text(COL_PACESPEED)).toDWORD(); + if(dwTaskCount > 1) + { + dwTaskPauseTime = CTime(lpItem->text(COL_PAUSETIME)).toDWORD(); + dwTaskPauseDist = String2DWORD(lpItem->text(COL_PAUSEDIST).toLatin1().data()); + szTaskPauseHR = lpItem->text(COL_PAUSEHR); + dwTaskPausePace =CTime(lpItem->text(COL_PAUSEPACESPEED)).toDWORD(); + } + else + { + dwTaskPauseTime = 0; + dwTaskPauseDist = 0; + szTaskPauseHR = ""; + dwTaskPausePace = 0; + } + return(true); +} + +void MainWindow::SetTaskData(QTreeWidgetItem* lpItem, const QString& szDesc, uint32_t dwCount, uint32_t dwTime, uint32_t dwDist, const QString& szHR, uint32_t dwPace, uint32_t dwPauseTime, uint32_t dwPauseDist, const QString& szPauseHR, uint32_t dwPausePace, const QString& szSport) +{ + CTime Time(dwTime); + CTime PauseTime(dwPauseTime); + lpItem->setText(0, szDesc); + SetChildText(lpItem, COL_COUNT, QString("%1").arg(dwCount), Qt::AlignRight); + SetChildText(lpItem, COL_TIME, QDate(HOURS(dwTime), MINUTES(dwTime), SECONDS(dwTime)).toString(tr("yyyyMMdd")), Qt::AlignRight); + SetChildText(lpItem, COL_DIST, DWORD2String(dwDist), Qt::AlignRight); + SetChildText(lpItem, COL_HR, FormatHR(szSport, szHR), Qt::AlignRight); + SetChildText(lpItem, COL_PACESPEED, FormatPace(szSport, dwPace), Qt::AlignRight); + SetChildText(lpItem, COL_PAUSETIME, QDate(HOURS(dwPauseTime), MINUTES(dwPauseTime), SECONDS(dwPauseTime)).toString(tr("yyyyMMdd")), Qt::AlignRight); + SetChildText(lpItem, COL_PAUSEDIST, DWORD2String(dwPauseDist), Qt::AlignRight); + SetChildText(lpItem, COL_PAUSEHR, FormatHR(szSport, szPauseHR), Qt::AlignRight); + SetChildText(lpItem, COL_PAUSEPACESPEED, FormatPace(szSport, dwPausePace), Qt::AlignRight); + + CalculateSession(lpItem->parent()); +} + +void MainWindow::CalculateSession(QTreeWidgetItem* lpSession) +{ + if(!lpSession) + return; + + QString szDesc; + uint32_t dwTaskCount; + uint32_t dwTaskTime; + uint32_t dwTaskDist; + QString szTaskHR; + uint32_t dwTaskPace; + uint32_t dwTaskPauseTime; + uint32_t dwTaskPauseDist; + QString szTaskPauseHR; + uint32_t dwTaskPausePace; + uint32_t dwTime = 0; + uint32_t dwDist = 0; + + for(int i = 0;i < lpSession->childCount();i++) + { + QTreeWidgetItem* lpChild = lpSession->child(i); + + GetTaskData(lpChild, szDesc, dwTaskCount, dwTaskTime, dwTaskDist, szTaskHR, dwTaskPace, dwTaskPauseTime, dwTaskPauseDist, szTaskPauseHR, dwTaskPausePace); + + dwTime += dwTaskTime * dwTaskCount + dwTaskPauseTime * (dwTaskCount-1); + dwDist += dwTaskDist * dwTaskCount + dwTaskPauseDist * (dwTaskCount-1); + } + if(dwTime) + SetChildText(lpSession, COL_TIME, CTime(dwTime).Format(), Qt::AlignRight); + if(dwDist) + SetChildText(lpSession, COL_DIST, DWORD2String(dwDist), Qt::AlignRight); + + QTreeWidgetItem* lpDay = lpSession->parent(); + CalculateDay(lpDay); +} + +void MainWindow::CalculateDay(QTreeWidgetItem* lpDay) +{ + uint32_t dwDayTime; + uint32_t dwDayDist; + uint32_t dwTime = 0; + uint32_t dwDist = 0; + + for(int i = 0;i < lpDay->childCount();i++) + { + QTreeWidgetItem* lpChild = lpDay->child(i); + QString sz = lpChild->text(COL_TIME); + dwDayTime = CTime(lpChild->text(COL_TIME)).toDWORD(); + dwDayDist = String2DWORD(lpChild->text(COL_DIST).toLatin1().data()); + + dwTime += dwDayTime; + dwDist += dwDayDist; + } + if(dwTime) + SetChildText(lpDay, COL_TIME, CTime(dwTime).Format(), Qt::AlignRight); + if(dwDist) + SetChildText(lpDay, COL_DIST, DWORD2String(dwDist), Qt::AlignRight); +} + +int MainWindow::GetIndent(QTreeWidgetItem* lpItem) +{ + int iIndent = 0; + QTreeWidgetItem* lpParent; + + lpParent = lpItem->parent(); + while(lpParent) + { + iIndent++; + lpParent = lpParent->parent(); + } + return(iIndent); +} + +QString MainWindow::FormatHR(const QString& szSport, const QString& szHR) +{ + QString szRet = szHR; + QTreeWidgetItem* lpSport = FindSport(szSport); + QTreeWidgetItem* lpHR = FindHR(szSport, szHR); + + if(!lpSport) + return(szRet); + if(!lpHR) + return(szRet); + + CClientData* lpSportData = GetClientData(lpSport); + CClientData* lpHRData = GetClientData(lpHR); + uint32_t dwMaxHR = lpSportData->GetSportMaxHR(); + if(!dwMaxHR) + dwMaxHR = 180; + + if(lpHRData->GetHRMin() != lpHRData->GetHRMax()) + szRet = QString("%1 (%2 - %3)").arg(szHR).arg(lpHRData->GetHRMin()*dwMaxHR/100).arg(lpHRData->GetHRMax()*dwMaxHR/100); + else + szRet = QString("%1 (%2)").arg(szHR).arg(lpHRData->GetHRMin()*dwMaxHR/100); + + return(szRet); +} + +QString MainWindow::FormatPace(const QString& szSport, uint32_t dwPace) +{ + QString szRet = QString(""); + QTreeWidgetItem* lpSport = FindSport(szSport); + + if(!dwPace) + return(szRet); + if(!lpSport) + return(szRet); + + CClientData* lpSportData = GetClientData(lpSport); + if(lpSportData->GetSportPace()) + szRet = CTime(dwPace).Format()+QString(tr(" min/km")); + else + szRet = QString(tr("%1 km/h")).arg(3600/(double)dwPace, 0, 'f'); + + return(szRet); +} + +void MainWindow::EditPlan(bool) +{ + QTreeWidgetItem* lpSelected = ui->m_lpPlanView->currentItem(); + if(!lpSelected) + return; + EditPlan(lpSelected, true); +} + +void MainWindow::AddSport(bool) +{ + CEditSport* lpNewSport = new CEditSport(this); + if(lpNewSport->exec() == QDialog::Accepted) + { + QString szName = lpNewSport->GetName(); + uint32_t dwMaxHR = lpNewSport->GetMaxHR(); + bool bPace = lpNewSport->GetPace(); + AddSport(szName, dwMaxHR, bPace); + } +} + +void MainWindow::EditSport(bool) +{ + QTreeWidgetItem* lpSelected = ui->m_lpSportView->currentItem(); + if(!lpSelected) + return; + EditSport(lpSelected, true); +} + +void MainWindow::DeleteSport(bool) +{ + if(MESSAGE_QUESTION(tr("Are you sure you want to delete this sport?")) == QMessageBox::Yes) + { + QTreeWidgetItem* lpSelected = ui->m_lpSportView->currentItem(); + delete lpSelected; + } +} + +void MainWindow::AddHR(bool) +{ + QTreeWidgetItem* lpSelected = ui->m_lpSportView->currentItem(); + if(!lpSelected) + return; + + CEditHR* lpNewHR = new CEditHR(this); + if(lpNewHR->exec() == QDialog::Accepted) + { + QString szName = lpNewHR->GetName(); + QString szDesc = lpNewHR->GetDesc(); + uint32_t dwMin = lpNewHR->GetMin(); + uint32_t dwMax = lpNewHR->GetMax(); + CClientData* lpClientData = GetClientData(lpSelected); + uint32_t dwMaxHR = lpClientData->GetSportMaxHR(); + AddHR(lpSelected, szName, szDesc, dwMaxHR, dwMin, dwMax); + } +} + +void MainWindow::EditHR(bool) +{ + QTreeWidgetItem* lpSelected = ui->m_lpSportView->currentItem(); + if(!lpSelected) + return; + EditHR(lpSelected, true); +} + +void MainWindow::DeleteHR(bool) +{ + if(MESSAGE_QUESTION(tr("Are you sure you want to delete this HR?")) == QMessageBox::Yes) + { + QTreeWidgetItem* lpSelected = ui->m_lpSportView->currentItem(); + delete lpSelected; + } +} + +void MainWindow::AddTraining(bool) +{ + CEditTraining* lpNewTraining = new CEditTraining(this); + if(lpNewTraining->exec() == QDialog::Accepted) + { + QString szName = lpNewTraining->GetTraining(); + AddTraining(0, szName); + } + delete lpNewTraining; +} + +void MainWindow::AddDay(bool) +{ + CEditDay* lpNewDay = new CEditDay(this); + if(lpNewDay->exec() == QDialog::Accepted) + { + int iDay = lpNewDay->GetDay(); + QString szDesc = lpNewDay->GetDesc(); + if(FindDay(0, iDay)) + { + MESSAGE(tr("Day allready exists!")); + delete lpNewDay; + return; + } + + QTreeWidgetItem* lpTraining = FindTraining(0); + if(!lpTraining) + { + MESSAGE(tr("No training available!")); + delete lpNewDay; + return; + } + + int i; + for(i = lpTraining->childCount()-1;i >= 0;i--) + { + QTreeWidgetItem* lpInsert = lpTraining->child(i); + CClientData* lpData = GetClientData(lpInsert); + if(lpData->GetDay() < iDay) + break; + } + QTreeWidgetItem* lpDay = AddDay(lpTraining, iDay, QString("(%1) %2").arg(iDay).arg(szDesc), i+1); + ui->m_lpPlanView->setCurrentItem(lpDay); + HasChanged(); + } + delete lpNewDay; +} + +void MainWindow::AddSession(bool) +{ + CEditSession* lpNewSession = new CEditSession(this); + QStringList DayList; + QStringList SportList; + QTreeWidgetItem* lpDay = ui->m_lpPlanView->currentItem(); + CClientData* lpClientData; + int i; + + while(GetIndent(lpDay) > INDENT_DAY) + lpDay = lpDay->parent(); + lpClientData = GetClientData(lpDay); + + for(i = 0;i < m_lpPlanRoot->childCount();i++) + DayList << m_lpPlanRoot->child(i)->text(0); + + for(int i = 0;i < ui->m_lpSportView->topLevelItemCount();i++) + SportList << ui->m_lpSportView->topLevelItem(i)->text(0); + + lpNewSession->Set(DayList, SportList, lpDay->text(0), "", ""); + if(lpNewSession->exec() == QDialog::Accepted) + { + QString szDay = lpNewSession->GetDay(); + QString szDesc = lpNewSession->GetDesc(); + QString szSport = lpNewSession->GetSport(); + + lpDay = FindDay(QString(""), szDay); + int iSession = -1; + QTreeWidgetItem* lpSession; + for(i = 0;i < lpDay->childCount();i++) + { + lpClientData = GetClientData(lpDay->child(i)); + if(lpClientData->GetSession() > iSession) + iSession = lpClientData->GetSession(); + } + lpSession = AddSession(lpDay, iSession+1, szDesc, szSport); + ui->m_lpPlanView->setCurrentItem(lpSession); + HasChanged(); + } + delete lpNewSession; +} + +void MainWindow::AddTask(bool) +{ + QTreeWidgetItem* lpSession = ui->m_lpPlanView->currentItem(); + CClientData* lpClientData; + CClientData* lpClientDataSport; + QStringList HRList; + int i; + + while(GetIndent(lpSession) > INDENT_SESSION) + lpSession = lpSession->parent(); + lpClientData = GetClientData(lpSession); + + QTreeWidgetItem* lpSport = FindSport(lpClientData->GetSessionSport()); + lpClientDataSport = GetClientData(lpSport); + + for(i = 0;i < lpSport->childCount();i++) + HRList << QString("%1 (%2)").arg(lpSport->child(i)->text(0)).arg(lpSport->child(i)->text(4)); + + QString sz = lpClientData->GetSessionSport(); + if(lpClientDataSport->GetSportPace()) + { + CEditTask* lpNewTask = new CEditTask(this); + lpNewTask->Set(HRList, "", 1, CTime(0, 0, 0), 0, 0, 0, CTime(0, 0, 0), 0, 0, 0); + if(lpNewTask->exec() == QDialog::Accepted) + { + int iTask = -1; + QTreeWidgetItem* lpTask; + for(i = 0;i < lpSession->childCount();i++) + { + lpClientData = GetClientData(lpSession->child(i)); + if(lpClientData->GetTask() > iTask) + iTask = lpClientData->GetTask(); + } + lpTask = AddTask(lpSession, iTask+1, lpNewTask->GetDesc(), lpSession->text(COL_SPORT), lpNewTask->GetCount(), lpNewTask->GetTime().toDWORD(), lpNewTask->GetDist(), lpNewTask->GetHR(), lpNewTask->GetPace(), lpNewTask->GetPauseTime().toDWORD(), lpNewTask->GetPauseDist(), lpNewTask->GetPauseHR(), lpNewTask->GetPausePace()); + ui->m_lpPlanView->setCurrentItem(lpTask); + } + delete lpNewTask; + HasChanged(); + } + else + { + CEditTaskS* lpNewTask = new CEditTaskS(this); + lpNewTask->Set(HRList, "", 1, CTime(0, 0, 0), 0, 0, 0, CTime(0, 0, 0), 0, 0, 0); + if(lpNewTask->exec() == QDialog::Accepted) + { + int iTask = -1; + QTreeWidgetItem* lpTask; + for(i = 0;i < lpSession->childCount();i++) + { + lpClientData = GetClientData(lpSession->child(i)); + if(lpClientData->GetTask() > iTask) + iTask = lpClientData->GetTask(); + } + lpTask = AddTask(lpSession, iTask+1, lpNewTask->GetDesc(), lpSession->text(COL_SPORT), lpNewTask->GetCount(), lpNewTask->GetTime().toDWORD(), lpNewTask->GetDist(), lpNewTask->GetHR(), lpNewTask->GetPace(), lpNewTask->GetPauseTime().toDWORD(), lpNewTask->GetPauseDist(), lpNewTask->GetPauseHR(), lpNewTask->GetPausePace()); + ui->m_lpPlanView->setCurrentItem(lpTask); + } + delete lpNewTask; + HasChanged(); + } +} + +void MainWindow::DeleteTraining(bool) +{ + if(MESSAGE_QUESTION(tr("Are you sure you want to delete this training?")) == QMessageBox::Yes) + { + QTreeWidgetItem* lpSelected = ui->m_lpPlanView->currentItem(); + delete lpSelected; + HasChanged(); + } +} + +void MainWindow::DeleteDay(bool) +{ + if(MESSAGE_QUESTION(tr("Are you sure you want to delete this day?")) == QMessageBox::Yes) + { + QTreeWidgetItem* lpSelected = ui->m_lpPlanView->currentItem(); + delete lpSelected; + HasChanged(); + } +} + +void MainWindow::DeleteSession(bool) +{ + if(MESSAGE_QUESTION(tr("Are you sure you want to delete this session?")) == QMessageBox::Yes) + { + QTreeWidgetItem* lpSelected = ui->m_lpPlanView->currentItem(); + QTreeWidgetItem* lpDay = lpSelected->parent(); + delete lpSelected; + HasChanged(); + CalculateDay(lpDay); + } +} + +void MainWindow::DeleteTask(bool) +{ + if(MESSAGE_QUESTION(tr("Are you sure you want to delete this task?")) == QMessageBox::Yes) + { + QTreeWidgetItem* lpSelected = ui->m_lpPlanView->currentItem(); + QTreeWidgetItem* lpSession = lpSelected->parent(); + delete lpSelected; + HasChanged(); + CalculateSession(lpSession); + } +} + +void MainWindow::MoveUp(bool) +{ + QTreeWidgetItem* lpSelected = ui->m_lpPlanView->currentItem(); + QTreeWidgetItem* lpParent = lpSelected->parent(); + int iIndex = lpParent->indexOfChild(lpSelected)-1; + + if(iIndex < 0) + return; + + lpParent->removeChild(lpSelected); + lpParent->insertChild(iIndex, lpSelected); + ui->m_lpPlanView->setCurrentItem(lpSelected); + HasChanged(); +} + +void MainWindow::MoveDown(bool) +{ + QTreeWidgetItem* lpSelected = ui->m_lpPlanView->currentItem(); + QTreeWidgetItem* lpParent = lpSelected->parent(); + int iIndex = lpParent->indexOfChild(lpSelected)+1; + + if(iIndex >= lpParent->childCount()) + return; + + lpParent->removeChild(lpSelected); + lpParent->insertChild(iIndex, lpSelected); + ui->m_lpPlanView->setCurrentItem(lpSelected); + HasChanged(); +} + +bool MainWindow::EditSport(QTreeWidgetItem* lpItem, bool bRightClick) +{ + int iIndent = GetIndent(lpItem); + + switch(iIndent) + { + case INDENT_SPORT: + if(bRightClick) + { + CEditSport* lpEditSport = new CEditSport(this); + lpEditSport->Set(lpItem->text(0), lpItem->text(1).toInt(), lpItem->text(2) == "Pace" ? true : false); + if(lpEditSport->exec() == QDialog::Accepted) + { + CClientData* lpClientData = GetClientData(lpItem); + QString szName = lpEditSport->GetName(); + uint32_t dwMaxHR = lpEditSport->GetMaxHR(); + bool bPace = lpEditSport->GetPace(); + lpItem->setText(0, szName); + lpItem->setText(1, QString("%1").arg(dwMaxHR)); + lpItem->setText(2, bPace ? "Pace" : "Speed"); + lpClientData->SetSportName(szName); + lpClientData->SetSportMaxHR(dwMaxHR); + lpClientData->SetSportPace(bPace); + } + delete lpEditSport; + } + break; + } + return(true); +} + +bool MainWindow::EditHR(QTreeWidgetItem* lpItem, bool bRightClick) +{ + int iIndent = GetIndent(lpItem); + + switch(iIndent) + { + case INDENT_HR: + if(bRightClick) + { + CClientData* lpClientData = GetClientData(lpItem); + CEditHR* lpEditHR = new CEditHR(this); + lpEditHR->Set(lpItem->text(0), lpItem->text(2), lpClientData->GetHRMin(), lpClientData->GetHRMax()); + + if(lpEditHR->exec() == QDialog::Accepted) + { + QString szName = lpEditHR->GetName(); + QString szDesc = lpEditHR->GetDesc(); + uint32_t dwMin = lpEditHR->GetMin(); + uint32_t dwMax = lpEditHR->GetMax(); + CClientData* lpParentData = GetClientData(lpItem->parent()); + uint32_t dwMaxHR = lpParentData->GetSportMaxHR(); + lpItem->setText(0, szName); + lpItem->setText(2, szDesc); + lpItem->setText(3, QString("%1\% - %2\%").arg(dwMin).arg(dwMax)); + lpItem->setText(4, QString("%1 - %2").arg(dwMaxHR*dwMin/100).arg(dwMaxHR*dwMax/100)); + lpClientData->SetHRName(szName); + lpClientData->SetHRDesc(szDesc); + lpClientData->SetHRMin(dwMin); + lpClientData->SetHRMax(dwMax); + } + delete lpEditHR; + } + break; + } + return(true); +} + +bool MainWindow::EditPlan(QTreeWidgetItem* lpItem, bool bRightClick) +{ + int iIndent = GetIndent(lpItem); + + switch(iIndent) + { + case INDENT_TRAINING: + if(bRightClick) + { + CEditTraining* lpEditTraining = new CEditTraining(this); + lpEditTraining->SetTraining(lpItem->text(0)); + if(lpEditTraining->exec() == QDialog::Accepted) + { + QString szTraining = lpEditTraining->GetTraining(); + if(szTraining.length()) + lpItem->setText(0, szTraining); + HasChanged(); + } + delete lpEditTraining; + } + break; + case INDENT_DAY: + if(bRightClick) + { + CEditDay* lpEditDay = new CEditDay(this); + CClientData* lpClientData = GetClientData(lpItem); + int iOldDay = lpClientData->GetDay(); + + lpEditDay->Set(iOldDay, lpItem->text(0).mid(lpItem->text(0).indexOf(")")+2)); + if(lpEditDay->exec() == QDialog::Accepted) + { + QString szDesc = lpEditDay->GetDesc(); + int iDay = lpEditDay->GetDay(); + QTreeWidgetItem* lpDay = FindDay(0, iDay); + + if(lpDay && lpDay != lpItem) + { + QTreeWidgetItem* lpChild; + QTreeWidgetItem* lpChild1; + QTreeWidgetItem* lpOldDay = FindDay(0, iOldDay); + CClientData* lpTemp; + for(int i = 0;i < lpOldDay->childCount();i++) + { + lpChild = lpOldDay->child(i); + lpTemp = GetClientData(lpChild); + QString szSport = lpTemp->GetSessionSport(); + QTreeWidgetItem* lpSession = AddSession(lpDay, lpTemp->GetSession(), lpTemp->GetSessionDesc(), lpTemp->GetSessionSport()); + for(int j = 0;j < lpChild->childCount();j++) + { + lpChild1 = lpChild->child(j); + lpTemp = GetClientData(lpChild1); + CTime Time = lpTemp->GetTaskTime(); + uint32_t dwTime = (uint32_t)Time.second()+(uint32_t)Time.minute()*60+(uint32_t)Time.hour()*3600; + CTime PauseTime = lpTemp->GetTaskPauseTime(); + uint32_t dwPauseTime = (uint32_t)PauseTime.second()+(uint32_t)PauseTime.minute()*60+(uint32_t)PauseTime.hour()*3600; + + AddTask(lpSession, lpTemp->GetTask(), lpTemp->GetTaskDesc(), szSport, lpTemp->GetTaskCount(), dwTime, lpTemp->GetTaskDist(), lpTemp->GetTaskHR(), lpTemp->GetTaskPace(), dwPauseTime, lpTemp->GetTaskPauseDist(), lpTemp->GetTaskPauseHR(), lpTemp->GetTaskPausePace()); + } + } + delete lpOldDay; + } + else + { + lpClientData->SetDay(iDay); + lpClientData->SetDayDesc(szDesc); + lpItem->setText(0, QString("(%1) %2").arg(iDay).arg(szDesc)); + } + HasChanged(); + } + delete lpEditDay; + } + break; + case INDENT_SESSION: + if(bRightClick) + { + CEditSession* lpEditSession = new CEditSession(this); + QString szDesc = lpItem->text(0); + QString szSport = lpItem->text(1); + QTreeWidgetItem* lpDay = lpItem->parent(); + int iDay; + QString szDayDesc; + QStringList DayList; + QStringList SportList; + CClientData* lpClientData; + int i; + + lpClientData = GetClientData(lpDay); + iDay = lpClientData->GetDay(); + szDayDesc = lpDay->text(0).mid(lpItem->text(0).indexOf(")")+2); + + for(i = 0;i < m_lpPlanRoot->childCount();i++) + DayList << m_lpPlanRoot->child(i)->text(0); + + for(int i = 0;i < ui->m_lpSportView->topLevelItemCount();i++) + SportList << ui->m_lpSportView->topLevelItem(i)->text(0); + + lpEditSession->Set(DayList, SportList, lpDay->text(0), szDesc, szSport); + if(lpEditSession->exec() == QDialog::Accepted) + { + QString szNewDay = lpEditSession->GetDay(); + QString szNewDesc = lpEditSession->GetDesc(); + QString szNewSport = lpEditSession->GetSport(); + + lpClientData = GetClientData(lpItem); + lpClientData->SetSessionDesc(szNewDesc); + lpClientData->SetSessionSport(szNewSport); + lpItem->setText(0, szDesc); + lpItem->setText(1, szSport); + + if(szDayDesc != szNewDay) + { + QString szEmpty(""); + QTreeWidgetItem* lpNewDay = FindDay(szEmpty, szNewDay); + if(lpNewDay) + { + QTreeWidgetItem* lpSession = AddSession(lpNewDay, lpClientData->GetSession(), lpClientData->GetSessionDesc(), lpClientData->GetSessionSport()); + for(int j = 0;j < lpItem->childCount();j++) + { + QTreeWidgetItem* lpChild = lpItem->child(j); + lpClientData = GetClientData(lpChild); + CTime Time = lpClientData->GetTaskTime(); + uint32_t dwTime = (uint32_t)Time.second()+(uint32_t)Time.minute()*60+(uint32_t)Time.hour()*3600; + CTime PauseTime = lpClientData->GetTaskPauseTime(); + uint32_t dwPauseTime = (uint32_t)PauseTime.second()+(uint32_t)PauseTime.minute()*60+(uint32_t)PauseTime.hour()*3600; + + AddTask(lpSession, lpClientData->GetTask(), lpClientData->GetTaskDesc(), szSport, lpClientData->GetTaskCount(), dwTime, lpClientData->GetTaskDist(), lpClientData->GetTaskHR(), lpClientData->GetTaskPace(), dwPauseTime, lpClientData->GetTaskPauseDist(), lpClientData->GetTaskPauseHR(), lpClientData->GetTaskPausePace()); + } + delete lpItem; + } + } + HasChanged(); + } + delete lpEditSession; + } + break; + case INDENT_TASK: + { + CClientData* lpClientData = GetClientData(lpItem); + QTreeWidgetItem* lpSession = lpItem->parent(); + QStringList HRList; + int i; + QTreeWidgetItem* lpSport = FindSport(lpSession->text(COL_SPORT)); + CClientData* lpClientDataSport = GetClientData(lpSport); + + for(i = 0;i < lpSport->childCount();i++) + HRList << QString("%1 (%2)").arg(lpSport->child(i)->text(0)).arg(lpSport->child(i)->text(4)); + + if(lpClientDataSport->GetSportPace()) + { + CEditTask* lpEditTask = new CEditTask(this); + lpEditTask->Set(HRList, lpClientData->GetTaskDesc(), lpClientData->GetTaskCount(), lpClientData->GetTaskTime(), lpClientData->GetTaskDist(), lpClientData->GetTaskHR(), lpClientData->GetTaskPace(), lpClientData->GetTaskPauseTime(), lpClientData->GetTaskPauseDist(), lpClientData->GetTaskPauseHR(), lpClientData->GetTaskPausePace()); + if(lpEditTask->exec() == QDialog::Accepted) + { + lpClientData->SetTaskDesc(lpEditTask->GetDesc()); + lpClientData->SetTaskCount(lpEditTask->GetCount()); + lpClientData->SetTaskTime(lpEditTask->GetTime()); + lpClientData->SetTaskDist(lpEditTask->GetDist()); + lpClientData->SetTaskHR(lpEditTask->GetHR()); + lpClientData->SetTaskPace(lpEditTask->GetPace()); + lpClientData->SetTaskPauseTime(lpEditTask->GetPauseTime()); + lpClientData->SetTaskPauseDist(lpEditTask->GetPauseDist()); + lpClientData->SetTaskPauseHR(lpEditTask->GetPauseHR()); + lpClientData->SetTaskPausePace(lpEditTask->GetPausePace()); + SetTaskData(lpItem, lpClientData->GetTaskDesc(), lpClientData->GetTaskCount(), lpClientData->GetTaskTime().toDWORD(), lpClientData->GetTaskDist(), lpClientData->GetTaskHR(), lpClientData->GetTaskPace(), lpClientData->GetTaskPauseTime().toDWORD(), lpClientData->GetTaskPauseDist(), lpClientData->GetTaskPauseHR(), lpClientData->GetTaskPausePace(), lpSession->text(COL_SPORT)); + } + HasChanged(); + delete lpEditTask; + } + else + { + CEditTaskS* lpEditTask = new CEditTaskS(this); + lpEditTask->Set(HRList, lpClientData->GetTaskDesc(), lpClientData->GetTaskCount(), lpClientData->GetTaskTime(), lpClientData->GetTaskDist(), lpClientData->GetTaskHR(), lpClientData->GetTaskPace(), lpClientData->GetTaskPauseTime(), lpClientData->GetTaskPauseDist(), lpClientData->GetTaskPauseHR(), lpClientData->GetTaskPausePace()); + if(lpEditTask->exec() == QDialog::Accepted) + { + lpClientData->SetTaskDesc(lpEditTask->GetDesc()); + lpClientData->SetTaskCount(lpEditTask->GetCount()); + lpClientData->SetTaskTime(lpEditTask->GetTime()); + lpClientData->SetTaskDist(lpEditTask->GetDist()); + lpClientData->SetTaskHR(lpEditTask->GetHR()); + lpClientData->SetTaskPace(lpEditTask->GetPace()); + lpClientData->SetTaskPauseTime(lpEditTask->GetPauseTime()); + lpClientData->SetTaskPauseDist(lpEditTask->GetPauseDist()); + lpClientData->SetTaskPauseHR(lpEditTask->GetPauseHR()); + lpClientData->SetTaskPausePace(lpEditTask->GetPausePace()); + SetTaskData(lpItem, lpClientData->GetTaskDesc(), lpClientData->GetTaskCount(), lpClientData->GetTaskTime().toDWORD(), lpClientData->GetTaskDist(), lpClientData->GetTaskHR(), lpClientData->GetTaskPace(), lpClientData->GetTaskPauseTime().toDWORD(), lpClientData->GetTaskPauseDist(), lpClientData->GetTaskPauseHR(), lpClientData->GetTaskPausePace(), lpSession->text(COL_SPORT)); + } + HasChanged(); + delete lpEditTask; + } + } + break; + } + return(true); +} + +bool MainWindow::SavePlan(const QString& szFile) +{ + if(!m_lpPlanRoot) + { + MESSAGE(tr("No training to save!")); + return(false); + } + + CTraining* lpTraining = new CTraining(); + lpTraining->SetTraining(m_lpPlanRoot->text(0).toLatin1().data(), ui->m_lpTrainingStart->date()); + lpTraining->SetPerson(ui->m_lpFirstName->text(), ui->m_lpLastName->text(), ui->m_lpDayOfBirth->date(), ui->m_lpHeight->value(), ui->m_lpWeight->value()); + + int i; + int j; + int k; + CClientData* lpSportData; + CClientData* lpHRData; + CClientData* lpDayData; + CClientData* lpSessionData; + CClientData* lpTaskData; + QTreeWidgetItem* lpSport; + QTreeWidgetItem* lpHR; + QTreeWidgetItem* lpDay; + QTreeWidgetItem* lpSession; + QTreeWidgetItem* lpTask; + int iSession; + int iTask; + + for(i = 0;i < ui->m_lpSportView->topLevelItemCount();i++) + { + lpSport = ui->m_lpSportView->topLevelItem(i); + lpSportData = GetClientData(lpSport); + lpTraining->AddSport(lpSportData->GetSportName().toLatin1().data(), lpSportData->GetSportMaxHR(), lpSportData->GetSportPace()); + for(j = 0;j < lpSport->childCount();j++) + { + lpHR = lpSport->child(j); + lpHRData = GetClientData(lpHR); + lpTraining->AddHR(lpSportData->GetSportName().toLatin1().data(), lpHRData->GetHRName().toLatin1().data(), lpHRData->GetHRDesc().toLatin1().data(), lpHRData->GetHRMin(), lpHRData->GetHRMax()); + } + } + + for(i = 0;i < m_lpPlanRoot->childCount();i++) + { + lpDay = m_lpPlanRoot->child(i); + lpDayData = GetClientData(lpDay); + lpTraining->AddDay(lpDayData->GetDay(), lpDayData->GetDayDesc(false)); + iSession = 0; + for(j = 0;j < lpDay->childCount();j++) + { + lpSession = lpDay->child(j); + lpSessionData = GetClientData(lpSession); + lpTraining->AddSession(lpDayData->GetDay(), iSession, lpSessionData->GetSessionDesc().toLatin1().data(), lpSessionData->GetSessionSport().toLatin1().data()); + iTask = 0; + for(k = 0;k < lpSession->childCount();k++) + { + lpTask = lpSession->child(k); + lpTaskData = GetClientData(lpTask); + lpTraining->AddTask(lpDayData->GetDay(), iSession, iTask, lpTaskData->GetTaskDesc().toLatin1().data(), lpTaskData->GetTaskCount(), lpTaskData->GetTaskTime().toDWORD(), lpTaskData->GetTaskDist(), lpTaskData->GetTaskHR().toLatin1().data(), lpTaskData->GetTaskPace(), lpTaskData->GetTaskPauseTime().toDWORD(), lpTaskData->GetTaskPauseDist(), lpTaskData->GetTaskPauseHR().toLatin1().data(), lpTaskData->GetTaskPausePace()); + iTask++; + } + iSession++; + } + } + + if(!lpTraining->Save(szFile.toLatin1().data())) + { + MESSAGE(tr("Could not save training!")); + delete lpTraining; + return(false); + } + m_szFileName = szFile; + delete lpTraining; + Changed(false); + setWindowTitle(QString(tr("qtTrainingPlan - "))+szFile); + return(true); +} + +void MainWindow::HasChanged() +{ + Changed(true); + DrawCalendar(); +} + +void MainWindow::DrawCalendar() +{ + if(!m_lpPlanRoot) + return; + + QTreeWidgetItem* lpDay; + QTreeWidgetItem* lpSession; + CClientData* lpDayData; + CClientData* lpSessionData; + int iOld = 1; + int i; + int iDay = 0; + QString szText(""); + QDate Date(2009, 11, 16); + QDate Day = ui->m_lpTrainingStart->date(); + + szText = QString("
"); + szText += QString(""); + + Day = Day.addDays(-Day.dayOfWeek()+1); + while(Day < ui->m_lpTrainingStart->date()) + { + szText += QString(""); + iDay++; + Day = Day.addDays(1); + } + + for(i = 0;i < m_lpPlanRoot->childCount();i++) + { + lpDay = m_lpPlanRoot->child(i); + lpDayData = GetClientData(lpDay); + + while(iOld < lpDayData->GetDay()) + { + szText += QString(""); + + Day = Day.addDays(1); + iDay++; + if(iDay == 7) + { + iDay = 0; + szText += QString(""); + szText += QString(""); + } + iOld++; + } + + szText += QString(""); + + Day = Day.addDays(1); + iDay++; + if(iDay == 7) + { + iDay = 0; + szText += QString(""); + szText += QString(""); + } + iOld++; + } + szText += QString(""); + szText += QString("
"); + szText += QString("
"); + szText += QString(""); + szText += QString(""); + szText += QString(""); + szText += QString(""); + szText += QString("
")+Day.toString("ddd, dd.MM.yyyy")+QString("
"); + szText += QString("
"); + szText += QString("
"); + szText += QString("
"); + szText += QString(""); + szText += QString(""); + szText += QString(""); + szText += QString(""); + szText += QString("
")+Day.toString("ddd, dd.MM.yyyy")+QString("
"); + szText += QString("
"); + szText += QString("
"); + szText += QString("
"); + szText += QString(""); + szText += QString(""); + szText += QString(""); + szText += QString(""); + szText += QString(""); + szText += QString(""); + szText += QString(""); + + for(int j = 0;j < lpDay->childCount();j++) + { + lpSession = lpDay->child(j); + lpSessionData = GetClientData(lpSession); + + szText += QString(""); + szText += QString(""); + szText += QString(""); + szText += QString(""); + szText += QString(""); + szText += QString(""); + } + szText += QString("
")+Day.toString("ddd, dd.MM.yyyy")+QString("
")+lpDay->text(0).mid(lpDay->text(0).indexOf(")")+2)+QString("
")+lpSession->text(0)+QString("")+lpSession->text(1)+QString("
")+lpSession->text(3)+QString("")+lpSession->text(4)+QString("
"); + szText += QString("
"); + szText += QString("
m_lpCalendar->setHtml(szText); +} + +uint32_t MainWindow::GetMaxDays() +{ + if(!m_lpPlanRoot) + return(1); + + uint32_t iMaxDay = 0; + uint32_t iDay; + CClientData* lpDayData; + + for(int i = 0;i < m_lpPlanRoot->childCount();i++) + { + lpDayData = GetClientData(m_lpPlanRoot->child(i)); + iDay = lpDayData->GetDay(); + if(iDay > iMaxDay) + iMaxDay = iDay; + } + return(iMaxDay); +} + +void MainWindow::Changed(bool bChanged) +{ + QString szTitle = windowTitle(); + m_bHasChanged = bChanged; + if(bChanged) + { + if(szTitle.right(1) != QString("*")) + szTitle = szTitle+QString(" *"); + } + else + { + if(szTitle.right(1) == QString("*")) + szTitle = szTitle.left(szTitle.length()-2); + } + setWindowTitle(szTitle); +} + +void MainWindow::on_action_Print_triggered() +{ +} + + +#define MY_BLACK QColor(2, 2, 2) +#define MY_WHITE QColor(255, 255, 255) +#define MY_BLUE QColor(0, 0, 255) +#define MY_LTBLUE QColor(127, 127, 255) +#define MY_GREY QColor(191, 191, 191) +#define MY_RED QColor(255, 0, 0) +#define MY_YELLOW QColor(255, 255, 0) + +void Draw(QPainter* lpPainter, const QColor& Pen, int iX, int iY, int iW) +{ + lpPainter->setPen(Pen); + lpPainter->drawLine(iX, iY, iX+iW-1, iY); +} + +void Draw(QPainter* lpPainter, const QColor& Pen, const QColor& Brush, int iX, int iY, int iW, int iH) +{ + lpPainter->setPen(Pen); + lpPainter->setBrush(QBrush(Brush)); + lpPainter->drawRect(iX, iY, iW, iH); +} + +void Draw(QPainter* lpPainter, const QColor& Pen, const QColor& Brush, int iX, int iY, int iW, int iH, const QColor& FontColor, const QFont& Font, int iFlags, const QString& szText) +{ + Draw(lpPainter, Pen, Brush, iX, iY, iW, iH); + + lpPainter->setPen(FontColor); + lpPainter->setFont(Font); + lpPainter->drawText(QRect(iX, iY, iW, iH), iFlags, szText); +} + +void Draw(QPainter* lpPainter, const QColor& Brush, int iX, int iY, int iW, int iH, const QColor& FontColor, const QFont& Font, int iFlags, const QString& szText) +{ + lpPainter->setBrush(QBrush(Brush)); + lpPainter->setPen(FontColor); + lpPainter->setFont(Font); + lpPainter->drawText(QRect(iX, iY, iW, iH), iFlags, szText); +} + +void MainWindow::on_action_PDF_triggered() +{ + QPrinter printer(QPrinter::HighResolution); + + CExportPDF* lpExportPDF = new CExportPDF(this); + if(lpExportPDF->exec() != QDialog::Accepted) + { + delete lpExportPDF; + return; + } + + int iFormat = lpExportPDF->GetFormat(); + int iWeeksPerSheet = lpExportPDF->GetWeeks(); + int iUnit = lpExportPDF->GetUnit(); + double dLeft = lpExportPDF->GetLeft(); + double dRight = lpExportPDF->GetRight(); + double dTop = lpExportPDF->GetTop(); + double dBottom = lpExportPDF->GetBottom(); + QString szFileName = lpExportPDF->GetFile(); + delete lpExportPDF; + + if(szFileName.indexOf(".pdf", 0, Qt::CaseInsensitive) == -1) + szFileName.append(".pdf"); + + QFile File(szFileName); + if(!File.open(QIODevice::ReadWrite)) + { + QMessageBox::critical(this, tr("Export PDF"), QString(tr("Can't export to %1").arg(szFileName))); + return; + } + File.close(); + + printer.setOutputFormat(QPrinter::PdfFormat); + printer.setOrientation(QPrinter::Landscape); + printer.setPaperSize((QPrinter::PageSize)iFormat); + printer.setPageSize((QPrinter::PageSize)iFormat); + printer.setPageMargins(dLeft, dTop, dRight, dBottom, (QPrinter::Unit)iUnit); + printer.newPage(); + + printer.setOutputFileName(szFileName); + QPainter painter; + + painter.begin(&printer); + + QRect PrintArea = QRect(0, 0, printer.pageRect().right()-printer.pageRect().left(), printer.pageRect().bottom()-printer.pageRect().top()); + int iCalendarWidth = PrintArea.width()/22*3; + int iCalendarHeight = PrintArea.height()/iWeeksPerSheet; + int iSumWidth = PrintArea.width()-iCalendarWidth*7; + int iDateHeight = iCalendarHeight/8; + int iDayHeight = iCalendarHeight/8; + int iSumHeight = iCalendarHeight/8; + int iRowHeight = (iCalendarHeight-iDateHeight-iDayHeight-iSumHeight)/6; + int iCol1 = (iCalendarWidth-2)/5; + int iCol3 = iCol1*2; + int iCol2 = iCalendarWidth-2-iCol1-iCol3; + + QDate Day = ui->m_lpTrainingStart->date(); + int iDay = 0; + int iWeek = 0; + int i; + QTreeWidgetItem* lpDay; + QTreeWidgetItem* lpSession; + QTreeWidgetItem* lpTask; + CClientData* lpDayData; + CClientData* lpSessionData; + CClientData* lpTaskData; + int iOld = 1; + + uint32_t dwWeekTime = 0; + uint32_t dwWeekDist = 0; + + QFont DefaultFont = painter.font(); + + QFont DateFont = DefaultFont; + DateFont.setPixelSize(iDateHeight*2/3); + DateFont.setBold(true); + + QFont DayFont = DefaultFont; + DayFont.setPixelSize(iDayHeight*2/3); + + QFont SumFont = DefaultFont; + SumFont.setPixelSize(iSumHeight*2/3); + SumFont.setBold(true); + + QFont RowFont = DefaultFont; + RowFont.setPixelSize(iRowHeight*2/3); + + + Day = Day.addDays(-Day.dayOfWeek()+1); + while(Day < ui->m_lpTrainingStart->date()) + { + Draw(&painter, MY_BLACK, MY_WHITE, iDay*iCalendarWidth, iWeek*iCalendarHeight, iCalendarWidth, iCalendarHeight); + Draw(&painter, MY_BLACK, MY_BLACK, iDay*iCalendarWidth, iWeek*iCalendarHeight, iCalendarWidth, iDateHeight, MY_WHITE, DateFont, Qt::AlignCenter | Qt::AlignHCenter, Day.toString("ddd, dd.MM.yyyy")); + + iDay++; + if(iDay >= 7) + { + CTime WeekTime(dwWeekTime); + + Draw(&painter, MY_BLACK, MY_YELLOW, 7*iCalendarWidth, iWeek*iCalendarHeight, iSumWidth, iCalendarHeight); + Draw(&painter, MY_YELLOW, 7*iCalendarWidth, iWeek*iCalendarHeight, iSumWidth, iDateHeight, MY_BLACK, DateFont, Qt::AlignCenter | Qt::AlignHCenter, "Total"); + + painter.save(); + painter.translate(7*iCalendarWidth, (iWeek+1)*iCalendarHeight); + painter.rotate(270); + Draw(&painter, MY_YELLOW, 0, 0, iCalendarHeight-iDateHeight-iDayHeight, iSumWidth/2, MY_BLACK, SumFont, Qt::AlignCenter | Qt::AlignHCenter, QString("%1").arg(dwWeekDist)); + painter.restore(); + + painter.save(); + painter.translate(7*iCalendarWidth+iSumWidth/2, (iWeek+1)*iCalendarHeight); + painter.rotate(270); + Draw(&painter, MY_YELLOW, 0, 0, iCalendarHeight-iDateHeight-iDayHeight, iSumWidth/2, MY_BLACK, SumFont, Qt::AlignCenter | Qt::AlignHCenter, WeekTime.Format()); + painter.restore(); + + dwWeekTime = 0; + dwWeekDist = 0; + + iDay = 0; + iWeek++; + if(iWeek >= iWeeksPerSheet) + { + iWeek = 0; + printer.newPage(); + } + } + Day = Day.addDays(1); + } + + for(i = 0;i < m_lpPlanRoot->childCount();i++) + { + lpDay = m_lpPlanRoot->child(i); + lpDayData = GetClientData(lpDay); + + while(iOld < lpDayData->GetDay()) + { + Draw(&painter, MY_BLACK, MY_WHITE, iDay*iCalendarWidth, iWeek*iCalendarHeight, iCalendarWidth, iCalendarHeight); + Draw(&painter, MY_BLACK, MY_BLACK, iDay*iCalendarWidth, iWeek*iCalendarHeight, iCalendarWidth, iDateHeight, MY_WHITE, DateFont, Qt::AlignCenter | Qt::AlignHCenter, Day.toString("ddd, dd.MM.yyyy")); + + Day = Day.addDays(1); + iDay++; + if(iDay >= 7) + { + CTime WeekTime(dwWeekTime); + + Draw(&painter, MY_BLACK, MY_YELLOW, 7*iCalendarWidth, iWeek*iCalendarHeight, iSumWidth, iCalendarHeight); + Draw(&painter, MY_YELLOW, 7*iCalendarWidth, iWeek*iCalendarHeight, iSumWidth, iDateHeight, MY_BLACK, DateFont, Qt::AlignCenter | Qt::AlignHCenter, "Total"); + + painter.save(); + painter.translate(7*iCalendarWidth, (iWeek+1)*iCalendarHeight); + painter.rotate(270); + Draw(&painter, MY_YELLOW, 0, 0, iCalendarHeight-iDateHeight-iDayHeight, iSumWidth/2, MY_BLACK, SumFont, Qt::AlignCenter | Qt::AlignHCenter, QString("%1").arg(dwWeekDist)); + painter.restore(); + + painter.save(); + painter.translate(7*iCalendarWidth+iSumWidth/2, (iWeek+1)*iCalendarHeight); + painter.rotate(270); + Draw(&painter, MY_YELLOW, 0, 0, iCalendarHeight-iDateHeight-iDayHeight, iSumWidth/2, MY_BLACK, SumFont, Qt::AlignCenter | Qt::AlignHCenter, WeekTime.Format()); + painter.restore(); + + dwWeekTime = 0; + dwWeekDist = 0; + + iDay = 0; + iWeek++; + if(iWeek >= iWeeksPerSheet) + { + iWeek = 0; + printer.newPage(); + } + } + iOld++; + } + + Draw(&painter, MY_BLACK, MY_WHITE, iDay*iCalendarWidth, iWeek*iCalendarHeight, iCalendarWidth, iCalendarHeight); + Draw(&painter, MY_BLACK, MY_BLACK, iDay*iCalendarWidth, iWeek*iCalendarHeight, iCalendarWidth, iDateHeight, MY_WHITE, DateFont, Qt::AlignCenter | Qt::AlignHCenter, Day.toString("ddd, dd.MM.yyyy")); + + Draw(&painter, MY_BLUE, MY_BLUE, iDay*iCalendarWidth+1, iWeek*iCalendarHeight+iDateHeight, iCalendarWidth-2, iDayHeight, MY_WHITE, DayFont, Qt::AlignCenter | Qt::AlignHCenter, lpDayData->GetDayDesc(false)); + + + uint32_t dwTotalTime = 0; + uint32_t dwTotalDist = 0; + uint32_t dwCount; + int iTask = 0; + + for(int j = 0;j < lpDay->childCount();j++) + { + lpSession = lpDay->child(j); + lpSessionData = GetClientData(lpSession); + + Draw(&painter, MY_BLACK, MY_LTBLUE, iDay*iCalendarWidth+1, iWeek*iCalendarHeight+iDateHeight+iDayHeight+iRowHeight*iTask, iCalendarWidth-2, iRowHeight, MY_BLACK, RowFont, Qt::AlignCenter | Qt::AlignHCenter, lpSession->text(1)); + iTask++; + + for(int k = 0;k < lpSession->childCount();k++) + { + lpTask = lpSession->child(k); + lpTaskData = GetClientData(lpTask); + + + dwCount = lpTaskData->GetTaskCount(); + dwTotalTime += lpTaskData->GetTaskTime().toDWORD()*dwCount; + dwTotalDist += lpTaskData->GetTaskDist()*dwCount; + if(dwCount > 1) + { + dwTotalTime += lpTaskData->GetTaskPauseTime().toDWORD()*(dwCount-1); + dwTotalDist += lpTaskData->GetTaskDist()*(dwCount-1); + } + + Draw(&painter, MY_WHITE, iDay*iCalendarWidth+1, iWeek*iCalendarHeight+iDateHeight+iDayHeight+iRowHeight*iTask, iCol1, iRowHeight, MY_BLACK, RowFont, Qt::AlignRight | Qt::AlignHCenter, QString("%1x").arg(dwCount)); + Draw(&painter, MY_WHITE, iDay*iCalendarWidth+1+iCol1, iWeek*iCalendarHeight+iDateHeight+iDayHeight+iRowHeight*iTask, iCol2, iRowHeight, MY_BLACK, RowFont, Qt::AlignRight | Qt::AlignHCenter, QString("%1").arg(lpTaskData->GetTaskDist())); + Draw(&painter, MY_WHITE, iDay*iCalendarWidth-5+iCol1+iCol2, iWeek*iCalendarHeight+iDateHeight+iDayHeight+iRowHeight*iTask, iCol3, iRowHeight, MY_BLACK, RowFont, Qt::AlignRight | Qt::AlignHCenter, DWORD2Time(lpTaskData->GetTaskPace())); + iTask++; + + if(dwCount > 1) + { + Draw(&painter, MY_WHITE, iDay*iCalendarWidth+1, iWeek*iCalendarHeight+iDateHeight+iDayHeight+iRowHeight*iTask, iCol1, iRowHeight, MY_BLACK, RowFont, Qt::AlignRight | Qt::AlignHCenter, "P"); + Draw(&painter, MY_WHITE, iDay*iCalendarWidth+1+iCol1, iWeek*iCalendarHeight+iDateHeight+iDayHeight+iRowHeight*iTask, iCol2, iRowHeight, MY_BLACK, RowFont, Qt::AlignRight | Qt::AlignHCenter, QString("%1").arg(lpTaskData->GetTaskPauseDist())); + Draw(&painter, MY_WHITE, iDay*iCalendarWidth-5+iCol1+iCol2, iWeek*iCalendarHeight+iDateHeight+iDayHeight+iRowHeight*iTask, iCol3, iRowHeight, MY_BLACK, RowFont, Qt::AlignRight | Qt::AlignHCenter, DWORD2Time(lpTaskData->GetTaskPausePace())); + iTask++; + if(iWeek >= iWeeksPerSheet) + { + iWeek = 0; + printer.newPage(); + } + } + Draw(&painter, MY_BLACK, iDay*iCalendarWidth+1, iWeek*iCalendarHeight+iDateHeight+iDayHeight+iRowHeight*iTask, iCalendarWidth-2); + } + } + CTime TotalTime(dwTotalTime); + Draw(&painter, MY_BLACK, MY_GREY, iDay*iCalendarWidth+1, iWeek*iCalendarHeight+iCalendarHeight-iSumHeight, iCalendarWidth-2, iSumHeight); + Draw(&painter, MY_GREY, iDay*iCalendarWidth+1, iWeek*iCalendarHeight+iCalendarHeight-iSumHeight, iCol1, iSumHeight, MY_BLACK, SumFont, Qt::AlignRight | Qt::AlignHCenter, "Tot"); + Draw(&painter, MY_GREY, iDay*iCalendarWidth+1+iCol1, iWeek*iCalendarHeight+iCalendarHeight-iSumHeight, iCol2, iSumHeight, MY_BLACK, SumFont, Qt::AlignRight | Qt::AlignHCenter, QString("%1").arg(dwTotalDist)); + Draw(&painter, MY_GREY, iDay*iCalendarWidth+1+iCol1+iCol2, iWeek*iCalendarHeight+iCalendarHeight-iSumHeight, iCol3, iSumHeight, MY_BLACK, SumFont, Qt::AlignRight | Qt::AlignHCenter, TotalTime.Format()); + + dwWeekTime += dwTotalTime; + dwWeekDist += dwTotalDist; + + Day = Day.addDays(1); + iDay++; + if(iDay >= 7) + { + CTime WeekTime(dwWeekTime); + + Draw(&painter, MY_BLACK, MY_YELLOW, 7*iCalendarWidth, iWeek*iCalendarHeight, iSumWidth, iCalendarHeight); + Draw(&painter, MY_YELLOW, 7*iCalendarWidth, iWeek*iCalendarHeight, iSumWidth, iDateHeight, MY_BLACK, DateFont, Qt::AlignCenter | Qt::AlignHCenter, "Total"); + + painter.save(); + painter.translate(7*iCalendarWidth, (iWeek+1)*iCalendarHeight); + painter.rotate(270); + Draw(&painter, MY_YELLOW, 0, 0, iCalendarHeight-iDateHeight-iDayHeight, iSumWidth/2, MY_BLACK, SumFont, Qt::AlignCenter | Qt::AlignHCenter, QString("%1").arg(dwWeekDist)); + painter.restore(); + + painter.save(); + painter.translate(7*iCalendarWidth+iSumWidth/2, (iWeek+1)*iCalendarHeight); + painter.rotate(270); + Draw(&painter, MY_YELLOW, 0, 0, iCalendarHeight-iDateHeight-iDayHeight, iSumWidth/2, MY_BLACK, SumFont, Qt::AlignCenter | Qt::AlignHCenter, WeekTime.Format()); + painter.restore(); + + dwWeekTime = 0; + dwWeekDist = 0; + + iDay = 0; + iWeek++; + if(iWeek >= iWeeksPerSheet) + { + iWeek = 0; + printer.newPage(); + } + } + iOld++; + } + + painter.end(); +} diff --git a/mainwindow.h b/mainwindow.h new file mode 100644 index 0000000..12403dc --- /dev/null +++ b/mainwindow.h @@ -0,0 +1,150 @@ +#ifndef MAINWINDOW_H +#define MAINWINDOW_H + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "cclientdata.h" +#include "ctraining.h" + + +namespace Ui +{ + class MainWindow; +} + +class MainWindow : public QMainWindow +{ + Q_OBJECT +protected: + bool m_bDateChanging; + + QTreeWidgetItem* m_lpPlanRoot; + QString m_szFileName; + bool m_bHasChanged; + + QStatusBar* m_lpStatusBar; + + bool GetTaskData(QTreeWidgetItem* lpItem, QString& szDesc, uint32_t& dwTaskCount, uint32_t& dwTaskTime, uint32_t& dwTaskDist, QString& szTaskHR, uint32_t& dwTaskPace, uint32_t& dwTaskPauseTime, uint32_t& dwTaskPauseDist, QString& szTaskPauseHR, uint32_t& dwTaskPausePace); + void SetTaskData(QTreeWidgetItem* lpItem, const QString& szDesc, uint32_t dwCount, uint32_t dwTime, uint32_t dwDist, const QString& szHR, uint32_t dwPace, uint32_t dwPauseTime, uint32_t dwPauseDist, const QString& szPauseHR, uint32_t dwPausePace, const QString& szSport); + + int GetIndent(QTreeWidgetItem* lpItem); + + void CalculateDay(QTreeWidgetItem* lpDay); + void CalculateSession(QTreeWidgetItem* lpSession); + + QTreeWidgetItem* SetChildText(QTreeWidgetItem* lpItem, int iCol, const QString& szText, Qt::AlignmentFlag iAlign); + QTreeWidgetItem* AddChild(QTreeWidget* lpRoot, const QString& szText, CClientData* lpClientData, Qt::AlignmentFlag iAlign, const QColor& Color, const QColor& BGColor); + QTreeWidgetItem* AddChild(QTreeWidgetItem* lpRoot, const QString& szText, CClientData* lpClientData, Qt::AlignmentFlag iAlign, const QColor& Color, const QColor& BGColor, int iPos = -1); + + QTreeWidgetItem* AddTask(int iTraining, int iDay, int iSession, int iTask, const QString& szDesc, const QString& szSport, uint32_t dwCount, uint32_t dwTime, uint32_t dwDist, const QString& szHR, uint32_t dwPace, uint32_t dwPauseTime, uint32_t dwPauseDist, const QString& szPauseHR, uint32_t dwPausePace); + QTreeWidgetItem* AddTask(QTreeWidgetItem* lpRoot, int iTask, const QString& szDesc, const QString& szSport, uint32_t dwCount, uint32_t dwTime, uint32_t dwDist, const QString& szHR, uint32_t dwPace, uint32_t dwPauseTime, uint32_t dwPauseDist, const QString& szPauseHR, uint32_t dwPausePace); + + QTreeWidgetItem* FindSession(int iTraining, int iDay, int iSession); + QTreeWidgetItem* FindSession(const QString& szTraining, const QString& szDay, const QString& szSession); + QTreeWidgetItem* AddSession(int iTraining, int iDay, int iSession, const QString& szDesc, const QString& szSport); + QTreeWidgetItem* AddSession(QTreeWidgetItem* lpRoot, int iSession, const QString& szDesc, const QString& szSport); + + QTreeWidgetItem* FindDay(int iTraining, int iDay); + QTreeWidgetItem* FindDay(const QString& szTraining, const QString& szDay); + QTreeWidgetItem* AddDay(int iTraining, int iDay, const QString& szDesc); + QTreeWidgetItem* AddDay(QTreeWidgetItem* lpRoot, int iDay, const QString& szDesc, int iPos = -1); + + QTreeWidgetItem* FindTraining(int iTraining); + QTreeWidgetItem* FindTraining(const QString& szTraining); + bool AddTraining(int iTraining, const QString& szName); + + QTreeWidgetItem* AddHR(QTreeWidgetItem* lpRoot, const QString& szName, const QString& szDesc, uint32_t dwMaxHR, uint32_t dwMin, uint32_t dwMax); + + QTreeWidgetItem* AddSport(const QString& szSport, uint32_t dwMaxHR, bool bPace); + + bool LoadPlan(const QString& szFile, bool bPerson = true, bool bSport = true, bool bPlan = true); + bool SavePlan(const QString& szFile); + bool LoadPerson(CTraining* lpTraining); + bool LoadSport(CTraining* lpTraining); + bool LoadPlan(CTraining* lpTraining); + void Clear(); + void InitSportView(); + void InitPlanView(); + void InitCalendarView(); + void closeEvent(QCloseEvent *event); + bool MayClose(); + + CClientData* GetClientData(QTreeWidgetItem* lpItem); + + QTreeWidgetItem* FindSport(const QString& szSport); + QTreeWidgetItem* FindHR(const QString& szSport, const QString& szHR); + + QString FormatHR(const QString& szSport, const QString& szHR); + QString FormatPace(const QString& szSport, uint32_t dwPace); + + bool EditPlan(QTreeWidgetItem* lpItem, bool bRightClick = false); + bool EditSport(QTreeWidgetItem* lpItem, bool bRightClick = false); + bool EditHR(QTreeWidgetItem* lpItem, bool bRightClick); + + uint32_t GetMaxDays(); + + void Changed(bool bChanged); + void HasChanged(); + void DrawCalendar(); + +public: + MainWindow(QWidget *parent = 0); + ~MainWindow(); + +private: + Ui::MainWindow *ui; + +private slots: + void on_m_lpSportView_customContextMenuRequested(QPoint pos); + void on_action_PDF_triggered(); + void on_action_Print_triggered(); + void on_m_lpCalendar_linkClicked(QUrl url); + void on_m_lpTargetDate_dateChanged(QDate date); + void on_m_lpTrainingStart_dateChanged(QDate date); + void on_m_lpPlanView_itemDoubleClicked(QTreeWidgetItem* item, int column); + void on_m_lpPlanView_customContextMenuRequested(QPoint pos); + void on_m_lpWeight_valueChanged(int ); + void on_m_lpHeight_valueChanged(int ); + void on_m_lpDayOfBirth_dateChanged(QDate date); + void on_m_lpLastName_textChanged(QString ); + void on_m_lpFirstName_textChanged(QString ); + void on_actionE_xit_triggered(); + void on_actionSave_as_triggered(); + void on_action_Save_triggered(); + void on_action_Open_triggered(); + void on_actionNew_from_triggered(); + void on_action_New_triggered(); + + void EditPlan(bool); + + void AddSport(bool); + void EditSport(bool); + void DeleteSport(bool); + + void AddHR(bool); + void EditHR(bool); + void DeleteHR(bool); + + void AddTraining(bool); + + void AddDay(bool); + void AddSession(bool); + void AddTask(bool); + + void DeleteTraining(bool); + void DeleteDay(bool); + void DeleteSession(bool); + void DeleteTask(bool); + + void MoveUp(bool); + void MoveDown(bool); +}; + +#endif // MAINWINDOW_H diff --git a/mainwindow.ui b/mainwindow.ui new file mode 100644 index 0000000..1cf5c43 --- /dev/null +++ b/mainwindow.ui @@ -0,0 +1,493 @@ + + + MainWindow + + + + 0 + 0 + 944 + 674 + + + + qtTrainingPlan + + + + + + + + + + 300 + 200 + + + + Person + + + + + + + + Firstname: + + + + + + + + 200 + 16777215 + + + + + + + + + + + + Lastname: + + + + + + + + 200 + 16777215 + + + + + + + + + + + + Day of Birth: + + + + + + + true + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + + + Height: + + + + + + + 250 + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + + + Weight: + + + + + + + 250 + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + + + + + 16777215 + 200 + + + + Sport + + + + + + + 16777215 + 16777215 + + + + Qt::CustomContextMenu + + + false + + + false + + + 5 + + + + 1 + + + + + 2 + + + + + 3 + + + + + 4 + + + + + 5 + + + + + + + + + + + + + 0 + + + + Training Plan + + + + + + Qt::CustomContextMenu + + + + + + QAbstractItemView::DoubleClicked|QAbstractItemView::EditKeyPressed|QAbstractItemView::SelectedClicked + + + 10 + + + + 1 + + + + + 2 + + + + + 3 + + + + + 4 + + + + + 5 + + + + + 6 + + + + + 7 + + + + + 8 + + + + + 9 + + + + + 10 + + + + + + + + + Calendar + + + + + + + + Start Date: + + + + + + + dd.MM.yyyy + + + true + + + + + + + Target Date: + + + + + + + dd.MM.yyyy + + + true + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + Qt::NoContextMenu + + + + about:blank + + + + + + + + + + + + + + 0 + 0 + 944 + 25 + + + + + &File + + + + &Export + + + + + + + + + + + + + + + + + + + TopToolBarArea + + + false + + + + + + &New + + + + + New &from... + + + + + &Open + + + Ctrl+O + + + + + &Save + + + Ctrl+S + + + + + Save &as... + + + Ctrl+Shift+S + + + + + E&xit + + + Ctrl+X + + + + + &Print... + + + Ctrl+P + + + + + PDF... + + + + + + + QWebView + QWidget +
QtWebKit/QWebView
+
+
+ + +
diff --git a/qtTrainingPlan.pro b/qtTrainingPlan.pro new file mode 100644 index 0000000..a3eced2 --- /dev/null +++ b/qtTrainingPlan.pro @@ -0,0 +1,49 @@ +# ------------------------------------------------- +# Project created by QtCreator 2009-11-19T07:36:49 +# ------------------------------------------------- +#QT += webkit \ +# xml + +QT += core gui xml webkit +greaterThan(QT_MAJOR_VERSION, 4): QT += widgets printsupport webkitwidgets + +TARGET = qtTrainingPlan +TEMPLATE = app +SOURCES += main.cpp \ + mainwindow.cpp \ + ctraining.cpp \ + common.cpp \ + ctime.cpp \ + cclientdata.cpp \ + cedittraining.cpp \ + ceditday.cpp \ + ceditsession.cpp \ + cedittask.cpp \ + cedittasks.cpp \ + cexportpdf.cpp \ + ceditsport.cpp \ + cedithr.cpp +HEADERS += mainwindow.h \ + ctraining.h \ + common.h \ + ctime.h \ + cclientdata.h \ + cedittraining.h \ + ceditday.h \ + ceditsession.h \ + cedittask.h \ + cedittasks.h \ + cexportpdf.h \ + ceditsport.h \ + cedithr.h +FORMS += mainwindow.ui \ + cedittraining.ui \ + ceditday.ui \ + ceditsession.ui \ + cedittask.ui \ + cedittasks.ui \ + cexportpdf.ui \ + ceditsport.ui \ + cedithr.ui +TRANSLATIONS = qtTrainingPlan_de_AT.ts \ + qtTrainingPlan_de_DE.ts diff --git a/qtTrainingPlan.x b/qtTrainingPlan.x new file mode 100644 index 0000000..5572591 --- /dev/null +++ b/qtTrainingPlan.x @@ -0,0 +1,7 @@ + + + + File + Datei + + diff --git a/qtTrainingPlan_de_AT.qm b/qtTrainingPlan_de_AT.qm new file mode 100644 index 0000000..70c8d86 Binary files /dev/null and b/qtTrainingPlan_de_AT.qm differ diff --git a/qtTrainingPlan_de_AT.ts b/qtTrainingPlan_de_AT.ts new file mode 100644 index 0000000..0d15bcd --- /dev/null +++ b/qtTrainingPlan_de_AT.ts @@ -0,0 +1,568 @@ + + + + + + + qtTrainingPlan + qtTrainingPlan + + + new + neu + + + + CEditDay + + Dialog + Dialog + + + Day: + Tag: + + + Description: + Beschreibung: + + + Description is empty! + Beschreibung ist leer! + + + + CEditSession + + Dialog + Dialog + + + Description: + Beschreibung: + + + Day: + Tag: + + + Sport: + Sport: + + + Description is empty! + Beschreibung ist leer! + + + No day selected! + Kein Tag ausgewählt! + + + No sport selected! + Kein Sport ausgewählt! + + + + CEditTask + + Dialog + Dialog + + + Description: + Beschreibung: + + + Count: + Anzahl: + + + Tot. Time: + Gesamtzeit: + + + hh:mm:ss + hh:mm:ss + + + Tot. Dist.: + Gesamtdist.: + + + Basic + Basis + + + Time: + Zeit: + + + Distance: + Distanz: + + + HR: + HR: + + + Pace: + Tempo: + + + mm:ss + mm:ss + + + Pause + Pause + + + %1 + %1 + + + Description is empty! + Beschreibung ist leer! + + + No heart rate selected! + Keine Herzfrequenz ausgewählt! + + + No pause heart rate selected! + Keine Herzfrequenz für die Pause ausgewählt! + + + + CEditTaskS + + Dialog + Dialog + + + Description: + Beschreibung: + + + Count: + Anzahl: + + + Tot. Time: + Gesamtzeit: + + + hh:mm:ss + hh:mm:ss + + + Tot. Dist.: + Gesamtdist.: + + + Basic + Basis + + + Time: + Zeit: + + + Distance: + Distanz: + + + HR: + HR: + + + Speed: + Geschw.: + + + Pause + Pause + + + %1 + %1 + + + Description is empty! + Beschreibung ist leer! + + + No heart rate selected! + Keine Herzfrequenz ausgewählt! + + + No pause heart rate selected! + Keine Herzfrequenz für die Pause ausgewählt! + + + + CEditTraining + + Dialog + Dialog + + + Training: + Training: + + + Name is empty! + Name ist leer! + + + + MainWindow + + MainWindow + Hauptfenster + + + Person + Person + + + Firstname: + Vorname: + + + Lastname: + Nachname: + + + Day of Birth: + Gerbutsdatum: + + + Height: + Grösse: + + + Weight: + Gewicht: + + + Sport + Sport + + + 1 + 1 + + + 2 + 2 + + + 3 + 3 + + + 4 + 4 + + + 5 + 5 + + + Training Plan + Trainingsplan + + + 6 + 6 + + + 7 + 7 + + + 8 + 8 + + + 9 + 9 + + + 10 + 10 + + + Calendar + Kalender + + + Start Date: + Startdatum: + + + dd.MM.yyyy + dd.MM.yyyy + + + Target Date: + Zieldatum: + + + about:blank + about:blank + + + &File + &Datei + + + &New + &Neu + + + New &from... + Neu &von... + + + &Open + Ö&ffnen + + + Ctrl+O + Ctrl+O + + + &Save + &Speichern + + + Ctrl+S + Ctrl+S + + + Save &as... + Speichern &unter... + + + Ctrl+Shift+S + Ctrl+Shift+S + + + E&xit + &Beenden + + + Ctrl+X + Ctrl+X + + + Open Training + Training laden + + + Training Files (*.qtp);;XML Files (*.xml) + Trainingsdateien (*.qtp);;XML Dateien (*.xml) + + + Save Training + Training speichern + + + Description + Beschreibung + + + Count + Anzahl + + + Time + Zeit + + + Dist + Dist + + + HR + HR + + + Pace/Speed + Tempo/Geschw. + + + P.Time + P.Zeit + + + P.Dist + P.Dist + + + P.HR + P.HR + + + P.Pace/Speed + P.Tempo/Geschw. + + + MaxHR + MaxHR + + + Min-Max (%) + Min-Max (%) + + + Min-Max + Min-Max + + + %1 + %1 + + + %1% - %2% + %1% - %2% + + + %1 - %2 + %1 - %2 + + + (%1) %2 + (%1) %2 + + + %1 (%2) + %1 (%2) + + + test + test + + + Add training... + Training hinzufügen... + + + Add day... + Tag hinzufügen... + + + Edit training... + Training bearbeiten... + + + Delete training... + Training löschen... + + + Edit day... + Tag bearbeiten... + + + Delete day... + Tag löschen... + + + Add session... + Session hinzufügen... + + + Edit session... + Session bearbeiten... + + + Delete session... + Session löschen... + + + Add task... + Task hinzufügen... + + + Move up + Auf + + + Move down + Ab + + + Edit task... + Task bearbeiten... + + + Delete task... + Task löschen... + + + Training has been changed. Dou you want to save? + Training wurde geändert. Speichern? + + + yyyyMMdd + yyyyMMdd + + + MM:ss + MM:ss + + + min/km + min/km + + + %1 km/h + %1 km/h + + + Day allready exists! + Tag bereits vorhanden! + + + No training available! + Kein Training verfügbar! + + + Are you sure you want to delete this training? + Trining wirklich löschen? + + + Are you sure you want to delete this day? + Tag wirklich löschen? + + + Are you sure you want to delete this session? + Session wirklich löschen? + + + Are you sure you want to delete this task? + Task wirklich löschen? + + + No training to save! + Kein Training zum speichern! + + + Could not save training! + Kann Training nicht speichern! + + + qtTrainingPlan - + qtTrainingPlan - + + + + QMessageBox + + qtTrainingPlan + qtTrainingPlan + + + diff --git a/qtTrainingPlan_de_DE.qm b/qtTrainingPlan_de_DE.qm new file mode 100644 index 0000000..70c8d86 Binary files /dev/null and b/qtTrainingPlan_de_DE.qm differ diff --git a/qtTrainingPlan_de_DE.ts b/qtTrainingPlan_de_DE.ts new file mode 100644 index 0000000..0d15bcd --- /dev/null +++ b/qtTrainingPlan_de_DE.ts @@ -0,0 +1,568 @@ + + + + + + + qtTrainingPlan + qtTrainingPlan + + + new + neu + + + + CEditDay + + Dialog + Dialog + + + Day: + Tag: + + + Description: + Beschreibung: + + + Description is empty! + Beschreibung ist leer! + + + + CEditSession + + Dialog + Dialog + + + Description: + Beschreibung: + + + Day: + Tag: + + + Sport: + Sport: + + + Description is empty! + Beschreibung ist leer! + + + No day selected! + Kein Tag ausgewählt! + + + No sport selected! + Kein Sport ausgewählt! + + + + CEditTask + + Dialog + Dialog + + + Description: + Beschreibung: + + + Count: + Anzahl: + + + Tot. Time: + Gesamtzeit: + + + hh:mm:ss + hh:mm:ss + + + Tot. Dist.: + Gesamtdist.: + + + Basic + Basis + + + Time: + Zeit: + + + Distance: + Distanz: + + + HR: + HR: + + + Pace: + Tempo: + + + mm:ss + mm:ss + + + Pause + Pause + + + %1 + %1 + + + Description is empty! + Beschreibung ist leer! + + + No heart rate selected! + Keine Herzfrequenz ausgewählt! + + + No pause heart rate selected! + Keine Herzfrequenz für die Pause ausgewählt! + + + + CEditTaskS + + Dialog + Dialog + + + Description: + Beschreibung: + + + Count: + Anzahl: + + + Tot. Time: + Gesamtzeit: + + + hh:mm:ss + hh:mm:ss + + + Tot. Dist.: + Gesamtdist.: + + + Basic + Basis + + + Time: + Zeit: + + + Distance: + Distanz: + + + HR: + HR: + + + Speed: + Geschw.: + + + Pause + Pause + + + %1 + %1 + + + Description is empty! + Beschreibung ist leer! + + + No heart rate selected! + Keine Herzfrequenz ausgewählt! + + + No pause heart rate selected! + Keine Herzfrequenz für die Pause ausgewählt! + + + + CEditTraining + + Dialog + Dialog + + + Training: + Training: + + + Name is empty! + Name ist leer! + + + + MainWindow + + MainWindow + Hauptfenster + + + Person + Person + + + Firstname: + Vorname: + + + Lastname: + Nachname: + + + Day of Birth: + Gerbutsdatum: + + + Height: + Grösse: + + + Weight: + Gewicht: + + + Sport + Sport + + + 1 + 1 + + + 2 + 2 + + + 3 + 3 + + + 4 + 4 + + + 5 + 5 + + + Training Plan + Trainingsplan + + + 6 + 6 + + + 7 + 7 + + + 8 + 8 + + + 9 + 9 + + + 10 + 10 + + + Calendar + Kalender + + + Start Date: + Startdatum: + + + dd.MM.yyyy + dd.MM.yyyy + + + Target Date: + Zieldatum: + + + about:blank + about:blank + + + &File + &Datei + + + &New + &Neu + + + New &from... + Neu &von... + + + &Open + Ö&ffnen + + + Ctrl+O + Ctrl+O + + + &Save + &Speichern + + + Ctrl+S + Ctrl+S + + + Save &as... + Speichern &unter... + + + Ctrl+Shift+S + Ctrl+Shift+S + + + E&xit + &Beenden + + + Ctrl+X + Ctrl+X + + + Open Training + Training laden + + + Training Files (*.qtp);;XML Files (*.xml) + Trainingsdateien (*.qtp);;XML Dateien (*.xml) + + + Save Training + Training speichern + + + Description + Beschreibung + + + Count + Anzahl + + + Time + Zeit + + + Dist + Dist + + + HR + HR + + + Pace/Speed + Tempo/Geschw. + + + P.Time + P.Zeit + + + P.Dist + P.Dist + + + P.HR + P.HR + + + P.Pace/Speed + P.Tempo/Geschw. + + + MaxHR + MaxHR + + + Min-Max (%) + Min-Max (%) + + + Min-Max + Min-Max + + + %1 + %1 + + + %1% - %2% + %1% - %2% + + + %1 - %2 + %1 - %2 + + + (%1) %2 + (%1) %2 + + + %1 (%2) + %1 (%2) + + + test + test + + + Add training... + Training hinzufügen... + + + Add day... + Tag hinzufügen... + + + Edit training... + Training bearbeiten... + + + Delete training... + Training löschen... + + + Edit day... + Tag bearbeiten... + + + Delete day... + Tag löschen... + + + Add session... + Session hinzufügen... + + + Edit session... + Session bearbeiten... + + + Delete session... + Session löschen... + + + Add task... + Task hinzufügen... + + + Move up + Auf + + + Move down + Ab + + + Edit task... + Task bearbeiten... + + + Delete task... + Task löschen... + + + Training has been changed. Dou you want to save? + Training wurde geändert. Speichern? + + + yyyyMMdd + yyyyMMdd + + + MM:ss + MM:ss + + + min/km + min/km + + + %1 km/h + %1 km/h + + + Day allready exists! + Tag bereits vorhanden! + + + No training available! + Kein Training verfügbar! + + + Are you sure you want to delete this training? + Trining wirklich löschen? + + + Are you sure you want to delete this day? + Tag wirklich löschen? + + + Are you sure you want to delete this session? + Session wirklich löschen? + + + Are you sure you want to delete this task? + Task wirklich löschen? + + + No training to save! + Kein Training zum speichern! + + + Could not save training! + Kann Training nicht speichern! + + + qtTrainingPlan - + qtTrainingPlan - + + + + QMessageBox + + qtTrainingPlan + qtTrainingPlan + + +