moved.emit();
} else if (change == GraphicsItemChange.ItemPositionChange
&& scene() != null) {
// value is the new position.
QPointF newPos = (QPointF) value;
QRectF rect = scene().sceneRect();
double width = this.boundingRect().width();
width = Math.floor(width / scene.tileSize);
double height = this.boundingRect().height();
height = Math.floor(height / scene.tileSize);
QPointF p = rect.bottomRight();
//p.setX((fpScene.device.getColumns() - width) * fpScene.tileSize);
//p.setY((fpScene.device.getRows() - height) * fpScene.tileSize);
p.setX((scene.cols - width) * scene.tileSize);
p.setY((scene.rows - height) * scene.tileSize);
rect.setBottomRight(p);
if (!rect.contains(newPos)) {
// Keep the item inside the scene rect.
newPos.setX(Math.min(rect.right(), Math.max(newPos.x(), rect
.left())));
newPos.setY(Math.min(rect.bottom(), Math.max(newPos.y(), rect
.top())));
}
long x = Math.round(newPos.x() / scene.tileSize)
* scene.tileSize;
long y = Math.round(newPos.y() / scene.tileSize)