New version (0.11) - statistics addded
[scorecard] / src / table-model.h
index 89c0ab1..0c1c60b 100644 (file)
@@ -1,3 +1,11 @@
+/*
+ * Copyright (C) 2009 Sakari Poussa
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, version 2.
+ */
+
 #include <QStringList>
 #include <QAbstractTableModel>
 
@@ -13,15 +21,28 @@ class ScoreTableModel : public QAbstractTableModel
   Q_OBJECT
 
 public:
+  enum { ViewMode = 0, EditMode = 1 };
 
   ScoreTableModel(QObject *parent = 0) : QAbstractTableModel(parent) 
   {
     currentScore = 0;
+    score = 0;
+    club = 0;
+    course = 0;
+    currentMode = ViewMode;
   }
   Qt::ItemFlags flags ( const QModelIndex & index );
-  void setScore(QList<Score *> &sList);
+  void setMode(int m);
+  int mode(void);
+  void setScore(QList<Score *> &sList, Score *score = 0);
+  Score *getScore(void);
   void setClub(QList<Club *> &cList);
-  Course *findCourse(QString &clubName, QString &courseName);
+  Club *getClub(void);
+  Course *getCourse(void);
+
+  Course *findCourse(const QString &clubName, const QString &courseName);
+  QString& clubName(void);
+  QString& courseName(void);
   int rowCount(const QModelIndex & parent) const;
   int columnCount(const QModelIndex & parent) const;
   QModelIndex index(int row, int column, const QModelIndex &parent = QModelIndex()) const;
@@ -39,6 +60,11 @@ public:
   void last();
 
  private:
+  int currentMode;
+  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};
+
   QList<Score *> scoreList;
   QList<Club *> clubList;