From ef99599d15b761d5c3aa8929efa9fdb1aed06883 2012-01-19 12:07:14 From: Tero Ahola Date: 2012-01-19 12:07:14 Subject: [PATCH] Renamed to QtCommercialChart --- diff --git a/charts.pro b/charts.pro index 4366d14..130f9c4 100644 --- a/charts.pro +++ b/charts.pro @@ -1,11 +1,10 @@ -TEMPLATE = subdirs -SUBDIRS += src #qmlplugin - -QMAKE_CXXFLAGS += -g -Wall -QMAKE_DISTCLEAN += -r build - -# install feature file -feature.path = $$[QT_INSTALL_DATA]/mkspecs/features -feature.files = $$PWD/features/charts.prf -INSTALLS += feature - +TEMPLATE = subdirs +SUBDIRS += src #qmlplugin + +QMAKE_CXXFLAGS += -g -Wall +QMAKE_DISTCLEAN += -r build + +# install feature file +feature.path = $$[QT_INSTALL_DATA]/mkspecs/features +feature.files = $$PWD/features/qtcommercialchart.prf +INSTALLS += feature diff --git a/example/linechart/linechart.pro b/example/linechart/linechart.pro index 08094fa..1e1ebc3 100644 --- a/example/linechart/linechart.pro +++ b/example/linechart/linechart.pro @@ -3,6 +3,6 @@ TEMPLATE = app QT += core gui -CONFIG += charts +CONFIG += qtcommercialchart SOURCES += main.cpp diff --git a/example/linechart/main.cpp b/example/linechart/main.cpp index d4ab7fc..41e1bde 100644 --- a/example/linechart/main.cpp +++ b/example/linechart/main.cpp @@ -5,7 +5,7 @@ #include #include -QCHART_USE_NAMESPACE +QTCOMMERCIALCHART_USE_NAMESPACE #define PI 3.14159265358979 diff --git a/features/charts.prf b/features/charts.prf deleted file mode 100644 index 97e957f..0000000 --- a/features/charts.prf +++ /dev/null @@ -1,10 +0,0 @@ -message( "Configuring with qchart addon..." ) - -INCLUDEPATH += $$[QT_INSTALL_HEADERS]/QCharts - -CONFIG(debug, debug|release) { - LIBS += -lQChartd -} else { - LIBS += -lQChart -} - diff --git a/features/qtcommercialchart.prf b/features/qtcommercialchart.prf new file mode 100644 index 0000000..d60608e --- /dev/null +++ b/features/qtcommercialchart.prf @@ -0,0 +1,9 @@ +message( "Configuring with QtCommercialChart addon..." ) + +INCLUDEPATH += $$[QT_INSTALL_HEADERS]/QtCommercialChart + +CONFIG(debug, debug|release) { + LIBS += -lQtCommercialChartd +} else { + LIBS += -lQtCommercialChart +} diff --git a/src/axis.cpp b/src/axis.cpp index c40fea3..65a31f0 100644 --- a/src/axis.cpp +++ b/src/axis.cpp @@ -2,7 +2,7 @@ #include #include -QCHART_BEGIN_NAMESPACE +QTCOMMERCIALCHART_BEGIN_NAMESPACE Axis::Axis(QGraphicsItem* parent): QGraphicsItem(parent) { @@ -47,4 +47,4 @@ void Axis::paint(QPainter *painter, const QStyleOptionGraphicsItem *option,QWidg painter->restore(); } -QCHART_END_NAMESPACE +QTCOMMERCIALCHART_END_NAMESPACE diff --git a/src/axis_p.h b/src/axis_p.h index 55c9495..028b768 100644 --- a/src/axis_p.h +++ b/src/axis_p.h @@ -1,10 +1,10 @@ #ifndef AXIS_H_ #define AXIS_H_ -#include +#include #include -QCHART_BEGIN_NAMESPACE +QTCOMMERCIALCHART_BEGIN_NAMESPACE class Axis: public QGraphicsItem { @@ -24,6 +24,6 @@ private: QPainterPath m_path; }; -QCHART_END_NAMESPACE +QTCOMMERCIALCHART_END_NAMESPACE #endif /* AXIS_H_ */ diff --git a/src/qchart.cpp b/src/qchart.cpp index 9cc8430..0f9f0c8 100644 --- a/src/qchart.cpp +++ b/src/qchart.cpp @@ -6,7 +6,7 @@ #include "xygrid_p.h" #include -QCHART_BEGIN_NAMESPACE +QTCOMMERCIALCHART_BEGIN_NAMESPACE class QChartPrivate { @@ -72,12 +72,16 @@ void QChart::addSeries(QChartSeries* series) switch(series->type()) { - case QChartSeries::LINE: + case QChartSeries::SeriesTypeLine: { XYLineChartItem* item = new XYLineChartItem(reinterpret_cast(series),this); item->updateXYPlotData(d->m_plotDataList.at(0)); d->m_items<m_marginSize = margin; } - - -QCHART_END_NAMESPACE +QTCOMMERCIALCHART_END_NAMESPACE diff --git a/src/qchart.h b/src/qchart.h index d7932e6..26004bc 100644 --- a/src/qchart.h +++ b/src/qchart.h @@ -1,10 +1,10 @@ #ifndef CHART_H #define CHART_H -#include +#include #include -QCHART_BEGIN_NAMESPACE +QTCOMMERCIALCHART_BEGIN_NAMESPACE class Axis; class XYGrid; @@ -12,7 +12,7 @@ class QChartSeries; class XYPlotDomain; class QChartPrivate; -class QCHART_EXPORT QChart : public QGraphicsItem +class QTCOMMERCIALCHART_EXPORT QChart : public QGraphicsItem { public: @@ -38,6 +38,6 @@ private: }; -QCHART_END_NAMESPACE +QTCOMMERCIALCHART_END_NAMESPACE #endif diff --git a/src/qchartconfig.h b/src/qchartconfig.h deleted file mode 100644 index 681aaac..0000000 --- a/src/qchartconfig.h +++ /dev/null @@ -1,25 +0,0 @@ -#ifndef CHARTCONFIG_H -#define CHARTCONFIG_H - -#define QCHART_VERSION_STR "1.0" -#define QCHART_VERSION 0x01 - -#if defined(QCHART_LIBRARY) -# define QCHART_EXPORT Q_DECL_EXPORT -#else -# define QCHART_EXPORT Q_DECL_IMPORT -#endif - -#define QCHART_NAMESPACE QtChart - -#ifdef QCHART_NAMESPACE -# define QCHART_BEGIN_NAMESPACE namespace QCHART_NAMESPACE { -# define QCHART_END_NAMESPACE } -# define QCHART_USE_NAMESPACE using namespace QCHART_NAMESPACE; -#else -# define QCHART_BEGIN_NAMESPACE -# define QCHART_END_NAMESPACE -# define QCHART_USE_NAMESPACE -#endif - -#endif diff --git a/src/qchartglobal.h b/src/qchartglobal.h new file mode 100644 index 0000000..f429680 --- /dev/null +++ b/src/qchartglobal.h @@ -0,0 +1,25 @@ +#ifndef CHARTGLOBAL_H +#define CHARTGLOBAL_H + +#define QTCOMMERCIALCHART_VERSION_STR "1.0" +#define QTCOMMERCIALCHART_VERSION 0x01 + +#if defined(QTCOMMERCIALCHART_LIBRARY) +# define QTCOMMERCIALCHART_EXPORT Q_DECL_EXPORT +#else +# define QTCOMMERCIALCHART_EXPORT Q_DECL_IMPORT +#endif + +#define QTCOMMERCIALCHART_NAMESPACE QtCommercialChart + +#ifdef QTCOMMERCIALCHART_NAMESPACE +# define QTCOMMERCIALCHART_BEGIN_NAMESPACE namespace QTCOMMERCIALCHART_NAMESPACE { +# define QTCOMMERCIALCHART_END_NAMESPACE } +# define QTCOMMERCIALCHART_USE_NAMESPACE using namespace QTCOMMERCIALCHART_NAMESPACE; +#else +# define QTCOMMERCIALCHART_BEGIN_NAMESPACE +# define QTCOMMERCIALCHART_END_NAMESPACE +# define QTCOMMERCIALCHART_USE_NAMESPACE +#endif + +#endif diff --git a/src/qchartseries.h b/src/qchartseries.h index a97be96..6bb158d 100644 --- a/src/qchartseries.h +++ b/src/qchartseries.h @@ -1,16 +1,23 @@ #ifndef QCHARTSERIES_H #define QCHARTSERIES_H -#include "qchartconfig.h" +#include "qchartglobal.h" #include -QCHART_BEGIN_NAMESPACE +QTCOMMERCIALCHART_BEGIN_NAMESPACE -class QCHART_EXPORT QChartSeries : public QObject +class QTCOMMERCIALCHART_EXPORT QChartSeries : public QObject { public: - enum QChartSeriesType {LINE,PIE,BAR}; + enum QChartSeriesType { + SeriesTypeLine = 0, +// SeriesTypeArea, +// SeriesTypeBar, +// SeriesTypePie, + SeriesTypeScatter +// SeriesTypeSpline + }; protected: QChartSeries(QObject *parent = 0):QObject(parent){}; @@ -25,7 +32,7 @@ public: }; -QCHART_END_NAMESPACE +QTCOMMERCIALCHART_END_NAMESPACE #endif diff --git a/src/qchartwidget.cpp b/src/qchartwidget.cpp index e6f6567..a55f44a 100644 --- a/src/qchartwidget.cpp +++ b/src/qchartwidget.cpp @@ -4,7 +4,7 @@ #include #include -QCHART_BEGIN_NAMESPACE +QTCOMMERCIALCHART_BEGIN_NAMESPACE class QChartWidgetPrivate { @@ -66,4 +66,4 @@ void QChartWidget::addSeries(QChartSeries* series) #include "moc_qchartwidget.cpp" -QCHART_END_NAMESPACE +QTCOMMERCIALCHART_END_NAMESPACE diff --git a/src/qchartwidget.h b/src/qchartwidget.h index 1269f17..0edecd0 100644 --- a/src/qchartwidget.h +++ b/src/qchartwidget.h @@ -1,16 +1,16 @@ #ifndef QCHARTWIDGET_H #define QCHARTWIDGET_H -#include "qchartconfig.h" +#include "qchartglobal.h" #include "qchart.h" #include -QCHART_BEGIN_NAMESPACE +QTCOMMERCIALCHART_BEGIN_NAMESPACE class QChartSeries; class QChartWidgetPrivate; -class QCHART_EXPORT QChartWidget : public QWidget +class QTCOMMERCIALCHART_EXPORT QChartWidget : public QWidget { Q_OBJECT public: @@ -31,6 +31,6 @@ private: }; -QCHART_END_NAMESPACE +QTCOMMERCIALCHART_END_NAMESPACE #endif // QCHARTWIDGET_H diff --git a/src/src.pro b/src/src.pro index 5cf18bb..7305006 100644 --- a/src/src.pro +++ b/src/src.pro @@ -1,46 +1,49 @@ -TARGET = QChart -TEMPLATE = lib -QT += core \ - gui -CONFIG += debug_and_release -CONFIG(debug, debug|release):TARGET = QChartd - -SOURCES += \ - xylinechart/qxychartseries.cpp \ - xylinechart/xylinechartitem.cpp \ - xylinechart/xygrid.cpp \ - xylinechart/xyplotdomain.cpp \ - qchart.cpp \ - axis.cpp \ - qchartwidget.cpp - -PRIVATE_HEADERS += \ - xylinechart/xylinechartitem_p.h \ - xylinechart/xyplotdomain_p.h \ - xylinechart/xygrid_p.h \ - axis_p.h - -PUBLIC_HEADERS += \ - qchartseries.h \ - qchart.h \ - qchartwidget.h \ - qchartconfig.h \ - xylinechart/qxychartseries.h - -HEADERS += $$PUBLIC_HEADERS -HEADERS += $$PRIVATE_HEADERS - -INCLUDEPATH += xylinechart \ - . - -OBJECTS_DIR = ../build/lib -MOC_DIR = ../build/lib -UI_DIR = ../build/lib -RCC_DIR = ../build/lib -DEFINES += QCHART_LIBRARY - -public_headers.path = $$[QT_INSTALL_HEADERS]/QCharts -public_headers.files = $$PUBLIC_HEADERS -target.path = $$[QT_INSTALL_LIBS] -INSTALLS += target \ - public_headers +TARGET = QtCommercialChart +TEMPLATE = lib +QT += core \ + gui +CONFIG += debug_and_release +CONFIG(debug, debug|release):TARGET = QtCommercialChartd + +SOURCES += \ + xylinechart/qxychartseries.cpp \ + xylinechart/xylinechartitem.cpp \ + xylinechart/xygrid.cpp \ + xylinechart/xyplotdomain.cpp \ + qchart.cpp \ + axis.cpp \ + qchartwidget.cpp + +PRIVATE_HEADERS += \ + xylinechart/xylinechartitem_p.h \ + xylinechart/xyplotdomain_p.h \ + xylinechart/xygrid_p.h \ + axis_p.h + +PUBLIC_HEADERS += \ + qchartseries.h \ + qchart.h \ + qchartwidget.h \ + qchartglobal.h \ + xylinechart/qxychartseries.h + +HEADERS += $$PUBLIC_HEADERS +HEADERS += $$PRIVATE_HEADERS + +INCLUDEPATH += xylinechart \ + . + +OBJECTS_DIR = ../build/lib +MOC_DIR = ../build/lib +UI_DIR = ../build/lib +RCC_DIR = ../build/lib +DEFINES += QTCOMMERCIALCHART_LIBRARY + +public_headers.path = $$[QT_INSTALL_HEADERS]/QtCommercialChart +public_headers.files = $$PUBLIC_HEADERS +target.path = $$[QT_INSTALL_LIBS] +INSTALLS += target \ + public_headers + + + diff --git a/src/xylinechart/qxychartseries.cpp b/src/xylinechart/qxychartseries.cpp index 7340fd2..21ba0d9 100644 --- a/src/xylinechart/qxychartseries.cpp +++ b/src/xylinechart/qxychartseries.cpp @@ -1,6 +1,6 @@ #include "qxychartseries.h" -QCHART_BEGIN_NAMESPACE +QTCOMMERCIALCHART_BEGIN_NAMESPACE QXYChartSeries::QXYChartSeries(QObject* parent):QChartSeries(parent), m_color(Qt::black) @@ -65,4 +65,4 @@ QDebug operator<< (QDebug debug, const QXYChartSeries series) return debug.space(); } -QCHART_END_NAMESPACE +QTCOMMERCIALCHART_END_NAMESPACE diff --git a/src/xylinechart/qxychartseries.h b/src/xylinechart/qxychartseries.h index 8602242..0efd29c 100644 --- a/src/xylinechart/qxychartseries.h +++ b/src/xylinechart/qxychartseries.h @@ -1,14 +1,14 @@ #ifndef QXYSERIES_H_ #define QXYSERIES_H_ -#include "qchartconfig.h" +#include "qchartglobal.h" #include "qchartseries.h" #include #include -QCHART_BEGIN_NAMESPACE +QTCOMMERCIALCHART_BEGIN_NAMESPACE -class QCHART_EXPORT QXYChartSeries : public QChartSeries +class QTCOMMERCIALCHART_EXPORT QXYChartSeries : public QChartSeries { private: QXYChartSeries(QObject* parent=0); @@ -17,7 +17,7 @@ public: //implemented from QChartSeries static QXYChartSeries* create(QObject* parent=0); - virtual QChartSeriesType type() const { return QChartSeries::LINE;}; + virtual QChartSeriesType type() const { return QChartSeries::SeriesTypeLine;} void add(qreal x, qreal y); void clear(); @@ -35,6 +35,6 @@ private: }; -QCHART_END_NAMESPACE +QTCOMMERCIALCHART_END_NAMESPACE #endif diff --git a/src/xylinechart/xygrid.cpp b/src/xylinechart/xygrid.cpp index de71400..a5d2446 100644 --- a/src/xylinechart/xygrid.cpp +++ b/src/xylinechart/xygrid.cpp @@ -2,7 +2,7 @@ #include #include -QCHART_BEGIN_NAMESPACE +QTCOMMERCIALCHART_BEGIN_NAMESPACE XYGrid::XYGrid(QGraphicsItem* parent):QGraphicsItem(parent) { @@ -67,4 +67,4 @@ void XYGrid::paint(QPainter *painter, const QStyleOptionGraphicsItem *option,QWi //painter->drawRect(m_rect.adjusted(0, 0, -1, -1)); } -QCHART_END_NAMESPACE +QTCOMMERCIALCHART_END_NAMESPACE diff --git a/src/xylinechart/xygrid_p.h b/src/xylinechart/xygrid_p.h index b21be21..becd9f6 100644 --- a/src/xylinechart/xygrid_p.h +++ b/src/xylinechart/xygrid_p.h @@ -1,11 +1,11 @@ #ifndef XYGRID_H_ #define XYGRID_H_ -#include +#include #include #include -QCHART_BEGIN_NAMESPACE +QTCOMMERCIALCHART_BEGIN_NAMESPACE class XYGrid : public QGraphicsItem { @@ -26,6 +26,6 @@ private: XYPlotDomain m_xyPlotData; }; -QCHART_END_NAMESPACE +QTCOMMERCIALCHART_END_NAMESPACE #endif /* XYGRID_H_ */ diff --git a/src/xylinechart/xylinechartitem.cpp b/src/xylinechart/xylinechartitem.cpp index 76b0700..74a09d1 100644 --- a/src/xylinechart/xylinechartitem.cpp +++ b/src/xylinechart/xylinechartitem.cpp @@ -6,7 +6,7 @@ #include #include -QCHART_BEGIN_NAMESPACE +QTCOMMERCIALCHART_BEGIN_NAMESPACE XYLineChartItem::XYLineChartItem(QXYChartSeries* series,QGraphicsItem *parent):QGraphicsItem(parent), m_series(series) @@ -53,4 +53,4 @@ void XYLineChartItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *o } -QCHART_END_NAMESPACE +QTCOMMERCIALCHART_END_NAMESPACE diff --git a/src/xylinechart/xylinechartitem_p.h b/src/xylinechart/xylinechartitem_p.h index 0f35b10..beff445 100644 --- a/src/xylinechart/xylinechartitem_p.h +++ b/src/xylinechart/xylinechartitem_p.h @@ -1,11 +1,11 @@ #ifndef XYLINECHARTITEM_H #define XYLINECHARTITEM_H -#include "qchartconfig.h" +#include "qchartglobal.h" #include "qchart.h" #include "xyplotdomain_p.h" -QCHART_BEGIN_NAMESPACE +QTCOMMERCIALCHART_BEGIN_NAMESPACE class QXYChartSeries; @@ -28,6 +28,6 @@ private: XYPlotDomain m_xyPlotData; }; -QCHART_END_NAMESPACE +QTCOMMERCIALCHART_END_NAMESPACE #endif diff --git a/src/xylinechart/xyplotdomain.cpp b/src/xylinechart/xyplotdomain.cpp index 7e76564..8759054 100644 --- a/src/xylinechart/xyplotdomain.cpp +++ b/src/xylinechart/xyplotdomain.cpp @@ -1,6 +1,6 @@ #include "xyplotdomain_p.h" -QCHART_BEGIN_NAMESPACE +QTCOMMERCIALCHART_BEGIN_NAMESPACE XYPlotDomain::XYPlotDomain(): m_ticksX(0), @@ -30,4 +30,4 @@ qreal XYPlotDomain::spanY() const return m_maxY - m_minY; } -QCHART_END_NAMESPACE +QTCOMMERCIALCHART_END_NAMESPACE diff --git a/src/xylinechart/xyplotdomain_p.h b/src/xylinechart/xyplotdomain_p.h index 8ee0a1d..2b30674 100644 --- a/src/xylinechart/xyplotdomain_p.h +++ b/src/xylinechart/xyplotdomain_p.h @@ -1,9 +1,9 @@ #ifndef PLOTDOMAIN_H_ #define PLOTDOMAIN_H_ -#include "qchartconfig.h" +#include "qchartglobal.h" #include -QCHART_BEGIN_NAMESPACE +QTCOMMERCIALCHART_BEGIN_NAMESPACE class XYPlotDomain { public: @@ -25,6 +25,6 @@ public: QRect m_viewportRect; }; -QCHART_END_NAMESPACE +QTCOMMERCIALCHART_END_NAMESPACE #endif /* PLOTTER_H_ */ diff --git a/test/chartwidgettest/chartwidgettest.pro b/test/chartwidgettest/chartwidgettest.pro index 2457fd6..a301da6 100644 --- a/test/chartwidgettest/chartwidgettest.pro +++ b/test/chartwidgettest/chartwidgettest.pro @@ -6,7 +6,7 @@ contains(QT_MAJOR_VERSION, 5) { QT += widgets } -CONFIG += charts +CONFIG += qtcommercialchart OBJECTS_DIR = tmp MOC_DIR = tmp diff --git a/test/chartwidgettest/mainwidget.cpp b/test/chartwidgettest/mainwidget.cpp index 51e7b38..3189f03 100644 --- a/test/chartwidgettest/mainwidget.cpp +++ b/test/chartwidgettest/mainwidget.cpp @@ -13,15 +13,11 @@ #include #include -QCHART_USE_NAMESPACE +QTCOMMERCIALCHART_USE_NAMESPACE MainWidget::MainWidget(QWidget *parent) : QWidget(parent) { - m_chartWidget = new QChartWidget(this); -// m_chartWidget->resize(QSize(200,200)); -// m_chartWidget->setColor(Qt::red); - QPushButton *addSeriesButton = new QPushButton("Add series"); connect(addSeriesButton, SIGNAL(clicked()), this, SLOT(addSeries())); @@ -79,8 +75,11 @@ MainWidget::MainWidget(QWidget *parent) : grid->setRowStretch(8, 1); hbox->addLayout(grid); + + m_chartWidget = new QChartWidget(this); + //m_chartWidget->setColor(Qt::red); hbox->addWidget(m_chartWidget); - hbox->setStretch(1, 1); +// hbox->setStretch(1, 1); setLayout(hbox); @@ -101,8 +100,17 @@ void MainWidget::addSeries(QString series, QString data) qDebug() << "addSeries: " << series << " data: " << data; m_defaultSeries = series; + QXYChartSeries* series0 = 0; + // TODO: color of the series - QXYChartSeries* series0 = QXYChartSeries::create(); + if (series == "Scatter") { + series0 = QXYChartSeries::create(); + } else if (series == "Line") { + series0 = QXYChartSeries::create(); + } else { + // TODO + series0 = QXYChartSeries::create(); + } if (data == "linear") { for (int i = 0; i < 10; i++) @@ -124,13 +132,7 @@ void MainWidget::addSeries(QString series, QString data) // TODO: check if data has a valid file name } - if (series == "Scatter") { - m_chartWidget->addSeries(series0); - } else if (series == "Line") { - m_chartWidget->addSeries(series0); - } else { - // TODO - } + m_chartWidget->addSeries(series0); } void MainWidget::chartTypeChanged(int itemIndex) diff --git a/test/chartwidgettest/mainwidget.h b/test/chartwidgettest/mainwidget.h index e8bf4f7..8503c18 100644 --- a/test/chartwidgettest/mainwidget.h +++ b/test/chartwidgettest/mainwidget.h @@ -1,14 +1,14 @@ #ifndef MAINWIDGET_H #define MAINWIDGET_H -#include +#include #include #include class QSpinBox; class QCheckBox; -QCHART_USE_NAMESPACE +QTCOMMERCIALCHART_USE_NAMESPACE class MainWidget : public QWidget {