2021-06-17 18:32:32 +03:00
|
|
|
//#
|
|
|
|
//# Copyright (C) 2021-2021 QuasarApp.
|
|
|
|
//# Distributed under the GPLv3 software license, see the accompanying
|
|
|
|
//# Everyone is permitted to copy and distribute verbatim copies
|
|
|
|
//# of this license document, but changing it is not allowed.
|
|
|
|
//#
|
|
|
|
|
|
|
|
#include "claster.h"
|
2021-06-25 14:38:44 +03:00
|
|
|
#include "Crawl/singleclasterworlditem.h"
|
2021-06-17 18:32:32 +03:00
|
|
|
|
2021-06-25 14:38:44 +03:00
|
|
|
Claster::Claster() {}
|
2021-06-17 18:32:32 +03:00
|
|
|
|
2021-06-18 22:33:00 +03:00
|
|
|
Claster::~Claster() {
|
|
|
|
for (auto child : qAsConst(_objects)) {
|
|
|
|
child->removeClaster(this);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void Claster::add(ClasterItem *object) {
|
2021-06-17 18:32:32 +03:00
|
|
|
_objects.insert(object->guiId(), object);
|
2021-06-20 12:48:08 +03:00
|
|
|
if (auto singlClasterObject = dynamic_cast<ClasterItem*>(object)) {
|
2021-06-17 18:32:32 +03:00
|
|
|
singlClasterObject->setClaster(this);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-06-18 22:33:00 +03:00
|
|
|
void Claster::remove(ClasterItem *object) {
|
2021-06-17 18:32:32 +03:00
|
|
|
_objects.remove(object->guiId());
|
|
|
|
}
|
|
|
|
|
|
|
|
void Claster::remove(int id) {
|
|
|
|
_objects.remove(id);
|
|
|
|
}
|
|
|
|
|
2021-06-18 22:33:00 +03:00
|
|
|
const QHash<int, ClasterItem *> &Claster::objects() const {
|
2021-06-17 18:32:32 +03:00
|
|
|
return _objects;
|
|
|
|
}
|