X-Git-Url: https://vcs.maemo.org/git/?a=blobdiff_plain;f=src%2Fmatchdaymodel.cpp;h=c28027175355700b1e6357ce1cebd53e7a6904df;hb=d84515b43219808f126257d51c182d6e4f4920c8;hp=89f24d34dafb7eee0e61d175aeba87629a4eddfd;hpb=550599e15c77ef3fccb1d6a02e871d6dd4ff03b3;p=buliscores diff --git a/src/matchdaymodel.cpp b/src/matchdaymodel.cpp index 89f24d3..c280271 100644 --- a/src/matchdaymodel.cpp +++ b/src/matchdaymodel.cpp @@ -1,3 +1,4 @@ +#include #include #include #include @@ -8,8 +9,11 @@ #include "match.h" MatchDayModel::MatchDayModel(QObject *parent) : - QAbstractTableModel(parent) + QAbstractTableModel(parent), + m_lastRowCount(0), + m_settings("David Solbach", "BuliScores") { + m_backend = new BackendKicker(this); connect(m_backend, SIGNAL(matchListChanged()), @@ -121,7 +125,7 @@ QVariant MatchDayModel::data(const QModelIndex& index, int role) const s.setWidth(3); break; case Date: - s.setWidth(110); + s.setWidth(75); break; default: return QVariant(QVariant::Invalid); @@ -159,12 +163,25 @@ QVariant MatchDayModel::data(const QModelIndex& index, int role) const // only adds for now void MatchDayModel::onMatchListChanged(void) { + //remove all rows + qDebug() << "beginRemoveRows: " << 0 << ", " << rowCount(QModelIndex()) - 1; + beginRemoveRows(QModelIndex(), + 0, + m_lastRowCount); + endRemoveRows(); + + //add rows + qDebug() << "beginInsertRows: " << 0 << ", " << m_backend->matchList().count() - 1; beginInsertRows(QModelIndex(), - rowCount(QModelIndex()), - rowCount(QModelIndex())); + 0, + m_backend->matchList().count() - 1); endInsertRows(); + m_lastRowCount = m_backend->matchList().count() - 1; + // invalidate complete data + + qDebug() << "rowCount @ emit dataChanged: " << rowCount(QModelIndex()); emit dataChanged(index(0, 0), index(rowCount(QModelIndex()) - 1, columnCount(QModelIndex()) - 1)); @@ -172,8 +189,6 @@ void MatchDayModel::onMatchListChanged(void) void MatchDayModel::update(void) { - QSettings settings("David Solbach", "BuliScores"); - - this->m_backend->setLeague(settings.value("League", "1. Bundesliga").toString()); + this->m_backend->setLeague(m_settings.value("League", "1. Bundesliga").toString()); this->m_backend->update(); }