summaryrefslogtreecommitdiff
path: root/tagscene.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'tagscene.cpp')
-rw-r--r--tagscene.cpp49
1 files changed, 49 insertions, 0 deletions
diff --git a/tagscene.cpp b/tagscene.cpp
index c5777e0..a10bd2d 100644
--- a/tagscene.cpp
+++ b/tagscene.cpp
@@ -90,6 +90,29 @@ void TagScene::selectTag(const Tag &tag)
it->setSelected(true);
}
+void TagScene::setTool(ToolType tool)
+{
+ abortTool();
+ m_tool = tool;
+
+ if (tool == ToolType::TAG_TOOL) {
+ m_tagToolState = TAG_TOOL_ANCHOR;
+
+ } else if (tool == ToolType::SELECTION_TOOL) {
+
+ }
+}
+
+void TagScene::abortTool()
+{
+ if (m_tool == ToolType::TAG_TOOL) {
+ removeItem(m_previewTag);
+
+ } else if (m_tool == ToolType::SELECTION_TOOL) {
+
+ }
+}
+
void TagScene::mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event)
{
QGraphicsItem *it = itemAt(event->scenePos(), QTransform());
@@ -111,3 +134,29 @@ void TagScene::mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event)
tagDoubleClicked(tagitem->tag());
}
+
+void TagScene::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
+{
+ if (m_tool == ToolType::TAG_TOOL) {
+ if (m_tagToolState == TAG_TOOL_LABEL) {
+ Tag t = m_previewTag->tag();
+ t.labelPos = event->scenePos();
+ m_previewTag->tagUpdated(t);
+ }
+ }
+}
+
+void TagScene::mousePressEvent(QGraphicsSceneMouseEvent *event)
+{
+ if (m_tool == ToolType::TAG_TOOL) {
+ if (m_tagToolState == TAG_TOOL_ANCHOR) {
+ m_previewTag->tagUpdated(Tag(m_proj->getNextAutoTagName(), event->scenePos()));
+ m_tagToolState = TAG_TOOL_LABEL;
+
+ } else { /* TAG_TOOL_LABEL */
+ removeItem(m_previewTag);
+ m_proj->createTag(m_previewTag->tag());
+ m_tagToolState = TAG_TOOL_ANCHOR;
+ }
+ }
+}