diff --git a/plugins/declarative/declarativebarseries.cpp b/plugins/declarative/declarativebarseries.cpp index 8505be1..ca43528 100644 --- a/plugins/declarative/declarativebarseries.cpp +++ b/plugins/declarative/declarativebarseries.cpp @@ -29,6 +29,15 @@ QTCOMMERCIALCHART_BEGIN_NAMESPACE DeclarativeBarSet::DeclarativeBarSet(QObject *parent) : QBarSet("", parent) { + connect(this, SIGNAL(valuesAdded(int,int)), this, SLOT(handleCountChanged(int, int))); + connect(this, SIGNAL(valuesRemoved(int,int)), this, SLOT(handleCountChanged(int, int))); +} + +void DeclarativeBarSet::handleCountChanged(int index, int count) +{ + Q_UNUSED(index) + Q_UNUSED(count) + emit countChanged(QBarSet::count()); } QVariantList DeclarativeBarSet::values() @@ -50,42 +59,6 @@ void DeclarativeBarSet::setValues(QVariantList values) } } -QColor DeclarativeBarSet::color() -{ - return brush().color(); -} - -void DeclarativeBarSet::setColor(QColor color) -{ - QBrush b = brush(); - b.setColor(color); - setBrush(b); -} - -QColor DeclarativeBarSet::borderColor() -{ - return pen().color(); -} - -void DeclarativeBarSet::setBorderColor(QColor color) -{ - QPen p = pen(); - p.setColor(color); - setPen(p); -} - -QColor DeclarativeBarSet::labelColor() -{ - return labelBrush().color(); -} - -void DeclarativeBarSet::setLabelColor(QColor color) -{ - QBrush b = labelBrush(); - b.setColor(color); - setLabelBrush(b); -} - DeclarativeBarSeries::DeclarativeBarSeries(QDeclarativeItem *parent) : QBarSeries(parent) { diff --git a/plugins/declarative/declarativebarseries.h b/plugins/declarative/declarativebarseries.h index de08f18..169432a 100644 --- a/plugins/declarative/declarativebarseries.h +++ b/plugins/declarative/declarativebarseries.h @@ -37,24 +37,22 @@ class DeclarativeBarSet : public QBarSet { Q_OBJECT Q_PROPERTY(QVariantList values READ values WRITE setValues) - Q_PROPERTY(QColor color READ color WRITE setColor) - Q_PROPERTY(QColor borderColor READ borderColor WRITE setBorderColor) - Q_PROPERTY(QColor labelColor READ labelColor WRITE setLabelColor) + Q_PROPERTY(int count READ count NOTIFY countChanged) public: explicit DeclarativeBarSet(QObject *parent = 0); QVariantList values(); void setValues(QVariantList values); - QColor color(); - void setColor(QColor color); - QColor borderColor(); - void setBorderColor(QColor color); - QColor labelColor(); - void setLabelColor(QColor color); public: // From QBarSet Q_INVOKABLE void append(qreal value) { QBarSet::append(value); } Q_INVOKABLE void append(qreal x, qreal y) { QBarSet::append(QPointF(x, y)); } + +Q_SIGNALS: + void countChanged(int count); + +private Q_SLOTS: + void handleCountChanged(int index, int count); }; class DeclarativeBarSeries : public QBarSeries, public QDeclarativeParserStatus diff --git a/plugins/declarative/declarativelineseries.cpp b/plugins/declarative/declarativelineseries.cpp index 8ee95d4..dda1f5f 100644 --- a/plugins/declarative/declarativelineseries.cpp +++ b/plugins/declarative/declarativelineseries.cpp @@ -28,6 +28,8 @@ QTCOMMERCIALCHART_BEGIN_NAMESPACE DeclarativeLineSeries::DeclarativeLineSeries(QObject *parent) : QLineSeries(parent) { + connect(this, SIGNAL(pointAdded(int)), this, SLOT(handleCountChanged(int))); + connect(this, SIGNAL(pointRemoved(int)), this, SLOT(handleCountChanged(int))); } QXYSeries *DeclarativeLineSeries::xySeries() @@ -35,6 +37,12 @@ QXYSeries *DeclarativeLineSeries::xySeries() return this; } +void DeclarativeLineSeries::handleCountChanged(int index) +{ + Q_UNUSED(index) + emit countChanged(points().count()); +} + QDeclarativeListProperty DeclarativeLineSeries::declarativeChildren() { return QDeclarativeListProperty(this, 0, &appendDeclarativeChildren); @@ -42,10 +50,9 @@ QDeclarativeListProperty DeclarativeLineSeries::declarativeChildren() void DeclarativeLineSeries::appendDeclarativeChildren(QDeclarativeListProperty *list, QObject *element) { - QXYSeries *series = qobject_cast(list->object); - DeclarativeXyPoint *point = qobject_cast(element); - if (series && point) - series->append(*point); + Q_UNUSED(list) + Q_UNUSED(element) + // Empty implementation, childs are parsed in componentComplete } #include "moc_declarativelineseries.cpp" diff --git a/plugins/declarative/declarativelineseries.h b/plugins/declarative/declarativelineseries.h index 846767b..e0604ee 100644 --- a/plugins/declarative/declarativelineseries.h +++ b/plugins/declarative/declarativelineseries.h @@ -35,6 +35,7 @@ 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") @@ -53,8 +54,12 @@ public: // from QLineSeries Q_INVOKABLE void clear() { QLineSeries::clear(); } Q_INVOKABLE DeclarativeXyPoint *at(int index) { return DeclarativeXySeries::at(index); } +Q_SIGNALS: + void countChanged(int count); + public Q_SLOTS: static void appendDeclarativeChildren(QDeclarativeListProperty *list, QObject *element); + void handleCountChanged(int index); }; QTCOMMERCIALCHART_END_NAMESPACE diff --git a/plugins/declarative/declarativescatterseries.cpp b/plugins/declarative/declarativescatterseries.cpp index 2560bb8..fa27797 100644 --- a/plugins/declarative/declarativescatterseries.cpp +++ b/plugins/declarative/declarativescatterseries.cpp @@ -28,6 +28,8 @@ QTCOMMERCIALCHART_BEGIN_NAMESPACE DeclarativeScatterSeries::DeclarativeScatterSeries(QObject *parent) : QScatterSeries(parent) { + connect(this, SIGNAL(pointAdded(int)), this, SLOT(handleCountChanged(int))); + connect(this, SIGNAL(pointRemoved(int)), this, SLOT(handleCountChanged(int))); } QXYSeries *DeclarativeScatterSeries::xySeries() @@ -35,6 +37,12 @@ QXYSeries *DeclarativeScatterSeries::xySeries() return this; } +void DeclarativeScatterSeries::handleCountChanged(int index) +{ + Q_UNUSED(index) + emit countChanged(QScatterSeries::count()); +} + QDeclarativeListProperty DeclarativeScatterSeries::declarativeChildren() { return QDeclarativeListProperty(this, 0, &appendDeclarativeChildren); @@ -42,10 +50,9 @@ QDeclarativeListProperty DeclarativeScatterSeries::declarativeChildren( void DeclarativeScatterSeries::appendDeclarativeChildren(QDeclarativeListProperty *list, QObject *element) { - QXYSeries *series = qobject_cast(list->object); - DeclarativeXyPoint *point = qobject_cast(element); - if (series && point) - series->append(*point); + Q_UNUSED(list) + Q_UNUSED(element) + // Empty implementation, childs are parsed in componentComplete } QColor DeclarativeScatterSeries::brushColor() diff --git a/plugins/declarative/declarativescatterseries.h b/plugins/declarative/declarativescatterseries.h index ff7b1d4..c98f0fe 100644 --- a/plugins/declarative/declarativescatterseries.h +++ b/plugins/declarative/declarativescatterseries.h @@ -35,6 +35,7 @@ class DeclarativeScatterSeries : public QScatterSeries, public DeclarativeXySeri 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") @@ -55,8 +56,12 @@ public: // from QScatterSeries Q_INVOKABLE void clear() { QScatterSeries::clear(); } Q_INVOKABLE DeclarativeXyPoint *at(int index) { return DeclarativeXySeries::at(index); } +Q_SIGNALS: + void countChanged(int count); + public Q_SLOTS: static void appendDeclarativeChildren(QDeclarativeListProperty *list, QObject *element); + void handleCountChanged(int index); }; QTCOMMERCIALCHART_END_NAMESPACE diff --git a/plugins/declarative/declarativesplineseries.cpp b/plugins/declarative/declarativesplineseries.cpp index 1c9e4e7..e924f4a 100644 --- a/plugins/declarative/declarativesplineseries.cpp +++ b/plugins/declarative/declarativesplineseries.cpp @@ -28,6 +28,8 @@ QTCOMMERCIALCHART_BEGIN_NAMESPACE DeclarativeSplineSeries::DeclarativeSplineSeries(QObject *parent) : QSplineSeries(parent) { + connect(this, SIGNAL(pointAdded(int)), this, SLOT(handleCountChanged(int))); + connect(this, SIGNAL(pointRemoved(int)), this, SLOT(handleCountChanged(int))); } QXYSeries *DeclarativeSplineSeries::xySeries() @@ -35,6 +37,12 @@ QXYSeries *DeclarativeSplineSeries::xySeries() return this; } +void DeclarativeSplineSeries::handleCountChanged(int index) +{ + Q_UNUSED(index) + emit countChanged(points().count()); +} + QDeclarativeListProperty DeclarativeSplineSeries::declarativeChildren() { return QDeclarativeListProperty(this, 0, &appendDeclarativeChildren); @@ -42,10 +50,9 @@ QDeclarativeListProperty DeclarativeSplineSeries::declarativeChildren() void DeclarativeSplineSeries::appendDeclarativeChildren(QDeclarativeListProperty *list, QObject *element) { - QXYSeries *series = qobject_cast(list->object); - DeclarativeXyPoint *point = qobject_cast(element); - if (series && point) - series->append(*point); + Q_UNUSED(list) + Q_UNUSED(element) + // Empty implementation, childs are parsed in componentComplete } #include "moc_declarativesplineseries.cpp" diff --git a/plugins/declarative/declarativesplineseries.h b/plugins/declarative/declarativesplineseries.h index 21fa276..c506fc1 100644 --- a/plugins/declarative/declarativesplineseries.h +++ b/plugins/declarative/declarativesplineseries.h @@ -53,8 +53,12 @@ public: // from QSplineSeries Q_INVOKABLE void clear() { QSplineSeries::clear(); } Q_INVOKABLE DeclarativeXyPoint *at(int index) { return DeclarativeXySeries::at(index); } +Q_SIGNALS: + void countChanged(int count); + public Q_SLOTS: static void appendDeclarativeChildren(QDeclarativeListProperty *list, QObject *element); + void handleCountChanged(int index); }; QTCOMMERCIALCHART_END_NAMESPACE diff --git a/plugins/declarative/declarativexyseries.cpp b/plugins/declarative/declarativexyseries.cpp index 4a7ea1b..f68ff89 100644 --- a/plugins/declarative/declarativexyseries.cpp +++ b/plugins/declarative/declarativexyseries.cpp @@ -47,8 +47,8 @@ void DeclarativeXySeries::componentComplete() foreach(QObject *child, series->children()) { if (qobject_cast(child)) { - // TODO: -// series->append(qobject_cast(child)); + DeclarativeXyPoint *point = qobject_cast(child); + series->append(point->x(), point->y()); } else if(qobject_cast(child)) { QVXYModelMapper *mapper = qobject_cast(child); mapper->setSeries(series); diff --git a/plugins/declarative/plugin.cpp b/plugins/declarative/plugin.cpp index 4294794..40e896f 100644 --- a/plugins/declarative/plugin.cpp +++ b/plugins/declarative/plugin.cpp @@ -69,6 +69,8 @@ public: qmlRegisterUncreatableType(uri, 1, 0, "Legend", QLatin1String("Trying to create uncreatable: Legend.")); + qmlRegisterUncreatableType(uri, 1, 0, "QXYSeries", + QLatin1String("Trying to create uncreatable: QXYSeries.")); qmlRegisterUncreatableType(uri, 1, 0, "QScatterSeries", QLatin1String("Trying to create uncreatable: QScatterSeries.")); qmlRegisterUncreatableType(uri, 1, 0, "QPieSeries", diff --git a/src/axis/qaxis.h b/src/axis/qaxis.h index a2651a4..1940963 100644 --- a/src/axis/qaxis.h +++ b/src/axis/qaxis.h @@ -42,8 +42,8 @@ class QTCOMMERCIALCHART_EXPORT QAxis : public QObject Q_PROPERTY(bool shadesVisible READ shadesVisible WRITE setShadesVisible NOTIFY shadesVisibleChanged) Q_PROPERTY(QColor shadesColor READ shadesColor WRITE setShadesColor NOTIFY shadesColorChanged) Q_PROPERTY(QColor shadesBorderColor READ shadesBorderColor WRITE setShadesBorderColor NOTIFY shadesBorderColorChanged) - Q_PROPERTY(qreal min READ min WRITE setMin) - Q_PROPERTY(qreal max READ max WRITE setMax) + 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) @@ -115,8 +115,6 @@ Q_SIGNALS: void visibleChanged(bool visible); void labelsVisibleChanged(bool visible); void gridVisibleChanged(bool visible); - void minChanged(qreal min); - void maxChanged(qreal max); void rangeChanged(qreal min, qreal max); void colorChanged(QColor color); void labelsColorChanged(QColor color); @@ -124,6 +122,8 @@ Q_SIGNALS: 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); diff --git a/src/barchart/qbarseries.cpp b/src/barchart/qbarseries.cpp index 8135964..b6f3160 100644 --- a/src/barchart/qbarseries.cpp +++ b/src/barchart/qbarseries.cpp @@ -48,7 +48,7 @@ QTCOMMERCIALCHART_BEGIN_NAMESPACE /*! \property QBarSeries::barWidth - \brief Sets the width of the bars of the series. The unit of \a width is the unit of x-axis. The minimum width for bars + \brief The width of the bars of the series. The unit of \a width is the unit of x-axis. The minimum width for bars is zero and negative values are treated as zero. Setting the width to zero means that width of the bar on screen is one pixel no matter what the scale of x-axis is. Bars wider than zero are scaled with x-axis. Note that with QGroupedBarSeries this value means the width of one group of bars instead of just one bar. This is @@ -82,9 +82,9 @@ QTCOMMERCIALCHART_BEGIN_NAMESPACE Parameter \a status is true, if mouse entered on top of series, false if mouse left from top of series. */ /*! - \fn void QBarSeries::barWidthChanged() + \fn void QBarSeries::barWidthChanged(qreal) - This signal is emitted when bar width has been changed. + This signal is emitted when bar width has been changed to \a width. */ /*! @@ -153,25 +153,13 @@ QAbstractSeries::SeriesType QBarSeries::type() const return QAbstractSeries::SeriesTypeBar; } -/*! - Sets the width of the bars of the series. The unit of \a width is the unit of x-axis. The minimum width for bars - is zero and negative values are treated as zero. Setting the width to zero means that width of the bar on screen - is one pixel no matter what the scale of x-axis is. Bars wider than zero are scaled with x-axis. - Note that with QGroupedBarSeries this value means the width of one group of bars instead of just one bar. This is - because with grouped series it is more logical to set widht of whole group and let the chart calculate correct - width for bar. - \sa QGroupedBarSeries -*/ void QBarSeries::setBarWidth(qreal width) { Q_D(QBarSeries); d->setBarWidth(width); - emit barWidthChanged(); + emit barWidthChanged(width); } -/*! - Returns the width of bars. -*/ qreal QBarSeries::barWidth() const { Q_D(const QBarSeries); @@ -181,7 +169,6 @@ qreal QBarSeries::barWidth() const /*! Adds a set of bars to series. Takes ownership of \a set. If the set is null or is already in series, it won't be appended. Returns true, if appending succeeded. - */ bool QBarSeries::append(QBarSet *set) { diff --git a/src/barchart/qbarseries.h b/src/barchart/qbarseries.h index 101e5fe..4aaa154 100644 --- a/src/barchart/qbarseries.h +++ b/src/barchart/qbarseries.h @@ -63,7 +63,7 @@ protected: Q_SIGNALS: void clicked(QBarSet *barset, int index); void hovered(QBarSet* barset, bool status); - void barWidthChanged(); + void barWidthChanged(qreal width); void countChanged(); void labelsVisibleChanged(); diff --git a/src/barchart/qbarset.cpp b/src/barchart/qbarset.cpp index c0a02f3..0d87d1a 100644 --- a/src/barchart/qbarset.cpp +++ b/src/barchart/qbarset.cpp @@ -63,6 +63,21 @@ QTCOMMERCIALCHART_BEGIN_NAMESPACE */ /*! + \property QBarSet::color + \brief The fill (brush) color of the bar set. +*/ + +/*! + \property QBarSet::borderColor + \brief The line (pen) color of the bar set. +*/ + +/*! + \property QBarSet::labelColor + \brief The text (label) color of the bar set. +*/ + +/*! \fn void QBarSet::labelChanged() This signal is emitted when the label of the barSet has changed. @@ -103,6 +118,21 @@ QTCOMMERCIALCHART_BEGIN_NAMESPACE */ /*! + \fn void QBarSet::colorChanged(QColor) + This signal is emitted when the fill (brush) color of the set has changed to \a color. +*/ + +/*! + \fn void QBarSet::borderColorChanged(QColor) + This signal is emitted when the line (pen) color of the set has changed to \a color. +*/ + +/*! + \fn void QBarSet::labelColorChanged(QColor) + This signal is emitted when the text (label) color of the set has changed to \a color. +*/ + +/*! \fn void QBarSet::valuesAdded(int index, int count) This signal is emitted when new values have been added to the set. @@ -413,6 +443,51 @@ QFont QBarSet::labelFont() const return d_ptr->m_labelFont; } +QColor QBarSet::color() +{ + return brush().color(); +} + +void QBarSet::setColor(QColor color) +{ + QBrush b = brush(); + if (b.color() != color) { + b.setColor(color); + setBrush(b); + emit colorChanged(color); + } +} + +QColor QBarSet::borderColor() +{ + return pen().color(); +} + +void QBarSet::setBorderColor(QColor color) +{ + QPen p = pen(); + if (p.color() != color) { + p.setColor(color); + setPen(p); + emit borderColorChanged(color); + } +} + +QColor QBarSet::labelColor() +{ + return labelBrush().color(); +} + +void QBarSet::setLabelColor(QColor color) +{ + QBrush b = labelBrush(); + if (b.color() != color) { + b.setColor(color); + setLabelBrush(b); + emit labelColorChanged(color); + } +} + //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// QBarSetPrivate::QBarSetPrivate(const QString label, QBarSet *parent) : QObject(parent), diff --git a/src/barchart/qbarset.h b/src/barchart/qbarset.h index cbe3320..bbe2f33 100644 --- a/src/barchart/qbarset.h +++ b/src/barchart/qbarset.h @@ -37,6 +37,9 @@ class QTCOMMERCIALCHART_EXPORT QBarSet : public QObject Q_PROPERTY(QBrush brush READ brush WRITE setBrush NOTIFY brushChanged) Q_PROPERTY(QBrush labelBrush READ labelBrush WRITE setLabelBrush NOTIFY labelBrushChanged) Q_PROPERTY(QFont labelFont READ labelFont WRITE setLabelFont NOTIFY labelFontChanged) + Q_PROPERTY(QColor color READ color WRITE setColor NOTIFY colorChanged) + Q_PROPERTY(QColor borderColor READ borderColor WRITE setBorderColor NOTIFY borderColorChanged) + Q_PROPERTY(QColor labelColor READ labelColor WRITE setLabelColor NOTIFY labelColorChanged) public: explicit QBarSet(const QString label, QObject *parent = 0); @@ -75,12 +78,24 @@ public: void setLabelFont(const QFont &font); QFont labelFont() const; + QColor color(); + void setColor(QColor color); + + QColor borderColor(); + void setBorderColor(QColor color); + + QColor labelColor(); + void setLabelColor(QColor color); + Q_SIGNALS: void penChanged(); void brushChanged(); void labelChanged(); void labelBrushChanged(); void labelFontChanged(); + void colorChanged(QColor color); + void borderColorChanged(QColor color); + void labelColorChanged(QColor color); void valuesAdded(int index, int count); void valuesRemoved(int index, int count); diff --git a/src/xychart/qxyseries.cpp b/src/xychart/qxyseries.cpp index c11ecde..f99109b 100644 --- a/src/xychart/qxyseries.cpp +++ b/src/xychart/qxyseries.cpp @@ -37,12 +37,6 @@ QTCOMMERCIALCHART_BEGIN_NAMESPACE */ /*! - \property QXYSeries::count - - Number of points in the series. -*/ - -/*! \fn QPen QXYSeries::pen() const \brief Returns pen used to draw points for series. \sa setPen() @@ -78,6 +72,11 @@ QTCOMMERCIALCHART_BEGIN_NAMESPACE */ /*! + \fn void QXYSeries::pointsVisibleChanged(bool visible) + \brief Signal is emitted when the point visibility has changed to \a visible. +*/ + +/*! \fn void QXYSeriesPrivate::updated() \brief \internal */ @@ -262,6 +261,7 @@ 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 087aa7a..6125d07 100644 --- a/src/xychart/qxyseries.h +++ b/src/xychart/qxyseries.h @@ -36,8 +36,7 @@ class QXYModelMapper; class QTCOMMERCIALCHART_EXPORT QXYSeries : public QAbstractSeries { Q_OBJECT - Q_PROPERTY(bool pointsVisible READ pointsVisible WRITE setPointsVisible) - Q_PROPERTY(int count READ count) + Q_PROPERTY(bool pointsVisible READ pointsVisible WRITE setPointsVisible NOTIFY pointsVisibleChanged) protected: explicit QXYSeries(QXYSeriesPrivate &d,QObject *parent = 0); @@ -74,6 +73,8 @@ Q_SIGNALS: void pointReplaced(int index); void pointRemoved(int index); void pointAdded(int index); + void pointsVisibleChanged(bool visible); + private: Q_DECLARE_PRIVATE(QXYSeries) diff --git a/tests/auto/qbarset/tst_qbarset.cpp b/tests/auto/qbarset/tst_qbarset.cpp index 081730b..4200a21 100644 --- a/tests/auto/qbarset/tst_qbarset.cpp +++ b/tests/auto/qbarset/tst_qbarset.cpp @@ -130,7 +130,8 @@ void tst_QBarSet::append() QCOMPARE(m_barset->count(), 0); QVERIFY(qFuzzyIsNull(m_barset->sum())); - QSignalSpy valueSpy(m_barset,SIGNAL(valuesAdded(int,int))); + QSignalSpy valueSpy(m_barset, SIGNAL(valuesAdded(int,int))); + QSignalSpy countSpy(m_barset, SIGNAL(countChanged(int))); qreal sum(0.0); qreal value(0.0); @@ -145,7 +146,8 @@ void tst_QBarSet::append() QCOMPARE(m_barset->count(), count); QVERIFY(qFuzzyCompare(m_barset->sum(), sum)); - QVERIFY(valueSpy.count() == count); + QCOMPARE(valueSpy.count(), count); + QCOMPARE(countSpy.count(), count); } void tst_QBarSet::appendOperator_data() @@ -161,6 +163,7 @@ void tst_QBarSet::appendOperator() QVERIFY(qFuzzyIsNull(m_barset->sum())); QSignalSpy valueSpy(m_barset,SIGNAL(valuesAdded(int,int))); + QSignalSpy countSpy(m_barset, SIGNAL(countChanged(int))); qreal sum(0.0); qreal value(0.0); @@ -174,8 +177,8 @@ void tst_QBarSet::appendOperator() QCOMPARE(m_barset->count(), count); QVERIFY(qFuzzyCompare(m_barset->sum(), sum)); - QVERIFY(valueSpy.count() == count); - + QCOMPARE(valueSpy.count(), count); + QCOMPARE(countSpy.count(), count); } void tst_QBarSet::insert_data() @@ -187,6 +190,7 @@ void tst_QBarSet::insert() QCOMPARE(m_barset->count(), 0); QVERIFY(qFuzzyIsNull(m_barset->sum())); QSignalSpy valueSpy(m_barset,SIGNAL(valuesAdded(int,int))); + QSignalSpy countSpy(m_barset, SIGNAL(countChanged(int))); m_barset->insert(0, 1.0); // 1.0 QCOMPARE(m_barset->at(0).y(), 1.0); @@ -205,7 +209,8 @@ void tst_QBarSet::insert() QCOMPARE(m_barset->at(2).y(), 1.0); QCOMPARE(m_barset->count(), 3); QVERIFY(qFuzzyCompare(m_barset->sum(), 6.0)); - QVERIFY(valueSpy.count() == 3); + QCOMPARE(valueSpy.count(), 3); + QCOMPARE(countSpy.count(), 3); } void tst_QBarSet::remove_data() @@ -218,6 +223,7 @@ void tst_QBarSet::remove() QVERIFY(qFuzzyIsNull(m_barset->sum())); QSignalSpy valueSpy(m_barset,SIGNAL(valuesRemoved(int,int))); + QSignalSpy countSpy(m_barset, SIGNAL(countChanged(int))); m_barset->append(1.0); m_barset->append(2.0); @@ -240,7 +246,8 @@ void tst_QBarSet::remove() QCOMPARE(m_barset->count(), 2); QCOMPARE(m_barset->sum(), 6.0); - QVERIFY(valueSpy.count() == 2); + QCOMPARE(valueSpy.count(), 2); + QCOMPARE(countSpy.count(), 6); } void tst_QBarSet::replace_data() diff --git a/tests/qmlchartproperties/qml/qmlchartproperties/BarEditor.qml b/tests/qmlchartproperties/qml/qmlchartproperties/BarEditor.qml index 8f325b6..68e5727 100644 --- a/tests/qmlchartproperties/qml/qmlchartproperties/BarEditor.qml +++ b/tests/qmlchartproperties/qml/qmlchartproperties/BarEditor.qml @@ -37,17 +37,18 @@ Flow { ignoreUnknownSignals: true onNameChanged: console.log("series.onNameChanged: " + series.name); onVisibleChanged: console.log("series.onVisibleChanged: " + series.visible); + onBarWidthChanged: console.log("series.onBardWidthChanged: " + width) onLabelsVisibleChanged: console.log("series.onLabelsVisibleChanged: " + series.labelsVisible); - onCountChanged: console.log("series.onCountChanged: " + series.count); + onCountChanged: console.log("series.onCountChanged: " + count); } Connections { id: setConnections ignoreUnknownSignals: true - onColorChanged: console.log("series.onColorChanged: " + series.color); - onBorderColorChanged: console.log("series.onBorderColorChanged: " + series.borderColor); - onLabelColorChanged: console.log("series.onLabelColorChanged: " + series.labelColor); - onCountChanged: console.log("series.onCountChanged: " + series.count); + 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 { diff --git a/tests/qmlchartproperties/qml/qmlchartproperties/ChartEditor.qml b/tests/qmlchartproperties/qml/qmlchartproperties/ChartEditor.qml index 6457f4a..c068476 100644 --- a/tests/qmlchartproperties/qml/qmlchartproperties/ChartEditor.qml +++ b/tests/qmlchartproperties/qml/qmlchartproperties/ChartEditor.qml @@ -68,8 +68,10 @@ Flow { onShadesVisibleChanged: console.log("axisX.onShadesVisibleChanged: " + visible); onShadesColorChanged: console.log("axisX.onShadesColorChanged: " + color); onShadesBorderColorChanged: console.log("axisX.onShadesBorderColorChanged: " + color); - onNiceNumbersEnabledChanged: console.log("axisX.onNiceNumbersEnabledChanged: " + enabled); + 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 { @@ -84,8 +86,10 @@ Flow { onShadesVisibleChanged: console.log("axisY.onShadesVisibleChanged: " + visible); onShadesColorChanged: console.log("axisY.onShadesColorChanged: " + color); onShadesBorderColorChanged: console.log("axisY.onShadesBorderColorChanged: " + color); - onNiceNumbersEnabledChanged: console.log("axisY.onNiceNumbersEnabledChanged: " + enabled); + 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 { @@ -177,10 +181,6 @@ Flow { onClicked: series.legend.alignment ^= Qt.AlignRight; } Button { - text: "axis X nice nmb" - onClicked: series.axisX.niceNumbersEnabled = !series.axisX.niceNumbersEnabled; - } - Button { text: "axis X visible" onClicked: series.axisX.visible = !series.axisX.visible; } @@ -221,6 +221,22 @@ Flow { onClicked: series.axisX.shadesBorderColor = main.nextColor(); } Button { + text: "axis X max +" + onClicked: series.axisX.max += 0.1; + } + Button { + text: "axis X max -" + onClicked: series.axisX.max -= 0.1; + } + Button { + text: "axis X min +" + onClicked: series.axisX.min += 0.1; + } + Button { + text: "axis X min -" + onClicked: series.axisX.min -= 0.1; + } + Button { text: "axis X ticks count +" onClicked: series.axisX.ticksCount++; } @@ -229,8 +245,8 @@ Flow { onClicked: series.axisX.ticksCount--; } Button { - text: "axis Y nice nmb" - onClicked: series.axisY.niceNumbersEnabled = !series.axisY.niceNumbersEnabled; + text: "axis X nice nmb" + onClicked: series.axisX.niceNumbersEnabled = !series.axisX.niceNumbersEnabled; } Button { text: "axis Y visible" @@ -273,6 +289,22 @@ Flow { onClicked: series.axisY.shadesBorderColor = main.nextColor(); } Button { + text: "axis Y max +" + onClicked: series.axisY.max += 0.1; + } + Button { + text: "axis Y max -" + onClicked: series.axisY.max -= 0.1; + } + Button { + text: "axis Y min +" + onClicked: series.axisY.min += 0.1; + } + Button { + text: "axis Y min -" + onClicked: series.axisY.min -= 0.1; + } + Button { text: "axis Y ticks count +" onClicked: series.axisY.ticksCount++; } @@ -280,4 +312,8 @@ Flow { text: "axis Y ticks count -" onClicked: series.axisY.ticksCount--; } + Button { + text: "axis Y nice nmb" + onClicked: series.axisY.niceNumbersEnabled = !series.axisY.niceNumbersEnabled; + } }