--- a/src/main.cpp Wed Jul 20 21:35:55 2022 +0300 +++ b/src/main.cpp Wed Jul 20 21:48:46 2022 +0300 @@ -53,7 +53,7 @@ std::unique_ptr<AxesLayer> axesLayer; std::unique_ptr<GridLayer> gridLayer; std::unique_ptr<QTextCursor> textcursor; - Model* model; + QTextDocument* model; }; class Signal final : public QObject @@ -169,16 +169,6 @@ } } -static Model* currentModelBody(Ui_MainWindow* ui, DocumentManager* documents) -{ - if (auto* const activeSubWindow = currentModelSubWindow(ui)) { - return documents->getModelById(activeSubWindow->modelId); - } - else { - return nullptr; - } -} - static std::optional<ModelId> findCurrentModelId(Ui_MainWindow* ui) { ModelSubWindow* activeSubWindow = qobject_cast<ModelSubWindow*>(ui->mdiArea->activeSubWindow()); @@ -332,15 +322,6 @@ } } -static QFont monospace() -{ - QFont font{"Monospace"}; - font.setStyleHint(QFont::TypeWriter); - font.setPointSize(10); - font.setFixedPitch(true); - return font; -} - constexpr bool sortModelIndexesByRow(const QModelIndex& a, const QModelIndex& b) { return a.row() < b.row(); @@ -409,17 +390,6 @@ return subWindow; } -static QSet<ElementId> resolveIdsFromSelection(const ModelData* data) -{ -// const auto selection = data->itemSelectionModel->selection(); - QSet<ElementId> selectedIndexes; -/* for (const QModelIndex& qindex : selection.indexes()) { - const std::size_t row = unsigned_cast(qindex.row()); - selectedIndexes.insert(data->model->idAt(row)); - } -*/ return selectedIndexes; -} - int main(int argc, char *argv[]) { doQtRegistrations(); @@ -469,7 +439,7 @@ } }; const auto executeAction = [&]( - Model* model, const ModelAction& action + QTextDocument* model, const ModelAction& action ) { std::visit(overloaded{ [model](const AppendToModel& action){ @@ -519,7 +489,7 @@ updateRecentlyOpenedDocumentsMenu(); }; const auto openModelForEditing = [&](const ModelId modelId){ - Model* model = documents.getModelById(modelId); + QTextDocument* model = documents.getModelById(modelId); if (model != nullptr) { ModelData* data = new ModelData(&documents); data->tools = std::make_unique<EditTools>(); @@ -756,7 +726,7 @@ &QAction::triggered, [&]{ if (ModelData* data = currentModelData(&ui, &documents)) { - Model* const model = data->model; + QTextDocument* const model = data->model; for (const ModelAction& action : ldraw::makeUnofficial(model)) { executeAction(model, action); }