diff -r 0e729e681a2c -r eb9d900dc79a src/document.cpp --- a/src/document.cpp Wed May 25 18:29:49 2022 +0300 +++ b/src/document.cpp Wed May 25 18:33:38 2022 +0300 @@ -56,21 +56,6 @@ connect(this->canvas, &Canvas::mouseClick, this, &Document::canvasMouseClick); connect(this->canvas, &Canvas::mouseMove, this, &Document::canvasMouseMove); connect(this->canvas, &Canvas::newStatusText, this, &Document::newStatusText); - connect(this->canvas, &Canvas::selectionChanged, [&](const QSet& newSelection) - { - QItemSelectionModel* selectionModel = this->ui.listView->selectionModel(); - QItemSelection selection; - for (const ldraw::id_t id : newSelection) - { - QModelIndex index = this->model->find(id); - if (index != QModelIndex{}) - { - selection.select(index, index); - } - } - QSignalBlocker blocker{this}; - selectionModel->select(selection, QItemSelectionModel::ClearAndSelect); - }); connect(this->ui.listView->selectionModel(), &QItemSelectionModel::selectionChanged, [&](const QItemSelection& selected, const QItemSelection& deselected) { @@ -86,6 +71,7 @@ { this->canvas->rebuildVertices(this); }); + this->canvas->drawState = &this->drawState; this->initializeTools(); } @@ -167,7 +153,7 @@ if (triggeredAction != nullptr) { const int index = triggeredAction->property(INDEX_PROPERTY).toInt(); - this->mode = static_cast(index); + this->drawState.mode = static_cast(index); this->ui.toolWidgetStack->setCurrentIndex(index); for (QAction* action : this->toolActions) { action->setChecked(action == triggeredAction); @@ -202,7 +188,7 @@ void Document::canvasMouseClick(QMouseEvent *event) { - switch(this->mode) + switch(this->drawState.mode) { case SelectMode: if (event->button() == Qt::LeftButton) @@ -245,7 +231,7 @@ void Document::canvasMouseMove(QMouseEvent *event) { - switch(this->mode) + switch(this->drawState.mode) { case SelectMode: break;