##// END OF EJS Templates
Property notifications: axis minmax, bar properties, xyseries p-visibl and count
Tero Ahola -
r1465:7735835ca38c
parent child
Show More
@@ -29,6 +29,15 QTCOMMERCIALCHART_BEGIN_NAMESPACE
29 29 DeclarativeBarSet::DeclarativeBarSet(QObject *parent) :
30 30 QBarSet("", parent)
31 31 {
32 connect(this, SIGNAL(valuesAdded(int,int)), this, SLOT(handleCountChanged(int, int)));
33 connect(this, SIGNAL(valuesRemoved(int,int)), this, SLOT(handleCountChanged(int, int)));
34 }
35
36 void DeclarativeBarSet::handleCountChanged(int index, int count)
37 {
38 Q_UNUSED(index)
39 Q_UNUSED(count)
40 emit countChanged(QBarSet::count());
32 41 }
33 42
34 43 QVariantList DeclarativeBarSet::values()
@@ -50,42 +59,6 void DeclarativeBarSet::setValues(QVariantList values)
50 59 }
51 60 }
52 61
53 QColor DeclarativeBarSet::color()
54 {
55 return brush().color();
56 }
57
58 void DeclarativeBarSet::setColor(QColor color)
59 {
60 QBrush b = brush();
61 b.setColor(color);
62 setBrush(b);
63 }
64
65 QColor DeclarativeBarSet::borderColor()
66 {
67 return pen().color();
68 }
69
70 void DeclarativeBarSet::setBorderColor(QColor color)
71 {
72 QPen p = pen();
73 p.setColor(color);
74 setPen(p);
75 }
76
77 QColor DeclarativeBarSet::labelColor()
78 {
79 return labelBrush().color();
80 }
81
82 void DeclarativeBarSet::setLabelColor(QColor color)
83 {
84 QBrush b = labelBrush();
85 b.setColor(color);
86 setLabelBrush(b);
87 }
88
89 62 DeclarativeBarSeries::DeclarativeBarSeries(QDeclarativeItem *parent) :
90 63 QBarSeries(parent)
91 64 {
@@ -37,24 +37,22 class DeclarativeBarSet : public QBarSet
37 37 {
38 38 Q_OBJECT
39 39 Q_PROPERTY(QVariantList values READ values WRITE setValues)
40 Q_PROPERTY(QColor color READ color WRITE setColor)
41 Q_PROPERTY(QColor borderColor READ borderColor WRITE setBorderColor)
42 Q_PROPERTY(QColor labelColor READ labelColor WRITE setLabelColor)
40 Q_PROPERTY(int count READ count NOTIFY countChanged)
43 41
44 42 public:
45 43 explicit DeclarativeBarSet(QObject *parent = 0);
46 44 QVariantList values();
47 45 void setValues(QVariantList values);
48 QColor color();
49 void setColor(QColor color);
50 QColor borderColor();
51 void setBorderColor(QColor color);
52 QColor labelColor();
53 void setLabelColor(QColor color);
54 46
55 47 public: // From QBarSet
56 48 Q_INVOKABLE void append(qreal value) { QBarSet::append(value); }
57 49 Q_INVOKABLE void append(qreal x, qreal y) { QBarSet::append(QPointF(x, y)); }
50
51 Q_SIGNALS:
52 void countChanged(int count);
53
54 private Q_SLOTS:
55 void handleCountChanged(int index, int count);
58 56 };
59 57
60 58 class DeclarativeBarSeries : public QBarSeries, public QDeclarativeParserStatus
@@ -28,6 +28,8 QTCOMMERCIALCHART_BEGIN_NAMESPACE
28 28 DeclarativeLineSeries::DeclarativeLineSeries(QObject *parent) :
29 29 QLineSeries(parent)
30 30 {
31 connect(this, SIGNAL(pointAdded(int)), this, SLOT(handleCountChanged(int)));
32 connect(this, SIGNAL(pointRemoved(int)), this, SLOT(handleCountChanged(int)));
31 33 }
32 34
33 35 QXYSeries *DeclarativeLineSeries::xySeries()
@@ -35,6 +37,12 QXYSeries *DeclarativeLineSeries::xySeries()
35 37 return this;
36 38 }
37 39
40 void DeclarativeLineSeries::handleCountChanged(int index)
41 {
42 Q_UNUSED(index)
43 emit countChanged(points().count());
44 }
45
38 46 QDeclarativeListProperty<QObject> DeclarativeLineSeries::declarativeChildren()
39 47 {
40 48 return QDeclarativeListProperty<QObject>(this, 0, &appendDeclarativeChildren);
@@ -42,10 +50,9 QDeclarativeListProperty<QObject> DeclarativeLineSeries::declarativeChildren()
42 50
43 51 void DeclarativeLineSeries::appendDeclarativeChildren(QDeclarativeListProperty<QObject> *list, QObject *element)
44 52 {
45 QXYSeries *series = qobject_cast<QXYSeries*>(list->object);
46 DeclarativeXyPoint *point = qobject_cast<DeclarativeXyPoint *>(element);
47 if (series && point)
48 series->append(*point);
53 Q_UNUSED(list)
54 Q_UNUSED(element)
55 // Empty implementation, childs are parsed in componentComplete
49 56 }
50 57
51 58 #include "moc_declarativelineseries.cpp"
@@ -35,6 +35,7 class DeclarativeLineSeries : public QLineSeries, public DeclarativeXySeries, pu
35 35 Q_OBJECT
36 36 Q_INTERFACES(QDeclarativeParserStatus)
37 37 Q_PROPERTY(QColor color READ penColor WRITE setPenColor)
38 Q_PROPERTY(int count READ count NOTIFY countChanged)
38 39 Q_PROPERTY(QDeclarativeListProperty<QObject> declarativeChildren READ declarativeChildren)
39 40 Q_CLASSINFO("DefaultProperty", "declarativeChildren")
40 41
@@ -53,8 +54,12 public: // from QLineSeries
53 54 Q_INVOKABLE void clear() { QLineSeries::clear(); }
54 55 Q_INVOKABLE DeclarativeXyPoint *at(int index) { return DeclarativeXySeries::at(index); }
55 56
57 Q_SIGNALS:
58 void countChanged(int count);
59
56 60 public Q_SLOTS:
57 61 static void appendDeclarativeChildren(QDeclarativeListProperty<QObject> *list, QObject *element);
62 void handleCountChanged(int index);
58 63 };
59 64
60 65 QTCOMMERCIALCHART_END_NAMESPACE
@@ -28,6 +28,8 QTCOMMERCIALCHART_BEGIN_NAMESPACE
28 28 DeclarativeScatterSeries::DeclarativeScatterSeries(QObject *parent) :
29 29 QScatterSeries(parent)
30 30 {
31 connect(this, SIGNAL(pointAdded(int)), this, SLOT(handleCountChanged(int)));
32 connect(this, SIGNAL(pointRemoved(int)), this, SLOT(handleCountChanged(int)));
31 33 }
32 34
33 35 QXYSeries *DeclarativeScatterSeries::xySeries()
@@ -35,6 +37,12 QXYSeries *DeclarativeScatterSeries::xySeries()
35 37 return this;
36 38 }
37 39
40 void DeclarativeScatterSeries::handleCountChanged(int index)
41 {
42 Q_UNUSED(index)
43 emit countChanged(QScatterSeries::count());
44 }
45
38 46 QDeclarativeListProperty<QObject> DeclarativeScatterSeries::declarativeChildren()
39 47 {
40 48 return QDeclarativeListProperty<QObject>(this, 0, &appendDeclarativeChildren);
@@ -42,10 +50,9 QDeclarativeListProperty<QObject> DeclarativeScatterSeries::declarativeChildren(
42 50
43 51 void DeclarativeScatterSeries::appendDeclarativeChildren(QDeclarativeListProperty<QObject> *list, QObject *element)
44 52 {
45 QXYSeries *series = qobject_cast<QXYSeries*>(list->object);
46 DeclarativeXyPoint *point = qobject_cast<DeclarativeXyPoint *>(element);
47 if (series && point)
48 series->append(*point);
53 Q_UNUSED(list)
54 Q_UNUSED(element)
55 // Empty implementation, childs are parsed in componentComplete
49 56 }
50 57
51 58 QColor DeclarativeScatterSeries::brushColor()
@@ -35,6 +35,7 class DeclarativeScatterSeries : public QScatterSeries, public DeclarativeXySeri
35 35 Q_INTERFACES(QDeclarativeParserStatus)
36 36 Q_PROPERTY(QColor color READ brushColor WRITE setBrushColor)
37 37 Q_PROPERTY(QColor borderColor READ penColor WRITE setPenColor)
38 Q_PROPERTY(int count READ count NOTIFY countChanged)
38 39 Q_PROPERTY(QDeclarativeListProperty<QObject> declarativeChildren READ declarativeChildren)
39 40 Q_CLASSINFO("DefaultProperty", "declarativeChildren")
40 41
@@ -55,8 +56,12 public: // from QScatterSeries
55 56 Q_INVOKABLE void clear() { QScatterSeries::clear(); }
56 57 Q_INVOKABLE DeclarativeXyPoint *at(int index) { return DeclarativeXySeries::at(index); }
57 58
59 Q_SIGNALS:
60 void countChanged(int count);
61
58 62 public Q_SLOTS:
59 63 static void appendDeclarativeChildren(QDeclarativeListProperty<QObject> *list, QObject *element);
64 void handleCountChanged(int index);
60 65 };
61 66
62 67 QTCOMMERCIALCHART_END_NAMESPACE
@@ -28,6 +28,8 QTCOMMERCIALCHART_BEGIN_NAMESPACE
28 28 DeclarativeSplineSeries::DeclarativeSplineSeries(QObject *parent) :
29 29 QSplineSeries(parent)
30 30 {
31 connect(this, SIGNAL(pointAdded(int)), this, SLOT(handleCountChanged(int)));
32 connect(this, SIGNAL(pointRemoved(int)), this, SLOT(handleCountChanged(int)));
31 33 }
32 34
33 35 QXYSeries *DeclarativeSplineSeries::xySeries()
@@ -35,6 +37,12 QXYSeries *DeclarativeSplineSeries::xySeries()
35 37 return this;
36 38 }
37 39
40 void DeclarativeSplineSeries::handleCountChanged(int index)
41 {
42 Q_UNUSED(index)
43 emit countChanged(points().count());
44 }
45
38 46 QDeclarativeListProperty<QObject> DeclarativeSplineSeries::declarativeChildren()
39 47 {
40 48 return QDeclarativeListProperty<QObject>(this, 0, &appendDeclarativeChildren);
@@ -42,10 +50,9 QDeclarativeListProperty<QObject> DeclarativeSplineSeries::declarativeChildren()
42 50
43 51 void DeclarativeSplineSeries::appendDeclarativeChildren(QDeclarativeListProperty<QObject> *list, QObject *element)
44 52 {
45 QXYSeries *series = qobject_cast<QXYSeries*>(list->object);
46 DeclarativeXyPoint *point = qobject_cast<DeclarativeXyPoint *>(element);
47 if (series && point)
48 series->append(*point);
53 Q_UNUSED(list)
54 Q_UNUSED(element)
55 // Empty implementation, childs are parsed in componentComplete
49 56 }
50 57
51 58 #include "moc_declarativesplineseries.cpp"
@@ -53,8 +53,12 public: // from QSplineSeries
53 53 Q_INVOKABLE void clear() { QSplineSeries::clear(); }
54 54 Q_INVOKABLE DeclarativeXyPoint *at(int index) { return DeclarativeXySeries::at(index); }
55 55
56 Q_SIGNALS:
57 void countChanged(int count);
58
56 59 public Q_SLOTS:
57 60 static void appendDeclarativeChildren(QDeclarativeListProperty<QObject> *list, QObject *element);
61 void handleCountChanged(int index);
58 62 };
59 63
60 64 QTCOMMERCIALCHART_END_NAMESPACE
@@ -47,8 +47,8 void DeclarativeXySeries::componentComplete()
47 47
48 48 foreach(QObject *child, series->children()) {
49 49 if (qobject_cast<DeclarativeXyPoint *>(child)) {
50 // TODO:
51 // series->append(qobject_cast<DeclarativeXyPoint *>(child));
50 DeclarativeXyPoint *point = qobject_cast<DeclarativeXyPoint *>(child);
51 series->append(point->x(), point->y());
52 52 } else if(qobject_cast<QVXYModelMapper *>(child)) {
53 53 QVXYModelMapper *mapper = qobject_cast<QVXYModelMapper *>(child);
54 54 mapper->setSeries(series);
@@ -69,6 +69,8 public:
69 69
70 70 qmlRegisterUncreatableType<QLegend>(uri, 1, 0, "Legend",
71 71 QLatin1String("Trying to create uncreatable: Legend."));
72 qmlRegisterUncreatableType<QXYSeries>(uri, 1, 0, "QXYSeries",
73 QLatin1String("Trying to create uncreatable: QXYSeries."));
72 74 qmlRegisterUncreatableType<QScatterSeries>(uri, 1, 0, "QScatterSeries",
73 75 QLatin1String("Trying to create uncreatable: QScatterSeries."));
74 76 qmlRegisterUncreatableType<QPieSeries>(uri, 1, 0, "QPieSeries",
@@ -42,8 +42,8 class QTCOMMERCIALCHART_EXPORT QAxis : public QObject
42 42 Q_PROPERTY(bool shadesVisible READ shadesVisible WRITE setShadesVisible NOTIFY shadesVisibleChanged)
43 43 Q_PROPERTY(QColor shadesColor READ shadesColor WRITE setShadesColor NOTIFY shadesColorChanged)
44 44 Q_PROPERTY(QColor shadesBorderColor READ shadesBorderColor WRITE setShadesBorderColor NOTIFY shadesBorderColorChanged)
45 Q_PROPERTY(qreal min READ min WRITE setMin)
46 Q_PROPERTY(qreal max READ max WRITE setMax)
45 Q_PROPERTY(qreal min READ min WRITE setMin NOTIFY minChanged)
46 Q_PROPERTY(qreal max READ max WRITE setMax NOTIFY maxChanged)
47 47 Q_PROPERTY(int ticksCount READ ticksCount WRITE setTicksCount NOTIFY ticksCountChanged)
48 48 Q_PROPERTY(bool niceNumbersEnabled READ niceNumbersEnabled WRITE setNiceNumbersEnabled NOTIFY niceNumbersEnabledChanged)
49 49
@@ -115,8 +115,6 Q_SIGNALS:
115 115 void visibleChanged(bool visible);
116 116 void labelsVisibleChanged(bool visible);
117 117 void gridVisibleChanged(bool visible);
118 void minChanged(qreal min);
119 void maxChanged(qreal max);
120 118 void rangeChanged(qreal min, qreal max);
121 119 void colorChanged(QColor color);
122 120 void labelsColorChanged(QColor color);
@@ -124,6 +122,8 Q_SIGNALS:
124 122 void shadesVisibleChanged(bool visible);
125 123 void shadesColorChanged(QColor color);
126 124 void shadesBorderColorChanged(QColor color);
125 void minChanged(qreal min);
126 void maxChanged(qreal max);
127 127 void ticksCountChanged(int count);
128 128 void niceNumbersEnabledChanged(bool enabled);
129 129
@@ -48,7 +48,7 QTCOMMERCIALCHART_BEGIN_NAMESPACE
48 48
49 49 /*!
50 50 \property QBarSeries::barWidth
51 \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
51 \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
52 52 is zero and negative values are treated as zero. Setting the width to zero means that width of the bar on screen
53 53 is one pixel no matter what the scale of x-axis is. Bars wider than zero are scaled with x-axis.
54 54 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
82 82 Parameter \a status is true, if mouse entered on top of series, false if mouse left from top of series.
83 83 */
84 84 /*!
85 \fn void QBarSeries::barWidthChanged()
85 \fn void QBarSeries::barWidthChanged(qreal)
86 86
87 This signal is emitted when bar width has been changed.
87 This signal is emitted when bar width has been changed to \a width.
88 88 */
89 89
90 90 /*!
@@ -153,25 +153,13 QAbstractSeries::SeriesType QBarSeries::type() const
153 153 return QAbstractSeries::SeriesTypeBar;
154 154 }
155 155
156 /*!
157 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
158 is zero and negative values are treated as zero. Setting the width to zero means that width of the bar on screen
159 is one pixel no matter what the scale of x-axis is. Bars wider than zero are scaled with x-axis.
160 Note that with QGroupedBarSeries this value means the width of one group of bars instead of just one bar. This is
161 because with grouped series it is more logical to set widht of whole group and let the chart calculate correct
162 width for bar.
163 \sa QGroupedBarSeries
164 */
165 156 void QBarSeries::setBarWidth(qreal width)
166 157 {
167 158 Q_D(QBarSeries);
168 159 d->setBarWidth(width);
169 emit barWidthChanged();
160 emit barWidthChanged(width);
170 161 }
171 162
172 /*!
173 Returns the width of bars.
174 */
175 163 qreal QBarSeries::barWidth() const
176 164 {
177 165 Q_D(const QBarSeries);
@@ -181,7 +169,6 qreal QBarSeries::barWidth() const
181 169 /*!
182 170 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.
183 171 Returns true, if appending succeeded.
184
185 172 */
186 173 bool QBarSeries::append(QBarSet *set)
187 174 {
@@ -63,7 +63,7 protected:
63 63 Q_SIGNALS:
64 64 void clicked(QBarSet *barset, int index);
65 65 void hovered(QBarSet* barset, bool status);
66 void barWidthChanged();
66 void barWidthChanged(qreal width);
67 67 void countChanged();
68 68 void labelsVisibleChanged();
69 69
@@ -63,6 +63,21 QTCOMMERCIALCHART_BEGIN_NAMESPACE
63 63 */
64 64
65 65 /*!
66 \property QBarSet::color
67 \brief The fill (brush) color of the bar set.
68 */
69
70 /*!
71 \property QBarSet::borderColor
72 \brief The line (pen) color of the bar set.
73 */
74
75 /*!
76 \property QBarSet::labelColor
77 \brief The text (label) color of the bar set.
78 */
79
80 /*!
66 81 \fn void QBarSet::labelChanged()
67 82
68 83 This signal is emitted when the label of the barSet has changed.
@@ -103,6 +118,21 QTCOMMERCIALCHART_BEGIN_NAMESPACE
103 118 */
104 119
105 120 /*!
121 \fn void QBarSet::colorChanged(QColor)
122 This signal is emitted when the fill (brush) color of the set has changed to \a color.
123 */
124
125 /*!
126 \fn void QBarSet::borderColorChanged(QColor)
127 This signal is emitted when the line (pen) color of the set has changed to \a color.
128 */
129
130 /*!
131 \fn void QBarSet::labelColorChanged(QColor)
132 This signal is emitted when the text (label) color of the set has changed to \a color.
133 */
134
135 /*!
106 136 \fn void QBarSet::valuesAdded(int index, int count)
107 137
108 138 This signal is emitted when new values have been added to the set.
@@ -413,6 +443,51 QFont QBarSet::labelFont() const
413 443 return d_ptr->m_labelFont;
414 444 }
415 445
446 QColor QBarSet::color()
447 {
448 return brush().color();
449 }
450
451 void QBarSet::setColor(QColor color)
452 {
453 QBrush b = brush();
454 if (b.color() != color) {
455 b.setColor(color);
456 setBrush(b);
457 emit colorChanged(color);
458 }
459 }
460
461 QColor QBarSet::borderColor()
462 {
463 return pen().color();
464 }
465
466 void QBarSet::setBorderColor(QColor color)
467 {
468 QPen p = pen();
469 if (p.color() != color) {
470 p.setColor(color);
471 setPen(p);
472 emit borderColorChanged(color);
473 }
474 }
475
476 QColor QBarSet::labelColor()
477 {
478 return labelBrush().color();
479 }
480
481 void QBarSet::setLabelColor(QColor color)
482 {
483 QBrush b = labelBrush();
484 if (b.color() != color) {
485 b.setColor(color);
486 setLabelBrush(b);
487 emit labelColorChanged(color);
488 }
489 }
490
416 491 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
417 492
418 493 QBarSetPrivate::QBarSetPrivate(const QString label, QBarSet *parent) : QObject(parent),
@@ -37,6 +37,9 class QTCOMMERCIALCHART_EXPORT QBarSet : public QObject
37 37 Q_PROPERTY(QBrush brush READ brush WRITE setBrush NOTIFY brushChanged)
38 38 Q_PROPERTY(QBrush labelBrush READ labelBrush WRITE setLabelBrush NOTIFY labelBrushChanged)
39 39 Q_PROPERTY(QFont labelFont READ labelFont WRITE setLabelFont NOTIFY labelFontChanged)
40 Q_PROPERTY(QColor color READ color WRITE setColor NOTIFY colorChanged)
41 Q_PROPERTY(QColor borderColor READ borderColor WRITE setBorderColor NOTIFY borderColorChanged)
42 Q_PROPERTY(QColor labelColor READ labelColor WRITE setLabelColor NOTIFY labelColorChanged)
40 43
41 44 public:
42 45 explicit QBarSet(const QString label, QObject *parent = 0);
@@ -75,12 +78,24 public:
75 78 void setLabelFont(const QFont &font);
76 79 QFont labelFont() const;
77 80
81 QColor color();
82 void setColor(QColor color);
83
84 QColor borderColor();
85 void setBorderColor(QColor color);
86
87 QColor labelColor();
88 void setLabelColor(QColor color);
89
78 90 Q_SIGNALS:
79 91 void penChanged();
80 92 void brushChanged();
81 93 void labelChanged();
82 94 void labelBrushChanged();
83 95 void labelFontChanged();
96 void colorChanged(QColor color);
97 void borderColorChanged(QColor color);
98 void labelColorChanged(QColor color);
84 99
85 100 void valuesAdded(int index, int count);
86 101 void valuesRemoved(int index, int count);
@@ -37,12 +37,6 QTCOMMERCIALCHART_BEGIN_NAMESPACE
37 37 */
38 38
39 39 /*!
40 \property QXYSeries::count
41
42 Number of points in the series.
43 */
44
45 /*!
46 40 \fn QPen QXYSeries::pen() const
47 41 \brief Returns pen used to draw points for series.
48 42 \sa setPen()
@@ -78,6 +72,11 QTCOMMERCIALCHART_BEGIN_NAMESPACE
78 72 */
79 73
80 74 /*!
75 \fn void QXYSeries::pointsVisibleChanged(bool visible)
76 \brief Signal is emitted when the point visibility has changed to \a visible.
77 */
78
79 /*!
81 80 \fn void QXYSeriesPrivate::updated()
82 81 \brief \internal
83 82 */
@@ -262,6 +261,7 void QXYSeries::setPointsVisible(bool visible)
262 261 if (d->m_pointsVisible != visible){
263 262 d->m_pointsVisible = visible;
264 263 emit d->updated();
264 emit pointsVisibleChanged(visible);
265 265 }
266 266 }
267 267
@@ -36,8 +36,7 class QXYModelMapper;
36 36 class QTCOMMERCIALCHART_EXPORT QXYSeries : public QAbstractSeries
37 37 {
38 38 Q_OBJECT
39 Q_PROPERTY(bool pointsVisible READ pointsVisible WRITE setPointsVisible)
40 Q_PROPERTY(int count READ count)
39 Q_PROPERTY(bool pointsVisible READ pointsVisible WRITE setPointsVisible NOTIFY pointsVisibleChanged)
41 40
42 41 protected:
43 42 explicit QXYSeries(QXYSeriesPrivate &d,QObject *parent = 0);
@@ -74,6 +73,8 Q_SIGNALS:
74 73 void pointReplaced(int index);
75 74 void pointRemoved(int index);
76 75 void pointAdded(int index);
76 void pointsVisibleChanged(bool visible);
77
77 78
78 79 private:
79 80 Q_DECLARE_PRIVATE(QXYSeries)
@@ -130,7 +130,8 void tst_QBarSet::append()
130 130 QCOMPARE(m_barset->count(), 0);
131 131 QVERIFY(qFuzzyIsNull(m_barset->sum()));
132 132
133 QSignalSpy valueSpy(m_barset,SIGNAL(valuesAdded(int,int)));
133 QSignalSpy valueSpy(m_barset, SIGNAL(valuesAdded(int,int)));
134 QSignalSpy countSpy(m_barset, SIGNAL(countChanged(int)));
134 135
135 136 qreal sum(0.0);
136 137 qreal value(0.0);
@@ -145,7 +146,8 void tst_QBarSet::append()
145 146 QCOMPARE(m_barset->count(), count);
146 147 QVERIFY(qFuzzyCompare(m_barset->sum(), sum));
147 148
148 QVERIFY(valueSpy.count() == count);
149 QCOMPARE(valueSpy.count(), count);
150 QCOMPARE(countSpy.count(), count);
149 151 }
150 152
151 153 void tst_QBarSet::appendOperator_data()
@@ -161,6 +163,7 void tst_QBarSet::appendOperator()
161 163 QVERIFY(qFuzzyIsNull(m_barset->sum()));
162 164
163 165 QSignalSpy valueSpy(m_barset,SIGNAL(valuesAdded(int,int)));
166 QSignalSpy countSpy(m_barset, SIGNAL(countChanged(int)));
164 167
165 168 qreal sum(0.0);
166 169 qreal value(0.0);
@@ -174,8 +177,8 void tst_QBarSet::appendOperator()
174 177
175 178 QCOMPARE(m_barset->count(), count);
176 179 QVERIFY(qFuzzyCompare(m_barset->sum(), sum));
177 QVERIFY(valueSpy.count() == count);
178
180 QCOMPARE(valueSpy.count(), count);
181 QCOMPARE(countSpy.count(), count);
179 182 }
180 183
181 184 void tst_QBarSet::insert_data()
@@ -187,6 +190,7 void tst_QBarSet::insert()
187 190 QCOMPARE(m_barset->count(), 0);
188 191 QVERIFY(qFuzzyIsNull(m_barset->sum()));
189 192 QSignalSpy valueSpy(m_barset,SIGNAL(valuesAdded(int,int)));
193 QSignalSpy countSpy(m_barset, SIGNAL(countChanged(int)));
190 194
191 195 m_barset->insert(0, 1.0); // 1.0
192 196 QCOMPARE(m_barset->at(0).y(), 1.0);
@@ -205,7 +209,8 void tst_QBarSet::insert()
205 209 QCOMPARE(m_barset->at(2).y(), 1.0);
206 210 QCOMPARE(m_barset->count(), 3);
207 211 QVERIFY(qFuzzyCompare(m_barset->sum(), 6.0));
208 QVERIFY(valueSpy.count() == 3);
212 QCOMPARE(valueSpy.count(), 3);
213 QCOMPARE(countSpy.count(), 3);
209 214 }
210 215
211 216 void tst_QBarSet::remove_data()
@@ -218,6 +223,7 void tst_QBarSet::remove()
218 223 QVERIFY(qFuzzyIsNull(m_barset->sum()));
219 224
220 225 QSignalSpy valueSpy(m_barset,SIGNAL(valuesRemoved(int,int)));
226 QSignalSpy countSpy(m_barset, SIGNAL(countChanged(int)));
221 227
222 228 m_barset->append(1.0);
223 229 m_barset->append(2.0);
@@ -240,7 +246,8 void tst_QBarSet::remove()
240 246 QCOMPARE(m_barset->count(), 2);
241 247 QCOMPARE(m_barset->sum(), 6.0);
242 248
243 QVERIFY(valueSpy.count() == 2);
249 QCOMPARE(valueSpy.count(), 2);
250 QCOMPARE(countSpy.count(), 6);
244 251 }
245 252
246 253 void tst_QBarSet::replace_data()
@@ -37,17 +37,18 Flow {
37 37 ignoreUnknownSignals: true
38 38 onNameChanged: console.log("series.onNameChanged: " + series.name);
39 39 onVisibleChanged: console.log("series.onVisibleChanged: " + series.visible);
40 onBarWidthChanged: console.log("series.onBardWidthChanged: " + width)
40 41 onLabelsVisibleChanged: console.log("series.onLabelsVisibleChanged: " + series.labelsVisible);
41 onCountChanged: console.log("series.onCountChanged: " + series.count);
42 onCountChanged: console.log("series.onCountChanged: " + count);
42 43 }
43 44
44 45 Connections {
45 46 id: setConnections
46 47 ignoreUnknownSignals: true
47 onColorChanged: console.log("series.onColorChanged: " + series.color);
48 onBorderColorChanged: console.log("series.onBorderColorChanged: " + series.borderColor);
49 onLabelColorChanged: console.log("series.onLabelColorChanged: " + series.labelColor);
50 onCountChanged: console.log("series.onCountChanged: " + series.count);
48 onColorChanged: console.log("series.onColorChanged: " + color);
49 onBorderColorChanged: console.log("series.onBorderColorChanged: " + color);
50 onLabelColorChanged: console.log("series.onLabelColorChanged: " + color);
51 onCountChanged: console.log("series.onCountChanged: " + count);
51 52 }
52 53
53 54 Button {
@@ -68,8 +68,10 Flow {
68 68 onShadesVisibleChanged: console.log("axisX.onShadesVisibleChanged: " + visible);
69 69 onShadesColorChanged: console.log("axisX.onShadesColorChanged: " + color);
70 70 onShadesBorderColorChanged: console.log("axisX.onShadesBorderColorChanged: " + color);
71 onNiceNumbersEnabledChanged: console.log("axisX.onNiceNumbersEnabledChanged: " + enabled);
71 onMinChanged: console.log("axisX.onMinChanged: " + min);
72 onMaxChanged: console.log("axisX.onMaxChanged: " + max);
72 73 onTicksCountChanged: console.log("axisX.onTicksCountChanged: " + count);
74 onNiceNumbersEnabledChanged: console.log("axisX.onNiceNumbersEnabledChanged: " + enabled);
73 75 }
74 76
75 77 Connections {
@@ -84,8 +86,10 Flow {
84 86 onShadesVisibleChanged: console.log("axisY.onShadesVisibleChanged: " + visible);
85 87 onShadesColorChanged: console.log("axisY.onShadesColorChanged: " + color);
86 88 onShadesBorderColorChanged: console.log("axisY.onShadesBorderColorChanged: " + color);
87 onNiceNumbersEnabledChanged: console.log("axisY.onNiceNumbersEnabledChanged: " + enabled);
89 onMinChanged: console.log("axisY.onMinChanged: " + min);
90 onMaxChanged: console.log("axisY.onMaxChanged: " + max);
88 91 onTicksCountChanged: console.log("axisY.onTicksCountChanged: " + count);
92 onNiceNumbersEnabledChanged: console.log("axisY.onNiceNumbersEnabledChanged: " + enabled);
89 93 }
90 94
91 95 Button {
@@ -177,10 +181,6 Flow {
177 181 onClicked: series.legend.alignment ^= Qt.AlignRight;
178 182 }
179 183 Button {
180 text: "axis X nice nmb"
181 onClicked: series.axisX.niceNumbersEnabled = !series.axisX.niceNumbersEnabled;
182 }
183 Button {
184 184 text: "axis X visible"
185 185 onClicked: series.axisX.visible = !series.axisX.visible;
186 186 }
@@ -221,6 +221,22 Flow {
221 221 onClicked: series.axisX.shadesBorderColor = main.nextColor();
222 222 }
223 223 Button {
224 text: "axis X max +"
225 onClicked: series.axisX.max += 0.1;
226 }
227 Button {
228 text: "axis X max -"
229 onClicked: series.axisX.max -= 0.1;
230 }
231 Button {
232 text: "axis X min +"
233 onClicked: series.axisX.min += 0.1;
234 }
235 Button {
236 text: "axis X min -"
237 onClicked: series.axisX.min -= 0.1;
238 }
239 Button {
224 240 text: "axis X ticks count +"
225 241 onClicked: series.axisX.ticksCount++;
226 242 }
@@ -229,8 +245,8 Flow {
229 245 onClicked: series.axisX.ticksCount--;
230 246 }
231 247 Button {
232 text: "axis Y nice nmb"
233 onClicked: series.axisY.niceNumbersEnabled = !series.axisY.niceNumbersEnabled;
248 text: "axis X nice nmb"
249 onClicked: series.axisX.niceNumbersEnabled = !series.axisX.niceNumbersEnabled;
234 250 }
235 251 Button {
236 252 text: "axis Y visible"
@@ -273,6 +289,22 Flow {
273 289 onClicked: series.axisY.shadesBorderColor = main.nextColor();
274 290 }
275 291 Button {
292 text: "axis Y max +"
293 onClicked: series.axisY.max += 0.1;
294 }
295 Button {
296 text: "axis Y max -"
297 onClicked: series.axisY.max -= 0.1;
298 }
299 Button {
300 text: "axis Y min +"
301 onClicked: series.axisY.min += 0.1;
302 }
303 Button {
304 text: "axis Y min -"
305 onClicked: series.axisY.min -= 0.1;
306 }
307 Button {
276 308 text: "axis Y ticks count +"
277 309 onClicked: series.axisY.ticksCount++;
278 310 }
@@ -280,4 +312,8 Flow {
280 312 text: "axis Y ticks count -"
281 313 onClicked: series.axisY.ticksCount--;
282 314 }
315 Button {
316 text: "axis Y nice nmb"
317 onClicked: series.axisY.niceNumbersEnabled = !series.axisY.niceNumbersEnabled;
318 }
283 319 }
General Comments 0
You need to be logged in to leave comments. Login now