# HG changeset patch # User Teemu Piippo # Date 1653492818 -10800 # Node ID eb9d900dc79add2ad8a1d5cedc57c95b9f1902b0 # Parent 0e729e681a2c41a34c143d7fca882f32f60aba6d fix up things and remove unnecessary code 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; diff -r 0e729e681a2c -r eb9d900dc79a src/document.h --- a/src/document.h Wed May 25 18:29:49 2022 +0300 +++ b/src/document.h Wed May 25 18:33:38 2022 +0300 @@ -47,7 +47,6 @@ Q_SLOT void canvasMouseClick(QMouseEvent* event); Q_SLOT void canvasMouseMove(QMouseEvent* event); void select(const QSet &selected); - EditingMode mode; DrawState drawState; Q_SIGNALS: void newStatusText(const QString& newStatusText); diff -r 0e729e681a2c -r eb9d900dc79a src/ui/canvas.cpp --- a/src/ui/canvas.cpp Wed May 25 18:29:49 2022 +0300 +++ b/src/ui/canvas.cpp Wed May 25 18:33:38 2022 +0300 @@ -426,29 +426,6 @@ } } -/** - * @brief Clears the selection. - */ -void Canvas::clearSelection() -{ - this->selection.clear(); - gl::setModelShaderSelectedObjects(&this->shaders, this->selection); - Q_EMIT selectionChanged(this->selection); - this->update(); -} - -/** - * @brief Adds an object to selection. - * @param id ID of object to add - */ -void Canvas::addToSelection(ldraw::id_t id) -{ - this->selection.insert(id); - gl::setModelShaderSelectedObjects(&this->shaders, this->selection); - Q_EMIT selectionChanged(this->selection); - this->update(); -} - void Canvas::setOverpaintCallback(Canvas::OverpaintCallback fn) { this->overpaintCallback = fn; diff -r 0e729e681a2c -r eb9d900dc79a src/ui/canvas.h --- a/src/ui/canvas.h Wed May 25 18:29:49 2022 +0300 +++ b/src/ui/canvas.h Wed May 25 18:33:38 2022 +0300 @@ -32,8 +32,6 @@ DocumentManager* documents, const ldraw::ColorTable& colorTable, QWidget* parent = nullptr); - void clearSelection(); - void addToSelection(ldraw::id_t id); void setOverpaintCallback(OverpaintCallback fn); void drawWorldPoint(QPainter* painter, const glm::vec3& worldPoint) const; void drawWorldPolyline(QPainter* painter, const std::vector& points); @@ -58,7 +56,6 @@ void paintGL() override; Q_SIGNALS: void newStatusText(const QString& newStatusText); - void selectionChanged(const QSet& newSelection); void mouseClick(QMouseEvent* event); void mouseMove(QMouseEvent* event); private: