BlockView cosmetics, more enums, fixed right-click on bus point/segment move
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
#include "alignedtextitem.h"
|
||||
#include "blockbase.h"
|
||||
#include <QApplication>
|
||||
#include <QPainter>
|
||||
#include <QDebug>
|
||||
@@ -6,7 +7,7 @@
|
||||
|
||||
AlignedTextItem::AlignedTextItem(QGraphicsItem * parent): QGraphicsItem(parent), text_(this) {
|
||||
align_ = Qt::AlignTop | Qt::AlignHCenter;
|
||||
text_.setData(1003, true);
|
||||
text_.setData(bvidVisualizeSelection, true);
|
||||
setFont(font());
|
||||
_move();
|
||||
}
|
||||
@@ -14,7 +15,7 @@ AlignedTextItem::AlignedTextItem(QGraphicsItem * parent): QGraphicsItem(parent),
|
||||
|
||||
AlignedTextItem::AlignedTextItem(const QString & text, QGraphicsItem * parent): QGraphicsItem(parent), text_(this) {
|
||||
align_ = Qt::AlignTop | Qt::AlignHCenter;
|
||||
text_.setData(1003, true);
|
||||
text_.setData(bvidVisualizeSelection, true);
|
||||
setFont(font());
|
||||
setText(text);
|
||||
}
|
||||
|
||||
@@ -32,42 +32,29 @@
|
||||
#include "qad_blockview_export.h"
|
||||
|
||||
|
||||
/// data:
|
||||
/// 1002 - flag for move parent (true)
|
||||
/// 1003 - flag for visualize selection (true)
|
||||
/// 1004 - BlockItemPin ("pin")
|
||||
/// 1005 - BlockBusItem ("connection")
|
||||
/// 1006 - BlockItem ("item")
|
||||
/// 1007 - BlockItem selection (true)
|
||||
/// 1008 - item is NOT decor, ignore for function decors() (true)
|
||||
/// 1009 - item is scene decor ("decor")
|
||||
/// 1010 - BlockItem decor (src text for QGraphicsSimpleTextItem)
|
||||
/// 1011 - item is BlockItem decor (true)
|
||||
/// 1100 - flag for correct move (true)
|
||||
|
||||
static const int _blockitem_current_version_ = 1;
|
||||
|
||||
|
||||
enum BlockviewItemData {
|
||||
bvidSelected = 1000, // bool
|
||||
bvidItemPos = 1001, // QpointF
|
||||
bvidMoveParent = 1002, // bool
|
||||
bvidVisualizeSelection = 1003, // bool
|
||||
bvidType = 1005, // BlockviewItemType
|
||||
bvidInvalidItem = 1008, // bool
|
||||
bvidDecorText = 1010, // QString
|
||||
bvidBlockDecor = 1011, // bool
|
||||
bvidDTHandle = 1012, // bool
|
||||
bvidCorrectMove = 1100, // bool
|
||||
bvidSelected = 1000, // bool
|
||||
bvidType , // BlockviewItemType
|
||||
bvidItemPos , // QPointF
|
||||
bvidDecorText , // QString src text for QGraphicsSimpleTextItem
|
||||
bvidMoveParent , // bool flag for move parent
|
||||
bvidVisualizeSelection , // bool flag for visualize selection
|
||||
bvidItemSelection , // bool BlockItem selection
|
||||
bvidInvalidItem , // bool item is NOT decor, ignore for function decors
|
||||
bvidBlockDecor , // bool item is BlockItem decor
|
||||
bvidDTHandle , // bool
|
||||
bvidCorrectMove , // bool
|
||||
};
|
||||
|
||||
enum BlockviewItemType {
|
||||
bvitInvalid,
|
||||
bvitPin,
|
||||
bvitBus,
|
||||
bvitBlock,
|
||||
bvitSelection,
|
||||
bvitDecor,
|
||||
bvitItemText,
|
||||
};
|
||||
|
||||
QAD_BLOCKVIEW_EXPORT QDataStream & operator <<(QDataStream & s, const QGraphicsItem * item);
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
BlockBusItem::BlockBusItem(bool temp): QGraphicsObject(), PropertyStorage() {
|
||||
temp_ = temp;
|
||||
_init();
|
||||
if (!temp) setData(1005, "connection");
|
||||
if (!temp) setData(bvidType, bvitBus);
|
||||
else hide();
|
||||
}
|
||||
|
||||
@@ -12,7 +12,7 @@ BlockBusItem::BlockBusItem(bool temp): QGraphicsObject(), PropertyStorage() {
|
||||
BlockBusItem::BlockBusItem(const BlockBusItem & other): QGraphicsObject(), PropertyStorage() {
|
||||
temp_ = false;
|
||||
_init();
|
||||
setData(1005, "connection");
|
||||
setData(bvidType, bvitBus);
|
||||
setPen(other.pen());
|
||||
setBrush(other.brush());
|
||||
setBusType(other.busType());
|
||||
@@ -543,7 +543,7 @@ void BlockBusItem::hoverMoveEvent(QGraphicsSceneHoverEvent * e) {
|
||||
bil << this;
|
||||
for (int i = 0; i < il.size(); ++i) {
|
||||
QGraphicsItem * b = il[i];
|
||||
if (b->data(1005) == "connection" && b != this) {
|
||||
if ((b->data(bvidType).toInt() == bvitBus) && b != this) {
|
||||
int tp = -1, ts = -1;
|
||||
((BlockBusItem*)b)->testPoint(sp, &tp, &ts);
|
||||
if (tp >= 0 || ts >= 0) {
|
||||
@@ -581,14 +581,17 @@ void BlockBusItem::mousePressEvent(QGraphicsSceneMouseEvent * e) {
|
||||
return;
|
||||
}
|
||||
int btncnt = 0;
|
||||
if (endpoints().contains(selPoint) && (e->button() == Qt::LeftButton) && e->modifiers().testFlag(Qt::ShiftModifier))
|
||||
QMetaObject::invokeMethod(scene()->views().back(), "startBusPointMove", Q_ARG(int, busType()));
|
||||
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()));
|
||||
}
|
||||
if (e->buttons().testFlag(Qt::LeftButton)) btncnt++;
|
||||
if (e->buttons().testFlag(Qt::RightButton)) btncnt++;
|
||||
if (e->buttons().testFlag(Qt::MidButton)) btncnt++;
|
||||
if (btncnt > 0) mm_mods = e->modifiers();
|
||||
//qDebug() << "press" << e;
|
||||
if (btncnt >= 2 && e->button() == Qt::RightButton) {
|
||||
//qDebug() << "bus revert";
|
||||
mm_cancel = true;
|
||||
moved = false;
|
||||
QPointF lp = qp - press_pos;
|
||||
@@ -659,16 +662,22 @@ void BlockBusItem::mouseMoveEvent(QGraphicsSceneMouseEvent * e) {
|
||||
QGraphicsObject::mouseMoveEvent(e);
|
||||
return;
|
||||
}
|
||||
BlockView * bv = 0;
|
||||
if (!scene()->views().isEmpty()) {
|
||||
bv = qobject_cast<BlockView*>(scene()->views().back());
|
||||
}
|
||||
qp = quantize(e->scenePos(), grid_step);
|
||||
lp = qp - lp;
|
||||
if (e->buttons().testFlag(Qt::LeftButton) && mm_mods.testFlag(Qt::NoModifier) && new_segment) {
|
||||
QMetaObject::invokeMethod(scene()->views().back(), "newBranchTrace", Q_ARG(BlockBusItem * , this), Q_ARG(QPointF, e->scenePos()));
|
||||
if (bv)
|
||||
QMetaObject::invokeMethod(bv, "newBranchTrace", Q_ARG(BlockBusItem * , this), Q_ARG(QPointF, e->scenePos()));
|
||||
return;
|
||||
}
|
||||
if (new_segment) {
|
||||
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)
|
||||
|
||||
@@ -83,8 +83,8 @@ void BlockEditor::loadModel(const QByteArray &model) {
|
||||
pin_tli[p->alignment()]->addChild(ti);
|
||||
}
|
||||
foreach (QGraphicsItem * i, block.decors()) {
|
||||
i->setData(1002, false);
|
||||
i->setData(1100, true);
|
||||
i->setData(bvidMoveParent, false);
|
||||
i->setData(bvidCorrectMove, true);
|
||||
}
|
||||
ui->treePins->blockSignals(false);
|
||||
}
|
||||
@@ -123,8 +123,8 @@ void BlockEditor::selectionChanged() {
|
||||
|
||||
void BlockEditor::addItem(QGraphicsItem *item) {
|
||||
block.addDecor(item);
|
||||
item->setData(1002, false);
|
||||
item->setData(1100, true);
|
||||
item->setData(bvidMoveParent, false);
|
||||
item->setData(bvidCorrectMove, true);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -6,16 +6,16 @@
|
||||
|
||||
BlockItem::BlockItem(QGraphicsItem * parent): QGraphicsObject(parent), PropertyStorage(),
|
||||
g_main(this), g_selection(this) {
|
||||
setData(1006, "item");
|
||||
setData(bvidType, bvitBlock);
|
||||
setZValue(2.);
|
||||
setAcceptHoverEvents(true);
|
||||
setFlags(QGraphicsItem::ItemIsSelectable | QGraphicsItem::ItemIsMovable);
|
||||
g_main.setData(1002, true);
|
||||
g_selection.setData(1007, true);
|
||||
g_main.setData(bvidMoveParent, true);
|
||||
g_selection.setData(bvidItemSelection, true);
|
||||
g_selection.setAcceptedMouseButtons(Qt::MouseButtons());
|
||||
g_selection.setZValue(10.);
|
||||
g_selection.hide();
|
||||
g_selection.setData(1003, true);
|
||||
g_selection.setData(bvidVisualizeSelection, true);
|
||||
col = Qt::lightGray;
|
||||
_resize(QSizeF(100., 60.));
|
||||
QPen p(QColor(128, 128, 255), lineThickness(), Qt::DotLine);
|
||||
@@ -117,11 +117,11 @@ void BlockItem::addDecor(QGraphicsItem * item) {
|
||||
if (qgraphicsitem_cast<QGraphicsPixmapItem*>(item))
|
||||
qgraphicsitem_cast<QGraphicsPixmapItem*>(item)->setTransformationMode(Qt::SmoothTransformation);
|
||||
if (qgraphicsitem_cast<QGraphicsSimpleTextItem*>(item))
|
||||
qgraphicsitem_cast<QGraphicsSimpleTextItem*>(item)->setData(1010, qgraphicsitem_cast<QGraphicsSimpleTextItem*>(item)->text());
|
||||
qgraphicsitem_cast<QGraphicsSimpleTextItem*>(item)->setData(bvidDecorText, qgraphicsitem_cast<QGraphicsSimpleTextItem*>(item)->text());
|
||||
if (qgraphicsitem_cast<AlignedTextItem*>(item))
|
||||
qgraphicsitem_cast<AlignedTextItem*>(item)->setData(1010, qgraphicsitem_cast<AlignedTextItem*>(item)->text());
|
||||
item->setData(1002, true);
|
||||
item->setData(1011, true);
|
||||
qgraphicsitem_cast<AlignedTextItem*>(item)->setData(bvidDecorText, qgraphicsitem_cast<AlignedTextItem*>(item)->text());
|
||||
item->setData(bvidMoveParent, true);
|
||||
item->setData(bvidBlockDecor, true);
|
||||
decors_ << item;
|
||||
item->setParentItem(this);
|
||||
}
|
||||
@@ -132,11 +132,11 @@ void BlockItem::addDecor(QGraphicsItem & item) {
|
||||
if (qgraphicsitem_cast<QGraphicsPixmapItem*>(&item))
|
||||
qgraphicsitem_cast<QGraphicsPixmapItem*>(&item)->setTransformationMode(Qt::SmoothTransformation);
|
||||
if (qgraphicsitem_cast<QGraphicsSimpleTextItem*>(&item))
|
||||
qgraphicsitem_cast<QGraphicsSimpleTextItem*>(&item)->setData(1010, qgraphicsitem_cast<QGraphicsSimpleTextItem*>(&item)->text());
|
||||
qgraphicsitem_cast<QGraphicsSimpleTextItem*>(&item)->setData(bvidDecorText, qgraphicsitem_cast<QGraphicsSimpleTextItem*>(&item)->text());
|
||||
if (qgraphicsitem_cast<AlignedTextItem*>(&item))
|
||||
qgraphicsitem_cast<AlignedTextItem*>(&item)->setData(1010, qgraphicsitem_cast<AlignedTextItem*>(&item)->text());
|
||||
item.setData(1002, true);
|
||||
item.setData(1011, true);
|
||||
qgraphicsitem_cast<AlignedTextItem*>(&item)->setData(bvidDecorText, qgraphicsitem_cast<AlignedTextItem*>(&item)->text());
|
||||
item.setData(bvidMoveParent, true);
|
||||
item.setData(bvidBlockDecor, true);
|
||||
//decors_ << &item;
|
||||
item.setParentItem(this);
|
||||
}
|
||||
|
||||
@@ -4,10 +4,10 @@
|
||||
|
||||
BlockItemPin::BlockItemPin(Qt::Alignment a, int bus_type_, const QString & text_, QGraphicsObject * _parent): QGraphicsObject(_parent), ell_item(this), text_item(this) {
|
||||
parent_ = 0;
|
||||
setData(1004, "pin");
|
||||
setData(bvidType, bvitPin);
|
||||
setAcceptHoverEvents(true);
|
||||
text_item.setData(1002, true);
|
||||
ell_item.setData(1003, true);
|
||||
text_item.setData(bvidMoveParent, true);
|
||||
ell_item.setData(bvidVisualizeSelection, true);
|
||||
br[Disconnected] = QBrush(Qt::lightGray);
|
||||
br[Connected] = QBrush(Qt::darkGreen);
|
||||
br[Hover] = QBrush(Qt::blue);
|
||||
|
||||
@@ -13,6 +13,14 @@
|
||||
const QString _BlockView_Mime_ = "_BlockView_copypaste_";
|
||||
|
||||
|
||||
template <typename T> QSet<T> QList2QSet(const QList<T> & l) {
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(5, 14, 0)
|
||||
return QSet<T>(l.begin(), l.end());
|
||||
#else
|
||||
return QSet<T>::fromList(l);
|
||||
#endif
|
||||
}
|
||||
|
||||
BlockView::BlockView(QWidget * parent): QGraphicsView(parent), tmp_bus(true) {
|
||||
_init();
|
||||
}
|
||||
@@ -33,7 +41,7 @@ void BlockView::_init() {
|
||||
qRegisterMetaType<BlockBusItem*>();
|
||||
grid_visible = grid_snap = pm_connect = navigation = m_connect = m_trace_with_buses = prev_tcb = minimap = true;
|
||||
mm_drag = moved = new_branch = new_bus = mm_cancel = iconnect = mm_copy = m_pin_mc = mm_thumb = move_bus_point = wheel_zoom = false;
|
||||
match_bus = bus_from = 0;
|
||||
match_bus = bus_from = cur_bus = 0;
|
||||
mm_ci = 0;
|
||||
hpin = 0;
|
||||
ghost_ = 0;
|
||||
@@ -164,12 +172,12 @@ bool BlockView::eventFilter(QObject * o, QEvent * e) {
|
||||
case QEvent::GraphicsSceneMouseDoubleClick:
|
||||
mil = scene_->items(scene_point);
|
||||
foreach (QGraphicsItem * i, mil) {
|
||||
if (i->data(1006) == "item") {
|
||||
if (i->data(bvidType).toInt() == bvitBlock) {
|
||||
//emit blockDoubleClicked((BlockItem * )i);
|
||||
QMetaObject::invokeMethod(this, "blockDoubleClicked", Qt::QueuedConnection, Q_ARG(BlockItem * , (BlockItem*)i));
|
||||
return true;
|
||||
}
|
||||
if (i->data(1005) == "connection") {
|
||||
if (i->data(bvidType).toInt() == bvitBus) {
|
||||
if (qgraphicsitem_cast<BlockBusItem*>(i)->isBusSelected()) {
|
||||
//emit busDoubleClicked(qgraphicsitem_cast<BlockBusItem*>(i));
|
||||
QMetaObject::invokeMethod(this, "busDoubleClicked", Qt::QueuedConnection, Q_ARG(BlockBusItem * , (BlockBusItem*)i));
|
||||
@@ -183,7 +191,7 @@ bool BlockView::eventFilter(QObject * o, QEvent * e) {
|
||||
mil = scene_->items(scene_point);
|
||||
mm_ci = (mil.isEmpty() ? 0 : mil.front());
|
||||
if (mm_ci != 0) {
|
||||
while (mm_ci->data(1005).toString() == "connection") {
|
||||
while (mm_ci->data(bvidType).toInt() == bvitBus) {
|
||||
if (qgraphicsitem_cast<BlockBusItem*>(mm_ci))
|
||||
if (qgraphicsitem_cast<BlockBusItem*>(mm_ci)->isBusSelected())
|
||||
break;
|
||||
@@ -199,13 +207,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->data(bvidInvalidItem).toBool()) {
|
||||
mm_ci = 0;
|
||||
break;
|
||||
}
|
||||
//if (mm_ci->data(1007).toBool()) break;
|
||||
//if (mm_ci->data(bvidItemSelection).toBool()) break;
|
||||
}
|
||||
//qDebug() << "press";
|
||||
if (me->buttons().testFlag(Qt::LeftButton)) btncnt++;
|
||||
if (me->buttons().testFlag(Qt::RightButton)) btncnt++;
|
||||
if (me->buttons().testFlag(Qt::MidButton)) btncnt++;
|
||||
@@ -218,34 +225,41 @@ bool BlockView::eventFilter(QObject * o, QEvent * e) {
|
||||
QList<QGraphicsItem*> gi = scene_->items();
|
||||
block_emit_selection = true;
|
||||
foreach (QGraphicsItem * i, gi)
|
||||
i->setSelected(i->data(1000).toBool());
|
||||
i->setSelected(i->data(bvidSelected).toBool());
|
||||
block_emit_selection = false;
|
||||
emit selectionChanged();
|
||||
}
|
||||
if (mm_copy && mm_cancel) {
|
||||
deleteCopyTemp();
|
||||
mm_copy = moved = false;
|
||||
unsetCursor();
|
||||
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;
|
||||
unsetCursor();
|
||||
}
|
||||
if (new_bus) {
|
||||
new_bus = false;
|
||||
unmarkPins(true);
|
||||
reconnectAll();
|
||||
hideTmpBuses();
|
||||
m_trace_with_buses = prev_tcb;
|
||||
}
|
||||
if (new_branch) {
|
||||
new_branch = false;
|
||||
hideTmpBuses();
|
||||
m_trace_with_buses = prev_tcb;
|
||||
}
|
||||
if (moved) {
|
||||
moved = false;
|
||||
restoreSelState();
|
||||
hideTmpBuses();
|
||||
m_trace_with_buses = prev_tcb;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
if (new_bus && mm_cancel) {
|
||||
new_bus = false;
|
||||
unmarkPins(true);
|
||||
reconnectAll();
|
||||
hideTmpBuses();
|
||||
m_trace_with_buses = prev_tcb;
|
||||
}
|
||||
if (new_branch && mm_cancel) {
|
||||
new_branch = false;
|
||||
hideTmpBuses();
|
||||
m_trace_with_buses = prev_tcb;
|
||||
}
|
||||
if (moved && mm_cancel) {
|
||||
moved = false;
|
||||
restoreSelState();
|
||||
hideTmpBuses();
|
||||
m_trace_with_buses = prev_tcb;
|
||||
}
|
||||
if (mm_cancel) return true;
|
||||
mm_mods = me->modifiers();
|
||||
mm_drag = moved = false;
|
||||
screen_point = me->screenPos();
|
||||
@@ -260,7 +274,7 @@ bool BlockView::eventFilter(QObject * o, QEvent * e) {
|
||||
while (!mil.isEmpty()) {
|
||||
mm_ci = mil.front();
|
||||
if (mm_ci->data(bvidDTHandle).toBool()) return QGraphicsView::eventFilter(o, e);
|
||||
if (mm_ci->data(1008).toBool() || mm_ci->data(1007).toBool()) {
|
||||
if (mm_ci->data(bvidInvalidItem).toBool() || mm_ci->data(bvidItemSelection).toBool()) {
|
||||
mil.pop_front();
|
||||
} else break;
|
||||
}
|
||||
@@ -268,7 +282,7 @@ bool BlockView::eventFilter(QObject * o, QEvent * e) {
|
||||
mm_ci = 0;
|
||||
return true;
|
||||
}
|
||||
while (mm_ci->data(1005).toString() == "connection") {
|
||||
while (mm_ci->data(bvidType).toInt() == bvitBus) {
|
||||
if (qgraphicsitem_cast<BlockBusItem*>(mm_ci))
|
||||
if (qgraphicsitem_cast<BlockBusItem*>(mm_ci)->isBusSelected())
|
||||
break;
|
||||
@@ -280,21 +294,21 @@ bool BlockView::eventFilter(QObject * o, QEvent * e) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (mm_ci->data(1003).toBool()) {
|
||||
if (mm_ci->data(bvidVisualizeSelection).toBool()) {
|
||||
if (mil.size() > 1) {
|
||||
mm_ci = mil[1];
|
||||
mil.pop_front();
|
||||
if (mm_ci->data(1003).toBool())
|
||||
if (mm_ci->data(bvidVisualizeSelection).toBool())
|
||||
if (mil.size() > 1)
|
||||
mm_ci = mil[1];
|
||||
} else
|
||||
mm_ci = 0;
|
||||
}
|
||||
if (mm_ci->data(1002).toBool()) {
|
||||
if (mm_ci->data(bvidMoveParent).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
|
||||
if (!ti->data(bvidDecorText).toString().isEmpty()) { // text item, check for rect
|
||||
BlockItem * bi = qgraphicsitem_cast<BlockItem*>(mm_ci);
|
||||
if (bi) {
|
||||
if (!bi->sceneRect().contains(scene_point)) {
|
||||
@@ -306,7 +320,7 @@ bool BlockView::eventFilter(QObject * o, QEvent * e) {
|
||||
return true;
|
||||
}
|
||||
if (mm_ci) {
|
||||
if (mm_ci->data(1004) == "pin" && m_connect) {
|
||||
if ((mm_ci->data(bvidType).toInt() == bvitPin) && m_connect) {
|
||||
if (qgraphicsitem_cast<BlockItemPin*>(mm_ci)->state() == BlockItemPin::Hover) {
|
||||
trace_from = mm_ci->scenePos();
|
||||
qgraphicsitem_cast<BlockItemPin*>(mm_ci)->clearStateStack();
|
||||
@@ -344,11 +358,11 @@ 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(bvidInvalidItem).toBool()) {
|
||||
mm_ci = 0;
|
||||
break;
|
||||
}
|
||||
if (mm_ci->data(1007).toBool()) break;
|
||||
if (mm_ci->data(bvidItemSelection).toBool()) break;
|
||||
if (mm_ci->data(bvidDTHandle).toBool()) break;
|
||||
if (mm_cancel) return true;
|
||||
if (me->buttons().testFlag(Qt::LeftButton)) {
|
||||
@@ -362,7 +376,7 @@ bool BlockView::eventFilter(QObject * o, QEvent * e) {
|
||||
mil = scene_->items(me->scenePos());
|
||||
hpin = 0;
|
||||
foreach (QGraphicsItem * i, mil)
|
||||
if (i->data(1004) == "pin") {
|
||||
if (i->data(bvidType).toInt() == bvitPin) {
|
||||
hpin = qgraphicsitem_cast<BlockItemPin*>(i);
|
||||
break;
|
||||
}
|
||||
@@ -391,7 +405,7 @@ bool BlockView::eventFilter(QObject * o, QEvent * e) {
|
||||
if (fmm_drag) {
|
||||
fmm_drag = false;
|
||||
if (mm_ci) {
|
||||
if ((mm_ci->data(1006) == "item")) {
|
||||
if (mm_ci->data(bvidType).toInt() == bvitBlock) {
|
||||
if (!mm_ci->isSelected() && sel_items.isEmpty()) {
|
||||
clearSelection();
|
||||
mm_ci->setSelected(true);
|
||||
@@ -407,7 +421,7 @@ bool BlockView::eventFilter(QObject * o, QEvent * e) {
|
||||
deleteCopyTemp();
|
||||
QList<BlockItem * > bi;
|
||||
foreach (QGraphicsItem * i, sel_items) {
|
||||
if (i->data(1006) == "item") {
|
||||
if (i->data(bvidType).toInt() == bvitBlock) {
|
||||
//qDebug() << "copy";
|
||||
bi << qgraphicsitem_cast<BlockItem*>(i);
|
||||
BlockItem * ti = bi.back()->copy();
|
||||
@@ -492,7 +506,7 @@ bool BlockView::eventFilter(QObject * o, QEvent * e) {
|
||||
}
|
||||
}
|
||||
if (mm_ci)
|
||||
if (mm_ci->data(1100).toBool())
|
||||
if (mm_ci->data(bvidBlockDecor).toBool())
|
||||
return true;
|
||||
}
|
||||
if (me->modifiers().testFlag(Qt::ControlModifier) && me->buttons() != 0 && mm_ci == 0)
|
||||
@@ -510,11 +524,11 @@ bool BlockView::eventFilter(QObject * o, QEvent * e) {
|
||||
return true;
|
||||
}
|
||||
if (mm_ci)
|
||||
if (mm_ci->data(1008).toBool()) {
|
||||
if (mm_ci->data(bvidInvalidItem).toBool()) {
|
||||
mm_ci = 0;
|
||||
break;
|
||||
}
|
||||
if (mm_ci->data(1007).toBool()) break;
|
||||
if (mm_ci->data(bvidItemSelection).toBool()) break;
|
||||
if (mm_copy) {
|
||||
QList<QGraphicsItem*> ai;
|
||||
blockSignals(true);
|
||||
@@ -522,7 +536,7 @@ bool BlockView::eventFilter(QObject * o, QEvent * e) {
|
||||
QList<BlockItem*> ci;
|
||||
QList<BlockBusItem*> bi;
|
||||
foreach (QGraphicsItem * b, sel_items)
|
||||
if (b->data(1006) == "item") {
|
||||
if (b->data(bvidType).toInt() == bvitBlock) {
|
||||
ci << qgraphicsitem_cast<BlockItem*>(b);
|
||||
ai << qgraphicsitem_cast<QGraphicsItem*>(b);
|
||||
}
|
||||
@@ -544,7 +558,7 @@ bool BlockView::eventFilter(QObject * o, QEvent * e) {
|
||||
if (moved && pm_connect) {
|
||||
QList<QGraphicsItem*> ci;
|
||||
foreach (QGraphicsItem * b, sel_items)
|
||||
if (b->data(1006) == "item")
|
||||
if (b->data(bvidType).toInt() == bvitBlock)
|
||||
ci << b;
|
||||
simplifyBuses();
|
||||
emitActionEvent(BlockItemBase::BlockMove, ci);
|
||||
@@ -591,7 +605,7 @@ bool BlockView::eventFilter(QObject * o, QEvent * e) {
|
||||
} else {
|
||||
if (mm_ci != 0) {
|
||||
if (me->modifiers().testFlag(Qt::ControlModifier)) {
|
||||
if (mm_ci->data(1006) == "item")
|
||||
if (mm_ci->data(bvidType).toInt() == bvitBlock)
|
||||
mm_ci->setSelected(!mm_ci->isSelected());
|
||||
} else
|
||||
mm_ci->setSelected(true);
|
||||
@@ -642,12 +656,20 @@ void BlockView::timerEvent(QTimerEvent * e) {
|
||||
void BlockView::wheelEvent(QWheelEvent * e) {
|
||||
if (!navigation) return;
|
||||
if (wheel_zoom || e->modifiers().testFlag(Qt::ControlModifier)) {
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(5, 14, 0)
|
||||
double scl = 1. - e->angleDelta().y() / 500.;
|
||||
#else
|
||||
double scl = 1. - e->delta() / 500.;
|
||||
#endif
|
||||
if (!is_nav_anim || (nav_anim.state() != QPropertyAnimation::Running))
|
||||
nav_target = _nav();
|
||||
QRectF r = nav_target;
|
||||
double vw = viewport()->width(), vh = viewport()->height();
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(5, 14, 0)
|
||||
double cx = double(e->position().x()) / vw, cy = double(e->position().y()) / vh;
|
||||
#else
|
||||
double cx = double(e->pos().x()) / vw, cy = double(e->pos().y()) / vh;
|
||||
#endif
|
||||
double pw = r.width(), ph = r.height();
|
||||
r.setWidth(r.width() * scl);
|
||||
r.setHeight(r.width() * vh / vw);
|
||||
@@ -950,7 +972,7 @@ void BlockView::clearSelection() {
|
||||
void BlockView::addItem(QGraphicsItem * item, bool emit_action) {
|
||||
scene_->addItem(item);
|
||||
applyGridStep();
|
||||
if (item->data(1005) == "connection") {
|
||||
if (item->data(bvidType).toInt() == bvitBus) {
|
||||
loadBus(qgraphicsitem_cast<BlockBusItem*>(item));
|
||||
((BlockBusItem*)item)->setSquareNodes(square_node);
|
||||
connect((BlockBusItem*)item, SIGNAL(destroyed(QObject*)), this, SLOT(removedBus(QObject*)), Qt::UniqueConnection);
|
||||
@@ -958,14 +980,14 @@ void BlockView::addItem(QGraphicsItem * item, bool emit_action) {
|
||||
emit connectionsChanged();
|
||||
return;
|
||||
}
|
||||
if (item->data(1006) == "item") {
|
||||
if (item->data(bvidType).toInt() == bvitBlock) {
|
||||
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(blockHoverLeave(BlockItem*)), this, SIGNAL(blockHoverLeave(BlockItem*)), Qt::UniqueConnection);
|
||||
if (emit_action) emitActionEvent(BlockItemBase::BlockAdd, QList<QGraphicsItem*>() << item);
|
||||
return;
|
||||
}
|
||||
item->setData(1009, "decor");
|
||||
item->setData(bvidType, bvitDecor);
|
||||
}
|
||||
|
||||
|
||||
@@ -973,7 +995,7 @@ QList<BlockBusItem * > BlockView::buses() const {
|
||||
QList<BlockBusItem * > ret;
|
||||
QList<QGraphicsItem*> gi = scene_->items();
|
||||
foreach (QGraphicsItem * i, gi)
|
||||
if (i->data(1005) == "connection")
|
||||
if (i->data(bvidType).toInt() == bvitBus)
|
||||
if (!copy_buses.contains((BlockBusItem*)i))
|
||||
ret << qgraphicsitem_cast<BlockBusItem*>(i);
|
||||
return ret;
|
||||
@@ -1002,7 +1024,7 @@ QList<BlockItem * > BlockView::blocks() const {
|
||||
QList<BlockItem * > ret;
|
||||
QList<QGraphicsItem*> gi = scene_->items();
|
||||
foreach (QGraphicsItem * i, gi)
|
||||
if (i->data(1006) == "item")
|
||||
if (i->data(bvidType).toInt() == bvitBlock)
|
||||
ret << qgraphicsitem_cast<BlockItem*>(i);
|
||||
return ret;
|
||||
}
|
||||
@@ -1011,7 +1033,7 @@ QList<BlockItem * > BlockView::blocks() const {
|
||||
QList<QGraphicsItem * > BlockView::decors() const {
|
||||
QList<QGraphicsItem*> ret, gi = scene_->items();
|
||||
foreach (QGraphicsItem * i, gi)
|
||||
if ((i->data(1009) == "decor") && !i->data(1008).toBool() && !i->data(1007).toBool() && (i->parentItem() == 0)
|
||||
if ((i->data(bvidType).toInt() == bvitDecor) && !i->data(bvidInvalidItem).toBool() && !i->data(bvidItemSelection).toBool() && (i->parentItem() == 0)
|
||||
&& (i != &sel_rect) && (i != &tmp_bus) && !tmp_buses.contains((BlockBusItem*)i))
|
||||
ret << i;
|
||||
return ret;
|
||||
@@ -1027,7 +1049,8 @@ BlockBusItem * BlockView::connectionBus(BlockItem * b0, BlockItem * b1) const {
|
||||
|
||||
QList<BlockBusItem * > BlockView::connectionBuses(BlockItem * b0, BlockItem * b1) const {
|
||||
if (!b0 || !b1) return QList<BlockBusItem * >();
|
||||
QSet<BlockBusItem * > bs0 = b0->connectedBuses().toSet(), bs1 = b1->connectedBuses().toSet();
|
||||
QSet<BlockBusItem * > bs0 = QList2QSet(b0->connectedBuses()),
|
||||
bs1 = QList2QSet(b1->connectedBuses());
|
||||
return (bs0 & bs1).values();
|
||||
}
|
||||
|
||||
@@ -1037,7 +1060,7 @@ bool BlockView::connectPins(BlockItemPin * p0, BlockItemPin * p1) {
|
||||
if (p0 == p1) return false;
|
||||
if (p0->busType() != p1->busType()) return false;
|
||||
QList<BlockBusItem * > bl0 = p0->connectedBuses(), bl1 = p1->connectedBuses();
|
||||
if (!(bl0.toSet() & bl1.toSet()).isEmpty()) return true;
|
||||
if (!(QList2QSet(bl0) & QList2QSet(bl1)).isEmpty()) return true;
|
||||
BlockBusItem * nb = new BlockBusItem();
|
||||
nb->setBusType(p0->busType());
|
||||
//nb->setEndpointsNumber(3);
|
||||
@@ -1165,7 +1188,7 @@ QRectF BlockView::itemsBoundingRect() const {
|
||||
QRectF ret;
|
||||
foreach (QGraphicsItem * i, gi)
|
||||
if (i->isVisible() && (i != &tmp_bus) && !tmp_buses.contains((BlockBusItem*)i)) {
|
||||
if (!(i->data(1007).toBool()) && !i->data(1008).toBool()) {
|
||||
if (!(i->data(bvidItemSelection).toBool()) && !i->data(bvidInvalidItem).toBool()) {
|
||||
QRectF br = i->mapRectToScene(i->boundingRect());
|
||||
if (br.width() <= 1 || br.height() <= 1) continue;
|
||||
if (f) ret = br;
|
||||
@@ -1179,11 +1202,11 @@ QRectF BlockView::itemsBoundingRect() const {
|
||||
|
||||
void BlockView::restoreSelState() {
|
||||
foreach (QGraphicsItem * i, sel_items) {
|
||||
i->setPos(i->data(1001).toPointF());
|
||||
i->setPos(i->data(bvidItemPos).toPointF());
|
||||
}
|
||||
QList<QGraphicsItem*> gi = scene_->items();
|
||||
foreach (QGraphicsItem * i, gi)
|
||||
if (i->data(1005) == "connection") {
|
||||
if (i->data(bvidType).toInt() == bvitBus) {
|
||||
BlockBusItem * bi = qgraphicsitem_cast<BlockBusItem*>(i);
|
||||
bi->pol = bi->bpol;
|
||||
bi->prepareGeometryChange();
|
||||
@@ -1195,9 +1218,9 @@ void BlockView::saveSelState() {
|
||||
QList<QGraphicsItem*> gi = scene_->items();
|
||||
sel_items = scene_->selectedItems();
|
||||
foreach (QGraphicsItem * i, gi) {
|
||||
i->setData(1000, i->isSelected());
|
||||
i->setData(1001, i->pos());
|
||||
if (i->data(1005) == "connection")
|
||||
i->setData(bvidSelected, i->isSelected());
|
||||
i->setData(bvidItemPos, i->pos());
|
||||
if (i->data(bvidType).toInt() == bvitBus)
|
||||
qgraphicsitem_cast<BlockBusItem*>(i)->bpol = qgraphicsitem_cast<BlockBusItem*>(i)->pol;
|
||||
}
|
||||
}
|
||||
@@ -1226,7 +1249,7 @@ void BlockView::applySelRect(QGraphicsSceneMouseEvent * me) {
|
||||
if (!add) clearSelection();
|
||||
else {
|
||||
foreach (QGraphicsItem * i, gi)
|
||||
i->setSelected(i->data(1000).toBool());
|
||||
i->setSelected(i->data(bvidSelected).toBool());
|
||||
}
|
||||
foreach (QGraphicsItem * i, ci) {
|
||||
i->setSelected(!i->isSelected());
|
||||
@@ -1262,7 +1285,7 @@ void BlockView::trace(QPointF scene_pos_from, QPointF scene_pos_to, BlockBusItem
|
||||
wavetrace.fill(BlockViewWavetrace::Empty);
|
||||
QList<QGraphicsItem*> gi = scene_->items();
|
||||
foreach (QGraphicsItem * i, gi)
|
||||
if (i->data(1006) == "item") {
|
||||
if (i->data(bvidType).toInt() == bvitBlock) {
|
||||
QRect ir = i->mapRectToScene(i->boundingRect()).toRect().normalized();
|
||||
wavetrace.fill(QRect(ir.topLeft() / grid_step + dp, ir.bottomRight() / grid_step + dp), BlockViewWavetrace::Blocked);
|
||||
QVector<BlockItemPin * > pins = qgraphicsitem_cast<BlockItem * >(i)->pins();
|
||||
@@ -1273,7 +1296,7 @@ void BlockView::trace(QPointF scene_pos_from, QPointF scene_pos_to, BlockBusItem
|
||||
}
|
||||
if (m_trace_with_buses) {
|
||||
foreach (QGraphicsItem * i, gi)
|
||||
if (i->data(1005) == "connection") {
|
||||
if (i->data(bvidType).toInt() == bvitBus) {
|
||||
BlockBusItem * b = qgraphicsitem_cast<BlockBusItem * >(i);
|
||||
if (!b) continue;
|
||||
for (int s = 0; s < b->segments.size(); ++s) {
|
||||
@@ -1322,7 +1345,7 @@ void BlockView::trace(QPointF scene_pos_from, QPointF scene_pos_to, BlockBusItem
|
||||
void BlockView::clearBusStates() {
|
||||
QList<QGraphicsItem * > gi = scene_->items();
|
||||
foreach (QGraphicsItem * i, gi)
|
||||
if (i->data(1005) == "connection") {
|
||||
if (i->data(bvidType).toInt() == bvitBus) {
|
||||
BlockBusItem * b = qgraphicsitem_cast<BlockBusItem*>(i);
|
||||
b->clearBusState();
|
||||
// if (i != bus_from && i != match_bus)
|
||||
@@ -1344,9 +1367,9 @@ void BlockView::matchBus() {
|
||||
point = tmp_bus.pol.back();
|
||||
foreach (QGraphicsItem * i, gi) {
|
||||
if (i != bus_from) {
|
||||
if (i->data(1005) == "connection")
|
||||
if (i->data(bvidType).toInt() == bvitBus)
|
||||
buses << qgraphicsitem_cast<BlockBusItem*>(i);
|
||||
if (i->data(1006) == "item")
|
||||
if (i->data(bvidType).toInt() == bvitBlock)
|
||||
blockl << qgraphicsitem_cast<BlockItem*>(i);
|
||||
}
|
||||
}
|
||||
@@ -1435,7 +1458,7 @@ void BlockView::markPins(int bus_type) {
|
||||
unhoverPins();
|
||||
QList<QGraphicsItem * > gi = scene_->items();
|
||||
foreach (QGraphicsItem * i, gi) {
|
||||
if (i->data(1004) == "pin") {
|
||||
if (i->data(bvidType).toInt() == bvitPin) {
|
||||
BlockItemPin * p = qgraphicsitem_cast<BlockItemPin*>(i);
|
||||
p->saveState();
|
||||
if (m_pin_mc) {
|
||||
@@ -1458,7 +1481,7 @@ void BlockView::unmarkPins(bool to_normal) {
|
||||
unhoverPins();
|
||||
QList<QGraphicsItem * > gi = scene_->items();
|
||||
foreach (QGraphicsItem * i, gi) {
|
||||
if (i->data(1004) == "pin") {
|
||||
if (i->data(bvidType).toInt() == bvitPin) {
|
||||
qgraphicsitem_cast<BlockItemPin*>(i)->restoreState();
|
||||
if (to_normal)
|
||||
while (qgraphicsitem_cast<BlockItemPin*>(i)->restoreState());
|
||||
@@ -1477,7 +1500,7 @@ void BlockView::unhoverPins(BlockItemPin* excl_pin) {
|
||||
QList<QGraphicsItem * > gi = scene_->items();
|
||||
foreach (QGraphicsItem * i, gi) {
|
||||
if (excl_pin == ((BlockItemPin*)i)) continue;
|
||||
if (i->data(1004) == "pin") {
|
||||
if (i->data(bvidType).toInt() == bvitPin) {
|
||||
((BlockItemPin*)i)->enlargePin(false);
|
||||
}
|
||||
}
|
||||
@@ -1498,10 +1521,10 @@ void BlockView::moveBuses(const QList<QGraphicsItem * > & items, QPointF dp) {
|
||||
QList<BlockBusItem * > buses;
|
||||
//qDebug() << "move" << dp;
|
||||
foreach (QGraphicsItem * i, items)
|
||||
if (i->data(1006) == "item" && i->flags().testFlag(QGraphicsItem::ItemIsMovable))
|
||||
if ((i->data(bvidType).toInt() == bvitBlock) && i->flags().testFlag(QGraphicsItem::ItemIsMovable))
|
||||
pins << qgraphicsitem_cast<BlockItem*>(i)->pins();
|
||||
foreach (QGraphicsItem * i, gi)
|
||||
if (i->data(1005) == "connection")
|
||||
if (i->data(bvidType).toInt() == bvitBus)
|
||||
buses << qgraphicsitem_cast<BlockBusItem*>(i);
|
||||
foreach (BlockBusItem * b, buses) {
|
||||
QList<BlockItemPin * > bpins = b->connections_.values();
|
||||
@@ -1555,10 +1578,10 @@ QList<BlockBusItem * > BlockView::internalBuses(const QList<BlockItem * > & item
|
||||
QList<BlockBusItem * > ret;
|
||||
if (items.isEmpty()) return ret;
|
||||
QList<BlockBusItem * > sbl = buses();
|
||||
QSet<BlockItem * > sis = QSet<BlockItem * >::fromList(items);
|
||||
QSet<BlockItem * > sis = QList2QSet(items);
|
||||
foreach (BlockBusItem * bi, sbl) {
|
||||
if (bi->connectedBlocks().isEmpty()) continue;
|
||||
QSet<BlockItem * > bis = QSet<BlockItem * >::fromList(bi->connectedBlocks());
|
||||
QSet<BlockItem * > bis = QList2QSet(bi->connectedBlocks());
|
||||
if ((bis - sis).isEmpty())
|
||||
ret << bi;
|
||||
}
|
||||
@@ -1604,7 +1627,7 @@ QList<BlockItemPin * > BlockView::nearPins(BlockItemPin * pin, Qt::KeyboardModif
|
||||
|
||||
BlockItemPin * BlockView::getPin(const QList<QGraphicsItem *> & list) const {
|
||||
foreach (QGraphicsItem * i, list) {
|
||||
if (i->data(1004) == "pin")
|
||||
if (i->data(bvidType).toInt() == bvitPin)
|
||||
return qgraphicsitem_cast<BlockItemPin*>(i);
|
||||
}
|
||||
return 0;
|
||||
@@ -1638,7 +1661,7 @@ QList<BlockItem * > BlockView::selectedBlocks() const {
|
||||
QList<BlockItem * > ret;
|
||||
QList<QGraphicsItem * > sil = scene()->selectedItems();
|
||||
foreach (QGraphicsItem * b, sil)
|
||||
if (b->data(1006) == "item")
|
||||
if (b->data(bvidType).toInt() == bvitBlock)
|
||||
ret << qgraphicsitem_cast<BlockItem*>(b);
|
||||
return ret;
|
||||
}
|
||||
@@ -1833,7 +1856,7 @@ void BlockView::removedBlock(QObject * o) {
|
||||
void BlockView::removeJunk() {
|
||||
QList<QGraphicsItem * > gi = scene_->items();
|
||||
foreach (QGraphicsItem * i, gi) {
|
||||
if (i->data(1005) != "connection") continue;
|
||||
if (i->data(bvidType).toInt() != bvitBus) continue;
|
||||
BlockBusItem * b = qgraphicsitem_cast<BlockBusItem*>(i);
|
||||
if (b->pol.size() <= 1) {
|
||||
b->deleteLater();
|
||||
@@ -1892,9 +1915,9 @@ void BlockView::reconnectAll() {
|
||||
QList<BlockItemPin * > pins;
|
||||
QList<BlockBusItem * > buses;
|
||||
foreach (QGraphicsItem * i, gi) {
|
||||
if (i->data(1004) == "pin")
|
||||
if (i->data(bvidType).toInt() == bvitPin)
|
||||
pins << qgraphicsitem_cast<BlockItemPin*>(i);
|
||||
if (i->data(1005) == "connection")
|
||||
if (i->data(bvidType).toInt() == bvitBus)
|
||||
buses << qgraphicsitem_cast<BlockBusItem*>(i);
|
||||
}
|
||||
foreach (BlockItemPin * p, pins) {
|
||||
@@ -2043,9 +2066,9 @@ void BlockView::removeSelected() {
|
||||
if (i->connectedBlocks().isEmpty())
|
||||
dbuses << i;
|
||||
foreach (QGraphicsItem * i, gi) {
|
||||
if (i->data(1006) == "item")
|
||||
if (i->data(bvidType).toInt() == bvitBlock)
|
||||
ai << qgraphicsitem_cast<QGraphicsItem*>(i);
|
||||
if ((i->data(1006) == "item") || (i->data(1005) == "connection") || (i->data(1009) == "decor")) {
|
||||
if ((i->data(bvidType).toInt() == bvitBlock) || (i->data(bvidType).toInt() == bvitBus) || (i->data(bvidType).toInt() == bvitDecor)) {
|
||||
scene_->sendEvent(i, new QGraphicsSceneEvent(QEvent::Close));
|
||||
delete i;
|
||||
}
|
||||
@@ -2068,11 +2091,11 @@ void BlockView::removeAll() {
|
||||
QList<QGraphicsItem*> gi = scene_->items(), ai;
|
||||
blockSignals(true);
|
||||
foreach (QGraphicsItem * i, gi) {
|
||||
if (i->data(1006) == "item")
|
||||
if (i->data(bvidType).toInt() == bvitBlock)
|
||||
ai << qgraphicsitem_cast<QGraphicsItem*>(i);
|
||||
if ((i->data(1006) == "item") || (i->data(1005) == "connection") || (i->data(1009) == "decor")) {
|
||||
if ((i != &sel_rect) && (i != &tmp_bus) && (i->parentItem() == 0) && !(i->data(1008).toBool()) && !(i->data(1007).toBool())) {
|
||||
//qDebug() << "delete" << i->data(1004);
|
||||
if ((i->data(bvidType).toInt() == bvitBlock) || (i->data(bvidType).toInt() == bvitBus) || (i->data(bvidType).toInt() == bvitDecor)) {
|
||||
if ((i != &sel_rect) && (i != &tmp_bus) && (i->parentItem() == 0) && !(i->data(bvidInvalidItem).toBool()) && !(i->data(bvidItemSelection).toBool())) {
|
||||
//qDebug() << "delete" << i->data(1005).toInt();
|
||||
scene_->sendEvent(i, new QGraphicsSceneEvent(QEvent::Close));
|
||||
delete i;
|
||||
}
|
||||
|
||||
@@ -63,6 +63,8 @@ class QAD_BLOCKVIEW_EXPORT BlockView: public QGraphicsView
|
||||
Q_PROPERTY(double _thumb READ _thumb WRITE _setThumb DESIGNABLE false SCRIPTABLE false)
|
||||
Q_PROPERTY(QRectF _nav READ _nav WRITE _setNav DESIGNABLE false SCRIPTABLE false)
|
||||
|
||||
friend class BlockBusItem;
|
||||
|
||||
public:
|
||||
BlockView(QWidget * parent = 0);
|
||||
BlockView(QGraphicsScene * scene, QWidget * parent = 0);
|
||||
@@ -180,7 +182,7 @@ protected:
|
||||
QList<BlockItem * > copy_items;
|
||||
QList<BlockItemPin * > last_multiconnect_pl;
|
||||
QList<BlockBusItem * > copy_buses, tmp_buses;
|
||||
BlockBusItem tmp_bus, * match_bus, * bus_from;
|
||||
BlockBusItem tmp_bus, * match_bus, * bus_from, * cur_bus;
|
||||
BlockItemPin * hpin;
|
||||
BlockItem * ghost_;
|
||||
BlockViewWavetrace wavetrace;
|
||||
|
||||
@@ -15,10 +15,10 @@ _DTSizeItem::_DTSizeItem(): QGraphicsObject() {
|
||||
cur_item = 0;
|
||||
grid = 10.;
|
||||
in_process = can_drag = false;
|
||||
setData(1007, true);
|
||||
setData(bvidItemSelection, true);
|
||||
for (int i = 0; i < 8; ++i) {
|
||||
//qDebug() << &(rects[i]);
|
||||
rects[i].setData(1007, true);
|
||||
rects[i].setData(bvidItemSelection, true);
|
||||
rects[i].setData(bvidDTHandle, true);
|
||||
rects[i].setFlag(QGraphicsItem::ItemIgnoresTransformations);
|
||||
rects[i].setZValue(10.);
|
||||
@@ -26,7 +26,7 @@ _DTSizeItem::_DTSizeItem(): QGraphicsObject() {
|
||||
rects[i].setRect(-5, -5, 10, 10);
|
||||
rects[i].setPen(QPen(Qt::darkBlue));
|
||||
rects[i].setBrush(QBrush(QColor(64, 64, 255, 128)));
|
||||
//rects[i].setData(1100, true);
|
||||
//rects[i].setData(bvidBlockDecor, true);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -411,7 +411,7 @@ bool DrawTools::eventFilter(QObject * o, QEvent * e) {
|
||||
if (new_type == 1 || new_type == 2)
|
||||
((QAbstractGraphicsShapeItem*)new_item)->setBrush(Qt::white);
|
||||
new_item->setFlags(QGraphicsItem::ItemIsSelectable | QGraphicsItem::ItemIsMovable);
|
||||
new_item->setData(1100, true);
|
||||
new_item->setData(bvidBlockDecor, true);
|
||||
emit itemCreated(new_item);
|
||||
return true;
|
||||
}
|
||||
@@ -597,7 +597,10 @@ void DrawTools::emitZAvailabe(QGraphicsItem * item) {
|
||||
}
|
||||
QList<QGraphicsItem * > dl;
|
||||
if (item->parentItem() == 0) dl = view->decors();
|
||||
else if (item->parentItem()->data(1006) == "item") dl = ((BlockItem*)(item->parentItem()))->decors_;
|
||||
else {
|
||||
if (item->parentItem()->data(bvidType).toInt() == bvitBlock)
|
||||
dl = ((BlockItem*)(item->parentItem()))->decors_;
|
||||
}
|
||||
if (dl.size() <= 1) {
|
||||
moveZUpAvailable(false);
|
||||
moveZDownAvailable(false);
|
||||
@@ -895,7 +898,7 @@ void DrawTools::buttonTextEdit_clicked() {
|
||||
|
||||
void DrawTools::actionZ_triggered() {
|
||||
if (!cur_item) return;
|
||||
if (cur_item->data(1009) == "decor") {
|
||||
if (cur_item->data(bvidType).toInt() == bvitDecor) {
|
||||
BlockView * view = 0;
|
||||
if (cur_item->scene()) if (!cur_item->scene()->views().isEmpty())
|
||||
view = qobject_cast<BlockView * >(cur_item->scene()->views()[0]);
|
||||
@@ -913,7 +916,7 @@ void DrawTools::actionZ_triggered() {
|
||||
foreach (QGraphicsItem * d, dl) scene->addItem(d);
|
||||
scene->blockSignals(false);
|
||||
}
|
||||
if (cur_item->data(1011).toBool()) {
|
||||
if (cur_item->data(bvidBlockDecor).toBool()) {
|
||||
BlockItem * bi = qgraphicsitem_cast<BlockItem*>(cur_item->parentItem());
|
||||
if (!bi) return;
|
||||
QList<QGraphicsItem*> dl = bi->decors_;
|
||||
|
||||
Reference in New Issue
Block a user