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/charts/charts.pro | 35 ++++++++++++++++++++++++++ tests/fute/charts/charts_test.cpp | 52 +++++++++++++++++++++++++++++++++++++++ tests/fute/charts/charts_test.h | 31 +++++++++++++++++++++++ tests/fute/charts/main.cpp | 12 +++++++++ 4 files changed, 130 insertions(+) create mode 100644 tests/fute/charts/charts.pro create mode 100644 tests/fute/charts/charts_test.cpp create mode 100644 tests/fute/charts/charts_test.h create mode 100644 tests/fute/charts/main.cpp (limited to 'tests/fute/charts') diff --git a/tests/fute/charts/charts.pro b/tests/fute/charts/charts.pro new file mode 100644 index 0000000..613fee8 --- /dev/null +++ b/tests/fute/charts/charts.pro @@ -0,0 +1,35 @@ +TEMPLATE = app +QT += widgets +TARGET = charts_test +DEPENDPATH += . +INCLUDEPATH += . +QMAKE_CXXFLAGS += -std=gnu++11 +DESTDIR = ./ + +win32: { + CONFIG += console + } + +HEADERS = \ + charts_test.h \ + ../../../src/charts/Chart.h \ + ../../../src/charts/TimeChart.h \ + ../../../src/charts/DataPoint.h \ + ../../../src/charts/ChartScene.h \ + ../../../src/charts/ChartView.h \ + ../../../src/charts/ChartAxes.h \ + ../../../src/charts/ChartDataLine.h \ + ../../../src/charts/ChartMarker.h \ + ../../../src/charts/ChartToolTip.h + +SOURCES = \ + main.cpp \ + charts_test.cpp \ + ../../../src/charts/Chart.cpp \ + ../../../src/charts/TimeChart.cpp \ + ../../../src/charts/ChartScene.cpp \ + ../../../src/charts/ChartView.cpp \ + ../../../src/charts/ChartAxes.cpp \ + ../../../src/charts/ChartDataLine.cpp \ + ../../../src/charts/ChartMarker.cpp \ + ../../../src/charts/ChartToolTip.cpp diff --git a/tests/fute/charts/charts_test.cpp b/tests/fute/charts/charts_test.cpp new file mode 100644 index 0000000..0870027 --- /dev/null +++ b/tests/fute/charts/charts_test.cpp @@ -0,0 +1,52 @@ +#include "charts_test.h" +#include "../../../src/charts/Chart.h" + +#include +#include + +ChartsTest::ChartsTest() +{ + srand(time(NULL)); + createUi(); + changeDataSet(); +} + +void ChartsTest::changeDataSet() +{ + const int daysNum = 7; + yValuesStr = "Values: "; + dataSet.clear(); + for (int i = 0; i < daysNum; i++) + addDataPoint(i); + chart->setDataSet(dataSet); + valuesLabel->setText(yValuesStr); +} + +void ChartsTest::addDataPoint(int index) +{ + const int firstDay = 15; + QString xLabel = QString::number(firstDay + index) + ".11"; + int yValue = rand() % 70; + dataSet << DataPoint(xLabel, yValue, xLabel); + yValuesStr += QString::number(yValue) + ", "; +} + +void ChartsTest::createUi() +{ + QPushButton* newBtn = new QPushButton(tr("New chart")); + connect(newBtn, SIGNAL(clicked()), SLOT(changeDataSet())); + + valuesLabel = new QLabel; + chart = new Chart; + chart->setLabels("Date", "Value"); + + QHBoxLayout* controlLt = new QHBoxLayout; + controlLt->addWidget(valuesLabel); + controlLt->addWidget(newBtn); + + QVBoxLayout* mainLt = new QVBoxLayout; + mainLt->addLayout(controlLt); + mainLt->addWidget(chart); + setLayout(mainLt); + resize(800, 500); +} diff --git a/tests/fute/charts/charts_test.h b/tests/fute/charts/charts_test.h new file mode 100644 index 0000000..3975444 --- /dev/null +++ b/tests/fute/charts/charts_test.h @@ -0,0 +1,31 @@ +#ifndef CHARTS_TEST_H +#define CHARTS_TEST_H + +#include +#include + +#include "../../../src/charts/DataPoint.h" + +class Chart; + +class ChartsTest: public QWidget +{ + Q_OBJECT +public: + ChartsTest(); + +private: + void createUi(); + void addDataPoint(int index); + +private slots: + void changeDataSet(); + +private: + QString yValuesStr; + Chart* chart; + QList dataSet; + QLabel* valuesLabel; +}; + +#endif diff --git a/tests/fute/charts/main.cpp b/tests/fute/charts/main.cpp new file mode 100644 index 0000000..346133d --- /dev/null +++ b/tests/fute/charts/main.cpp @@ -0,0 +1,12 @@ +#include + +#include "charts_test.h" + +int main(int argc, char *argv[]) +{ + QApplication app(argc, argv); + ChartsTest mainWin; + mainWin.show(); + return app.exec(); +} + -- cgit