Commit 091d4227 authored by Maxime Perrotin's avatar Maxime Perrotin
Browse files

Test undo/redo

parent ae300714
......@@ -234,6 +234,7 @@ inst {fv};'''.format(fv=fv_name)]
@Slot(unicode)
def addCondition(self, condition):
''' Add a "Condition" box to the MSC (single word with no spaces) '''
# TODO REMOVE THIS CODE
condbox = self.msc_scene.addCondition(self.taste_instance,
y=self.next_y,
label=condition)
......
......@@ -126,6 +126,8 @@ class sdlHandler(QObject):
redo_button = widget.findChild(QToolButton, 'redoButton')
reset_button = widget.findChild(QToolButton, 'resetButton')
reset_button.clicked.connect(self.reset_simulation)
undo_button.clicked.connect(self.undo)
redo_button.clicked.connect(self.redo)
@property
def dll(self):
......@@ -202,6 +204,18 @@ class sdlHandler(QObject):
self.restore_global_state(self.init_state)
# TODO: clean log, clean MSC, rewind undo stack
def undo(self):
''' Called when the undo button is pressed '''
self.undo_stack.undo()
self.check_state()
self.current_hash = self.on_event()
def redo(self):
''' Called when the redo button is pressed '''
self.undo_stack.redo()
self.check_state()
self.current_hash = self.on_event()
def restore_global_state(self, statehash):
''' From a hashcode, restore a global state in the DLL (state +
all internal variables '''
......@@ -272,7 +286,7 @@ class sdlHandler(QObject):
continue
button.setEnabled(tc in allowed_tc)
if tc_name in self.timers:
self.buttons[name].setEnabled(False)
self.buttons[tc_name].setEnabled(False)
# Emit the list of allowed TC for the GUI to update other buttons
self.allowed_messages.emit(allowed_tc)
if tc_name:
......@@ -311,7 +325,7 @@ class sdlHandler(QObject):
''' Send a TC - Used either locally (parameterless TCs) or via
a signal sent by the B-mapper-generated backends '''
if name in self.timers:
self.buttons[name].setEnabled(False)
# self.buttons[name].setEnabled(False)
self.add_to_msc('timeout', name)
elif not param:
msg = '{tc}{arg}'.format(tc=name,
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment