src/tools/selecttool.cpp

Sun, 25 Jul 2021 16:29:08 +0300

author
Teemu Piippo <teemu@hecknology.net>
date
Sun, 25 Jul 2021 16:29:08 +0300
changeset 110
d922431eacf7
parent 107
02f142b399b1
child 111
1f42c03fafca
permissions
-rw-r--r--

stuff

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
02f142b399b1 Move selection logic into select tool
Teemu Piippo <teemu@hecknology.net>
parents: 96
diff changeset
18 bool SelectTool::mouseClick(const Canvas::MouseClickInfo& info)
02f142b399b1 Move selection logic into select tool
Teemu Piippo <teemu@hecknology.net>
parents: 96
diff changeset
19 {
02f142b399b1 Move selection logic into select tool
Teemu Piippo <teemu@hecknology.net>
parents: 96
diff changeset
20 const ldraw::id_t highlighted = info.invoker->getHighlightedObject();
02f142b399b1 Move selection logic into select tool
Teemu Piippo <teemu@hecknology.net>
parents: 96
diff changeset
21 info.invoker->clearSelection();
02f142b399b1 Move selection logic into select tool
Teemu Piippo <teemu@hecknology.net>
parents: 96
diff changeset
22 if (highlighted != ldraw::NULL_ID)
02f142b399b1 Move selection logic into select tool
Teemu Piippo <teemu@hecknology.net>
parents: 96
diff changeset
23 {
02f142b399b1 Move selection logic into select tool
Teemu Piippo <teemu@hecknology.net>
parents: 96
diff changeset
24 info.invoker->addToSelection(highlighted);
02f142b399b1 Move selection logic into select tool
Teemu Piippo <teemu@hecknology.net>
parents: 96
diff changeset
25 }
02f142b399b1 Move selection logic into select tool
Teemu Piippo <teemu@hecknology.net>
parents: 96
diff changeset
26 return true;
02f142b399b1 Move selection logic into select tool
Teemu Piippo <teemu@hecknology.net>
parents: 96
diff changeset
27 }

mercurial