mirror of
https://github.com/overte-org/overte.git
synced 2025-08-09 19:52:26 +02:00
Allow atomic editing of multiple overlays from scripts
This commit is contained in:
parent
89d9affb41
commit
121a0f0f5e
2 changed files with 27 additions and 0 deletions
|
@ -234,6 +234,29 @@ bool Overlays::editOverlay(unsigned int id, const QVariant& properties) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool Overlays::editOverlays(const QVariant& propertiesById) {
|
||||||
|
QVariantMap map = propertiesById.toMap();
|
||||||
|
bool success = true;
|
||||||
|
QWriteLocker lock(&_lock);
|
||||||
|
for (const auto& key : map.keys()) {
|
||||||
|
bool convertSuccess;
|
||||||
|
unsigned int id = key.toUInt(&convertSuccess);
|
||||||
|
if (!convertSuccess) {
|
||||||
|
success = false;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
Overlay::Pointer thisOverlay = getOverlay(id);
|
||||||
|
if (!thisOverlay) {
|
||||||
|
success = false;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
QVariant properties = map[key];
|
||||||
|
thisOverlay->setProperties(properties.toMap());
|
||||||
|
}
|
||||||
|
return success;
|
||||||
|
}
|
||||||
|
|
||||||
void Overlays::deleteOverlay(unsigned int id) {
|
void Overlays::deleteOverlay(unsigned int id) {
|
||||||
Overlay::Pointer overlayToDelete;
|
Overlay::Pointer overlayToDelete;
|
||||||
|
|
||||||
|
|
|
@ -89,6 +89,10 @@ public slots:
|
||||||
/// successful edit, if the input id is for an unknown overlay this function will have no effect
|
/// successful edit, if the input id is for an unknown overlay this function will have no effect
|
||||||
bool editOverlay(unsigned int id, const QVariant& properties);
|
bool editOverlay(unsigned int id, const QVariant& properties);
|
||||||
|
|
||||||
|
/// edits an overlay updating only the included properties, will return the identified OverlayID in case of
|
||||||
|
/// successful edit, if the input id is for an unknown overlay this function will have no effect
|
||||||
|
bool editOverlays(const QVariant& propertiesById);
|
||||||
|
|
||||||
/// deletes a particle
|
/// deletes a particle
|
||||||
void deleteOverlay(unsigned int id);
|
void deleteOverlay(unsigned int id);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue