! * Updates the background of the cuves entry in the treeview * @param pen Pen of the curve * @param curveName Curve name to find in treemodel */
| 1435 | * @param curveName Curve name to find in treemodel |
| 1436 | */ |
| 1437 | void Worksheet::updateCurveBackground(QColor color, const QString& curveName) { |
| 1438 | Q_D(const Worksheet); |
| 1439 | const auto* plot = static_cast<const CartesianPlot*>(QObject::sender()); |
| 1440 | auto* treeModel = cursorModel(); |
| 1441 | int rowCount = treeModel->rowCount(); |
| 1442 | |
| 1443 | for (int i = 0; i < rowCount; i++) { |
| 1444 | auto plotIndex = treeModel->index(i, static_cast<int>(WorksheetPrivate::TreeModelColumn::PLOTNAME)); |
| 1445 | if (plotIndex.data().toString().compare(plot->name()) != 0) |
| 1446 | continue; |
| 1447 | |
| 1448 | int curveCount = treeModel->rowCount(plotIndex); |
| 1449 | for (int j = 0; j < curveCount; j++) { |
| 1450 | auto curveIndex = treeModel->index(j, static_cast<int>(WorksheetPrivate::TreeModelColumn::SIGNALNAME), plotIndex); |
| 1451 | |
| 1452 | if (curveIndex.data().toString().compare(curveName) != 0) |
| 1453 | continue; |
| 1454 | |
| 1455 | color.setAlpha(d->cursorTreeModelCurveBackgroundAlpha); |
| 1456 | treeModel->setTreeData(QVariant(color), j, static_cast<int>(WorksheetPrivate::TreeModelColumn::SIGNALNAME), plotIndex, Qt::BackgroundRole); |
| 1457 | return; |
| 1458 | } |
| 1459 | return; |
| 1460 | } |
| 1461 | } |
| 1462 | |
| 1463 | /** |
| 1464 | * @brief Worksheet::updateCompleteCursorTreeModel |