introduce a new class for undo and redo

Signed-off-by: Mattias Andrée <maandree@operamail.com>