src/tools/selecttool.cpp

Mon, 26 Jul 2021 11:50:45 +0300

author
Teemu Piippo <teemu@hecknology.net>
date
Mon, 26 Jul 2021 11:50:45 +0300
changeset 113
c0d064521ee0
parent 111
1f42c03fafca
child 121
000781318c36
permissions
-rw-r--r--

refactor

96
165777a20dc7 added tool base code
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
1 #include "selecttool.h"
165777a20dc7 added tool base code
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
2
165777a20dc7 added tool base code
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
3 SelectTool::SelectTool(QObject* parent) :
165777a20dc7 added tool base code
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
4 BaseTool{parent} {}
165777a20dc7 added tool base code
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
5
165777a20dc7 added tool base code
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
6 QString SelectTool::name() const
165777a20dc7 added tool base code
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
7 {
165777a20dc7 added tool base code
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
8 static const QString result = tr("Select");
165777a20dc7 added tool base code
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
9 return result;
165777a20dc7 added tool base code
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
10 }
165777a20dc7 added tool base code
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
11
165777a20dc7 added tool base code
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
12 QString SelectTool::toolTip() const
165777a20dc7 added tool base code
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
13 {
165777a20dc7 added tool base code
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
14 static const QString result = tr("Select elements from the model.");
165777a20dc7 added tool base code
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
15 return result;
165777a20dc7 added tool base code
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
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 }

mercurial