Skip to content
This repository has been archived by the owner on Sep 28, 2022. It is now read-only.

Transactions Editing the model and map with Undo and Redo functionality

Colleen Barr edited this page Feb 20, 2020 · 1 revision

Some editing operations affect both the core model elements and the visual objects displayed on the map. These operations include adding and removing visual objects from the model and changing the coordinates of an object (moving it.)

We are using the Qt Undo/Redo framework for these operations. Each operation is implemented as a method of the main form and as a small private class. For example, adding a new item to the model and the map is accomplished by calling the add_item method which internally uses the private _AddItem class to handle doing (and optionally undoing and redoing) this operation. Similarly the delete_item operation internally uses the private _DeleteItem class.

Moving an item or editing other aspects of it can be handled similarly.