| 46 | } |
| 47 | |
| 48 | void CursorDock::setWorksheet(Worksheet* worksheet) { |
| 49 | CONDITIONAL_LOCK_RETURN; |
| 50 | |
| 51 | ui->tvCursorData->setModel(worksheet->cursorModel()); |
| 52 | ui->tvCursorData->resizeColumnToContents(0); |
| 53 | m_plotList = worksheet->children<CartesianPlot>(); |
| 54 | if (m_plotList.isEmpty()) |
| 55 | return; |
| 56 | |
| 57 | m_plot = m_plotList.first(); |
| 58 | |
| 59 | bool cursor0Enabled = m_plot->cursor0Enable(); |
| 60 | bool cursor1Enabled = m_plot->cursor1Enable(); |
| 61 | ui->cbCursor0en->setChecked(cursor0Enabled); |
| 62 | ui->cbCursor1en->setChecked(cursor1Enabled); |
| 63 | |
| 64 | ui->tvCursorData->setColumnHidden(static_cast<int>(WorksheetPrivate::TreeModelColumn::CURSOR0), !cursor0Enabled); |
| 65 | ui->tvCursorData->setColumnHidden(static_cast<int>(WorksheetPrivate::TreeModelColumn::CURSOR1), !cursor1Enabled); |
| 66 | if (cursor0Enabled && cursor1Enabled) |
| 67 | ui->tvCursorData->setColumnHidden(static_cast<int>(WorksheetPrivate::TreeModelColumn::CURSORDIFF), false); |
| 68 | else |
| 69 | ui->tvCursorData->setColumnHidden(static_cast<int>(WorksheetPrivate::TreeModelColumn::CURSORDIFF), true); |
| 70 | |
| 71 | ui->tvCursorData->expandAll(); |
| 72 | |
| 73 | // connect all plots as a workaround to not be able to know which plot is selected |
| 74 | for (auto& connection : selectedPlotsConnection) |
| 75 | disconnect(connection); |
| 76 | for (const auto* plot : m_plotList) { |
| 77 | selectedPlotsConnection << connect(plot, &CartesianPlot::cursor0EnableChanged, this, &CursorDock::plotCursor0EnableChanged); |
| 78 | selectedPlotsConnection << connect(plot, &CartesianPlot::cursor1EnableChanged, this, &CursorDock::plotCursor1EnableChanged); |
| 79 | selectedPlotsConnection << connect(plot, &CartesianPlot::mousePressCursorModeSignal, this, &CursorDock::cursorUsed); |
| 80 | selectedPlotsConnection << connect(plot, &CartesianPlot::mousePressCursorModeSignal, this, &CursorDock::cursorUsed); |
| 81 | } |
| 82 | } |
| 83 | |
| 84 | CursorDock::~CursorDock() { |
| 85 | delete ui; |
no test coverage detected