From 3024028485068b4a27d1adf85a9fc36662b3ca18 Mon Sep 17 00:00:00 2001 From: Marek Rosa Date: Mon, 10 Dec 2012 12:46:13 +0200 Subject: Presenterchart moved to tests --- examples/examples.pro | 1 - examples/presenterchart/chartview.cpp | 100 ----------------------------- examples/presenterchart/chartview.h | 49 -------------- examples/presenterchart/main.cpp | 37 ----------- examples/presenterchart/presenterchart.pro | 6 -- tests/presenterchart/chartview.cpp | 100 +++++++++++++++++++++++++++++ tests/presenterchart/chartview.h | 49 ++++++++++++++ tests/presenterchart/main.cpp | 37 +++++++++++ tests/presenterchart/presenterchart.pro | 6 ++ tests/tests.pro | 3 +- 10 files changed, 194 insertions(+), 194 deletions(-) delete mode 100644 examples/presenterchart/chartview.cpp delete mode 100644 examples/presenterchart/chartview.h delete mode 100644 examples/presenterchart/main.cpp delete mode 100644 examples/presenterchart/presenterchart.pro create mode 100644 tests/presenterchart/chartview.cpp create mode 100644 tests/presenterchart/chartview.h create mode 100644 tests/presenterchart/main.cpp create mode 100644 tests/presenterchart/presenterchart.pro diff --git a/examples/examples.pro b/examples/examples.pro index ecc1b5fb..c65bebde 100644 --- a/examples/examples.pro +++ b/examples/examples.pro @@ -11,7 +11,6 @@ SUBDIRS += \ percentbarchart \ piechart \ piechartdrilldown \ - presenterchart \ scatterchart \ scatterinteractions \ splinechart \ diff --git a/examples/presenterchart/chartview.cpp b/examples/presenterchart/chartview.cpp deleted file mode 100644 index f81dce6e..00000000 --- a/examples/presenterchart/chartview.cpp +++ /dev/null @@ -1,100 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Digia Plc -** All rights reserved. -** For any questions to Digia, please use contact form at http://qt.digia.com -** -** This file is part of the Qt Commercial Charts Add-on. -** -** $QT_BEGIN_LICENSE$ -** Licensees holding valid Qt Commercial licenses may use this file in -** accordance with the Qt Commercial License Agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Digia. -** -** If you have questions regarding the use of this file, please use -** contact form at http://qt.digia.com -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "chartview.h" -#include -#include -#include -#include -#include - -ChartView::ChartView(QChart *chart, QWidget *parent) - : QChartView(chart, parent), - m_index(-1), - m_chart(chart) -{ - m_chart->setTitle("Charts presenter"); - m_chart->setDropShadowEnabled(false); - QObject::connect(&m_timer, SIGNAL(timeout()), this, SLOT(handleTimeout())); - m_timer.setInterval(3000); - - //![1] - QLineSeries *series0 = new QLineSeries(); - series0->setName("line"); - - QScatterSeries *series1 = new QScatterSeries(); - series1->setName("scatter"); - - QSplineSeries *series2 = new QSplineSeries(); - series2->setName("spline"); - - QAreaSeries *series3 = new QAreaSeries(series0); - series3->setName("area"); - //![1] - - //![2] - int numPoints = 10; - - for (int x = 0; x <= numPoints; ++x) { - qreal y = qrand() % 100; - series0->append(x, y); - series1->append(x, y); - series2->append(x, y); - } - //![2] - - //![3] - m_series << series0; - m_titles << m_chart->title() + ": LineChart"; - m_series << series1; - m_titles << m_chart->title() + ": ScatterChart"; - m_series << series2; - m_titles << m_chart->title() + ": SplineChart"; - m_series << series3; - m_titles << m_chart->title() + ": AreaChart"; - //![3] - - m_timer.start(); - handleTimeout(); -} - -ChartView::~ChartView() -{ - if (m_series.size() == 0) - return; - m_chart->removeSeries(m_series.at(m_index)); - m_series.removeLast(); //remove QAreaSeries instance since they will be deleted when QLineSeries instance is gone - qDeleteAll(m_series); -} - -//![4] -void ChartView::handleTimeout() -{ - if (m_series.size() == 0) - return; - if (m_index >= 0) - m_chart->removeSeries(m_series.at(m_index)); - m_index++; - m_index = m_index % m_series.size(); - m_chart->addSeries(m_series.at(m_index)); - m_chart->setTitle(m_titles.at(m_index)); - m_chart->createDefaultAxes(); -} -//![4] diff --git a/examples/presenterchart/chartview.h b/examples/presenterchart/chartview.h deleted file mode 100644 index 1e4de3b2..00000000 --- a/examples/presenterchart/chartview.h +++ /dev/null @@ -1,49 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Digia Plc -** All rights reserved. -** For any questions to Digia, please use contact form at http://qt.digia.com -** -** This file is part of the Qt Commercial Charts Add-on. -** -** $QT_BEGIN_LICENSE$ -** Licensees holding valid Qt Commercial licenses may use this file in -** accordance with the Qt Commercial License Agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Digia. -** -** If you have questions regarding the use of this file, please use -** contact form at http://qt.digia.com -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef CHARTVIEW_H -#define CHARTVIEW_H - -#include -#include - -QTCOMMERCIALCHART_USE_NAMESPACE - -//![1] -class ChartView: public QChartView -{ - Q_OBJECT -public: - ChartView(QChart *chart, QWidget *parent = 0); - virtual ~ChartView(); - -public slots: - void handleTimeout(); - -private: - QTimer m_timer; - QList m_series; - QStringList m_titles; - int m_index; - QChart *m_chart; -}; -//![1] - -#endif /* CHARTVIEW_H */ diff --git a/examples/presenterchart/main.cpp b/examples/presenterchart/main.cpp deleted file mode 100644 index 506acacd..00000000 --- a/examples/presenterchart/main.cpp +++ /dev/null @@ -1,37 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Digia Plc -** All rights reserved. -** For any questions to Digia, please use contact form at http://qt.digia.com -** -** This file is part of the Qt Commercial Charts Add-on. -** -** $QT_BEGIN_LICENSE$ -** Licensees holding valid Qt Commercial licenses may use this file in -** accordance with the Qt Commercial License Agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Digia. -** -** If you have questions regarding the use of this file, please use -** contact form at http://qt.digia.com -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "chartview.h" -#include -#include - -int main(int argc, char *argv[]) -{ - QApplication a(argc, argv); - QMainWindow window; - QChart *chart = new QChart(); - ChartView chartView(chart, &window); - chartView.setRenderHint(QPainter::Antialiasing); - chart->setAnimationOptions(QChart::SeriesAnimations); - window.setCentralWidget(&chartView); - window.resize(400, 300); - window.show(); - return a.exec(); -} diff --git a/examples/presenterchart/presenterchart.pro b/examples/presenterchart/presenterchart.pro deleted file mode 100644 index 1637b84a..00000000 --- a/examples/presenterchart/presenterchart.pro +++ /dev/null @@ -1,6 +0,0 @@ -!include( ../examples.pri ) { - error( "Couldn't find the examples.pri file!" ) -} -TARGET = presenterchart -HEADERS += chartview.h -SOURCES += main.cpp chartview.cpp diff --git a/tests/presenterchart/chartview.cpp b/tests/presenterchart/chartview.cpp new file mode 100644 index 00000000..f81dce6e --- /dev/null +++ b/tests/presenterchart/chartview.cpp @@ -0,0 +1,100 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Digia Plc +** All rights reserved. +** For any questions to Digia, please use contact form at http://qt.digia.com +** +** This file is part of the Qt Commercial Charts Add-on. +** +** $QT_BEGIN_LICENSE$ +** Licensees holding valid Qt Commercial licenses may use this file in +** accordance with the Qt Commercial License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. +** +** If you have questions regarding the use of this file, please use +** contact form at http://qt.digia.com +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "chartview.h" +#include +#include +#include +#include +#include + +ChartView::ChartView(QChart *chart, QWidget *parent) + : QChartView(chart, parent), + m_index(-1), + m_chart(chart) +{ + m_chart->setTitle("Charts presenter"); + m_chart->setDropShadowEnabled(false); + QObject::connect(&m_timer, SIGNAL(timeout()), this, SLOT(handleTimeout())); + m_timer.setInterval(3000); + + //![1] + QLineSeries *series0 = new QLineSeries(); + series0->setName("line"); + + QScatterSeries *series1 = new QScatterSeries(); + series1->setName("scatter"); + + QSplineSeries *series2 = new QSplineSeries(); + series2->setName("spline"); + + QAreaSeries *series3 = new QAreaSeries(series0); + series3->setName("area"); + //![1] + + //![2] + int numPoints = 10; + + for (int x = 0; x <= numPoints; ++x) { + qreal y = qrand() % 100; + series0->append(x, y); + series1->append(x, y); + series2->append(x, y); + } + //![2] + + //![3] + m_series << series0; + m_titles << m_chart->title() + ": LineChart"; + m_series << series1; + m_titles << m_chart->title() + ": ScatterChart"; + m_series << series2; + m_titles << m_chart->title() + ": SplineChart"; + m_series << series3; + m_titles << m_chart->title() + ": AreaChart"; + //![3] + + m_timer.start(); + handleTimeout(); +} + +ChartView::~ChartView() +{ + if (m_series.size() == 0) + return; + m_chart->removeSeries(m_series.at(m_index)); + m_series.removeLast(); //remove QAreaSeries instance since they will be deleted when QLineSeries instance is gone + qDeleteAll(m_series); +} + +//![4] +void ChartView::handleTimeout() +{ + if (m_series.size() == 0) + return; + if (m_index >= 0) + m_chart->removeSeries(m_series.at(m_index)); + m_index++; + m_index = m_index % m_series.size(); + m_chart->addSeries(m_series.at(m_index)); + m_chart->setTitle(m_titles.at(m_index)); + m_chart->createDefaultAxes(); +} +//![4] diff --git a/tests/presenterchart/chartview.h b/tests/presenterchart/chartview.h new file mode 100644 index 00000000..1e4de3b2 --- /dev/null +++ b/tests/presenterchart/chartview.h @@ -0,0 +1,49 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Digia Plc +** All rights reserved. +** For any questions to Digia, please use contact form at http://qt.digia.com +** +** This file is part of the Qt Commercial Charts Add-on. +** +** $QT_BEGIN_LICENSE$ +** Licensees holding valid Qt Commercial licenses may use this file in +** accordance with the Qt Commercial License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. +** +** If you have questions regarding the use of this file, please use +** contact form at http://qt.digia.com +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef CHARTVIEW_H +#define CHARTVIEW_H + +#include +#include + +QTCOMMERCIALCHART_USE_NAMESPACE + +//![1] +class ChartView: public QChartView +{ + Q_OBJECT +public: + ChartView(QChart *chart, QWidget *parent = 0); + virtual ~ChartView(); + +public slots: + void handleTimeout(); + +private: + QTimer m_timer; + QList m_series; + QStringList m_titles; + int m_index; + QChart *m_chart; +}; +//![1] + +#endif /* CHARTVIEW_H */ diff --git a/tests/presenterchart/main.cpp b/tests/presenterchart/main.cpp new file mode 100644 index 00000000..506acacd --- /dev/null +++ b/tests/presenterchart/main.cpp @@ -0,0 +1,37 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Digia Plc +** All rights reserved. +** For any questions to Digia, please use contact form at http://qt.digia.com +** +** This file is part of the Qt Commercial Charts Add-on. +** +** $QT_BEGIN_LICENSE$ +** Licensees holding valid Qt Commercial licenses may use this file in +** accordance with the Qt Commercial License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. +** +** If you have questions regarding the use of this file, please use +** contact form at http://qt.digia.com +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "chartview.h" +#include +#include + +int main(int argc, char *argv[]) +{ + QApplication a(argc, argv); + QMainWindow window; + QChart *chart = new QChart(); + ChartView chartView(chart, &window); + chartView.setRenderHint(QPainter::Antialiasing); + chart->setAnimationOptions(QChart::SeriesAnimations); + window.setCentralWidget(&chartView); + window.resize(400, 300); + window.show(); + return a.exec(); +} diff --git a/tests/presenterchart/presenterchart.pro b/tests/presenterchart/presenterchart.pro new file mode 100644 index 00000000..dc948675 --- /dev/null +++ b/tests/presenterchart/presenterchart.pro @@ -0,0 +1,6 @@ +!include( ../tests.pri ) { + error( "Couldn't find the examples.pri file!" ) +} +TARGET = presenterchart +HEADERS += chartview.h +SOURCES += main.cpp chartview.cpp diff --git a/tests/tests.pro b/tests/tests.pro index a02f3027..38dd75d9 100644 --- a/tests/tests.pro +++ b/tests/tests.pro @@ -6,7 +6,8 @@ TEMPLATE = subdirs SUBDIRS += \ auto \ qmlchartproperties \ - qmlchartaxis + qmlchartaxis \ + presenterchart contains(QT_CONFIG, opengl) { SUBDIRS += chartwidgettest \ -- cgit v1.2.3