fix up things and remove unnecessary code

Wed, 25 May 2022 18:33:38 +0300

author
Teemu Piippo <teemu@hecknology.net>
date
Wed, 25 May 2022 18:33:38 +0300
changeset 198
eb9d900dc79a
parent 197
0e729e681a2c
child 199
6988973515d2

fix up things and remove unnecessary code

src/document.cpp file | annotate | diff | comparison | revisions
src/document.h file | annotate | diff | comparison | revisions
src/ui/canvas.cpp file | annotate | diff | comparison | revisions
src/ui/canvas.h file | annotate | diff | comparison | revisions
--- 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<ldraw::id_t>& 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<EditingMode>(index);
+		this->drawState.mode = static_cast<EditingMode>(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;
--- 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<ldraw::id_t> &selected);
-	EditingMode mode;
 	DrawState drawState;
 Q_SIGNALS:
 	void newStatusText(const QString& newStatusText);
--- 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;
--- 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<glm::vec3>& points);
@@ -58,7 +56,6 @@
 	void paintGL() override;
 Q_SIGNALS:
 	void newStatusText(const QString& newStatusText);
-	void selectionChanged(const QSet<ldraw::id_t>& newSelection);
 	void mouseClick(QMouseEvent* event);
 	void mouseMove(QMouseEvent* event);
 private:

mercurial