Turning hands to Undo & Redo

Since undo/redo form a very essential part of any application, we chose to implement this after the deployment of movement and selection of items. This will avoid the chaos when proceeding with actions like cut, copy and paste. The Qt’s Undo Framework supports undo/redo for all those actions/functions that are inherited from QUndoCommand.

The previous implementation of adding any graphics item to the scene was nowhere close to this. Why had we not inherited QGraphicsItemGroup instead of QGraphicsItem before? Well, moving to this stage made us realize we need to switch to the former and made our implementation quite better and reduced redundancy of a few things too.

Each event like addition, deletion, moving will be having classes of their own where items will be added, deleted and moved respectively. The mousePressEvent dealt with the pushing of the action to the undoStack. We have done with undo/redo associated with addition event today. Will be completing the other two tomorrow.

Feels good to see Ctrl+Z and Ctrl+Shift+Z working. ^_^

Leave a Reply

Follow

Get notified with the latest posts

Plugin Supporter WordPress Post Navigation
%d bloggers like this: