porymap/include/ui/connectionpixmapitem.h

52 lines
1.5 KiB
C
Raw Normal View History

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:
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;
MapConnection* const connection;
2018-09-27 00:30:05 +01:00
int initialX;
int initialY;
int initialOffset;
int baseMapWidth;
int baseMapHeight;
void render(qreal opacity = 1);
void setEditable(bool editable);
bool getEditable();
void updateHighlight(bool selected);
2018-09-27 00:30:05 +01:00
private:
bool highlighted = false;
2018-09-27 00:30:05 +01:00
protected:
QVariant itemChange(GraphicsItemChange change, const QVariant &value);
void mousePressEvent(QGraphicsSceneMouseEvent*);
void mouseDoubleClickEvent(QGraphicsSceneMouseEvent*);
signals:
void connectionItemSelected(ConnectionPixmapItem* connectionItem);
void connectionItemDoubleClicked(ConnectionPixmapItem* connectionItem);
void connectionMoved(MapConnection*);
void highlightChanged(bool highlighted);
2018-09-27 00:30:05 +01:00
};
#endif // CONNECTIONPIXMAPITEM_H