55 { |
55 { |
56 QItemSelectionModel* selectionModel = this->ui.listView->selectionModel(); |
56 QItemSelectionModel* selectionModel = this->ui.listView->selectionModel(); |
57 QItemSelection selection; |
57 QItemSelection selection; |
58 for (ldraw::id_t id : newSelection) |
58 for (ldraw::id_t id : newSelection) |
59 { |
59 { |
60 QModelIndex index = this->model->lookup(id); |
60 QModelIndex index = this->model->find(id); |
61 if (index != QModelIndex{}) |
61 if (index != QModelIndex{}) |
62 { |
62 { |
63 selection.select(index, index); |
63 selection.select(index, index); |
64 } |
64 } |
65 } |
65 } |
68 this->selectionChanged(newSelection); |
68 this->selectionChanged(newSelection); |
69 }); |
69 }); |
70 connect(this->ui.listView->selectionModel(), &QItemSelectionModel::selectionChanged, |
70 connect(this->ui.listView->selectionModel(), &QItemSelectionModel::selectionChanged, |
71 [&](const QItemSelection& selected, const QItemSelection& deselected) |
71 [&](const QItemSelection& selected, const QItemSelection& deselected) |
72 { |
72 { |
73 auto resolveIndex = [this](const QModelIndex& index){ return this->model->resolve(index); }; |
73 auto resolveIndex = [this](const QModelIndex& index){ return (*this->model)[index.row()]->id; }; |
74 auto resolve = [resolveIndex](const QItemSelection& selection) |
74 auto resolve = [resolveIndex](const QItemSelection& selection) |
75 { |
75 { |
76 return fn::map<QSet<ldraw::id_t>>(selection.indexes(), resolveIndex); |
76 return fn::map<QSet<ldraw::id_t>>(selection.indexes(), resolveIndex); |
77 }; |
77 }; |
78 this->renderer->handleSelectionChange(resolve(selected), resolve(deselected)); |
78 this->renderer->handleSelectionChange(resolve(selected), resolve(deselected)); |