Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Manual save system and undo/redo #174

Open
35 tasks
svetter opened this issue Nov 7, 2023 · 2 comments
Open
35 tasks

Manual save system and undo/redo #174

svetter opened this issue Nov 7, 2023 · 2 comments
Labels
enhancement New feature or request
Milestone

Comments

@svetter
Copy link
Owner

svetter commented Nov 7, 2023

Only save changes to base table buffers, and keep score of which changes were made. Allow the user to step through that list of changes with undo/redo operations. On save, go through list of changes and commit to SQL.

Both the buffers and SQL module will have a pointer to the list of changes which can be moved by undo/redo (buffers) or saving (SQL), respectively.

Backend

  • Create container classes for the different kinds of changes
    • Base class
    • Add row
    • Update row
    • Delete row
  • Create tree of change objects
    • Root is project open (no undo possible)
    • Pointer for runtime
    • Pointer for persistent storage
  • Create class TempItemID or other solution to ID problem
    • Make sure it is compatible with the tree format
  • Create system for assigning (translated) names to change objects

Event handling

  • On user change
    • Make changes in cache
    • Create new change object
    • If the previous node in the change tree has another child, remove that subtree unless it contains the storage pointer
  • On save
    • Determine path between storage pointer and runtime pointer
    • Walk along path and execute changes on SQL
    • Prune change tree
      • Remove any node which is neither ascendant nor descendant of the current one
  • On undo
    • Execute changes of current change node on caches (backwards)
    • Move runtime pointer to direct parent
  • On redo
    • Move runtime pointer to direct child
      • If there is more than one child, choose the one which does not 'contain' the storage pointer
    • Execute changes of current change node on caches (forwards)

Frontend

  • Create menu bar entries for undo and redo
  • Create sub-menus for multi-undo and multi-redo
    • List of n previous/next changes
    • On click, move to clicked state
  • Create keyboard shortcuts
  • Show confirmation message in status bar after undo and redo

Finalization

  • Test and debug
@svetter svetter added the enhancement New feature or request label Nov 7, 2023
@svetter svetter added this to the Ideas milestone Nov 7, 2023
@svetter
Copy link
Owner Author

svetter commented Nov 9, 2023

ID problem

New items get their IDs from the data base. If they're not saved to the DB straight away, they don't have IDs, which are needed immediately.

Possible solution: New class like TempItemID : protected ValidItemID, used for new items in place of ItemID/ValidItemID. While committing the changes from list to database, a map from TempItemIDs to new database keys is kept and TempItemIDs replaced. TempItemIDs can be assigned starting just above the highest ValidItemID of its item type, because the only way new actual ItemIDs can be created is by the database, which is a controllable process.

@svetter svetter changed the title Manual save system instead of immediate auto-save Manual save system and undo/redo May 15, 2024
@svetter
Copy link
Owner Author

svetter commented Aug 1, 2024

Optional advanced feature for the future:

  • Remove any tree pruning
  • At change nodes with multiple children, allow user to select between them
  • Critically requires good naming system for change nodes

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant