From: Sakari Poussa Date: Mon, 12 Oct 2009 16:17:23 +0000 (+0300) Subject: initial commit X-Git-Url: http://vcs.maemo.org/git/?a=commitdiff_plain;h=2f1a9ddf160fb91a5f2e6b17dcc774413948b08e;p=scorecard initial commit --- 2f1a9ddf160fb91a5f2e6b17dcc774413948b08e diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..a8ddea2 --- /dev/null +++ b/Makefile @@ -0,0 +1,336 @@ +############################################################################# +# Makefile for building: bin/scorecard +# Generated by qmake (2.01a) (Qt 4.5.0) on: Mon Oct 12 19:08:14 2009 +# Project: scorecard.pro +# Template: app +# Command: /opt/qtsdk-2009.01/qt/bin/qmake -unix -o Makefile scorecard.pro +############################################################################# + +####### Compiler, tools and options + +CC = gcc +CXX = g++ +DEFINES = -DQT_XML_LIB -DQT_GUI_LIB -DQT_CORE_LIB -DQT_SHARED +CFLAGS = -pipe -g -D_REENTRANT -Wall -W $(DEFINES) +CXXFLAGS = -pipe -Wno-return-type -g -D_REENTRANT -Wall -W $(DEFINES) +INCPATH = -I/opt/qtsdk-2009.01/qt/mkspecs/linux-g++ -I. -I/opt/qtsdk-2009.01/qt/include/QtCore -I/opt/qtsdk-2009.01/qt/include/QtGui -I/opt/qtsdk-2009.01/qt/include/QtXml -I/opt/qtsdk-2009.01/qt/include -Imoc -Iobj +LINK = g++ +LFLAGS = -Wl,-rpath,/opt/qtsdk-2009.01/qt/lib +LIBS = $(SUBLIBS) -L/opt/qtsdk-2009.01/qt/lib -lQtXml -L/opt/qtsdk-2009.01/qt/lib -pthread -pthread -lQtGui -L/usr/X11R6/lib -pthread -lfreetype -lgobject-2.0 -lSM -lICE -pthread -pthread -lXrender -lfontconfig -lXext -lX11 -lQtCore -lm -pthread -lgthread-2.0 -lrt -lglib-2.0 -ldl -lpthread +AR = ar cqs +RANLIB = +QMAKE = /opt/qtsdk-2009.01/qt/bin/qmake +TAR = tar -cf +COMPRESS = gzip -9f +COPY = cp -f +SED = sed +COPY_FILE = $(COPY) +COPY_DIR = $(COPY) -r +INSTALL_FILE = install -m 644 -p +INSTALL_DIR = $(COPY_DIR) +INSTALL_PROGRAM = install -m 755 -p +DEL_FILE = rm -f +SYMLINK = ln -sf +DEL_DIR = rmdir +MOVE = mv -f +CHK_DIR_EXISTS= test -d +MKDIR = mkdir -p + +####### Output directory + +OBJECTS_DIR = obj/ + +####### Files + +SOURCES = src/main.cpp \ + src/main-window.cpp \ + src/score-dialog.cpp \ + src/course-dialog.cpp \ + src/cell-delegate.cpp \ + src/table-model.cpp \ + src/xml-parser.cpp \ + src/xml-dom-parser.cpp \ + src/data.cpp \ + src/tree-model.cpp \ + src/tree-item.cpp \ + src/tree-widget.cpp moc/moc_main-window.cpp \ + moc/moc_score-dialog.cpp \ + moc/moc_course-dialog.cpp \ + moc/moc_cell-delegate.cpp \ + moc/moc_table-model.cpp \ + moc/moc_tree-model.cpp \ + moc/moc_tree-widget.cpp +OBJECTS = obj/main.o \ + obj/main-window.o \ + obj/score-dialog.o \ + obj/course-dialog.o \ + obj/cell-delegate.o \ + obj/table-model.o \ + obj/xml-parser.o \ + obj/xml-dom-parser.o \ + obj/data.o \ + obj/tree-model.o \ + obj/tree-item.o \ + obj/tree-widget.o \ + obj/moc_main-window.o \ + obj/moc_score-dialog.o \ + obj/moc_course-dialog.o \ + obj/moc_cell-delegate.o \ + obj/moc_table-model.o \ + obj/moc_tree-model.o \ + obj/moc_tree-widget.o +DIST = /opt/qtsdk-2009.01/qt/mkspecs/common/g++.conf \ + /opt/qtsdk-2009.01/qt/mkspecs/common/unix.conf \ + /opt/qtsdk-2009.01/qt/mkspecs/common/linux.conf \ + /opt/qtsdk-2009.01/qt/mkspecs/qconfig.pri \ + /opt/qtsdk-2009.01/qt/mkspecs/features/qt_functions.prf \ + /opt/qtsdk-2009.01/qt/mkspecs/features/qt_config.prf \ + /opt/qtsdk-2009.01/qt/mkspecs/features/exclusive_builds.prf \ + /opt/qtsdk-2009.01/qt/mkspecs/features/default_pre.prf \ + /opt/qtsdk-2009.01/qt/mkspecs/features/debug.prf \ + /opt/qtsdk-2009.01/qt/mkspecs/features/default_post.prf \ + /opt/qtsdk-2009.01/qt/mkspecs/features/qt.prf \ + /opt/qtsdk-2009.01/qt/mkspecs/features/unix/thread.prf \ + /opt/qtsdk-2009.01/qt/mkspecs/features/moc.prf \ + /opt/qtsdk-2009.01/qt/mkspecs/features/warn_on.prf \ + /opt/qtsdk-2009.01/qt/mkspecs/features/resources.prf \ + /opt/qtsdk-2009.01/qt/mkspecs/features/uic.prf \ + /opt/qtsdk-2009.01/qt/mkspecs/features/yacc.prf \ + /opt/qtsdk-2009.01/qt/mkspecs/features/lex.prf \ + scorecard.pro +QMAKE_TARGET = scorecard +DESTDIR = bin/ +TARGET = bin/scorecard + +first: all +####### Implicit rules + +.SUFFIXES: .o .c .cpp .cc .cxx .C + +.cpp.o: + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o "$@" "$<" + +.cc.o: + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o "$@" "$<" + +.cxx.o: + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o "$@" "$<" + +.C.o: + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o "$@" "$<" + +.c.o: + $(CC) -c $(CFLAGS) $(INCPATH) -o "$@" "$<" + +####### Build rules + +all: Makefile $(TARGET) + +$(TARGET): $(OBJECTS) + @$(CHK_DIR_EXISTS) bin/ || $(MKDIR) bin/ + $(LINK) $(LFLAGS) -o $(TARGET) $(OBJECTS) $(OBJCOMP) $(LIBS) + +Makefile: scorecard.pro /opt/qtsdk-2009.01/qt/mkspecs/linux-g++/qmake.conf /opt/qtsdk-2009.01/qt/mkspecs/common/g++.conf \ + /opt/qtsdk-2009.01/qt/mkspecs/common/unix.conf \ + /opt/qtsdk-2009.01/qt/mkspecs/common/linux.conf \ + /opt/qtsdk-2009.01/qt/mkspecs/qconfig.pri \ + /opt/qtsdk-2009.01/qt/mkspecs/features/qt_functions.prf \ + /opt/qtsdk-2009.01/qt/mkspecs/features/qt_config.prf \ + /opt/qtsdk-2009.01/qt/mkspecs/features/exclusive_builds.prf \ + /opt/qtsdk-2009.01/qt/mkspecs/features/default_pre.prf \ + /opt/qtsdk-2009.01/qt/mkspecs/features/debug.prf \ + /opt/qtsdk-2009.01/qt/mkspecs/features/default_post.prf \ + /opt/qtsdk-2009.01/qt/mkspecs/features/qt.prf \ + /opt/qtsdk-2009.01/qt/mkspecs/features/unix/thread.prf \ + /opt/qtsdk-2009.01/qt/mkspecs/features/moc.prf \ + /opt/qtsdk-2009.01/qt/mkspecs/features/warn_on.prf \ + /opt/qtsdk-2009.01/qt/mkspecs/features/resources.prf \ + /opt/qtsdk-2009.01/qt/mkspecs/features/uic.prf \ + /opt/qtsdk-2009.01/qt/mkspecs/features/yacc.prf \ + /opt/qtsdk-2009.01/qt/mkspecs/features/lex.prf \ + /opt/qtsdk-2009.01/qt/lib/libQtXml.prl \ + /opt/qtsdk-2009.01/qt/lib/libQtCore.prl \ + /opt/qtsdk-2009.01/qt/lib/libQtGui.prl + $(QMAKE) -unix -o Makefile scorecard.pro +/opt/qtsdk-2009.01/qt/mkspecs/common/g++.conf: +/opt/qtsdk-2009.01/qt/mkspecs/common/unix.conf: +/opt/qtsdk-2009.01/qt/mkspecs/common/linux.conf: +/opt/qtsdk-2009.01/qt/mkspecs/qconfig.pri: +/opt/qtsdk-2009.01/qt/mkspecs/features/qt_functions.prf: +/opt/qtsdk-2009.01/qt/mkspecs/features/qt_config.prf: +/opt/qtsdk-2009.01/qt/mkspecs/features/exclusive_builds.prf: +/opt/qtsdk-2009.01/qt/mkspecs/features/default_pre.prf: +/opt/qtsdk-2009.01/qt/mkspecs/features/debug.prf: +/opt/qtsdk-2009.01/qt/mkspecs/features/default_post.prf: +/opt/qtsdk-2009.01/qt/mkspecs/features/qt.prf: +/opt/qtsdk-2009.01/qt/mkspecs/features/unix/thread.prf: +/opt/qtsdk-2009.01/qt/mkspecs/features/moc.prf: +/opt/qtsdk-2009.01/qt/mkspecs/features/warn_on.prf: +/opt/qtsdk-2009.01/qt/mkspecs/features/resources.prf: +/opt/qtsdk-2009.01/qt/mkspecs/features/uic.prf: +/opt/qtsdk-2009.01/qt/mkspecs/features/yacc.prf: +/opt/qtsdk-2009.01/qt/mkspecs/features/lex.prf: +/opt/qtsdk-2009.01/qt/lib/libQtXml.prl: +/opt/qtsdk-2009.01/qt/lib/libQtCore.prl: +/opt/qtsdk-2009.01/qt/lib/libQtGui.prl: +qmake: FORCE + @$(QMAKE) -unix -o Makefile scorecard.pro + +dist: + @$(CHK_DIR_EXISTS) obj/scorecard1.0.0 || $(MKDIR) obj/scorecard1.0.0 + $(COPY_FILE) --parents $(SOURCES) $(DIST) obj/scorecard1.0.0/ && $(COPY_FILE) --parents src/main-window.h src/score-dialog.h src/course-dialog.h src/cell-delegate.h src/table-model.h src/xml-parser.h src/xml-dom-parser.h src/data.h src/tree-model.h src/tree-item.h src/tree-widget.h obj/scorecard1.0.0/ && $(COPY_FILE) --parents src/main.cpp src/main-window.cpp src/score-dialog.cpp src/course-dialog.cpp src/cell-delegate.cpp src/table-model.cpp src/xml-parser.cpp src/xml-dom-parser.cpp src/data.cpp src/tree-model.cpp src/tree-item.cpp src/tree-widget.cpp obj/scorecard1.0.0/ && (cd `dirname obj/scorecard1.0.0` && $(TAR) scorecard1.0.0.tar scorecard1.0.0 && $(COMPRESS) scorecard1.0.0.tar) && $(MOVE) `dirname obj/scorecard1.0.0`/scorecard1.0.0.tar.gz . && $(DEL_FILE) -r obj/scorecard1.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/moc_main-window.cpp moc/moc_score-dialog.cpp moc/moc_course-dialog.cpp moc/moc_cell-delegate.cpp moc/moc_table-model.cpp moc/moc_tree-model.cpp moc/moc_tree-widget.cpp +compiler_moc_header_clean: + -$(DEL_FILE) moc/moc_main-window.cpp moc/moc_score-dialog.cpp moc/moc_course-dialog.cpp moc/moc_cell-delegate.cpp moc/moc_table-model.cpp moc/moc_tree-model.cpp moc/moc_tree-widget.cpp +moc/moc_main-window.cpp: src/data.h \ + src/table-model.h \ + src/tree-model.h \ + src/tree-item.h \ + src/main-window.h + /opt/qtsdk-2009.01/qt/bin/moc $(DEFINES) $(INCPATH) src/main-window.h -o moc/moc_main-window.cpp + +moc/moc_score-dialog.cpp: src/data.h \ + src/score-dialog.h + /opt/qtsdk-2009.01/qt/bin/moc $(DEFINES) $(INCPATH) src/score-dialog.h -o moc/moc_score-dialog.cpp + +moc/moc_course-dialog.cpp: src/course-dialog.h + /opt/qtsdk-2009.01/qt/bin/moc $(DEFINES) $(INCPATH) src/course-dialog.h -o moc/moc_course-dialog.cpp + +moc/moc_cell-delegate.cpp: src/cell-delegate.h + /opt/qtsdk-2009.01/qt/bin/moc $(DEFINES) $(INCPATH) src/cell-delegate.h -o moc/moc_cell-delegate.cpp + +moc/moc_table-model.cpp: src/data.h \ + src/table-model.h + /opt/qtsdk-2009.01/qt/bin/moc $(DEFINES) $(INCPATH) src/table-model.h -o moc/moc_table-model.cpp + +moc/moc_tree-model.cpp: src/tree-item.h \ + src/data.h \ + src/tree-model.h + /opt/qtsdk-2009.01/qt/bin/moc $(DEFINES) $(INCPATH) src/tree-model.h -o moc/moc_tree-model.cpp + +moc/moc_tree-widget.cpp: src/tree-widget.h + /opt/qtsdk-2009.01/qt/bin/moc $(DEFINES) $(INCPATH) src/tree-widget.h -o moc/moc_tree-widget.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: +compiler_uic_clean: +compiler_yacc_decl_make_all: +compiler_yacc_decl_clean: +compiler_yacc_impl_make_all: +compiler_yacc_impl_clean: +compiler_lex_make_all: +compiler_lex_clean: +compiler_clean: compiler_moc_header_clean + +####### Compile + +obj/main.o: src/main.cpp src/main-window.h \ + src/data.h \ + src/table-model.h \ + src/tree-model.h \ + src/tree-item.h + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o obj/main.o src/main.cpp + +obj/main-window.o: src/main-window.cpp src/main-window.h \ + src/data.h \ + src/table-model.h \ + src/tree-model.h \ + src/tree-item.h \ + src/score-dialog.h \ + src/course-dialog.h \ + src/tree-widget.h \ + src/xml-parser.h \ + src/xml-dom-parser.h + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o obj/main-window.o src/main-window.cpp + +obj/score-dialog.o: src/score-dialog.cpp src/score-dialog.h \ + src/data.h + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o obj/score-dialog.o src/score-dialog.cpp + +obj/course-dialog.o: src/course-dialog.cpp src/course-dialog.h \ + src/cell-delegate.h + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o obj/course-dialog.o src/course-dialog.cpp + +obj/cell-delegate.o: src/cell-delegate.cpp src/cell-delegate.h + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o obj/cell-delegate.o src/cell-delegate.cpp + +obj/table-model.o: src/table-model.cpp src/table-model.h \ + src/data.h + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o obj/table-model.o src/table-model.cpp + +obj/xml-parser.o: src/xml-parser.cpp src/xml-parser.h \ + src/data.h + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o obj/xml-parser.o src/xml-parser.cpp + +obj/xml-dom-parser.o: src/xml-dom-parser.cpp src/xml-dom-parser.h \ + src/data.h + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o obj/xml-dom-parser.o src/xml-dom-parser.cpp + +obj/data.o: src/data.cpp src/data.h + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o obj/data.o src/data.cpp + +obj/tree-model.o: src/tree-model.cpp src/tree-model.h \ + src/tree-item.h \ + src/data.h + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o obj/tree-model.o src/tree-model.cpp + +obj/tree-item.o: src/tree-item.cpp src/tree-item.h \ + src/data.h + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o obj/tree-item.o src/tree-item.cpp + +obj/tree-widget.o: src/tree-widget.cpp src/tree-widget.h + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o obj/tree-widget.o src/tree-widget.cpp + +obj/moc_main-window.o: moc/moc_main-window.cpp + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o obj/moc_main-window.o moc/moc_main-window.cpp + +obj/moc_score-dialog.o: moc/moc_score-dialog.cpp + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o obj/moc_score-dialog.o moc/moc_score-dialog.cpp + +obj/moc_course-dialog.o: moc/moc_course-dialog.cpp + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o obj/moc_course-dialog.o moc/moc_course-dialog.cpp + +obj/moc_cell-delegate.o: moc/moc_cell-delegate.cpp + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o obj/moc_cell-delegate.o moc/moc_cell-delegate.cpp + +obj/moc_table-model.o: moc/moc_table-model.cpp + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o obj/moc_table-model.o moc/moc_table-model.cpp + +obj/moc_tree-model.o: moc/moc_tree-model.cpp + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o obj/moc_tree-model.o moc/moc_tree-model.cpp + +obj/moc_tree-widget.o: moc/moc_tree-widget.cpp + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o obj/moc_tree-widget.o moc/moc_tree-widget.cpp + +####### Install + +install: FORCE + +uninstall: FORCE + +FORCE: + diff --git a/TODO b/TODO new file mode 100644 index 0000000..eb1e36b --- /dev/null +++ b/TODO @@ -0,0 +1,12 @@ +General: + +- New course - selection dialog +- Course view +- Stat view +- Settings + +Hildon 2.2 + +- Date picker for the score dialog +- Replace LineEdit w/ HildonEntry + \ No newline at end of file diff --git a/bin/data/club-save.xml b/bin/data/club-save.xml new file mode 100644 index 0000000..894f1d9 --- /dev/null +++ b/bin/data/club-save.xml @@ -0,0 +1,152 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/bin/data/club.xml b/bin/data/club.xml new file mode 100644 index 0000000..894f1d9 --- /dev/null +++ b/bin/data/club.xml @@ -0,0 +1,152 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/bin/data/save/club.xml b/bin/data/save/club.xml new file mode 100644 index 0000000..480d26e --- /dev/null +++ b/bin/data/save/club.xml @@ -0,0 +1,152 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/bin/data/save/score.xml b/bin/data/save/score.xml new file mode 100644 index 0000000..44628f4 --- /dev/null +++ b/bin/data/save/score.xml @@ -0,0 +1,622 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/bin/data/score-save.xml b/bin/data/score-save.xml new file mode 100644 index 0000000..32240a2 --- /dev/null +++ b/bin/data/score-save.xml @@ -0,0 +1,642 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/bin/data/score.xml b/bin/data/score.xml new file mode 100644 index 0000000..7405258 --- /dev/null +++ b/bin/data/score.xml @@ -0,0 +1,842 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/bin/data/score.xml~ b/bin/data/score.xml~ new file mode 100644 index 0000000..3126fb3 --- /dev/null +++ b/bin/data/score.xml~ @@ -0,0 +1,282 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/data/club-save.xml b/data/club-save.xml new file mode 100644 index 0000000..894f1d9 --- /dev/null +++ b/data/club-save.xml @@ -0,0 +1,152 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/data/club.xml b/data/club.xml new file mode 100644 index 0000000..894f1d9 --- /dev/null +++ b/data/club.xml @@ -0,0 +1,152 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/data/save/club.xml b/data/save/club.xml new file mode 100644 index 0000000..480d26e --- /dev/null +++ b/data/save/club.xml @@ -0,0 +1,152 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/data/save/score.xml b/data/save/score.xml new file mode 100644 index 0000000..44628f4 --- /dev/null +++ b/data/save/score.xml @@ -0,0 +1,622 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/data/score-save.xml b/data/score-save.xml new file mode 100644 index 0000000..32240a2 --- /dev/null +++ b/data/score-save.xml @@ -0,0 +1,642 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/data/score.xml b/data/score.xml new file mode 100644 index 0000000..7405258 --- /dev/null +++ b/data/score.xml @@ -0,0 +1,842 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/data/score.xml~ b/data/score.xml~ new file mode 100644 index 0000000..3126fb3 --- /dev/null +++ b/data/score.xml~ @@ -0,0 +1,282 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/debian/changelog b/debian/changelog new file mode 100644 index 0000000..d5bccea --- /dev/null +++ b/debian/changelog @@ -0,0 +1,6 @@ +scorecard (0.1-1) unstable; urgency=low + + * Initial release + + -- Sakari Poussa Sun, 11 Oct 2009 + diff --git a/debian/changelog~ b/debian/changelog~ new file mode 100644 index 0000000..180d9f1 --- /dev/null +++ b/debian/changelog~ @@ -0,0 +1,14 @@ +qt-maemo-example (0.1-2) unstable; urgency=low + + * Fix Maemo-Icon-26 field in control + * Fix postinstall script + * Remove install script + + -- Antonio Aloisio Fri, 15 Aug 2008 08:46:17 +0300 + +qt-maemo-example (0.1-1) unstable; urgency=low + + * Initial release + + -- Antonio Aloisio Wed, 13 Aug 2008 14:17:22 +0300 + diff --git a/debian/compat b/debian/compat new file mode 100644 index 0000000..7ed6ff8 --- /dev/null +++ b/debian/compat @@ -0,0 +1 @@ +5 diff --git a/debian/control b/debian/control new file mode 100644 index 0000000..694a4b1 --- /dev/null +++ b/debian/control @@ -0,0 +1,42 @@ +Source: scorecard +Section: user/other +Priority: optional +Maintainer: Sakari Poussa (spoussa@gmail.com) +Build-Depends: debhelper (>= 5), libqt4-dev +Standards-Version: 3.7.2 + +Package: scorecard +Architecture: any +Depends: libqt4-core (>= 4.5.3), libqt4-gui (>= 4.5.3), libqt4-xml (>= 4.5.3) +Description: A simple golf score card application for N900 + . + Further Information: qt4.garage.maemo.org +XB-Maemo-Icon-26: + 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 + RK5CYII= diff --git a/debian/control~ b/debian/control~ new file mode 100644 index 0000000..d6a39fa --- /dev/null +++ b/debian/control~ @@ -0,0 +1,46 @@ +Source: qt-maemo-example +Section: user/other +Priority: optional +Maintainer: Antonio Aloisio +Build-Depends: debhelper (>= 5), libqt4-dev +Standards-Version: 3.7.2 + +Package: qt-maemo-example +Architecture: any +Depends: libqt4-core (>= 4.5.2), libc6 (>= 2.5.0-1), libgcc1 (>= 1:4.2.1), libqt4-gui (>= 4.5.2), libstdc++6 (>= 4.2.1),, hildon-application-manager +Description: A simple Qt text editor + A simple Qt application to test maemo Qt. + You can analize this package in order to + understand how to package a Qt application + for maemo. + . + Further Information: qt4.garage.maemo.org +XB-Maemo-Icon-26: + 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 + RK5CYII= diff --git a/debian/copyright b/debian/copyright new file mode 100644 index 0000000..d3596d9 --- /dev/null +++ b/debian/copyright @@ -0,0 +1,22 @@ +This package was debianized by unknown on +Wed, 13 Aug 2008 14:17:22 +0300. + +It was downloaded from + +Upstream Author: + +Copyright: + +License: + + + + +The Debian packaging is (C) 2008, unknown and +is licensed under the GPL, see `/usr/share/common-licenses/GPL'. + + +# Please also look if there are files or directories which have a +# different copyright/license attached and list them here. + diff --git a/debian/dirs b/debian/dirs new file mode 100644 index 0000000..80507f1 --- /dev/null +++ b/debian/dirs @@ -0,0 +1,2 @@ +usr/bin +usr/share/applications/hildon diff --git a/debian/postinst b/debian/postinst new file mode 100644 index 0000000..79fb6dd --- /dev/null +++ b/debian/postinst @@ -0,0 +1,5 @@ +#!/bin/sh -e + +gtk-update-icon-cache -f /usr/share/icons/hicolor + +exit 0 diff --git a/debian/rules b/debian/rules new file mode 100755 index 0000000..4d4009e --- /dev/null +++ b/debian/rules @@ -0,0 +1,72 @@ +#!/usr/bin/make -f +# -*- makefile -*- +# Sample debian/rules that uses debhelper. +# This file was originally written by Joey Hess and Craig Small. +# As a special exception, when this file is copied by dh-make into a +# dh-make output file, you may use that output file without restriction. +# This special exception was added by Craig Small in version 0.37 of dh-make. + +# Uncomment this to turn on verbose mode. +#export DH_VERBOSE=1 + +APPNAME := qt-maemo-example +builddir: + mkdir -p builddir + +builddir/Makefile: builddir + cd builddir && qmake-qt4 PREFIX=/usr ../$(APPNAME).pro + +build: build-stamp + +build-stamp: builddir/Makefile + dh_testdir + + # Add here commands to compile the package. + cd builddir && $(MAKE) + #docbook-to-man debian/$(APPNAME).sgml > $(APPNAME).1 + + touch $@ + +clean: + dh_testdir + dh_testroot + rm -f build-stamp + + # Add here commands to clean up after the build process. + rm -rf builddir + + dh_clean + +install: build + dh_testdir + dh_testroot + dh_clean -k + dh_installdirs + + # Add here commands to install the package into debian/arora. + cd builddir && $(MAKE) INSTALL_ROOT=$(CURDIR)/debian/$(APPNAME) install + + +# Build architecture-independent files here. +binary-indep: build install +# We have nothing to do by default. + +# Build architecture-dependent files here. +binary-arch: build install + dh_testdir + dh_testroot + dh_installdocs + dh_installexamples + dh_installman + dh_link + dh_strip + dh_compress + dh_fixperms + dh_installdeb + dh_shlibdeps + dh_gencontrol + dh_md5sums + dh_builddeb + +binary: binary-indep binary-arch +.PHONY: build clean binary-indep binary-arch binary install configure diff --git a/debian/substvars b/debian/substvars new file mode 100644 index 0000000..ef7081a --- /dev/null +++ b/debian/substvars @@ -0,0 +1 @@ +shlibs:Depends=libc6 (>= 2.5.0-1), libgcc1 (>= 1:4.2.1), libqt4-core (>= 4.5.2-git20090622), libqt4-gui (>= 4.5.2-git20090622), libstdc++6 (>= 4.2.1) diff --git a/scorecard.pro b/scorecard.pro new file mode 100644 index 0000000..c9899d7 --- /dev/null +++ b/scorecard.pro @@ -0,0 +1,37 @@ +DESTDIR = bin +MOC_DIR = moc +OBJECTS_DIR = obj +UI_DIR = obj + +QMAKE_CXXFLAGS += -Wno-return-type + +CONFIG += qt debug +TEMPLATE = app +QT += xml + +HEADERS = \ +src/main-window.h \ +src/score-dialog.h \ +src/course-dialog.h \ +src/cell-delegate.h \ +src/table-model.h \ +src/xml-parser.h \ +src/xml-dom-parser.h \ +src/data.h \ +src/tree-model.h \ +src/tree-item.h \ +src/tree-widget.h + +SOURCES = \ +src/main.cpp \ +src/main-window.cpp \ +src/score-dialog.cpp \ +src/course-dialog.cpp \ +src/cell-delegate.cpp \ +src/table-model.cpp \ +src/xml-parser.cpp \ +src/xml-dom-parser.cpp \ +src/data.cpp \ +src/tree-model.cpp \ +src/tree-item.cpp \ +src/tree-widget.cpp diff --git a/src/cell-delegate.cpp b/src/cell-delegate.cpp new file mode 100644 index 0000000..126fa2a --- /dev/null +++ b/src/cell-delegate.cpp @@ -0,0 +1,58 @@ +#include "cell-delegate.h" +#include +#include + +CellDelegate::CellDelegate(QObject *parent) : QItemDelegate(parent) +{ + m_parent = parent; +} + +QWidget *CellDelegate::createEditor(QWidget *parent, + const QStyleOptionViewItem &, + const QModelIndex &index) const +{ + CellFilter *filter = new CellFilter(m_parent); // HACK + + //CellFilter filter(parent); + + QLineEdit *le = new QLineEdit(parent); + + le->installEventFilter(filter); + + qDebug() << "parent=" << parent << " m_parent=" << m_parent; + // HACK: Connect CellFilter signal to CourseDialog nextCell slot + connect(filter, SIGNAL(nextCell(QObject *)), m_parent, SLOT(nextCell(QObject *))); + + return le; +} + +void CellDelegate::commitAndCloseEditor() +{ + QLineEdit *editor = qobject_cast(sender()); + + // TODO: del editor + emit commitData(editor); + emit closeEditor(editor); +} + +void CellDelegate::setEditorData(QWidget *editor, + const QModelIndex &index) const +{ + QString value = index.model()->data(index, Qt::EditRole).toString(); + + QLineEdit *le = static_cast(editor); + + le->setText(value); +} + +void CellDelegate::setModelData(QWidget *editor, + QAbstractItemModel *model, const QModelIndex &index) const +{ + QLineEdit *le = static_cast(editor); + + QString value = le->text(); + + model->setData(index, value, Qt::EditRole); + +} + diff --git a/src/cell-delegate.h b/src/cell-delegate.h new file mode 100644 index 0000000..75c5069 --- /dev/null +++ b/src/cell-delegate.h @@ -0,0 +1,70 @@ +#ifndef CELLDELEGATE_H +#define CELLDELEGATE_H + +#include +#include +#include +#include +//#include "cell.h" + +class CellFilter : public QObject +{ + Q_OBJECT + +public: + CellFilter(QObject *parent=0) : QObject(parent) + { + m_parent = parent; + } + + signals: + void nextCell(QObject *); + +protected: + bool eventFilter(QObject *dist, QEvent *event) + { + if (event->type() == QEvent::KeyPress) { + QKeyEvent *keyEvent = static_cast(event); + static QString digits = QString("123456789"); + if (digits.indexOf(keyEvent->text()) != -1) { + qDebug() << "Key press number"; + int rc = QObject::eventFilter(dist, event); + emit nextCell(m_parent); + //return rc; + return false; + } + else { + qDebug() << "Key press invalid"; + return true; + } + } + + } + private: + QObject *m_parent; +}; + +class CellDelegate : public QItemDelegate +{ + Q_OBJECT + +public: + CellDelegate(QObject *parent = 0); + QWidget *createEditor(QWidget *parent, const QStyleOptionViewItem &, + const QModelIndex &index) const; + void setEditorData(QWidget *editor, const QModelIndex &index) const; + void setModelData(QWidget *editor, QAbstractItemModel *model, + const QModelIndex &index) const; + CellFilter *filter; + + signals: + void nextCell(QObject *); + +private slots: + void commitAndCloseEditor(); + + private: + QObject *m_parent; +}; + +#endif // CELLDELEGATE_H diff --git a/src/course-dialog.cpp b/src/course-dialog.cpp new file mode 100644 index 0000000..dd6bedb --- /dev/null +++ b/src/course-dialog.cpp @@ -0,0 +1,134 @@ +#include +#include +#include +#include +#include + +#include "course-dialog.h" +#include "cell-delegate.h" + + +CourseDialog::CourseDialog(QWidget *parent) : QDialog(parent) +{ + resize(800, 400); + + QFont font; + font.setPointSize(20); + setFont(font); + + createTable(); + createLabel(); + + createLayout(this); + + setWindowTitle(tr("New Course")); +} + +void CourseDialog::createLayout(QWidget *parent) +{ + leftLayout = new QVBoxLayout; + leftLayout->addWidget(table); + + rightLayout = new QVBoxLayout; + rightLayout->addStretch(); + rightLayout->addWidget(pushButtonOk); + + QHBoxLayout *mainLayout = new QHBoxLayout(parent); + mainLayout->addLayout(leftLayout); + mainLayout->addLayout(rightLayout); + setLayout(mainLayout); +} + +void CourseDialog::createLabel(QWidget *parent) +{ + clubLabel = new QLabel(tr("Club")); + courseLabel = new QLabel(tr("Course")); + + clubEdit = new QLineEdit; + courseEdit = new QLineEdit; + + pushButtonOk = new QPushButton(tr("OK")); +} + +void CourseDialog::createTable(QWidget *parent) +{ + table = new QTableWidget(rows, cols); + + QStringList headers; + headers << "Hole" << "Par" << "HCP" << "Len" << "Hole" << "Par" << "HCP" << "Len"; + table->setVerticalHeaderLabels(headers); + table->horizontalHeader()->hide(); + + //CellDelegate *cellDelegate = new CellDelegate(this); + //table->setItemDelegate(cellDelegate); + + table->horizontalHeader()->setResizeMode(QHeaderView::Stretch); + table->verticalHeader()->setResizeMode(QHeaderView::Stretch); + + for (int i=0; i<18; i++) { + QTableWidgetItem *par = new QTableWidgetItem(""); + QTableWidgetItem *hcp = new QTableWidgetItem(""); + QTableWidgetItem *len = new QTableWidgetItem(""); + + QTableWidgetItem *holeNum = new QTableWidgetItem(QString::number(i+1)); + QColor bgColor(Qt::gray); + holeNum->setBackgroundColor(bgColor); + + holeNum->setTextAlignment(Qt::AlignCenter); + par->setTextAlignment(Qt::AlignCenter); + hcp->setTextAlignment(Qt::AlignCenter); + len->setTextAlignment(Qt::AlignCenter); + + if (i < 9) { + table->setItem(0, i, holeNum); + table->setItem(1, i, par); + table->setItem(2, i, hcp); + table->setItem(3, i, len); + } + else { + table->setItem(4, i-9, holeNum); + table->setItem(5, i-9, par); + table->setItem(6, i-9, hcp); + table->setItem(7, i-9, len); + } + } + + //connect(table, SIGNAL(itemChanged(QTableWidgetItem *)), this, SLOT(itemChanged(QTableWidgetItem *))); + +} + +void CourseDialog::itemChanged(QTableWidgetItem *item) +{ + qDebug() << "itemChanged"; + + int row = table->currentRow(); + int col = table->currentColumn(); + + col++; + if (col == cols) { + col = 0; + row++; + if (row == separator_row) + row++; + } + table->setCurrentCell(row, col); +} + +void CourseDialog::nextCell(QObject *obj) +{ +#if 0 + int row = table->currentRow(); + int col = table->currentColumn(); + QTableWidgetItem *item = table->item(row, col); + + qDebug() << "next Cell " << obj; + qDebug() << "item " << item << "row=" << row << " col=" << col; + + table->setItem(row, col, item); + + + table->currentIndex(); + table->setCurrentCell(2,2); +#endif +} + diff --git a/src/course-dialog.h b/src/course-dialog.h new file mode 100644 index 0000000..06bb9b5 --- /dev/null +++ b/src/course-dialog.h @@ -0,0 +1,78 @@ +#ifndef COURSE_DIALOG_H +#define COURSE_DIALOG_H + +#include +#include +#include +#include +#include +#include +#include + +QT_BEGIN_NAMESPACE +class QTableWidget; +class QTableWidgetItem; +QT_END_NAMESPACE + +class ScoreTable : public QTableWidget +{ +public: + ScoreTable(int r, int c, QWidget *p=0) : QTableWidget(r, c, p) {} + + QSize minimumSizeHint() const + { + QSize size( QTableWidget::sizeHint() ); + int width = 0; + + for (int c = 0; c < columnCount(); ++c) + width += columnWidth( c ); + + size.setWidth( width + 4 ); + return size; + } + + QSize sizeHint() const + { + return minimumSizeHint(); + } + +}; + +class CourseDialog: public QDialog +{ + Q_OBJECT + + public: + CourseDialog(QWidget *w); + + public slots: + void itemChanged(QTableWidgetItem *item); + void nextCell(QObject *); + + private: + enum { rows = 8, cols = 9, separator_row = 3 }; + enum { NumGridRows = 3, NumButtons = 4 }; + + void createTable(QWidget *parent = 0); + void createLabel(QWidget *parent = 0); + void createLayout(QWidget *parent = 0); + + QLabel *labels[NumGridRows]; + QLineEdit *lineEdits[NumGridRows]; + QPushButton *buttons[NumButtons]; + + // Widgets + //ScoreTable *table; + QTableWidget *table; + QLabel *clubLabel; + QLabel *courseLabel; + QLineEdit *clubEdit; + QLineEdit *courseEdit; + QPushButton *pushButtonOk; + + // Layouts + QVBoxLayout *rightLayout; + QVBoxLayout *leftLayout; +}; + +#endif diff --git a/src/data.cpp b/src/data.cpp new file mode 100644 index 0000000..d49082c --- /dev/null +++ b/src/data.cpp @@ -0,0 +1,298 @@ +#include "data.h" + +//////////////////////////////////////////////////////////////////////// +// Hole +//////////////////////////////////////////////////////////////////////// + +Hole::Hole(const QXmlAttributes &attrs) { + if (attrs.index("num") != -1) + num = attrs.value("num"); + if (attrs.index("shots") != -1) + shots = attrs.value("shots"); + if (attrs.index("putts") != -1) + putts = attrs.value("putts"); + if (attrs.index("hcp") != -1) + hcp = attrs.value("hcp"); + if (attrs.index("length") != -1) + length = attrs.value("length"); + if (attrs.index("par") != -1) + par = attrs.value("par"); +} + +Hole::Hole(const QDomElement node) { + num = node.attribute("num", ""); + shots = node.attribute("shots", ""); + putts = node.attribute("putts", ""); + hcp = node.attribute("hcp", ""); + length = node.attribute("length", ""); + par = node.attribute("par", ""); +} + +Hole::Hole(int num, QString &shots) +{ + this->num = QString::number(num); + this->shots = shots; +} + +QDomElement Hole::toElement(QDomDocument doc) +{ + QDomElement node = doc.createElement("hole"); + + if (!num.isEmpty()) + node.setAttribute("num", num); + if (!shots.isEmpty()) + node.setAttribute("shots", shots); + if (!putts.isEmpty()) + node.setAttribute("putts", putts); + if (!hcp.isEmpty()) + node.setAttribute("hcp", hcp); + if (!length.isEmpty()) + node.setAttribute("length", length); + if (!par.isEmpty()) + node.setAttribute("par", par); + + return node; +} + +QString Hole::getShots() { + return shots; +} + +QString Hole::getHcp() { + return hcp; +} + +QString Hole::getPar() { + return par; +} + +void Hole::dump() { + qDebug() << num << "(" << par << ") : " << shots << "/" << putts ; +} + +//////////////////////////////////////////////////////////////////////// +// Score +//////////////////////////////////////////////////////////////////////// + +Score::Score(const QXmlAttributes &attrs) +{ + club = attrs.value("club"); + course = attrs.value("course"); + date = attrs.value("date"); +} + +Score::Score(QString &iClub, QString &iCourse, QString &iDate) +{ + club = iClub; + course = iCourse; + date = iDate; +} + +Score::Score(QVector scores, QString &club, QString &course, QString &date) +{ + this->club = club; + this->course = course; + this->date = date; + + for (int i=0; itoElement(doc)); + } + return node; +} + +void Score::addHole(Hole *iHole) { + holeList << iHole; +} + +QString Score::getScore(int i) { + if (i >= 0 && i < holeList.size()) + return holeList.at(i)->getShots(); + else + return QString("-"); +} + +QString Score::getTotal(int what) { + int tot = 0; + + if (what == Total) + for (int i=0; i <= 17; i++) + tot += holeList.at(i)->getShots().toInt(); + + if (what == TotalOut) + for (int i=0; i <= 8; i++) + tot += holeList.at(i)->getShots().toInt(); + + if (what == TotalIn) + for (int i=9; i <= 17; i++) + tot += holeList.at(i)->getShots().toInt(); + + return QString("%1").arg(tot); +} + +QString& Score::getClubName() { + return club; +} + +QString& Score::getCourseName() { + return course; +} + +QString& Score::getDate() { + return date; +} + +void Score::dump() { + qDebug() << club << " " << course << " " << date ; + for (int i=0; idump(); +} + +//////////////////////////////////////////////////////////////////////// +// Course +//////////////////////////////////////////////////////////////////////// + +Course::Course(const QXmlAttributes &attrs) { + name = attrs.value("name"); +} + +Course::Course(const QDomElement node) { + name = node.attribute("name", ""); +} + +QDomElement Course::toElement(QDomDocument doc) +{ + QDomElement node = doc.createElement("course"); + + node.setAttribute("name", name); + + for (int i=0; i < holeList.size(); i++) { + Hole *hole = holeList.at(i); + node.appendChild(hole->toElement(doc)); + } + return node; +} + +void Course::addHole(Hole *iHole) { + holeList << iHole; +} + +QString Course::getPar(int i) { + if (i >= 0 && i < holeList.size()) + return holeList.at(i)->getPar(); + else + return QString("-"); +} + +QString Course::getHcp(int i) { + if (i >= 0 && i < holeList.size()) + return holeList.at(i)->getHcp(); + else + return QString("-"); +} + +QString& Course::getName() +{ + return name; +} + +QString Course::getTotal(int what) { + int tot = 0; + + if (what == Total) + for (int i = 0; i < 18; i++) + tot += holeList.at(i)->getPar().toInt(); + + if (what == TotalOut) + for (int i = 0; i < 9; i++) + tot += holeList.at(i)->getPar().toInt(); + + if (what == TotalIn) + for (int i = 9; i < 18; i++) + tot += holeList.at(i)->getPar().toInt(); + + return QString("%1").arg(tot); +} + + +void Course::dump() { + qDebug() << " " << name; + for (int i=0; idump(); +} + +//////////////////////////////////////////////////////////////////////// +// Club +//////////////////////////////////////////////////////////////////////// + +Club::Club(const QXmlAttributes &attrs) { + name = attrs.value("name"); +} + +Club::Club(const QDomElement node) { + name = node.attribute("name", ""); +} + +void Club::addCourse(Course *iCourse) { + courseList << iCourse; +} + +QDomElement Club::toElement(QDomDocument doc) +{ + QDomElement node = doc.createElement("club"); + + node.setAttribute("name", name); + + for (int i=0; i < courseList.size(); i++) { + Course *course = courseList.at(i); + node.appendChild(course->toElement(doc)); + } + return node; +} + +void Club::dump() { + qDebug() << name; + for (int i=0; idump(); +} + +QString& Club::getName() { return name; } + +Course *Club::getCourse(int pos) { + return courseList.at(pos); +} + +Course *Club::getCourse(QString &courseName) { + QListIterator i(courseList); + Course *c = 0; + + while (i.hasNext()) { + c = i.next(); + if (c->getName() == courseName) { + qDebug() << "Match " << courseName; + break; + } + } + return c; +} diff --git a/src/data.h b/src/data.h new file mode 100644 index 0000000..77c74f1 --- /dev/null +++ b/src/data.h @@ -0,0 +1,88 @@ +#ifndef __SCORE_DATA_H +#define __SCORE_DATA_H + +#include +#include +#include +#include +#include + +enum { TotalOut, TotalIn, Total }; + + +class Hole { + public: + Hole(const QXmlAttributes &attrs); + Hole(const QDomElement node); + Hole(int num, QString &shots); + QDomElement toElement(QDomDocument doc); + QString getShots(); + QString getHcp(); + QString getPar(); + void dump(); + + private: + QString num, shots, putts, hcp, length, par; +}; + +class Score { + public: + + Score(const QXmlAttributes &attrs); + Score(QString &iClub, QString &iCourse, QString &iDate); + Score(const QDomElement node); + Score(QVector scores, QString &club, QString &course, QString &date); + + QDomElement toElement(QDomDocument doc); + void addHole(Hole *iHole); + QString getScore(int i); + QString getTotal(int what); + QString& getClubName(); + QString& getCourseName(); + QString& getDate(); + void dump(); + + private: + QList holeList; + QString club, course, date; + +}; + +class Course { + public: + Course(const QXmlAttributes &attrs); + Course(const QDomElement node); + QDomElement toElement(QDomDocument doc); + void addHole(Hole *iHole); + QString getPar(int i); + QString getHcp(int i); + QString& getName(); + QString getTotal(int what); + void dump(); + + private: + QList holeList; + QString name; + +}; + +class Club { + public: + + Club(const QXmlAttributes &attrs); + Club(const QDomElement node); + QDomElement toElement(QDomDocument doc); + void addCourse(Course *iCourse); + void dump(); + QString& getName(); + Course *getCourse(int pos); + Course *getCourse(QString &courseName); + + QList getCourseList() { return courseList; } // HACK: fixme + + private: + QList courseList; + QString name; + +}; +#endif diff --git a/src/main-window.cpp b/src/main-window.cpp new file mode 100644 index 0000000..d19bf8b --- /dev/null +++ b/src/main-window.cpp @@ -0,0 +1,294 @@ +#include +#include +#include +#include +#include + +#include "main-window.h" +#include "score-dialog.h" +#include "course-dialog.h" +#include "tree-widget.h" +#include "xml-parser.h" +#include "xml-dom-parser.h" + +QString scoreFile("data/score.xml"); +QString scoreFileWr("data/score-save.xml"); +QString clubFile("data/club.xml"); +QString clubFileWr("data/club-save.xml"); + +MainWindow::MainWindow(QMainWindow *parent) : QMainWindow(parent) +{ + resize(800, 480); + + QWidget *centralWidget = new QWidget(this); + + // TODO: move to proper function + tableViewFront = new QTableView(centralWidget); + tableViewBack = new QTableView(centralWidget); + + setCentralWidget(centralWidget); + + loadScoreFile(scoreFile, scoreList); + loadClubFile(clubFile, clubList); + +#ifdef TEST + saveScoreFile(scoreFileWr, scoreList); + saveClubFile(clubFileWr, clubList); +#endif + + createTableView(scoreList, clubList); + //createTreeView(scoreList, parent); + createStatusBar(); + + createLayout(centralWidget); + + createActions(); + createMenus(); +} + +void MainWindow::createLayout(QWidget *parent) +{ + buttonLayout = new QVBoxLayout; + //labelLayout->addStretch(); + buttonLayout->addWidget(nextButton); + buttonLayout->addWidget(prevButton); + buttonLayout->addWidget(lastButton); + buttonLayout->addWidget(firstButton); + + tableLayout = new QVBoxLayout; + tableLayout->addWidget(tableViewFront); + tableLayout->addWidget(tableViewBack); + + QHBoxLayout *mainLayout = new QHBoxLayout(parent); + mainLayout->addLayout(tableLayout); + mainLayout->addLayout(buttonLayout); + setLayout(mainLayout); +} + +// Setup 'score' tab view +void MainWindow::createTableView(QList &scoreList, QList &clubList) +{ + nextButton = new QPushButton(tr(">")); + prevButton = new QPushButton(tr("<")); + firstButton = new QPushButton(tr("<<")); + lastButton = new QPushButton(tr(">>")); + + connect(nextButton, SIGNAL(clicked()), this, SLOT(nextButtonClicked())); + connect(prevButton, SIGNAL(clicked()), this, SLOT(prevButtonClicked())); + connect(firstButton, SIGNAL(clicked()), this, SLOT(firstButtonClicked())); + connect(lastButton, SIGNAL(clicked()), this, SLOT(lastButtonClicked())); + + scoreTableModel = new ScoreTableModel(); + scoreTableModel->setScore(scoreList); + scoreTableModel->setClub(clubList); + + tableViewFront->showGrid(); + tableViewBack->showGrid(); + + tableViewFront->setModel(scoreTableModel); + tableViewBack->setModel(scoreTableModel); + + // Flag model items which one belongs to front and back nines + tableViewFront->setRootIndex(scoreTableModel->index(0, 0)); + tableViewBack->setRootIndex(scoreTableModel->index(0, 1)); + + // Fill out all the space with the tables + tableViewFront->horizontalHeader()->setResizeMode(QHeaderView::Stretch); + tableViewFront->verticalHeader()->setResizeMode(QHeaderView::Stretch); + tableViewBack->horizontalHeader()->setResizeMode(QHeaderView::Stretch); + tableViewBack->verticalHeader()->setResizeMode(QHeaderView::Stretch); +} + +// When selection down in 'stat' view, this is called. +void MainWindow::updateTreeView(const QModelIndex & index) +{ + QString scope("Scope"); + QString count("Rounds"); + QString scoreAvg("Score (avg.)"); + QString scoreBest("Score (best)"); + QString score("Total"); + QString scoreIn("Total in"); + QString scoreOut("Total out"); + + QVariant str = scoreTreeModel->data(index, Qt::DisplayRole); + QVariant type = scoreTreeModel->data(index, ScoreTreeModel::Type); + + qDebug() << "update(" << index.row() << "/" << index.column() << "):" << str << type; + + tableModel->setData(tableModel->index(0, 0, QModelIndex()), scope); + tableModel->setData(tableModel->index(0, 1, QModelIndex()), str); + + if (type == TreeItem::TypeDate) { + tableModel->setData(tableModel->index(1, 0, QModelIndex()), count); + tableModel->setData(tableModel->index(2, 0, QModelIndex()), scoreAvg); + tableModel->setData(tableModel->index(3, 0, QModelIndex()), scoreBest); + } + else if (type == TreeItem::TypeScore) { + QVariant value = scoreTreeModel->data(index, ScoreTreeModel::Total); + tableModel->setData(tableModel->index(1, 0, QModelIndex()), score); + tableModel->setData(tableModel->index(1, 1, QModelIndex()), value); + + value = scoreTreeModel->data(index, ScoreTreeModel::TotalOut); + tableModel->setData(tableModel->index(2, 0, QModelIndex()), scoreOut); + tableModel->setData(tableModel->index(2, 1, QModelIndex()), value); + + value = scoreTreeModel->data(index, ScoreTreeModel::TotalIn); + tableModel->setData(tableModel->index(3, 0, QModelIndex()), scoreIn); + tableModel->setData(tableModel->index(3, 1, QModelIndex()), value); + } +} + +void MainWindow::createStatusBar() +{ + updateStatusBar(); +} + +void MainWindow::createActions() +{ + newScoreAct = new QAction(tr("&New Score"), this); + connect(newScoreAct, SIGNAL(triggered()), this, SLOT(newScore())); + + newCourseAct = new QAction(tr("&New Course"), this); + connect(newCourseAct, SIGNAL(triggered()), this, SLOT(newCourse())); + +#if 0 + viewScoreAct = new QAction(tr("&View Scores"), this); + connect(viewScoreAct, SIGNAL(triggered()), this, SLOT(viewScore())); + + viewCourseAct = new QAction(tr("&View Courses"), this); + connect(viewCourseAct, SIGNAL(triggered()), this, SLOT(viewCourse())); + + viewStatisticAct = new QAction(tr("&View Statistics"), this); + connect(viewStatisticAct, SIGNAL(triggered()), this, SLOT(viewStatistic())); +#endif +} + +void MainWindow::createMenus() +{ + menu = menuBar()->addMenu(tr("fremantle")); +#if 0 + menu->addAction(viewScoreAct); + menu->addAction(viewCourseAct); + menu->addAction(viewStatisticAct); +#endif + menu->addAction(newScoreAct); + menu->addAction(newCourseAct); +} + +void MainWindow::updateStatusBar() +{ + setWindowTitle(scoreTableModel->getInfoText()); +} + +void MainWindow::firstButtonClicked() +{ + scoreTableModel->first(); + updateStatusBar(); +} + +void MainWindow::lastButtonClicked() +{ + scoreTableModel->last(); + updateStatusBar(); +} + +void MainWindow::nextButtonClicked() +{ + scoreTableModel->next(); + updateStatusBar(); +} + +void MainWindow::prevButtonClicked() +{ + scoreTableModel->prev(); + updateStatusBar(); +} + +void MainWindow::newCourse() +{ + CourseDialog *dlg = new CourseDialog(this); + + int result = dlg->exec(); +} + +void MainWindow::newScore() +{ + SelectDialog *selectDialog = new SelectDialog(this); + + selectDialog->init(clubList); + + int result = selectDialog->exec(); + if (result) { + QString clubName; + QString courseName; + QString date; + + selectDialog->results(clubName, courseName, date); + qDebug() << "club=" << clubName; + qDebug() << "course=" << courseName; + qDebug() << "date=" << date; + + ScoreDialog *scoreDialog = new ScoreDialog(this); + + // FIXME + Club *club = clubList[0]; + Course *course = club->getCourse(courseName); + + scoreDialog->init(course); + + result = scoreDialog->exec(); + + if (result) { + QVector scores(18); + + scoreDialog->results(scores); + for (int i=0; isetScore(scoreList); + lastButtonClicked(); + } + } +} + +void MainWindow::loadScoreFile(QString &fileName, QList &list) +{ + ScoreXmlHandler handler(list); + + if (handler.parse(fileName)) + qDebug() << "Score loaded : " << fileName << + " entries : " << list.size(); +} + +void MainWindow::saveScoreFile(QString &fileName, QList &list) +{ + ScoreXmlHandler handler(list); + + if (handler.save(fileName)) + qDebug() << "Score saved : " << fileName << + " entries : " << list.size(); +} + +void MainWindow::loadClubFile(QString &fileName, QList &list) +{ + ClubXmlHandler handler(list); + + if (handler.parse(fileName)) + qDebug() << "Club loaded: " << fileName << + " entries : " << list.size(); +} + +void MainWindow::saveClubFile(QString &fileName, QList &list) +{ + ClubXmlHandler handler(list); + + if (handler.save(fileName)) + qDebug() << "Club saved : " << fileName << + " entries : " << list.size(); +} diff --git a/src/main-window.h b/src/main-window.h new file mode 100644 index 0000000..65a7d9c --- /dev/null +++ b/src/main-window.h @@ -0,0 +1,81 @@ +#include +#include +#include +#include +#include +#include +#include +#include + +#include "data.h" +#include "table-model.h" +#include "tree-model.h" + +class MainWindow : public QMainWindow +{ + Q_OBJECT + +public: + MainWindow(QMainWindow *parent = 0); + void createLayout(QWidget *parent = 0); + void createStatusBar(); + void createTableView(QList &scoreList, QList &clubList); + void createTreeView(QList &scoreList, QObject *parent); + void updateStatusBar(); + void loadScoreFile(QString &fileName, QList &scoreList); + void loadClubFile(QString &fileName, QList &clubList); + void saveScoreFile(QString &fileName, QList &scoreList); + void saveClubFile(QString &fileName, QList &clubList); + +signals: + void dataChanged(); + +private slots: + void firstButtonClicked(); + void lastButtonClicked(); + void nextButtonClicked(); + void prevButtonClicked(); + + void updateTreeView(const QModelIndex & index); + void newScore(); + void newCourse(); + +private: + + QList scoreList; + QList clubList; + + ScoreTableModel *scoreTableModel; + ScoreTreeModel *scoreTreeModel; + + QAbstractItemModel *tableModel; + QItemSelectionModel *selectionModel; + + QTableView *tableViewFront; + QTableView *tableViewBack; + + // Layouts + QVBoxLayout *tableLayout; + QVBoxLayout *buttonLayout; + + // Menus + QMenu *menu; + + // Buttons + QPushButton *nextButton; + QPushButton *prevButton; + QPushButton *firstButton; + QPushButton *lastButton; + + // Actions + QAction *newScoreAct; + QAction *newCourseAct; + QAction *viewScoreAct; + QAction *viewCourseAct; + QAction *viewStatisticAct; + + void createMenus(); + void createActions(); + + +}; diff --git a/src/main.cpp b/src/main.cpp new file mode 100644 index 0000000..e1f9e23 --- /dev/null +++ b/src/main.cpp @@ -0,0 +1,25 @@ +#include +#include +#include + +#include "main-window.h" + +int main(int argc, char *argv[]) +{ + QApplication app(argc, argv); + + //#define Q_WS_HILDON +#ifdef Q_WS_HILDON + QStringList keys = QInputContextFactory::keys(); + qDebug() << "Input Context Factory keys: " << keys; + QInputContext *hildonInputContext=0; + //QHildonInputContext *hildonInputContext=QInputContextFactory::create("hildon"); + hildonInputContext=QInputContextFactory::create("hildon", 0); + app.setInputContext(hildonInputContext); +#endif + + MainWindow win; + win.show(); + + return app.exec(); +} diff --git a/src/score-dialog.cpp b/src/score-dialog.cpp new file mode 100644 index 0000000..b33f12e --- /dev/null +++ b/src/score-dialog.cpp @@ -0,0 +1,354 @@ +#include +#include + +#include "score-dialog.h" + +SelectDialog::SelectDialog(QWidget *parent) : QDialog(parent) +{ + QWidget *centralWidget = new QWidget(this); + createLayout(centralWidget); + + setWindowTitle(tr("ScoreCard: Select Club, Course and Date")); +} + +void SelectDialog::createLayout(QWidget *parent) +{ + labelClub = new QLabel(tr("Club")); + labelCourse = new QLabel(tr("Course")); + comboBoxClub = new QComboBox; + comboBoxCourse = new QComboBox; + lineEditDate = new QLineEdit; + pushButtonNext = new QPushButton(tr("Next")); + + QDate today(QDate::currentDate()); + lineEditDate->setText(today.toString("yyyy-MM-dd")); + + connect(pushButtonNext, SIGNAL(clicked()), this, SLOT(next())); + connect(comboBoxClub, SIGNAL(activated(int)), this, SLOT(comboBoxClubChanged())); + connect(comboBoxCourse, SIGNAL(activated(int)), this, SLOT(comboBoxCourseChanged())); + + leftLayout = new QVBoxLayout; + leftLayout->addWidget(comboBoxClub); + leftLayout->addWidget(comboBoxCourse); + leftLayout->addWidget(lineEditDate); + + rightLayout = new QVBoxLayout; + rightLayout->addStretch(); + rightLayout->addWidget(pushButtonNext); + + QHBoxLayout *mainLayout = new QHBoxLayout(parent); + mainLayout->addLayout(leftLayout); + mainLayout->addLayout(rightLayout); + + setLayout(mainLayout); +} + +void SelectDialog::init(QList &list) +{ + clubList = list; + + QListIterator i(clubList); + int index = 0; + + while (i.hasNext()) { + Club *club = i.next(); + comboBoxClub->insertItem(index, club->getName()); + index++; + } + comboBoxCourseUpdate(); +} + +void SelectDialog::results(QString &club, + QString &course, + QString &date) +{ + club = comboBoxClub->currentText(); + course = comboBoxCourse->currentText(); + date = lineEditDate->text(); +} + +void SelectDialog::comboBoxCourseUpdate() +{ + int index = comboBoxClub->currentIndex(); + + Club *club = clubList[index]; + QList courseList = club->getCourseList(); + + comboBoxCourse->clear(); + QListIterator i(courseList); + index = 0; + while (i.hasNext()) { + Course *course = i.next(); + comboBoxCourse->insertItem(index, course->getName()); + index++; + } +} + +void SelectDialog::comboBoxClubChanged() +{ + comboBoxCourseUpdate(); +} + +void SelectDialog::comboBoxCourseChanged() +{ +} + +bool SelectDialog::validate(void) +{ + return true; +} + +void SelectDialog::next(void) +{ + if (validate()) + done(1); + else { + qDebug() << "SelectDialog: invalid data, cancel or correct"; + } +} + +void SelectDialog::reject(void) +{ + done(0); +} + +//////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// + +ScoreDialog::ScoreDialog(QWidget *parent) : QDialog(parent) +{ + resize(800, 400); + + QFont font; + font.setPointSize(20); + setFont(font); + + QWidget *centralWidget = new QWidget(this); + + createTable(); + createButton(); + + createLayout(centralWidget); + + setWindowTitle(tr("ScoreCard: New Score")); +} + +void ScoreDialog::createLayout(QWidget *parent) +{ + leftLayout = new QVBoxLayout; + leftLayout->addWidget(table); + + rightLayout = new QVBoxLayout; + rightLayout->addWidget(pushButtonUp); + rightLayout->addWidget(pushButtonDown); + rightLayout->addWidget(pushButtonNext); + rightLayout->addStretch(); + rightLayout->addWidget(pushButtonFinnish); + + QHBoxLayout *mainLayout = new QHBoxLayout(parent); + mainLayout->addLayout(leftLayout); + mainLayout->addLayout(rightLayout); + + setLayout(mainLayout); +} + +void ScoreDialog::createTable(QWidget *parent) +{ + table = new QTableWidget(ROWS, COLS, parent); + + table->horizontalHeader()->setResizeMode(QHeaderView::Stretch); + table->verticalHeader()->setResizeMode(QHeaderView::Stretch); + table->horizontalHeader()->hide(); + + QStringList headers; + headers << "" << "Par" << "HCP" << "Score" << "" << "Par" << "HCP" << "Score"; + table->setVerticalHeaderLabels(headers); + + //connect(table, SIGNAL(itemChanged(QTableWidgetItem *)), this, SLOT(itemChanged(QTableWidgetItem *))); + //connect(table, SIGNAL(itemPressed(QTableWidgetItem *)), this, SLOT(itemChanged(QTableWidgetItem *))); +} + +void ScoreDialog::createButton(QWidget *parent) +{ + pushButtonFinnish = new QPushButton(tr("Finnish")); + connect(pushButtonFinnish, SIGNAL(clicked()), this, SLOT(finnish())); + + pushButtonUp = new QPushButton(tr("+")); + connect(pushButtonUp, SIGNAL(clicked()), this, SLOT(up())); + + pushButtonDown = new QPushButton(tr("-")); + connect(pushButtonDown, SIGNAL(clicked()), this, SLOT(down())); + + pushButtonNext = new QPushButton(tr("Next")); + connect(pushButtonNext, SIGNAL(clicked()), this, SLOT(next())); +} + +void ScoreDialog::init(Course *course) +{ + QTableWidgetItem *par, *hcp, *score; + + for (int i = 0; i < 18; i++) { + par = new QTableWidgetItem(course->getPar(i)); + hcp = new QTableWidgetItem(course->getHcp(i)); + score = new QTableWidgetItem(""); + //score->setInputMask("9"); + + QTableWidgetItem *holeNum = new QTableWidgetItem(QString::number(i+1)); + QColor bgColor(Qt::gray); + holeNum->setBackgroundColor(bgColor); + + holeNum->setTextAlignment(Qt::AlignCenter); + + par->setTextAlignment(Qt::AlignCenter); + hcp->setTextAlignment(Qt::AlignCenter); + score->setTextAlignment(Qt::AlignCenter); + + if (i < 9) { + table->setItem(ROW_HOLE, i, holeNum); + table->setItem(ROW_PAR, i, par); + table->setItem(ROW_HCP, i, hcp); + table->setItem(ROW_SCORE, i, score); + } + else { + table->setItem(ROW_HOLE_2, i-9, holeNum); + table->setItem(ROW_PAR_2, i-9, par); + table->setItem(ROW_HCP_2, i-9, hcp); + table->setItem(ROW_SCORE_2, i-9, score); + } + } + + // Set focus to 1st cell + table->setCurrentCell(ROW_SCORE, 0); + setDefaultScore(table); +} + +// Set default score to par if not set +void ScoreDialog::setDefaultScore(QTableWidget *table) +{ + int row = table->currentRow(); + int col = table->currentColumn(); + + if (row == ROW_SCORE) + row = ROW_PAR; + else if (row == ROW_SCORE_2) + row = ROW_PAR_2; + else { + qDebug() << "ERROR: unknown row in default score"; + return; + } + QTableWidgetItem *par = table->item(row, col); + QTableWidgetItem *score = table->item(row + 2, col); + + if (par && score && score->text() == "") { + QVariant value(par->text()); + score->setData(Qt::DisplayRole, value); + } +} + +void ScoreDialog::moveToNextCell(QTableWidgetItem *item) +{ + if (!item) + return; + + QTableWidget *table = item->tableWidget(); + + if (!table) + return; + + int row = table->currentRow(); + int col = table->currentColumn(); + + if (col < (COLS-1)) { + col++; + } + else if (col == (COLS-1)) { + col = 0; + row = (row == ROW_SCORE_2) ? ROW_SCORE : ROW_SCORE_2; + } + //qDebug() << "new cell: " << row << "/" << col; + table->setCurrentCell(row, col); +} + +void ScoreDialog::next(void) +{ + if (table) { + QTableWidgetItem *item = table->currentItem(); + moveToNextCell(item); + setDefaultScore(table); + } +} + +void ScoreDialog::up(void) +{ + QTableWidgetItem *item = table->currentItem(); + + if (!item) + return; + + int i = (item->text()).toInt(); + QVariant value(i+1); + item->setData(Qt::DisplayRole, value); +} + +void ScoreDialog::down(void) +{ + QTableWidgetItem *item = table->currentItem(); + + if (!item) + return; + + int i = (item->text()).toInt(); + QVariant value(i-1); + item->setData(Qt::DisplayRole, value); +} + +void ScoreDialog::itemChanged(QTableWidgetItem *item) +{ +} + +void ScoreDialog::results(QVector &scores) +{ + for (int i = 0; i < 9; i++) { + QTableWidgetItem *frontItem = table->item(ROW_SCORE, i); + QTableWidgetItem *backItem = table->item(ROW_SCORE_2, i); + + if (frontItem) + scores[i] = frontItem->text(); + + if (backItem) + scores[i+9] = backItem->text(); + } +} + +bool ScoreDialog::validate(void) +{ + for (int i=0; i<9; i++) { + QTableWidgetItem *frontItem = table->item(ROW_SCORE, i); + QTableWidgetItem *backItem = table->item(ROW_SCORE_2, i); + + if (!frontItem || !backItem) + return false; + + QString str1 = frontItem->text(); + QString str2 = backItem->text(); + + if (str1.isEmpty() || str2.isEmpty()) + return false; + } + return true; +} + +void ScoreDialog::finnish(void) +{ + if (validate()) + done(1); + else { + qDebug() << "ScoreDialog: invalid data, cancel or correct"; + } +} + +void ScoreDialog::reject(void) +{ + done(0); +} diff --git a/src/score-dialog.h b/src/score-dialog.h new file mode 100644 index 0000000..0b9b748 --- /dev/null +++ b/src/score-dialog.h @@ -0,0 +1,96 @@ +#ifndef SCORE_DIALOG_H +#define SCORE_DIALOG_H + +#include +#include +#include +#include +#include +#include + +#include "data.h" + +class SelectDialog: public QDialog +{ + Q_OBJECT + + public: + SelectDialog(QWidget *parent = 0); + + void results(QString &club, QString &course, QString &date); + void init(QList &list); + +private slots: + void comboBoxClubChanged(); + void comboBoxCourseChanged(); + void next(void); + + private: + + bool validate(void); + void reject(void); + + void comboBoxCourseUpdate(void); + void createLayout(QWidget *parent = 0); + + QComboBox *comboBoxClub; + QComboBox *comboBoxCourse; + + QLineEdit *lineEditDate; + + QLabel *labelClub; + QLabel *labelCourse; + + QPushButton *pushButtonNext; + + // Layouts + QVBoxLayout *leftLayout; + QVBoxLayout *rightLayout; + + QList clubList; +}; + +class ScoreDialog: public QDialog +{ + Q_OBJECT + +public: + ScoreDialog(QWidget *parent = 0); + void init(Course *course); + void results(QVector &scores); + bool validate(void); + +private slots: + void itemChanged(QTableWidgetItem *item); + void moveToNextCell(QTableWidgetItem *item); + void finnish(void); + void up(void); + void down(void); + void next(void); + +private: + + void createTable(QWidget *parent = 0); + void createButton(QWidget *parent = 0); + void createLayout(QWidget *parent = 0); + void setDefaultScore(QTableWidget *table); + + enum { ROWS = 8, COLS = 9 }; + enum { ROW_HOLE = 0, ROW_PAR = 1, ROW_HCP = 2, ROW_SCORE = 3, + ROW_HOLE_2 = 4, ROW_PAR_2 = 5, ROW_HCP_2 = 6, ROW_SCORE_2 = 7}; + + void reject(void); + + // Widgets + QTableWidget *table; + + QPushButton *pushButtonFinnish; + QPushButton *pushButtonUp; + QPushButton *pushButtonDown; + QPushButton *pushButtonNext; + + // Layouts + QVBoxLayout *leftLayout; + QVBoxLayout *rightLayout; +}; +#endif diff --git a/src/table-model.cpp b/src/table-model.cpp new file mode 100644 index 0000000..c0cc2d7 --- /dev/null +++ b/src/table-model.cpp @@ -0,0 +1,253 @@ + +#include +#include +#include "table-model.h" + +Qt::ItemFlags ScoreTableModel::flags ( const QModelIndex & index ) +{ + return Qt::NoItemFlags; +} + +void ScoreTableModel::setScore(QList &sList) +{ + scoreList = sList; + score = scoreList.at(currentScore); // NOTE: assumes non-empty list +} + +void ScoreTableModel::setClub(QList &cList) +{ + clubList = cList; + club = clubList.at(0); + course = club->getCourse(0); +} + +QString ScoreTableModel::getInfoText() +{ + QString str = QString("%1, %2 / [%3/%4]").arg(score->getCourseName()).arg(score->getDate()).arg(currentScore+1).arg(scoreList.count()); + return str; +} + +QString ScoreTableModel::getCountText() +{ + QString str = QString("%1/%2").arg(currentScore+1, 2).arg(scoreList.count(), 2); + return str; +} + +Course *ScoreTableModel::findCourse(QString &clubName, QString &courseName) +{ + QListIterator i(clubList); + Club *c; + + while (i.hasNext()) { + c = i.next(); + if (c->getName() == clubName) { + return c->getCourse(courseName); + } + } + return 0; +} + +void ScoreTableModel::first() +{ + currentScore = 0; + score = scoreList.at(currentScore); + course = findCourse(score->getClubName(), score->getCourseName()); + emit dataChanged(createIndex(0, 0), createIndex(ROW_COUNT-1, COL_COUNT-1)); +} + +void ScoreTableModel::last() +{ + currentScore = scoreList.size() - 1; + score = scoreList.at(currentScore); + course = findCourse(score->getClubName(), score->getCourseName()); + emit dataChanged(createIndex(0, 0), createIndex(ROW_COUNT-1, COL_COUNT-1)); +} + +void ScoreTableModel::next() +{ + if (currentScore < (scoreList.size() - 1)) { + currentScore++; + score = scoreList.at(currentScore); + course = findCourse(score->getClubName(), score->getCourseName()); + emit dataChanged(createIndex(0, 0), createIndex(ROW_COUNT-1, COL_COUNT-1)); + } +} + +void ScoreTableModel::prev() +{ + if (currentScore > 0) { + currentScore--; + score = scoreList.at(currentScore); + course = findCourse(score->getClubName(), score->getCourseName()); + emit dataChanged(createIndex(0, 0), createIndex(ROW_COUNT-1, COL_COUNT-1)); + } +} + +int ScoreTableModel::rowCount(const QModelIndex & parent) const +{ + return ROW_COUNT; +} + +int ScoreTableModel::columnCount(const QModelIndex & parent) const +{ + return COL_COUNT + 2; // 2 for in/out and tot columns +} + +QModelIndex ScoreTableModel::index(int row, int column, const QModelIndex &parent) const +{ + if (hasIndex(row, column, parent)) { + int flag = (parent.column() > 0) ? parent.column() : 0; + //qDebug() << "index() " << row << "/" << column << "/ flag: " << flag <<"//" << parent; + return createIndex(row, column, flag); + } + else { + return QModelIndex(); + } +} + +#define ROW_PAR 0 +#define ROW_HCP 1 +#define ROW_SCORE 2 + +QVariant ScoreTableModel::data(const QModelIndex &index, int role) const +{ + if (!index.isValid()) + return QVariant(); + + int row = index.row(); + int col = index.column(); + + // + // ALIGNMENT + // + if (role == Qt::TextAlignmentRole ) { + return Qt::AlignCenter; + } + + // Does this item belog to front or back nine + int offset = index.internalId() ? 9 : 0; + if (index.column() > 10) + return QVariant(); + + // + // COLORS + // + if (role == Qt::BackgroundRole) { + int par = (course->getPar(index.column() + offset)).toInt(); + int shots = (score->getScore(index.column() + offset)).toInt(); + + if (index.row() == ROW_SCORE) { + if (index.column() == 10 && offset == 9) { + // Total score + QColor color(Qt::blue); + QBrush brush(color); + return brush; + } + if (col == 9 && row == 2) { + // In and Out scores + QColor color(Qt::blue); + QBrush brush(color); + return brush; + } + if (index.column() < 9) { + if (shots == par) { + // Par + QColor color(Qt::yellow); + QBrush brush(color); + return brush; + } + if (shots == (par-1)) { + // Birdie + QColor color(Qt::green); + QBrush brush(color); + return brush; + } + if (shots == (par+1)) { + // Bogey + QColor color(Qt::red); + QBrush brush(color); + return brush; + } + } + } + return QVariant(); + } + + + // + // DATA + // + if (role == Qt::DisplayRole) { + // In/Out column + if (index.column() == 9) { + if (index.row() == ROW_PAR) + if (offset == 0) + return course->getTotal(TotalOut); + else + return course->getTotal(TotalIn); + else if (index.row() == ROW_SCORE) { + if (offset == 0) + return score->getTotal(TotalOut); + else + return score->getTotal(TotalIn); + } + else + return QVariant(); + } + + // Tot column + if (index.column() == 10) { + if (index.row() == ROW_PAR && offset == 9) + return course->getTotal(Total); + else if (index.row() == ROW_SCORE && offset == 9) + return score->getTotal(Total); + else + return QVariant(); + } + + //qDebug() << "data() " << index << "/" << offset; + switch(index.row()) { + case ROW_PAR: + return course->getPar(index.column() + offset); + case ROW_HCP: + return course->getHcp(index.column() + offset); + case ROW_SCORE: + return score->getScore(index.column() + offset); + } + } + return QVariant(); +} + +int ScoreTableModel::setItem(int row, int col, int data) +{ + emit dataChanged(createIndex(row, col), createIndex(row, col)); + return 1; +} + +QVariant ScoreTableModel::headerData(int section, Qt::Orientation orientation, int role) const +{ + if (role != Qt::DisplayRole) + return QVariant(); + + // TODO: how to diff between the two table views (no index?) + + if (orientation == Qt::Horizontal) + if (section >= 0 && section <= 8) + return QString("%1").arg(section+1); + else if (section == 9) + return QString("I/O"); + else + return QString("Tot"); + else { + switch(section) { + case 0: + return QString("Par"); + case 1: + return QString("HCP"); + case 2: + return QString("Score"); + } + } + return QVariant(); +} + diff --git a/src/table-model.h b/src/table-model.h new file mode 100644 index 0000000..89c0ab1 --- /dev/null +++ b/src/table-model.h @@ -0,0 +1,51 @@ +#include +#include + +#include "data.h" + +#define ROW_COUNT 3 +#define COL_COUNT 9 + +// TODO: change name to ScoreTableModel +class ScoreTableModel : public QAbstractTableModel +{ + + Q_OBJECT + +public: + + ScoreTableModel(QObject *parent = 0) : QAbstractTableModel(parent) + { + currentScore = 0; + } + Qt::ItemFlags flags ( const QModelIndex & index ); + void setScore(QList &sList); + void setClub(QList &cList); + Course *findCourse(QString &clubName, QString &courseName); + int rowCount(const QModelIndex & parent) const; + int columnCount(const QModelIndex & parent) const; + QModelIndex index(int row, int column, const QModelIndex &parent = QModelIndex()) const; + QVariant data(const QModelIndex & index, int role) const; + QVariant headerData(int section, Qt::Orientation orientation, int role) const; + + int setItem(int row, int col, int data); + + QString getInfoText(); + QString getCountText(); + + void next(); + void prev(); + void first(); + void last(); + + private: + QList scoreList; + QList clubList; + + int currentScore; + + // Current data pointers + Score *score; + Club *club; + Course *course; +}; diff --git a/src/tree-item.cpp b/src/tree-item.cpp new file mode 100644 index 0000000..7c0e6d6 --- /dev/null +++ b/src/tree-item.cpp @@ -0,0 +1,65 @@ +#include "tree-item.h" + +TreeItem::TreeItem() +{ + this->type = TypeRoot; + this->score = 0; + parent = 0; +} + +TreeItem::TreeItem(const QString &str) +{ + this->type = TypeDate; + this->score = 0; + this->str = str; + parent = 0; +} + +TreeItem::TreeItem(Score *s) +{ + this->type = TypeScore; + this->score = s; + this->str = s->getDate(); + parent = 0; +} + +TreeItem::~TreeItem() +{ + qDeleteAll(children); +} + +#if 1 +int TreeItem::childCount() const +{ + return children.count(); +} + +int TreeItem::columnCount() const +{ + return 1; +} + +void TreeItem::appendChild(TreeItem *item) +{ + item->parent = this; + children.append(item); +} + +TreeItem *TreeItem::child(int row) +{ + return children.value(row); +} + +QVariant TreeItem::data(int column) const +{ + return str; +} + +int TreeItem::row() const +{ + if (parent) + return parent->children.indexOf(const_cast(this)); + + return 0; +} +#endif diff --git a/src/tree-item.h b/src/tree-item.h new file mode 100644 index 0000000..bd82d7c --- /dev/null +++ b/src/tree-item.h @@ -0,0 +1,35 @@ +#include +#include +#include + +#include "data.h" + +class TreeItem +{ + + public: + enum Type { TypeRoot, TypeScore, TypeDate }; + + TreeItem(); + TreeItem(const QString &str); + TreeItem(Score *score); + ~TreeItem(); + +#if 1 + void appendChild(TreeItem *item); + int childCount() const; + int columnCount() const; + TreeItem *child(int row); + QVariant data(int column) const; + int row() const; +#endif + + Type type; + QString str; + Score *score; + + QList children; + + TreeItem *parent; + +}; diff --git a/src/tree-model.cpp b/src/tree-model.cpp new file mode 100644 index 0000000..9047bd4 --- /dev/null +++ b/src/tree-model.cpp @@ -0,0 +1,174 @@ +#include "tree-model.h" +#include + +ScoreTreeModel::ScoreTreeModel(QList &scoreList, QObject *parent) : QAbstractItemModel(parent) +{ + rootItem = new TreeItem(); + setupModelData(scoreList, rootItem); +} + +void ScoreTreeModel::setupModelData(QList &scoreList, TreeItem *parent) +{ + QListIterator iScore(scoreList); + QMultiMap yearMap; + QStringList yearList; + QSet yearSet; + + // Create multi map with years as keys, scores as values + // Create list of years + while (iScore.hasNext()) { + Score *score = iScore.next(); + QString year = score->getDate().split("-").at(0); + yearMap.insert(year, score); + yearList << year; + } + + // Create uniq list of years + yearSet = QSet::fromList(yearList); + QList years = yearMap.keys(); + QSetIterator iYear(yearSet); + + // For each year, add scores as childs + while (iYear.hasNext()) { + QString year = iYear.next(); + + qDebug() << "---" << year; + + TreeItem *newItem = new TreeItem(year); + parent->appendChild(newItem); + + QList scoresPerYear = yearMap.values(year); + QListIterator iScoresPerYear(scoresPerYear); + + // for each year, add score + while (iScoresPerYear.hasNext()) { + Score *s = iScoresPerYear.next(); + TreeItem *nextItem = new TreeItem(s); + newItem->appendChild(nextItem); + } + } +} + +int ScoreTreeModel::rowCount(const QModelIndex & parent) const +{ + TreeItem *parentItem; + if (parent.column() > 0) + return 0; + + if (!parent.isValid()) + parentItem = rootItem; + else + parentItem = static_cast(parent.internalPointer()); + + return parentItem->childCount(); +} + +int ScoreTreeModel::columnCount(const QModelIndex & parent) const +{ + if (parent.isValid()) + return static_cast(parent.internalPointer())->columnCount(); + else + return rootItem->columnCount(); +} + +TreeItem *ScoreTreeModel::itemFromIndex(const QModelIndex &index) const +{ + if (index.isValid()) + return static_cast(index.internalPointer()); + else + return rootItem; +} + +//Given a model index for a parent item, this function allows views +//and delegates to access children of that item +QModelIndex ScoreTreeModel::index(int row, int column, const QModelIndex &parent) const +{ + QModelIndex index; + + if (!hasIndex(row, column, parent)) + return QModelIndex(); + + TreeItem *parentItem = itemFromIndex(parent); + TreeItem *childItem = parentItem->children.value(row); + + if (childItem) + index = createIndex(row, column, childItem); + else + index = QModelIndex(); + + //qDebug() << "index: " << row << ":" << column << "parent" << parent << "index" << index; + return index; +} + +QModelIndex ScoreTreeModel::parent(const QModelIndex & index) const +{ + if (!index.isValid()) + return QModelIndex(); + + TreeItem *item = itemFromIndex(index); + if (!item) + return QModelIndex(); + + TreeItem *parent = item->parent; + if (!parent) + return QModelIndex(); + + TreeItem *grandParent = parent->parent; + if (!grandParent) + return QModelIndex(); + + int row = grandParent->children.indexOf(parent); + return createIndex(row, 0, parent); +} + +QVariant ScoreTreeModel::data(const QModelIndex &index, int role) const +{ + if (!index.isValid()) + return QVariant(); + + if (role != Qt::DisplayRole && role < Qt::UserRole) + return QVariant(); + + TreeItem *item = itemFromIndex(index); + if (!item) + return QVariant(); + + switch(role) { + case Qt::DisplayRole: + return item->str; + + // User defined roles + case Type: + return item->type; + + case Total: + if (item->score) + return item->score->getTotal(Total); + break; + + case TotalOut: + if (item->score) + return item->score->getTotal(TotalOut); + break; + + case TotalIn: + if (item->score) + return item->score->getTotal(TotalIn); + break; + + default: + qDebug() << "data: unknow role: " << role; + } + return QVariant(); +} + +QVariant ScoreTreeModel::headerData(int section, Qt::Orientation orientation, int role) const +{ + + if (orientation == Qt::Horizontal && role == Qt::DisplayRole) + return rootItem->data(section); + + return QVariant(); + +} + diff --git a/src/tree-model.h b/src/tree-model.h new file mode 100644 index 0000000..c7cffe6 --- /dev/null +++ b/src/tree-model.h @@ -0,0 +1,28 @@ +#include +#include + +#include "tree-item.h" + +class ScoreTreeModel : public QAbstractItemModel +{ + + Q_OBJECT + +public: + + enum Roles {Type=Qt::UserRole, Rounds, Total, TotalIn, TotalOut, ScoreBest, ScoreAvg }; + + ScoreTreeModel(QList &scoreList, QObject *parent = 0); + int rowCount(const QModelIndex & parent) const; + int columnCount(const QModelIndex & parent) const; + QModelIndex index(int row, int column, const QModelIndex &parent = QModelIndex()) const; + QModelIndex parent(const QModelIndex &index) const; + QVariant data(const QModelIndex & index, int role) const; + QVariant headerData(int section, Qt::Orientation orientation, int role) const; + + void setupModelData(QList &scoreList, TreeItem *parent); + + private: + TreeItem *itemFromIndex(const QModelIndex &index) const; + TreeItem *rootItem; +}; diff --git a/src/tree-widget.cpp b/src/tree-widget.cpp new file mode 100644 index 0000000..c76361f --- /dev/null +++ b/src/tree-widget.cpp @@ -0,0 +1,13 @@ +#include "tree-widget.h" + +ScoreTreeWidget::ScoreTreeWidget(QWidget *parent) + : QTreeWidget(parent) +{ +} + +#if 1 +QSize ScoreTreeWidget::sizeHint() const +{ + return QSize(300, 380); +} +#endif diff --git a/src/tree-widget.h b/src/tree-widget.h new file mode 100644 index 0000000..49f2a93 --- /dev/null +++ b/src/tree-widget.h @@ -0,0 +1,18 @@ +#ifndef TREEWIDGET_H +#define TREEWIDGET_H + +#include +#include +#include + +class QSettings; + +class ScoreTreeWidget : public QTreeWidget +{ + Q_OBJECT + +public: + ScoreTreeWidget(QWidget *parent = 0); + QSize sizeHint() const; +}; +#endif diff --git a/src/xml-dom-parser.cpp b/src/xml-dom-parser.cpp new file mode 100644 index 0000000..e0426fa --- /dev/null +++ b/src/xml-dom-parser.cpp @@ -0,0 +1,140 @@ +#include +#include "xml-dom-parser.h" + +ScoreXmlHandler::ScoreXmlHandler(QList &list) : list(list) +{ +} + +int ScoreXmlHandler::parse(QString &fileName) +{ + QFile file(fileName); + + if (!file.open(QFile::ReadOnly)) { + qDebug() << "Unable to open : " << fileName; + return false; + } + else if (!doc.setContent(&file)) { + file.close(); + qDebug() << "Unable set content : " << fileName; + return false; + } + else { + file.close(); + qDebug() << "File ready for XML : " << fileName; + } + + root = doc.documentElement(); // this is for reading + + QDomElement scoreElement = root.firstChildElement("score"); + while (!scoreElement.isNull()) { + Score *score = new Score(scoreElement); + QDomElement holeElement = scoreElement.firstChildElement("hole"); + + while (!holeElement.isNull()) { + Hole *hole = new Hole(holeElement); + score->addHole(hole); + holeElement = holeElement.nextSiblingElement("hole"); + } + list << score; + scoreElement = scoreElement.nextSiblingElement("score"); + } + return true; +} + +int ScoreXmlHandler::save(QString &fileName) +{ + QFile file(fileName); + + root = doc.createElement("data"); + doc.appendChild(root); + + for (int i = 0; i < list.size(); i++) { + Score *score = list.at(i); + root.appendChild(score->toElement(doc)); + } + + if (!file.open(QFile::WriteOnly)) + return false; + + QTextStream ts(&file); + ts << doc.toString(); + file.close(); + + return true; +} + +// ========================================================== +// +// ========================================================== + +ClubXmlHandler::ClubXmlHandler(QList &list) : list(list) +{ +} + +int ClubXmlHandler::parse(QString &fileName) +{ + QFile file(fileName); + + if (!file.open(QFile::ReadOnly)) { + qDebug() << "Unable to open : " << fileName; + return false; + } + else if (!doc.setContent(&file)) { + file.close(); + qDebug() << "Unable set content : " << fileName; + return false; + } + else { + file.close(); + qDebug() << "File ready for XML : " << fileName; + } + + root = doc.documentElement(); // this is for reading + + QDomElement clubElement = root.firstChildElement("club"); + while (!clubElement.isNull()) { + + Club *club = new Club(clubElement); + + QDomElement courseElement = clubElement.firstChildElement("course"); + while (!courseElement.isNull()) { + + Course *course = new Course(courseElement); + club->addCourse(course); + + QDomElement holeElement = courseElement.firstChildElement("hole"); + while (!holeElement.isNull()) { + Hole *hole = new Hole(holeElement); + course->addHole(hole); + + holeElement = holeElement.nextSiblingElement("hole"); + } + courseElement = courseElement.nextSiblingElement("course"); + } + list << club; + clubElement = clubElement.nextSiblingElement("club"); + } + return true; +} + +int ClubXmlHandler::save(QString &fileName) +{ + QFile file(fileName); + + root = doc.createElement("data"); + doc.appendChild(root); + + for (int i = 0; i < list.size(); i++) { + Club *club = list.at(i); + root.appendChild(club->toElement(doc)); + } + + if (!file.open(QFile::WriteOnly)) + return false; + + QTextStream ts(&file); + ts << doc.toString(); + file.close(); + + return true; +} diff --git a/src/xml-dom-parser.h b/src/xml-dom-parser.h new file mode 100644 index 0000000..d6e0bd3 --- /dev/null +++ b/src/xml-dom-parser.h @@ -0,0 +1,33 @@ +#ifndef XML_DOM_PARSER_H +#define XML_DOM_PARSER_H + +#include +#include "data.h" + +class ScoreXmlHandler +{ + public: + ScoreXmlHandler(QList &list); + int parse(QString &fileName); + int save(QString &fileName); + + private: + QDomDocument doc; + QDomElement root; + QList &list; +}; + +class ClubXmlHandler +{ + public: + ClubXmlHandler(QList &list); + int parse(QString &fileName); + int save(QString &fileName); + + private: + QDomDocument doc; + QDomElement root; + QList &list; +}; + +#endif diff --git a/src/xml-parser.cpp b/src/xml-parser.cpp new file mode 100644 index 0000000..f97c9b8 --- /dev/null +++ b/src/xml-parser.cpp @@ -0,0 +1,140 @@ +#include + +#include + +#include "xml-parser.h" +#include "data.h" + +// +// Score +// +ScoreHandler::ScoreHandler(QList &scoreList) : scoreList(scoreList) +{ + score = 0; + hole = 0; +} + +bool ScoreHandler::startDocument() +{ + inScore = false; + return true; +} + +bool ScoreHandler::endDocument() +{ + return true; +} + +bool ScoreHandler::startElement(const QString & /* namespaceURI */, + const QString & /* localName */, + const QString &name, + const QXmlAttributes &attrs) +{ + if (inScore && name == "hole") { + hole = new Hole(attrs); + } + else if (name == "score") { + score = new Score(attrs); + inScore = true; + } + return true; +} + +bool ScoreHandler::endElement(const QString & /* namespaceURI */, + const QString & /* localName */, + const QString &name) +{ + if (name == "score") { + inScore = false; + scoreList << score; + } else if (name == "hole") + score->addHole(hole); + + return true; +} + +bool ScoreHandler::fatalError(const QXmlParseException &exception) +{ + qWarning() << "Fatal error on line" << exception.lineNumber() + << ", column" << exception.columnNumber() << ":" + << exception.message(); + + return false; +} + +QString ScoreHandler::errorString() const +{ + return errorStr; +} + +// +// Club +// +ClubHandler::ClubHandler(QList &clubList) : clubList(clubList) +{ + club = 0; + hole = 0; +} + +bool ClubHandler::startDocument() +{ + inClub = false; + inCourse = false; + return true; +} + +bool ClubHandler::endDocument() +{ + return true; +} + +bool ClubHandler::startElement(const QString & /* namespaceURI */, + const QString & /* localName */, + const QString &name, + const QXmlAttributes &attrs) +{ + if (inCourse && name == "hole") { + hole = new Hole(attrs); + } + else if (name == "course") { + course = new Course(attrs); + inCourse = true; + } + else if (name == "club") { + club = new Club(attrs); + inClub = true; + } + return true; +} + +bool ClubHandler::endElement(const QString & /* namespaceURI */, + const QString & /* localName */, + const QString &name) +{ + if (name == "club") { + inClub = false; + clubList << club; + } + else if (name == "course") { + inCourse = false; + club->addCourse(course); + } + else if (name == "hole") + course->addHole(hole); + + return true; +} + +bool ClubHandler::fatalError(const QXmlParseException &exception) +{ + qWarning() << "Fatal error on line" << exception.lineNumber() + << ", column" << exception.columnNumber() << ":" + << exception.message(); + + return false; +} + +QString ClubHandler::errorString() const +{ + return errorStr; +} diff --git a/src/xml-parser.h b/src/xml-parser.h new file mode 100644 index 0000000..add35a5 --- /dev/null +++ b/src/xml-parser.h @@ -0,0 +1,55 @@ +#ifndef XMLPARSER_H +#define XMLPARSER_H + +#include +#include + +#include "data.h" + +class ScoreHandler : public QXmlDefaultHandler +{ + public: + ScoreHandler(QList &scoreList); + + bool startDocument(); + bool endDocument(); + bool startElement(const QString &namespaceURI, const QString &localName, + const QString &qName, const QXmlAttributes &attributes); + bool endElement(const QString &namespaceURI, const QString &localName, + const QString &qName); + bool fatalError(const QXmlParseException &exception); + QString errorString() const; + + private: + QList &scoreList; + Score *score; + Hole *hole; + QString errorStr; + bool inScore; +}; + +class ClubHandler : public QXmlDefaultHandler +{ + public: + ClubHandler(QList &clubList); + + bool startDocument(); + bool endDocument(); + bool startElement(const QString &namespaceURI, const QString &localName, + const QString &qName, const QXmlAttributes &attributes); + bool endElement(const QString &namespaceURI, const QString &localName, + const QString &qName); + bool fatalError(const QXmlParseException &exception); + QString errorString() const; + + private: + QList &clubList; + Club *club; + Course *course; + Hole *hole; + QString errorStr; + bool inClub; + bool inCourse; +}; + +#endif