src/tools/selecttool.cpp

Sun, 29 Aug 2021 20:05:24 +0300

author
Teemu Piippo <teemu@hecknology.net>
date
Sun, 29 Aug 2021 20:05:24 +0300
changeset 124
f9f308c8e0c5
parent 121
000781318c36
child 126
a7c720aff97c
permissions
-rw-r--r--

esc with draw mode now clears the polygon

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
121
000781318c36 added right click support for draw tool
Teemu Piippo <teemu@hecknology.net>
parents: 111
diff changeset
18 bool SelectTool::mouseClick(Document* document, Canvas* canvas, QMouseEvent* event)
107
02f142b399b1 Move selection logic into select tool
Teemu Piippo <teemu@hecknology.net>
parents: 96
diff changeset
19 {
121
000781318c36 added right click support for draw tool
Teemu Piippo <teemu@hecknology.net>
parents: 111
diff changeset
20 if (event->button() == Qt::LeftButton)
107
02f142b399b1 Move selection logic into select tool
Teemu Piippo <teemu@hecknology.net>
parents: 96
diff changeset
21 {
121
000781318c36 added right click support for draw tool
Teemu Piippo <teemu@hecknology.net>
parents: 111
diff changeset
22 static_cast<void>(document);
000781318c36 added right click support for draw tool
Teemu Piippo <teemu@hecknology.net>
parents: 111
diff changeset
23 const ldraw::id_t highlighted = canvas->getHighlightedObject();
000781318c36 added right click support for draw tool
Teemu Piippo <teemu@hecknology.net>
parents: 111
diff changeset
24 canvas->clearSelection();
000781318c36 added right click support for draw tool
Teemu Piippo <teemu@hecknology.net>
parents: 111
diff changeset
25 if (highlighted != ldraw::NULL_ID)
000781318c36 added right click support for draw tool
Teemu Piippo <teemu@hecknology.net>
parents: 111
diff changeset
26 {
000781318c36 added right click support for draw tool
Teemu Piippo <teemu@hecknology.net>
parents: 111
diff changeset
27 canvas->addToSelection(highlighted);
000781318c36 added right click support for draw tool
Teemu Piippo <teemu@hecknology.net>
parents: 111
diff changeset
28 }
000781318c36 added right click support for draw tool
Teemu Piippo <teemu@hecknology.net>
parents: 111
diff changeset
29 return true;
107
02f142b399b1 Move selection logic into select tool
Teemu Piippo <teemu@hecknology.net>
parents: 96
diff changeset
30 }
121
000781318c36 added right click support for draw tool
Teemu Piippo <teemu@hecknology.net>
parents: 111
diff changeset
31 else
000781318c36 added right click support for draw tool
Teemu Piippo <teemu@hecknology.net>
parents: 111
diff changeset
32 {
000781318c36 added right click support for draw tool
Teemu Piippo <teemu@hecknology.net>
parents: 111
diff changeset
33 return false;
000781318c36 added right click support for draw tool
Teemu Piippo <teemu@hecknology.net>
parents: 111
diff changeset
34 }
107
02f142b399b1 Move selection logic into select tool
Teemu Piippo <teemu@hecknology.net>
parents: 96
diff changeset
35 }

mercurial