X-Git-Url: http://git.maemo.org/git/?p=buliscores;a=blobdiff_plain;f=src%2Fmatchdaymodel.cpp;h=89f24d34dafb7eee0e61d175aeba87629a4eddfd;hp=970dec4efac8de0471ff42ccc7f2ef9db7c3ed38;hb=90ece8a023da4535eb0c2830e3dcab1bfb93b881;hpb=d2c6b23ece54ac512726cff8c7819cff17d568fc diff --git a/src/matchdaymodel.cpp b/src/matchdaymodel.cpp index 970dec4..89f24d3 100644 --- a/src/matchdaymodel.cpp +++ b/src/matchdaymodel.cpp @@ -1,29 +1,32 @@ -#include "matchdaymodel.h" #include #include #include #include +#include + +#include "matchdaymodel.h" +#include "match.h" MatchDayModel::MatchDayModel(QObject *parent) : QAbstractTableModel(parent) { - backendkicker = new BackendKicker(this); + m_backend = new BackendKicker(this); - connect(backendkicker, SIGNAL(matchListChanged()), + connect(m_backend, SIGNAL(matchListChanged()), this, SLOT(onMatchListChanged())); } -int MatchDayModel::rowCount(const QModelIndex& index) const +int MatchDayModel::rowCount(const QModelIndex&) const { - int count = backendkicker->matchList().count(); + int count = m_backend->matchList().count(); return count; } -int MatchDayModel::columnCount(const QModelIndex& index) const +int MatchDayModel::columnCount(const QModelIndex&) const { - return 7; + return 8; } QVariant MatchDayModel::data(const QModelIndex& index, int role) const @@ -35,7 +38,7 @@ QVariant MatchDayModel::data(const QModelIndex& index, int role) const f.setPixelSize(14); - if ((match = backendkicker->matchList().at(index.row())) == NULL) { + if ((match = m_backend->matchList().at(index.row())) == NULL) { return QVariant(QVariant::Invalid); } @@ -49,6 +52,9 @@ QVariant MatchDayModel::data(const QModelIndex& index, int role) const case HomeIcon: i = match->homeEmblem().pixmap(25,25); break; + case Seperator: + i = QIcon(":/Icons/Application/football.png").pixmap(20,20); + break; } return i; break; @@ -59,19 +65,30 @@ QVariant MatchDayModel::data(const QModelIndex& index, int role) const return match->awayEmblem(); break; case AwayTeam: - return match->awayteam(); + return match->awayTeam(); break; case AwayScore: - return match->awayscore(); + if (match->state() == Match::NotStarted) { + return "-"; + } else { + return match->awayScore(); + } break; case HomeIcon: return match->homeEmblem(); break; case HomeTeam: - return match->hometeam(); + return match->homeTeam(); break; case HomeScore: - return match->homescore(); + if (match->state() == Match::NotStarted) { + return "-"; + } else { + return match->homeScore(); + } + break; + case Date: + return match->date().toString("ddd hh mm"); break; default: return QVariant(QVariant::Invalid); @@ -103,6 +120,9 @@ QVariant MatchDayModel::data(const QModelIndex& index, int role) const case Seperator: s.setWidth(3); break; + case Date: + s.setWidth(110); + break; default: return QVariant(QVariant::Invalid); break; @@ -131,6 +151,8 @@ QVariant MatchDayModel::data(const QModelIndex& index, int role) const default: return QVariant(QVariant::Invalid); } + + return QVariant(QVariant::Invalid); } @@ -147,3 +169,11 @@ void MatchDayModel::onMatchListChanged(void) index(rowCount(QModelIndex()) - 1, columnCount(QModelIndex()) - 1)); } + +void MatchDayModel::update(void) +{ + QSettings settings("David Solbach", "BuliScores"); + + this->m_backend->setLeague(settings.value("League", "1. Bundesliga").toString()); + this->m_backend->update(); +}