summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJohn Englund <john.englund@gmail.com>2017-05-30 17:08:38 -0700
committerJohn Englund <john.englund@gmail.com>2017-06-01 17:41:16 +0000
commitbfb98a08513699a377beddedb93cbe50bea482c5 (patch)
treef9b7df9c912c414b00c6e0697a1a701060fe7d08
parent5d6e30cccb31e7e7efa0ef5497c2dc46b40a72b6 (diff)
fix for some QXYModelMapper sync issues
- 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 <miikka.heikkinen@qt.io>
-rw-r--r--src/charts/xychart/qxymodelmapper.cpp6
1 files changed, 3 insertions, 3 deletions
diff --git a/src/charts/xychart/qxymodelmapper.cpp b/src/charts/xychart/qxymodelmapper.cpp
index 51f4a85a..b8930621 100644
--- a/src/charts/xychart/qxymodelmapper.cpp
+++ b/src/charts/xychart/qxymodelmapper.cpp
@@ -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()));
}
@@ -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)) {
@@ -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);