| 283 | } |
| 284 | |
| 285 | bool ActionContainer::update() |
| 286 | { |
| 287 | bool hasitems = false; |
| 288 | QList<QAction *> actions = d->menu->actions(); |
| 289 | |
| 290 | for (const Group &group : std::as_const(d->groupList)) { |
| 291 | for (QObject *item : std::as_const(group.items)) { |
| 292 | if (auto container = qobject_cast<ActionContainer *>(item)) { |
| 293 | actions.removeAll(container->menu()->menuAction()); |
| 294 | if (container == this) { |
| 295 | QByteArray warning = Q_FUNC_INFO + QByteArray(" container '"); |
| 296 | if (this->menu()) |
| 297 | warning += this->menu()->title().toLocal8Bit(); |
| 298 | warning += "' contains itself as subcontainer"; |
| 299 | qWarning("%s", warning.constData()); |
| 300 | continue; |
| 301 | } |
| 302 | if (container->update()) { |
| 303 | hasitems = true; |
| 304 | break; |
| 305 | } |
| 306 | } else if (auto command = qobject_cast<Command *>(item)) { |
| 307 | actions.removeAll(command->action()); |
| 308 | if (command->isActive() |
| 309 | && command->action()->menuRole() != QAction::ApplicationSpecificRole) { |
| 310 | hasitems = true; |
| 311 | break; |
| 312 | } |
| 313 | } else { |
| 314 | QTC_ASSERT(false, continue); |
| 315 | } |
| 316 | } |
| 317 | if (hasitems) |
| 318 | break; |
| 319 | } |
| 320 | if (!hasitems) { |
| 321 | // look if there were actions added that we don't control and check if they are enabled |
| 322 | for (const QAction *action : std::as_const(actions)) { |
| 323 | if (!action->isSeparator() && action->isEnabled()) { |
| 324 | hasitems = true; |
| 325 | break; |
| 326 | } |
| 327 | } |
| 328 | } |
| 329 | |
| 330 | if (onAllDisabledBehavior() == Hide) |
| 331 | d->menu->menuAction()->setVisible(hasitems); |
| 332 | else if (onAllDisabledBehavior() == Disable) |
| 333 | d->menu->menuAction()->setEnabled(hasitems); |
| 334 | |
| 335 | return hasitems; |
| 336 | } |
nothing calls this directly
no test coverage detected