UI: Move rename buffer management to new view base class

Renaming is a nice example of a feature that shouldn't need a specific
implementation for a specific view type (e.g. grid or tree view). So it's
something that can be supported in the general view code. Individual views can
use it "for free" then. This ports the view level part of the renaming code,
the view item level part of it can be ported once we have a common base class
for the view items.
This commit is contained in:
2022-07-02 22:36:50 +02:00
parent c355be6fae
commit e86c2f7288
4 changed files with 85 additions and 35 deletions

View File

@@ -117,20 +117,11 @@ class AbstractTreeView : public AbstractView, public TreeViewItemContainer {
friend class AbstractTreeViewItem;
friend class TreeViewBuilder;
/**
* Only one item can be renamed at a time. So the tree is informed about the renaming state to
* enforce that.
*/
std::unique_ptr<std::array<char, MAX_NAME>> rename_buffer_;
public:
virtual ~AbstractTreeView() = default;
void foreach_item(ItemIterFn iter_fn, IterOptions options = IterOptions::None) const;
/** Only one item can be renamed at a time. */
bool is_renaming() const;
protected:
virtual void build_tree() = 0;