src/openedmodel.cpp

Thu, 15 Jun 2023 16:18:03 +0300

author
Teemu Piippo <teemu.s.piippo@gmail.com>
date
Thu, 15 Jun 2023 16:18:03 +0300
changeset 383
530d23cd4e97
permissions
-rw-r--r--

Refactor, make selecting elements from the model select the corresponding line from the editor as well

#include "openedmodel.h"
#include "settings.h"
#include "ldrawsyntaxhighlighter.h"

EditableModel::EditableModel(QTextDocument* model, DocumentManager* documents, ColorTable* colorTable)
	: QObject{documents}, model{model}
{
	this->tools = std::make_unique<EditTools>();
	this->canvas = std::make_unique<PartRenderer>(model, documents, *colorTable);
	this->axesLayer = std::make_unique<AxesLayer>();
	this->gridLayer = std::make_unique<GridLayer>();
	this->gridLayer->setGridMatrix(DEFAULT_GRID_MATRIX);
	this->tools->setGridMatrix(DEFAULT_GRID_MATRIX);
	this->canvas->addRenderLayer(this->axesLayer.get());
	this->canvas->setLayerEnabled(this->axesLayer.get(), setting<Setting::DrawAxes>());
	this->canvas->addRenderLayer(this->gridLayer.get());
	this->canvas->addRenderLayer(this->tools.get());
	new LDrawSyntaxHighlighter{model};
	this->textcursor = std::make_unique<QTextCursor>(model);
	QObject::connect(
		this->tools.get(),
		&EditTools::modelAction,
		this,
		&EditableModel::modelAction);
	QObject::connect(
		this->tools.get(),
		&EditTools::newStatusText,
		this,
		&EditableModel::newStatusText);
	QObject::connect(
		this->tools.get(),
		&EditTools::select,
		this,
		&EditableModel::select);
}

mercurial