#include "GVWidget.h"
#include <QPoint>

#include <QMessageBox>
#include <QString>
#include <QVariant>

void GVWidget::mousePressEvent(QMouseEvent* event) {
    if(event->button() == Qt::LeftButton) {
        emit left_press(widget_to_scene(QPoint(event->x(), event->y())));
    }
    if(event->button() == Qt::RightButton) {
        emit right_press(widget_to_scene(QPoint(event->x(), event->y())));
    }
    QGraphicsView::mousePressEvent(event);
}

void GVWidget::mouseReleaseEvent(QMouseEvent* event) {
    if(event->button() == Qt::LeftButton) {
        QPointF p = widget_to_scene(QPoint(event->x(), event->y()));
        emit left_release(p);
        emit clicked(p.x(), p.y());
    }
    if(event->button() == Qt::RightButton) {
        emit right_release(widget_to_scene(QPoint(event->x(), event->y())));
    }
    QGraphicsView::mouseReleaseEvent(event);
}

void GVWidget::mouseMoveEvent(QMouseEvent* event) {
    emit mouse_move(widget_to_scene(QPoint(event->x(), event->y())));
    QGraphicsView::mouseMoveEvent(event);
}

QPointF GVWidget::widget_to_scene(QPoint point) {
    return this->mapToScene(point);
}
