git-svn-id: svn://db.shs.com.ru/libs@589 a8b55f48-bf90-11e4-a774-851b48703e85

This commit is contained in:
2019-09-12 11:56:33 +00:00
parent 7d05789819
commit fd7465c449

View File

@@ -158,6 +158,7 @@ bool BlockView::event(QEvent * e) {
bool BlockView::eventFilter(QObject * o, QEvent * e) { bool BlockView::eventFilter(QObject * o, QEvent * e) {
if (o == &widget_thumb) { if (o == &widget_thumb) {
QMouseEvent * me = (QMouseEvent*)e; QMouseEvent * me = (QMouseEvent*)e;
if(!me) return true;
switch (e->type()) { switch (e->type()) {
case QEvent::Paint: case QEvent::Paint:
drawThumb(); drawThumb();
@@ -236,9 +237,12 @@ bool BlockView::eventFilter(QObject * o, QEvent * e) {
} }
break;*/ break;*/
case QEvent::GraphicsSceneMousePress: case QEvent::GraphicsSceneMousePress:
if (mm_ci != 0) if (mm_ci != 0) {
if (mm_ci->data(1008).toBool()) if (mm_ci->data(1008).toBool()) {
mm_ci = 0;
break; break;
}
}
//qDebug() << "press"; //qDebug() << "press";
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::RightButton)) btncnt++;
@@ -282,48 +286,53 @@ bool BlockView::eventFilter(QObject * o, QEvent * e) {
return true; return true;
} }
mil = scene_->items(scene_point); mil = scene_->items(scene_point);
mm_ci = (mil.isEmpty() ? 0 : mil.front()); //qDebug() << mil;
if (mil.isEmpty()) return true; while (!mil.isEmpty()) {
if (mm_ci != 0) { mm_ci = mil.front();
if (mm_ci->data(1008).toBool()) if (mm_ci->data(1008).toBool()) {
break; mil.pop_front();
while (mm_ci->data(1005).toString() == "connection") { } else break;
if (qgraphicsitem_cast<BlockBusItem*>(mm_ci)) }
if (qgraphicsitem_cast<BlockBusItem*>(mm_ci)->isBusSelected()) if (mil.isEmpty()) {
break; mm_ci = 0;
if (mil.size() > 1) { return true;
mm_ci = mil[1]; }
mil.pop_front(); while (mm_ci->data(1005).toString() == "connection") {
} else { if (qgraphicsitem_cast<BlockBusItem*>(mm_ci))
mm_ci = 0; if (qgraphicsitem_cast<BlockBusItem*>(mm_ci)->isBusSelected())
break; break;
} if (mil.size() > 1) {
mm_ci = mil[1];
mil.pop_front();
} else {
mm_ci = 0;
break;
} }
if (mm_ci->data(1003).toBool()) { }
if (mil.size() > 1) { if (mm_ci->data(1003).toBool()) {
mm_ci = mil[1]; if (mil.size() > 1) {
mil.pop_front(); mm_ci = mil[1];
if (mm_ci->data(1003).toBool()) mil.pop_front();
if (mil.size() > 1) if (mm_ci->data(1003).toBool())
mm_ci = mil[1]; if (mil.size() > 1)
} else mm_ci = mil[1];
mm_ci = 0; } else
} mm_ci = 0;
if (mm_ci->data(1002).toBool()) { }
QGraphicsItem * ti = mm_ci; if (mm_ci->data(1002).toBool()) {
while (mm_ci->parentItem() != 0) QGraphicsItem * ti = mm_ci;
mm_ci = mm_ci->parentItem(); while (mm_ci->parentItem() != 0)
if (!ti->data(1010).toString().isEmpty()) { // text item, check for rect mm_ci = mm_ci->parentItem();
BlockItem * bi = qgraphicsitem_cast<BlockItem*>(mm_ci); if (!ti->data(1010).toString().isEmpty()) { // text item, check for rect
if (bi) { BlockItem * bi = qgraphicsitem_cast<BlockItem*>(mm_ci);
if (!bi->sceneRect().contains(scene_point)) { if (bi) {
//qDebug() << "return"; if (!bi->sceneRect().contains(scene_point)) {
mm_ci = 0; //qDebug() << "return";
} mm_ci = 0;
} }
} }
return true;
} }
return true;
} }
if (mm_ci) { if (mm_ci) {
if (mm_ci->data(1004) == "pin" && m_connect) { if (mm_ci->data(1004) == "pin" && m_connect) {
@@ -364,8 +373,10 @@ bool BlockView::eventFilter(QObject * o, QEvent * e) {
ghost_->setPos(quantize(me->scenePos(), grid_step)); ghost_->setPos(quantize(me->scenePos(), grid_step));
}*/ }*/
if (mm_ci) if (mm_ci)
if (mm_ci->data(1008).toBool()) if (mm_ci->data(1008).toBool()) {
mm_ci = 0;
break; break;
}
if (mm_cancel) return true; if (mm_cancel) return true;
if (me->buttons().testFlag(Qt::LeftButton)) { if (me->buttons().testFlag(Qt::LeftButton)) {
if (!mm_drag) { if (!mm_drag) {
@@ -705,6 +716,7 @@ void BlockView::scrolled() {
void BlockView::mouseMoveEvent(QMouseEvent * event) { void BlockView::mouseMoveEvent(QMouseEvent * event) {
if (!event) return;
if (navigation) { if (navigation) {
if (event->buttons().testFlag(Qt::MidButton) || event->buttons().testFlag(Qt::RightButton)) { if (event->buttons().testFlag(Qt::MidButton) || event->buttons().testFlag(Qt::RightButton)) {
QPoint dp = (press_point - event->pos()); QPoint dp = (press_point - event->pos());
@@ -952,7 +964,7 @@ void BlockView::clearSelection() {
sel_items.clear(); sel_items.clear();
QList<QGraphicsItem*> gi = scene_->items(); QList<QGraphicsItem*> gi = scene_->items();
foreach (QGraphicsItem * i, gi) foreach (QGraphicsItem * i, gi)
i->setSelected(false); if (i->flags().testFlag(QGraphicsItem::ItemIsSelectable)) i->setSelected(false);
} }