I am building an application (Python/PyQt). The first-order item will be a tree view/model wit many helper functions to add new items, move them around in the tree, etc.. Then I will have a main window object that will basically serve as a wrapper for the tree, with a toolbar with buttons for the user to add/remove/move items (these actions will call the helper methods built into the tree object).
I want to give the user the ability to undo/redo any actions, using Qt's undo framework. I am curious whether there is consensus/experience on whether to implement the undo stack classes when defining the tree object, or perhaps in its wrapper? I can see going either way.
Initially I was thinking in the wrapper, so I could keep my tree smaller and compact. As I started, though, I realized I seemed to be breaking modularity, and might end up making the wrapper depend too much on how the helper functions are implemented in the tree object.
So now I'm leaning toward making the undo stack an attribute of the tree itself, rather than its wrapper, and then basically treat the [QUndoCommand][2] classes as an api for my wrapper to use, rather than define such classes as part of the wrapper.
But I am completely new to this, so am wondering if there is some hard-to-find-on-Google wisdom folks might have.
Aucun commentaire:
Enregistrer un commentaire