diff --git a/demos/qmlchart/qml/qmlchart/View1.qml b/demos/qmlchart/qml/qmlchart/View1.qml
index 1332bf6..b76d5c1 100644
--- a/demos/qmlchart/qml/qmlchart/View1.qml
+++ b/demos/qmlchart/qml/qmlchart/View1.qml
@@ -31,9 +31,9 @@ Rectangle {
legend: Chart.LegendBottom
PieSeries {
- horizontalPosition: 0.2
- verticalPosition: 0.3
- size: 0.4
+ horizontalPosition: 0.5
+ verticalPosition: 0.5
+ size: 0.7
slices: [
PieSlice { label: "Volkswagen"; value: 13.5 },
PieSlice { label: "Toyota"; value: 10.9 },
@@ -43,10 +43,5 @@ Rectangle {
PieSlice { label: "Others"; value: 52.0 }
]
}
-
- BarSeries {
- barCategories: [ "2008", "2009", "2010", "2011", "2012" ]
- // data implementation missing
- }
}
}
diff --git a/demos/qmlchart/qml/qmlchart/View3.qml b/demos/qmlchart/qml/qmlchart/View3.qml
index faa869c..97e2cf3 100644
--- a/demos/qmlchart/qml/qmlchart/View3.qml
+++ b/demos/qmlchart/qml/qmlchart/View3.qml
@@ -31,20 +31,20 @@ Rectangle {
legend: Chart.LegendTop
AreaSeries {
- name: "Finnish"
+ name: "Swedish"
points: [
- XyPoint { x: 0; y: 0 },
- XyPoint { x: 1; y: 0 },
- XyPoint { x: 2; y: 0 },
- XyPoint { x: 3; y: 0 },
- XyPoint { x: 4; y: 0 },
+ XyPoint { x: 0; y: 1 },
+ XyPoint { x: 1; y: 1 },
+ XyPoint { x: 2; y: 3 },
+ XyPoint { x: 3; y: 3 },
+ XyPoint { x: 4; y: 2 },
XyPoint { x: 5; y: 0 },
- XyPoint { x: 6; y: 1 },
- XyPoint { x: 7; y: 0 },
- XyPoint { x: 8; y: 0 },
- XyPoint { x: 9; y: 0 },
- XyPoint { x: 10; y: 0 },
- XyPoint { x: 11; y: 1 }
+ XyPoint { x: 6; y: 2 },
+ XyPoint { x: 7; y: 1 },
+ XyPoint { x: 8; y: 2 },
+ XyPoint { x: 9; y: 1 },
+ XyPoint { x: 10; y: 3 },
+ XyPoint { x: 11; y: 3 }
]
lowerPoints: [
XyPoint { x: 0; y: 0 },
@@ -95,20 +95,20 @@ Rectangle {
}
AreaSeries {
- name: "Swedish"
+ name: "Finnish"
points: [
- XyPoint { x: 0; y: 1 },
- XyPoint { x: 1; y: 1 },
- XyPoint { x: 2; y: 3 },
- XyPoint { x: 3; y: 3 },
- XyPoint { x: 4; y: 2 },
+ XyPoint { x: 0; y: 0 },
+ XyPoint { x: 1; y: 0 },
+ XyPoint { x: 2; y: 0 },
+ XyPoint { x: 3; y: 0 },
+ XyPoint { x: 4; y: 0 },
XyPoint { x: 5; y: 0 },
- XyPoint { x: 6; y: 2 },
- XyPoint { x: 7; y: 1 },
- XyPoint { x: 8; y: 2 },
- XyPoint { x: 9; y: 1 },
- XyPoint { x: 10; y: 3 },
- XyPoint { x: 11; y: 3 }
+ XyPoint { x: 6; y: 1 },
+ XyPoint { x: 7; y: 0 },
+ XyPoint { x: 8; y: 0 },
+ XyPoint { x: 9; y: 0 },
+ XyPoint { x: 10; y: 0 },
+ XyPoint { x: 11; y: 1 }
]
lowerPoints: [
XyPoint { x: 0; y: 0 },
diff --git a/demos/qmlchart/qml/qmlchart/main.qml b/demos/qmlchart/qml/qmlchart/main.qml
index 0db7f73..fe4efbe 100644
--- a/demos/qmlchart/qml/qmlchart/main.qml
+++ b/demos/qmlchart/qml/qmlchart/main.qml
@@ -40,7 +40,7 @@ Rectangle {
Loader {
id: loader
anchors.fill: parent
- source: "View" + (__viewNumber % 4 + 1) + ".qml";
+ source: "View" + (__viewNumber % 5 + 1) + ".qml";
}
MouseArea {
diff --git a/demos/qmlchart/resources.qrc b/demos/qmlchart/resources.qrc
index 82eb434..44c623e 100644
--- a/demos/qmlchart/resources.qrc
+++ b/demos/qmlchart/resources.qrc
@@ -6,5 +6,6 @@
qml/qmlchart/View2.qml
qml/qmlchart/View3.qml
qml/qmlchart/View4.qml
+ qml/qmlchart/View5.qml
diff --git a/qmlplugin/declarativeareaseries.cpp b/qmlplugin/declarativeareaseries.cpp
index 68edbcd..86ca0c3 100644
--- a/qmlplugin/declarativeareaseries.cpp
+++ b/qmlplugin/declarativeareaseries.cpp
@@ -30,11 +30,6 @@ DeclarativeAreaSeries::DeclarativeAreaSeries(QObject *parent) :
{
}
-QAbstractSeries *DeclarativeAreaSeries::series()
-{
- return this;
-}
-
QDeclarativeListProperty DeclarativeAreaSeries::points()
{
return QDeclarativeListProperty(this, 0, &DeclarativeAreaSeries::appendPoints);
diff --git a/qmlplugin/declarativeareaseries.h b/qmlplugin/declarativeareaseries.h
index a9428f4..f2a41ab 100644
--- a/qmlplugin/declarativeareaseries.h
+++ b/qmlplugin/declarativeareaseries.h
@@ -37,7 +37,6 @@ public:
explicit DeclarativeAreaSeries(QObject *parent = 0);
public:
- QAbstractSeries *series();
QDeclarativeListProperty points();
QDeclarativeListProperty lowerPoints();
diff --git a/qmlplugin/declarativechart.cpp b/qmlplugin/declarativechart.cpp
index c58a8ee..e5d5d9c 100644
--- a/qmlplugin/declarativechart.cpp
+++ b/qmlplugin/declarativechart.cpp
@@ -19,6 +19,7 @@
****************************************************************************/
#include "declarativechart.h"
+#include "declarativepieseries.h"
#include
QTCOMMERCIALCHART_BEGIN_NAMESPACE
@@ -36,6 +37,26 @@ DeclarativeChart::~DeclarativeChart()
delete m_chart;
}
+void DeclarativeChart::childEvent(QChildEvent *event)
+{
+ if (event->type() == QEvent::ChildAdded) {
+ if (qobject_cast(event->child())) {
+ m_chart->addSeries(qobject_cast(event->child()));
+ }
+ }
+}
+
+void DeclarativeChart::componentComplete()
+{
+ foreach(QObject *child, children()) {
+ if (qobject_cast(child)) {
+ m_chart->addSeries(qobject_cast(child));
+ }
+ }
+
+ QDeclarativeItem::componentComplete();
+}
+
void DeclarativeChart::geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry)
{
Q_UNUSED(oldGeometry)
diff --git a/qmlplugin/declarativechart.h b/qmlplugin/declarativechart.h
index 9229056..9e6b656 100644
--- a/qmlplugin/declarativechart.h
+++ b/qmlplugin/declarativechart.h
@@ -53,6 +53,8 @@ public:
~DeclarativeChart();
public: // From QDeclarativeItem/QGraphicsItem
+ void childEvent(QChildEvent *event);
+ void componentComplete();
void geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry);
void paint (QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = 0);
diff --git a/qmlplugin/declarativelineseries.cpp b/qmlplugin/declarativelineseries.cpp
index 9c5934c..dd57245 100644
--- a/qmlplugin/declarativelineseries.cpp
+++ b/qmlplugin/declarativelineseries.cpp
@@ -30,11 +30,6 @@ DeclarativeLineSeries::DeclarativeLineSeries(QObject *parent) :
{
}
-QAbstractSeries *DeclarativeLineSeries::series()
-{
- return this;
-}
-
QDeclarativeListProperty DeclarativeLineSeries::points()
{
return QDeclarativeListProperty(this, 0, &DeclarativeXySeries::appendPoints);
diff --git a/qmlplugin/declarativelineseries.h b/qmlplugin/declarativelineseries.h
index 2b50631..2849c84 100644
--- a/qmlplugin/declarativelineseries.h
+++ b/qmlplugin/declarativelineseries.h
@@ -37,7 +37,6 @@ public:
explicit DeclarativeLineSeries(QObject *parent = 0);
public:
- QAbstractSeries *series();
QDeclarativeListProperty points();
};
diff --git a/qmlplugin/declarativepieseries.cpp b/qmlplugin/declarativepieseries.cpp
index 493b56e..f5f31bf 100644
--- a/qmlplugin/declarativepieseries.cpp
+++ b/qmlplugin/declarativepieseries.cpp
@@ -25,25 +25,10 @@
QTCOMMERCIALCHART_BEGIN_NAMESPACE
DeclarativePieSeries::DeclarativePieSeries(QObject *parent) :
- QPieSeries(parent),
- m_chart(0)
+ QPieSeries(parent)
{
}
-void DeclarativePieSeries::classBegin()
-{
-}
-
-void DeclarativePieSeries::componentComplete()
-{
- DeclarativeChart *declarativeChart = qobject_cast(parent());
- if (declarativeChart) {
- QChart *chart = qobject_cast(declarativeChart->m_chart);
- Q_ASSERT(chart);
- chart->addSeries(this);
- }
-}
-
QDeclarativeListProperty DeclarativePieSeries::slices()
{
return QDeclarativeListProperty(this, 0, &DeclarativePieSeries::appendSlice);
diff --git a/qmlplugin/declarativepieseries.h b/qmlplugin/declarativepieseries.h
index 131104a..bc13132 100644
--- a/qmlplugin/declarativepieseries.h
+++ b/qmlplugin/declarativepieseries.h
@@ -24,32 +24,24 @@
#include "qchartglobal.h"
#include "qpieslice.h"
#include "qpieseries.h"
-#include
+#include
QTCOMMERCIALCHART_BEGIN_NAMESPACE
class QChart;
-class DeclarativePieSeries : public QPieSeries, public QDeclarativeParserStatus
+class DeclarativePieSeries : public QPieSeries
{
Q_OBJECT
- Q_INTERFACES(QDeclarativeParserStatus)
Q_PROPERTY(QDeclarativeListProperty slices READ slices)
public:
explicit DeclarativePieSeries(QObject *parent = 0);
QDeclarativeListProperty slices();
-public: // from QDeclarativeParserStatus
- void classBegin();
- void componentComplete();
-
public Q_SLOTS:
static void appendSlice(QDeclarativeListProperty *list,
QPieSlice *element);
-
-private:
- QChart *m_chart;
};
QTCOMMERCIALCHART_END_NAMESPACE
diff --git a/qmlplugin/declarativescatterseries.cpp b/qmlplugin/declarativescatterseries.cpp
index 0376631..936fa66 100644
--- a/qmlplugin/declarativescatterseries.cpp
+++ b/qmlplugin/declarativescatterseries.cpp
@@ -30,11 +30,6 @@ DeclarativeScatterSeries::DeclarativeScatterSeries(QObject *parent) :
{
}
-QAbstractSeries *DeclarativeScatterSeries::series()
-{
- return this;
-}
-
QDeclarativeListProperty DeclarativeScatterSeries::points()
{
return QDeclarativeListProperty(this, 0, &DeclarativeXySeries::appendPoints);
diff --git a/qmlplugin/declarativescatterseries.h b/qmlplugin/declarativescatterseries.h
index 7471052..ba6ffa7 100644
--- a/qmlplugin/declarativescatterseries.h
+++ b/qmlplugin/declarativescatterseries.h
@@ -37,7 +37,6 @@ public:
explicit DeclarativeScatterSeries(QObject *parent = 0);
public:
- QAbstractSeries *series();
QDeclarativeListProperty points();
};
diff --git a/qmlplugin/declarativesplineseries.cpp b/qmlplugin/declarativesplineseries.cpp
index 41648f2..c6753c0 100644
--- a/qmlplugin/declarativesplineseries.cpp
+++ b/qmlplugin/declarativesplineseries.cpp
@@ -29,11 +29,6 @@ DeclarativeSplineSeries::DeclarativeSplineSeries(QObject *parent) :
{
}
-QAbstractSeries *DeclarativeSplineSeries::series()
-{
- return this;
-}
-
QDeclarativeListProperty DeclarativeSplineSeries::points()
{
return QDeclarativeListProperty(this, 0, &DeclarativeXySeries::appendPoints);
diff --git a/qmlplugin/declarativesplineseries.h b/qmlplugin/declarativesplineseries.h
index 344ff27..a3bfc1a 100644
--- a/qmlplugin/declarativesplineseries.h
+++ b/qmlplugin/declarativesplineseries.h
@@ -37,7 +37,6 @@ public:
explicit DeclarativeSplineSeries(QObject *parent = 0);
public:
- QAbstractSeries *series();
QDeclarativeListProperty points();
};
diff --git a/qmlplugin/declarativexyseries.cpp b/qmlplugin/declarativexyseries.cpp
index 09651cd..f673102 100644
--- a/qmlplugin/declarativexyseries.cpp
+++ b/qmlplugin/declarativexyseries.cpp
@@ -33,22 +33,6 @@ DeclarativeXySeries::~DeclarativeXySeries()
{
}
-void DeclarativeXySeries::classBegin()
-{
-}
-
-void DeclarativeXySeries::componentComplete()
-{
- QAbstractSeries *thisObj = reinterpret_cast(series());
- DeclarativeChart *declarativeChart = qobject_cast(thisObj->parent());
-
- if (declarativeChart) {
- QChart *chart = qobject_cast(declarativeChart->m_chart);
- Q_ASSERT(chart);
- chart->addSeries(thisObj);
- }
-}
-
void DeclarativeXySeries::appendPoints(QDeclarativeListProperty *list,
DeclarativeXyPoint *element)
{
diff --git a/qmlplugin/declarativexyseries.h b/qmlplugin/declarativexyseries.h
index b9174e2..7372140 100644
--- a/qmlplugin/declarativexyseries.h
+++ b/qmlplugin/declarativexyseries.h
@@ -23,7 +23,6 @@
#include "qchartglobal.h"
#include "declarativexypoint.h"
-#include
#include
QTCOMMERCIALCHART_BEGIN_NAMESPACE
@@ -31,7 +30,7 @@ QTCOMMERCIALCHART_BEGIN_NAMESPACE
class QChart;
class QAbstractSeries;
-class DeclarativeXySeries : public QDeclarativeParserStatus
+class DeclarativeXySeries
{
Q_INTERFACES(QDeclarativeParserStatus)
@@ -39,12 +38,7 @@ public:
explicit DeclarativeXySeries();
~DeclarativeXySeries();
-public: // from QDeclarativeParserStatus
- virtual void classBegin();
- virtual void componentComplete();
-
public:
- virtual QAbstractSeries *series() = 0;
virtual QDeclarativeListProperty points() = 0;
public Q_SLOTS: