##// END OF EJS Templates
Renamed appendBarSet to append, removeBarSet to remove
sauimone -
r1194:d962cd819f79
parent child
Show More
@@ -222,7 +222,7 QChart* ThemeWidget::createBarChart(int valueCount) const
222 222 QBarSet *set = new QBarSet("Bar set " + QString::number(i));
223 223 foreach (Data data, m_dataTable[i])
224 224 *set << data.first.y();
225 series->appendBarSet(set);
225 series->append(set);
226 226 }
227 227 chart->addSeries(series);
228 228
@@ -53,11 +53,11 int main(int argc, char *argv[])
53 53 //![3]
54 54 QBarSeries* series = new QBarSeries();
55 55 series->setCategories(categories);
56 series->appendBarSet(set0);
57 series->appendBarSet(set1);
58 series->appendBarSet(set2);
59 series->appendBarSet(set3);
60 series->appendBarSet(set4);
56 series->append(set0);
57 series->append(set1);
58 series->append(set2);
59 series->append(set3);
60 series->append(set4);
61 61
62 62 //![3]
63 63
@@ -53,11 +53,11 int main(int argc, char *argv[])
53 53 //![3]
54 54 QGroupedBarSeries* series = new QGroupedBarSeries();
55 55 series->setCategories(categories);
56 series->appendBarSet(set0);
57 series->appendBarSet(set1);
58 series->appendBarSet(set2);
59 series->appendBarSet(set3);
60 series->appendBarSet(set4);
56 series->append(set0);
57 series->append(set1);
58 series->append(set2);
59 series->append(set3);
60 series->append(set4);
61 61
62 62 //![3]
63 63
@@ -53,11 +53,11 int main(int argc, char *argv[])
53 53 //![3]
54 54 QPercentBarSeries* series = new QPercentBarSeries();
55 55 series->setCategories(categories);
56 series->appendBarSet(set0);
57 series->appendBarSet(set1);
58 series->appendBarSet(set2);
59 series->appendBarSet(set3);
60 series->appendBarSet(set4);
56 series->append(set0);
57 series->append(set1);
58 series->append(set2);
59 series->append(set3);
60 series->append(set4);
61 61 //![3]
62 62
63 63 //![4]
@@ -53,11 +53,11 int main(int argc, char *argv[])
53 53 //![3]
54 54 QStackedBarSeries* series = new QStackedBarSeries();
55 55 series->setCategories(categories);
56 series->appendBarSet(set0);
57 series->appendBarSet(set1);
58 series->appendBarSet(set2);
59 series->appendBarSet(set3);
60 series->appendBarSet(set4);
56 series->append(set0);
57 series->append(set1);
58 series->append(set2);
59 series->append(set3);
60 series->append(set4);
61 61 //![3]
62 62
63 63 //![4]
@@ -86,10 +86,10 int main(int argc, char *argv[])
86 86 foreach (QString week, weeks )
87 87 *weeklyCrop << (qrand() % 20);
88 88 // Get the drilldown series from season series and add crop to it.
89 seasonSeries->drilldownSeries(month)->appendBarSet(weeklyCrop);
89 seasonSeries->drilldownSeries(month)->append(weeklyCrop);
90 90 *monthlyCrop << weeklyCrop->sum();
91 91 }
92 seasonSeries->appendBarSet(monthlyCrop);
92 seasonSeries->append(monthlyCrop);
93 93 }
94 94 //! [5]
95 95
@@ -107,7 +107,7 void QBarSeries::setCategories(QBarCategories categories)
107 107 /*!
108 108 Adds a set of bars to series. Takes ownership of \a set.
109 109 */
110 bool QBarSeries::appendBarSet(QBarSet *set)
110 bool QBarSeries::append(QBarSet *set)
111 111 {
112 112 Q_D(QBarSeries);
113 113 if ((d->m_barSets.contains(set)) || (set == 0)) {
@@ -123,7 +123,7 bool QBarSeries::appendBarSet(QBarSet *set)
123 123 /*!
124 124 Removes a set of bars from series. Releases ownership of \a set. Doesn't delete \a set.
125 125 */
126 bool QBarSeries::removeBarSet(QBarSet *set)
126 bool QBarSeries::remove(QBarSet *set)
127 127 {
128 128 Q_D(QBarSeries);
129 129 if (!d->m_barSets.contains(set)) {
@@ -139,7 +139,7 bool QBarSeries::removeBarSet(QBarSet *set)
139 139 /*!
140 140 Adds a list of barsets to series. Takes ownership of \a sets.
141 141 */
142 bool QBarSeries::appendBarSets(QList<QBarSet* > sets)
142 bool QBarSeries::append(QList<QBarSet* > sets)
143 143 {
144 144 Q_D(QBarSeries);
145 145 foreach (QBarSet* set, sets) {
@@ -164,7 +164,7 bool QBarSeries::appendBarSets(QList<QBarSet* > sets)
164 164 /*!
165 165 Removes a list of barsets from series. Releases ownership of \a sets. Doesn't delete \a sets.
166 166 */
167 bool QBarSeries::removeBarSets(QList<QBarSet* > sets)
167 bool QBarSeries::remove(QList<QBarSet* > sets)
168 168 {
169 169 Q_D(QBarSeries);
170 170
@@ -513,7 +513,7 void QBarSeriesPrivate::initializeDataFromModel()
513 513 QBarSet* barSet = new QBarSet(m_model->headerData(i, Qt::Horizontal, Qt::DisplayRole).toString());
514 514 for(int m = m_mapper->first(); m < m_mapper->first() + rowCount; m++)
515 515 *barSet << m_model->data(m_model->index(m, i), Qt::DisplayRole).toDouble();
516 q->appendBarSet(barSet);
516 q->append(barSet);
517 517 }
518 518 } else {
519 519 if (m_mapCategories >= m_model->rowCount())
@@ -533,7 +533,7 void QBarSeriesPrivate::initializeDataFromModel()
533 533 QBarSet* barSet = new QBarSet(m_model->headerData(i, Qt::Vertical, Qt::DisplayRole).toString());
534 534 for(int m = m_mapper->first(); m < m_mapper->first() + columnCount; m++)
535 535 *barSet << m_model->data(m_model->index(i, m), Qt::DisplayRole).toDouble();
536 q->appendBarSet(barSet);
536 q->append(barSet);
537 537 }
538 538 }
539 539 emit restructuredBars();
@@ -46,10 +46,10 public:
46 46 QAbstractSeries::SeriesType type() const;
47 47 void setCategories(QBarCategories categories);
48 48
49 bool appendBarSet(QBarSet *set); // Takes ownership of set
50 bool removeBarSet(QBarSet *set); // Releases ownership, doesn't delete set
51 bool appendBarSets(QList<QBarSet* > sets);
52 bool removeBarSets(QList<QBarSet* > sets);
49 bool append(QBarSet *set); // Takes ownership of set
50 bool remove(QBarSet *set); // Releases ownership, doesn't delete set
51 bool append(QList<QBarSet* > sets);
52 bool remove(QList<QBarSet* > sets);
53 53 int barsetCount() const;
54 54 int categoryCount() const;
55 55 QList<QBarSet*> barSets() const;
@@ -45,14 +45,14 private slots:
45 45 void type();
46 46 void setCategories_data();
47 47 void setCategories();
48 void appendBarSet_data();
49 void appendBarSet();
50 void removeBarSet_data();
51 void removeBarSet();
52 void appendBarSets_data();
53 void appendBarSets();
54 void removeBarSets_data();
55 void removeBarSets();
48 void append_data();
49 void append();
50 void remove_data();
51 void remove();
52 void appendList_data();
53 void appendList();
54 void removeList_data();
55 void removeList();
56 56 void barsetCount_data();
57 57 void barsetCount();
58 58 void categoryCount_data();
@@ -96,14 +96,14 void tst_QBarSeries::init()
96 96
97 97 for (int i=0; i<5; i++) {
98 98 m_testSets.append(new QBarSet("testset"));
99 m_barseries_with_sets->appendBarSet(m_testSets.at(i));
99 m_barseries_with_sets->append(m_testSets.at(i));
100 100 }
101 101 }
102 102
103 103 void tst_QBarSeries::cleanup()
104 104 {
105 105 foreach(QBarSet* s, m_testSets) {
106 m_barseries_with_sets->removeBarSet(s);
106 m_barseries_with_sets->remove(s);
107 107 delete s;
108 108 }
109 109 m_testSets.clear();
@@ -168,11 +168,11 void tst_QBarSeries::setCategories()
168 168 }
169 169 }
170 170
171 void tst_QBarSeries::appendBarSet_data()
171 void tst_QBarSeries::append_data()
172 172 {
173 173 }
174 174
175 void tst_QBarSeries::appendBarSet()
175 void tst_QBarSeries::append()
176 176 {
177 177 QVERIFY(m_barseries->barsetCount() == 0);
178 178
@@ -180,56 +180,56 void tst_QBarSeries::appendBarSet()
180 180
181 181 // Try adding barset
182 182 QBarSet *barset = new QBarSet("testset");
183 ret = m_barseries->appendBarSet(barset);
183 ret = m_barseries->append(barset);
184 184
185 185 QVERIFY(ret == true);
186 186 QVERIFY(m_barseries->barsetCount() == 1);
187 187
188 188 // Try adding another set
189 189 QBarSet *barset2 = new QBarSet("testset2");
190 ret = m_barseries->appendBarSet(barset2);
190 ret = m_barseries->append(barset2);
191 191
192 192 QVERIFY(ret == true);
193 193 QVERIFY(m_barseries->barsetCount() == 2);
194 194
195 195 // Try adding same set again
196 ret = m_barseries->appendBarSet(barset2);
196 ret = m_barseries->append(barset2);
197 197 QVERIFY(ret == false);
198 198 QVERIFY(m_barseries->barsetCount() == 2);
199 199
200 200 // Try adding null set
201 ret = m_barseries->appendBarSet(0);
201 ret = m_barseries->append(0);
202 202 QVERIFY(ret == false);
203 203 QVERIFY(m_barseries->barsetCount() == 2);
204 204
205 205 }
206 206
207 void tst_QBarSeries::removeBarSet_data()
207 void tst_QBarSeries::remove_data()
208 208 {
209 209 }
210 210
211 void tst_QBarSeries::removeBarSet()
211 void tst_QBarSeries::remove()
212 212 {
213 213 int count = m_testSets.count();
214 214 QVERIFY(m_barseries_with_sets->barsetCount() == count);
215 215
216 216 // Try to remove null pointer (should not remove, should not crash)
217 217 bool ret = false;
218 ret = m_barseries_with_sets->removeBarSet(0);
218 ret = m_barseries_with_sets->remove(0);
219 219 QVERIFY(ret == false);
220 220 QVERIFY(m_barseries_with_sets->barsetCount() == count);
221 221
222 222 // Try to remove invalid pointer (should not remove, should not crash)
223 ret = m_barseries_with_sets->removeBarSet((QBarSet*) (m_testSets.at(0) + 1) );
223 ret = m_barseries_with_sets->remove((QBarSet*) (m_testSets.at(0) + 1) );
224 224 QVERIFY(ret == false);
225 225 QVERIFY(m_barseries_with_sets->barsetCount() == count);
226 226
227 227 // remove some sets
228 ret = m_barseries_with_sets->removeBarSet(m_testSets.at(2));
228 ret = m_barseries_with_sets->remove(m_testSets.at(2));
229 229 QVERIFY(ret == true);
230 ret = m_barseries_with_sets->removeBarSet(m_testSets.at(3));
230 ret = m_barseries_with_sets->remove(m_testSets.at(3));
231 231 QVERIFY(ret == true);
232 ret = m_barseries_with_sets->removeBarSet(m_testSets.at(4));
232 ret = m_barseries_with_sets->remove(m_testSets.at(4));
233 233 QVERIFY(ret == true);
234 234
235 235 QVERIFY(m_barseries_with_sets->barsetCount() == 2);
@@ -242,19 +242,19 void tst_QBarSeries::removeBarSet()
242 242 // Try removing all sets again (should be ok, even if some sets have already been removed)
243 243 ret = false;
244 244 for (int i=0; i<count; i++) {
245 ret |= m_barseries_with_sets->removeBarSet(m_testSets.at(i));
245 ret |= m_barseries_with_sets->remove(m_testSets.at(i));
246 246 }
247 247
248 248 QVERIFY(ret == true);
249 249 QVERIFY(m_barseries_with_sets->barsetCount() == 0);
250 250 }
251 251
252 void tst_QBarSeries::appendBarSets_data()
252 void tst_QBarSeries::appendList_data()
253 253 {
254 254
255 255 }
256 256
257 void tst_QBarSeries::appendBarSets()
257 void tst_QBarSeries::appendList()
258 258 {
259 259 int count = 5;
260 260 QVERIFY(m_barseries->barsetCount() == 0);
@@ -266,25 +266,25 void tst_QBarSeries::appendBarSets()
266 266
267 267 // Append new sets (should succeed, count should match the count of sets)
268 268 bool ret = false;
269 ret = m_barseries->appendBarSets(sets);
269 ret = m_barseries->append(sets);
270 270 QVERIFY(ret == true);
271 271 QVERIFY(m_barseries->barsetCount() == count);
272 272
273 273 // Append same sets again (should fail, count should remain same)
274 ret = m_barseries->appendBarSets(sets);
274 ret = m_barseries->append(sets);
275 275 QVERIFY(ret == false);
276 276 QVERIFY(m_barseries->barsetCount() == count);
277 277
278 278 // Try append empty list (should succeed, but count should remain same)
279 279 QList<QBarSet*> invalidList;
280 ret = m_barseries->appendBarSets(invalidList);
280 ret = m_barseries->append(invalidList);
281 281 QVERIFY(ret == true);
282 282 QVERIFY(m_barseries->barsetCount() == count);
283 283
284 284 // Try append list with one new and one existing set (should fail, count remains same)
285 285 invalidList.append(new QBarSet("ok set"));
286 286 invalidList.append(sets.at(0));
287 ret = m_barseries->appendBarSets(invalidList);
287 ret = m_barseries->append(invalidList);
288 288 QVERIFY(ret == false);
289 289 QVERIFY(m_barseries->barsetCount() == count);
290 290
@@ -293,17 +293,17 void tst_QBarSeries::appendBarSets()
293 293 invalidList2.append(0);
294 294 invalidList2.append(0);
295 295 invalidList2.append(0);
296 ret = m_barseries->appendBarSets(invalidList2);
296 ret = m_barseries->append(invalidList2);
297 297 QVERIFY(ret == false);
298 298 QVERIFY(m_barseries->barsetCount() == count);
299 299 }
300 300
301 void tst_QBarSeries::removeBarSets_data()
301 void tst_QBarSeries::removeList_data()
302 302 {
303 303
304 304 }
305 305
306 void tst_QBarSeries::removeBarSets()
306 void tst_QBarSeries::removeList()
307 307 {
308 308 int count = m_testSets.count();
309 309 QVERIFY(m_barseries_with_sets->barsetCount() == count);
@@ -311,7 +311,7 void tst_QBarSeries::removeBarSets()
311 311 // Try removing empty list of sets (should return false, since no barsets were removed)
312 312 bool ret = false;
313 313 QList<QBarSet*> invalidList;
314 ret = m_barseries_with_sets->removeBarSets(invalidList);
314 ret = m_barseries_with_sets->remove(invalidList);
315 315 QVERIFY(ret == false);
316 316 QVERIFY(m_barseries_with_sets->barsetCount() == count);
317 317
@@ -321,22 +321,22 void tst_QBarSeries::removeBarSets()
321 321 invalidList.append(0);
322 322
323 323 // Try removing null pointers from list (should return false, should not crash, should not remove anything)
324 ret = m_barseries_with_sets->removeBarSets(invalidList);
324 ret = m_barseries_with_sets->remove(invalidList);
325 325 QVERIFY(ret == false);
326 326 QVERIFY(m_barseries_with_sets->barsetCount() == count);
327 327
328 328 // remove all sets (should return true, since sets were removed)
329 ret = m_barseries_with_sets->removeBarSets(m_testSets);
329 ret = m_barseries_with_sets->remove(m_testSets);
330 330 QVERIFY(ret == true);
331 331 QVERIFY(m_barseries_with_sets->barsetCount() == 0);
332 332
333 333 // Try removing invalid list again (should return false, since no barsets were removed)
334 ret = m_barseries_with_sets->removeBarSets(invalidList);
334 ret = m_barseries_with_sets->remove(invalidList);
335 335 QVERIFY(ret == false);
336 336 QVERIFY(m_barseries_with_sets->barsetCount() == 0);
337 337
338 338 // remove all sets again (should return false, since barsets were already removed)
339 ret = m_barseries_with_sets->removeBarSets(m_testSets);
339 ret = m_barseries_with_sets->remove(m_testSets);
340 340 QVERIFY(ret == false);
341 341 QVERIFY(m_barseries_with_sets->barsetCount() == 0);
342 342 }
@@ -440,11 +440,11 void tst_QBarSeries::mouseclicked()
440 440
441 441 QBarSet* set1 = new QBarSet(QString("set 1"));
442 442 *set1 << QPointF(0,10) << QPointF(1,10) << QPointF(2,10);
443 series->appendBarSet(set1);
443 series->append(set1);
444 444
445 445 QBarSet* set2 = new QBarSet(QString("set 2"));
446 446 *set2 << QPointF(0.5,10) << QPointF(1.5,10) << QPointF(2.5,10);
447 series->appendBarSet(set2);
447 series->append(set2);
448 448
449 449 QSignalSpy setSpy1(set1, SIGNAL(clicked(QString)));
450 450 QSignalSpy setSpy2(set2, SIGNAL(clicked(QString)));
@@ -577,11 +577,11 void tst_QBarSeries::mousehovered()
577 577
578 578 QBarSet* set1 = new QBarSet(QString("set 1"));
579 579 *set1 << QPointF(0.1,10) << QPointF(1.1,10) << QPointF(2.1,10);
580 series->appendBarSet(set1);
580 series->append(set1);
581 581
582 582 QBarSet* set2 = new QBarSet(QString("set 2"));
583 583 *set2 << QPointF(0.4,10) << QPointF(1.4,10) << QPointF(2.4,10);
584 series->appendBarSet(set2);
584 series->append(set2);
585 585
586 586 QSignalSpy setSpy1(set1, SIGNAL(hovered(bool)));
587 587 QSignalSpy setSpy2(set2, SIGNAL(hovered(bool)));
@@ -109,11 +109,11 void tst_QGroupedBarSeries::mouseclicked()
109 109
110 110 QBarSet* set1 = new QBarSet(QString("set 1"));
111 111 *set1 << 10 << 10 << 10;
112 series->appendBarSet(set1);
112 series->append(set1);
113 113
114 114 QBarSet* set2 = new QBarSet(QString("set 2"));
115 115 *set2 << 10 << 10 << 10;
116 series->appendBarSet(set2);
116 series->append(set2);
117 117
118 118 QSignalSpy setSpy1(set1, SIGNAL(clicked(QString)));
119 119 QSignalSpy setSpy2(set2, SIGNAL(clicked(QString)));
@@ -246,11 +246,11 void tst_QGroupedBarSeries::mousehovered()
246 246
247 247 QBarSet* set1 = new QBarSet(QString("set 1"));
248 248 *set1 << 10 << 10 << 10;
249 series->appendBarSet(set1);
249 series->append(set1);
250 250
251 251 QBarSet* set2 = new QBarSet(QString("set 2"));
252 252 *set2 << 10 << 10 << 10;
253 series->appendBarSet(set2);
253 series->append(set2);
254 254
255 255 QSignalSpy setSpy1(set1, SIGNAL(hovered(bool)));
256 256 QSignalSpy setSpy2(set2, SIGNAL(hovered(bool)));
@@ -106,11 +106,11 void tst_QPercentBarSeries::mouseclicked()
106 106
107 107 QBarSet* set1 = new QBarSet(QString("set 1"));
108 108 *set1 << 10 << 10 << 10;
109 series->appendBarSet(set1);
109 series->append(set1);
110 110
111 111 QBarSet* set2 = new QBarSet(QString("set 2"));
112 112 *set2 << 10 << 10 << 10;
113 series->appendBarSet(set2);
113 series->append(set2);
114 114
115 115 QSignalSpy setSpy1(set1, SIGNAL(clicked(QString)));
116 116 QSignalSpy setSpy2(set2, SIGNAL(clicked(QString)));
@@ -243,11 +243,11 void tst_QPercentBarSeries::mousehovered()
243 243
244 244 QBarSet* set1 = new QBarSet(QString("set 1"));
245 245 *set1 << 10 << 10 << 10;
246 series->appendBarSet(set1);
246 series->append(set1);
247 247
248 248 QBarSet* set2 = new QBarSet(QString("set 2"));
249 249 *set2 << 10 << 10 << 10;
250 series->appendBarSet(set2);
250 series->append(set2);
251 251
252 252 QSignalSpy setSpy1(set1, SIGNAL(hovered(bool)));
253 253 QSignalSpy setSpy2(set2, SIGNAL(hovered(bool)));
@@ -106,11 +106,11 void tst_QStackedBarSeries::mouseclicked()
106 106
107 107 QBarSet* set1 = new QBarSet(QString("set 1"));
108 108 *set1 << 10 << 10 << 10;
109 series->appendBarSet(set1);
109 series->append(set1);
110 110
111 111 QBarSet* set2 = new QBarSet(QString("set 2"));
112 112 *set2 << 10 << 10 << 10;
113 series->appendBarSet(set2);
113 series->append(set2);
114 114
115 115 QSignalSpy setSpy1(set1, SIGNAL(clicked(QString)));
116 116 QSignalSpy setSpy2(set2, SIGNAL(clicked(QString)));
@@ -243,11 +243,11 void tst_QStackedBarSeries::mousehovered()
243 243
244 244 QBarSet* set1 = new QBarSet(QString("set 1"));
245 245 *set1 << 10 << 10 << 10;
246 series->appendBarSet(set1);
246 series->append(set1);
247 247
248 248 QBarSet* set2 = new QBarSet(QString("set 2"));
249 249 *set2 << 10 << 10 << 10;
250 series->appendBarSet(set2);
250 series->append(set2);
251 251
252 252 QSignalSpy setSpy1(set1, SIGNAL(hovered(bool)));
253 253 QSignalSpy setSpy2(set2, SIGNAL(hovered(bool)));
@@ -288,7 +288,7 void MainWidget::addSeries(QString seriesName, int columnCount, int rowCount, QS
288 288 QBarSet *set = new QBarSet("set" + QString::number(j));
289 289 for (int i(0); i < column.count(); i++)
290 290 *set << column.at(i);
291 series->appendBarSet(set);
291 series->append(set);
292 292 }
293 293
294 294 m_chart->addSeries(series);
@@ -183,7 +183,7 void Widget::refreshChart()
183 183 qDebug() << "Putting 0 for the missing data" << " : " << QString("%1").arg(selectedYearsInts[i]);
184 184 }
185 185 }
186 series0->appendBarSet(barSet);
186 series0->append(barSet);
187 187 }
188 188 // add the serie to the chart
189 189 chartView->chart()->addSeries(series0);
General Comments 0
You need to be logged in to leave comments. Login now