Wed, 20 Jul 2022 21:48:46 +0300
Delete unused code
Remove Model legacy type alias, QTextDocument is used now instead
#include <QTextBlock> #include "src/ldrawalgorithm.h" std::pair<Triangle, Triangle> splitTriangles( const Quadrilateral& q, ldraw::Diagonal diagonal) { std::pair<Triangle, Triangle> result; switch (diagonal) { case ldraw::Diagonal::Diagonal_13: result = {Triangle{q.p1, q.p2, q.p3}, {q.p1, q.p3, q.p4}}; break; case ldraw::Diagonal::Diagonal_24: result = {Triangle{q.p1, q.p2, q.p3}, {q.p2, q.p3, q.p4}}; break; } return result; } std::vector<ModelAction> ldraw::makeUnofficial(const QTextDocument* model) { std::vector<ModelAction> actions; constexpr int ldrawOrgLinePosition = 3; const QTextBlock block = model->findBlockByLineNumber(ldrawOrgLinePosition); if (block.isValid()) { const QString body = block.text().simplified(); if (body.startsWith("0 !LDRAW_ORG ") and not body.startsWith("0 !LDRAW_ORG Unofficial_")) { // Add Unofficial_ to part type QStringList tokens = body.split(" "); tokens[2] = "Unofficial_" + tokens[2]; // Remove the UPDATE tag if it's there if (tokens.size() >= 5 && tokens[3] == "UPDATE") { tokens.removeAt(4); tokens.removeAt(3); } actions.push_back(ModifyModel{ .position = ldrawOrgLinePosition, .newElement = Comment{.text = tokens.mid(1).join(" ")} }); } } return actions; }