| 232 | } |
| 233 | |
| 234 | PlotWidget* takeForArea(const LayoutNode& node) { |
| 235 | const QDomElement plot_element = node.plots.isEmpty() ? QDomElement{} : node.plots.front(); |
| 236 | const QString plot_id = plot_element.attribute(QStringLiteral("id")); |
| 237 | if (!plot_id.isEmpty()) { |
| 238 | auto it = plots_by_id_.find(plot_id); |
| 239 | if (it != plots_by_id_.end() && !used_.contains(it.value())) { |
| 240 | PlotWidget* plot = it.value(); |
| 241 | used_.insert(plot); |
| 242 | return plot; |
| 243 | } |
| 244 | } |
| 245 | |
| 246 | while (next_position_ < plots_by_position_.size()) { |
| 247 | PlotWidget* plot = plots_by_position_.at(next_position_++); |
| 248 | if (plot != nullptr && !used_.contains(plot)) { |
| 249 | used_.insert(plot); |
| 250 | return plot; |
| 251 | } |
| 252 | } |
| 253 | |
| 254 | return createPlot(plot_id); |
| 255 | } |
| 256 | |
| 257 | void deleteUnused() { |
| 258 | for (PlotWidget* plot : plots_by_position_) { |