diff options
author | Jedidiah Barber <contact@jedbarber.id.au> | 2021-07-14 11:49:10 +1200 |
---|---|---|
committer | Jedidiah Barber <contact@jedbarber.id.au> | 2021-07-14 11:49:10 +1200 |
commit | d24f813f3f2a05c112e803e4256b53535895fc98 (patch) | |
tree | 601e6ae9a1cd44bcfdcf91739a5ca36aedd827c9 /tests/fute/timeCharts/timeCharts_test.cpp |
Diffstat (limited to 'tests/fute/timeCharts/timeCharts_test.cpp')
-rw-r--r-- | tests/fute/timeCharts/timeCharts_test.cpp | 58 |
1 files changed, 58 insertions, 0 deletions
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 <cstdlib> +#include <time.h> +#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); +} |