Skip to content

Commit

Permalink
fix for some QXYModelMapper sync issues
Browse files Browse the repository at this point in the history
- QXYModelMapper was not handling the model's layoutChanged() signal, which could leave points out of order

- QXYModelMapper handled dataChanged() by replacing points by value rather than index, which could cause the wrong point to be replaced. This was fixed.

Change-Id: I77a49acc5fc6982dabf976a3811c644843d18bb2
Reviewed-by: Miikka Heikkinen <[email protected]>
  • Loading branch information
yakaneli committed Jun 1, 2017
1 parent 5d6e30c commit bfb98a0
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/charts/xychart/qxymodelmapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ void QXYModelMapper::setModel(QAbstractItemModel *model)
connect(d->m_model, SIGNAL(columnsInserted(QModelIndex,int,int)), d, SLOT(modelColumnsAdded(QModelIndex,int,int)));
connect(d->m_model, SIGNAL(columnsRemoved(QModelIndex,int,int)), d, SLOT(modelColumnsRemoved(QModelIndex,int,int)));
connect(d->m_model, SIGNAL(modelReset()), d, SLOT(initializeXYFromModel()));
connect(d->m_model, SIGNAL(layoutChanged()), d, SLOT(initializeXYFromModel()));
connect(d->m_model, SIGNAL(destroyed()), d, SLOT(handleModelDestroyed()));
}

Expand Down Expand Up @@ -379,6 +380,7 @@ void QXYModelMapperPrivate::modelUpdated(QModelIndex topLeft, QModelIndex bottom
oldPoint = m_series->points().at(index.row() - m_first);
newPoint.setX(valueFromModel(xIndex));
newPoint.setY(valueFromModel(yIndex));
m_series->replace(index.row() - m_first, newPoint);
}
}
} else if (m_orientation == Qt::Horizontal && (index.row() == m_xSection || index.row() == m_ySection)) {
Expand All @@ -389,12 +391,10 @@ void QXYModelMapperPrivate::modelUpdated(QModelIndex topLeft, QModelIndex bottom
oldPoint = m_series->points().at(index.column() - m_first);
newPoint.setX(valueFromModel(xIndex));
newPoint.setY(valueFromModel(yIndex));
m_series->replace(index.column() - m_first, newPoint);
}
}
} else {
continue;
}
m_series->replace(oldPoint, newPoint);
}
}
blockSeriesSignals(false);
Expand Down

0 comments on commit bfb98a0

Please sign in to comment.