From 404274be324804f7ece34b3e3cd1448cba1706bd Mon Sep 17 00:00:00 2001 From: Peinthor Rene Date: Fri, 16 May 2014 17:32:25 +0200 Subject: [PATCH] plot: keep the color between model updates --- src/MainWindow.cpp | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/MainWindow.cpp b/src/MainWindow.cpp index a0c6f3be..e9ce6dfb 100644 --- a/src/MainWindow.cpp +++ b/src/MainWindow.cpp @@ -1395,7 +1395,7 @@ void MainWindow::updatePlot(SqliteTableModel *model, bool update) // save current selected columns, so we can restore them after the update QString sItemX; // selected X column - QStringList sItemsY; // selected Y columns + QMap mapItemsY; // selected Y columns with color for(int i = 0; i < ui->treePlotColumns->topLevelItemCount(); ++i) { QTreeWidgetItem* item = ui->treePlotColumns->topLevelItem(i); @@ -1403,7 +1403,9 @@ void MainWindow::updatePlot(SqliteTableModel *model, bool update) sItemX = item->text(PlotColumnField); if(item->checkState(PlotColumnY) == Qt::Checked) - sItemsY << item->text(PlotColumnField); + { + mapItemsY[item->text(PlotColumnField)] = item->backgroundColor(PlotColumnY); + } } ui->treePlotColumns->clear(); @@ -1426,8 +1428,11 @@ void MainWindow::updatePlot(SqliteTableModel *model, bool update) columnitem->setText(PlotColumnField, model->headerData(i, Qt::Horizontal).toString()); // restore previous check state - if(sItemsY.contains(columnitem->text(PlotColumnField))) + if(mapItemsY.contains(columnitem->text(PlotColumnField))) + { columnitem->setCheckState(PlotColumnY, Qt::Checked); + columnitem->setBackgroundColor(PlotColumnY, mapItemsY[columnitem->text(PlotColumnField)]); + } else columnitem->setCheckState(PlotColumnY, Qt::Unchecked); if(sItemX == columnitem->text(PlotColumnField))