enthought / enthought/traitsui

Request: Include apptools UndoManager support for TreeEditor DND events

Open
#899 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Python
Stars
306
Forks
99
PR merge metrics
No merged PRs in 30d

Description

_Note: I am not sure what the best way to include this support is, or if it could also be extended to other editor classes. It also may not be beneficial to do so if it is expected that TraitsUI may migrate to a different undo / redo system in the near future._

I am implementing an `apptools` undo / redo system for a set of TraitsUI `TreeNode` objects. This involves representing each UI event that I would like to support as undoable by an `apptools` `AbstractCommand` class. Additionally, each `TreeNode` subclass has a reference to the UI's `UndoManager` that is handling the active stack, in order to be able to push commands.

Simple commands on the tree (add / delete / insert nodes) are easily adapted into `apptools` commands by using the existing `ITreeNode` API (`ITreeNode.append_child`, `ITreeNode.insert_child`, `ITreeNode.delete_child`). However, from what I can tell, drag and drop events are exposed at the Qt/Wx level only - presumably since they are represented by combinations of primitive events (delete + add), rather than a single event.

Therefore I am unable to implement an `apptools` command (or macro) that represents moving one item in the tree to another location without monkeypatching either the low-level `qt4.tree_editor._TreeWidget.dropEvent` or `wx.tree_editor.SimpleEditor.wx_dropped_on` methods.

Is there a way of exposing a `move_child` command on the `ITreeNode` class that would be called on a successful drag + drop event? It would effectively bypass the following sequence of function calls:

```python
SimpleEditor._begin_undo()
SimpleEditor._undoable_delete(node, object, index, make_copy)
SimpleEditor._undoable_append(node, object, data)
SimpleEditor._end_undo()
```

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.