| 1198 | } |
| 1199 | |
| 1200 | void CartesianPlotDock::removePlotRange() { |
| 1201 | DEBUG(Q_FUNC_INFO) |
| 1202 | |
| 1203 | int currentRow{ui.twPlotRanges->currentRow()}; |
| 1204 | QDEBUG(Q_FUNC_INFO << ", current plot range = " << currentRow) |
| 1205 | if (currentRow < 0 || currentRow > m_plot->coordinateSystemCount()) { |
| 1206 | DEBUG(Q_FUNC_INFO << ", no current plot range") |
| 1207 | currentRow = m_plot->coordinateSystemCount() - 1; |
| 1208 | } |
| 1209 | QDEBUG(Q_FUNC_INFO << ", removing plot range " << currentRow) |
| 1210 | |
| 1211 | // check all children for cSystem usage |
| 1212 | for (auto* element : m_plot->children<WorksheetElement>()) { |
| 1213 | const int cSystemIndex{element->coordinateSystemIndex()}; |
| 1214 | DEBUG(Q_FUNC_INFO << ", element x index = " << cSystemIndex) |
| 1215 | if (cSystemIndex == currentRow) { |
| 1216 | DEBUG(Q_FUNC_INFO << ", WARNING: plot range used in element") |
| 1217 | |
| 1218 | auto status = |
| 1219 | KMessageBox::warningTwoActions(this, |
| 1220 | i18n("Plot range %1 is used by element \"%2\". ", currentRow + 1, element->name()) + i18n("Really remove it?"), |
| 1221 | QString(), |
| 1222 | KStandardGuiItem::remove(), |
| 1223 | KStandardGuiItem::cancel()); |
| 1224 | if (status == KMessageBox::SecondaryAction) |
| 1225 | return; |
| 1226 | else |
| 1227 | element->setCoordinateSystemIndex(0); // reset |
| 1228 | } |
| 1229 | } |
| 1230 | |
| 1231 | m_plot->removeCoordinateSystem(currentRow); |
| 1232 | updatePlotRangeList(); |
| 1233 | m_plot->retransform(); // update plot and elements |
| 1234 | } |
| 1235 | |
| 1236 | void CartesianPlotDock::PlotRangeChanged(const int plotRangeIndex, const Dimension dim, const int index) { |
| 1237 | const std::string dimStr = CartesianCoordinateSystem::dimensionToString(dim).toStdString(); |
nothing calls this directly
no test coverage detected