From 61d3ed85e2c12eacdf0015899f5fa8442a7e97c0 2012-03-16 15:33:11 From: Marek Rosa Date: 2012-03-16 15:33:11 Subject: [PATCH] QPieSeries: label value is now also updated when the same row/column of the model is mapped for values and labels --- diff --git a/src/piechart/qpieseries.cpp b/src/piechart/qpieseries.cpp index 4738419..49313ed 100644 --- a/src/piechart/qpieseries.cpp +++ b/src/piechart/qpieseries.cpp @@ -541,7 +541,15 @@ void QPieSeries::modelUpdated(QModelIndex topLeft, QModelIndex bottomRight) { // slices().at(topLeft.row())->setValue(m_model->data(m_model->index(topLeft.row(), topLeft.column()), Qt::DisplayRole).toDouble()); if (topLeft.column() == m_mapValues) - slices().at(topLeft.row())->setValue(m_model->data(topLeft, Qt::DisplayRole).toDouble()); + if (m_mapValues == m_mapLabels) + { + slices().at(topLeft.row())->setValue(m_model->data(topLeft, Qt::DisplayRole).toDouble()); + slices().at(topLeft.row())->setLabel(m_model->data(topLeft, Qt::DisplayRole).toString()); + } + else + { + slices().at(topLeft.row())->setValue(m_model->data(topLeft, Qt::DisplayRole).toDouble()); + } else if (topLeft.column() == m_mapLabels) slices().at(topLeft.row())->setLabel(m_model->data(topLeft, Qt::DisplayRole).toString()); } @@ -549,7 +557,15 @@ void QPieSeries::modelUpdated(QModelIndex topLeft, QModelIndex bottomRight) { // slices().at(topLeft.column())->setValue(m_model->data(m_model->index(topLeft.row(), topLeft.column()), Qt::DisplayRole).toDouble()); if (topLeft.row() == m_mapValues) - slices().at(topLeft.column())->setValue(m_model->data(topLeft, Qt::DisplayRole).toDouble()); + if (m_mapValues == m_mapLabels) + { + slices().at(topLeft.column())->setValue(m_model->data(topLeft, Qt::DisplayRole).toDouble()); + slices().at(topLeft.column())->setLabel(m_model->data(topLeft, Qt::DisplayRole).toString()); + } + else + { + slices().at(topLeft.column())->setValue(m_model->data(topLeft, Qt::DisplayRole).toDouble()); + } else if (topLeft.row() == m_mapLabels) slices().at(topLeft.column())->setLabel(m_model->data(topLeft, Qt::DisplayRole).toString()); }