| |
1 #include <QTextBlock> |
| 1 #include "src/ldrawalgorithm.h" |
2 #include "src/ldrawalgorithm.h" |
| 2 |
3 |
| 3 std::pair<Triangle, Triangle> splitTriangles( |
4 std::pair<Triangle, Triangle> splitTriangles( |
| 4 const Quadrilateral& q, |
5 const Quadrilateral& q, |
| 5 ldraw::Diagonal diagonal) |
6 ldraw::Diagonal diagonal) |
| 15 break; |
16 break; |
| 16 } |
17 } |
| 17 return result; |
18 return result; |
| 18 } |
19 } |
| 19 |
20 |
| 20 std::vector<ModelAction> ldraw::makeUnofficial(const Model* model) |
21 std::vector<ModelAction> ldraw::makeUnofficial(const QTextDocument* model) |
| 21 { |
22 { |
| 22 std::vector<ModelAction> actions; |
23 std::vector<ModelAction> actions; |
| 23 #if 0 |
24 constexpr int ldrawOrgLinePosition = 3; |
| 24 if (model->size() >= 4) { |
25 const QTextBlock block = model->findBlockByLineNumber(ldrawOrgLinePosition); |
| 25 if (const Comment* comment = std::get_if<Comment>(&(*model)[3])) { |
26 if (block.isValid()) { |
| 26 const QString& body = comment->text; |
27 const QString body = block.text().simplified(); |
| 27 if (body.startsWith("!LDRAW_ORG ") and not body.startsWith("!LDRAW_ORG Unofficial_")) |
28 if (body.startsWith("0 !LDRAW_ORG ") and not body.startsWith("0 !LDRAW_ORG Unofficial_")) { |
| |
29 // Add Unofficial_ to part type |
| |
30 QStringList tokens = body.split(" "); |
| |
31 tokens[2] = "Unofficial_" + tokens[2]; |
| |
32 // Remove the UPDATE tag if it's there |
| |
33 if (tokens.size() >= 5 && tokens[3] == "UPDATE") |
| 28 { |
34 { |
| 29 // Add Unofficial_ to part type |
35 tokens.removeAt(4); |
| 30 QStringList tokens = body.split(" "); |
36 tokens.removeAt(3); |
| 31 tokens[1] = "Unofficial_" + tokens[1]; |
|
| 32 // Remove the UPDATE tag if it's there |
|
| 33 if (tokens.size() >= 4 && tokens[2] == "UPDATE") |
|
| 34 { |
|
| 35 tokens.removeAt(3); |
|
| 36 tokens.removeAt(2); |
|
| 37 } |
|
| 38 actions.push_back(ModifyModel{ |
|
| 39 .position = 3, |
|
| 40 .newElement = Comment{.text = tokens.join(" ")} |
|
| 41 }); |
|
| 42 } |
37 } |
| |
38 actions.push_back(ModifyModel{ |
| |
39 .position = ldrawOrgLinePosition, |
| |
40 .newElement = Comment{.text = tokens.mid(1).join(" ")} |
| |
41 }); |
| 43 } |
42 } |
| 44 } |
43 } |
| 45 #endif |
|
| 46 return actions; |
44 return actions; |
| 47 } |
45 } |