MCPcopy Create free account
hub / github.com/actuallyaridan/linux-devmgmt / saveExpandedState

Method saveExpandedState

src/ui/MainWindow.cpp:91–107  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

89}
90
91QSet<QString> MainWindow::saveExpandedState() const {
92 QSet<QString> expanded;
93 std::function<void(const QModelIndex &, int)> walk =
94 [&](const QModelIndex &parent, int depth) {
95 for (int i = 0; i < m_model->rowCount(parent); ++i) {
96 QModelIndex idx = m_model->index(i, 0, parent);
97 if (m_tree->isExpanded(idx)) {
98 expanded.insert(
99 QString::number(depth) + ':'
100 + m_model->data(idx, Qt::DisplayRole).toString());
101 walk(idx, depth + 1);
102 }
103 }
104 };
105 walk(m_tree->rootIndex(), 0);
106 return expanded;
107}
108
109void MainWindow::restoreExpandedState(const QSet<QString> &expanded) {
110 std::function<void(const QModelIndex &, int)> walk =

Callers

nothing calls this directly

Calls 3

rowCountMethod · 0.80
indexMethod · 0.80
dataMethod · 0.80

Tested by

no test coverage detected