MCPcopy Create free account
hub / github.com/MeshInspector/MeshLib / updateUndoListCache_

Method updateUndoListCache_

source/MRViewer/MRSceneControlMenuItems.cpp:86–114  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

84}
85
86void 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
116RedoMenuItem::RedoMenuItem() :
117 RibbonMenuItem( "Redo" )

Callers

nothing calls this directly

Calls 8

trimHashHashSuffixFunction · 0.85
getNActionsMethod · 0.80
undoMethod · 0.80
translateFunction · 0.70
emptyMethod · 0.45
clearMethod · 0.45
resizeMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected