Improved the DuiDocument and keep a working copy of the document in the editor, also use the QML api.