From dbc1daf2590ac8086bfb96b6a10dff343463a477 2012-03-29 11:15:23 From: Tero Ahola Date: 2012-03-29 11:15:23 Subject: [PATCH] Refactoring declarative xy series --- diff --git a/qmlplugin/declarativelineseries.cpp b/qmlplugin/declarativelineseries.cpp index ccfcba9..200e0ef 100644 --- a/qmlplugin/declarativelineseries.cpp +++ b/qmlplugin/declarativelineseries.cpp @@ -10,7 +10,7 @@ DeclarativeLineSeries::DeclarativeLineSeries(QObject *parent) : { } -void DeclarativeLineSeries::seriesComplete() +void DeclarativeLineSeries::componentComplete() { DeclarativeChart *declarativeChart = qobject_cast(parent()); @@ -21,14 +21,9 @@ void DeclarativeLineSeries::seriesComplete() } } -QObject *DeclarativeLineSeries::seriesObject() -{ - return this; -} - QDeclarativeListProperty DeclarativeLineSeries::points() { - return DeclarativeXySeries::points(); + return QDeclarativeListProperty(this, 0, &DeclarativeXySeries::appendPoints); } void DeclarativeLineSeries::appendPoints(QDeclarativeListProperty *list, diff --git a/qmlplugin/declarativelineseries.h b/qmlplugin/declarativelineseries.h index 9329fb6..fc0f882 100644 --- a/qmlplugin/declarativelineseries.h +++ b/qmlplugin/declarativelineseries.h @@ -17,13 +17,10 @@ public: explicit DeclarativeLineSeries(QObject *parent = 0); public: - void seriesComplete(); - QObject *seriesObject(); - -public: + void componentComplete(); QDeclarativeListProperty points(); -public slots: +public Q_SLOTS: static void appendPoints(QDeclarativeListProperty *list, DeclarativeXyPoint *element); }; diff --git a/qmlplugin/declarativescatterseries.cpp b/qmlplugin/declarativescatterseries.cpp index c614b38..9312fe0 100644 --- a/qmlplugin/declarativescatterseries.cpp +++ b/qmlplugin/declarativescatterseries.cpp @@ -10,7 +10,7 @@ DeclarativeScatterSeries::DeclarativeScatterSeries(QObject *parent) : { } -void DeclarativeScatterSeries::seriesComplete() +void DeclarativeScatterSeries::componentComplete() { DeclarativeChart *declarativeChart = qobject_cast(parent()); @@ -22,14 +22,9 @@ void DeclarativeScatterSeries::seriesComplete() } } -QObject *DeclarativeScatterSeries::seriesObject() -{ - return this; -} - QDeclarativeListProperty DeclarativeScatterSeries::points() { - return DeclarativeXySeries::points(); + return QDeclarativeListProperty(this, 0, &DeclarativeXySeries::appendPoints); } void DeclarativeScatterSeries::appendPoints(QDeclarativeListProperty *list, diff --git a/qmlplugin/declarativescatterseries.h b/qmlplugin/declarativescatterseries.h index a2fd044..0f3d7ca 100644 --- a/qmlplugin/declarativescatterseries.h +++ b/qmlplugin/declarativescatterseries.h @@ -17,13 +17,10 @@ public: explicit DeclarativeScatterSeries(QObject *parent = 0); public: - void seriesComplete(); - QObject *seriesObject(); - -public: + void componentComplete(); QDeclarativeListProperty points(); -public slots: +public Q_SLOTS: static void appendPoints(QDeclarativeListProperty *list, DeclarativeXyPoint *element); }; diff --git a/qmlplugin/declarativesplineseries.cpp b/qmlplugin/declarativesplineseries.cpp index b5c23f3..d78fb1a 100644 --- a/qmlplugin/declarativesplineseries.cpp +++ b/qmlplugin/declarativesplineseries.cpp @@ -9,7 +9,7 @@ DeclarativeSplineSeries::DeclarativeSplineSeries(QObject *parent) : { } -void DeclarativeSplineSeries::seriesComplete() +void DeclarativeSplineSeries::componentComplete() { DeclarativeChart *declarativeChart = qobject_cast(parent()); @@ -20,14 +20,9 @@ void DeclarativeSplineSeries::seriesComplete() } } -QObject *DeclarativeSplineSeries::seriesObject() -{ - return this; -} - QDeclarativeListProperty DeclarativeSplineSeries::points() { - return DeclarativeXySeries::points(); + return QDeclarativeListProperty(this, 0, &DeclarativeXySeries::appendPoints); } void DeclarativeSplineSeries::appendPoints(QDeclarativeListProperty *list, diff --git a/qmlplugin/declarativesplineseries.h b/qmlplugin/declarativesplineseries.h index 8bc022a..ef583af 100644 --- a/qmlplugin/declarativesplineseries.h +++ b/qmlplugin/declarativesplineseries.h @@ -17,13 +17,10 @@ public: explicit DeclarativeSplineSeries(QObject *parent = 0); public: - void seriesComplete(); - QObject *seriesObject(); - -public: + virtual void componentComplete(); QDeclarativeListProperty points(); -public slots: +public Q_SLOTS: static void appendPoints(QDeclarativeListProperty *list, DeclarativeXyPoint *element); }; diff --git a/qmlplugin/declarativexyseries.cpp b/qmlplugin/declarativexyseries.cpp index b7a0b78..dd9a218 100644 --- a/qmlplugin/declarativexyseries.cpp +++ b/qmlplugin/declarativexyseries.cpp @@ -16,16 +16,6 @@ void DeclarativeXySeries::classBegin() { } -void DeclarativeXySeries::componentComplete() -{ - seriesComplete(); -} - -QDeclarativeListProperty DeclarativeXySeries::points() -{ - return QDeclarativeListProperty(seriesObject(), 0, &DeclarativeXySeries::appendPoints); -} - void DeclarativeXySeries::appendPoints(QDeclarativeListProperty *list, DeclarativeXyPoint *element) { diff --git a/qmlplugin/declarativexyseries.h b/qmlplugin/declarativexyseries.h index a981db1..78c5289 100644 --- a/qmlplugin/declarativexyseries.h +++ b/qmlplugin/declarativexyseries.h @@ -19,19 +19,15 @@ public: ~DeclarativeXySeries(); public: // from QDeclarativeParserStatus - void classBegin(); - void componentComplete(); + virtual void classBegin(); + virtual void componentComplete() = 0; public: - QDeclarativeListProperty points(); + virtual QDeclarativeListProperty points() = 0; public Q_SLOTS: static void appendPoints(QDeclarativeListProperty *list, DeclarativeXyPoint *element); - -protected: - virtual void seriesComplete() = 0; - virtual QObject *seriesObject() = 0; }; QTCOMMERCIALCHART_END_NAMESPACE