MCPcopy Create free account
hub / github.com/OneMoreGres/ScreenTranslator / tryAction

Method tryAction

src/service/updates.cpp:399–421  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

397}
398
399void Model::tryAction(Action action, const QModelIndex &index)
400{
401 const auto visitor = [this, action](Component &component, auto v) -> void {
402 if (component.checkOnly)
403 return;
404
405 const auto &state = component.state;
406 auto ok = (action == Action::Remove &&
407 (state == State::UpdateAvailable || state == State::Actual)) ||
408 (action == Action::Install && (state == State::UpdateAvailable ||
409 state == State::NotInstalled));
410 if (ok)
411 updater_.applyAction(action, component.files);
412
413 if (!component.children.empty()) {
414 for (auto &child : component.children) v(*child, v);
415 }
416 };
417
418 auto component = toComponent(index);
419 SOFT_ASSERT(component, return );
420 visitor(*component, visitor);
421}
422
423Model::Component *Model::toComponent(const QModelIndex &index) const
424{

Callers 2

showModelContextMenuMethod · 0.80

Calls 1

applyActionMethod · 0.80

Tested by

no test coverage detected