Gui: sync expression change in property editor
This patch fixes two problems, When one property item is assigned an expression, auto remove any parent and child item expressions to avoid expression conflicts. Disable value update when an property item or any of its parents are bound by an expression.
This commit is contained in:
@@ -111,6 +111,29 @@ void PropertyItem::reset()
|
||||
childItems.clear();
|
||||
}
|
||||
|
||||
void PropertyItem::onChange()
|
||||
{
|
||||
if(hasExpression()) {
|
||||
for(auto child : childItems) {
|
||||
if(child && child->hasExpression())
|
||||
child->setExpression(boost::shared_ptr<App::Expression>());
|
||||
}
|
||||
for(auto item=parentItem;item;item=item->parentItem) {
|
||||
if(item->hasExpression())
|
||||
item->setExpression(boost::shared_ptr<App::Expression>());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool PropertyItem::hasAnyExpression() const
|
||||
{
|
||||
if(ExpressionBinding::hasExpression())
|
||||
return true;
|
||||
if(parentItem)
|
||||
return parentItem->hasExpression();
|
||||
return false;
|
||||
}
|
||||
|
||||
void PropertyItem::setPropertyData(const std::vector<App::Property*>& items)
|
||||
{
|
||||
//if we have a single property we can bind it for expression handling
|
||||
@@ -581,7 +604,7 @@ bool PropertyItem::setData (const QVariant& value)
|
||||
// property or delegates again to its parent...
|
||||
if (propertyItems.empty()) {
|
||||
PropertyItem* parent = this->parent();
|
||||
if (!parent || !parent->parent())
|
||||
if (!parent || !parent->parent() || hasAnyExpression())
|
||||
return false;
|
||||
parent->setProperty(qPrintable(objectName()),value);
|
||||
return true;
|
||||
|
||||
@@ -164,6 +164,8 @@ public:
|
||||
int row() const;
|
||||
void reset();
|
||||
|
||||
bool hasAnyExpression() const;
|
||||
|
||||
protected:
|
||||
PropertyItem();
|
||||
|
||||
@@ -176,6 +178,9 @@ protected:
|
||||
virtual void initialize();
|
||||
QString pythonIdentifier(const App::Property*) const;
|
||||
|
||||
//gets called when the bound expression is changed
|
||||
virtual void onChange();
|
||||
|
||||
protected:
|
||||
QString propName;
|
||||
QString displayText;
|
||||
|
||||
Reference in New Issue
Block a user