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