src/ui/canvas.cpp

changeset 52
eee644f88e93
parent 51
1a9eac27698d
child 55
cb81ecb5fb23
equal deleted inserted replaced
51:1a9eac27698d 52:eee644f88e93
11 this->setMouseTracking(true); 11 this->setMouseTracking(true);
12 } 12 }
13 13
14 void Canvas::handleSelectionChange(const QSet<ldraw::Id>& selectedIds, const QSet<ldraw::Id>& deselectedIds) 14 void Canvas::handleSelectionChange(const QSet<ldraw::Id>& selectedIds, const QSet<ldraw::Id>& deselectedIds)
15 { 15 {
16 Q_ASSERT(not selectedIds.contains(ldraw::NULL_ID));
16 this->selection.subtract(deselectedIds); 17 this->selection.subtract(deselectedIds);
17 this->selection.unite(selectedIds); 18 this->selection.unite(selectedIds);
18 this->compiler->setSelectedObjects(this->selection); 19 this->compiler->setSelectedObjects(this->selection);
19 this->update(); 20 this->update();
20 } 21 }
38 39
39 void Canvas::mouseReleaseEvent(QMouseEvent* event) 40 void Canvas::mouseReleaseEvent(QMouseEvent* event)
40 { 41 {
41 if (this->totalMouseMove < (2.0 / sqrt(2)) * 5.0) 42 if (this->totalMouseMove < (2.0 / sqrt(2)) * 5.0)
42 { 43 {
43 this->selection = {this->highlighted}; 44 if (this->highlighted == ldraw::NULL_ID)
45 {
46 this->selection = {};
47 }
48 else
49 {
50 this->selection = {this->highlighted};
51 }
44 this->compiler->setSelectedObjects(this->selection); 52 this->compiler->setSelectedObjects(this->selection);
45 emit selectionChanged(this->selection); 53 emit selectionChanged(this->selection);
46 this->update(); 54 this->update();
47 } 55 }
48 PartRenderer::mouseReleaseEvent(event); 56 PartRenderer::mouseReleaseEvent(event);

mercurial