mirror of
https://github.com/JulianGro/overte.git
synced 2025-04-25 17:14:59 +02:00
pass just what is given to filter, more or less
This commit is contained in:
parent
00e53c8ea6
commit
957b1d9ae4
2 changed files with 9 additions and 4 deletions
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Reference in a new issue