diff --git a/plugins/declarative/declarativeareaseries.cpp b/plugins/declarative/declarativeareaseries.cpp index 354abfd..c138b68 100644 --- a/plugins/declarative/declarativeareaseries.cpp +++ b/plugins/declarative/declarativeareaseries.cpp @@ -64,30 +64,6 @@ DeclarativeLineSeries* DeclarativeAreaSeries::lowerSeries() const return qobject_cast(QAreaSeries::lowerSeries()); } -QColor DeclarativeAreaSeries::penColor() const -{ - return pen().color(); -} - -void DeclarativeAreaSeries::setPenColor(QColor color) -{ - QPen p = pen(); - p.setColor(color); - setPen(p); -} - -QColor DeclarativeAreaSeries::brushColor() const -{ - return brush().color(); -} - -void DeclarativeAreaSeries::setBrushColor(QColor color) -{ - QBrush b = brush(); - b.setColor(color); - setBrush(b); -} - #include "moc_declarativeareaseries.cpp" QTCOMMERCIALCHART_END_NAMESPACE diff --git a/plugins/declarative/declarativeareaseries.h b/plugins/declarative/declarativeareaseries.h index 347216b..2742888 100644 --- a/plugins/declarative/declarativeareaseries.h +++ b/plugins/declarative/declarativeareaseries.h @@ -32,8 +32,6 @@ class DeclarativeAreaSeries : public QAreaSeries Q_OBJECT Q_PROPERTY(DeclarativeLineSeries *upperSeries READ upperSeries WRITE setUpperSeries) Q_PROPERTY(DeclarativeLineSeries *lowerSeries READ lowerSeries WRITE setLowerSeries) - Q_PROPERTY(QColor color READ brushColor WRITE setBrushColor) - Q_PROPERTY(QColor borderColor READ penColor WRITE setPenColor) public: explicit DeclarativeAreaSeries(QObject *parent = 0); @@ -41,10 +39,6 @@ public: DeclarativeLineSeries* upperSeries() const; void setLowerSeries(DeclarativeLineSeries* series); DeclarativeLineSeries* lowerSeries() const; - QColor penColor() const; - void setPenColor(QColor color); - QColor brushColor() const; - void setBrushColor(QColor color); }; QTCOMMERCIALCHART_END_NAMESPACE diff --git a/plugins/declarative/declarativechart.cpp b/plugins/declarative/declarativechart.cpp index d48ffee..06d5863 100644 --- a/plugins/declarative/declarativechart.cpp +++ b/plugins/declarative/declarativechart.cpp @@ -160,10 +160,8 @@ void DeclarativeChart::paint(QPainter *painter, const QStyleOptionGraphicsItem * void DeclarativeChart::setTheme(DeclarativeChart::Theme theme) { QChart::ChartTheme chartTheme = (QChart::ChartTheme) theme; - if (chartTheme != m_chart->theme()) { + if (chartTheme != m_chart->theme()) m_chart->setTheme(chartTheme); - themeChanged(); - } } DeclarativeChart::Theme DeclarativeChart::theme() @@ -174,10 +172,8 @@ DeclarativeChart::Theme DeclarativeChart::theme() void DeclarativeChart::setAnimationOptions(DeclarativeChart::Animation animations) { QChart::AnimationOption animationOptions = (QChart::AnimationOption) animations; - if (animationOptions != m_chart->animationOptions()) { + if (animationOptions != m_chart->animationOptions()) m_chart->setAnimationOptions(animationOptions); - animationOptionsChanged(); - } } DeclarativeChart::Animation DeclarativeChart::animationOptions() @@ -194,10 +190,8 @@ DeclarativeChart::Animation DeclarativeChart::animationOptions() void DeclarativeChart::setTitle(QString title) { - if (title != m_chart->title()) { + if (title != m_chart->title()) m_chart->setTitle(title); - emit titleChanged(); - } } QString DeclarativeChart::title() { diff --git a/plugins/declarative/declarativechart.h b/plugins/declarative/declarativechart.h index b223a22..b99b25c 100644 --- a/plugins/declarative/declarativechart.h +++ b/plugins/declarative/declarativechart.h @@ -34,9 +34,9 @@ class DeclarativeChart : public QDeclarativeItem //class DeclarativeChart : public QQuickPaintedItem, public Chart { Q_OBJECT - Q_PROPERTY(Theme theme READ theme WRITE setTheme NOTIFY themeChanged) - Q_PROPERTY(Animation animationOptions READ animationOptions WRITE setAnimationOptions NOTIFY animationOptionsChanged) - Q_PROPERTY(QString title READ title WRITE setTitle NOTIFY titleChanged) + Q_PROPERTY(Theme theme READ theme WRITE setTheme) + Q_PROPERTY(Animation animationOptions READ animationOptions WRITE setAnimationOptions) + Q_PROPERTY(QString title READ title WRITE setTitle) Q_PROPERTY(QColor titleColor READ titleColor WRITE setTitleColor NOTIFY titleColorChanged) Q_PROPERTY(QAxis *axisX READ axisX) Q_PROPERTY(QAxis *axisY READ axisY) @@ -120,9 +120,6 @@ public: Q_INVOKABLE QAbstractSeries *createSeries(DeclarativeChart::SeriesType type, QString name = ""); Q_SIGNALS: - void themeChanged(); - void animationOptionsChanged(); - void titleChanged(); void axisLabelsChanged(); void titleColorChanged(); void backgroundColorChanged(); diff --git a/plugins/declarative/declarativelineseries.h b/plugins/declarative/declarativelineseries.h index e0604ee..860fa5a 100644 --- a/plugins/declarative/declarativelineseries.h +++ b/plugins/declarative/declarativelineseries.h @@ -34,7 +34,6 @@ class DeclarativeLineSeries : public QLineSeries, public DeclarativeXySeries, pu { Q_OBJECT Q_INTERFACES(QDeclarativeParserStatus) - Q_PROPERTY(QColor color READ penColor WRITE setPenColor) Q_PROPERTY(int count READ count NOTIFY countChanged) Q_PROPERTY(QDeclarativeListProperty declarativeChildren READ declarativeChildren) Q_CLASSINFO("DefaultProperty", "declarativeChildren") diff --git a/plugins/declarative/declarativescatterseries.cpp b/plugins/declarative/declarativescatterseries.cpp index efdd5a1..053b9f1 100644 --- a/plugins/declarative/declarativescatterseries.cpp +++ b/plugins/declarative/declarativescatterseries.cpp @@ -68,18 +68,6 @@ void DeclarativeScatterSeries::appendDeclarativeChildren(QDeclarativeListPropert // Empty implementation, childs are parsed in componentComplete } -QColor DeclarativeScatterSeries::brushColor() -{ - return brush().color(); -} - -void DeclarativeScatterSeries::setBrushColor(QColor color) -{ - QBrush b = brush(); - b.setColor(color); - setBrush(b); -} - #include "moc_declarativescatterseries.cpp" QTCOMMERCIALCHART_END_NAMESPACE diff --git a/plugins/declarative/declarativescatterseries.h b/plugins/declarative/declarativescatterseries.h index c98f0fe..11930cc 100644 --- a/plugins/declarative/declarativescatterseries.h +++ b/plugins/declarative/declarativescatterseries.h @@ -33,8 +33,6 @@ class DeclarativeScatterSeries : public QScatterSeries, public DeclarativeXySeri { Q_OBJECT Q_INTERFACES(QDeclarativeParserStatus) - Q_PROPERTY(QColor color READ brushColor WRITE setBrushColor) - Q_PROPERTY(QColor borderColor READ penColor WRITE setPenColor) Q_PROPERTY(int count READ count NOTIFY countChanged) Q_PROPERTY(QDeclarativeListProperty declarativeChildren READ declarativeChildren) Q_CLASSINFO("DefaultProperty", "declarativeChildren") @@ -43,8 +41,6 @@ public: explicit DeclarativeScatterSeries(QObject *parent = 0); QXYSeries *xySeries(); QDeclarativeListProperty declarativeChildren(); - QColor brushColor(); - void setBrushColor(QColor color); public: // from QDeclarativeParserStatus void classBegin() { DeclarativeXySeries::classBegin(); } diff --git a/plugins/declarative/declarativesplineseries.h b/plugins/declarative/declarativesplineseries.h index c506fc1..bb5bb52 100644 --- a/plugins/declarative/declarativesplineseries.h +++ b/plugins/declarative/declarativesplineseries.h @@ -34,7 +34,6 @@ class DeclarativeSplineSeries : public QSplineSeries, public DeclarativeXySeries { Q_OBJECT Q_INTERFACES(QDeclarativeParserStatus) - Q_PROPERTY(QColor color READ penColor WRITE setPenColor) Q_PROPERTY(QDeclarativeListProperty declarativeChildren READ declarativeChildren) Q_CLASSINFO("DefaultProperty", "declarativeChildren") diff --git a/plugins/declarative/declarativexyseries.cpp b/plugins/declarative/declarativexyseries.cpp index f68ff89..d07dc26 100644 --- a/plugins/declarative/declarativexyseries.cpp +++ b/plugins/declarative/declarativexyseries.cpp @@ -59,23 +59,6 @@ void DeclarativeXySeries::componentComplete() } } -QColor DeclarativeXySeries::penColor() -{ - // All the inherited objects must be of type QXYSeries, so it is safe to cast - QXYSeries *series = qobject_cast(xySeries()); - Q_ASSERT(series); - return series->pen().color(); -} - -void DeclarativeXySeries::setPenColor(QColor color) -{ - QXYSeries *series = qobject_cast(xySeries()); - Q_ASSERT(series); - QPen pen = series->pen(); - pen.setColor(color); - series->setPen(pen); -} - DeclarativeXyPoint *DeclarativeXySeries::at(int index) { QXYSeries *series = qobject_cast(xySeries()); diff --git a/plugins/declarative/declarativexyseries.h b/plugins/declarative/declarativexyseries.h index e00ef16..0665a70 100644 --- a/plugins/declarative/declarativexyseries.h +++ b/plugins/declarative/declarativexyseries.h @@ -41,8 +41,6 @@ public: void classBegin(); void componentComplete(); virtual QXYSeries *xySeries() = 0; - QColor penColor(); - void setPenColor(QColor color); DeclarativeXyPoint *at(int index); }; diff --git a/src/areachart/qareaseries.cpp b/src/areachart/qareaseries.cpp index 3161e31..5c49148 100644 --- a/src/areachart/qareaseries.cpp +++ b/src/areachart/qareaseries.cpp @@ -58,6 +58,18 @@ QTCOMMERCIALCHART_BEGIN_NAMESPACE */ /*! + \property QAreaSeries::color + Fill (brush) color of the series. This is a convenience property for modifying the color of brush. + \sa QAreaSeries::brush() +*/ + +/*! + \property QAreaSeries::borderColor + Line (pen) color of the series. This is a convenience property for modifying the color of pen. + \sa QAreaSeries::pen() +*/ + +/*! \fn QPen QAreaSeries::pen() const \brief Returns the pen used to draw line for this series. \sa setPen() @@ -70,6 +82,16 @@ QTCOMMERCIALCHART_BEGIN_NAMESPACE */ /*! + \fn void QAreaSeries::colorChanged(QColor color) + \brief Signal is emitted when the fill (brush) color has changed to \a color. +*/ + +/*! + \fn void QAreaSeries::borderColorChanged(QColor color) + \brief Signal is emitted when the line (pen) color has changed to \a color. +*/ + +/*! \fn bool QAreaSeries::pointsVisible() const \brief Returns if the points are drawn for this series. \sa setPointsVisible() @@ -191,6 +213,37 @@ QBrush QAreaSeries::brush() const Q_D(const QAreaSeries); return d->m_brush; } + +void QAreaSeries::setColor(const QColor &color) +{ + QBrush b = brush(); + if (b.color() != color) { + b.setColor(color); + setBrush(b); + emit colorChanged(color); + } +} + +QColor QAreaSeries::color() const +{ + return brush().color(); +} + +void QAreaSeries::setBorderColor(const QColor &color) +{ + QPen p = pen(); + if (p.color() != color) { + p.setColor(color); + setPen(p); + emit borderColorChanged(color); + } +} + +QColor QAreaSeries::borderColor() const +{ + return pen().color(); +} + /*! Sets if data points are \a visible and should be drawn on line. */ diff --git a/src/areachart/qareaseries.h b/src/areachart/qareaseries.h index f5cfa25..c986ff9 100644 --- a/src/areachart/qareaseries.h +++ b/src/areachart/qareaseries.h @@ -35,6 +35,8 @@ class QTCOMMERCIALCHART_EXPORT QAreaSeries : public QAbstractSeries Q_OBJECT Q_PROPERTY(QAbstractSeries *upperSeries READ upperSeries) Q_PROPERTY(QAbstractSeries *lowerSeries READ lowerSeries) + Q_PROPERTY(QColor color READ color WRITE setColor NOTIFY colorChanged) + Q_PROPERTY(QColor borderColor READ borderColor WRITE setBorderColor NOTIFY borderColorChanged) public: explicit QAreaSeries(QObject *parent = 0); @@ -55,16 +57,24 @@ public: void setBrush(const QBrush &brush); QBrush brush() const; + void setColor(const QColor &color); + QColor color() const; + + void setBorderColor(const QColor &color); + QColor borderColor() const; + void setPointsVisible(bool visible = true); bool pointsVisible() const; Q_SIGNALS: void clicked(const QPointF &point); void selected(); + void colorChanged(QColor color); + void borderColorChanged(QColor color); private: - Q_DECLARE_PRIVATE(QAreaSeries); - Q_DISABLE_COPY(QAreaSeries); + Q_DECLARE_PRIVATE(QAreaSeries) + Q_DISABLE_COPY(QAreaSeries) friend class AreaLegendMarker; friend class AreaChartItem; }; diff --git a/src/axis/qaxis.cpp b/src/axis/qaxis.cpp index 76854af..f5fcc03 100644 --- a/src/axis/qaxis.cpp +++ b/src/axis/qaxis.cpp @@ -218,11 +218,6 @@ QTCOMMERCIALCHART_BEGIN_NAMESPACE */ /*! - \fn void QAxis::labelsAngleChanged(int) - Emitted if the \a angle of the axis labels is changed. -*/ - -/*! \fn void QAxis::shadesVisibleChanged(bool) Emitted if the visibility of the axis shades is changed to \a visible. */ @@ -238,18 +233,6 @@ QTCOMMERCIALCHART_BEGIN_NAMESPACE */ /*! - \fn void QAxis::ticksCountChanged(int count) - \brief Emits the new \a count of ticks on the axis - Signal is emitted when the number of the ticks on the axis has been changed to a different value. - Parementer count\a count is the new number of ticks on the axis. -*/ - -/*! - \fn void QAxis::niceNumbersEnabledChanged(bool) - Nice numbers algorithm was \a enabled or disabled. -*/ - -/*! Constructs new axis object which is a child of \a parent. Ownership is taken by QChart when axis added. */ @@ -427,7 +410,6 @@ void QAxis::setLabelsAngle(int angle) if (d_ptr->m_labelsAngle != angle) { d_ptr->m_labelsAngle = angle; emit d_ptr->updated(); - emit labelsAngleChanged(angle); } } @@ -579,7 +561,6 @@ void QAxis::setTicksCount(int count) { if (d_ptr->m_ticksCount != count) { d_ptr->m_ticksCount = count; - emit ticksCountChanged(count); emit d_ptr->changed(d_ptr->m_min, d_ptr->m_max, d_ptr->m_ticksCount, d_ptr->m_niceNumbers); } } @@ -622,7 +603,6 @@ void QAxis::setNiceNumbersEnabled(bool enable) if (d_ptr->m_niceNumbers != enable){ d_ptr->m_niceNumbers = enable; emit d_ptr->changed(d_ptr->m_min, d_ptr->m_max, d_ptr->m_ticksCount, d_ptr->m_niceNumbers); - emit niceNumbersEnabledChanged(enable); } } diff --git a/src/axis/qaxis.h b/src/axis/qaxis.h index 1940963..52ecca9 100644 --- a/src/axis/qaxis.h +++ b/src/axis/qaxis.h @@ -36,7 +36,7 @@ class QTCOMMERCIALCHART_EXPORT QAxis : public QObject Q_PROPERTY(bool visible READ isAxisVisible WRITE setAxisVisible NOTIFY visibleChanged) Q_PROPERTY(QColor color READ axisPenColor WRITE setAxisPenColor NOTIFY colorChanged) Q_PROPERTY(bool labelsVisible READ labelsVisible WRITE setLabelsVisible NOTIFY labelsVisibleChanged) - Q_PROPERTY(int labelsAngle READ labelsAngle WRITE setLabelsAngle NOTIFY labelsAngleChanged) + Q_PROPERTY(int labelsAngle READ labelsAngle WRITE setLabelsAngle) Q_PROPERTY(QColor labelsColor READ labelsColor WRITE setLabelsColor NOTIFY labelsColorChanged) Q_PROPERTY(bool gridVisible READ isGridLineVisible WRITE setGridLineVisible NOTIFY gridVisibleChanged) Q_PROPERTY(bool shadesVisible READ shadesVisible WRITE setShadesVisible NOTIFY shadesVisibleChanged) @@ -44,8 +44,8 @@ class QTCOMMERCIALCHART_EXPORT QAxis : public QObject Q_PROPERTY(QColor shadesBorderColor READ shadesBorderColor WRITE setShadesBorderColor NOTIFY shadesBorderColorChanged) Q_PROPERTY(qreal min READ min WRITE setMin NOTIFY minChanged) Q_PROPERTY(qreal max READ max WRITE setMax NOTIFY maxChanged) - Q_PROPERTY(int ticksCount READ ticksCount WRITE setTicksCount NOTIFY ticksCountChanged) - Q_PROPERTY(bool niceNumbersEnabled READ niceNumbersEnabled WRITE setNiceNumbersEnabled NOTIFY niceNumbersEnabledChanged) + Q_PROPERTY(int ticksCount READ ticksCount WRITE setTicksCount) + Q_PROPERTY(bool niceNumbersEnabled READ niceNumbersEnabled WRITE setNiceNumbersEnabled) public: @@ -118,14 +118,11 @@ Q_SIGNALS: void rangeChanged(qreal min, qreal max); void colorChanged(QColor color); void labelsColorChanged(QColor color); - void labelsAngleChanged(int angle); void shadesVisibleChanged(bool visible); void shadesColorChanged(QColor color); void shadesBorderColorChanged(QColor color); void minChanged(qreal min); void maxChanged(qreal max); - void ticksCountChanged(int count); - void niceNumbersEnabledChanged(bool enabled); private: QScopedPointer d_ptr; diff --git a/src/legend/qlegend.cpp b/src/legend/qlegend.cpp index 90d2146..101455e 100644 --- a/src/legend/qlegend.cpp +++ b/src/legend/qlegend.cpp @@ -121,11 +121,6 @@ QTCOMMERCIALCHART_BEGIN_NAMESPACE */ /*! - \fn void QLegend::alignmentChanged(Qt::Alignment) - Emitted when the \a alignment of the legend changes. -*/ - -/*! \fn void QLegend::backgroundVisibleChanged(bool) The visibility of the legend background changed to \a visible. */ @@ -271,7 +266,6 @@ void QLegend::setAlignment(Qt::Alignment alignment) if(d_ptr->m_alignment!=alignment) { d_ptr->m_alignment = alignment; d_ptr->updateLayout(); - alignmentChanged(alignment); } } diff --git a/src/legend/qlegend.h b/src/legend/qlegend.h index 22dcd92..c6dbb72 100644 --- a/src/legend/qlegend.h +++ b/src/legend/qlegend.h @@ -43,7 +43,7 @@ class QLegendPrivate; class QTCOMMERCIALCHART_EXPORT QLegend : public QGraphicsWidget { Q_OBJECT - Q_PROPERTY(Qt::Alignment alignment READ alignment WRITE setAlignment NOTIFY alignmentChanged) + Q_PROPERTY(Qt::Alignment alignment READ alignment WRITE setAlignment) Q_PROPERTY(bool backgroundVisible READ isBackgroundVisible WRITE setBackgroundVisible NOTIFY backgroundVisibleChanged) Q_PROPERTY(QColor color READ color WRITE setColor NOTIFY colorChanged) Q_PROPERTY(QColor borderColor READ borderColor WRITE setBorderColor NOTIFY borderColorChanged) @@ -86,7 +86,6 @@ protected: void showEvent(QShowEvent *event); Q_SIGNALS: - void alignmentChanged(Qt::Alignment alignment); void backgroundVisibleChanged(bool visible); void colorChanged(QColor color); void borderColorChanged(QColor color); diff --git a/src/scatterchart/qscatterseries.cpp b/src/scatterchart/qscatterseries.cpp index aa1ddd0..1c6095e 100644 --- a/src/scatterchart/qscatterseries.cpp +++ b/src/scatterchart/qscatterseries.cpp @@ -56,25 +56,37 @@ */ /*! - \property QScatterSeries::markerShape - - Defines the shape of the marker used to draw the points in the series. + \property QScatterSeries::color + Fill (brush) color of the series. This is a convenience property for modifying the color of brush. + \sa QScatterSeries::brush() */ /*! - \fn void QScatterSeries::markerShapeChanged() - Emitted when marker shape is changed + \property QScatterSeries::borderColor + Line (pen) color of the series. This is a convenience property for modifying the color of pen. + \sa QScatterSeries::pen() */ /*! - \fn void QScatterSeries::markerSizeChanged() - Emitted when marker size is changed + \property QScatterSeries::markerShape + + Defines the shape of the marker used to draw the points in the series. The default shape is MarkerShapeCircle. */ /*! \property QScatterSeries::markerSize - Defines the size of the marker used to draw the points in the series. + Defines the size of the marker used to draw the points in the series. The default size is 15.0. +*/ + +/*! + \fn void QScatterSeries::colorChanged(QColor color) + \brief Signal is emitted when the fill (brush) color has changed to \a color. +*/ + +/*! + \fn void QScatterSeries::borderColorChanged(QColor color) + \brief Signal is emitted when the line (pen) color has changed to \a color. */ /*! @@ -108,47 +120,64 @@ QAbstractSeries::SeriesType QScatterSeries::type() const return QAbstractSeries::SeriesTypeScatter; } -/*! - Returns the shape used for drawing markers. -*/ +void QScatterSeries::setColor(const QColor &color) +{ + QBrush b = brush(); + if (b.color() != color) { + b.setColor(color); + setBrush(b); + emit colorChanged(color); + } +} + +QColor QScatterSeries::color() const +{ + return brush().color(); +} + +void QScatterSeries::setBorderColor(const QColor &color) +{ + QPen p = pen(); + if (p.color() != color) { + p.setColor(color); + setPen(p); + emit borderColorChanged(color); + } +} + +QColor QScatterSeries::borderColor() const +{ + return pen().color(); +} + QScatterSeries::MarkerShape QScatterSeries::markerShape() const { Q_D(const QScatterSeries); return d->m_shape; } -/*! - Overrides the default shape of the marker items with a user defined \a shape. The default shape - is defined by chart theme setting. -*/ void QScatterSeries::setMarkerShape(MarkerShape shape) { Q_D(QScatterSeries); if (d->m_shape != shape) { d->m_shape = shape; - emit markerShapeChanged(); + emit d->updated(); } } -/*! - Returns the size of the marker items. -*/ qreal QScatterSeries::markerSize() const { Q_D(const QScatterSeries); return d->m_size; } -/*! - Set the \a size of the marker items. The default size is 15. -*/ void QScatterSeries::setMarkerSize(qreal size) { Q_D(QScatterSeries); if (!qFuzzyIsNull(d->m_size - size)) { d->m_size = size; - emit markerSizeChanged(); + emit d->updated(); } } diff --git a/src/scatterchart/qscatterseries.h b/src/scatterchart/qscatterseries.h index ef45948..9780da9 100644 --- a/src/scatterchart/qscatterseries.h +++ b/src/scatterchart/qscatterseries.h @@ -31,8 +31,10 @@ class QScatterSeriesPrivate; class QTCOMMERCIALCHART_EXPORT QScatterSeries : public QXYSeries { Q_OBJECT - Q_PROPERTY(MarkerShape markerShape READ markerShape WRITE setMarkerShape NOTIFY markerShapeChanged) - Q_PROPERTY(qreal markerSize READ markerSize WRITE setMarkerSize NOTIFY markerSizeChanged) + Q_PROPERTY(QColor color READ color WRITE setColor NOTIFY colorChanged) + Q_PROPERTY(QColor borderColor READ borderColor WRITE setBorderColor NOTIFY borderColorChanged) + Q_PROPERTY(MarkerShape markerShape READ markerShape WRITE setMarkerShape) + Q_PROPERTY(qreal markerSize READ markerSize WRITE setMarkerSize) Q_ENUMS(MarkerShape) public: @@ -45,20 +47,23 @@ public: explicit QScatterSeries(QObject *parent = 0); ~QScatterSeries(); QAbstractSeries::SeriesType type() const; + void setColor(const QColor &color); + QColor color() const; + void setBorderColor(const QColor &color); + QColor borderColor() const; MarkerShape markerShape() const; void setMarkerShape(MarkerShape shape); qreal markerSize() const; void setMarkerSize(qreal size); Q_SIGNALS: - void markerShapeChanged(); - void markerSizeChanged(); + void colorChanged(QColor color); + void borderColorChanged(QColor color); private: Q_DECLARE_PRIVATE(QScatterSeries) Q_DISABLE_COPY(QScatterSeries) friend class ScatterChartItem; - }; QTCOMMERCIALCHART_END_NAMESPACE diff --git a/src/scatterchart/scatterchartitem.cpp b/src/scatterchart/scatterchartitem.cpp index e721781..4fa6ecc 100644 --- a/src/scatterchart/scatterchartitem.cpp +++ b/src/scatterchart/scatterchartitem.cpp @@ -39,8 +39,6 @@ ScatterChartItem::ScatterChartItem(QScatterSeries *series, ChartPresenter *prese m_size(15) { QObject::connect(m_series->d_func(),SIGNAL(updated()), this, SLOT(handleUpdated())); - QObject::connect(m_series, SIGNAL(markerShapeChanged()), this, SLOT(handleUpdated())); - QObject::connect(m_series, SIGNAL(markerSizeChanged()), this, SLOT(handleUpdated())); QObject::connect(m_series, SIGNAL(visibleChanged()), this, SLOT(handleUpdated())); setZValue(ChartPresenter::ScatterSeriesZValue); diff --git a/src/xychart/qxyseries.cpp b/src/xychart/qxyseries.cpp index f99109b..c906ca0 100644 --- a/src/xychart/qxyseries.cpp +++ b/src/xychart/qxyseries.cpp @@ -49,6 +49,12 @@ QTCOMMERCIALCHART_BEGIN_NAMESPACE */ /*! + \property QXYSeries::color + Line (pen) color of the series. This is a convenience property for modifying the color of pen. + \sa QXYSeries::pen() +*/ + +/*! \fn void QXYSeries::clicked(const QPointF& point) \brief Signal is emitted when user clicks the \a point on chart. */ @@ -72,8 +78,8 @@ QTCOMMERCIALCHART_BEGIN_NAMESPACE */ /*! - \fn void QXYSeries::pointsVisibleChanged(bool visible) - \brief Signal is emitted when the point visibility has changed to \a visible. + \fn void QXYSeries::colorChanged(QColor color) + \brief Signal is emitted when the line (pen) color has changed to \a color. */ /*! @@ -254,6 +260,20 @@ QBrush QXYSeries::brush() const return d->m_brush; } +void QXYSeries::setColor(const QColor &color) +{ + QPen p = pen(); + if (p.color() != color) { + p.setColor(color); + setPen(p); + emit colorChanged(color); + } +} + +QColor QXYSeries::color() const +{ + return pen().color(); +} void QXYSeries::setPointsVisible(bool visible) { @@ -261,7 +281,6 @@ void QXYSeries::setPointsVisible(bool visible) if (d->m_pointsVisible != visible){ d->m_pointsVisible = visible; emit d->updated(); - emit pointsVisibleChanged(visible); } } diff --git a/src/xychart/qxyseries.h b/src/xychart/qxyseries.h index 6125d07..e1dce66 100644 --- a/src/xychart/qxyseries.h +++ b/src/xychart/qxyseries.h @@ -36,7 +36,8 @@ class QXYModelMapper; class QTCOMMERCIALCHART_EXPORT QXYSeries : public QAbstractSeries { Q_OBJECT - Q_PROPERTY(bool pointsVisible READ pointsVisible WRITE setPointsVisible NOTIFY pointsVisibleChanged) + Q_PROPERTY(bool pointsVisible READ pointsVisible WRITE setPointsVisible) + Q_PROPERTY(QColor color READ color WRITE setColor NOTIFY colorChanged) protected: explicit QXYSeries(QXYSeriesPrivate &d,QObject *parent = 0); @@ -65,6 +66,9 @@ public: void setBrush(const QBrush &brush); QBrush brush() const; + virtual void setColor(const QColor &color); + virtual QColor color() const; + void setPointsVisible(bool visible = true); bool pointsVisible() const; @@ -73,8 +77,7 @@ Q_SIGNALS: void pointReplaced(int index); void pointRemoved(int index); void pointAdded(int index); - void pointsVisibleChanged(bool visible); - + void colorChanged(QColor color); private: Q_DECLARE_PRIVATE(QXYSeries) diff --git a/tests/qmlchartproperties/qml/qmlchartproperties/AreaEditor.qml b/tests/qmlchartproperties/qml/qmlchartproperties/AreaEditor.qml index ec3b7f7..49e7fd6 100644 --- a/tests/qmlchartproperties/qml/qmlchartproperties/AreaEditor.qml +++ b/tests/qmlchartproperties/qml/qmlchartproperties/AreaEditor.qml @@ -29,12 +29,16 @@ Flow { property variant series onSeriesChanged: { - seriesConnections.target = series; + if (series && series.name == "area 1") { + seriesConnections.target = series; + } else { + seriesConnections.target = null; + } } Connections { id: seriesConnections - ignoreUnknownSignals: true + target: null onNameChanged: console.log("series.onNameChanged: " + series.name); onVisibleChanged: console.log("series.onVisibleChanged: " + series.visible); onColorChanged: console.log("series.onColorChanged: " + series.color); diff --git a/tests/qmlchartproperties/qml/qmlchartproperties/BarChart.qml b/tests/qmlchartproperties/qml/qmlchartproperties/BarChart.qml index 1ebfc90..59f8434 100644 --- a/tests/qmlchartproperties/qml/qmlchartproperties/BarChart.qml +++ b/tests/qmlchartproperties/qml/qmlchartproperties/BarChart.qml @@ -32,6 +32,7 @@ ChartView { BarSeries { id: daSeries + name: "bar" BarSet { label: "Bob"; values: [4, 7, 3, 10, 5, 6] } BarSet { label: "Susan"; values: [5, 1, 2, 4, 1, 8] } BarSet { label: "James"; values: [3, 5, 8, 5, 4, 7] } diff --git a/tests/qmlchartproperties/qml/qmlchartproperties/BarEditor.qml b/tests/qmlchartproperties/qml/qmlchartproperties/BarEditor.qml index 68e5727..92cc943 100644 --- a/tests/qmlchartproperties/qml/qmlchartproperties/BarEditor.qml +++ b/tests/qmlchartproperties/qml/qmlchartproperties/BarEditor.qml @@ -28,13 +28,18 @@ Flow { property variant series onSeriesChanged: { - seriesConnections.target = series; - setConnections.target = series.at(0); + if (series && series.name == "bar") { + seriesConnections.target = series; + setConnections.target = series.at(0); + } else { + seriesConnections.target = null; + setConnections.target = null; + } } Connections { id: seriesConnections - ignoreUnknownSignals: true + target: null onNameChanged: console.log("series.onNameChanged: " + series.name); onVisibleChanged: console.log("series.onVisibleChanged: " + series.visible); onBarWidthChanged: console.log("series.onBardWidthChanged: " + width) @@ -44,7 +49,7 @@ Flow { Connections { id: setConnections - ignoreUnknownSignals: true + target: null onColorChanged: console.log("series.onColorChanged: " + color); onBorderColorChanged: console.log("series.onBorderColorChanged: " + color); onLabelColorChanged: console.log("series.onLabelColorChanged: " + color); diff --git a/tests/qmlchartproperties/qml/qmlchartproperties/ChartEditor.qml b/tests/qmlchartproperties/qml/qmlchartproperties/ChartEditor.qml index c068476..1084a20 100644 --- a/tests/qmlchartproperties/qml/qmlchartproperties/ChartEditor.qml +++ b/tests/qmlchartproperties/qml/qmlchartproperties/ChartEditor.qml @@ -29,18 +29,22 @@ Flow { property variant series // TODO: rename to chart onSeriesChanged: { - legendConnections.target = series.legend; - axisXConnections.target = series.axisX; - axisYConnections.target = series.axisY; + 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 { - target: series - ignoreUnknownSignals: true + id: chartConnections + target: null onVisibleChanged: console.log("chart.onVisibleChanged: " + series.visible); - onThemeChanged: console.log("chart.onThemeChanged: " + series.theme); - onLegendChanged: console.log("chart.onLegendChanged: " + series.legend); - onAnimationOptionsChanged: console.log("chart.onAnimationOptionsChanged: " + series.animationOptions); onTitleColorChanged: console.log("chart.onTitleColorChanged: " + series.titleColor); onBackgroundColorChanged: console.log("chart.onBackgroundColorChanged: " + series.backgroundColor); onDropShadowEnabledChanged: console.log("chart.onDropShadowEnabledChanged: " + enabled); @@ -48,8 +52,7 @@ Flow { Connections { id: legendConnections - ignoreUnknownSignals: true - onAlignmentChanged: console.log("legend.onAlignmentChanged: " + alignment); + target: null onVisibleChanged: console.log("legend.onVisibleChanged: " + series.legend.visible); onBackgroundVisibleChanged: console.log("legend.onBackgroundVisibleChanged: " + visible); onColorChanged: console.log("legend.onColorChanged: " + color); @@ -58,11 +61,10 @@ Flow { Connections { id: axisXConnections - ignoreUnknownSignals: true + target: null onColorChanged: console.log("axisX.onColorChanged: " + color); onLabelsVisibleChanged: console.log("axisX.onLabelsVisibleChanged: " + visible); onLabelsColorChanged: console.log("axisX.onLabelsColorChanged: " + color); - onLabelsAngleChanged: console.log("axisX.onLabelsAngleChanged: " + angle); onVisibleChanged: console.log("axisX.onVisibleChanged: " + visible); onGridVisibleChanged: console.log("axisX.onGridVisibleChanged: " + visible); onShadesVisibleChanged: console.log("axisX.onShadesVisibleChanged: " + visible); @@ -70,17 +72,14 @@ Flow { onShadesBorderColorChanged: console.log("axisX.onShadesBorderColorChanged: " + color); onMinChanged: console.log("axisX.onMinChanged: " + min); onMaxChanged: console.log("axisX.onMaxChanged: " + max); - onTicksCountChanged: console.log("axisX.onTicksCountChanged: " + count); - onNiceNumbersEnabledChanged: console.log("axisX.onNiceNumbersEnabledChanged: " + enabled); } Connections { id: axisYConnections - ignoreUnknownSignals: true + target: null onColorChanged: console.log("axisY.onColorChanged: " + color); onLabelsVisibleChanged: console.log("axisY.onLabelsVisibleChanged: " + visible); onLabelsColorChanged: console.log("axisY.onLabelsColorChanged: " + color); - onLabelsAngleChanged: console.log("axisY.onLabelsAngleChanged: " + angle); onVisibleChanged: console.log("axisY.onVisibleChanged: " + visible); onGridVisibleChanged: console.log("axisY.onGridVisibleChanged: " + visible); onShadesVisibleChanged: console.log("axisY.onShadesVisibleChanged: " + visible); @@ -88,8 +87,6 @@ Flow { onShadesBorderColorChanged: console.log("axisY.onShadesBorderColorChanged: " + color); onMinChanged: console.log("axisY.onMinChanged: " + min); onMaxChanged: console.log("axisY.onMaxChanged: " + max); - onTicksCountChanged: console.log("axisY.onTicksCountChanged: " + count); - onNiceNumbersEnabledChanged: console.log("axisY.onNiceNumbersEnabledChanged: " + enabled); } Button { diff --git a/tests/qmlchartproperties/qml/qmlchartproperties/GroupedBarChart.qml b/tests/qmlchartproperties/qml/qmlchartproperties/GroupedBarChart.qml index 63cc8cd..9e50876 100644 --- a/tests/qmlchartproperties/qml/qmlchartproperties/GroupedBarChart.qml +++ b/tests/qmlchartproperties/qml/qmlchartproperties/GroupedBarChart.qml @@ -32,6 +32,7 @@ ChartView { GroupedBarSeries { id: daSeries + name: "bar" BarSet { label: "Bob"; values: [2, 2, 3, 4, 5, 6] } BarSet { label: "Susan"; values: [5, 1, 2, 4, 1, 7] } BarSet { label: "James"; values: [3, 5, 8, 13, 5, 8] } diff --git a/tests/qmlchartproperties/qml/qmlchartproperties/LineEditor.qml b/tests/qmlchartproperties/qml/qmlchartproperties/LineEditor.qml index 99ac402..71e1d52 100644 --- a/tests/qmlchartproperties/qml/qmlchartproperties/LineEditor.qml +++ b/tests/qmlchartproperties/qml/qmlchartproperties/LineEditor.qml @@ -29,15 +29,18 @@ Flow { property variant series onSeriesChanged: { - seriesConnections.target = series; + if (series && (series.name == "line 1" || series.name == "spline 1")) { + seriesConnections.target = series; + } else { + seriesConnections.target = null; + } } Connections { id: seriesConnections - ignoreUnknownSignals: true + target: null onNameChanged: console.log("series.onNameChanged: " + series.name); onVisibleChanged: console.log("series.onVisibleChanged: " + series.visible); - onPointsVisibleChanged: console.log("series.onPointsVisibleChanged: " + series.pointsVisible); onColorChanged: console.log("series.onColorChanged: " + series.color); onCountChanged: console.log("series.onCountChanged: " + series.count); } diff --git a/tests/qmlchartproperties/qml/qmlchartproperties/PercentBarChart.qml b/tests/qmlchartproperties/qml/qmlchartproperties/PercentBarChart.qml index ccb1a1b..ccdbc50 100644 --- a/tests/qmlchartproperties/qml/qmlchartproperties/PercentBarChart.qml +++ b/tests/qmlchartproperties/qml/qmlchartproperties/PercentBarChart.qml @@ -32,6 +32,7 @@ ChartView { PercentBarSeries { id: daSeries + name: "bar" BarSet { label: "Bob"; values: [2, 2, 3, 4, 5, 6] } BarSet { label: "Susan"; values: [5, 1, 2, 4, 1, 7] } BarSet { label: "James"; values: [3, 5, 8, 13, 5, 8] } diff --git a/tests/qmlchartproperties/qml/qmlchartproperties/PieChart.qml b/tests/qmlchartproperties/qml/qmlchartproperties/PieChart.qml index e6f15fc..4d82623 100644 --- a/tests/qmlchartproperties/qml/qmlchartproperties/PieChart.qml +++ b/tests/qmlchartproperties/qml/qmlchartproperties/PieChart.qml @@ -30,6 +30,7 @@ ChartView { PieSeries { id: pieSeries + name: "pie" PieSlice { id: daSlice; label: "slice1"; value: 11 } PieSlice { label: "slice2"; value: 22 } PieSlice { label: "slice3"; value: 33 } diff --git a/tests/qmlchartproperties/qml/qmlchartproperties/PieEditor.qml b/tests/qmlchartproperties/qml/qmlchartproperties/PieEditor.qml index c120e55..5195c28 100644 --- a/tests/qmlchartproperties/qml/qmlchartproperties/PieEditor.qml +++ b/tests/qmlchartproperties/qml/qmlchartproperties/PieEditor.qml @@ -28,13 +28,18 @@ Flow { property variant series onSeriesChanged: { - seriesConnections.target = series; - sliceConnections.target = series.at(0); + if (series && series.name == "pie") { + seriesConnections.target = series; + sliceConnections.target = series.at(0); + } else { + seriesConnections.target = null; + sliceConnections.target = null; + } } Connections { id: seriesConnections - ignoreUnknownSignals: true + target: null onVisibleChanged: console.log("series.onVisibleChanged: " + series.visible); onHorizontalPositionChanged:console.log("series.onHorizontalPositionChanged: " + series.horizontalPosition); onVerticalPositionChanged: console.log("series.onVerticalPositionChanged: " + series.verticalPosition); @@ -47,7 +52,7 @@ Flow { Connections { id: sliceConnections - ignoreUnknownSignals: true + target: null onValueChanged: console.log("slice.onValueChanged: " + series.at(0).value); onLabelVisibleChanged: console.log("slice.onLabelVisibleChanged: " + series.at(0).labelVisible); onLabelPositionChanged: console.log("slice.onLabelPositionChanged: " + series.at(0).labelPosition); diff --git a/tests/qmlchartproperties/qml/qmlchartproperties/ScatterEditor.qml b/tests/qmlchartproperties/qml/qmlchartproperties/ScatterEditor.qml index 97a7051..fbd10da 100644 --- a/tests/qmlchartproperties/qml/qmlchartproperties/ScatterEditor.qml +++ b/tests/qmlchartproperties/qml/qmlchartproperties/ScatterEditor.qml @@ -29,20 +29,21 @@ Flow { property variant series onSeriesChanged: { - seriesConnections.target = series; + if (series && series.name == "scatter 1") { + seriesConnections.target = series; + } else { + seriesConnections.target = null; + } } Connections { id: seriesConnections - ignoreUnknownSignals: true + target: null onNameChanged: console.log("series.onNameChanged: " + series.name); onVisibleChanged: console.log("series.onVisibleChanged: " + series.visible); - onPointsVisibleChanged: console.log("series.onPointsVisibleChanged: " + series.pointsVisible); onColorChanged: console.log("series.onColorChanged: " + series.color); onBorderColorChanged: console.log("series.onBorderColorChanged: " + series.borderColor); onCountChanged: console.log("series.onCountChanged: " + series.count); - onMarkerSizeChanged: console.log("series.onMarkerSizeChanged: " + series.markerSize); - onMarkerShapeChanged: console.log("series.onMarkerShapeChanged: " + series.markerShape); } Button { diff --git a/tests/qmlchartproperties/qml/qmlchartproperties/StackedBarChart.qml b/tests/qmlchartproperties/qml/qmlchartproperties/StackedBarChart.qml index c8d8c47..0e44f68 100644 --- a/tests/qmlchartproperties/qml/qmlchartproperties/StackedBarChart.qml +++ b/tests/qmlchartproperties/qml/qmlchartproperties/StackedBarChart.qml @@ -32,6 +32,7 @@ ChartView { StackedBarSeries { id: daSeries + name: "bar" BarSet { label: "Bob"; values: [2, 2, 3, 4, 5, 6] } BarSet { label: "Susan"; values: [5, 1, 2, 4, 1, 7] } BarSet { label: "James"; values: [3, 5, 8, 13, 5, 8] }