2018-09-27 00:30:05 +01:00
|
|
|
#ifndef CONNECTIONPIXMAPITEM_H
|
|
|
|
#define CONNECTIONPIXMAPITEM_H
|
|
|
|
|
|
|
|
#include "mapconnection.h"
|
|
|
|
#include <QGraphicsPixmapItem>
|
|
|
|
#include <QPainter>
|
2024-08-05 00:11:29 +01:00
|
|
|
#include <QPointer>
|
2018-09-27 00:30:05 +01:00
|
|
|
|
|
|
|
class ConnectionPixmapItem : public QObject, public QGraphicsPixmapItem {
|
|
|
|
Q_OBJECT
|
|
|
|
public:
|
2024-08-15 03:22:54 +01:00
|
|
|
ConnectionPixmapItem(MapConnection* connection, int originX, int originY);
|
|
|
|
ConnectionPixmapItem(MapConnection* connection, QPoint origin);
|
|
|
|
|
|
|
|
const QPointer<MapConnection> connection;
|
|
|
|
|
|
|
|
void setOrigin(int x, int y);
|
|
|
|
void setOrigin(QPoint pos);
|
2024-07-12 19:05:37 +01:00
|
|
|
|
2023-01-16 04:18:19 +00:00
|
|
|
void setEditable(bool editable);
|
|
|
|
bool getEditable();
|
2024-08-15 03:22:54 +01:00
|
|
|
|
2024-07-12 19:05:37 +01:00
|
|
|
void setSelected(bool selected);
|
2024-08-15 03:22:54 +01:00
|
|
|
|
|
|
|
void updatePos();
|
|
|
|
void render(bool ignoreCache = false);
|
2018-09-27 00:30:05 +01:00
|
|
|
|
2024-07-03 21:01:52 +01:00
|
|
|
private:
|
2024-08-15 03:22:54 +01:00
|
|
|
QPixmap basePixmap;
|
|
|
|
qreal originX;
|
|
|
|
qreal originY;
|
2024-07-12 19:05:37 +01:00
|
|
|
bool selected = false;
|
2024-08-15 03:22:54 +01:00
|
|
|
unsigned actionId = 0;
|
|
|
|
|
|
|
|
static const int mWidth = 16;
|
|
|
|
static const int mHeight = 16;
|
2024-07-03 21:01:52 +01:00
|
|
|
|
2018-09-27 00:30:05 +01:00
|
|
|
protected:
|
2024-08-15 03:22:54 +01:00
|
|
|
QVariant itemChange(GraphicsItemChange change, const QVariant &value) override;
|
|
|
|
void mousePressEvent(QGraphicsSceneMouseEvent*) override;
|
|
|
|
void mouseReleaseEvent(QGraphicsSceneMouseEvent*) override;
|
|
|
|
void mouseDoubleClickEvent(QGraphicsSceneMouseEvent*) override;
|
2018-09-27 00:30:05 +01:00
|
|
|
|
|
|
|
signals:
|
2024-08-05 00:11:29 +01:00
|
|
|
void connectionItemDoubleClicked(MapConnection*);
|
2024-07-12 19:05:37 +01:00
|
|
|
void selectionChanged(bool selected);
|
2018-09-27 00:30:05 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // CONNECTIONPIXMAPITEM_H
|