MCPcopy Create free account
hub / github.com/Zalafina/QKeyMapper / commitHistorySnapshotIfNeeded

Method commitHistorySnapshotIfNeeded

QKeyMapper/qmappingsequenceedit.cpp:409–439  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

407}
408
409void QMappingSequenceEdit::commitHistorySnapshotIfNeeded()
410{
411 if (m_IsRestoringHistory) {
412 return;
413 }
414
415 const MappingSequenceHistorySnapshot snapshot = captureHistorySnapshot();
416
417 // Skip empty steps: only record when the list content actually changes.
418 if (m_HistoryIndex >= 0 && m_HistoryIndex < m_HistorySnapshots.size()) {
419 if (m_HistorySnapshots.at(m_HistoryIndex).mappingSequenceList == snapshot.mappingSequenceList) {
420 return;
421 }
422 }
423
424 // If we have undone some steps, discard redo branch when a new change is committed.
425 if (m_HistoryIndex >= 0 && m_HistoryIndex < m_HistorySnapshots.size() - 1) {
426 m_HistorySnapshots.resize(m_HistoryIndex + 1);
427 }
428
429 m_HistorySnapshots.append(snapshot);
430 m_HistoryIndex = m_HistorySnapshots.size() - 1;
431
432 const int maxSnapshots = qMax(2, MAPPINGSEQUENCEEDIT_HISTORY_MAX + 1);
433 while (m_HistorySnapshots.size() > maxSnapshots) {
434 m_HistorySnapshots.remove(0);
435 m_HistoryIndex = qMax(0, m_HistoryIndex - 1);
436 }
437
438 updateUndoRedoButtonsEnabled();
439}
440
441void QMappingSequenceEdit::undo()
442{

Callers

nothing calls this directly

Calls 2

sizeMethod · 0.80
removeMethod · 0.80

Tested by

no test coverage detected