fix typo; don't point from an item to itself

This commit is contained in:
Max-Wilhelm Bruker 2009-10-19 21:30:58 +02:00
parent c86a1ed4f6
commit 43d516672a
3 changed files with 15 additions and 11 deletions

View file

@ -32,14 +32,18 @@ void ArrowItem::updatePath(const QPointF &endPoint)
QLineF line(startPoint, endPoint);
qreal lineLength = line.length();
path = QPainterPath(QPointF(0, -arrowWidth / 2));
path.lineTo(0, arrowWidth / 2);
path.lineTo(lineLength - headLength, arrowWidth / 2);
path.lineTo(lineLength - headLength, headWidth / 2);
path.lineTo(lineLength, 0);
path.lineTo(lineLength - headLength, -headWidth / 2);
path.lineTo(lineLength - headLength, -arrowWidth / 2);
path.lineTo(0, -arrowWidth / 2);
if (lineLength < headLength)
path = QPainterPath();
else {
path = QPainterPath(QPointF(0, -arrowWidth / 2));
path.lineTo(0, arrowWidth / 2);
path.lineTo(lineLength - headLength, arrowWidth / 2);
path.lineTo(lineLength - headLength, headWidth / 2);
path.lineTo(lineLength, 0);
path.lineTo(lineLength - headLength, -headWidth / 2);
path.lineTo(lineLength - headLength, -arrowWidth / 2);
path.lineTo(0, -arrowWidth / 2);
}
setPos(startPoint);
setTransform(QTransform().rotate(-line.angle()));
@ -79,7 +83,7 @@ void ArrowDragItem::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
void ArrowDragItem::mouseReleaseEvent(QGraphicsSceneMouseEvent * /*event*/)
{
if (targetItem) {
if (targetItem && (targetItem != startItem)) {
CardZone *startZone = static_cast<CardZone *>(startItem->parentItem());
CardZone *targetZone = static_cast<CardZone *>(targetItem->parentItem());
startZone->getPlayer()->client->createArrow(