| 84 | } |
| 85 | |
| 86 | void UndoMenuItem::updateUndoListCache_( const HistoryStore& store, HistoryStore::ChangeType type, std::shared_ptr<HistoryAction> ) |
| 87 | { |
| 88 | if ( type == HistoryStore::ChangeType::PreRedo || |
| 89 | type == HistoryStore::ChangeType::PreUndo || |
| 90 | type == HistoryStore::ChangeType::PreAppendAction ) |
| 91 | return; // no need to update cache in this case |
| 92 | |
| 93 | if ( type == HistoryStore::ChangeType::PostAppendAction && bool( store.getScopeBlockPtr() ) ) |
| 94 | return; // no need to update cache for actions in scope |
| 95 | |
| 96 | auto lastUndos = store.getNActions( cMaxNumActionsInList, HistoryAction::Type::Undo ); |
| 97 | if ( lastUndos.empty() ) |
| 98 | { |
| 99 | dropList_.clear(); |
| 100 | return; |
| 101 | } |
| 102 | |
| 103 | dropList_.resize( lastUndos.size() ); |
| 104 | for ( int i = 0; i < lastUndos.size(); ++i ) |
| 105 | { |
| 106 | const auto itemName = fmt::format( "{}##{}", Locale::translate( trimHashHashSuffix( lastUndos[i] ), Locale::genericDomain ), i ); |
| 107 | dropList_[i] = std::make_shared<LambdaRibbonItem>( itemName, [i] |
| 108 | { |
| 109 | if ( auto* history = HistoryStore::getViewerInstance() ) |
| 110 | for ( int j = 0; j <= i; ++j ) |
| 111 | history->undo(); |
| 112 | } ); |
| 113 | } |
| 114 | } |
| 115 | |
| 116 | RedoMenuItem::RedoMenuItem() : |
| 117 | RibbonMenuItem( "Redo" ) |
nothing calls this directly
no test coverage detected