| 
									
										
										
										
											2016-04-04 22:02:03 -07:00
										 |  |  | #include "desktop-widgets/statistics/statisticswidget.h"
 | 
					
						
							|  |  |  | #include "qt-models/yearlystatisticsmodel.h"
 | 
					
						
							| 
									
										
										
										
											2014-08-25 16:10:47 -03:00
										 |  |  | #include <QModelIndex>
 | 
					
						
							| 
									
										
										
										
											2014-08-25 15:46:08 -03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-06-22 06:42:02 -07:00
										 |  |  | YearlyStatisticsWidget::YearlyStatisticsWidget(QWidget *parent): | 
					
						
							|  |  |  | 	QGraphicsView(parent), | 
					
						
							|  |  |  | 	m_model(NULL) | 
					
						
							| 
									
										
										
										
											2014-08-25 15:46:08 -03:00
										 |  |  | { | 
					
						
							|  |  |  | } | 
					
						
							| 
									
										
										
										
											2014-08-25 16:10:47 -03:00
										 |  |  | 
 | 
					
						
							|  |  |  | void YearlyStatisticsWidget::setModel(YearlyStatisticsModel *m) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	m_model = m; | 
					
						
							|  |  |  | 	connect(m, SIGNAL(dataChanged(QModelIndex,QModelIndex)), | 
					
						
							|  |  |  | 			this, SLOT(modelDataChanged(QModelIndex,QModelIndex))); | 
					
						
							| 
									
										
										
										
											2014-08-25 16:32:24 -03:00
										 |  |  | 	connect(m, SIGNAL(rowsAboutToBeRemoved(QModelIndex,int,int)), | 
					
						
							| 
									
										
										
										
											2014-08-25 16:39:11 -03:00
										 |  |  | 			scene(), SLOT(clear())); | 
					
						
							| 
									
										
										
										
											2014-08-25 16:10:47 -03: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) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2016-03-09 20:10:42 -08:00
										 |  |  | 	Q_UNUSED(index) | 
					
						
							|  |  |  | 	Q_UNUSED(first) | 
					
						
							|  |  |  | 	Q_UNUSED(last) | 
					
						
							| 
									
										
										
										
											2014-08-25 16:10:47 -03:00
										 |  |  | 	// stub
 | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void YearlyStatisticsWidget::modelDataChanged(const QModelIndex &topLeft, const QModelIndex& bottomRight) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2014-08-25 16:55:26 -03:00
										 |  |  | 	Q_UNUSED(topLeft); | 
					
						
							|  |  |  | 	Q_UNUSED(bottomRight); | 
					
						
							|  |  |  | 	scene()->clear(); | 
					
						
							|  |  |  | 	modelRowsInserted(QModelIndex(),0,m_model->rowCount()-1); | 
					
						
							| 
									
										
										
										
											2014-08-25 16:10:47 -03:00
										 |  |  | } | 
					
						
							| 
									
										
										
										
											2014-08-25 16:31:05 -03:00
										 |  |  | 
 | 
					
						
							|  |  |  | void YearlyStatisticsWidget::resizeEvent(QResizeEvent *event) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	QGraphicsView::resizeEvent(event); | 
					
						
							|  |  |  | 	fitInView(sceneRect(), Qt::IgnoreAspectRatio); | 
					
						
							|  |  |  | } |