2 * Copyright (C) 2009 Sakari Poussa
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation, version 2.
12 #include "list-model.h"
13 #include "score-common.h"
15 void ScoreListModel::update(QList<Score *> &list)
21 int ScoreListModel::rowCount(const QModelIndex &) const
23 return scoreList.count();
26 QVariant ScoreListModel::data(const QModelIndex &index, int role) const
31 int row = index.row();
33 Score * score = scoreList.at(row);
34 //Course * course = findCourse(score->getClubName(), score->getCourseName());
40 if (role == Qt::TextAlignmentRole ) {
41 return Qt::AlignCenter;
44 if (index.column() > 10)
50 if (role == Qt::DisplayRole) {
51 int n = score->getTotal(Total).toInt();
52 QString s = QString("%1, %2").arg(score->getClubName()).arg(score->getCourseName());
67 QString str = QString("%1 %2 %3\n%4").arg(s, -40).arg(tabs).arg(n).arg(score->getDate());
73 CourseListModel::CourseListModel(QList<Club *> &list, QObject *parent) : QAbstractListModel(parent), clubList(list)
78 int CourseListModel::rowCount(const QModelIndex &) const
80 return clubAndCourseList.count();
83 QVariant CourseListModel::data(const QModelIndex &index, int role) const
88 int row = index.row();
90 if (role == Qt::DisplayRole) {
91 QString *s = clubAndCourseList.at(row);
98 void CourseListModel::updateList()
100 QListIterator<Club *> i(clubList);
102 while (!clubAndCourseList.isEmpty())
103 delete clubAndCourseList.takeFirst();
105 while (i.hasNext()) {
106 Club *club = i.next();
107 QList<Course *> courseList = club->getCourseList();
109 QListIterator<Course *> j(courseList);
110 while (j.hasNext()) {
111 Course *course = j.next();
112 QString *str = new QString(club->getName() + ", " + course->getName());
113 clubAndCourseList << str;
118 void CourseListModel::update(QList<Club *> &list)