<commit_before>#include "wallItem.h"
#include <QtGui/QGraphicsSceneMouseEvent>
#include <QtGui/QStyleOptionGraphicsItem>
#include <QDebug>

using namespace qReal::interpreters::robots;
using namespace details::d2Model;
using namespace graphicsUtils;

WallItem::WallItem(QPointF const &begin, QPointF const &end)
	: LineItem(begin, end)
	, mDragged(false)
	, mImage(QImage(":/icons/wall.png"))
{
	setPrivateData();
}

void WallItem::setPrivateData()
{
	setZValue(1);

	mPen.setWidth(10);

	mBrush.setStyle(Qt::SolidPattern);
	mBrush.setTextureImage(mImage);
	mPen.setStyle(Qt::NoPen);
}

QPointF WallItem::begin()
{
	return QPointF(mX1, mY1) + scenePos();
}

QPointF WallItem::end()
{
	return QPointF(mX2, mY2) + scenePos();
}

void WallItem::drawItem(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget)
{
	Q_UNUSED(option);
	Q_UNUSED(widget);
	painter->drawPath(shape());
}

void WallItem::drawExtractionForItem(QPainter *painter)
{
	if (!isSelected())
		return;

	painter->setPen(QPen(Qt::green));
	mLineImpl.drawExtractionForItem(painter, mX1, mY1, mX2, mY2, drift);
	mLineImpl.drawFieldForResizeItem(painter, resizeDrift, mX1, mY1, mX2, mY2);
}

void WallItem::mousePressEvent(QGraphicsSceneMouseEvent * event)
{
	AbstractItem::mousePressEvent(event);
	mDragged = true;
}

void WallItem::mouseMoveEvent(QGraphicsSceneMouseEvent * event)
{
	QPointF oldPos = pos();
	QGraphicsItem::mouseMoveEvent(event);
	if (mDragged) {
		emit wallDragged(this->realBoundingRect(), oldPos);
	}
}

bool WallItem::isDragged()
{
	return mDragged;
}

void WallItem::toStopWall(bool isNeedStop, QPointF const& oldPos)
{
	if (isNeedStop) {
		setPos(oldPos);
		setFlag(ItemIsMovable, false);
	} else {
		setFlag(ItemIsMovable, true);
	}
}
<commit_msg>fixed dragging wall on robot<commit_after>#include "wallItem.h"
#include <QtGui/QGraphicsSceneMouseEvent>
#include <QtGui/QStyleOptionGraphicsItem>
#include <QDebug>

using namespace qReal::interpreters::robots;
using namespace details::d2Model;
using namespace graphicsUtils;

WallItem::WallItem(QPointF const &begin, QPointF const &end)
	: LineItem(begin, end)
	, mDragged(false)
	, mImage(QImage(":/icons/wall.png"))
{
	setPrivateData();
}

void WallItem::setPrivateData()
{
	setZValue(1);

	mPen.setWidth(10);

	mBrush.setStyle(Qt::SolidPattern);
	mBrush.setTextureImage(mImage);
	mPen.setStyle(Qt::NoPen);
}

QPointF WallItem::begin()
{
	return QPointF(mX1, mY1) + scenePos();
}

QPointF WallItem::end()
{
	return QPointF(mX2, mY2) + scenePos();
}

void WallItem::drawItem(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget)
{
	Q_UNUSED(option);
	Q_UNUSED(widget);
	painter->drawPath(shape());
}

void WallItem::drawExtractionForItem(QPainter *painter)
{
	if (!isSelected())
		return;

	painter->setPen(QPen(Qt::green));
	mLineImpl.drawExtractionForItem(painter, mX1, mY1, mX2, mY2, drift);
	mLineImpl.drawFieldForResizeItem(painter, resizeDrift, mX1, mY1, mX2, mY2);
}

void WallItem::mousePressEvent(QGraphicsSceneMouseEvent * event)
{
	AbstractItem::mousePressEvent(event);
	mDragged = true;
}

void WallItem::mouseMoveEvent(QGraphicsSceneMouseEvent * event)
{
	QPointF oldPos = pos();
	QGraphicsItem::mouseMoveEvent(event);
	if (mDragged) {
		emit wallDragged(this->realBoundingRect(), oldPos);
	}
}

bool WallItem::isDragged()
{
	return mDragged;
}

void WallItem::toStopWall(bool isNeedStop, QPointF const& oldPos)
{
	if (mDragged) {
		if (isNeedStop) {
			setPos(oldPos);
			setFlag(ItemIsMovable, false);
		} else {
			setFlag(ItemIsMovable, true);
		}
	}
}

{'fraction_non_alphanumeric': 0.14201183431952663, 'fraction_numerical': 0.009016624401239785, 'mean_word_length': 6.941834451901566, 'pattern_counts': {'":': 2, '<': 9, '<?xml version=': 0, '>': 15, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5451785', 'n_tokens_mistral': 1412, 'n_tokens_neox': 1362, 'n_words': 232}