15 break; |
15 break; |
16 } |
16 } |
17 return result; |
17 return result; |
18 } |
18 } |
19 |
19 |
20 /** |
20 std::vector<ModelAction> ldraw::makeUnofficial(const Model* model) |
21 * @brief Modifies the !LDRAW_ORG line so that it becomes unofficial |
|
22 */ |
|
23 /* |
|
24 void ldraw::makeUnofficial(ModelEditor& editor) |
|
25 { |
21 { |
26 if (editor.model().size() >= 4) |
22 std::vector<ModelAction> actions; |
27 { |
23 if (model->size() >= 4) { |
28 const ldraw::Object* ldrawOrgLine = editor.model()[3]; |
24 if (const Comment* comment = std::get_if<Comment>(&(*model)[3])) { |
29 if (isA<ldraw::MetaCommand>(ldrawOrgLine)) |
25 const QString& body = comment->text; |
30 { |
|
31 const QString& body = ldrawOrgLine->getProperty<ldraw::Property::Text>(); |
|
32 if (body.startsWith("!LDRAW_ORG ") and not body.startsWith("!LDRAW_ORG Unofficial_")) |
26 if (body.startsWith("!LDRAW_ORG ") and not body.startsWith("!LDRAW_ORG Unofficial_")) |
33 { |
27 { |
34 // Add Unofficial_ to part type |
28 // Add Unofficial_ to part type |
35 QStringList tokens = body.split(" "); |
29 QStringList tokens = body.split(" "); |
36 tokens[1] = "Unofficial_" + tokens[1]; |
30 tokens[1] = "Unofficial_" + tokens[1]; |
38 if (tokens.size() >= 4 && tokens[2] == "UPDATE") |
32 if (tokens.size() >= 4 && tokens[2] == "UPDATE") |
39 { |
33 { |
40 tokens.removeAt(3); |
34 tokens.removeAt(3); |
41 tokens.removeAt(2); |
35 tokens.removeAt(2); |
42 } |
36 } |
43 editor.setObjectProperty<ldraw::Property::Text>(ldrawOrgLine->id, tokens.join(" ")); |
37 actions.push_back(ModifyModel{ |
|
38 .position = 3, |
|
39 .newElement = Comment{.text = tokens.join(" ")} |
|
40 }); |
44 } |
41 } |
45 } |
42 } |
46 } |
43 } |
|
44 return actions; |
47 } |
45 } |
48 */ |
|
49 |
46 |
50 ModelElement inverted(const ModelElement& element) |
47 ModelElement inverted(const ModelElement& element) |
51 { |
48 { |
52 return std::visit(overloaded{ |
49 return std::visit(overloaded{ |
53 [](Colored<SubfileReference> ref) -> ModelElement { |
50 [](Colored<SubfileReference> ref) -> ModelElement { |