Repository navigation
Make each drag of a node one undo step - #573
Merged
Merged
Conversation
paceholder
force-pushed
the
fix-drag-undo-steps
branch
from
November 30, 2026 21:08
431bfe5 to
009df03
Compare
QUndoStack merges commands with the same id and does not know where a drag ends, so two drags of the same nodes became one undo step. A press on a node or a group now starts a new move, and only the commands of one move merge. Fixes #538
paceholder
force-pushed
the
fix-drag-undo-steps
branch
from
December 1, 2026 07:42
009df03 to
956957e
Compare
This was referenced Dec 1, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Type of change
Description
MoveNodeCommand::mergeWithmerged every move of the same nodes. Drag node A, release, drag A again: one undo reverted both drags.QUndoStackmerges commands that follow each other and have the same id, and it does not know where a drag ends. This comes from the first undo implementation. The fix for #525 and #526 restored the flow of a drag through the model and the undo stack, and kept the merge.MoveNodeCommandnow has a move id. All commands that are created get the current id. A mouse press on a node or on a group callsMoveNodeCommand::beginMove(), which starts a new move. Commands merge only when the node set and the move id are the same. The mouse moves of one drag still merge into one step. A new press starts a new step. No id is stored in the graphics objects, and the scene is not changed.Code that creates the command itself and never calls
beginMove()merges as before, until the next press on a node or a group.Testing
Not tested: Qt5 locally, a group drag, a real mouse with fast moves.
Breaking changes?
Undo after two drags of the same node now reverts only the second drag. The API only gets a static function.
Related issue
Fixes #538.