Commit 9f487f25bc32d7eb8919532fa42027ea599b6f66

  • Tree SHA1: e9265ad
  • Parent SHA1: 5ab2383 (Created ExpensesGraphModel class to act as the ExpensesGraphModel. SummaryData and MonthData are children of ExpensesGraphModel. Added an evolution graph to the summary option)
  • raw diff | raw patch
Added ExpensesGraphModel files (should habe gone in last commit). Added a new method to get from the model the labels for the X axis of the graph
  
162162 X_LABEL_WIDTH,
163163 X_LABEL_HEIGHT,
164164 Qt::AlignCenter,
165 QString("1"));
165 QString("%1").arg(_model->label(0)));
166166 painter.setPen(pen);
167167 x = xStart + (xStep *xStepsPerLabel);
168168 for (i = xStepsPerLabel + 1; i<=_model->xDivisions(); i+=xStepsPerLabel) {
175175 X_LABEL_WIDTH,
176176 X_LABEL_HEIGHT,
177177 Qt::AlignCenter,
178 QString("%1").arg(i));
178 QString("%1").arg(_model->label(i-1)));
179179 painter.setPen(pen);
180180 x += xStep * xStepsPerLabel;
181181 }
  
1#include "expensesgraphmodel.h"
2
3ExpensesGraphModel::ExpensesGraphModel(QObject *parent)
4 : QObject(parent)
5{
6}
  
1#ifndef EXPENSESGRAPHMODEL_H
2#define EXPENSESGRAPHMODEL_H
3
4#include <QObject>
5
6class ExpensesGraphModel : public QObject
7{
8 Q_OBJECT
9 public:
10 ExpensesGraphModel(QObject *parent = 0);
11
12 virtual double budget() = 0;
13 virtual double totalExpense() = 0;
14 virtual double maxExpense() = 0;
15 virtual bool isCurrent() = 0;
16 virtual int xDivisions() = 0;
17 virtual double value(int i) = 0;
18 virtual int label(int i) = 0;
19
20 signals:
21 void expensesChanged();
22 void budgetChanged();
23
24 private:
25};
26
27#endif
  
143143{
144144 return _date.daysInMonth();
145145}
146
147int MonthData::label(int index)
148{
149 return index + 1;
150}
  
3838 QDate date();
3939 void clear();
4040 int xDivisions();
41 int label(int i);
4142
4243 signals:
4344
  
150150{
151151 return _values.value(index);
152152}
153
154int SummaryData::label(int index)
155{
156 return (index + _startMonth) % 12;
157}
  
4040 bool isCurrent();
4141 int xDivisions();
4242 double value(int i);
43 int label(int i);
4344
4445 const QList<Concept*>& concepts();
4546
  
7979 chart = new ConceptsChart();
8080 vbox->addWidget(chart, 1);
8181
82 viewLabel = new QLabel(tr("Monthly accumulated view"));
83 vbox->addWidget(viewLabel, 0, Qt::AlignCenter);
8284 graph = new ExpensesGraph();
8385 vbox->addWidget(graph, 1);
8486
8888 statistics->setChecked(true);
8989 chart->hide();
9090 graph->hide();
91 viewLabel->hide();
9192}
9293
9394SummaryWindow::~SummaryWindow()
103103 statsBox->show();
104104 chart->hide();
105105 graph->hide();
106 viewLabel->hide();
106107}
107108
108109void SummaryWindow::itemsSelected()
111111 statsBox->hide();
112112 chart->show();
113113 graph->hide();
114 viewLabel->hide();
114115}
115116
116117void SummaryWindow::evolutionSelected()
119119 statsBox->hide();
120120 chart->hide();
121121 graph->show();
122 viewLabel->show();
122123}
123124
124125void SummaryWindow::setSummaryData(SummaryData *data)
175175{
176176 if (graph->isVisible()) {
177177 graph->changeView();
178 if (graph->accumulated()) {
179 viewLabel->setText(tr("Monthly accumulated view"));
180 } else {
181 viewLabel->setText(tr("Month expenses view"));
182 }
178183 }
179184}
  
4949
5050 /* items stuff */
5151 ConceptsChart *chart;
52
53 QLabel *viewLabel;
5254 ExpensesGraph *graph;
5355
5456 SummaryData *summaryData;