2017-04-27 18:26:05 +00:00
|
|
|
// SPDX-License-Identifier: GPL-2.0
|
2016-04-05 05:02:03 +00:00
|
|
|
#include "desktop-widgets/statistics/statisticswidget.h"
|
|
|
|
#include "qt-models/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);
|
|
|
|
}
|
|
|
|
|
2018-05-21 16:12:27 +00:00
|
|
|
void YearlyStatisticsWidget::modelRowsInserted(const QModelIndex&, int, int)
|
2014-08-25 19:10:47 +00:00
|
|
|
{
|
|
|
|
// stub
|
|
|
|
}
|
|
|
|
|
2018-05-21 16:12:27 +00:00
|
|
|
void YearlyStatisticsWidget::modelDataChanged(const QModelIndex&, const QModelIndex&)
|
2014-08-25 19:10:47 +00:00
|
|
|
{
|
2014-08-25 19:55:26 +00:00
|
|
|
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);
|
|
|
|
}
|