2018-09-27 00:30:05 +01:00
|
|
|
#ifndef CONNECTIONPIXMAPITEM_H
|
|
|
|
#define CONNECTIONPIXMAPITEM_H
|
|
|
|
|
|
|
|
#include "mapconnection.h"
|
|
|
|
#include <QGraphicsPixmapItem>
|
|
|
|
#include <QPainter>
|
|
|
|
|
|
|
|
class ConnectionPixmapItem : public QObject, public QGraphicsPixmapItem {
|
|
|
|
Q_OBJECT
|
|
|
|
public:
|
2024-07-02 19:05:54 +01:00
|
|
|
ConnectionPixmapItem(QPixmap pixmap, MapConnection* connection, int x, int y, int baseMapWidth, int baseMapHeight)
|
|
|
|
: QGraphicsPixmapItem(pixmap),
|
|
|
|
connection(connection)
|
|
|
|
{
|
2018-09-27 00:30:05 +01:00
|
|
|
this->basePixmap = pixmap;
|
|
|
|
setFlag(ItemIsMovable);
|
|
|
|
setFlag(ItemSendsGeometryChanges);
|
|
|
|
this->initialX = x;
|
|
|
|
this->initialY = y;
|
2022-10-16 07:49:42 +01:00
|
|
|
this->initialOffset = connection->offset;
|
2018-09-27 00:30:05 +01:00
|
|
|
this->baseMapWidth = baseMapWidth;
|
|
|
|
this->baseMapHeight = baseMapHeight;
|
|
|
|
}
|
|
|
|
QPixmap basePixmap;
|
2024-07-02 19:05:54 +01:00
|
|
|
MapConnection* const connection;
|
2018-09-27 00:30:05 +01:00
|
|
|
int initialX;
|
|
|
|
int initialY;
|
|
|
|
int initialOffset;
|
|
|
|
int baseMapWidth;
|
|
|
|
int baseMapHeight;
|
2024-07-12 19:05:37 +01:00
|
|
|
|
2023-01-16 04:18:19 +00:00
|
|
|
void setEditable(bool editable);
|
|
|
|
bool getEditable();
|
2024-07-12 19:05:37 +01:00
|
|
|
void setSelected(bool selected);
|
|
|
|
void render();
|
2018-09-27 00:30:05 +01:00
|
|
|
|
2024-07-03 21:01:52 +01:00
|
|
|
private:
|
2024-07-12 19:05:37 +01:00
|
|
|
bool selected = false;
|
2024-07-03 21:01:52 +01:00
|
|
|
|
2018-09-27 00:30:05 +01:00
|
|
|
protected:
|
|
|
|
QVariant itemChange(GraphicsItemChange change, const QVariant &value);
|
|
|
|
void mousePressEvent(QGraphicsSceneMouseEvent*);
|
|
|
|
void mouseDoubleClickEvent(QGraphicsSceneMouseEvent*);
|
|
|
|
|
|
|
|
signals:
|
|
|
|
void connectionItemDoubleClicked(ConnectionPixmapItem* connectionItem);
|
2024-07-08 21:01:30 +01:00
|
|
|
void connectionMoved(MapConnection *, int newOffset);
|
2024-07-12 19:05:37 +01:00
|
|
|
void selectionChanged(bool selected);
|
2018-09-27 00:30:05 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // CONNECTIONPIXMAPITEM_H
|