##// END OF EJS Templates
Pie now has defualt Model to which slice data is copied.
Marek Rosa -
r1195:505ff5d19e3d
parent child
Show More
@@ -33,13 +33,13 DeclarativePieSeries::DeclarativePieSeries(QObject *parent) :
33 // setModel(new DeclarativeTableModel());
33 // setModel(new DeclarativeTableModel());
34
34
35 // TODO: Set default mapper parameters to allow easy to use PieSeries api?
35 // TODO: Set default mapper parameters to allow easy to use PieSeries api?
36 QPieModelMapper *mapper = new QPieModelMapper();
36 QPieModelMapper *mapper = modelMapper();//new QPieModelMapper();
37 mapper->setMapLabels(0);
37 mapper->setMapLabels(0);
38 mapper->setMapValues(1);
38 mapper->setMapValues(1);
39 mapper->setOrientation(Qt::Vertical);
39 mapper->setOrientation(Qt::Vertical);
40 mapper->setFirst(0);
40 mapper->setFirst(0);
41 mapper->setCount(-1);
41 mapper->setCount(-1);
42 setModelMapper(mapper);
42 // setModelMapper(mapper);
43 }
43 }
44
44
45 void DeclarativePieSeries::classBegin()
45 void DeclarativePieSeries::classBegin()
@@ -26,7 +26,8
26 #include "charttheme_p.h"
26 #include "charttheme_p.h"
27 #include "chartanimator_p.h"
27 #include "chartanimator_p.h"
28 #include "legendmarker_p.h"
28 #include "legendmarker_p.h"
29 #include <QAbstractItemModel>
29 //#include <QAbstractItemModel>
30 #include <QStandardItemModel>
30 #include "qpiemodelmapper.h"
31 #include "qpiemodelmapper.h"
31
32
32 QTCOMMERCIALCHART_BEGIN_NAMESPACE
33 QTCOMMERCIALCHART_BEGIN_NAMESPACE
@@ -215,16 +216,33 bool QPieSeries::insert(int index, QPieSlice* slice)
215 if (!slice || d->m_slices.contains(slice))
216 if (!slice || d->m_slices.contains(slice))
216 return false;
217 return false;
217
218
218 slice->setParent(this);
219 d->m_model->insertRow(index);
219 d->m_slices.insert(index, slice);
220 if (d->m_mapper->orientation() == Qt::Vertical) {
221 d->m_model->setData(d->m_model->index(index, d->m_mapper->mapValues()), slice->value());
222 d->m_model->setData(d->m_model->index(index, d->m_mapper->mapLabels()), slice->label());
223 } else {
224 d->m_model->setData(d->m_model->index(d->m_mapper->mapValues(), index), slice->value());
225 d->m_model->setData(d->m_model->index(d->m_mapper->mapLabels(), index), slice->label());
226 }
220
227
221 d->updateDerivativeData();
228 // if (index < 0 || index > d->m_slices.count())
229 // return false;
230
231 // if (!slice || d->m_slices.contains(slice))
232 // return false;
233
234 // slice->setParent(this);
235 // d->m_slices.insert(index, slice);
236
237 // d->updateDerivativeData();
238
239 // connect(slice, SIGNAL(changed()), d, SLOT(sliceChanged()));
240 // connect(slice, SIGNAL(clicked()), d, SLOT(sliceClicked()));
241 // connect(slice, SIGNAL(hovered(bool)), d, SLOT(sliceHovered(bool)));
242
243 // emit d->added(QList<QPieSlice*>() << slice);
222
244
223 connect(slice, SIGNAL(changed()), d, SLOT(sliceChanged()));
224 connect(slice, SIGNAL(clicked()), d, SLOT(sliceClicked()));
225 connect(slice, SIGNAL(hovered(bool)), d, SLOT(sliceHovered(bool)));
226
245
227 emit d->added(QList<QPieSlice*>() << slice);
228
246
229 return true;
247 return true;
230 }
248 }
@@ -257,18 +275,24 bool QPieSeries::remove(QPieSlice* slice)
257 void QPieSeries::clear()
275 void QPieSeries::clear()
258 {
276 {
259 Q_D(QPieSeries);
277 Q_D(QPieSeries);
260 if (d->m_slices.count() == 0)
278 if (count() == 0)
261 return;
279 return;
280 if (d->m_mapper->orientation() == Qt::Vertical)
281 d->m_model->removeRows(d->m_mapper->first(), count());
282 else
283 d->m_model->removeColumns(d->m_mapper->first(), count());
284 // if (d->m_slices.count() == 0)
285 // return;
262
286
263 QList<QPieSlice*> slices = d->m_slices;
287 // QList<QPieSlice*> slices = d->m_slices;
264 foreach (QPieSlice* s, d->m_slices) {
288 // foreach (QPieSlice* s, d->m_slices) {
265 d->m_slices.removeOne(s);
289 // d->m_slices.removeOne(s);
266 delete s;
290 // delete s;
267 }
291 // }
268
292
269 d->updateDerivativeData();
293 // d->updateDerivativeData();
270
294
271 emit d->removed(slices);
295 // emit d->removed(slices);
272 }
296 }
273
297
274 /*!
298 /*!
@@ -277,7 +301,31 void QPieSeries::clear()
277 int QPieSeries::count() const
301 int QPieSeries::count() const
278 {
302 {
279 Q_D(const QPieSeries);
303 Q_D(const QPieSeries);
280 return d->m_slices.count();
304 // return d->m_slices.count();
305
306 // if (d->m_model && d->m_mapper) {
307
308 if (d->m_mapper->orientation() == Qt::Vertical) {
309 // data is in a column. Return the number of mapped items if the model's column have enough items
310 // or the number of items that can be mapped
311 if (d->m_mapper->mapValues() >= d->m_model->columnCount() || d->m_mapper->mapLabels() >= d->m_model->columnCount())
312 return 0; // mapped columns are not existing
313 else if (d->m_mapper->count() != -1)
314 // void setModelMapper(QPieModelMapper *mapper);
315 return qMin(d->m_mapper->count(), qMax(d->m_model->rowCount() - d->m_mapper->first(), 0));
316 else
317 return qMax(d->m_model->rowCount() - d->m_mapper->first(), 0);
318 } else {
319 // data is in a row. Return the number of mapped items if the model's row have enough items
320 // or the number of items that can be mapped
321 if (d->m_mapper->mapValues() >= d->m_model->rowCount() || d->m_mapper->mapLabels() >= d->m_model->rowCount())
322 return 0; // mapped rows are not existing
323 else if (d->m_mapper->count() != -1)
324 return qMin(d->m_mapper->count(), qMax(d->m_model->columnCount() - d->m_mapper->first(), 0));
325 else
326 return qMax(d->m_model->columnCount() - d->m_mapper->first(), 0);
327 }
328 // }
281 }
329 }
282
330
283 /*!
331 /*!
@@ -429,15 +477,14 qreal QPieSeries::sum() const
429 void QPieSeries::setModel(QAbstractItemModel* model)
477 void QPieSeries::setModel(QAbstractItemModel* model)
430 {
478 {
431 Q_D(QPieSeries);
479 Q_D(QPieSeries);
432 // disconnect signals from old model
433 if(d->m_model)
434 {
435 disconnect(d->m_model, 0, this, 0);
436 }
437
480
438 // set new model
481 // set new model
439 if(model)
482 if(model)
440 {
483 {
484 // disconnect signals from old model and delete it
485 disconnect(d->m_model, 0, this, 0);
486 delete d->m_model;
487
441 d->m_model = model;
488 d->m_model = model;
442 // connect signals from the model
489 // connect signals from the model
443 connect(d->m_model, SIGNAL(dataChanged(QModelIndex,QModelIndex)), d, SLOT(modelUpdated(QModelIndex,QModelIndex)));
490 connect(d->m_model, SIGNAL(dataChanged(QModelIndex,QModelIndex)), d, SLOT(modelUpdated(QModelIndex,QModelIndex)));
@@ -449,31 +496,37 void QPieSeries::setModel(QAbstractItemModel* model)
449 if (d->m_mapper)
496 if (d->m_mapper)
450 d->initializePieFromModel();
497 d->initializePieFromModel();
451 }
498 }
452 else
499 // else
453 {
500 // {
454 d->m_model = 0;
501 // d->m_model = new QStandardItemModel;
455 }
502 // d->m_mapper->reset();
456 }
503 // d->m_mapper->setMapLabels(0);
457
504 // d->m_mapper->setMapValues(1);
458 void QPieSeries::setModelMapper(QPieModelMapper *mapper)
505 // }
459 {
506 }
460 Q_D(QPieSeries);
507
461 // disconnect signals from old mapper
508 //void QPieSeries::setModelMapper(QPieModelMapper *mapper)
462 if (d->m_mapper) {
509 //{
463 QObject::disconnect(d->m_mapper, 0, this, 0);
510 // Q_D(QPieSeries);
464 }
511 // // disconnect signals from old mapper
465
512 // if (d->m_mapper) {
466 if (mapper) {
513 // QObject::disconnect(d->m_mapper, 0, this, 0);
467 d->m_mapper = mapper;
514 // }
468 // connect the signal from the mapper
515
469 connect(d->m_mapper, SIGNAL(updated()), d, SLOT(initializePieFromModel()));
516 // if (mapper) {
470
517 // d->m_mapper = mapper;
471 if (d->m_model)
518
472 d->initializePieFromModel();
519 // if (d->m_model)
473 } else {
520 // d->initializePieFromModel();
474 d->m_mapper = 0;
521 // } else {
475 }
522 // d->m_mapper = new QPieModelMapper;
476 }
523 // d->m_mapper->setMapLabels(0);
524 // d->m_mapper->setMapValues(1);
525 // }
526
527 // // connect the signal from the mapper
528 // connect(d->m_mapper, SIGNAL(updated()), d, SLOT(initializePieFromModel()));
529 //}
477
530
478 QPieModelMapper* QPieSeries::modelMapper() const
531 QPieModelMapper* QPieSeries::modelMapper() const
479 {
532 {
@@ -492,9 +545,18 QPieSeriesPrivate::QPieSeriesPrivate(QPieSeries *parent) :
492 m_pieStartAngle(0),
545 m_pieStartAngle(0),
493 m_pieEndAngle(360),
546 m_pieEndAngle(360),
494 m_sum(0),
547 m_sum(0),
495 m_mapper(0)
548 m_model(new QStandardItemModel),
549 m_mapper(new QPieModelMapper)
496 {
550 {
551 // connect signals from the model
552 connect(m_model, SIGNAL(dataChanged(QModelIndex,QModelIndex)), this, SLOT(modelUpdated(QModelIndex,QModelIndex)));
553 connect(m_model, SIGNAL(rowsInserted(QModelIndex,int,int)), this, SLOT(modelRowsAdded(QModelIndex,int,int)));
554 connect(m_model, SIGNAL(rowsRemoved(QModelIndex,int,int)), this, SLOT(modelRowsRemoved(QModelIndex,int,int)));
555 connect(m_model, SIGNAL(columnsInserted(QModelIndex,int,int)), this, SLOT(modelColumnsAdded(QModelIndex,int,int)));
556 connect(m_model, SIGNAL(columnsRemoved(QModelIndex,int,int)), this, SLOT(modelColumnsRemoved(QModelIndex,int,int)));
497
557
558 // connect the signal from the mapper
559 connect(m_mapper, SIGNAL(updated()), this, SLOT(initializePieFromModel()));
498 }
560 }
499
561
500 QPieSeriesPrivate::~QPieSeriesPrivate()
562 QPieSeriesPrivate::~QPieSeriesPrivate()
@@ -549,6 +611,23 QPieSeriesPrivate* QPieSeriesPrivate::seriesData(QPieSeries &series)
549 void QPieSeriesPrivate::sliceChanged()
611 void QPieSeriesPrivate::sliceChanged()
550 {
612 {
551 Q_ASSERT(m_slices.contains(qobject_cast<QPieSlice *>(sender())));
613 Q_ASSERT(m_slices.contains(qobject_cast<QPieSlice *>(sender())));
614 QPieSlice *slice = qobject_cast<QPieSlice *>(sender());
615 int sliceIndex = m_slices.indexOf(slice);
616 if (m_mapper->orientation() == Qt::Vertical) {
617 QModelIndex modelIndex = m_model->index(sliceIndex + m_mapper->first(), m_mapper->mapValues());
618 if (m_model->data(modelIndex).toReal() != slice->value())
619 m_model->setData(modelIndex, slice->value());
620 modelIndex = m_model->index(sliceIndex + m_mapper->first(), m_mapper->mapLabels());
621 if (m_model->data(modelIndex).toString() != slice->label())
622 m_model->setData(modelIndex, slice->label());
623 } else {
624 QModelIndex modelIndex = m_model->index(m_mapper->mapValues(), sliceIndex + m_mapper->first());
625 if (m_model->data(modelIndex).toReal() != slice->value())
626 m_model->setData(modelIndex, slice->value());
627 modelIndex = m_model->index(m_mapper->mapLabels(), sliceIndex + m_mapper->first());
628 if (m_model->data(modelIndex).toString() != slice->label())
629 m_model->setData(modelIndex, slice->label());
630 }
552 updateDerivativeData();
631 updateDerivativeData();
553 }
632 }
554
633
@@ -568,6 +647,59 void QPieSeriesPrivate::sliceHovered(bool state)
568 emit q->hovered(slice, state);
647 emit q->hovered(slice, state);
569 }
648 }
570
649
650 void QPieSeriesPrivate::doClear()
651 {
652 if (m_slices.count() == 0)
653 return;
654
655 QList<QPieSlice*> slices = m_slices;
656 foreach (QPieSlice* s, m_slices) {
657 m_slices.removeOne(s);
658 delete s;
659 }
660
661 updateDerivativeData();
662
663 emit removed(slices);
664 }
665
666 void QPieSeriesPrivate::doRemove(QPieSlice* slice)
667 {
668 if (!m_slices.removeOne(slice))
669 return;// false;
670
671 updateDerivativeData();
672
673 emit removed(QList<QPieSlice*>() << slice);
674
675 delete slice;
676 slice = 0;
677
678 return;// true;
679 }
680
681 void QPieSeriesPrivate::doInsert(int index, QPieSlice* slice)
682 {
683 if (index < 0 || index > m_slices.count())
684 return;// false;
685
686 if (!slice || m_slices.contains(slice))
687 return;// false;
688
689 slice->setParent(this);
690 m_slices.insert(index, slice);
691
692 updateDerivativeData();
693
694 connect(slice, SIGNAL(changed()), this, SLOT(sliceChanged()));
695 connect(slice, SIGNAL(clicked()), this, SLOT(sliceClicked()));
696 connect(slice, SIGNAL(hovered(bool)), this, SLOT(sliceHovered(bool)));
697
698 emit added(QList<QPieSlice*>() << slice);
699
700 return;// true;
701 }
702
571 void QPieSeriesPrivate::modelUpdated(QModelIndex topLeft, QModelIndex bottomRight)
703 void QPieSeriesPrivate::modelUpdated(QModelIndex topLeft, QModelIndex bottomRight)
572 {
704 {
573 if (m_mapper) {
705 if (m_mapper) {
@@ -663,11 +795,13 void QPieSeriesPrivate::insertData(int start, int end)
663 slice->setLabel(m_model->data(m_model->index(m_mapper->mapLabels(), i), Qt::DisplayRole).toString());
795 slice->setLabel(m_model->data(m_model->index(m_mapper->mapLabels(), i), Qt::DisplayRole).toString());
664 }
796 }
665 slice->setLabelVisible();
797 slice->setLabelVisible();
666 q->insert(i - m_mapper->first(), slice);
798 // q->insert(i - m_mapper->first(), slice);
799 doInsert(i - m_mapper->first(), slice);
667 }
800 }
668 if (m_mapper->count() != -1 && m_slices.size() > m_mapper->count())
801 if (m_mapper->count() != -1 && m_slices.size() > m_mapper->count())
669 for (int i = m_slices.size() - 1; i >= m_mapper->count(); i--)
802 for (int i = m_slices.size() - 1; i >= m_mapper->count(); i--)
670 q->remove(q->slices().at(i));
803 // q->remove(q->slices().at(i));
804 doRemove(q->slices().at(i));
671 }
805 }
672 }
806 }
673 }
807 }
@@ -684,7 +818,8 void QPieSeriesPrivate::removeData(int start, int end)
684 int first = qMax(start, m_mapper->first()); // get the index of the first item that will be removed.
818 int first = qMax(start, m_mapper->first()); // get the index of the first item that will be removed.
685 int last = qMin(first + toRemove - 1, m_slices.size() + m_mapper->first() - 1); // get the index of the last item that will be removed.
819 int last = qMin(first + toRemove - 1, m_slices.size() + m_mapper->first() - 1); // get the index of the last item that will be removed.
686 for (int i = last; i >= first; i--)
820 for (int i = last; i >= first; i--)
687 q->remove(q->slices().at(i - m_mapper->first()));
821 // q->remove(q->slices().at(i - m_mapper->first()));
822 doRemove(q->slices().at(i - m_mapper->first()));
688
823
689 if (m_mapper->count() != -1) {
824 if (m_mapper->count() != -1) {
690 int itemsAvailable; // check how many are available to be added
825 int itemsAvailable; // check how many are available to be added
@@ -705,7 +840,8 void QPieSeriesPrivate::removeData(int start, int end)
705 slice->setLabel(m_model->data(m_model->index(m_mapper->mapLabels(), i + m_mapper->first()), Qt::DisplayRole).toString());
840 slice->setLabel(m_model->data(m_model->index(m_mapper->mapLabels(), i + m_mapper->first()), Qt::DisplayRole).toString());
706 }
841 }
707 slice->setLabelVisible();
842 slice->setLabelVisible();
708 q->insert(i, slice);
843 // q->insert(i, slice);
844 doInsert(i, slice);
709 }
845 }
710 }
846 }
711 }
847 }
@@ -717,7 +853,7 void QPieSeriesPrivate::initializePieFromModel()
717 Q_Q(QPieSeries);
853 Q_Q(QPieSeries);
718
854
719 // clear current content
855 // clear current content
720 q->clear();
856 doClear();
721
857
722 if (m_model == 0 || m_mapper == 0)
858 if (m_model == 0 || m_mapper == 0)
723 return;
859 return;
@@ -75,7 +75,7 public:
75 void setLabelsVisible(bool visible = true);
75 void setLabelsVisible(bool visible = true);
76
76
77 void setModel(QAbstractItemModel* model);
77 void setModel(QAbstractItemModel* model);
78 void setModelMapper(QPieModelMapper *mapper);
78 // void setModelMapper(QPieModelMapper *mapper);
79 QPieModelMapper* modelMapper() const;
79 QPieModelMapper* modelMapper() const;
80
80
81 Q_SIGNALS:
81 Q_SIGNALS:
@@ -65,6 +65,9 public Q_SLOTS:
65 bool setRealValue(qreal &value, qreal newValue, qreal max, qreal min = 0.0);
65 bool setRealValue(qreal &value, qreal newValue, qreal max, qreal min = 0.0);
66
66
67 private:
67 private:
68 void doClear();
69 void doRemove(QPieSlice* slice);
70 void doInsert(int index, QPieSlice* slice);
68 void insertData(int start, int end);
71 void insertData(int start, int end);
69 void removeData(int start, int end);
72 void removeData(int start, int end);
70
73
@@ -77,7 +80,8 public:
77 qreal m_pieEndAngle;
80 qreal m_pieEndAngle;
78 qreal m_sum;
81 qreal m_sum;
79
82
80 // model map
83 // model
84 QAbstractItemModel *m_model;
81 QPieModelMapper *m_mapper;
85 QPieModelMapper *m_mapper;
82
86
83 private:
87 private:
@@ -20,6 +20,7
20
20
21 #include "qpieslice.h"
21 #include "qpieslice.h"
22 #include "pieslicedata_p.h"
22 #include "pieslicedata_p.h"
23 #include <QAbstractItemModel>
23
24
24 QTCOMMERCIALCHART_BEGIN_NAMESPACE
25 QTCOMMERCIALCHART_BEGIN_NAMESPACE
25
26
@@ -271,6 +272,7 void QPieSlice::setLabel(QString label)
271 {
272 {
272 if (d->m_labelText != label) {
273 if (d->m_labelText != label) {
273 d->m_labelText = label;
274 d->m_labelText = label;
275
274 emit changed();
276 emit changed();
275 }
277 }
276 }
278 }
@@ -351,10 +351,10 void tst_qpieseries::model()
351 QVERIFY2(series->slices().count() == 0, "Mapper has not been set, so the number of slices should be 0");
351 QVERIFY2(series->slices().count() == 0, "Mapper has not been set, so the number of slices should be 0");
352
352
353 // set the mapper
353 // set the mapper
354 QPieModelMapper *mapper = new QPieModelMapper;
354 QPieModelMapper *mapper = series->modelMapper();//new QPieModelMapper;
355 mapper->setMapValues(0);
355 mapper->setMapValues(0);
356 mapper->setMapLabels(0);
356 mapper->setMapLabels(0);
357 series->setModelMapper(mapper); // this should cause the Pie to get initialized from the model, since there is now both the model and the mapper defined
357 // series->setModelMapper(mapper); // this should cause the Pie to get initialized from the model, since there is now both the model and the mapper defined
358 QCOMPARE(series->slices().count(), rowCount);
358 QCOMPARE(series->slices().count(), rowCount);
359
359
360 // set the mappings to be outside of the model
360 // set the mappings to be outside of the model
@@ -373,9 +373,9 void tst_qpieseries::model()
373
373
374 // unset the model and the mapper
374 // unset the model and the mapper
375 series->setModel(0);
375 series->setModel(0);
376 series->setModelMapper(0);
376 // series->setModelMapper(0);
377 QVERIFY(series->model() == 0); // Model should be unset
377 QVERIFY(series->model() == 0); // Model should be unset
378 QVERIFY(series->modelMapper() == 0); // Model mapper should be unset
378 // QVERIFY(series->modelMapper() == 0); // Model mapper should be unset
379 }
379 }
380
380
381 void tst_qpieseries::modelCustomMap()
381 void tst_qpieseries::modelCustomMap()
@@ -397,10 +397,10 void tst_qpieseries::modelCustomMap()
397 chartView->show();
397 chartView->show();
398 series->setModel(stdModel);
398 series->setModel(stdModel);
399
399
400 QPieModelMapper *mapper = new QPieModelMapper;
400 QPieModelMapper *mapper = series->modelMapper();//new QPieModelMapper;
401 mapper->setMapValues(0);
401 mapper->setMapValues(0);
402 mapper->setMapLabels(0);
402 mapper->setMapLabels(0);
403 series->setModelMapper(mapper);
403 // series->setModelMapper(mapper);
404 QCOMPARE(series->slices().count(), rowCount);
404 QCOMPARE(series->slices().count(), rowCount);
405
405
406 // lets change the orientation to horizontal
406 // lets change the orientation to horizontal
@@ -442,10 +442,10 void tst_qpieseries::modelUpdate()
442 chartView->show();
442 chartView->show();
443 series->setModel(stdModel);
443 series->setModel(stdModel);
444
444
445 QPieModelMapper *mapper = new QPieModelMapper;
445 QPieModelMapper *mapper = series->modelMapper();//new QPieModelMapper;
446 mapper->setMapValues(0);
446 mapper->setMapValues(0);
447 mapper->setMapLabels(0);
447 mapper->setMapLabels(0);
448 series->setModelMapper(mapper);
448 // series->setModelMapper(mapper);
449
449
450 stdModel->insertRows(3, 5);
450 stdModel->insertRows(3, 5);
451 QCOMPARE(series->slices().count(), rowCount + 5);
451 QCOMPARE(series->slices().count(), rowCount + 5);
@@ -342,12 +342,12 void TableWidget::updateChartType(bool toggle)
342 QPieSeries* pieSeries = new QPieSeries;
342 QPieSeries* pieSeries = new QPieSeries;
343 pieSeries->setModel(m_model);
343 pieSeries->setModel(m_model);
344
344
345 QPieModelMapper *mapper = new QPieModelMapper;
345 QPieModelMapper *mapper = pieSeries->modelMapper();//new QPieModelMapper;
346 mapper->setMapValues(-1);
346 mapper->setMapValues(1);
347 mapper->setMapLabels(-1);
347 mapper->setMapLabels(0);
348 mapper->setFirst(2);
348 mapper->setFirst(2);
349 mapper->setCount(5);
349 mapper->setCount(5);
350 pieSeries->setModelMapper(mapper);
350 // pieSeries->setModelMapper(mapper);
351
351
352 pieSeries->setLabelsVisible(true);
352 pieSeries->setLabelsVisible(true);
353 pieSeries->setPieSize(0.75);
353 pieSeries->setPieSize(0.75);
@@ -355,9 +355,13 void TableWidget::updateChartType(bool toggle)
355 // pieSeries->setVerticalPosition(0.3);
355 // pieSeries->setVerticalPosition(0.3);
356
356
357 m_chart->addSeries(pieSeries);
357 m_chart->addSeries(pieSeries);
358 // seriesColorHex = "#" + QString::number(pieSeries->slices().at(pieSeries->slices().count()/2)->brush().color().rgb(), 16).right(6).toUpper();
358 seriesColorHex = "#" + QString::number(pieSeries->slices().at(pieSeries->slices().count()/2)->brush().color().rgb(), 16).right(6).toUpper();
359 m_model->addMapping(seriesColorHex, QRect(0, 2, 2, 5));
359 m_model->addMapping(seriesColorHex, QRect(0, 2, 2, 5));
360
360
361
362 pieSeries->slices().at(0)->setValue(400);
363 pieSeries->slices().at(0)->setLabel(QString("36"));
364
361 // // pie 2
365 // // pie 2
362 // pieSeries = new QPieSeries;
366 // pieSeries = new QPieSeries;
363 // pieSeries->setModel(m_model);
367 // pieSeries->setModel(m_model);
@@ -453,7 +457,7 void TableWidget::updateChartType(bool toggle)
453
457
454 void TableWidget::testPie()
458 void TableWidget::testPie()
455 {
459 {
456 m_series->modelMapper()->setMapX(4);
460 // m_series->modelMapper()->setMapX(4);
457 // m_tableView->setColumnWidth(10, 250);
461 // m_tableView->setColumnWidth(10, 250);
458 // if (specialPie) {
462 // if (specialPie) {
459 // specialPie->remove(specialPie->slices().at(2));
463 // specialPie->remove(specialPie->slices().at(2));
General Comments 0
You need to be logged in to leave comments. Login now