src/ldrawalgorithm.cpp

changeset 262
dc33f8a707c4
parent 248
29986dfd1750
child 264
76a025db4948
--- a/src/ldrawalgorithm.cpp	Sun Jun 26 20:27:04 2022 +0300
+++ b/src/ldrawalgorithm.cpp	Sun Jun 26 20:54:09 2022 +0300
@@ -17,18 +17,12 @@
 	return result;
 }
 
-/**
- * @brief Modifies the !LDRAW_ORG line so that it becomes unofficial
- */
-/*
-void ldraw::makeUnofficial(ModelEditor& editor)
+std::vector<ModelAction> ldraw::makeUnofficial(const Model* model)
 {
-	if (editor.model().size() >= 4)
-	{
-		const ldraw::Object* ldrawOrgLine = editor.model()[3];
-		if (isA<ldraw::MetaCommand>(ldrawOrgLine))
-		{
-			const QString& body = ldrawOrgLine->getProperty<ldraw::Property::Text>();
+	std::vector<ModelAction> actions;
+	if (model->size() >= 4) {
+		if (const Comment* comment = std::get_if<Comment>(&(*model)[3])) {
+			const QString& body = comment->text;
 			if (body.startsWith("!LDRAW_ORG ") and not body.startsWith("!LDRAW_ORG Unofficial_"))
 			{
 				// Add Unofficial_ to part type
@@ -40,12 +34,15 @@
 					tokens.removeAt(3);
 					tokens.removeAt(2);
 				}
-				editor.setObjectProperty<ldraw::Property::Text>(ldrawOrgLine->id, tokens.join(" "));
+				actions.push_back(ModifyModel{
+					.position = 3,
+					.newElement = Comment{.text = tokens.join(" ")}
+				});
 			}
 		}
 	}
+	return actions;
 }
-*/
 
 ModelElement inverted(const ModelElement& element)
 {

mercurial