MCPcopy Create free account
hub / github.com/Codeya-IDE/deepin-ide / update

Method update

src/common/actionmanager/actioncontainer.cpp:285–336  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

283}
284
285bool 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}

Callers

nothing calls this directly

Calls 10

menuMethod · 0.95
QByteArrayClass · 0.85
setVisibleMethod · 0.80
actionsMethod · 0.45
removeAllMethod · 0.45
titleMethod · 0.45
actionMethod · 0.45
isActiveMethod · 0.45
isEnabledMethod · 0.45
setEnabledMethod · 0.45

Tested by

no test coverage detected