1 #include "selecttool.h" |
|
2 |
|
3 SelectTool::SelectTool(Document* document) : |
|
4 BaseTool{document}, |
|
5 objectEditor{new ObjectEditor{document, ldraw::NULL_ID}} |
|
6 { |
|
7 } |
|
8 |
|
9 QString SelectTool::name() const |
|
10 { |
|
11 static const QString result = tr("Select"); |
|
12 return result; |
|
13 } |
|
14 |
|
15 QString SelectTool::toolTip() const |
|
16 { |
|
17 static const QString result = tr("Select elements from the model."); |
|
18 return result; |
|
19 } |
|
20 |
|
21 bool SelectTool::mouseClick(Canvas* canvas, QMouseEvent* event) |
|
22 { |
|
23 if (event->button() == Qt::LeftButton) |
|
24 { |
|
25 const ldraw::id_t highlighted = canvas->getHighlightedObject(); |
|
26 canvas->clearSelection(); |
|
27 if (highlighted != ldraw::NULL_ID) |
|
28 { |
|
29 canvas->addToSelection(highlighted); |
|
30 } |
|
31 return true; |
|
32 } |
|
33 else |
|
34 { |
|
35 return false; |
|
36 } |
|
37 } |
|
38 |
|
39 QWidget* SelectTool::toolWidget() |
|
40 { |
|
41 return this->objectEditor; |
|
42 } |
|
43 |
|
44 void SelectTool::selectionChanged(const QSet<ldraw::id_t>& newSelection) |
|
45 { |
|
46 if (newSelection.size() == 1) |
|
47 { |
|
48 this->objectEditor->setObjectId(*newSelection.begin()); |
|
49 } |
|
50 else |
|
51 { |
|
52 this->objectEditor->setObjectId(ldraw::NULL_ID); |
|
53 } |
|
54 } |
|
55 |
|
56 QString SelectTool::iconName() const |
|
57 { |
|
58 return ":/icons/navigate-outline.png"; |
|
59 } |
|