+bool dateMoreThan(const Score *s1, const Score *s2)
+{
+ return (*s1) > (*s2);
+}
+// Find score based on club and course name
+Score *MainWindow::findScore(QString & clubName, QString & courseName)
+{
+ TRACE;
+ QListIterator<Score *> i(scoreList);
+ Score * s;
+
+ while (i.hasNext()) {
+ s = i.next();
+ if ((s->getClubName() == clubName) &&
+ (s->getCourseName() == courseName))
+ return s;
+ }
+ return 0;
+}
+
+// Find club based on name
+Club *MainWindow::findClub(QString &name)
+{
+ TRACE;
+ QListIterator<Club *> i(clubList);
+ Club *c;
+
+ while (i.hasNext()) {
+ c = i.next();
+ if (c->getName() == name)
+ return c;
+ }
+ return 0;
+}
+
+// Find course based on club & course name
+Course *MainWindow::findCourse(const QString &clubName,
+ const QString &courseName)
+{
+ TRACE;
+ QListIterator<Club *> i(clubList);
+ Club *c;
+
+ while (i.hasNext()) {
+ c = i.next();
+ if (c->getName() == clubName) {
+ return c->getCourse(courseName);
+ }
+ }
+ return 0;
+}
+
+// Find course based on current selection on the list
+// TODO: make sure this is only called when course list is the model...
+Course *MainWindow::currentCourse()
+{
+ TRACE;
+ QModelIndex index = selectionModel->currentIndex();
+
+ if (!index.isValid())
+ return 0;
+
+ const QAbstractItemModel *model = selectionModel->model();
+ QString str = model->data(index, Qt::DisplayRole).toString();
+
+ QStringList strList = str.split(", ");
+ if (strList.count() != 2) {
+ showNote(tr("Invalid course selection"));
+ return 0;
+ }
+ return findCourse(strList[0], strList[1]);
+}
+
+// Find score based on current selection on the list
+// TODO: make sure this is only called when score list is the model...
+Score *MainWindow::currentScore()
+{
+ TRACE;
+ QModelIndex index = selectionModel->currentIndex();
+
+ if (!index.isValid())
+ return 0;
+
+ return scoreList.at(index.row());
+}
+
+void MainWindow::flushReadOnlyItems()
+{
+ TRACE;
+ QMutableListIterator<Club *> i(clubList);
+ Club *c;
+
+ while (i.hasNext()) {
+ c = i.next();
+ if (c->isReadOnly()) {
+ qDebug() << "Del:" << c->getName();
+ i.remove();
+ }
+ }
+}
+
+void MainWindow::markHomeClub()
+{
+ TRACE;
+ QListIterator<Club *> i(clubList);
+ Club *c;
+
+ while (i.hasNext()) {
+ c = i.next();
+ if (c->getName() == conf.homeClub)
+ c->setHomeClub(true);
+ else
+ c->setHomeClub(false);
+ }
+}
+