From 8e404718d98e032ff7c44f2d4f973eb5579b5ff7 2012-08-31 12:35:31 From: Tero Ahola Date: 2012-08-31 12:35:31 Subject: [PATCH] Fixed a bug in setting scatter/area series brush color --- diff --git a/demos/qmlchart/qml/qmlchart/View4.qml b/demos/qmlchart/qml/qmlchart/View4.qml index e3e25bc..05f91ec 100644 --- a/demos/qmlchart/qml/qmlchart/View4.qml +++ b/demos/qmlchart/qml/qmlchart/View4.qml @@ -48,6 +48,9 @@ Rectangle { AreaSeries { name: "Russian" + color: "#FFD52B1E" + borderColor: "#FF0039A5" + borderWidth: 3 axisX: categoriesAxis upperSeries: LineSeries { XYPoint { x: 0; y: 1 } @@ -69,6 +72,9 @@ Rectangle { AreaSeries { name: "Swedish" + color: "#AF005292" + borderColor: "#AFFDCA00" + borderWidth: 3 axisX: categoriesAxis upperSeries: LineSeries { XYPoint { x: 0; y: 1 } @@ -88,6 +94,9 @@ Rectangle { AreaSeries { name: "Finnish" + color: "#00357F" + borderColor: "#FEFEFE" + borderWidth: 3 axisX: categoriesAxis upperSeries: LineSeries { XYPoint { x: 0; y: 0 } @@ -103,10 +112,6 @@ Rectangle { XYPoint { x: 10; y: 0 } XYPoint { x: 11; y: 1 } } - onClicked: { - color = "white"; - borderColor = "blue"; - } } } } diff --git a/src/areachart/qareaseries.cpp b/src/areachart/qareaseries.cpp index 5201fe0..d6a2e06 100644 --- a/src/areachart/qareaseries.cpp +++ b/src/areachart/qareaseries.cpp @@ -248,8 +248,11 @@ void QAreaSeries::setBrush(const QBrush &brush) { Q_D(QAreaSeries); if (d->m_brush != brush) { + bool emitColorChanged = brush.color() != d->m_brush.color(); d->m_brush = brush; emit d->updated(); + if (emitColorChanged) + emit colorChanged(brush.color()); } } @@ -262,11 +265,10 @@ QBrush QAreaSeries::brush() const void QAreaSeries::setColor(const QColor &color) { QBrush b = brush(); - if (b.color() != color) { - b.setColor(color); - setBrush(b); - emit colorChanged(color); - } + if (b == QBrush()) + b.setStyle(Qt::SolidPattern); + b.setColor(color); + setBrush(b); } QColor QAreaSeries::color() const diff --git a/src/scatterchart/qscatterseries.cpp b/src/scatterchart/qscatterseries.cpp index d19edd6..2a0386b 100644 --- a/src/scatterchart/qscatterseries.cpp +++ b/src/scatterchart/qscatterseries.cpp @@ -185,10 +185,10 @@ void QScatterSeries::setBrush(const QBrush &brush) void QScatterSeries::setColor(const QColor &color) { QBrush b = brush(); - if (b.color() != color) { - b.setColor(color); - setBrush(b); - } + if (b == QBrush()) + b.setStyle(Qt::SolidPattern); + b.setColor(color); + setBrush(b); } QColor QScatterSeries::color() const