QString logFile("/tmp/scorecard.log");
QString titleScores("ScoreCard - Scores");
QString titleCourses("ScoreCard - Courses");
-QString settingsGroup("Settings");
-QString settingsHcp("hcp");
-QString settingsHomeClub("home-club");
-QString settingsDefaultCourses("default-courses");
bool dateLessThan(const Score *s1, const Score *s2)
{
#include <QColor>
+static QString settingsGroup("Settings");
+static QString settingsHcp("hcp");
+static QString settingsHomeClub("home-club");
+static QString settingsDefaultCourses("default-courses");
+
#ifndef WANT_DEBUG
#define TRACE
#else
static QColor doubleBogey() { return Qt::red; }
static QColor bad() { return Qt::red; }
static QColor subTotal() { return Qt::white; }
- static QColor total() { return Qt::white; }
+ static QColor total() { return Qt::magenta; }
};
static QString statStyleSheet("QTableView {color : white;}");
{
score = 0;
course = 0;
+ handicap = -1;
}
-void ScoreTableModel::set(Score * s, Course * c)
+void ScoreTableModel::set(Score * s, Course * c, int h)
{
score = s;
course = c;
+ handicap = h;
}
int ScoreTableModel::rowCount(const QModelIndex &) const
return course->getTotal(Total);
if (score && row == ROW_SCORE_2)
return score->getTotal(Total);
+ // calculate net score
+ if (score && course && row == ROW_HCP_2) {
+ int scoreTotal = score->getTotal(Total).toInt();
+ int courseTotal = course->getTotal(Total).toInt();
+ int n = scoreTotal - courseTotal;
+ return QString("+%1").arg(n);
+ }
}
else {
// data cells
public:
ScoreTableModel(QObject *parent = 0);
- void set(Score *, Course *);
+ void set(Score *, Course *, int handicap = -1);
int rowCount(const QModelIndex & parent) const;
int columnCount(const QModelIndex & parent) const;
QVariant data(const QModelIndex & index, int role) const;
Score *score;
Club *club;
Course *course;
+
+ // Current handicap
+ int handicap;
};
class CourseTableModel : public QAbstractTableModel