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

This commit is contained in:
2018-06-14 08:21:37 +00:00
parent 372abdf222
commit bc94f7cee2
2 changed files with 6 additions and 9 deletions

View File

@@ -534,13 +534,10 @@ bool BlockView::eventFilter(QObject * o, QEvent * e) {
//qDebug() << "!!!"; //qDebug() << "!!!";
if (match_bus == 0) { if (match_bus == 0) {
BlockBusItem * nb = new BlockBusItem(tmp_bus); BlockBusItem * nb = new BlockBusItem(tmp_bus);
loadBus(nb); addItem(nb, tmp_buses.isEmpty());
addItem(nb);
//qDebug() << "also" << tmp_buses;
foreach (BlockBusItem * b, tmp_buses) { foreach (BlockBusItem * b, tmp_buses) {
nb = new BlockBusItem(*b); nb = new BlockBusItem(*b);
loadBus(nb); addItem(nb, b == tmp_buses.back());
addItem(nb);
} }
} else { } else {
if (connectTmpToBus(match_bus)) { if (connectTmpToBus(match_bus)) {
@@ -875,13 +872,13 @@ void BlockView::clearSelection() {
} }
void BlockView::addItem(QGraphicsItem * item) { void BlockView::addItem(QGraphicsItem * item, bool emit_action) {
scene_->addItem(item); scene_->addItem(item);
applyGridStep(); applyGridStep();
if (item->data(1005) == "connection") { if (item->data(1005) == "connection") {
loadBus(qgraphicsitem_cast<BlockBusItem*>(item)); loadBus(qgraphicsitem_cast<BlockBusItem*>(item));
connect((BlockBusItem*)item, SIGNAL(destroyed(QObject*)), this, SLOT(removedBus(QObject*)), Qt::UniqueConnection); connect((BlockBusItem*)item, SIGNAL(destroyed(QObject*)), this, SLOT(removedBus(QObject*)), Qt::UniqueConnection);
emitActionEvent(BlockItemBase::BusAdd, QList<QGraphicsItem*>() << item); if (emit_action) emitActionEvent(BlockItemBase::BusAdd, QList<QGraphicsItem*>() << item);
emit connectionsChanged(); emit connectionsChanged();
return; return;
} }
@@ -889,7 +886,7 @@ void BlockView::addItem(QGraphicsItem * item) {
connect((BlockItem*)item, SIGNAL(destroyed(QObject*)), this, SLOT(removedBlock(QObject*)), Qt::UniqueConnection); connect((BlockItem*)item, SIGNAL(destroyed(QObject*)), this, SLOT(removedBlock(QObject*)), Qt::UniqueConnection);
connect((BlockItem*)item, SIGNAL(blockHoverEnter(BlockItem*)), this, SIGNAL(blockHoverEnter(BlockItem*)), Qt::UniqueConnection); connect((BlockItem*)item, SIGNAL(blockHoverEnter(BlockItem*)), this, SIGNAL(blockHoverEnter(BlockItem*)), Qt::UniqueConnection);
connect((BlockItem*)item, SIGNAL(blockHoverLeave(BlockItem*)), this, SIGNAL(blockHoverLeave(BlockItem*)), Qt::UniqueConnection); connect((BlockItem*)item, SIGNAL(blockHoverLeave(BlockItem*)), this, SIGNAL(blockHoverLeave(BlockItem*)), Qt::UniqueConnection);
emitActionEvent(BlockItemBase::BlockAdd, QList<QGraphicsItem*>() << item); if (emit_action) emitActionEvent(BlockItemBase::BlockAdd, QList<QGraphicsItem*>() << item);
return; return;
} }
item->setData(1009, "decor"); item->setData(1009, "decor");

View File

@@ -233,7 +233,7 @@ public slots:
void removeSelected(); void removeSelected();
void removeAll(); void removeAll();
void clearSelection(); void clearSelection();
void addItem(QGraphicsItem * item); void addItem(QGraphicsItem * item, bool emit_action = true);
signals: signals:
void blockDoubleClicked(BlockItem * ); void blockDoubleClicked(BlockItem * );