From 0877d20a603e0b41ddfe84e60f6f1c29c6d7af31 Mon Sep 17 00:00:00 2001 From: "Zheng, Lei" Date: Thu, 2 Jan 2020 11:15:02 +0800 Subject: [PATCH] Gui: expose 'Expression...' property editor menu action For expression binding of all type of property. Previously this action is only available if 'Show all' is activated. --- src/Gui/propertyeditor/PropertyEditor.cpp | 54 +++++++++++------------ 1 file changed, 27 insertions(+), 27 deletions(-) diff --git a/src/Gui/propertyeditor/PropertyEditor.cpp b/src/Gui/propertyeditor/PropertyEditor.cpp index 155727ca97..9e0c86a578 100644 --- a/src/Gui/propertyeditor/PropertyEditor.cpp +++ b/src/Gui/propertyeditor/PropertyEditor.cpp @@ -525,21 +525,36 @@ void PropertyEditor::contextMenuEvent(QContextMenuEvent *) { auto contextIndex = currentIndex(); std::unordered_set props; - - if(PropertyView::showAll()) { - for(auto index : selectedIndexes()) { - auto item = static_cast(index.internalPointer()); - if(item->isSeparator()) - continue; - for(auto parent=item;parent;parent=parent->parent()) { - const auto &ps = parent->getPropertyData(); - if(ps.size()) { - props.insert(ps.begin(),ps.end()); - break; - } + for(auto index : selectedIndexes()) { + auto item = static_cast(index.internalPointer()); + if(item->isSeparator()) + continue; + for(auto parent=item;parent;parent=parent->parent()) { + const auto &ps = parent->getPropertyData(); + if(ps.size()) { + props.insert(ps.begin(),ps.end()); + break; } } + } + if(props.size() == 1) { + auto item = static_cast(contextIndex.internalPointer()); + auto prop = *props.begin(); + if(item->isBound() + && !prop->isDerivedFrom(App::PropertyExpressionEngine::getClassTypeId()) + && !prop->isReadOnly() + && !prop->testStatus(App::Property::Immutable) + && !(prop->getType() & App::Prop_ReadOnly)) + { + contextIndex = propertyModel->buddy(contextIndex); + setCurrentIndex(contextIndex); + menu.addSeparator(); + menu.addAction(tr("Expression..."))->setData(QVariant(MA_Expression)); + } + } + + if(PropertyView::showAll()) { if(props.size()) { menu.addAction(tr("Add property"))->setData(QVariant(MA_AddProp)); unsigned count = 0; @@ -570,21 +585,6 @@ void PropertyEditor::contextMenuEvent(QContextMenuEvent *) { if(canRemove) menu.addAction(tr("Remove property"))->setData(QVariant(MA_RemoveProp)); - if(props.size() == 1) { - auto item = static_cast(contextIndex.internalPointer()); - auto prop = *props.begin(); - if(item->isBound() - && !prop->isDerivedFrom(App::PropertyExpressionEngine::getClassTypeId()) - && !prop->isReadOnly() - && !(prop->getType() & App::Prop_ReadOnly)) - { - contextIndex = propertyModel->buddy(contextIndex); - setCurrentIndex(contextIndex); - menu.addSeparator(); - menu.addAction(tr("Expression..."))->setData(QVariant(MA_Expression)); - } - } - if(props.size()) { menu.addSeparator();