29 QWidget{parent}, |
29 QWidget{parent}, |
30 model{model}, |
30 model{model}, |
31 documents{documents}, |
31 documents{documents}, |
32 colorTable{colorTable}, |
32 colorTable{colorTable}, |
33 renderer{new Canvas{model, documents, colorTable, this}}, |
33 renderer{new Canvas{model, documents, colorTable, this}}, |
34 ui{*new Ui::Document} |
34 ui{*new Ui::Document}, |
|
35 objectEditor{model, ldraw::NULL_ID, this} |
35 { |
36 { |
36 this->ui.setupUi(this); |
37 this->ui.setupUi(this); |
37 this->ui.listView->setModel(model); |
38 this->ui.listView->setModel(model); |
38 QVBoxLayout* layout = new QVBoxLayout; |
39 this->ui.viewportFrame->setLayout(new QVBoxLayout{this->ui.listView}); |
39 layout->addWidget(this->renderer); |
40 this->ui.viewportFrame->layout()->addWidget(this->renderer); |
40 this->ui.viewportFrame->setLayout(layout); |
41 this->ui.objectEditorFrame->setLayout(new QVBoxLayout{this->ui.objectEditorFrame}); |
|
42 this->ui.objectEditorFrame->layout()->addWidget(&this->objectEditor); |
41 this->setMouseTracking(true); |
43 this->setMouseTracking(true); |
42 connect(this->ui.splitter, &QSplitter::splitterMoved, this, &Document::splitterChanged); |
44 connect(this->ui.splitter, &QSplitter::splitterMoved, this, &Document::splitterChanged); |
43 connect(this->renderer, &Canvas::newStatusText, this, &Document::newStatusText); |
45 connect(this->renderer, &Canvas::newStatusText, this, &Document::newStatusText); |
44 connect(this->renderer, &Canvas::selectionChanged, [&](const QSet<ldraw::id_t>& newSelection) |
46 connect(this->renderer, &Canvas::selectionChanged, [&](const QSet<ldraw::id_t>& newSelection) |
45 { |
47 { |
51 if (index != QModelIndex{}) |
53 if (index != QModelIndex{}) |
52 { |
54 { |
53 selection.select(index, index); |
55 selection.select(index, index); |
54 } |
56 } |
55 } |
57 } |
|
58 QSignalBlocker blocker{this}; |
56 selectionModel->select(selection, QItemSelectionModel::ClearAndSelect); |
59 selectionModel->select(selection, QItemSelectionModel::ClearAndSelect); |
|
60 this->selectionChanged(newSelection); |
57 }); |
61 }); |
58 connect(this->ui.listView->selectionModel(), &QItemSelectionModel::selectionChanged, |
62 connect(this->ui.listView->selectionModel(), &QItemSelectionModel::selectionChanged, |
59 [&](const QItemSelection& selected, const QItemSelection& deselected) |
63 [&](const QItemSelection& selected, const QItemSelection& deselected) |
60 { |
64 { |
61 auto resolveIndex = [this](const QModelIndex& index){ return this->model->resolve(index); }; |
65 auto resolveIndex = [this](const QModelIndex& index){ return this->model->resolve(index); }; |
62 auto resolve = [resolveIndex](const QItemSelection& selection) |
66 auto resolve = [resolveIndex](const QItemSelection& selection) |
63 { |
67 { |
64 return fn::map<QSet<ldraw::id_t>>(selection.indexes(), resolveIndex); |
68 return fn::map<QSet<ldraw::id_t>>(selection.indexes(), resolveIndex); |
65 }; |
69 }; |
66 this->renderer->handleSelectionChange(resolve(selected), resolve(deselected)); |
70 this->renderer->handleSelectionChange(resolve(selected), resolve(deselected)); |
|
71 this->selectionChanged(resolve(this->ui.listView->selectionModel()->selection())); |
67 }); |
72 }); |
68 } |
73 } |
69 |
74 |
70 Document::~Document() |
75 Document::~Document() |
71 { |
76 { |