src/documentmanager.cpp

changeset 193
b4beff48bb7a
parent 176
cd9d6bf6f649
child 194
be056e87c8ca
--- a/src/documentmanager.cpp	Wed May 25 17:25:24 2022 +0300
+++ b/src/documentmanager.cpp	Wed May 25 17:42:02 2022 +0300
@@ -370,10 +370,21 @@
 	Model* model = this->getModelById(modelId);
 	if (model != nullptr)
 	{
-		this->polygonCaches.emplace(
-			std::piecewise_construct,
-			std::forward_as_tuple(modelId),
-			std::forward_as_tuple(model));
+		this->polygonCaches[modelId] = {};
+		connect(model, &Model::dataChanged, this, &DocumentManager::modelModified);
+		connect(model, &Model::rowsInserted, this, &DocumentManager::modelModified);
+		connect(model, &Model::rowsRemoved, this, &DocumentManager::modelModified);
+	}
+}
+
+void DocumentManager::modelModified()
+{
+	Model* model = qobject_cast<Model*>(this->sender());
+	for (auto it = this->openModels.begin(); it != this->openModels.end(); ++it) {
+		if (model == it->second.model.get()) {
+			this->polygonCaches[it->second.id].needRecache = true;
+			break;
+		}
 	}
 }
 

mercurial