- //
- // COLORS
- //
- if (role == Qt::ForegroundRole) {
- // Hole numbers 1-18. All hole nums, in, out and tot cell but not
- // the empty cell.
- if ((row == ROW_HOLE && col != 10) || row == ROW_HOLE_2) {
- QBrush brush(ScoreColor::holeBg());
- return brush;
+ //
+ // COLORS
+ //
+ if (role == Qt::ForegroundRole) {
+ // Hole numbers 1-18. All hole nums, in, out and tot cell but not
+ // the empty cell.
+ if ((row == ROW_HOLE && col != 10) || row == ROW_HOLE_2) {
+ QBrush brush(ScoreColor::holeBg());
+ return brush;
+ }
+ if (score && course && (row == ROW_SCORE || row == ROW_SCORE_2)) {
+ int par;
+ int shots;
+ if (row == ROW_SCORE) {
+ par = course->getPar(col).toInt();
+ shots = score->getScore(col).toInt();
+ }
+ else {
+ par = course->getPar(col + 9).toInt();
+ shots = score->getScore(col + 9).toInt();
+ }
+
+ if (col == (COLS+1) && row == ROW_SCORE_2) {
+ // Total score
+ QBrush brush(ScoreColor::total());
+ return brush;
+ }
+ if (col == COLS) {
+ // In and Out scores
+ QBrush brush(ScoreColor::subTotal());
+ return brush;
+ }
+ if (col < COLS) {
+ if (shots == par) {
+ // Par
+ QBrush brush(ScoreColor::par());
+ return brush;
+ }
+ if (shots == (par-1)) {
+ // Birdie
+ QBrush brush(ScoreColor::birdie());
+ return brush;
+ }
+ if (shots == (par+1)) {
+ // Bogey
+ QBrush brush(ScoreColor::bogey());
+ return brush;
+ }
+ if (shots == (par+2)) {
+ // Double Bogey
+ QBrush brush(ScoreColor::doubleBogey());
+ return brush;
+ }
+ if (shots > (par+2)) {
+ // Very bad
+ QBrush brush(ScoreColor::bad());
+ return brush;
+ }
+ }
+ }
+ return QVariant();