# UndoCommand.py -- Pamhyr # Copyright (C) 2023-2024 INRAE # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . # -*- coding: utf-8 -*- from copy import deepcopy from tools import trace, timer from PyQt5.QtWidgets import ( QUndoCommand, QUndoStack, ) class AddScenariosCommand(QUndoCommand): def __init__(self, study, source): QUndoCommand.__init__(self) self._study = study self._source = source def undo(self): logger.error(f"TODO {type(self)} : undo") def redo(self): self._study.new_scenario_from_current(switch=False) class DelScenariosCommand(QUndoCommand): def __init__(self, study, scenario): QUndoCommand.__init__(self) self._study = study self._scenario = scenario def undo(self): logger.error(f"TODO {type(self)} : undo") def redo(self): logger.error(f"TODO {type(self)} : redo") class SetCommand(QUndoCommand): def __init__(self, scenario, column, new_value): QUndoCommand.__init__(self) self._el = scenario self._column = column self._old = self._el[self._column] self._new = new_value def undo(self): self._el[self._column] = self._old def redo(self): self._el[self._column] = self._new