src/document.cpp

changeset 150
b6cbba6e29a1
parent 148
e1ced2523cad
child 152
03f8e6d42e13
equal deleted inserted replaced
148:e1ced2523cad 150:b6cbba6e29a1
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));

mercurial