Thu, 15 Jun 2023 16:18:03 +0300
Refactor, make selecting elements from the model select the corresponding line from the editor as well
383
530d23cd4e97
Refactor, make selecting elements from the model select the corresponding line from the editor as well
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
diff
changeset
|
1 | #include "openedmodel.h" |
530d23cd4e97
Refactor, make selecting elements from the model select the corresponding line from the editor as well
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
diff
changeset
|
2 | #include "settings.h" |
530d23cd4e97
Refactor, make selecting elements from the model select the corresponding line from the editor as well
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
diff
changeset
|
3 | #include "ldrawsyntaxhighlighter.h" |
530d23cd4e97
Refactor, make selecting elements from the model select the corresponding line from the editor as well
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
diff
changeset
|
4 | |
530d23cd4e97
Refactor, make selecting elements from the model select the corresponding line from the editor as well
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
diff
changeset
|
5 | EditableModel::EditableModel(QTextDocument* model, DocumentManager* documents, ColorTable* colorTable) |
530d23cd4e97
Refactor, make selecting elements from the model select the corresponding line from the editor as well
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
diff
changeset
|
6 | : QObject{documents}, model{model} |
530d23cd4e97
Refactor, make selecting elements from the model select the corresponding line from the editor as well
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
diff
changeset
|
7 | { |
530d23cd4e97
Refactor, make selecting elements from the model select the corresponding line from the editor as well
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
diff
changeset
|
8 | this->tools = std::make_unique<EditTools>(); |
530d23cd4e97
Refactor, make selecting elements from the model select the corresponding line from the editor as well
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
diff
changeset
|
9 | this->canvas = std::make_unique<PartRenderer>(model, documents, *colorTable); |
530d23cd4e97
Refactor, make selecting elements from the model select the corresponding line from the editor as well
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
diff
changeset
|
10 | this->axesLayer = std::make_unique<AxesLayer>(); |
530d23cd4e97
Refactor, make selecting elements from the model select the corresponding line from the editor as well
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
diff
changeset
|
11 | this->gridLayer = std::make_unique<GridLayer>(); |
530d23cd4e97
Refactor, make selecting elements from the model select the corresponding line from the editor as well
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
diff
changeset
|
12 | this->gridLayer->setGridMatrix(DEFAULT_GRID_MATRIX); |
530d23cd4e97
Refactor, make selecting elements from the model select the corresponding line from the editor as well
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
diff
changeset
|
13 | this->tools->setGridMatrix(DEFAULT_GRID_MATRIX); |
530d23cd4e97
Refactor, make selecting elements from the model select the corresponding line from the editor as well
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
diff
changeset
|
14 | this->canvas->addRenderLayer(this->axesLayer.get()); |
530d23cd4e97
Refactor, make selecting elements from the model select the corresponding line from the editor as well
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
diff
changeset
|
15 | this->canvas->setLayerEnabled(this->axesLayer.get(), setting<Setting::DrawAxes>()); |
530d23cd4e97
Refactor, make selecting elements from the model select the corresponding line from the editor as well
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
diff
changeset
|
16 | this->canvas->addRenderLayer(this->gridLayer.get()); |
530d23cd4e97
Refactor, make selecting elements from the model select the corresponding line from the editor as well
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
diff
changeset
|
17 | this->canvas->addRenderLayer(this->tools.get()); |
530d23cd4e97
Refactor, make selecting elements from the model select the corresponding line from the editor as well
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
diff
changeset
|
18 | new LDrawSyntaxHighlighter{model}; |
530d23cd4e97
Refactor, make selecting elements from the model select the corresponding line from the editor as well
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
diff
changeset
|
19 | this->textcursor = std::make_unique<QTextCursor>(model); |
530d23cd4e97
Refactor, make selecting elements from the model select the corresponding line from the editor as well
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
diff
changeset
|
20 | QObject::connect( |
530d23cd4e97
Refactor, make selecting elements from the model select the corresponding line from the editor as well
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
diff
changeset
|
21 | this->tools.get(), |
530d23cd4e97
Refactor, make selecting elements from the model select the corresponding line from the editor as well
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
diff
changeset
|
22 | &EditTools::modelAction, |
530d23cd4e97
Refactor, make selecting elements from the model select the corresponding line from the editor as well
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
diff
changeset
|
23 | this, |
530d23cd4e97
Refactor, make selecting elements from the model select the corresponding line from the editor as well
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
diff
changeset
|
24 | &EditableModel::modelAction); |
530d23cd4e97
Refactor, make selecting elements from the model select the corresponding line from the editor as well
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
diff
changeset
|
25 | QObject::connect( |
530d23cd4e97
Refactor, make selecting elements from the model select the corresponding line from the editor as well
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
diff
changeset
|
26 | this->tools.get(), |
530d23cd4e97
Refactor, make selecting elements from the model select the corresponding line from the editor as well
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
diff
changeset
|
27 | &EditTools::newStatusText, |
530d23cd4e97
Refactor, make selecting elements from the model select the corresponding line from the editor as well
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
diff
changeset
|
28 | this, |
530d23cd4e97
Refactor, make selecting elements from the model select the corresponding line from the editor as well
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
diff
changeset
|
29 | &EditableModel::newStatusText); |
530d23cd4e97
Refactor, make selecting elements from the model select the corresponding line from the editor as well
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
diff
changeset
|
30 | QObject::connect( |
530d23cd4e97
Refactor, make selecting elements from the model select the corresponding line from the editor as well
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
diff
changeset
|
31 | this->tools.get(), |
530d23cd4e97
Refactor, make selecting elements from the model select the corresponding line from the editor as well
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
diff
changeset
|
32 | &EditTools::select, |
530d23cd4e97
Refactor, make selecting elements from the model select the corresponding line from the editor as well
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
diff
changeset
|
33 | this, |
530d23cd4e97
Refactor, make selecting elements from the model select the corresponding line from the editor as well
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
diff
changeset
|
34 | &EditableModel::select); |
530d23cd4e97
Refactor, make selecting elements from the model select the corresponding line from the editor as well
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
diff
changeset
|
35 | } |