From 873325dbfe57660621ccf855c317fbb7a4880db9 2012-06-20 07:33:13 From: Tero Ahola Date: 2012-06-20 07:33:13 Subject: [PATCH] QML api pie slice added/removed signals --- diff --git a/plugins/declarative/declarativepieseries.cpp b/plugins/declarative/declarativepieseries.cpp index 6d47259..10b1008 100644 --- a/plugins/declarative/declarativepieseries.cpp +++ b/plugins/declarative/declarativepieseries.cpp @@ -30,6 +30,8 @@ QTCOMMERCIALCHART_BEGIN_NAMESPACE DeclarativePieSeries::DeclarativePieSeries(QObject *parent) : QPieSeries(parent) { + connect(this, SIGNAL(added(QList)), this, SLOT(handleAdded(QList))); + connect(this, SIGNAL(removed(QList)), this, SLOT(handleRemoved(QList))); } void DeclarativePieSeries::classBegin() @@ -66,7 +68,7 @@ void DeclarativePieSeries::appendSeriesChildren(QDeclarativeListProperty sliceList = slices(); - if (index < sliceList.count()) + if (index >= 0 && index < sliceList.count()) return sliceList[index]; return 0; @@ -91,6 +93,31 @@ QPieSlice* DeclarativePieSeries::append(QString label, qreal value) return slice; } +bool DeclarativePieSeries::remove(int index) +{ + QPieSlice *slice = at(index); + if (slice) + return QPieSeries::remove(slice); + return false; +} + +void DeclarativePieSeries::clear() +{ + QPieSeries::clear(); +} + +void DeclarativePieSeries::handleAdded(QList slices) +{ + foreach(QPieSlice *slice, slices) + emit sliceAdded(slice); +} + +void DeclarativePieSeries::handleRemoved(QList slices) +{ + foreach(QPieSlice *slice, slices) + emit sliceRemoved(slice); +} + #include "moc_declarativepieseries.cpp" QTCOMMERCIALCHART_END_NAMESPACE diff --git a/plugins/declarative/declarativepieseries.h b/plugins/declarative/declarativepieseries.h index 5b31268..eae14a5 100644 --- a/plugins/declarative/declarativepieseries.h +++ b/plugins/declarative/declarativepieseries.h @@ -45,13 +45,21 @@ public: Q_INVOKABLE QPieSlice *at(int index); Q_INVOKABLE QPieSlice *find(QString label); Q_INVOKABLE QPieSlice *append(QString label, qreal value); + Q_INVOKABLE bool remove(int index); + Q_INVOKABLE void clear(); public: void classBegin(); void componentComplete(); +Q_SIGNALS: + void sliceAdded(QPieSlice* slice); + void sliceRemoved(QPieSlice* slice); + public Q_SLOTS: static void appendSeriesChildren(QDeclarativeListProperty *list, QObject *element); + void handleAdded(QList slices); + void handleRemoved(QList slices); }; QTCOMMERCIALCHART_END_NAMESPACE diff --git a/src/piechart/qpieseries.cpp b/src/piechart/qpieseries.cpp index 2550c41..1b80f80 100644 --- a/src/piechart/qpieseries.cpp +++ b/src/piechart/qpieseries.cpp @@ -172,14 +172,20 @@ QTCOMMERCIALCHART_BEGIN_NAMESPACE \sa append(), insert() */ +/*! + \qmlsignal PieSeries::added(PieSlice slice) + Emitted when \a slice has been added to the series. +*/ /*! \fn void QPieSeries::removed(QList slices) - This signal is emitted when \a slices have been removed from the series. - \sa remove() */ +/*! + \qmlsignal PieSeries::removed(PieSlice slice) + Emitted when \a slice has been removed from the series. +*/ /*! \fn void QPieSeries::clicked(QPieSlice* slice) diff --git a/tests/qmlchartproperties/qml/qmlchartproperties/AreaChart.qml b/tests/qmlchartproperties/qml/qmlchartproperties/AreaChart.qml index 111f036..f21388a 100644 --- a/tests/qmlchartproperties/qml/qmlchartproperties/AreaChart.qml +++ b/tests/qmlchartproperties/qml/qmlchartproperties/AreaChart.qml @@ -27,13 +27,11 @@ ChartView { axisXLabels: ["0", "2000", "1", "2001", "2", "2002", "3", "2003", "4", "2004", "5", "2005", "6", "2006", "7", "2007", "8", "2008", "9", "2009", "10", "2010", "11", "2011"] - property variant series: daSeries + property variant series: areaSeries AreaSeries { - id: daSeries + id: areaSeries name: "area 1" - onSelected: console.log("areaSeries.onSelected"); - onClicked: console.log("areaSeries.onClicked: " + point.x + ", " + point.y); upperSeries: LineSeries { XyPoint { x: 0; y: 1 } XyPoint { x: 1; y: 1 } @@ -62,5 +60,13 @@ ChartView { XyPoint { x: 10; y: 0 } XyPoint { x: 11; y: 0 } } + + onNameChanged: console.log("areaSeries.onNameChanged: " + name); + onVisibleChanged: console.log("areaSeries.onVisibleChanged: " + visible); + onClicked: console.log("areaSeries.onClicked: " + point.x + ", " + point.y); + onSelected: console.log("areaSeries.onSelected"); + onColorChanged: console.log("areaSeries.onColorChanged: " + color); + onBorderColorChanged: console.log("areaSeries.onBorderColorChanged: " + borderColor); +// onCountChanged: console.log("areaSeries.onCountChanged: " + count); } } diff --git a/tests/qmlchartproperties/qml/qmlchartproperties/AreaEditor.qml b/tests/qmlchartproperties/qml/qmlchartproperties/AreaEditor.qml index 49e7fd6..43ad78f 100644 --- a/tests/qmlchartproperties/qml/qmlchartproperties/AreaEditor.qml +++ b/tests/qmlchartproperties/qml/qmlchartproperties/AreaEditor.qml @@ -28,24 +28,6 @@ Flow { flow: Flow.TopToBottom property variant series - onSeriesChanged: { - if (series && series.name == "area 1") { - seriesConnections.target = series; - } else { - seriesConnections.target = null; - } - } - - Connections { - id: seriesConnections - target: null - onNameChanged: console.log("series.onNameChanged: " + series.name); - onVisibleChanged: console.log("series.onVisibleChanged: " + series.visible); - onColorChanged: console.log("series.onColorChanged: " + series.color); - onBorderColorChanged: console.log("series.onBorderColorChanged: " + series.borderColor); - onCountChanged: console.log("series.onCountChanged: " + series.count); - } - Button { text: "visible" onClicked: series.visible = !series.visible; diff --git a/tests/qmlchartproperties/qml/qmlchartproperties/BarChart.qml b/tests/qmlchartproperties/qml/qmlchartproperties/BarChart.qml index f4cfcec..6d6a42d 100644 --- a/tests/qmlchartproperties/qml/qmlchartproperties/BarChart.qml +++ b/tests/qmlchartproperties/qml/qmlchartproperties/BarChart.qml @@ -28,18 +28,27 @@ ChartView { legend.alignment: Qt.AlignBottom axisXLabels: ["0", "2007", "1", "2008", "2", "2009", "3", "2010", "4", "2011", "5", "2012"] - property variant series: daSeries + property variant series: barSeries BarSeries { - id: daSeries + id: barSeries name: "bar" - onClicked: console.log("onClicked: " + barset + " " + index); - onHovered: console.log("onHovered: " + barset + " " + status); BarSet { label: "Bob"; values: [4, 7, 3, 10, 5, 6] - onClicked: console.log("barset.onClicked: " + index); - onHovered: console.log("barset.onHovered: " + status); + onClicked: console.log("barset.onClicked: " + index); + onHovered: console.log("barset.onHovered: " + status); + onColorChanged: console.log("barset.onColorChanged: " + color); + onBorderColorChanged: console.log("barset.onBorderColorChanged: " + color); + onLabelColorChanged: console.log("barset.onLabelColorChanged: " + color); + onCountChanged: console.log("barset.onCountChanged: " + count); } BarSet { label: "Susan"; values: [5, 1, 2, 4, 1, 8] } BarSet { label: "James"; values: [3, 5, 8, 5, 4, 7] } + + onNameChanged: console.log("barSeries.onNameChanged: " + series.name); + onVisibleChanged: console.log("barSeries.onVisibleChanged: " + series.visible); + onClicked: console.log("barSeries.onClicked: " + barset + " " + index); + onHovered: console.log("barSeries.onHovered: " + barset + " " + status); + onLabelsVisibleChanged: console.log("barSeries.onLabelsVisibleChanged: " + series.labelsVisible); + onCountChanged: console.log("barSeries.onCountChanged: " + count); } } diff --git a/tests/qmlchartproperties/qml/qmlchartproperties/BarEditor.qml b/tests/qmlchartproperties/qml/qmlchartproperties/BarEditor.qml index 7214fba..7f08fe2 100644 --- a/tests/qmlchartproperties/qml/qmlchartproperties/BarEditor.qml +++ b/tests/qmlchartproperties/qml/qmlchartproperties/BarEditor.qml @@ -27,34 +27,6 @@ Flow { flow: Flow.TopToBottom property variant series - onSeriesChanged: { - if (series && series.name == "bar") { - seriesConnections.target = series; - setConnections.target = series.at(0); - } else { - seriesConnections.target = null; - setConnections.target = null; - } - } - - Connections { - id: seriesConnections - target: null - onNameChanged: console.log("series.onNameChanged: " + series.name); - onVisibleChanged: console.log("series.onVisibleChanged: " + series.visible); - onLabelsVisibleChanged: console.log("series.onLabelsVisibleChanged: " + series.labelsVisible); - onCountChanged: console.log("series.onCountChanged: " + count); - } - - Connections { - id: setConnections - target: null - onColorChanged: console.log("series.onColorChanged: " + color); - onBorderColorChanged: console.log("series.onBorderColorChanged: " + color); - onLabelColorChanged: console.log("series.onLabelColorChanged: " + color); - onCountChanged: console.log("series.onCountChanged: " + count); - } - Button { text: "visible" onClicked: series.visible = !series.visible; diff --git a/tests/qmlchartproperties/qml/qmlchartproperties/Chart.qml b/tests/qmlchartproperties/qml/qmlchartproperties/Chart.qml index 6963ee6..c34b294 100644 --- a/tests/qmlchartproperties/qml/qmlchartproperties/Chart.qml +++ b/tests/qmlchartproperties/qml/qmlchartproperties/Chart.qml @@ -37,4 +37,36 @@ ChartView { XyPoint { x: 3.4; y: 3.0 } XyPoint { x: 4.1; y: 3.3 } } + + onVisibleChanged: console.log("chart.onVisibleChanged: " + series.visible); + onTitleColorChanged: console.log("chart.onTitleColorChanged: " + series.titleColor); + onBackgroundColorChanged: console.log("chart.onBackgroundColorChanged: " + series.backgroundColor); + onDropShadowEnabledChanged: console.log("chart.onDropShadowEnabledChanged: " + enabled); + + legend.onVisibleChanged: console.log("legend.onVisibleChanged: " + series.legend.visible); + legend.onBackgroundVisibleChanged: console.log("legend.onBackgroundVisibleChanged: " + visible); + legend.onColorChanged: console.log("legend.onColorChanged: " + color); + legend.onBorderColorChanged: console.log("legend.onBorderColorChanged: " + color); + + axisX.onColorChanged: console.log("axisX.onColorChanged: " + color); + axisX.onLabelsVisibleChanged: console.log("axisX.onLabelsVisibleChanged: " + visible); + axisX.onLabelsColorChanged: console.log("axisX.onLabelsColorChanged: " + color); + axisX.onVisibleChanged: console.log("axisX.onVisibleChanged: " + visible); + axisX.onGridVisibleChanged: console.log("axisX.onGridVisibleChanged: " + visible); + axisX.onShadesVisibleChanged: console.log("axisX.onShadesVisibleChanged: " + visible); + axisX.onShadesColorChanged: console.log("axisX.onShadesColorChanged: " + color); + axisX.onShadesBorderColorChanged: console.log("axisX.onShadesBorderColorChanged: " + color); + axisX.onMinChanged: console.log("axisX.onMinChanged: " + min); + axisX.onMaxChanged: console.log("axisX.onMaxChanged: " + max); + + axisY.onColorChanged: console.log("axisY.onColorChanged: " + color); + axisY.onLabelsVisibleChanged: console.log("axisY.onLabelsVisibleChanged: " + visible); + axisY.onLabelsColorChanged: console.log("axisY.onLabelsColorChanged: " + color); + axisY.onVisibleChanged: console.log("axisY.onVisibleChanged: " + visible); + axisY.onGridVisibleChanged: console.log("axisY.onGridVisibleChanged: " + visible); + axisY.onShadesVisibleChanged: console.log("axisY.onShadesVisibleChanged: " + visible); + axisY.onShadesColorChanged: console.log("axisY.onShadesColorChanged: " + color); + axisY.onShadesBorderColorChanged: console.log("axisY.onShadesBorderColorChanged: " + color); + axisY.onMinChanged: console.log("axisY.onMinChanged: " + min); + axisY.onMaxChanged: console.log("axisY.onMaxChanged: " + max); } diff --git a/tests/qmlchartproperties/qml/qmlchartproperties/ChartEditor.qml b/tests/qmlchartproperties/qml/qmlchartproperties/ChartEditor.qml index 1084a20..50fb696 100644 --- a/tests/qmlchartproperties/qml/qmlchartproperties/ChartEditor.qml +++ b/tests/qmlchartproperties/qml/qmlchartproperties/ChartEditor.qml @@ -28,67 +28,6 @@ Flow { flow: Flow.TopToBottom property variant series // TODO: rename to chart - onSeriesChanged: { - if (series && series.name == "") { - chartConnections.target = series; - legendConnections.target = series.legend; - axisXConnections.target = series.axisX; - axisYConnections.target = series.axisY; - } else { - legendConnections.target = null; - axisXConnections.target = null; - axisYConnections.target = null; - } - } - - Connections { - id: chartConnections - target: null - onVisibleChanged: console.log("chart.onVisibleChanged: " + series.visible); - onTitleColorChanged: console.log("chart.onTitleColorChanged: " + series.titleColor); - onBackgroundColorChanged: console.log("chart.onBackgroundColorChanged: " + series.backgroundColor); - onDropShadowEnabledChanged: console.log("chart.onDropShadowEnabledChanged: " + enabled); - } - - Connections { - id: legendConnections - target: null - onVisibleChanged: console.log("legend.onVisibleChanged: " + series.legend.visible); - onBackgroundVisibleChanged: console.log("legend.onBackgroundVisibleChanged: " + visible); - onColorChanged: console.log("legend.onColorChanged: " + color); - onBorderColorChanged: console.log("legend.onBorderColorChanged: " + color); - } - - Connections { - id: axisXConnections - target: null - onColorChanged: console.log("axisX.onColorChanged: " + color); - onLabelsVisibleChanged: console.log("axisX.onLabelsVisibleChanged: " + visible); - onLabelsColorChanged: console.log("axisX.onLabelsColorChanged: " + color); - onVisibleChanged: console.log("axisX.onVisibleChanged: " + visible); - onGridVisibleChanged: console.log("axisX.onGridVisibleChanged: " + visible); - onShadesVisibleChanged: console.log("axisX.onShadesVisibleChanged: " + visible); - onShadesColorChanged: console.log("axisX.onShadesColorChanged: " + color); - onShadesBorderColorChanged: console.log("axisX.onShadesBorderColorChanged: " + color); - onMinChanged: console.log("axisX.onMinChanged: " + min); - onMaxChanged: console.log("axisX.onMaxChanged: " + max); - } - - Connections { - id: axisYConnections - target: null - onColorChanged: console.log("axisY.onColorChanged: " + color); - onLabelsVisibleChanged: console.log("axisY.onLabelsVisibleChanged: " + visible); - onLabelsColorChanged: console.log("axisY.onLabelsColorChanged: " + color); - onVisibleChanged: console.log("axisY.onVisibleChanged: " + visible); - onGridVisibleChanged: console.log("axisY.onGridVisibleChanged: " + visible); - onShadesVisibleChanged: console.log("axisY.onShadesVisibleChanged: " + visible); - onShadesColorChanged: console.log("axisY.onShadesColorChanged: " + color); - onShadesBorderColorChanged: console.log("axisY.onShadesBorderColorChanged: " + color); - onMinChanged: console.log("axisY.onMinChanged: " + min); - onMaxChanged: console.log("axisY.onMaxChanged: " + max); - } - Button { text: "visible" onClicked: series.visible = !series.visible; diff --git a/tests/qmlchartproperties/qml/qmlchartproperties/GroupedBarChart.qml b/tests/qmlchartproperties/qml/qmlchartproperties/GroupedBarChart.qml index a0c6c0c..c34cd8d 100644 --- a/tests/qmlchartproperties/qml/qmlchartproperties/GroupedBarChart.qml +++ b/tests/qmlchartproperties/qml/qmlchartproperties/GroupedBarChart.qml @@ -28,15 +28,27 @@ ChartView { legend.alignment: Qt.AlignBottom axisXLabels: ["0", "2007", "1", "2008", "2", "2009", "3", "2010", "4", "2011", "5", "2012"] - property variant series: daSeries + property variant series: barSeries GroupedBarSeries { - id: daSeries + id: barSeries name: "bar" - onClicked: console.log("onClicked: " + barset + " " + index); - onHovered: console.log("onHovered: " + barset + " " + status); - BarSet { label: "Bob"; values: [2, 2, 3, 4, 5, 6] } + BarSet { label: "Bob"; values: [2, 2, 3, 4, 5, 6] + onClicked: console.log("barset.onClicked: " + index); + onHovered: console.log("barset.onHovered: " + status); + onColorChanged: console.log("barset.onColorChanged: " + color); + onBorderColorChanged: console.log("barset.onBorderColorChanged: " + color); + onLabelColorChanged: console.log("barset.onLabelColorChanged: " + color); + onCountChanged: console.log("barset.onCountChanged: " + count); + } BarSet { label: "Susan"; values: [5, 1, 2, 4, 1, 7] } BarSet { label: "James"; values: [3, 5, 8, 13, 5, 8] } + + onNameChanged: console.log("groupedBarSeries.onNameChanged: " + series.name); + onVisibleChanged: console.log("groupedBarSeries.onVisibleChanged: " + series.visible); + onClicked: console.log("groupedBarSeries.onClicked: " + barset + " " + index); + onHovered: console.log("groupedBarSeries.onHovered: " + barset + " " + status); + onLabelsVisibleChanged: console.log("groupedBarSeries.onLabelsVisibleChanged: " + series.labelsVisible); + onCountChanged: console.log("groupedBarSeries.onCountChanged: " + count); } } diff --git a/tests/qmlchartproperties/qml/qmlchartproperties/LineChart.qml b/tests/qmlchartproperties/qml/qmlchartproperties/LineChart.qml index 5b38ea2..92a4031 100644 --- a/tests/qmlchartproperties/qml/qmlchartproperties/LineChart.qml +++ b/tests/qmlchartproperties/qml/qmlchartproperties/LineChart.qml @@ -22,15 +22,14 @@ import QtQuick 1.0 import QtCommercial.Chart 1.0 ChartView { + property variant series: lineSeries + title: "line series" anchors.fill: parent - property variant series: daSeries - LineSeries { - id: daSeries + id: lineSeries name: "line 1" - onClicked: console.log("onClicked: " + point.x + ", " + point.y); XyPoint { x: 0; y: 0 } XyPoint { x: 1.1; y: 2.1 } XyPoint { x: 1.9; y: 3.3 } @@ -38,6 +37,15 @@ ChartView { XyPoint { x: 2.9; y: 4.9 } XyPoint { x: 3.4; y: 3.0 } XyPoint { x: 4.1; y: 3.3 } + + onNameChanged: console.log("lineSeries.onNameChanged: " + name); + onVisibleChanged: console.log("lineSeries.onVisibleChanged: " + visible); + onClicked: console.log("lineSeries.onClicked: " + point.x + ", " + point.y); + onPointReplaced: console.log("lineSeries.onPointReplaced: " + index); + onPointRemoved: console.log("lineSeries.onPointRemoved: " + index); + onPointAdded: console.log("lineSeries.onPointAdded: " + index); + onColorChanged: console.log("lineSeries.onColorChanged: " + color); + onCountChanged: console.log("lineSeries.onCountChanged: " + count); } LineSeries { diff --git a/tests/qmlchartproperties/qml/qmlchartproperties/LineEditor.qml b/tests/qmlchartproperties/qml/qmlchartproperties/LineEditor.qml index 71e1d52..f4243f4 100644 --- a/tests/qmlchartproperties/qml/qmlchartproperties/LineEditor.qml +++ b/tests/qmlchartproperties/qml/qmlchartproperties/LineEditor.qml @@ -28,23 +28,6 @@ Flow { flow: Flow.TopToBottom property variant series - onSeriesChanged: { - if (series && (series.name == "line 1" || series.name == "spline 1")) { - seriesConnections.target = series; - } else { - seriesConnections.target = null; - } - } - - Connections { - id: seriesConnections - target: null - onNameChanged: console.log("series.onNameChanged: " + series.name); - onVisibleChanged: console.log("series.onVisibleChanged: " + series.visible); - onColorChanged: console.log("series.onColorChanged: " + series.color); - onCountChanged: console.log("series.onCountChanged: " + series.count); - } - Button { text: "visible" onClicked: series.visible = !series.visible; diff --git a/tests/qmlchartproperties/qml/qmlchartproperties/PercentBarChart.qml b/tests/qmlchartproperties/qml/qmlchartproperties/PercentBarChart.qml index 5baecb4..6f27e97 100644 --- a/tests/qmlchartproperties/qml/qmlchartproperties/PercentBarChart.qml +++ b/tests/qmlchartproperties/qml/qmlchartproperties/PercentBarChart.qml @@ -28,15 +28,27 @@ ChartView { legend.alignment: Qt.AlignBottom axisXLabels: ["0", "2007", "1", "2008", "2", "2009", "3", "2010", "4", "2011", "5", "2012"] - property variant series: daSeries + property variant series: barSeries PercentBarSeries { - id: daSeries + id: barSeries name: "bar" - onClicked: console.log("onClicked: " + barset + " " + index); - onHovered: console.log("onHovered: " + barset + " " + status); - BarSet { label: "Bob"; values: [2, 2, 3, 4, 5, 6] } + BarSet { label: "Bob"; values: [2, 2, 3, 4, 5, 6] + onClicked: console.log("barset.onClicked: " + index); + onHovered: console.log("barset.onHovered: " + status); + onColorChanged: console.log("barset.onColorChanged: " + color); + onBorderColorChanged: console.log("barset.onBorderColorChanged: " + color); + onLabelColorChanged: console.log("barset.onLabelColorChanged: " + color); + onCountChanged: console.log("barset.onCountChanged: " + count); + } BarSet { label: "Susan"; values: [5, 1, 2, 4, 1, 7] } BarSet { label: "James"; values: [3, 5, 8, 13, 5, 8] } + + onNameChanged: console.log("percentBarSeries.onNameChanged: " + series.name); + onVisibleChanged: console.log("percentBarSeries.onVisibleChanged: " + series.visible); + onClicked: console.log("percentBarSeries.onClicked: " + barset + " " + index); + onHovered: console.log("percentBarSeries.onHovered: " + barset + " " + status); + onLabelsVisibleChanged: console.log("percentBarSeries.onLabelsVisibleChanged: " + series.labelsVisible); + onCountChanged: console.log("percentBarSeries.onCountChanged: " + count); } } diff --git a/tests/qmlchartproperties/qml/qmlchartproperties/PieChart.qml b/tests/qmlchartproperties/qml/qmlchartproperties/PieChart.qml index 2a49732..0c6b181 100644 --- a/tests/qmlchartproperties/qml/qmlchartproperties/PieChart.qml +++ b/tests/qmlchartproperties/qml/qmlchartproperties/PieChart.qml @@ -31,8 +31,36 @@ ChartView { PieSeries { id: pieSeries name: "pie" - PieSlice { label: "slice1"; value: 11 } + PieSlice { label: "slice1"; value: 11; + onValueChanged: console.log("slice.onValueChanged: " + value); + onLabelVisibleChanged: console.log("slice.onLabelVisibleChanged: " + labelVisible); + onPenChanged: console.log("slice.onPenChanged: " + pen); + onBorderColorChanged: console.log("slice.onBorderColorChanged: " + borderColor); + onBorderWidthChanged: console.log("slice.onBorderWidthChanged: " + borderWidth); + onBrushChanged: console.log("slice.onBrushChanged: " + brush); + onColorChanged: console.log("slice.onColorChanged: " + color); + onLabelColorChanged: console.log("slice.onLabelColorChanged: " + labelColor); + onLabelBrushChanged: console.log("slice.onLabelBrushChanged: " + labelBrush); + onLabelFontChanged: console.log("slice.onLabelFontChanged: " + labelFont); + onPercentageChanged: console.log("slice.onPercentageChanged: " + percentage); + onStartAngleChanged: console.log("slice.onStartAngleChanged: " + startAngle); + onAngleSpanChanged: console.log("slice.onAngleSpanChanged: " + angleSpan); + onClicked: console.log("slice.onClicked: " + label); + onHovered: console.log("slice.onHovered: " + state); + } PieSlice { label: "slice2"; value: 22 } PieSlice { label: "slice3"; value: 33 } + PieSlice { label: "slice4"; value: 44 } + + onNameChanged: console.log("pieSeries.onNameChanged: " + series.name); + onVisibleChanged: console.log("pieSeries.onVisibleChanged: " + series.visible); + onClicked: console.log("pieSeries.onClicked: " + slice.label); + onHovered: console.log("pieSeries.onHovered: " + slice.label); + onAdded: console.log("pieSeries.onAdded: " + slices); + onSliceAdded: console.log("pieSeries.onSliceAdded: " + slice.label); + onRemoved: console.log("pieSeries.onRemoved: " + slices); + onSliceRemoved: console.log("pieSeries.onSliceRemoved: " + slice.label); + onCountChanged: console.log("pieSeries.onCountChanged: " + series.count); + onSumChanged: console.log("pieSeries.onSumChanged: " + series.sum); } } diff --git a/tests/qmlchartproperties/qml/qmlchartproperties/PieEditor.qml b/tests/qmlchartproperties/qml/qmlchartproperties/PieEditor.qml index bcbd3b9..a75dd12 100644 --- a/tests/qmlchartproperties/qml/qmlchartproperties/PieEditor.qml +++ b/tests/qmlchartproperties/qml/qmlchartproperties/PieEditor.qml @@ -27,44 +27,6 @@ Flow { flow: Flow.TopToBottom property variant series - onSeriesChanged: { - if (series && series.name == "pie") { - seriesConnections.target = series; - sliceConnections.target = series.at(0); - } else { - seriesConnections.target = null; - sliceConnections.target = null; - } - } - - Connections { - id: seriesConnections - target: null - onVisibleChanged: console.log("series.onVisibleChanged: " + series.visible); - onCountChanged: console.log("series.onCountChanged: " + series.count); - onSumChanged: console.log("series.onSumChanged: " + series.sum); - } - - Connections { - id: sliceConnections - target: null - onValueChanged: console.log("slice.onValueChanged: " + series.at(0).value); - onLabelVisibleChanged: console.log("slice.onLabelVisibleChanged: " + series.at(0).labelVisible); - onPenChanged: console.log("slice.onPenChanged: " + series.at(0).pen); - onBorderColorChanged: console.log("slice.onBorderColorChanged: " + series.at(0).borderColor); - onBorderWidthChanged: console.log("slice.onBorderWidthChanged: " + series.at(0).borderWidth); - onBrushChanged: console.log("slice.onBrushChanged: " + series.at(0).brush); - onColorChanged: console.log("slice.onColorChanged: " + series.at(0).color); - onLabelColorChanged: console.log("slice.onLabelColorChanged: " + series.at(0).labelColor); - onLabelBrushChanged: console.log("slice.onLabelBrushChanged: " + series.at(0).labelBrush); - onLabelFontChanged: console.log("slice.onLabelFontChanged: " + series.at(0).labelFont); - onPercentageChanged: console.log("slice.onPercentageChanged: " + series.at(0).percentage); - onStartAngleChanged: console.log("slice.onStartAngleChanged: " + series.at(0).startAngle); - onAngleSpanChanged: console.log("slice.onAngleSpanChanged: " + series.at(0).angleSpan); - onClicked: console.log("slice.onClicked"); - onHovered: console.log("slice.onHovered: " + state); - } - Button { text: "visible" onClicked: series.visible = !series.visible; @@ -110,6 +72,10 @@ Flow { onClicked: series.endAngle -= 1.1; } Button { + text: "remove slice" + onClicked: series.remove(series.count - 1); + } + Button { text: "slice color" onClicked: series.at(0).color = main.nextColor(); } diff --git a/tests/qmlchartproperties/qml/qmlchartproperties/ScatterChart.qml b/tests/qmlchartproperties/qml/qmlchartproperties/ScatterChart.qml index d5251dc..8fb58e4 100644 --- a/tests/qmlchartproperties/qml/qmlchartproperties/ScatterChart.qml +++ b/tests/qmlchartproperties/qml/qmlchartproperties/ScatterChart.qml @@ -25,10 +25,10 @@ ChartView { title: "scatter series" axisX.max: 4 axisY.max: 4 - property variant series: daSeries + property variant series: scatterSeries ScatterSeries { - id: daSeries + id: scatterSeries name: "scatter 1" XyPoint { x: 1.5; y: 1.5 } XyPoint { x: 1.5; y: 1.6 } @@ -37,6 +37,12 @@ ChartView { XyPoint { x: 1.9; y: 1.6 } XyPoint { x: 2.1; y: 1.3 } XyPoint { x: 2.5; y: 2.1 } + + onNameChanged: console.log("scatterSeries.onNameChanged: " + name); + onVisibleChanged: console.log("scatterSeries.onVisibleChanged: " + visible); + onColorChanged: console.log("scatterSeries.onColorChanged: " + color); + onBorderColorChanged: console.log("scatterSeries.onBorderColorChanged: " + borderColor); + onCountChanged: console.log("scatterSeries.onCountChanged: " + count); } ScatterSeries { diff --git a/tests/qmlchartproperties/qml/qmlchartproperties/ScatterEditor.qml b/tests/qmlchartproperties/qml/qmlchartproperties/ScatterEditor.qml index fbd10da..05d8341 100644 --- a/tests/qmlchartproperties/qml/qmlchartproperties/ScatterEditor.qml +++ b/tests/qmlchartproperties/qml/qmlchartproperties/ScatterEditor.qml @@ -28,24 +28,6 @@ Flow { flow: Flow.TopToBottom property variant series - onSeriesChanged: { - if (series && series.name == "scatter 1") { - seriesConnections.target = series; - } else { - seriesConnections.target = null; - } - } - - Connections { - id: seriesConnections - target: null - onNameChanged: console.log("series.onNameChanged: " + series.name); - onVisibleChanged: console.log("series.onVisibleChanged: " + series.visible); - onColorChanged: console.log("series.onColorChanged: " + series.color); - onBorderColorChanged: console.log("series.onBorderColorChanged: " + series.borderColor); - onCountChanged: console.log("series.onCountChanged: " + series.count); - } - Button { text: "visible" onClicked: series.visible = !series.visible; diff --git a/tests/qmlchartproperties/qml/qmlchartproperties/SplineChart.qml b/tests/qmlchartproperties/qml/qmlchartproperties/SplineChart.qml index 07881b1..7c9ced9 100644 --- a/tests/qmlchartproperties/qml/qmlchartproperties/SplineChart.qml +++ b/tests/qmlchartproperties/qml/qmlchartproperties/SplineChart.qml @@ -24,10 +24,10 @@ import QtCommercial.Chart 1.0 ChartView { title: "spline series" anchors.fill: parent - property variant series: daSeries + property variant series: splineSeries SplineSeries { - id: daSeries + id: splineSeries name: "spline 1" XyPoint { x: 0; y: 0 } XyPoint { x: 1.1; y: 2.1 } @@ -36,6 +36,15 @@ ChartView { XyPoint { x: 2.9; y: 4.9 } XyPoint { x: 3.4; y: 3.0 } XyPoint { x: 4.1; y: 3.3 } + + onNameChanged: console.log("splineSeries.onNameChanged: " + name); + onVisibleChanged: console.log("splineSeries.onVisibleChanged: " + visible); + onClicked: console.log("splineSeries.onClicked: " + point.x + ", " + point.y); + onPointReplaced: console.log("splineSeries.onPointReplaced: " + index); + onPointRemoved: console.log("splineSeries.onPointRemoved: " + index); + onPointAdded: console.log("splineSeries.onPointAdded: " + index); + onColorChanged: console.log("splineSeries.onColorChanged: " + color); + onCountChanged: console.log("splineSeries.onCountChanged: " + count); } SplineSeries { diff --git a/tests/qmlchartproperties/qml/qmlchartproperties/StackedBarChart.qml b/tests/qmlchartproperties/qml/qmlchartproperties/StackedBarChart.qml index aed0047..6738a04 100644 --- a/tests/qmlchartproperties/qml/qmlchartproperties/StackedBarChart.qml +++ b/tests/qmlchartproperties/qml/qmlchartproperties/StackedBarChart.qml @@ -28,15 +28,27 @@ ChartView { legend.alignment: Qt.AlignBottom axisXLabels: ["0", "2007", "1", "2008", "2", "2009", "3", "2010", "4", "2011", "5", "2012"] - property variant series: daSeries + property variant series: barSeries StackedBarSeries { - id: daSeries + id: barSeries name: "bar" - onClicked: console.log("onClicked: " + barset + " " + index); - onHovered: console.log("onHovered: " + barset + " " + status); - BarSet { label: "Bob"; values: [2, 2, 3, 4, 5, 6] } + BarSet { label: "Bob"; values: [2, 2, 3, 4, 5, 6] + onClicked: console.log("barset.onClicked: " + index); + onHovered: console.log("barset.onHovered: " + status); + onColorChanged: console.log("barset.onColorChanged: " + color); + onBorderColorChanged: console.log("barset.onBorderColorChanged: " + color); + onLabelColorChanged: console.log("barset.onLabelColorChanged: " + color); + onCountChanged: console.log("barset.onCountChanged: " + count); + } BarSet { label: "Susan"; values: [5, 1, 2, 4, 1, 7] } BarSet { label: "James"; values: [3, 5, 8, 13, 5, 8] } + + onNameChanged: console.log("stackedBarSeries.onNameChanged: " + series.name); + onVisibleChanged: console.log("stackedBarSeries.onVisibleChanged: " + series.visible); + onClicked: console.log("stackedBarSeries.onClicked: " + barset + " " + index); + onHovered: console.log("stackedBarSeries.onHovered: " + barset + " " + status); + onLabelsVisibleChanged: console.log("stackedBarSeries.onLabelsVisibleChanged: " + series.labelsVisible); + onCountChanged: console.log("stackedBarSeries.onCountChanged: " + count); } } diff --git a/tests/qmlchartproperties/qml/qmlchartproperties/main.qml b/tests/qmlchartproperties/qml/qmlchartproperties/main.qml index 51f13a9..43d1d66 100644 --- a/tests/qmlchartproperties/qml/qmlchartproperties/main.qml +++ b/tests/qmlchartproperties/qml/qmlchartproperties/main.qml @@ -32,7 +32,6 @@ Rectangle { function nextColor() { colorIndex++; - console.log("color: " + colors[colorIndex % colors.length]); return colors[colorIndex % colors.length]; }