Undo manager tweaks

Would be cool if the undo manager:

  1. there is UndoManager::setCurrentTransactionName but not UndoManager::getCurrentTransactionName
  2. i would like to implement a "Repeat last action" command, much like the one in graphics editor where you apply the last effect several times:
if (undoManager.canRedo()
    && undoManager.getNumActionsInCurrentTransaction() > 0)
{
    Array<const UndoableAction*> actions;
    undoManager.getActionsInCurrentTransaction(actions);

    const UndoableAction* action = actions.getLast();
    undoManager.perform(action);
}

obviously this doesn't work, cause i can't pass an immutable pointer again in the undo queue (which has the ownership of the UndoableAction). Some sort of virtual UndoableAction* UndoableAction::clone() const function would be cool (to be implemented by subclasses to pass internal parameters to a new action instance).

Will certainly add a getCurrentTransactionName method, no problem. As for adding a clone method, hmm, not 100% sure.. I guess it's not unreasonable, but can't help thinking it'd be difficult to actually use.

well, is there a way to create a fresh new non const copy of a UndoableAction returning from getActionsInCurrentTransaction without an explicit dynamic cast ? maybe the UndoManager could take care of this?

If you have your own subclass that implements a clone method then you could just dynamic-cast it to your own class and call your clone method, can't you? (Since a clone method should be const there'd not even be a need for a const cast?)

yeah of course i've done this way, but any time i'm forced to use dynamic casting in my code, the alarm bell is ringing in my head "things can be done properly in other ways" ?