Merge pull request #8308 from jherico/overlay_multi_edit

Allow atomic editing of multiple overlays from scripts
This commit is contained in:
Brad Hefta-Gaub 2016-07-23 13:51:51 -07:00 committed by GitHub
commit 4f04dbc926
2 changed files with 27 additions and 0 deletions

View file

@ -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;

View file

@ -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);