From 20fb6c76ccf26232558c721b38d0b5576b898320 2012-11-27 10:57:50 From: Tero Ahola Date: 2012-11-27 10:57:50 Subject: [PATCH] Fixed a bug in ChartView.axes property when no series added --- diff --git a/plugins/declarative/declarativechart.cpp b/plugins/declarative/declarativechart.cpp index e463538..58b0cd2 100644 --- a/plugins/declarative/declarativechart.cpp +++ b/plugins/declarative/declarativechart.cpp @@ -560,7 +560,7 @@ int DeclarativeChart::axesCountFunc(QDeclarativeListProperty *lis { if (qobject_cast(list->object)) { DeclarativeChart *chart = qobject_cast(list->object); - return chart->m_chart->axes(Qt::Horizontal | Qt::Vertical, chart->m_chart->series()[0]).count(); + return chart->m_chart->axes(Qt::Horizontal | Qt::Vertical).count(); } return 0; } diff --git a/plugins/declarative/declarativechart.h b/plugins/declarative/declarativechart.h index 52ba2ef..fec8f65 100644 --- a/plugins/declarative/declarativechart.h +++ b/plugins/declarative/declarativechart.h @@ -115,20 +115,20 @@ public: int count(); void setDropShadowEnabled(bool enabled); bool dropShadowEnabled(); + + // Margins & plotArea qreal topMargin(); qreal bottomMargin(); qreal leftMargin(); qreal rightMargin(); - QAbstractAxis *defaultAxis(Qt::Orientation orientation, QAbstractSeries *series); - void initializeAxes(QAbstractSeries *series); - void doInitializeAxes(QAbstractSeries *series, DeclarativeAxes *axes); - //TODO this is deprecated: DeclarativeMargins *minimumMargins() { return m_margins; } - Q_REVISION(2) DeclarativeMargins *margins() { return m_margins; } QRectF plotArea() { return m_chart->plotArea(); } - // Axis list property methods + // Axis handling + QAbstractAxis *defaultAxis(Qt::Orientation orientation, QAbstractSeries *series); + void initializeAxes(QAbstractSeries *series); + void doInitializeAxes(QAbstractSeries *series, DeclarativeAxes *axes); QDeclarativeListProperty axes(); static void axesAppendFunc(QDeclarativeListProperty *list, QAbstractAxis *element); static int axesCountFunc(QDeclarativeListProperty *list); diff --git a/tests/auto/qml-qtquicktest/tst_chartview.qml b/tests/auto/qml-qtquicktest/tst_chartview.qml index fc4a50e..00e5bd0 100644 --- a/tests/auto/qml-qtquicktest/tst_chartview.qml +++ b/tests/auto/qml-qtquicktest/tst_chartview.qml @@ -62,7 +62,7 @@ Rectangle { // Legend font compare(chartView.legend.font.bold, false, "ChartView.legend.font.bold"); compare(chartView.legend.font.capitalization, Font.MixedCase, "ChartView.legend.font.capitalization"); - compare(chartView.legend.font.family, "arial", "ChartView.legend.font.family"); + verify(chartView.legend.font.family != "", "ChartView.legend.font.family"); compare(chartView.legend.font.italic, false, "ChartView.legend.font.italic"); compare(chartView.legend.font.letterSpacing, 0.0, "ChartView.legend.font.letterSpacing"); verify(chartView.legend.font.pixelSize > 0 @@ -73,6 +73,7 @@ Rectangle { compare(chartView.legend.font.underline, false, "ChartView.legend.font.underline"); compare(chartView.legend.font.weight, Font.Normal, "ChartView.legend.font.weight"); compare(chartView.legend.font.wordSpacing, 0.0, "ChartView.legend.font.wordSpacing"); + compare(chartView.axes.length, 0, "ChartView.axes.length"); } } diff --git a/tests/auto/qml-qtquicktest/tst_chartview_1_1.qml b/tests/auto/qml-qtquicktest/tst_chartview_1_1.qml index 9d41c21..0c5c079 100644 --- a/tests/auto/qml-qtquicktest/tst_chartview_1_1.qml +++ b/tests/auto/qml-qtquicktest/tst_chartview_1_1.qml @@ -58,7 +58,7 @@ Rectangle { // Legend font compare(chartView.legend.font.bold, false, "ChartView.legend.font.bold"); compare(chartView.legend.font.capitalization, Font.MixedCase, "ChartView.legend.font.capitalization"); - compare(chartView.legend.font.family, "arial", "ChartView.legend.font.family"); + verify(chartView.legend.font.family != "", "ChartView.legend.font.family"); compare(chartView.legend.font.italic, false, "ChartView.legend.font.italic"); compare(chartView.legend.font.letterSpacing, 0.0, "ChartView.legend.font.letterSpacing"); verify(chartView.legend.font.pixelSize > 0 diff --git a/tests/auto/qml-qtquicktest/tst_valueaxis.qml b/tests/auto/qml-qtquicktest/tst_valueaxis.qml index 8ee58ff..01d8283 100644 --- a/tests/auto/qml-qtquicktest/tst_valueaxis.qml +++ b/tests/auto/qml-qtquicktest/tst_valueaxis.qml @@ -32,10 +32,10 @@ Rectangle { when: windowShown function test_defaultPropertyValues() { - compare(lineSeries1.axisX.min, 0, "AxisX min"); - compare(lineSeries1.axisX.max, 10, "AxisX max"); - compare(lineSeries1.axisY.min, 0, "AxisY min"); - compare(lineSeries1.axisY.max, 10, "AxisY max"); + verify(axisX.min < 0, "AxisX min"); + verify(axisX.max > 0, "AxisX max"); + verify(axisY.min < 0, "AxisY min"); + verify(axisY.max > 0, "AxisY max"); verify(axisX.tickCount > 0, "AxisX tick count"); verify(axisY.tickCount > 0, "AxisX tick count"); compare(axisX.niceNumbersEnabled, false, "nice numbers"); @@ -43,14 +43,16 @@ Rectangle { } function test_modifyProperties() { - lineSeries1.axisX.tickCount = 3; - compare(lineSeries1.axisX.tickCount, 3, "set tick count"); + axisX.tickCount = 3; + compare(axisX.tickCount, 3, "set tick count"); - lineSeries1.axisX.niceNumbersEnabled = true; + axisX.niceNumbersEnabled = true; compare(axisX.niceNumbersEnabled, true, "nice numbers"); } function test_signals() { + minChangedSpy.clear(); + maxChangedSpy.clear(); axisX.min = 2; compare(minChangedSpy.count, 1, "onMinChanged"); compare(maxChangedSpy.count, 0, "onMaxChanged"); @@ -75,13 +77,9 @@ Rectangle { id: lineSeries1 axisX: ValueAxis { id: axisX - min: 0 - max: 10 } axisY: ValueAxis { id: axisY - min: 0 - max: 10 } XYPoint { x: -1; y: -1 } XYPoint { x: 0; y: 0 } diff --git a/tests/auto/qml-qtquicktest/tst_xyseries.qml b/tests/auto/qml-qtquicktest/tst_xyseries.qml index eddf788..79fb68f 100644 --- a/tests/auto/qml-qtquicktest/tst_xyseries.qml +++ b/tests/auto/qml-qtquicktest/tst_xyseries.qml @@ -57,10 +57,6 @@ Rectangle { function test_axes() { compare(chartView.axes.length, 2); - console.log("chart.axes[0] " + chartView.axes[0]); - console.log("chart.axes[1] " + chartView.axes[1]); - console.log("lineSeries.axisX " + lineSeries.axisX); - console.log("lineSeries.axisY " + lineSeries.axisY); verify(chartView.axes[0] == lineSeries.axisX || chartView.axes[1] == lineSeries.axisX); verify(chartView.axes[0] == lineSeries.axisY || chartView.axes[1] == lineSeries.axisY); verify(lineSeries.axisX == splineSeries.axisX);