src/document.cpp

changeset 185
a38a0eb007b0
parent 178
a23024fc98e0
child 187
30204975694a
equal deleted inserted replaced
184:35bbfad4d0f4 185:a38a0eb007b0
22 #include "ui_document.h" 22 #include "ui_document.h"
23 #include "model.h" 23 #include "model.h"
24 #include "modeleditor.h" 24 #include "modeleditor.h"
25 #include "tools/basetool.h" 25 #include "tools/basetool.h"
26 #include "tools/drawtool.h" 26 #include "tools/drawtool.h"
27 #include "tools/pathtool.h"
27 #include "tools/selecttool.h" 28 #include "tools/selecttool.h"
28 #include "tools/transformtool.h" 29 #include "tools/transformtool.h"
29 30
30 Document::Document( 31 Document::Document(
31 Model* model, 32 Model* model,
81 connect(this->model, &Model::dataChanged, this->renderer, qOverload<>(&Canvas::update)); 82 connect(this->model, &Model::dataChanged, this->renderer, qOverload<>(&Canvas::update));
82 connect(this->renderer, &Canvas::mouseClick, this, [this](Canvas* canvas, QMouseEvent* event) 83 connect(this->renderer, &Canvas::mouseClick, this, [this](Canvas* canvas, QMouseEvent* event)
83 { 84 {
84 if (this->selectedTool != nullptr) 85 if (this->selectedTool != nullptr)
85 { 86 {
86 this->selectedTool->mouseClick(this, canvas, event); 87 this->selectedTool->mouseClick(canvas, event);
87 } 88 }
88 }); 89 });
89 connect(this->renderer, &Canvas::mouseMove, this, [this](Canvas* canvas, QMouseEvent* event) 90 connect(this->renderer, &Canvas::mouseMove, this, [this](Canvas* canvas, QMouseEvent* event)
90 { 91 {
91 if (this->selectedTool != nullptr) 92 if (this->selectedTool != nullptr)
158 { 159 {
159 this->tools.clear(); 160 this->tools.clear();
160 this->tools.reserve(3); 161 this->tools.reserve(3);
161 this->tools.push_back(new SelectTool{this}); 162 this->tools.push_back(new SelectTool{this});
162 this->tools.push_back(new DrawTool{this}); 163 this->tools.push_back(new DrawTool{this});
164 this->tools.push_back(new PathTool{this});
163 this->tools.push_back(new TransformTool{this}); 165 this->tools.push_back(new TransformTool{this});
164 for (BaseTool* const toolInstance : this->tools) 166 for (BaseTool* const toolInstance : this->tools)
165 { 167 {
166 QAction* action = new QAction{toolInstance->name(), this}; 168 QAction* action = new QAction{toolInstance->name(), this};
167 action->setCheckable(true); 169 action->setCheckable(true);

mercurial