2 #include <score/model/tree/TreeNode.hpp>
3 #include <score/model/tree/TreeNodeItemModel.hpp>
5 #include <QAbstractProxyModel>
12 template <
typename Node,
typename NodePath>
15 void save(QAbstractProxyModel* m, QTreeView* v)
17 auto de =
static_cast<TreeModel*
>(m->sourceModel());
19 m_expandedIndices.clear();
20 de->iterate(v->rootIndex(), [
this, m, v](
const QModelIndex& index) {
21 if(v->isExpanded(m->mapFromSource(index)))
23 if(
auto item =
static_cast<Node*
>(index.internalPointer()))
25 m_expandedIndices.push_back(NodePath{*item});
31 void restore(QAbstractProxyModel* m, QTreeView* v)
33 auto de =
static_cast<TreeModel*
>(m->sourceModel());
35 v->setUpdatesEnabled(
false);
37 for(
auto& path : m_expandedIndices)
39 auto idx = de->convertPathToIndex(path);
42 v->expand(m->mapFromSource(idx));
45 v->setUpdatesEnabled(
true);
49 std::vector<NodePath> m_expandedIndices;
Definition: TreeNodeItemModel.hpp:15
Base toolkit upon which the software is built.
Definition: Application.cpp:90
Definition: TreeViewExpandState.hpp:14