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) |
|
45 { |
|
46 QItemSelectionModel* selectionModel = this->ui.listView->selectionModel(); |
|
47 QItemSelection selection; |
|
48 for (ldraw::Id id : newSelection) |
|
49 { |
|
50 QModelIndex index = this->model->lookup(id); |
|
51 if (index != QModelIndex{}) |
|
52 { |
|
53 selection.select(index, index); |
|
54 } |
|
55 } |
|
56 selectionModel->select(selection, QItemSelectionModel::ClearAndSelect); |
|
57 }); |
|
58 connect(this->ui.listView->selectionModel(), &QItemSelectionModel::selectionChanged, |
|
59 [&](const QItemSelection& selected, const QItemSelection& deselected) |
|
60 { |
|
61 QSet<ldraw::Id> selectedIds; |
|
62 QSet<ldraw::Id> deselectedIds; |
|
63 for (const QModelIndex& index : selected.indexes()) |
|
64 { |
|
65 selectedIds.insert(this->model->resolve(index)); |
|
66 } |
|
67 for (const QModelIndex& index : deselected.indexes()) |
|
68 { |
|
69 deselectedIds.insert(this->model->resolve(index)); |
|
70 } |
|
71 this->renderer->handleSelectionChange(selectedIds, deselectedIds); |
|
72 }); |
44 } |
73 } |
45 |
74 |
46 Document::~Document() |
75 Document::~Document() |
47 { |
76 { |
48 delete &this->ui; |
77 delete &this->ui; |