Handle score coloring correctly in back nine
authorSakari Poussa <sakari.poussa@nokia.com>
Sun, 25 Oct 2009 21:28:06 +0000 (23:28 +0200)
committerSakari Poussa <sakari.poussa@nokia.com>
Sun, 25 Oct 2009 21:28:06 +0000 (23:28 +0200)
src/table-model.cpp

index fe8749a..0064e8b 100644 (file)
@@ -6,10 +6,7 @@
 
 Qt::ItemFlags ScoreTableModel::flags ( const QModelIndex & index )
 {
-  Qt::ItemFlags flags = QAbstractItemModel::flags(index);
-  qDebug() << "flags " << currentMode;
-  
-  return flags;
+  return 0;
 }
 
 void ScoreTableModel::setMode(int m)
@@ -221,9 +218,6 @@ QVariant ScoreTableModel::data(const QModelIndex &index, int role) const
     }
   }
   if (role == Qt::BackgroundRole) {
-    int par = course->getPar(col).toInt();
-    int shots = score->getScore(col).toInt();
-
     // Hole numbers 1-18
     if (row == ROW_HOLE || row == ROW_HOLE_2) {
        QBrush brush(colorHoleBg);
@@ -231,6 +225,17 @@ QVariant ScoreTableModel::data(const QModelIndex &index, int role) const
     }
 
     if (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 == 10 && row == ROW_SCORE_2) {
        // Total score
        QBrush brush(colorTotal);