Tue, 27 Jul 2021 12:44:54 +0300
refactor
96 | 1 | #include "selecttool.h" |
2 | ||
3 | SelectTool::SelectTool(QObject* parent) : | |
4 | BaseTool{parent} {} | |
5 | ||
6 | QString SelectTool::name() const | |
7 | { | |
8 | static const QString result = tr("Select"); | |
9 | return result; | |
10 | } | |
11 | ||
12 | QString SelectTool::toolTip() const | |
13 | { | |
14 | static const QString result = tr("Select elements from the model."); | |
15 | return result; | |
16 | } | |
107
02f142b399b1
Move selection logic into select tool
Teemu Piippo <teemu@hecknology.net>
parents:
96
diff
changeset
|
17 | |
111
1f42c03fafca
Draw tool actually adds objects now
Teemu Piippo <teemu@hecknology.net>
parents:
107
diff
changeset
|
18 | bool SelectTool::mouseClick(Document* document, Canvas* canvas) |
107
02f142b399b1
Move selection logic into select tool
Teemu Piippo <teemu@hecknology.net>
parents:
96
diff
changeset
|
19 | { |
111
1f42c03fafca
Draw tool actually adds objects now
Teemu Piippo <teemu@hecknology.net>
parents:
107
diff
changeset
|
20 | static_cast<void>(document); |
1f42c03fafca
Draw tool actually adds objects now
Teemu Piippo <teemu@hecknology.net>
parents:
107
diff
changeset
|
21 | const ldraw::id_t highlighted = canvas->getHighlightedObject(); |
1f42c03fafca
Draw tool actually adds objects now
Teemu Piippo <teemu@hecknology.net>
parents:
107
diff
changeset
|
22 | canvas->clearSelection(); |
107
02f142b399b1
Move selection logic into select tool
Teemu Piippo <teemu@hecknology.net>
parents:
96
diff
changeset
|
23 | if (highlighted != ldraw::NULL_ID) |
02f142b399b1
Move selection logic into select tool
Teemu Piippo <teemu@hecknology.net>
parents:
96
diff
changeset
|
24 | { |
111
1f42c03fafca
Draw tool actually adds objects now
Teemu Piippo <teemu@hecknology.net>
parents:
107
diff
changeset
|
25 | canvas->addToSelection(highlighted); |
107
02f142b399b1
Move selection logic into select tool
Teemu Piippo <teemu@hecknology.net>
parents:
96
diff
changeset
|
26 | } |
02f142b399b1
Move selection logic into select tool
Teemu Piippo <teemu@hecknology.net>
parents:
96
diff
changeset
|
27 | return true; |
02f142b399b1
Move selection logic into select tool
Teemu Piippo <teemu@hecknology.net>
parents:
96
diff
changeset
|
28 | } |