@@ -541,6 +541,7 void QXYSeries::insert(int index, const QPointF &point) | |||||
541 | { |
|
541 | { | |
542 | Q_D(QXYSeries); |
|
542 | Q_D(QXYSeries); | |
543 | if (isValidValue(point)) { |
|
543 | if (isValidValue(point)) { | |
|
544 | index = qMax(0, qMin(index, d->m_points.size())); | |||
544 | d->m_points.insert(index, point); |
|
545 | d->m_points.insert(index, point); | |
545 | emit pointAdded(index); |
|
546 | emit pointAdded(index); | |
546 | } |
|
547 | } |
@@ -37,6 +37,7 private slots: | |||||
37 | void pressedSignal(); |
|
37 | void pressedSignal(); | |
38 | void releasedSignal(); |
|
38 | void releasedSignal(); | |
39 | void doubleClickedSignal(); |
|
39 | void doubleClickedSignal(); | |
|
40 | void insert(); | |||
40 | protected: |
|
41 | protected: | |
41 | void pointsVisible_data(); |
|
42 | void pointsVisible_data(); | |
42 | }; |
|
43 | }; | |
@@ -165,6 +166,28 void tst_QLineSeries::releasedSignal() | |||||
165 | QCOMPARE(qRound(signalPoint.y()), qRound(linePoint.y())); |
|
166 | QCOMPARE(qRound(signalPoint.y()), qRound(linePoint.y())); | |
166 | } |
|
167 | } | |
167 |
|
168 | |||
|
169 | void tst_QLineSeries::insert() | |||
|
170 | { | |||
|
171 | QLineSeries lineSeries; | |||
|
172 | QSignalSpy insertSpy(&lineSeries, &QXYSeries::pointAdded); | |||
|
173 | lineSeries.insert(0, QPoint(3, 3)); | |||
|
174 | QCOMPARE(insertSpy.count(), 1); | |||
|
175 | QVariantList arguments = insertSpy.takeFirst(); | |||
|
176 | QCOMPARE(arguments.first().toInt(), 0); | |||
|
177 | lineSeries.insert(0, QPoint(1, 1)); | |||
|
178 | arguments = insertSpy.takeFirst(); | |||
|
179 | QCOMPARE(arguments.first().toInt(), 0); | |||
|
180 | lineSeries.insert(1, QPoint(2, 2)); | |||
|
181 | arguments = insertSpy.takeFirst(); | |||
|
182 | QCOMPARE(arguments.first().toInt(), 1); | |||
|
183 | lineSeries.insert(42, QPoint(0, 0)); | |||
|
184 | arguments = insertSpy.takeFirst(); | |||
|
185 | QCOMPARE(arguments.first().toInt(), 3); | |||
|
186 | lineSeries.insert(-42, QPoint(0, 0)); | |||
|
187 | arguments = insertSpy.takeFirst(); | |||
|
188 | QCOMPARE(arguments.first().toInt(), 0); | |||
|
189 | } | |||
|
190 | ||||
168 | void tst_QLineSeries::doubleClickedSignal() |
|
191 | void tst_QLineSeries::doubleClickedSignal() | |
169 | { |
|
192 | { | |
170 | SKIP_IF_CANNOT_TEST_MOUSE_EVENTS(); |
|
193 | SKIP_IF_CANNOT_TEST_MOUSE_EVENTS(); |
General Comments 0
You need to be logged in to leave comments.
Login now