From 6601c1904416e3180e484204ba830fd45982017f 2012-04-03 07:58:17 From: Tero Ahola Date: 2012-04-03 07:58:17 Subject: [PATCH] QML api to use chart theme enum of QChart --- diff --git a/qmlplugin/declarativechart.cpp b/qmlplugin/declarativechart.cpp index 5d3cd83..e7a1477 100644 --- a/qmlplugin/declarativechart.cpp +++ b/qmlplugin/declarativechart.cpp @@ -35,9 +35,9 @@ DeclarativeChart::~DeclarativeChart() delete m_chart; } -DeclarativeChart::ChartTheme DeclarativeChart::theme() +QChart::ChartTheme DeclarativeChart::theme() { - return (ChartTheme) m_chart->theme(); + return m_chart->theme(); } void DeclarativeChart::geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry) diff --git a/qmlplugin/declarativechart.h b/qmlplugin/declarativechart.h index 1078036..4a81852 100644 --- a/qmlplugin/declarativechart.h +++ b/qmlplugin/declarativechart.h @@ -32,20 +32,9 @@ class DeclarativeChart : public QDeclarativeItem //class DeclarativeChart : public QQuickPaintedItem, public Chart { Q_OBJECT - Q_ENUMS(ChartTheme) - Q_PROPERTY(ChartTheme theme READ theme WRITE setTheme) + Q_PROPERTY(QChart::ChartTheme theme READ theme WRITE setTheme) public: - enum ChartTheme { - ThemeDefault, - ThemeLight, - ThemeBlueCerulean, - ThemeDark, - ThemeBrownSand, - ThemeBlueNcs, - ThemeHighContrast, - ThemeBlueIcy - }; DeclarativeChart(QDeclarativeItem *parent = 0); ~DeclarativeChart(); @@ -54,8 +43,8 @@ public: // From QDeclarativeItem/QGraphicsItem void paint (QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = 0); public: - void setTheme(ChartTheme theme) {m_chart->setTheme((QChart::ChartTheme) theme);} - ChartTheme theme(); + void setTheme(QChart::ChartTheme theme) {m_chart->setTheme(theme);} + QChart::ChartTheme theme(); public: // Extending QChart with DeclarativeChart is not possible because QObject does not support diff --git a/qmlplugin/plugin.cpp b/qmlplugin/plugin.cpp index 7fe62d6..0ab5c72 100644 --- a/qmlplugin/plugin.cpp +++ b/qmlplugin/plugin.cpp @@ -20,6 +20,7 @@ #include #include +#include "qchart.h" #include "declarativechart.h" #include "declarativexypoint.h" #include "declarativelineseries.h" diff --git a/src/qchart.h b/src/qchart.h index d807658..dbe4839 100644 --- a/src/qchart.h +++ b/src/qchart.h @@ -36,6 +36,8 @@ struct QChartPrivate; class QTCOMMERCIALCHART_EXPORT QChart : public QGraphicsWidget { Q_OBJECT + Q_ENUMS(ChartTheme) + public: enum ChartTheme { ChartThemeDefault, diff --git a/test/qmlchart/qml/qmlchart/main.qml b/test/qmlchart/qml/qmlchart/main.qml index 14d58a2..8b57854 100644 --- a/test/qmlchart/qml/qmlchart/main.qml +++ b/test/qmlchart/qml/qmlchart/main.qml @@ -54,7 +54,7 @@ Rectangle { anchors.left: parent.left anchors.right: parent.right height: parent.height / 2 - theme: Chart.ThemeBlueCerulean + theme: Chart.ChartThemeBlueCerulean BarSeries { barCategories: [ "2008", "2009", "2010", "2011", "2012" ] @@ -79,7 +79,7 @@ Rectangle { anchors.bottom: parent.bottom anchors.left: parent.left anchors.right: parent.right - theme: Chart.ThemeBrownSand + theme: Chart.ChartThemeHighContrast LineSeries { points: [