Take advantage of MapConnection as QObject

This commit is contained in:
GriffinR
2024-08-04 19:11:29 -04:00
parent b5c7f9f86b
commit 4af1c4d463
14 changed files with 374 additions and 382 deletions

View File

@@ -218,6 +218,9 @@ QPixmap Map::renderBorder(bool ignoreCache) {
}
QPixmap Map::renderConnection(const QString &direction, MapLayout * fromLayout) {
if (direction == "dive" || direction == "emerge")
return render();
if (!MapConnection::isCardinal(direction))
return QPixmap();
@@ -510,6 +513,22 @@ void Map::addEvent(Event *event) {
if (!ownedEvents.contains(event)) ownedEvents.append(event);
}
bool Map::removeConnection(MapConnection *connection) {
if (connections.removeOne(connection)) {
modify();
return true;
}
return false;
}
void Map::addConnection(MapConnection *connection) {
if (!connection || connections.contains(connection))
return;
connections.append(connection);
modify();
emit connectionAdded(connection);
}
void Map::modify() {
emit modified();
}