mirror of
https://github.com/overte-org/overte.git
synced 2025-04-19 13:43:49 +02:00
Merge pull request #8308 from jherico/overlay_multi_edit
Allow atomic editing of multiple overlays from scripts
This commit is contained in:
commit
4f04dbc926
2 changed files with 27 additions and 0 deletions
|
@ -234,6 +234,29 @@ bool Overlays::editOverlay(unsigned int id, const QVariant& properties) {
|
|||
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) {
|
||||
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
|
||||
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
|
||||
void deleteOverlay(unsigned int id);
|
||||
|
||||
|
|
Loading…
Reference in a new issue