| 107 | } |
| 108 | |
| 109 | void MainWindow::restoreExpandedState(const QSet<QString> &expanded) { |
| 110 | std::function<void(const QModelIndex &, int)> walk = |
| 111 | [&](const QModelIndex &parent, int depth) { |
| 112 | for (int i = 0; i < m_model->rowCount(parent); ++i) { |
| 113 | QModelIndex idx = m_model->index(i, 0, parent); |
| 114 | if (expanded.contains( |
| 115 | QString::number(depth) + ':' |
| 116 | + m_model->data(idx, Qt::DisplayRole).toString())) { |
| 117 | m_tree->expand(idx); |
| 118 | walk(idx, depth + 1); |
| 119 | } |
| 120 | } |
| 121 | }; |
| 122 | walk(m_tree->rootIndex(), 0); |
| 123 | } |
| 124 | |
| 125 | void MainWindow::onScanComplete(const QString &hostName, |
| 126 | const QVector<DeviceCategory> &categories) { |