fixed changing a document not updating its references in other files

Wed, 04 Apr 2018 11:19:49 +0300

author
Teemu Piippo <teemu@hecknology.net>
date
Wed, 04 Apr 2018 11:19:49 +0300
changeset 1377
0b9a946002be
parent 1376
83dd6cbd7f1a
child 1378
86e5a2259f58

fixed changing a document not updating its references in other files

src/lddocument.cpp file | annotate | diff | comparison | revisions
src/mainwindow.cpp file | annotate | diff | comparison | revisions
src/model.cpp file | annotate | diff | comparison | revisions
src/model.h file | annotate | diff | comparison | revisions
--- a/src/lddocument.cpp	Tue Apr 03 18:55:57 2018 +0300
+++ b/src/lddocument.cpp	Wed Apr 04 11:19:49 2018 +0300
@@ -54,6 +54,14 @@
 		SLOT(handleImminentObjectRemoval(QModelIndex)),
 		Qt::DirectConnection
 	);
+	connect(
+		this,
+		&Model::modelChanged,
+		[&]()
+		{
+			this->m_needsRecache = true;
+		}
+	);
 }
 
 LDDocument::~LDDocument()
@@ -444,7 +452,7 @@
 	{
 		m_vertices.clear();
 		Model model {m_documents};
-		inlineContents(model, true, true);
+		this->inlineContents(model, true, true);
 
 		for (LDObject* obj : model.objects())
 		{
--- a/src/mainwindow.cpp	Tue Apr 03 18:55:57 2018 +0300
+++ b/src/mainwindow.cpp	Wed Apr 04 11:19:49 2018 +0300
@@ -925,6 +925,7 @@
 		print ("Changed document to %1", document->getDisplayName());
 		ui.objectList->setModel(document);
 		ui.header->setDocument(document);
+		renderer->fullUpdate();
 		QItemSelectionModel* selection = m_selections.value(document);
 
 		if (selection == nullptr)
--- a/src/model.cpp	Tue Apr 03 18:55:57 2018 +0300
+++ b/src/model.cpp	Wed Apr 04 11:19:49 2018 +0300
@@ -35,7 +35,17 @@
 
 void Model::installObject(int row, LDObject* object)
 {
-	connect(object, SIGNAL(modified(LDObjectState, LDObjectState)), this, SLOT(recountTriangles()));
+	connect(
+		object,
+		&LDObject::modified,
+		[&]()
+		{
+			this->recountTriangles();
+			emit objectModified(static_cast<LDObject*>(sender()));
+			emit modelChanged();
+		}
+	);
+
 	beginInsertRows({}, row, row);
 	_objects.insert(row, object);
 
@@ -47,6 +57,7 @@
 
 	_triangleCount += object->triangleCount(documentManager());
 	emit objectAdded(index(row));
+	emit modelChanged();
 	endInsertRows();
 }
 
@@ -157,6 +168,7 @@
 	_objects.removeAt(position);
 	_needsTriangleRecount = true;
 	endRemoveRows();
+	emit modelChanged();
 	delete object;
 }
 
--- a/src/model.h	Tue Apr 03 18:55:57 2018 +0300
+++ b/src/model.h	Wed Apr 04 11:19:49 2018 +0300
@@ -126,6 +126,7 @@
 	void aboutToRemoveObject(const QModelIndex& index);
 	void objectModified(LDObject* object);
 	void windingChanged(Winding newWinding);
+	void modelChanged();
 
 protected:
 	template<typename T, typename... Args> T* constructObject(Args&& ...args);

mercurial