BlockView right-click, ctrl+left-click fixes
This commit is contained in:
@@ -520,10 +520,16 @@ void BlockBusItem::hoverMoveEvent(QGraphicsSceneHoverEvent * e) {
|
||||
int ps = selSegment;
|
||||
bool empt = !(selPoint >= 0 || selSegment >= 0);
|
||||
testPoint(sp, &selPoint, &selSegment);
|
||||
BlockView * bv = 0;
|
||||
if (!scene()->views().isEmpty()) {
|
||||
bv = qobject_cast<BlockView*>(scene()->views().back());
|
||||
}
|
||||
if ((selPoint >= 0 && pp != selPoint) || (selSegment >= 0 && ps != selSegment)) {
|
||||
if (((BlockView *)scene()->views().back())->isBlockAnimationEnabled()) {
|
||||
setPointSize(0);
|
||||
anim_point_size.start();
|
||||
if (bv) {
|
||||
if (bv->isBlockAnimationEnabled()) {
|
||||
setPointSize(0);
|
||||
anim_point_size.start();
|
||||
}
|
||||
} else setPointSize(anim_point_size.endValue().toDouble());
|
||||
}
|
||||
|
||||
@@ -536,8 +542,10 @@ void BlockBusItem::hoverMoveEvent(QGraphicsSceneHoverEvent * e) {
|
||||
}
|
||||
setToolTip(tt);
|
||||
update();
|
||||
if (bv) bv->cur_bus = this;
|
||||
return;
|
||||
}
|
||||
if (bv) bv->cur_bus = 0;
|
||||
setToolTip(QString());
|
||||
QList<QGraphicsItem * > il = scene()->items(sp, Qt::ContainsItemBoundingRect, Qt::DescendingOrder), bil;
|
||||
bil << this;
|
||||
@@ -572,6 +580,13 @@ void BlockBusItem::hoverLeaveEvent(QGraphicsSceneHoverEvent * e) {
|
||||
void BlockBusItem::mousePressEvent(QGraphicsSceneMouseEvent * e) {
|
||||
if (temp_) return;
|
||||
lp = quantize(e->scenePos(), grid_step);
|
||||
if (e->button() != Qt::RightButton)
|
||||
bpol = pol;
|
||||
BlockView * bv = 0;
|
||||
if (!scene()->views().isEmpty()) {
|
||||
bv = qobject_cast<BlockView*>(scene()->views().back());
|
||||
}
|
||||
if (bv) bv->cur_bus = this;
|
||||
if (new_segment) {
|
||||
QMetaObject::invokeMethod(scene()->views().back(), "newBranchCancel");
|
||||
}
|
||||
@@ -582,7 +597,6 @@ void BlockBusItem::mousePressEvent(QGraphicsSceneMouseEvent * e) {
|
||||
}
|
||||
int btncnt = 0;
|
||||
if ((e->button() == Qt::LeftButton) && e->modifiers().testFlag(Qt::ShiftModifier)) {
|
||||
bpol = pol;
|
||||
if (endpoints().contains(selPoint))
|
||||
QMetaObject::invokeMethod(scene()->views().back(), "startBusPointMove", Q_ARG(int, busType()));
|
||||
}
|
||||
@@ -594,7 +608,7 @@ void BlockBusItem::mousePressEvent(QGraphicsSceneMouseEvent * e) {
|
||||
//qDebug() << "bus revert";
|
||||
mm_cancel = true;
|
||||
moved = false;
|
||||
QPointF lp = qp - press_pos;
|
||||
/*QPointF lp = qp - press_pos;
|
||||
//qDebug() << lp;
|
||||
if (selPoint >= 0 && selPoint <= pol.size() - 1) {
|
||||
pol[selPoint] += lp;
|
||||
@@ -603,7 +617,8 @@ void BlockBusItem::mousePressEvent(QGraphicsSceneMouseEvent * e) {
|
||||
pol[segments[selSegment].first] += lp;
|
||||
pol[segments[selSegment].second] += lp;
|
||||
}
|
||||
moved = true;
|
||||
moved = true;*/
|
||||
pol = bpol;
|
||||
prepareGeometryChange();
|
||||
return;
|
||||
}
|
||||
@@ -629,6 +644,7 @@ void BlockBusItem::mousePressEvent(QGraphicsSceneMouseEvent * e) {
|
||||
deleteLater();
|
||||
}
|
||||
if (e->modifiers().testFlag(Qt::ControlModifier)) {
|
||||
//qDebug() << "remove" << selPoint << selSegment;
|
||||
if (e->buttons().testFlag(Qt::RightButton)) {
|
||||
if (selPoint >= 0 && selPoint <= pol.size() - 1) {
|
||||
removePoint(selPoint);
|
||||
@@ -677,7 +693,6 @@ void BlockBusItem::mouseMoveEvent(QGraphicsSceneMouseEvent * e) {
|
||||
new_end = qp;
|
||||
prepareGeometryChange();
|
||||
} else {
|
||||
if (bv) bv->cur_bus = this;
|
||||
if (e->buttons().testFlag(Qt::LeftButton)) {
|
||||
lm_point = selPoint >= 0;
|
||||
if (selPoint >= 0 && selPoint <= pol.size() - 1)
|
||||
@@ -687,6 +702,7 @@ void BlockBusItem::mouseMoveEvent(QGraphicsSceneMouseEvent * e) {
|
||||
pol[segments[selSegment].second] += lp;
|
||||
}
|
||||
moved = true;
|
||||
//if (bv) bv->bus_moved = true;
|
||||
prepareGeometryChange();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
#include "blockview.h"
|
||||
#include "qad_types.h"
|
||||
#include <qmath.h>
|
||||
#include <QScrollBar>
|
||||
#include <QGraphicsSceneMouseEvent>
|
||||
@@ -213,9 +214,9 @@ bool BlockView::eventFilter(QObject * o, QEvent * e) {
|
||||
}
|
||||
//if (mm_ci->data(bvidItemSelection).toBool()) break;
|
||||
}
|
||||
if (me->buttons().testFlag(Qt::LeftButton)) btncnt++;
|
||||
if (me->buttons().testFlag(Qt::LeftButton )) btncnt++;
|
||||
if (me->buttons().testFlag(Qt::RightButton)) btncnt++;
|
||||
if (me->buttons().testFlag(Qt::MidButton)) btncnt++;
|
||||
if (me->buttons().testFlag(Qt::MidButton )) btncnt++;
|
||||
mm_cancel = btncnt >= 2;
|
||||
match_bus = bus_from = 0;
|
||||
hpin = 0;
|
||||
@@ -229,12 +230,11 @@ bool BlockView::eventFilter(QObject * o, QEvent * e) {
|
||||
block_emit_selection = false;
|
||||
emit selectionChanged();
|
||||
}
|
||||
//qDebug() << cur_bus;
|
||||
if (cur_bus) {
|
||||
return false;
|
||||
}
|
||||
if (mm_cancel) {
|
||||
if (cur_bus) {
|
||||
cur_bus->pol = cur_bus->bpol;
|
||||
cur_bus->prepareGeometryChange();
|
||||
cur_bus = 0;
|
||||
}
|
||||
if (mm_copy) {
|
||||
deleteCopyTemp();
|
||||
mm_copy = moved = false;
|
||||
@@ -357,6 +357,9 @@ bool BlockView::eventFilter(QObject * o, QEvent * e) {
|
||||
/*if (ghost_) {
|
||||
ghost_->setPos(quantize(me->scenePos(), grid_step));
|
||||
}*/
|
||||
if (cur_bus) {
|
||||
return false;
|
||||
}
|
||||
if (mm_ci)
|
||||
if (mm_ci->data(bvidInvalidItem).toBool()) {
|
||||
mm_ci = 0;
|
||||
@@ -518,6 +521,7 @@ bool BlockView::eventFilter(QObject * o, QEvent * e) {
|
||||
if (me->buttons().testFlag(Qt::LeftButton)) btncnt++;
|
||||
if (me->buttons().testFlag(Qt::RightButton)) btncnt++;
|
||||
if (me->buttons().testFlag(Qt::MidButton)) btncnt++;
|
||||
cur_bus = 0;
|
||||
mm_cancel = btncnt > 0;
|
||||
if (mm_cancel || (me->button() == Qt::MidButton) || (me->button() == Qt::RightButton)) {
|
||||
mm_ci = 0;
|
||||
|
||||
Reference in New Issue
Block a user