diff --git a/demos/chartviewer/charts.cpp b/demos/chartviewer/charts.cpp deleted file mode 100644 index 602dde7..0000000 --- a/demos/chartviewer/charts.cpp +++ /dev/null @@ -1,29 +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 "charts.h" - -Chart::Chart(){}; -Chart::~Chart(){}; - -void Chart::initialize() -{ - Charts::addChart(this); -} diff --git a/demos/chartviewer/charts.h b/demos/chartviewer/charts.h index 3f5ca7a..9432934 100644 --- a/demos/chartviewer/charts.h +++ b/demos/chartviewer/charts.h @@ -35,11 +35,7 @@ QTCOMMERCIALCHART_USE_NAMESPACE class Chart { public: - Chart(); - - virtual ~Chart(); - - virtual void initialize(); + virtual ~Chart(){}; virtual QChart* createChart(const DataTable& table) = 0; virtual QString name() = 0; virtual QString category() = 0; @@ -81,6 +77,17 @@ inline void addChart(Chart* chart) } } -#define DECLARE_CHART(chartName) static chartName t; +template +class ChartWrapper +{ +public: + QSharedPointer chart; + ChartWrapper() : chart(new T) + { + Charts::addChart(chart.data()); + } +}; + +#define DECLARE_CHART(chartName) static ChartWrapper t; #endif diff --git a/demos/chartviewer/charts/areachart.cpp b/demos/chartviewer/charts/areachart.cpp index c571fe7..9bb4191 100644 --- a/demos/chartviewer/charts/areachart.cpp +++ b/demos/chartviewer/charts/areachart.cpp @@ -26,11 +26,6 @@ class AreaChart: public Chart { public: - - AreaChart(){ - initialize(); - } - QString name() { return QObject::tr("AreaChart"); } QString category() { return QObject::tr("XYSeries"); } QString subCategory() { return QString::null; } diff --git a/demos/chartviewer/charts/horizontalbarchart.cpp b/demos/chartviewer/charts/horizontalbarchart.cpp index 15fe09e..665779a 100644 --- a/demos/chartviewer/charts/horizontalbarchart.cpp +++ b/demos/chartviewer/charts/horizontalbarchart.cpp @@ -26,11 +26,6 @@ class HorizontalBarChart: public Chart { public: - - HorizontalBarChart(){ - initialize(); - } - QString name() { return QObject::tr("HorizontalBarChart"); } QString category() { return QObject::tr("BarSeries"); } QString subCategory() { return QObject::tr("Vertical"); } diff --git a/demos/chartviewer/charts/horizontalstackedbarchart.cpp b/demos/chartviewer/charts/horizontalstackedbarchart.cpp index 546a64e..c9f73e7 100644 --- a/demos/chartviewer/charts/horizontalstackedbarchart.cpp +++ b/demos/chartviewer/charts/horizontalstackedbarchart.cpp @@ -26,11 +26,6 @@ class HorizontalStackedBarChart: public Chart { public: - - HorizontalStackedBarChart(){ - initialize(); - } - QString name() { return QObject::tr("HorizontalStackedBarChart"); } QString category() { return QObject::tr("BarSeries"); } QString subCategory() { return QObject::tr("Vertical"); } diff --git a/demos/chartviewer/charts/linechart.cpp b/demos/chartviewer/charts/linechart.cpp index 464be25..07d4311 100644 --- a/demos/chartviewer/charts/linechart.cpp +++ b/demos/chartviewer/charts/linechart.cpp @@ -25,11 +25,6 @@ class LineChart: public Chart { public: - - LineChart(){ - initialize(); - } - QString name() { return QObject::tr("LineChart"); } QString category() { return QObject::tr("XYSeries"); } QString subCategory() { return QString::null; } diff --git a/demos/chartviewer/charts/piechart.cpp b/demos/chartviewer/charts/piechart.cpp index d8def3d..9436fb9 100644 --- a/demos/chartviewer/charts/piechart.cpp +++ b/demos/chartviewer/charts/piechart.cpp @@ -25,11 +25,6 @@ class PieChart: public Chart { public: - - PieChart(){ - initialize(); - } - QString name() { return QObject::tr("PieChart"); } QString category() { return QString::null; } QString subCategory() { return QString::null; } diff --git a/demos/chartviewer/charts/scatterchart.cpp b/demos/chartviewer/charts/scatterchart.cpp index c17e9b4..a821962 100644 --- a/demos/chartviewer/charts/scatterchart.cpp +++ b/demos/chartviewer/charts/scatterchart.cpp @@ -25,11 +25,6 @@ class ScatterChart: public Chart { public: - - ScatterChart(){ - initialize(); - } - QString name() { return QObject::tr("ScatterChart"); } QString category() { return QObject::tr("XYSeries"); } QString subCategory() { return QString::null; } diff --git a/demos/chartviewer/charts/splinechart.cpp b/demos/chartviewer/charts/splinechart.cpp index aad1266..454c1c6 100644 --- a/demos/chartviewer/charts/splinechart.cpp +++ b/demos/chartviewer/charts/splinechart.cpp @@ -25,11 +25,6 @@ class SplineChart: public Chart { public: - - SplineChart(){ - initialize(); - } - QString name() { return QObject::tr("SplineChart"); } QString category() { return QObject::tr("XYSeries"); } QString subCategory() { return QString::null; } diff --git a/demos/chartviewer/charts/verticalbarchart.cpp b/demos/chartviewer/charts/verticalbarchart.cpp index b566037..a480b3d 100644 --- a/demos/chartviewer/charts/verticalbarchart.cpp +++ b/demos/chartviewer/charts/verticalbarchart.cpp @@ -26,11 +26,6 @@ class VerticalBarChart: public Chart { public: - - VerticalBarChart(){ - initialize(); - } - QString name() { return QObject::tr("VerticalBarChart"); } QString category() { return QObject::tr("BarSeries"); } QString subCategory() { return QObject::tr("Vertical"); } diff --git a/demos/chartviewer/charts/verticalstackedbarchart.cpp b/demos/chartviewer/charts/verticalstackedbarchart.cpp index e207093..c9c1a60 100644 --- a/demos/chartviewer/charts/verticalstackedbarchart.cpp +++ b/demos/chartviewer/charts/verticalstackedbarchart.cpp @@ -26,11 +26,6 @@ class VerticalStackedBarChart: public Chart { public: - - VerticalStackedBarChart(){ - initialize(); - } - QString name() { return QObject::tr("VerticalStackedBarChart"); } QString category() { return QObject::tr("BarSeries"); } QString subCategory() { return QObject::tr("Vertical"); } diff --git a/demos/chartviewer/chartviewer.pro b/demos/chartviewer/chartviewer.pro index adb88ae..3509ecb 100644 --- a/demos/chartviewer/chartviewer.pro +++ b/demos/chartviewer/chartviewer.pro @@ -3,6 +3,6 @@ include(charts/charts.pri) TARGET = chartviewer QT += opengl INCLUDEPATH += . -SOURCES += main.cpp window.cpp view.cpp charts.cpp +SOURCES += main.cpp window.cpp view.cpp HEADERS += window.h view.h charts.h model.h