@@ -269,6 +269,8 bool QPieSeries::append(QList<QPieSlice*> slices) | |||
|
269 | 269 | foreach (QPieSlice* s, slices) { |
|
270 | 270 | if (!s || d->m_slices.contains(s)) |
|
271 | 271 | return false; |
|
272 | if (s->series()) // already added to some series | |
|
273 | return false; | |
|
272 | 274 | } |
|
273 | 275 | |
|
274 | 276 | foreach (QPieSlice* s, slices) { |
@@ -329,6 +331,9 bool QPieSeries::insert(int index, QPieSlice* slice) | |||
|
329 | 331 | if (!slice || d->m_slices.contains(slice)) |
|
330 | 332 | return false; |
|
331 | 333 | |
|
334 | if (slice->series()) // already added to some series | |
|
335 | return false; | |
|
336 | ||
|
332 | 337 | slice->setParent(this); |
|
333 | 338 | QPieSlicePrivate::fromSlice(slice)->m_series = this; |
|
334 | 339 | d->m_slices.insert(index, slice); |
@@ -171,6 +171,10 void tst_qpieseries::append() | |||
|
171 | 171 | QCOMPARE(added.count(), 1); |
|
172 | 172 | QCOMPARE(added.first(), slice1); |
|
173 | 173 | |
|
174 | // try to append same slice to another series | |
|
175 | QPieSeries series2; | |
|
176 | QVERIFY(!series2.append(slice1)); | |
|
177 | ||
|
174 | 178 | // append pointer list |
|
175 | 179 | QList<QPieSlice *> list; |
|
176 | 180 | QVERIFY(!m_series->append(list)); |
@@ -240,6 +244,10 void tst_qpieseries::insert() | |||
|
240 | 244 | QCOMPARE(added.count(), 1); |
|
241 | 245 | QCOMPARE(added.first(), slice1); |
|
242 | 246 | |
|
247 | // try to insert same slice to another series | |
|
248 | QPieSeries series2; | |
|
249 | QVERIFY(!series2.insert(0, slice1)); | |
|
250 | ||
|
243 | 251 | // add some more slices |
|
244 | 252 | QPieSlice *slice2 = m_series->append("slice 2", 2); |
|
245 | 253 | QPieSlice *slice4 = m_series->append("slice 4", 4); |
General Comments 0
You need to be logged in to leave comments.
Login now