pass just what is given to filter, more or less

This commit is contained in:
howard-stearns 2017-01-18 13:22:54 -08:00
parent 00e53c8ea6
commit 957b1d9ae4
2 changed files with 9 additions and 4 deletions

View file

@ -925,13 +925,18 @@ void EntityTree::initEntityEditFilterEngine() {
_hasEntityEditFilter = _entityEditFilterFunction.isFunction();
}
bool EntityTree::filterProperties(const EntityItemProperties& propertiesIn, EntityItemProperties& propertiesOut, bool& wasChanged) {
bool EntityTree::filterProperties(EntityItemProperties& propertiesIn, EntityItemProperties& propertiesOut, bool& wasChanged) {
if (!_hasEntityEditFilter) {
propertiesOut = propertiesIn;
wasChanged = false; // not changed
return true; // allowed
}
QScriptValue inputValues = propertiesIn.copyToScriptValue(&_entityEditFilterEngine, true, true);
auto oldProperties = propertiesIn.getDesiredProperties();
auto specifiedProperties = propertiesIn.getChangedProperties();
propertiesIn.setDesiredProperties(specifiedProperties);
QScriptValue inputValues = propertiesIn.copyToScriptValue(&_entityEditFilterEngine, false, true, true);
propertiesIn.setDesiredProperties(oldProperties);
auto in = QJsonValue::fromVariant(inputValues.toVariant()); // grab json copy now, because the inputValues might be side effected by the filter.
qDebug() << "fixme filter input" << propertiesIn << inputValues.toVariant() << in;
QScriptValueList args;
@ -950,7 +955,7 @@ bool EntityTree::filterProperties(const EntityItemProperties& propertiesIn, Enti
wasChanged = !eq;
}
qDebug() << "fixme filter result" << propertiesOut << result.toVariant() << "accepted:" << accepted << "changed:" << (accepted && wasChanged);
qDebug() << "fixme filter accepted:" << accepted << " changed : " << (accepted && wasChanged) << " result:" << propertiesOut << result.toVariant();
return accepted;
}

View file

@ -352,7 +352,7 @@ protected:
float _maxTmpEntityLifetime { DEFAULT_MAX_TMP_ENTITY_LIFETIME };
bool filterProperties(const EntityItemProperties& propertiesIn, EntityItemProperties& propertiesOut, bool& wasChanged);
bool filterProperties(EntityItemProperties& propertiesIn, EntityItemProperties& propertiesOut, bool& wasChanged);
QString _entityEditFilter;
bool _hasEntityEditFilter{ false };
QScriptEngine _entityEditFilterEngine;