| 310 | } |
| 311 | |
| 312 | void WorksheetElement::prepareDrawingOrderMenu() { |
| 313 | const auto* parent = parentAspect(); |
| 314 | const int index = parent->indexOfChild<AbstractAspect>(this, ChildIndexFlag::IncludeHidden); |
| 315 | const auto& children = parent->children<AbstractAspect>(ChildIndexFlag::IncludeHidden); |
| 316 | |
| 317 | //"move behind" sub-menu |
| 318 | m_moveBehindMenu->clear(); |
| 319 | for (int i = 0; i < index; ++i) { |
| 320 | const auto* elem = children.at(i); |
| 321 | if (elem->isHidden()) |
| 322 | continue; |
| 323 | // axes and legends are always drawn on top of other elements, don't add them to the menu |
| 324 | if (elem->type() != AspectType::Axis && elem->type() != AspectType::CartesianPlotLegend) { |
| 325 | auto* action = m_moveBehindMenu->addAction(elem->icon(), elem->name()); |
| 326 | action->setData(i); |
| 327 | } |
| 328 | } |
| 329 | |
| 330 | //"move in front of" sub-menu |
| 331 | m_moveInFrontOfMenu->clear(); |
| 332 | for (int i = index + 1; i < children.size(); ++i) { |
| 333 | const auto* elem = children.at(i); |
| 334 | if (elem->isHidden()) |
| 335 | continue; |
| 336 | // axes and legends are always drawn on top of other elements, don't add them to the menu |
| 337 | if (elem->type() != AspectType::Axis && elem->type() != AspectType::CartesianPlotLegend) { |
| 338 | auto* action = m_moveInFrontOfMenu->addAction(elem->icon(), elem->name()); |
| 339 | action->setData(i); |
| 340 | } |
| 341 | } |
| 342 | |
| 343 | // hide the sub-menus if they don't have any entries |
| 344 | m_moveInFrontOfMenu->menuAction()->setVisible(!m_moveInFrontOfMenu->isEmpty()); |
| 345 | m_moveBehindMenu->menuAction()->setVisible(!m_moveBehindMenu->isEmpty()); |
| 346 | } |
| 347 | |
| 348 | void WorksheetElement::execMoveInFrontOf(QAction* action) { |
| 349 | auto* parent = parentAspect(); |