+#include <QDebug>
#include <QColor>
#include <QFontMetrics>
#include <QFont>
#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()),
s.setWidth(3);
break;
case Date:
- s.setWidth(110);
+ s.setWidth(75);
break;
default:
return QVariant(QVariant::Invalid);
// 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));
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();
}