From d24f813f3f2a05c112e803e4256b53535895fc98 Mon Sep 17 00:00:00 2001 From: Jedidiah Barber Date: Wed, 14 Jul 2021 11:49:10 +1200 Subject: Initial mirror commit --- tests/fute/timeCharts/timeCharts_test.cpp | 58 +++++++++++++++++++++++++++++++ 1 file changed, 58 insertions(+) create mode 100644 tests/fute/timeCharts/timeCharts_test.cpp (limited to 'tests/fute/timeCharts/timeCharts_test.cpp') diff --git a/tests/fute/timeCharts/timeCharts_test.cpp b/tests/fute/timeCharts/timeCharts_test.cpp new file mode 100644 index 0000000..53f0921 --- /dev/null +++ b/tests/fute/timeCharts/timeCharts_test.cpp @@ -0,0 +1,58 @@ +#include "../../../src/charts/TimeChart.h" + +#include +#include +#include "timeCharts_test.h" + +TimeChartsTest::TimeChartsTest() +{ + srand(time(NULL)); + createUi(); + changeDataSet(); +} + +void TimeChartsTest::changeDataSet() +{ + int daysNum = periodBox->value(); + yValuesStr = "Values: "; + dates.clear(); + for (int i = 0; i < daysNum; i++) + addDataPoint(i); + chart->setDates(dates, daysNum, 1); + valuesLabel->setText(yValuesStr); +} + +void TimeChartsTest::addDataPoint(int index) +{ + QDateTime date = QDateTime::currentDateTime().addDays(index); + int dayCardsNum = rand() % 50; + for(int i = 0; i < dayCardsNum; i++) + dates << date; + yValuesStr += QString::number(dayCardsNum) + ", "; +} + +void TimeChartsTest::createUi() +{ + QPushButton* newBtn = new QPushButton(tr("New chart")); + connect(newBtn, SIGNAL(clicked()), SLOT(changeDataSet())); + + valuesLabel = new QLabel; + valuesLabel->setMaximumWidth(750); + + periodBox = new QSpinBox; + periodBox->setRange(7, 5000); + + chart = new TimeChart; + chart->setLabels(tr("Date"), tr("Cards")); + + QHBoxLayout* controlLt = new QHBoxLayout; + controlLt->addWidget(periodBox); + controlLt->addWidget(newBtn); + + QVBoxLayout* mainLt = new QVBoxLayout; + mainLt->addLayout(controlLt); + mainLt->addWidget(valuesLabel); + mainLt->addWidget(chart); + setLayout(mainLt); + resize(800, 500); +} -- cgit