Sort scores based on dates not the entry date.
[scorecard] / src / table-model.cpp
index 98bbf18..8a10cfa 100644 (file)
@@ -8,11 +8,19 @@ Qt::ItemFlags ScoreTableModel::flags ( const QModelIndex & index )
   return Qt::NoItemFlags;
 }
 
-void ScoreTableModel::setScore(QList<Score *> &sList)
+// Assign the 'sList' to internal 'scoreList'. Set the current score
+// to 'currentScore', or to 's'.
+void ScoreTableModel::setScore(QList<Score *> &sList, Score *s)
 {
   scoreList = sList;
-  if (scoreList.size() > 0)
+  if (scoreList.size() > 0) {
+    if (s) {
+      currentScore = scoreList.indexOf(s);
+      if (currentScore == -1)
+       currentScore = 0;
+    }
     score = scoreList.at(currentScore); // NOTE: assumes non-empty list
+  }
 }
 
 void ScoreTableModel::setClub(QList<Club *> &cList)
@@ -42,7 +50,8 @@ QString ScoreTableModel::getCountText()
   return str;
 }
 
-Course *ScoreTableModel::findCourse(QString &clubName, QString &courseName)
+Course *ScoreTableModel::findCourse(const QString &clubName, 
+                                   const QString &courseName)
 {
   QListIterator<Club *> i(clubList);
   Club *c;