diff --git a/qad/blockview/blockbusitem.cpp b/qad/blockview/blockbusitem.cpp index 9c75ec1..1b62ae4 100644 --- a/qad/blockview/blockbusitem.cpp +++ b/qad/blockview/blockbusitem.cpp @@ -495,8 +495,10 @@ void BlockBusItem::hoverMoveEvent(QGraphicsSceneHoverEvent * e) { if (temp_) return; QPointF sp = e->scenePos(); int pp = selPoint; + int ps = selSegment; + bool empt = !(selPoint >= 0 || selSegment >= 0); testPoint(sp, &selPoint, &selSegment); - if (selPoint >= 0 && pp < 0) { + if ((selPoint >= 0 && pp != selPoint) || (selSegment >= 0 && ps != selSegment)) { if (((BlockView *)scene()->views().back())->isBlockAnimationEnabled()) { setPointSize(0); anim_point_size.start(); @@ -504,6 +506,12 @@ void BlockBusItem::hoverMoveEvent(QGraphicsSceneHoverEvent * e) { } if (selPoint >= 0 || selSegment >= 0) { + if (empt) { + QList pins = connectedPins(); + foreach (BlockItemPin * p, pins) { + p->animAccept(); + } + } setToolTip(tt); update(); return; @@ -674,20 +682,20 @@ void BlockBusItem::mouseReleaseEvent(QGraphicsSceneMouseEvent * e) { if (moved) { simplify(false); if (lm_point) { - QMetaObject::invokeMethod(scene()->views().back(), "endBusPointMove", Qt::QueuedConnection); emitAction(BlockItemBase::BusPointMove); } else { reconnect(); emitAction( BlockItemBase::BusSegmentMove); } } + QMetaObject::invokeMethod(scene()->views().back(), "endBusPointMove"); moved = new_segment = false; QGraphicsObject::mouseReleaseEvent(e); } void BlockBusItem::paint(QPainter * p, const QStyleOptionGraphicsItem * o, QWidget * w) { - ph.setWidthF(pen_width + 1.); + ph.setWidthF(pen_width + point_size / 2.); pu.setWidthF(pen_width); pa.setWidthF(pen_width); pr.setWidthF(pen_width); diff --git a/qad/blockview/blockitempin.cpp b/qad/blockview/blockitempin.cpp index 7b1ef90..c340ca0 100644 --- a/qad/blockview/blockitempin.cpp +++ b/qad/blockview/blockitempin.cpp @@ -21,7 +21,7 @@ BlockItemPin::BlockItemPin(Qt::Alignment a, int bus_type_, const QString & text_ anim_accept.setTargetObject(this); anim_accept.setPropertyName("pinSize"); anim_accept.setEasingCurve(QEasingCurve::InOutQuad); - anim_accept.setDuration(200); + anim_accept.setDuration(150); connect(&anim_accept, SIGNAL(finished()), this, SLOT(animationAccept())); setState(Disconnected); setAlignment(a); @@ -33,14 +33,20 @@ BlockItemPin::BlockItemPin(Qt::Alignment a, int bus_type_, const QString & text_ } +void BlockItemPin::animAccept() { + if (!((BlockView *)scene()->views().back())->isBlockAnimationEnabled() && anim_accept.state() != QAbstractAnimation::Running) return; + anim_accept.setStartValue(pinSize()); + anim_accept.setEndValue(10.); + anim_accept.start(); +} + + void BlockItemPin::setState(State s) { State os = state_; state_ = s; setBrush(br[int(state_)]); - if (s == Accept && os != Accept && anim_accept.state() != QAbstractAnimation::Running && ((BlockView *)scene()->views().back())->isBlockAnimationEnabled()) { - anim_accept.setStartValue(pinSize()); - anim_accept.setEndValue(10.); - anim_accept.start(); + if (s == Accept && os != Accept) { + animAccept(); } update(); } @@ -93,10 +99,10 @@ void BlockItemPin::_init(bool affect_parent) { text_item.setPos(0, -tbr.height() / 2.); text_item.setTransformOriginPoint(0, tbr.height() / 2.); switch (align) { - case Qt::AlignBottom: ell_item.setStartAngle(16*0); text_item.setRotation(-90.); text_item.moveBy(0, -r * 1.5); break; - case Qt::AlignRight: ell_item.setStartAngle(16*90); text_item.setRotation(0.); text_item.moveBy(-tbr.width() - r * 1.5, 0); break; - case Qt::AlignTop: ell_item.setStartAngle(16*180); text_item.setRotation(-90.); text_item.moveBy(0, tbr.width() + r * 1.5); break; - case Qt::AlignLeft: ell_item.setStartAngle(16*270); text_item.setRotation(0.); text_item.moveBy(r * 1.5, 0); break; + case Qt::AlignBottom: ell_item.setStartAngle(16*0); text_item.setRotation(-90.); text_item.moveBy(0, -r * 1.5); break; + case Qt::AlignRight: ell_item.setStartAngle(16*90); text_item.setRotation(0.); text_item.moveBy(-tbr.width() - r * 1.5, 0); break; + case Qt::AlignTop: ell_item.setStartAngle(16*180); text_item.setRotation(-90.); text_item.moveBy(0, tbr.width() + r * 1.5); break; + case Qt::AlignLeft: ell_item.setStartAngle(16*270); text_item.setRotation(0.); text_item.moveBy(r * 1.5, 0); break; default: break; } if (affect_parent && parent_) diff --git a/qad/blockview/blockitempin.h b/qad/blockview/blockitempin.h index cbea79f..8cae5a8 100644 --- a/qad/blockview/blockitempin.h +++ b/qad/blockview/blockitempin.h @@ -73,6 +73,9 @@ public: enum {Type = UserType + 3}; +public slots: + void animAccept(); + protected: void paint(QPainter * painter, const QStyleOptionGraphicsItem * option, QWidget * widget = 0) {} QRectF boundingRect() const {return ell_item.boundingRect().translated(ell_item.pos()) | text_item.boundingRect().translated(text_item.pos());} diff --git a/qad/blockview/blockview.cpp b/qad/blockview/blockview.cpp index 4499e0f..4d44eb8 100644 --- a/qad/blockview/blockview.cpp +++ b/qad/blockview/blockview.cpp @@ -1168,8 +1168,8 @@ void BlockView::clearBusStates() { if (i->data(1005) == "connection") { BlockBusItem * b = qgraphicsitem_cast(i); b->clearBusState(); - if (i != bus_from && i != match_bus) - b->selPoint = b->selSegment = -1; +// if (i != bus_from && i != match_bus) + //b->selPoint = b->selSegment = -1; } } @@ -1285,8 +1285,12 @@ void BlockView::markPins(int bus_type) { if (p->busType() == bus_type) p->setState(BlockItemPin::Accept); } else { - if (p->busType() == bus_type && p->state() == BlockItemPin::Disconnected) - p->setState(BlockItemPin::Accept); + if (p->busType() == bus_type) { + if (p->state() == BlockItemPin::Disconnected) + p->setState(BlockItemPin::Accept); +// else +// p->animAccept(); + } } } }