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

Method updateRedoListCache_

source/MRViewer/MRSceneControlMenuItems.cpp:165–193  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

163}
164
165void RedoMenuItem::updateRedoListCache_( const HistoryStore& store, HistoryStore::ChangeType type, std::shared_ptr<HistoryAction> )
166{
167 if ( type == HistoryStore::ChangeType::PreRedo ||
168 type == HistoryStore::ChangeType::PreUndo ||
169 type == HistoryStore::ChangeType::PreAppendAction )
170 return; // no need to update cache in this case
171
172 if ( type == HistoryStore::ChangeType::PostAppendAction && bool( store.getScopeBlockPtr() ) )
173 return; // no need to update cache for actions in scope
174
175 auto lastRedos = store.getNActions( cMaxNumActionsInList, HistoryAction::Type::Redo );
176 if ( lastRedos.empty() )
177 {
178 dropList_.clear();
179 return;
180 }
181
182 dropList_.resize( lastRedos.size() );
183 for ( int i = 0; i < lastRedos.size(); ++i )
184 {
185 const auto itemName = fmt::format( "{}##{}", Locale::translate( trimHashHashSuffix( lastRedos[i] ), Locale::genericDomain ), i );
186 dropList_[i] = std::make_shared<LambdaRibbonItem>( itemName, [i]
187 {
188 if ( auto* history = HistoryStore::getViewerInstance() )
189 for ( int j = 0; j <= i; ++j )
190 history->redo();
191 } );
192 }
193}
194
195MR_REGISTER_RIBBON_ITEM( UndoMenuItem )
196

Callers

nothing calls this directly

Calls 8

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

Tested by

no test coverage detected