|
@@ -194,11 +194,7 @@ void CMindView::mousePressEvent(QMouseEvent *event)
|
|
|
m_isMovingItem =
|
|
|
item != nullptr && (item->flags() & QGraphicsObject::ItemIsMovable) == QGraphicsObject::ItemIsMovable;
|
|
|
|
|
|
- if (m_isMovingItem) {
|
|
|
- setCursor(Qt::ClosedHandCursor);
|
|
|
- } else {
|
|
|
- setCursor(Qt::ArrowCursor);
|
|
|
- }
|
|
|
+ updateCursor(event->pos());
|
|
|
|
|
|
QGraphicsView::mousePressEvent(event);
|
|
|
}
|
|
@@ -206,34 +202,13 @@ void CMindView::mousePressEvent(QMouseEvent *event)
|
|
|
void CMindView::mouseMoveEvent(QMouseEvent *event)
|
|
|
{
|
|
|
QGraphicsView::mouseMoveEvent(event);
|
|
|
- QGraphicsItem *item = itemAt(event->pos());
|
|
|
-
|
|
|
- if (m_isMovingItem) {
|
|
|
- setCursor(Qt::ClosedHandCursor);
|
|
|
- } else {
|
|
|
- bool movable =
|
|
|
- item != nullptr && (item->flags() & QGraphicsObject::ItemIsMovable) == QGraphicsObject::ItemIsMovable;
|
|
|
-
|
|
|
- if (movable) {
|
|
|
- setCursor(Qt::OpenHandCursor);
|
|
|
- } else {
|
|
|
- setCursor(Qt::ArrowCursor);
|
|
|
- }
|
|
|
- }
|
|
|
+ updateCursor(event->pos());
|
|
|
}
|
|
|
|
|
|
void CMindView::mouseReleaseEvent(QMouseEvent *event)
|
|
|
{
|
|
|
- m_isMovingItem = false;
|
|
|
- QGraphicsItem *item = itemAt(event->pos());
|
|
|
- bool movable =
|
|
|
- item != nullptr && (item->flags() & QGraphicsObject::ItemIsMovable) == QGraphicsObject::ItemIsMovable;
|
|
|
-
|
|
|
- if (movable) {
|
|
|
- setCursor(Qt::OpenHandCursor);
|
|
|
- } else {
|
|
|
- setCursor(Qt::ArrowCursor);
|
|
|
- }
|
|
|
+ m_isMovingItem = false;
|
|
|
+ updateCursor(event->pos());
|
|
|
QGraphicsView::mouseReleaseEvent(event);
|
|
|
}
|
|
|
|
|
@@ -271,6 +246,24 @@ void CMindView::testData()
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+void CMindView::updateCursor(QPoint pos)
|
|
|
+{
|
|
|
+ QGraphicsItem *item = itemAt(pos);
|
|
|
+
|
|
|
+ if (m_isMovingItem) {
|
|
|
+ setCursor(Qt::ClosedHandCursor);
|
|
|
+ } else {
|
|
|
+ bool movable =
|
|
|
+ item != nullptr && (item->flags() & QGraphicsObject::ItemIsMovable) == QGraphicsObject::ItemIsMovable;
|
|
|
+
|
|
|
+ if (movable) {
|
|
|
+ setCursor(Qt::OpenHandCursor);
|
|
|
+ } else {
|
|
|
+ setCursor(Qt::ArrowCursor);
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
void CMindView::slotEditNode(CNodeData n)
|
|
|
{
|
|
|
emit sigEditNode(n);
|