@@ -439,8 +439,15 void QPieSeries::setModel(QAbstractItemModel* model) | |||
|
439 | 439 | if(model) |
|
440 | 440 | { |
|
441 | 441 | d->m_model = model; |
|
442 | // connect signals from the model | |
|
443 | connect(d->m_model, SIGNAL(dataChanged(QModelIndex,QModelIndex)), d, SLOT(modelUpdated(QModelIndex,QModelIndex))); | |
|
444 | connect(d->m_model, SIGNAL(rowsInserted(QModelIndex,int,int)), d, SLOT(modelRowsAdded(QModelIndex,int,int))); | |
|
445 | connect(d->m_model, SIGNAL(rowsRemoved(QModelIndex,int,int)), d, SLOT(modelRowsRemoved(QModelIndex,int,int))); | |
|
446 | connect(d->m_model, SIGNAL(columnsInserted(QModelIndex,int,int)), d, SLOT(modelColumnsAdded(QModelIndex,int,int))); | |
|
447 | connect(d->m_model, SIGNAL(columnsRemoved(QModelIndex,int,int)), d, SLOT(modelColumnsRemoved(QModelIndex,int,int))); | |
|
448 | ||
|
442 | 449 | if (d->m_mapper) |
|
443 | d->setMapping(); | |
|
450 | d->initializePieFromModel(); | |
|
444 | 451 | } |
|
445 | 452 | else |
|
446 | 453 | { |
@@ -458,8 +465,11 void QPieSeries::setModelMapper(QPieModelMapper *mapper) | |||
|
458 | 465 | |
|
459 | 466 | if (mapper) { |
|
460 | 467 | d->m_mapper = mapper; |
|
468 | // connect the signal from the mapper | |
|
469 | connect(d->m_mapper, SIGNAL(updated()), d, SLOT(initializePieFromModel())); | |
|
470 | ||
|
461 | 471 | if (d->m_model) |
|
462 | d->setMapping(); | |
|
472 | d->initializePieFromModel(); | |
|
463 | 473 | } else { |
|
464 | 474 | d->m_mapper = 0; |
|
465 | 475 | } |
@@ -560,24 +570,26 void QPieSeriesPrivate::sliceHovered(bool state) | |||
|
560 | 570 | |
|
561 | 571 | void QPieSeriesPrivate::modelUpdated(QModelIndex topLeft, QModelIndex bottomRight) |
|
562 | 572 | { |
|
563 | for (int row = topLeft.row(); row <= bottomRight.row(); row++) { | |
|
564 |
for (int |
|
|
565 | if (m_mapper->orientation() == Qt::Vertical) | |
|
566 | { | |
|
567 | if ( topLeft.row() >= m_mapper->first() && (m_mapper->count() == - 1 || topLeft.row() < m_mapper->first() + m_mapper->count())) { | |
|
568 | if (topLeft.column() == m_mapper->mapValues()) | |
|
569 | m_slices.at(topLeft.row() - m_mapper->first())->setValue(m_model->data(topLeft, Qt::DisplayRole).toDouble()); | |
|
570 | if (topLeft.column() == m_mapper->mapLabels()) | |
|
571 | m_slices.at(topLeft.row() - m_mapper->first())->setLabel(m_model->data(topLeft, Qt::DisplayRole).toString()); | |
|
573 | if (m_mapper) { | |
|
574 | for (int row = topLeft.row(); row <= bottomRight.row(); row++) { | |
|
575 | for (int column = topLeft.column(); column <= bottomRight.column(); column++) { | |
|
576 | if (m_mapper->orientation() == Qt::Vertical) | |
|
577 | { | |
|
578 | if ( topLeft.row() >= m_mapper->first() && (m_mapper->count() == - 1 || topLeft.row() < m_mapper->first() + m_mapper->count())) { | |
|
579 | if (topLeft.column() == m_mapper->mapValues()) | |
|
580 | m_slices.at(topLeft.row() - m_mapper->first())->setValue(m_model->data(topLeft, Qt::DisplayRole).toDouble()); | |
|
581 | if (topLeft.column() == m_mapper->mapLabels()) | |
|
582 | m_slices.at(topLeft.row() - m_mapper->first())->setLabel(m_model->data(topLeft, Qt::DisplayRole).toString()); | |
|
583 | } | |
|
572 | 584 | } |
|
573 |
|
|
|
574 |
|
|
|
575 | { | |
|
576 | if (topLeft.column() >= m_mapper->first() && (m_mapper->count() == - 1 || topLeft.column() < m_mapper->first() + m_mapper->count())) { | |
|
577 | if (topLeft.row() == m_mapper->mapValues()) | |
|
578 | m_slices.at(topLeft.column() - m_mapper->first())->setValue(m_model->data(topLeft, Qt::DisplayRole).toDouble()); | |
|
579 | if (topLeft.row() == m_mapper->mapLabels()) | |
|
580 | m_slices.at(topLeft.column() - m_mapper->first())->setLabel(m_model->data(topLeft, Qt::DisplayRole).toString()); | |
|
585 | else | |
|
586 | { | |
|
587 | if (topLeft.column() >= m_mapper->first() && (m_mapper->count() == - 1 || topLeft.column() < m_mapper->first() + m_mapper->count())) { | |
|
588 | if (topLeft.row() == m_mapper->mapValues()) | |
|
589 | m_slices.at(topLeft.column() - m_mapper->first())->setValue(m_model->data(topLeft, Qt::DisplayRole).toDouble()); | |
|
590 | if (topLeft.row() == m_mapper->mapLabels()) | |
|
591 | m_slices.at(topLeft.column() - m_mapper->first())->setLabel(m_model->data(topLeft, Qt::DisplayRole).toString()); | |
|
592 | } | |
|
581 | 593 | } |
|
582 | 594 | } |
|
583 | 595 | } |
@@ -588,121 +600,118 void QPieSeriesPrivate::modelUpdated(QModelIndex topLeft, QModelIndex bottomRigh | |||
|
588 | 600 | void QPieSeriesPrivate::modelRowsAdded(QModelIndex parent, int start, int end) |
|
589 | 601 | { |
|
590 | 602 | Q_UNUSED(parent); |
|
591 | if (m_mapper->orientation() == Qt::Vertical) | |
|
592 | insertData(start, end); | |
|
593 | else if (start <= m_mapper->mapValues() || start <= m_mapper->mapLabels()) // if the changes affect the map - reinitialize the pie | |
|
594 | initializePieFromModel(); | |
|
603 | if (m_mapper) { | |
|
604 | if (m_mapper->orientation() == Qt::Vertical) | |
|
605 | insertData(start, end); | |
|
606 | else if (start <= m_mapper->mapValues() || start <= m_mapper->mapLabels()) // if the changes affect the map - reinitialize the pie | |
|
607 | initializePieFromModel(); | |
|
608 | } | |
|
595 | 609 | } |
|
596 | 610 | |
|
597 | 611 | void QPieSeriesPrivate::modelRowsRemoved(QModelIndex parent, int start, int end) |
|
598 | 612 | { |
|
599 | 613 | Q_UNUSED(parent); |
|
600 | if (m_mapper->orientation() == Qt::Vertical) | |
|
601 | removeData(start, end); | |
|
602 | else if (start <= m_mapper->mapValues() || start <= m_mapper->mapLabels()) // if the changes affect the map - reinitialize the pie | |
|
603 | initializePieFromModel(); | |
|
614 | if (m_mapper) { | |
|
615 | if (m_mapper->orientation() == Qt::Vertical) | |
|
616 | removeData(start, end); | |
|
617 | else if (start <= m_mapper->mapValues() || start <= m_mapper->mapLabels()) // if the changes affect the map - reinitialize the pie | |
|
618 | initializePieFromModel(); | |
|
619 | } | |
|
604 | 620 | } |
|
605 | 621 | |
|
606 | 622 | void QPieSeriesPrivate::modelColumnsAdded(QModelIndex parent, int start, int end) |
|
607 | 623 | { |
|
608 | 624 | Q_UNUSED(parent); |
|
609 | if (m_mapper->orientation() == Qt::Horizontal) | |
|
610 | insertData(start, end); | |
|
611 | else if (start <= m_mapper->mapValues() || start <= m_mapper->mapLabels()) // if the changes affect the map - reinitialize the pie | |
|
612 | initializePieFromModel(); | |
|
625 | if (m_mapper) { | |
|
626 | if (m_mapper->orientation() == Qt::Horizontal) | |
|
627 | insertData(start, end); | |
|
628 | else if (start <= m_mapper->mapValues() || start <= m_mapper->mapLabels()) // if the changes affect the map - reinitialize the pie | |
|
629 | initializePieFromModel(); | |
|
630 | } | |
|
613 | 631 | } |
|
614 | 632 | |
|
615 | 633 | void QPieSeriesPrivate::modelColumnsRemoved(QModelIndex parent, int start, int end) |
|
616 | 634 | { |
|
617 | 635 | Q_UNUSED(parent); |
|
618 | if (m_mapper->orientation() == Qt::Horizontal) | |
|
619 | removeData(start, end); | |
|
620 | else if (start <= m_mapper->mapValues() || start <= m_mapper->mapLabels()) // if the changes affect the map - reinitialize the pie | |
|
621 | initializePieFromModel(); | |
|
636 | if (m_mapper) { | |
|
637 | if (m_mapper->orientation() == Qt::Horizontal) | |
|
638 | removeData(start, end); | |
|
639 | else if (start <= m_mapper->mapValues() || start <= m_mapper->mapLabels()) // if the changes affect the map - reinitialize the pie | |
|
640 | initializePieFromModel(); | |
|
641 | } | |
|
622 | 642 | } |
|
623 | 643 | |
|
624 | 644 | void QPieSeriesPrivate::insertData(int start, int end) |
|
625 | 645 | { |
|
626 | 646 | Q_Q(QPieSeries); |
|
627 | if (m_mapper->count() != -1 && start >= m_mapper->first() + m_mapper->count()) { | |
|
628 | return; | |
|
629 | } else { | |
|
630 | int addedCount = end - start + 1; | |
|
631 | if (m_mapper->count() != -1 && addedCount > m_mapper->count()) | |
|
632 |
addedCount |
|
|
633 | int first = qMax(start, m_mapper->first()); | |
|
634 | int last = qMin(first + addedCount - 1, m_mapper->orientation() == Qt::Vertical ? m_model->rowCount() - 1 : m_model->columnCount() - 1); | |
|
635 | for (int i = first; i <= last; i++) { | |
|
636 | QPieSlice *slice = new QPieSlice; | |
|
637 | if (m_mapper->orientation() == Qt::Vertical) { | |
|
638 | slice->setValue(m_model->data(m_model->index(i, m_mapper->mapValues()), Qt::DisplayRole).toDouble()); | |
|
639 |
slice->set |
|
|
640 | } else { | |
|
641 | slice->setValue(m_model->data(m_model->index(m_mapper->mapValues(), i), Qt::DisplayRole).toDouble()); | |
|
642 |
slice->set |
|
|
647 | if (m_mapper) { | |
|
648 | if (m_mapper->count() != -1 && start >= m_mapper->first() + m_mapper->count()) { | |
|
649 | return; | |
|
650 | } else { | |
|
651 | int addedCount = end - start + 1; | |
|
652 | if (m_mapper->count() != -1 && addedCount > m_mapper->count()) | |
|
653 | addedCount = m_mapper->count(); | |
|
654 | int first = qMax(start, m_mapper->first()); | |
|
655 | int last = qMin(first + addedCount - 1, m_mapper->orientation() == Qt::Vertical ? m_model->rowCount() - 1 : m_model->columnCount() - 1); | |
|
656 | for (int i = first; i <= last; i++) { | |
|
657 | QPieSlice *slice = new QPieSlice; | |
|
658 | if (m_mapper->orientation() == Qt::Vertical) { | |
|
659 | slice->setValue(m_model->data(m_model->index(i, m_mapper->mapValues()), Qt::DisplayRole).toDouble()); | |
|
660 | slice->setLabel(m_model->data(m_model->index(i, m_mapper->mapLabels()), Qt::DisplayRole).toString()); | |
|
661 | } else { | |
|
662 | slice->setValue(m_model->data(m_model->index(m_mapper->mapValues(), i), Qt::DisplayRole).toDouble()); | |
|
663 | slice->setLabel(m_model->data(m_model->index(m_mapper->mapLabels(), i), Qt::DisplayRole).toString()); | |
|
664 | } | |
|
665 | slice->setLabelVisible(); | |
|
666 | q->insert(i - m_mapper->first(), slice); | |
|
643 | 667 | } |
|
644 | slice->setLabelVisible(); | |
|
645 | q->insert(i - m_mapper->first(), slice); | |
|
668 | if (m_mapper->count() != -1 && m_slices.size() > m_mapper->count()) | |
|
669 | for (int i = m_slices.size() - 1; i >= m_mapper->count(); i--) | |
|
670 | q->remove(q->slices().at(i)); | |
|
646 | 671 | } |
|
647 | if (m_mapper->count() != -1 && m_slices.size() > m_mapper->count()) | |
|
648 | for (int i = m_slices.size() - 1; i >= m_mapper->count(); i--) | |
|
649 | q->remove(q->slices().at(i)); | |
|
650 | 672 | } |
|
651 | 673 | } |
|
652 | 674 | |
|
653 | 675 | void QPieSeriesPrivate::removeData(int start, int end) |
|
654 | 676 | { |
|
655 | 677 | Q_Q(QPieSeries); |
|
656 | int removedCount = end - start + 1; | |
|
657 | if (m_mapper->count() != -1 && start >= m_mapper->first() + m_mapper->count()) { | |
|
658 | return; | |
|
659 | } else { | |
|
660 | int toRemove = qMin(m_slices.size(), removedCount); // first find how many items can actually be removed | |
|
661 | int first = qMax(start, m_mapper->first()); // get the index of the first item that will be removed. | |
|
662 |
int |
|
|
663 | for (int i = last; i >= first; i--) | |
|
664 | q->remove(q->slices().at(i - m_mapper->first())); | |
|
665 | ||
|
666 | if (m_mapper->count() != -1) { | |
|
667 | int itemsAvailable; // check how many are available to be added | |
|
668 | if (m_mapper->orientation() == Qt::Vertical) | |
|
669 | itemsAvailable = m_model->rowCount() - m_mapper->first() - m_slices.size(); | |
|
670 | else | |
|
671 | itemsAvailable = m_model->columnCount() - m_mapper->first() - m_slices.size(); | |
|
672 | int toBeAdded = qMin(itemsAvailable, m_mapper->count() - m_slices.size()); // add not more items than there is space left to be filled. | |
|
673 | int currentSize = m_slices.size(); | |
|
674 | if (toBeAdded > 0) | |
|
675 | for (int i = m_slices.size(); i < currentSize + toBeAdded; i++) { | |
|
676 | QPieSlice *slice = new QPieSlice; | |
|
677 | if (m_mapper->orientation() == Qt::Vertical) { | |
|
678 | slice->setValue(m_model->data(m_model->index(i + m_mapper->first(), m_mapper->mapValues()), Qt::DisplayRole).toDouble()); | |
|
679 |
slice->set |
|
|
680 | } else { | |
|
681 | slice->setValue(m_model->data(m_model->index(m_mapper->mapValues(), i + m_mapper->first()), Qt::DisplayRole).toDouble()); | |
|
682 |
slice->set |
|
|
678 | if (m_mapper) { | |
|
679 | int removedCount = end - start + 1; | |
|
680 | if (m_mapper->count() != -1 && start >= m_mapper->first() + m_mapper->count()) { | |
|
681 | return; | |
|
682 | } else { | |
|
683 | int toRemove = qMin(m_slices.size(), removedCount); // first find how many items can actually be removed | |
|
684 | 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. | |
|
686 | for (int i = last; i >= first; i--) | |
|
687 | q->remove(q->slices().at(i - m_mapper->first())); | |
|
688 | ||
|
689 | if (m_mapper->count() != -1) { | |
|
690 | int itemsAvailable; // check how many are available to be added | |
|
691 | if (m_mapper->orientation() == Qt::Vertical) | |
|
692 | itemsAvailable = m_model->rowCount() - m_mapper->first() - m_slices.size(); | |
|
693 | else | |
|
694 | itemsAvailable = m_model->columnCount() - m_mapper->first() - m_slices.size(); | |
|
695 | int toBeAdded = qMin(itemsAvailable, m_mapper->count() - m_slices.size()); // add not more items than there is space left to be filled. | |
|
696 | int currentSize = m_slices.size(); | |
|
697 | if (toBeAdded > 0) | |
|
698 | for (int i = m_slices.size(); i < currentSize + toBeAdded; i++) { | |
|
699 | QPieSlice *slice = new QPieSlice; | |
|
700 | if (m_mapper->orientation() == Qt::Vertical) { | |
|
701 | slice->setValue(m_model->data(m_model->index(i + m_mapper->first(), m_mapper->mapValues()), Qt::DisplayRole).toDouble()); | |
|
702 | slice->setLabel(m_model->data(m_model->index(i + m_mapper->first(), m_mapper->mapLabels()), Qt::DisplayRole).toString()); | |
|
703 | } else { | |
|
704 | slice->setValue(m_model->data(m_model->index(m_mapper->mapValues(), i + m_mapper->first()), Qt::DisplayRole).toDouble()); | |
|
705 | slice->setLabel(m_model->data(m_model->index(m_mapper->mapLabels(), i + m_mapper->first()), Qt::DisplayRole).toString()); | |
|
706 | } | |
|
707 | slice->setLabelVisible(); | |
|
708 | q->insert(i, slice); | |
|
683 | 709 | } |
|
684 | slice->setLabelVisible(); | |
|
685 | q->insert(i, slice); | |
|
686 | } | |
|
710 | } | |
|
687 | 711 | } |
|
688 | 712 | } |
|
689 | 713 | } |
|
690 | 714 | |
|
691 | void QPieSeriesPrivate::setMapping() | |
|
692 | { | |
|
693 | initializePieFromModel(); | |
|
694 | ||
|
695 | // connect signals from the model | |
|
696 | connect(m_model, SIGNAL(dataChanged(QModelIndex,QModelIndex)), this, SLOT(modelUpdated(QModelIndex,QModelIndex))); | |
|
697 | connect(m_model, SIGNAL(rowsInserted(QModelIndex,int,int)), this, SLOT(modelRowsAdded(QModelIndex,int,int))); | |
|
698 | connect(m_model, SIGNAL(rowsRemoved(QModelIndex,int,int)), this, SLOT(modelRowsRemoved(QModelIndex,int,int))); | |
|
699 | connect(m_model, SIGNAL(columnsInserted(QModelIndex,int,int)), this, SLOT(modelColumnsAdded(QModelIndex,int,int))); | |
|
700 | connect(m_model, SIGNAL(columnsRemoved(QModelIndex,int,int)), this, SLOT(modelColumnsRemoved(QModelIndex,int,int))); | |
|
701 | ||
|
702 | // connect the signal from the mapper | |
|
703 | connect(m_mapper, SIGNAL(updated()), this, SLOT(initializePieFromModel())); | |
|
704 | } | |
|
705 | ||
|
706 | 715 | void QPieSeriesPrivate::initializePieFromModel() |
|
707 | 716 | { |
|
708 | 717 | Q_Q(QPieSeries); |
@@ -65,7 +65,6 public Q_SLOTS: | |||
|
65 | 65 | bool setRealValue(qreal &value, qreal newValue, qreal max, qreal min = 0.0); |
|
66 | 66 | |
|
67 | 67 | private: |
|
68 | void setMapping(); | |
|
69 | 68 | void insertData(int start, int end); |
|
70 | 69 | void removeData(int start, int end); |
|
71 | 70 |
@@ -339,8 +339,14 void QXYSeries::setModel(QAbstractItemModel *model) | |||
|
339 | 339 | // set new model |
|
340 | 340 | if (model) { |
|
341 | 341 | d->m_model = model; |
|
342 | if (d->m_mapper) | |
|
343 | d->setMapping(); | |
|
342 | emit d->reinitialized(); | |
|
343 | ||
|
344 | // connect signals from the model | |
|
345 | connect(d->m_model,SIGNAL(dataChanged(QModelIndex,QModelIndex)), d, SLOT(modelUpdated(QModelIndex,QModelIndex))); | |
|
346 | connect(d->m_model,SIGNAL(rowsInserted(QModelIndex,int,int)), d, SLOT(modelRowsAdded(QModelIndex,int,int))); | |
|
347 | connect(d->m_model,SIGNAL(rowsRemoved(QModelIndex,int,int)), d, SLOT(modelRowsRemoved(QModelIndex,int,int))); | |
|
348 | connect(d->m_model, SIGNAL(columnsInserted(QModelIndex,int,int)), d, SLOT(modelColumnsAdded(QModelIndex,int,int))); | |
|
349 | connect(d->m_model, SIGNAL(columnsRemoved(QModelIndex,int,int)), d, SLOT(modelColumnsRemoved(QModelIndex,int,int))); | |
|
344 | 350 | } else { |
|
345 | 351 | d->m_model = 0; |
|
346 | 352 | } |
@@ -356,8 +362,10 void QXYSeries::setModelMapper(QXYModelMapper *mapper) | |||
|
356 | 362 | |
|
357 | 363 | if (mapper) { |
|
358 | 364 | d->m_mapper = mapper; |
|
359 | if (d->m_model) | |
|
360 | d->setMapping(); | |
|
365 | emit d->reinitialized(); | |
|
366 | ||
|
367 | // connect the signal from the mapper | |
|
368 | connect(d->m_mapper, SIGNAL(updated()), d, SLOT(mappingUpdated())); | |
|
361 | 369 | } else { |
|
362 | 370 | d->m_mapper = 0; |
|
363 | 371 | } |
@@ -438,38 +446,28 QList<LegendMarker*> QXYSeriesPrivate::createLegendMarker(QLegend* legend) | |||
|
438 | 446 | return list << new XYLegendMarker(q,legend); |
|
439 | 447 | } |
|
440 | 448 | |
|
441 | void QXYSeriesPrivate::setMapping() | |
|
442 | { | |
|
443 | // connect signals from the model | |
|
444 | connect(m_model,SIGNAL(dataChanged(QModelIndex,QModelIndex)), this, SLOT(modelUpdated(QModelIndex,QModelIndex))); | |
|
445 | connect(m_model,SIGNAL(rowsInserted(QModelIndex,int,int)), this, SLOT(modelRowsAdded(QModelIndex,int,int))); | |
|
446 | connect(m_model,SIGNAL(rowsRemoved(QModelIndex,int,int)), this, SLOT(modelRowsRemoved(QModelIndex,int,int))); | |
|
447 | connect(m_model, SIGNAL(columnsInserted(QModelIndex,int,int)), this, SLOT(modelColumnsAdded(QModelIndex,int,int))); | |
|
448 | connect(m_model, SIGNAL(columnsRemoved(QModelIndex,int,int)), this, SLOT(modelColumnsRemoved(QModelIndex,int,int))); | |
|
449 | ||
|
450 | // connect the signal from the mapper | |
|
451 | connect(m_mapper, SIGNAL(updated()), this, SLOT(mappingUpdated())); | |
|
452 | } | |
|
453 | ||
|
454 | 449 | void QXYSeriesPrivate::mappingUpdated() |
|
455 | 450 | { |
|
456 | emit reinitialized(); | |
|
451 | if (m_model) | |
|
452 | emit reinitialized(); | |
|
457 | 453 | } |
|
458 | 454 | |
|
459 | 455 | void QXYSeriesPrivate::modelUpdated(QModelIndex topLeft, QModelIndex bottomRight) |
|
460 | 456 | { |
|
461 | for (int row = topLeft.row(); row <= bottomRight.row(); row++) { | |
|
462 |
for (int |
|
|
463 | if (m_mapper->orientation() == Qt::Vertical) { | |
|
464 | if ((column == m_mapper->mapX() || column == m_mapper->mapY()) // modified item is in a mapped column | |
|
465 | && row >= m_mapper->first() // modfied item in not before first item | |
|
466 | && (m_mapper->count() == -1 || row < m_mapper->first() + m_mapper->count())) // map is not limited or item lays before the end of map | |
|
467 | emit pointReplaced(row - m_mapper->first()); | |
|
468 | } else { | |
|
469 | if ((row == m_mapper->mapX() || row == m_mapper->mapY()) // modified item is in a mapped row | |
|
470 |
|
|
|
471 | && (m_mapper->count() == -1 || column < m_mapper->first() + m_mapper->count())) // map is not limited or item lays before the end of map | |
|
472 | emit pointReplaced(column - m_mapper->first()); | |
|
457 | if (m_mapper) { | |
|
458 | for (int row = topLeft.row(); row <= bottomRight.row(); row++) { | |
|
459 | for (int column = topLeft.column(); column <= bottomRight.column(); column++) { | |
|
460 | if (m_mapper->orientation() == Qt::Vertical) { | |
|
461 | if ((column == m_mapper->mapX() || column == m_mapper->mapY()) // modified item is in a mapped column | |
|
462 | && row >= m_mapper->first() // modfied item in not before first item | |
|
463 | && (m_mapper->count() == -1 || row < m_mapper->first() + m_mapper->count())) // map is not limited or item lays before the end of map | |
|
464 | emit pointReplaced(row - m_mapper->first()); | |
|
465 | } else { | |
|
466 | if ((row == m_mapper->mapX() || row == m_mapper->mapY()) // modified item is in a mapped row | |
|
467 | && column >= m_mapper->first() // modfied item in not before first item | |
|
468 | && (m_mapper->count() == -1 || column < m_mapper->first() + m_mapper->count())) // map is not limited or item lays before the end of map | |
|
469 | emit pointReplaced(column - m_mapper->first()); | |
|
470 | } | |
|
473 | 471 | } |
|
474 | 472 | } |
|
475 | 473 | } |
@@ -479,37 +477,45 void QXYSeriesPrivate::modelUpdated(QModelIndex topLeft, QModelIndex bottomRight | |||
|
479 | 477 | void QXYSeriesPrivate::modelRowsAdded(QModelIndex parent, int start, int end) |
|
480 | 478 | { |
|
481 | 479 | Q_UNUSED(parent); |
|
482 | if (m_mapper->orientation() == Qt::Vertical) | |
|
483 | emit pointsAdded(start, end); | |
|
484 | else if (start <= m_mapper->mapX() || start <= m_mapper->mapY()) | |
|
485 | emit reinitialized(); | |
|
480 | if (m_mapper) { | |
|
481 | if (m_mapper->orientation() == Qt::Vertical) | |
|
482 | emit pointsAdded(start, end); | |
|
483 | else if (start <= m_mapper->mapX() || start <= m_mapper->mapY()) | |
|
484 | emit reinitialized(); | |
|
485 | } | |
|
486 | 486 | } |
|
487 | 487 | |
|
488 | 488 | void QXYSeriesPrivate::modelRowsRemoved(QModelIndex parent, int start, int end) |
|
489 | 489 | { |
|
490 | 490 | Q_UNUSED(parent); |
|
491 | if (m_mapper->orientation() == Qt::Vertical) | |
|
492 | emit pointsRemoved(start, end); | |
|
493 | else if (start <= m_mapper->mapX() || start <= m_mapper->mapY()) | |
|
494 | emit reinitialized(); | |
|
491 | if (m_mapper) { | |
|
492 | if (m_mapper->orientation() == Qt::Vertical) | |
|
493 | emit pointsRemoved(start, end); | |
|
494 | else if (start <= m_mapper->mapX() || start <= m_mapper->mapY()) | |
|
495 | emit reinitialized(); | |
|
496 | } | |
|
495 | 497 | } |
|
496 | 498 | |
|
497 | 499 | void QXYSeriesPrivate::modelColumnsAdded(QModelIndex parent, int start, int end) |
|
498 | 500 | { |
|
499 | 501 | Q_UNUSED(parent); |
|
500 | if (m_mapper->orientation() == Qt::Horizontal) | |
|
501 | emit pointsAdded(start, end); | |
|
502 | else if (start <= m_mapper->mapX() || start <= m_mapper->mapY()) | |
|
503 | emit reinitialized(); | |
|
502 | if (m_mapper) { | |
|
503 | if (m_mapper->orientation() == Qt::Horizontal) | |
|
504 | emit pointsAdded(start, end); | |
|
505 | else if (start <= m_mapper->mapX() || start <= m_mapper->mapY()) | |
|
506 | emit reinitialized(); | |
|
507 | } | |
|
504 | 508 | } |
|
505 | 509 | |
|
506 | 510 | void QXYSeriesPrivate::modelColumnsRemoved(QModelIndex parent, int start, int end) |
|
507 | 511 | { |
|
508 | 512 | Q_UNUSED(parent); |
|
509 | if (m_mapper->orientation() == Qt::Horizontal) | |
|
510 | emit pointsRemoved(start, end); | |
|
511 | else if (start <= m_mapper->mapX() || start <= m_mapper->mapY()) | |
|
512 | emit reinitialized(); | |
|
513 | if (m_mapper) { | |
|
514 | if (m_mapper->orientation() == Qt::Horizontal) | |
|
515 | emit pointsRemoved(start, end); | |
|
516 | else if (start <= m_mapper->mapX() || start <= m_mapper->mapY()) | |
|
517 | emit reinitialized(); | |
|
518 | } | |
|
513 | 519 | } |
|
514 | 520 | |
|
515 | 521 | #include "moc_qxyseries.cpp" |
General Comments 0
You need to be logged in to leave comments.
Login now