2018-09-27 00:30:05 +01:00
|
|
|
#ifndef GRAPHICSVIEW_H
|
|
|
|
#define GRAPHICSVIEW_H
|
|
|
|
|
|
|
|
#include <QGraphicsView>
|
|
|
|
#include <QMouseEvent>
|
|
|
|
|
2024-01-28 19:15:45 +00:00
|
|
|
class NoScrollGraphicsView : public QGraphicsView
|
2022-09-07 02:42:19 +01:00
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
public:
|
2024-01-28 19:15:45 +00:00
|
|
|
NoScrollGraphicsView(QWidget *parent = nullptr) : QGraphicsView(parent) {}
|
|
|
|
|
|
|
|
protected:
|
|
|
|
void wheelEvent(QWheelEvent *event) {
|
|
|
|
event->ignore();
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
class ClickableGraphicsView : public NoScrollGraphicsView
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
public:
|
|
|
|
ClickableGraphicsView(QWidget *parent = nullptr) : NoScrollGraphicsView(parent) {}
|
2022-09-07 02:42:19 +01:00
|
|
|
|
|
|
|
public:
|
2022-09-28 00:22:08 +01:00
|
|
|
void mouseReleaseEvent(QMouseEvent *event) override {
|
|
|
|
QGraphicsView::mouseReleaseEvent(event);
|
2022-09-08 02:38:30 +01:00
|
|
|
emit this->clicked(event);
|
2022-09-07 02:42:19 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
signals:
|
2022-09-08 02:38:30 +01:00
|
|
|
void clicked(QMouseEvent *event);
|
2022-09-07 02:42:19 +01:00
|
|
|
};
|
|
|
|
|
2018-09-27 00:30:05 +01:00
|
|
|
class Editor;
|
|
|
|
|
|
|
|
class GraphicsView : public QGraphicsView
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
GraphicsView() : QGraphicsView() {}
|
|
|
|
GraphicsView(QWidget *parent) : QGraphicsView(parent) {}
|
|
|
|
|
|
|
|
public:
|
|
|
|
// GraphicsView_Object object;
|
|
|
|
Editor *editor;
|
|
|
|
protected:
|
|
|
|
void mousePressEvent(QMouseEvent *event);
|
|
|
|
void mouseMoveEvent(QMouseEvent *event);
|
|
|
|
void mouseReleaseEvent(QMouseEvent *event);
|
2020-10-26 03:49:00 +00:00
|
|
|
void moveEvent(QMoveEvent *event);
|
2018-09-27 00:30:05 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
//Q_DECLARE_METATYPE(GraphicsView)
|
|
|
|
|
|
|
|
#endif // GRAPHICSVIEW_H
|