18 |
18 |
19 #include <QMouseEvent> |
19 #include <QMouseEvent> |
20 #include "document.h" |
20 #include "document.h" |
21 #include "ui_document.h" |
21 #include "ui_document.h" |
22 #include "model.h" |
22 #include "model.h" |
|
23 #include "modeleditcontext.h" |
23 |
24 |
24 Document::Document( |
25 Document::Document( |
25 Model* model, |
26 Model* model, |
26 DocumentManager* documents, |
27 DocumentManager* documents, |
27 const ldraw::ColorTable& colorTable, |
28 const ldraw::ColorTable& colorTable, |
69 }; |
70 }; |
70 this->renderer->handleSelectionChange(resolve(selected), resolve(deselected)); |
71 this->renderer->handleSelectionChange(resolve(selected), resolve(deselected)); |
71 this->selectionChanged(resolve(this->ui.listView->selectionModel()->selection())); |
72 this->selectionChanged(resolve(this->ui.listView->selectionModel()->selection())); |
72 }); |
73 }); |
73 connect(this->model, &Model::dataChanged, this->renderer, qOverload<>(&Canvas::update)); |
74 connect(this->model, &Model::dataChanged, this->renderer, qOverload<>(&Canvas::update)); |
74 connect(this->renderer, &Canvas::mouseClick, this, &Document::mouseClick); |
75 connect(this->renderer, &Canvas::mouseClick, this, [this](Canvas* canvas) |
75 connect(this->renderer, &Canvas::mouseMove, this, &Document::mouseMove); |
76 { |
|
77 Q_EMIT this->mouseClick(this, canvas); |
|
78 }); |
|
79 connect(this->renderer, &Canvas::mouseMove, this, [this](Canvas* canvas) |
|
80 { |
|
81 Q_EMIT this->mouseMove(this, canvas); |
|
82 }); |
76 } |
83 } |
77 |
84 |
78 Document::~Document() |
85 Document::~Document() |
79 { |
86 { |
80 delete &this->ui; |
87 delete &this->ui; |
98 void Document::setCanvasOverpaintCallback(Canvas::OverpaintCallback fn) |
105 void Document::setCanvasOverpaintCallback(Canvas::OverpaintCallback fn) |
99 { |
106 { |
100 this->renderer->setOverpaintCallback(fn); |
107 this->renderer->setOverpaintCallback(fn); |
101 } |
108 } |
102 |
109 |
|
110 Model::EditContext Document::editModel() |
|
111 { |
|
112 return this->model->edit(); |
|
113 } |
|
114 |
103 void Document::selectionChanged(const QSet<ldraw::id_t>& newSelection) |
115 void Document::selectionChanged(const QSet<ldraw::id_t>& newSelection) |
104 { |
116 { |
105 if (newSelection.size() == 1) |
117 if (newSelection.size() == 1) |
106 { |
118 { |
107 this->objectEditor.setObjectId(*newSelection.begin()); |
119 this->objectEditor.setObjectId(*newSelection.begin()); |