| 257 | } |
| 258 | |
| 259 | void CurveEditor::setPlot(PlotWidget* plot) { |
| 260 | if (plot_ == plot) { |
| 261 | return; |
| 262 | } |
| 263 | if (curve_list_connection_) { |
| 264 | QObject::disconnect(curve_list_connection_); |
| 265 | } |
| 266 | if (curve_color_connection_) { |
| 267 | QObject::disconnect(curve_color_connection_); |
| 268 | } |
| 269 | if (plot_destroyed_connection_) { |
| 270 | QObject::disconnect(plot_destroyed_connection_); |
| 271 | } |
| 272 | plot_ = plot; |
| 273 | clearActivePicker(); |
| 274 | if (plot_ != nullptr) { |
| 275 | curve_list_connection_ = connect(plot_, &PlotWidgetBase::curveListChanged, this, &CurveEditor::refresh); |
| 276 | curve_color_connection_ = connect(plot_, &PlotWidget::curveColorChanged, this, &CurveEditor::onCurveColorChanged); |
| 277 | plot_destroyed_connection_ = connect(plot_, &QObject::destroyed, this, [this]() { |
| 278 | plot_ = nullptr; |
| 279 | clearActivePicker(); |
| 280 | ui_->listWidget->clear(); |
| 281 | }); |
| 282 | } |
| 283 | refresh(); |
| 284 | } |
| 285 | |
| 286 | void CurveEditor::refresh() { |
| 287 | // Clear without firing selection-change handlers; we re-evaluate at the end. |