22 lines
675 B
Python
22 lines
675 B
Python
from __future__ import annotations
|
|
|
|
from copy import deepcopy
|
|
|
|
from PySide6.QtGui import QUndoCommand
|
|
|
|
from bedit_gui.models import SimulationDatabase
|
|
|
|
|
|
class ChangeSimulationDatabaseCommand(QUndoCommand):
|
|
def __init__(self, document: object, database: SimulationDatabase) -> None:
|
|
super().__init__("Edit simulation settings")
|
|
self.document = document
|
|
self.old_database = document.stored_simulation_database()
|
|
self.new_database = deepcopy(database)
|
|
|
|
def redo(self) -> None:
|
|
self.document._set_simulation_database(self.new_database)
|
|
|
|
def undo(self) -> None:
|
|
self.document._set_simulation_database(self.old_database)
|