2014-08-25 18:46:08 +00:00
|
|
|
#include "statisticswidget.h"
|
2015-05-28 21:12:11 +00:00
|
|
|
#include "yearlystatisticsmodel.h"
|
2014-08-25 19:10:47 +00:00
|
|
|
#include <QModelIndex>
|
2014-08-25 18:46:08 +00:00
|
|
|
|
2015-06-22 13:42:02 +00:00
|
|
|
YearlyStatisticsWidget::YearlyStatisticsWidget(QWidget *parent):
|
|
|
|
QGraphicsView(parent),
|
|
|
|
m_model(NULL)
|
2014-08-25 18:46:08 +00:00
|
|
|
{
|
|
|
|
}
|
2014-08-25 19:10:47 +00:00
|
|
|
|
|
|
|
void YearlyStatisticsWidget::setModel(YearlyStatisticsModel *m)
|
|
|
|
{
|
|
|
|
m_model = m;
|
|
|
|
connect(m, SIGNAL(dataChanged(QModelIndex,QModelIndex)),
|
|
|
|
this, SLOT(modelDataChanged(QModelIndex,QModelIndex)));
|
2014-08-25 19:32:24 +00:00
|
|
|
connect(m, SIGNAL(rowsAboutToBeRemoved(QModelIndex,int,int)),
|
2014-08-25 19:39:11 +00:00
|
|
|
scene(), SLOT(clear()));
|
2014-08-25 19:10:47 +00:00
|
|
|
connect(m, SIGNAL(rowsInserted(QModelIndex,int,int)),
|
|
|
|
this, SLOT(modelRowsInserted(QModelIndex,int,int)));
|
|
|
|
|
|
|
|
modelRowsInserted(QModelIndex(),0,m_model->rowCount()-1);
|
|
|
|
}
|
|
|
|
|
|
|
|
void YearlyStatisticsWidget::modelRowsInserted(const QModelIndex &index, int first, int last)
|
|
|
|
{
|
|
|
|
// stub
|
|
|
|
}
|
|
|
|
|
|
|
|
void YearlyStatisticsWidget::modelDataChanged(const QModelIndex &topLeft, const QModelIndex& bottomRight)
|
|
|
|
{
|
2014-08-25 19:55:26 +00:00
|
|
|
Q_UNUSED(topLeft);
|
|
|
|
Q_UNUSED(bottomRight);
|
|
|
|
scene()->clear();
|
|
|
|
modelRowsInserted(QModelIndex(),0,m_model->rowCount()-1);
|
2014-08-25 19:10:47 +00:00
|
|
|
}
|
2014-08-25 19:31:05 +00:00
|
|
|
|
|
|
|
void YearlyStatisticsWidget::resizeEvent(QResizeEvent *event)
|
|
|
|
{
|
|
|
|
QGraphicsView::resizeEvent(event);
|
|
|
|
fitInView(sceneRect(), Qt::IgnoreAspectRatio);
|
|
|
|
}
|