Skip to content

Commit 404274b

Browse files
committed
plot: keep the color between model updates
1 parent 4b12faf commit 404274b

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

src/MainWindow.cpp

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1395,15 +1395,17 @@ void MainWindow::updatePlot(SqliteTableModel *model, bool update)
13951395

13961396
// save current selected columns, so we can restore them after the update
13971397
QString sItemX; // selected X column
1398-
QStringList sItemsY; // selected Y columns
1398+
QMap<QString, QColor> mapItemsY; // selected Y columns with color
13991399
for(int i = 0; i < ui->treePlotColumns->topLevelItemCount(); ++i)
14001400
{
14011401
QTreeWidgetItem* item = ui->treePlotColumns->topLevelItem(i);
14021402
if(item->checkState(PlotColumnX) == Qt::Checked)
14031403
sItemX = item->text(PlotColumnField);
14041404

14051405
if(item->checkState(PlotColumnY) == Qt::Checked)
1406-
sItemsY << item->text(PlotColumnField);
1406+
{
1407+
mapItemsY[item->text(PlotColumnField)] = item->backgroundColor(PlotColumnY);
1408+
}
14071409
}
14081410

14091411
ui->treePlotColumns->clear();
@@ -1426,8 +1428,11 @@ void MainWindow::updatePlot(SqliteTableModel *model, bool update)
14261428
columnitem->setText(PlotColumnField, model->headerData(i, Qt::Horizontal).toString());
14271429

14281430
// restore previous check state
1429-
if(sItemsY.contains(columnitem->text(PlotColumnField)))
1431+
if(mapItemsY.contains(columnitem->text(PlotColumnField)))
1432+
{
14301433
columnitem->setCheckState(PlotColumnY, Qt::Checked);
1434+
columnitem->setBackgroundColor(PlotColumnY, mapItemsY[columnitem->text(PlotColumnField)]);
1435+
}
14311436
else
14321437
columnitem->setCheckState(PlotColumnY, Qt::Unchecked);
14331438
if(sItemX == columnitem->text(PlotColumnField))

0 commit comments

Comments
 (0)