void CircuitView::dragEnterEvent(QDragEnterEvent *e) { ICNView::dragEnterEvent(e); if (e->isAccepted()) return; bool acceptable = e->provides("ktechlab/component") || e->provides("ktechlab/subcircuit"); if (!acceptable) return; e->accept(true); createDragItem(e); }
void CardItem::mouseMoveEvent(QGraphicsSceneMouseEvent *event) { if (event->buttons().testFlag(Qt::RightButton)) { if ((event->screenPos() - event->buttonDownScreenPos(Qt::RightButton)).manhattanLength() < 2 * QApplication::startDragDistance()) return; QColor arrowColor = Qt::red; if (event->modifiers().testFlag(Qt::ControlModifier)) arrowColor = Qt::yellow; else if (event->modifiers().testFlag(Qt::AltModifier)) arrowColor = Qt::blue; else if (event->modifiers().testFlag(Qt::ShiftModifier)) arrowColor = Qt::green; drawArrow(arrowColor); } else if (event->buttons().testFlag(Qt::LeftButton)) { if ((event->screenPos() - event->buttonDownScreenPos(Qt::LeftButton)).manhattanLength() < 2 * QApplication::startDragDistance()) return; if (zone->getIsView()) { const ZoneViewZone *const view = static_cast<const ZoneViewZone *const>(zone); if (view->getRevealZone() && !view->getWriteableRevealZone()) return; } else if (!owner->getLocal()) return; bool forceFaceDown = event->modifiers().testFlag(Qt::ShiftModifier); createDragItem(id, event->pos(), event->scenePos(), facedown || forceFaceDown); dragItem->grabMouse(); QList<QGraphicsItem *> sel = scene()->selectedItems(); int j = 0; for (int i = 0; i < sel.size(); i++) { CardItem *c = (CardItem *) sel.at(i); if ((c == this) || (c->getZone() != zone)) continue; ++j; QPointF childPos; if (zone->getHasCardAttr()) childPos = c->pos() - pos(); else childPos = QPointF(j * CARD_WIDTH / 2, 0); CardDragItem *drag = new CardDragItem(c, c->getId(), childPos, c->getFaceDown() || forceFaceDown, dragItem); drag->setPos(dragItem->pos() + childPos); scene()->addItem(drag); } } setCursor(Qt::OpenHandCursor); }