src/document.cpp

changeset 73
97df974b5ed5
parent 63
f7dd937667a5
child 81
62373840e33a
equal deleted inserted replaced
72:7c27cda03747 73:97df974b5ed5
39 layout->addWidget(this->renderer); 39 layout->addWidget(this->renderer);
40 this->ui.viewportFrame->setLayout(layout); 40 this->ui.viewportFrame->setLayout(layout);
41 this->setMouseTracking(true); 41 this->setMouseTracking(true);
42 connect(this->ui.splitter, &QSplitter::splitterMoved, this, &Document::splitterChanged); 42 connect(this->ui.splitter, &QSplitter::splitterMoved, this, &Document::splitterChanged);
43 connect(this->renderer, &Canvas::newStatusText, this, &Document::newStatusText); 43 connect(this->renderer, &Canvas::newStatusText, this, &Document::newStatusText);
44 connect(this->renderer, &Canvas::selectionChanged, [&](const QSet<ldraw::Id>& newSelection) 44 connect(this->renderer, &Canvas::selectionChanged, [&](const QSet<ldraw::id_t>& newSelection)
45 { 45 {
46 QItemSelectionModel* selectionModel = this->ui.listView->selectionModel(); 46 QItemSelectionModel* selectionModel = this->ui.listView->selectionModel();
47 QItemSelection selection; 47 QItemSelection selection;
48 for (ldraw::Id id : newSelection) 48 for (ldraw::id_t id : newSelection)
49 { 49 {
50 QModelIndex index = this->model->lookup(id); 50 QModelIndex index = this->model->lookup(id);
51 if (index != QModelIndex{}) 51 if (index != QModelIndex{})
52 { 52 {
53 selection.select(index, index); 53 selection.select(index, index);
59 [&](const QItemSelection& selected, const QItemSelection& deselected) 59 [&](const QItemSelection& selected, const QItemSelection& deselected)
60 { 60 {
61 auto resolveIndex = [this](const QModelIndex& index){ return this->model->resolve(index); }; 61 auto resolveIndex = [this](const QModelIndex& index){ return this->model->resolve(index); };
62 auto resolve = [resolveIndex](const QItemSelection& selection) 62 auto resolve = [resolveIndex](const QItemSelection& selection)
63 { 63 {
64 return fn::map<QSet<ldraw::Id>>(selection.indexes(), resolveIndex); 64 return fn::map<QSet<ldraw::id_t>>(selection.indexes(), resolveIndex);
65 }; 65 };
66 this->renderer->handleSelectionChange(resolve(selected), resolve(deselected)); 66 this->renderer->handleSelectionChange(resolve(selected), resolve(deselected));
67 }); 67 });
68 } 68 }
69 69

mercurial