bug fixes, refactoring started
git-svn-id: svn://db.shs.com.ru/libs@590 a8b55f48-bf90-11e4-a774-851b48703e85
This commit is contained in:
@@ -95,46 +95,6 @@ void BlockView::_init() {
|
||||
sc.setAlphaF(0.2);
|
||||
sel_rect.setBrush(QBrush(sc));
|
||||
checkPaste(true);
|
||||
|
||||
/*AlignedTextItem * ti = new AlignedTextItem("This is text!");
|
||||
ti->setFlag(QGraphicsItem::ItemIsSelectable, true);
|
||||
ti->setFlag(QGraphicsItem::ItemIsMovable, true);
|
||||
addItem(ti);
|
||||
ti->setAlignment(Qt::AlignBottom | Qt::AlignLeft);
|
||||
ti->setText("text\nt");
|
||||
QGraphicsSimpleTextItem * t__ = new QGraphicsSimpleTextItem("TEXT");
|
||||
t__->setFlags(QGraphicsItem::ItemIsSelectable);
|
||||
addItem(t__);
|
||||
addItem(new QGraphicsLineItem(0, -50, 0, 50));
|
||||
addItem(new QGraphicsLineItem(-50, 0, 50, 0));
|
||||
|
||||
for (int i = 0; i < 5; ++i) {
|
||||
BlockItem * it = new BlockItem();
|
||||
it->setPos(i*150, i*20);
|
||||
it->addPin(new BlockItemPin());
|
||||
if (i == 2)
|
||||
it->setFlags(QGraphicsItem::ItemIsSelectable);
|
||||
scene_->addItem(it);
|
||||
}
|
||||
QGraphicsItem * it = new QGraphicsRectItem(0, 0, 200, 100);
|
||||
it->setFlags(QGraphicsItem::ItemIsSelectable | QGraphicsItem::ItemIsMovable);
|
||||
it->setData(1001, true);
|
||||
scene_->addItem(it);
|
||||
|
||||
BlockBusItem * bus = new BlockBusItem();
|
||||
bus->setImages(QImage("icons/bus_twin.png"), QImage("icons/bus_end_rj45.png"));
|
||||
bus->setEndpointsNumber(3);
|
||||
bus->setBusType(1);
|
||||
bus->appendPoint(QPointF(20, 40));
|
||||
bus->appendPoint(QPointF(150, -20));
|
||||
bus->appendPoint(QPointF(40, -80));
|
||||
//bus->setImages(QImage("icons/bus_twin.png"), QImage("icons/bus_end_rj45.png"));
|
||||
addItem(bus);
|
||||
bus = new BlockBusItem();
|
||||
bus->appendPoint(QPointF(-20, 40));
|
||||
bus->appendPoint(QPointF(100, -30));
|
||||
bus->appendPoint(QPointF(20, -60));
|
||||
addItem(bus);*/
|
||||
}
|
||||
|
||||
|
||||
@@ -242,6 +202,7 @@ bool BlockView::eventFilter(QObject * o, QEvent * e) {
|
||||
mm_ci = 0;
|
||||
break;
|
||||
}
|
||||
if (mm_ci->data(1007).toBool()) break;
|
||||
}
|
||||
//qDebug() << "press";
|
||||
if (me->buttons().testFlag(Qt::LeftButton)) btncnt++;
|
||||
@@ -289,7 +250,7 @@ bool BlockView::eventFilter(QObject * o, QEvent * e) {
|
||||
//qDebug() << mil;
|
||||
while (!mil.isEmpty()) {
|
||||
mm_ci = mil.front();
|
||||
if (mm_ci->data(1008).toBool()) {
|
||||
if (mm_ci->data(1008).toBool() || mm_ci->data(1007).toBool()) {
|
||||
mil.pop_front();
|
||||
} else break;
|
||||
}
|
||||
@@ -377,6 +338,7 @@ bool BlockView::eventFilter(QObject * o, QEvent * e) {
|
||||
mm_ci = 0;
|
||||
break;
|
||||
}
|
||||
if (mm_ci->data(1007).toBool()) break;
|
||||
if (mm_cancel) return true;
|
||||
if (me->buttons().testFlag(Qt::LeftButton)) {
|
||||
if (!mm_drag) {
|
||||
@@ -541,6 +503,7 @@ bool BlockView::eventFilter(QObject * o, QEvent * e) {
|
||||
mm_ci = 0;
|
||||
break;
|
||||
}
|
||||
if (mm_ci->data(1007).toBool()) break;
|
||||
if (mm_copy) {
|
||||
QList<QGraphicsItem*> ai;
|
||||
blockSignals(true);
|
||||
@@ -1031,7 +994,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->parentItem() == 0)
|
||||
if ((i->data(1009) == "decor") && !i->data(1008).toBool() && !i->data(1007).toBool() && (i->parentItem() == 0)
|
||||
&& (i != &sel_rect) && (i != &tmp_bus) && !tmp_buses.contains((BlockBusItem*)i))
|
||||
ret << i;
|
||||
return ret;
|
||||
@@ -1185,7 +1148,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) != "item_selection") && !i->data(1008).toBool()) {
|
||||
if (!(i->data(1007).toBool()) && !i->data(1008).toBool()) {
|
||||
QRectF br = i->mapRectToScene(i->boundingRect());
|
||||
if (br.width() <= 1 || br.height() <= 1) continue;
|
||||
if (f) ret = br;
|
||||
@@ -2061,7 +2024,7 @@ void BlockView::removeAll() {
|
||||
if (i->data(1006) == "item")
|
||||
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())) {
|
||||
if ((i != &sel_rect) && (i != &tmp_bus) && (i->parentItem() == 0) && !(i->data(1008).toBool()) && !(i->data(1007).toBool())) {
|
||||
//qDebug() << "delete" << i->data(1004);
|
||||
scene_->sendEvent(i, new QGraphicsSceneEvent(QEvent::Close));
|
||||
delete i;
|
||||
|
||||
Reference in New Issue
Block a user