nodeview: implemented moving with either the hand tool or middle mouse button
Includes splitting off this functionality from TimelineViewBase so it can be re-used in any QGraphicsView.
This commit is contained in:
@@ -26,10 +26,12 @@
|
||||
#include "nodeviewundo.h"
|
||||
#include "node/factory.h"
|
||||
|
||||
#define super HandMovableView
|
||||
|
||||
OLIVE_NAMESPACE_ENTER
|
||||
|
||||
NodeView::NodeView(QWidget *parent) :
|
||||
QGraphicsView(parent),
|
||||
HandMovableView(parent),
|
||||
graph_(nullptr),
|
||||
attached_item_(nullptr),
|
||||
drop_edge_(nullptr)
|
||||
@@ -196,7 +198,7 @@ void NodeView::ItemsChanged()
|
||||
|
||||
void NodeView::keyPressEvent(QKeyEvent *event)
|
||||
{
|
||||
QGraphicsView::keyPressEvent(event);
|
||||
super::keyPressEvent(event);
|
||||
|
||||
if (event->key() == Qt::Key_Escape && attached_item_) {
|
||||
DetachItemFromCursor();
|
||||
@@ -209,6 +211,8 @@ void NodeView::keyPressEvent(QKeyEvent *event)
|
||||
|
||||
void NodeView::mousePressEvent(QMouseEvent *event)
|
||||
{
|
||||
if (HandPress(event)) return;
|
||||
|
||||
if (attached_item_) {
|
||||
Node* dropping_node = attached_item_->GetNode();
|
||||
|
||||
@@ -233,12 +237,14 @@ void NodeView::mousePressEvent(QMouseEvent *event)
|
||||
drop_edge_ = nullptr;
|
||||
}
|
||||
|
||||
QGraphicsView::mousePressEvent(event);
|
||||
super::mousePressEvent(event);
|
||||
}
|
||||
|
||||
void NodeView::mouseMoveEvent(QMouseEvent *event)
|
||||
{
|
||||
QGraphicsView::mouseMoveEvent(event);
|
||||
if (HandMove(event)) return;
|
||||
|
||||
super::mouseMoveEvent(event);
|
||||
|
||||
if (attached_item_) {
|
||||
attached_item_->setPos(mapToScene(event->pos()));
|
||||
@@ -296,6 +302,13 @@ void NodeView::mouseMoveEvent(QMouseEvent *event)
|
||||
}
|
||||
}
|
||||
|
||||
void NodeView::mouseReleaseEvent(QMouseEvent *event)
|
||||
{
|
||||
if (HandRelease(event)) return;
|
||||
|
||||
super::mouseReleaseEvent(event);
|
||||
}
|
||||
|
||||
void NodeView::wheelEvent(QWheelEvent *event)
|
||||
{
|
||||
if (event->modifiers() & Qt::ControlModifier) {
|
||||
|
||||
Reference in New Issue
Block a user