Fix issue #8 (undoredo).

This commit adds a proper undo/redo mechanism for switching templates.
This commit is based on the multifiles branch, so it can not be merged anywhere pending PR #13.

So please vote there!
Merge pull request #15 from jjpe/undoredo

Fix issue #8 (undoredo).

And due to the merging of #13, this can also be merged.