Core: Update expressions on property rename
This includes both expressions in generic containers and in spreadsheets.
This commit is contained in:
committed by
Yorik van Havre
parent
18d87df6f1
commit
5bdfba3a1a
@@ -53,6 +53,8 @@ PropertyExpressionContainer::PropertyExpressionContainer()
|
||||
inited = true;
|
||||
GetApplication().signalRelabelDocument.connect(
|
||||
PropertyExpressionContainer::slotRelabelDocument);
|
||||
GetApplication().signalRenameDynamicProperty.connect(
|
||||
PropertyExpressionContainer::slotRenameDynamicProperty);
|
||||
}
|
||||
_ExprContainers.insert(this);
|
||||
}
|
||||
@@ -75,6 +77,13 @@ void PropertyExpressionContainer::slotRelabelDocument(const App::Document& doc)
|
||||
}
|
||||
}
|
||||
|
||||
void PropertyExpressionContainer::slotRenameDynamicProperty(const App::Property& prop, const char* oldName)
|
||||
{
|
||||
for (auto container : _ExprContainers) {
|
||||
container->onRenameDynamicProperty(prop, oldName);
|
||||
}
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
struct PropertyExpressionEngine::Private
|
||||
@@ -1208,6 +1217,17 @@ void PropertyExpressionEngine::onRelabeledDocument(const App::Document& doc)
|
||||
}
|
||||
}
|
||||
|
||||
void PropertyExpressionEngine::onRenameDynamicProperty(const App::Property& prop, const char* oldName)
|
||||
{
|
||||
ObjectIdentifier oldNameId = ObjectIdentifier(prop.getContainer(), std::string(oldName));
|
||||
ObjectIdentifier newNameId = ObjectIdentifier(prop);
|
||||
const std::map<ObjectIdentifier, ObjectIdentifier> paths = {
|
||||
{oldNameId, newNameId},
|
||||
};
|
||||
|
||||
renameObjectIdentifiers(paths);
|
||||
}
|
||||
|
||||
void PropertyExpressionEngine::getLinksTo(std::vector<App::ObjectIdentifier>& identifiers,
|
||||
App::DocumentObject* obj,
|
||||
const char* subname,
|
||||
|
||||
@@ -59,9 +59,11 @@ public:
|
||||
|
||||
protected:
|
||||
virtual void onRelabeledDocument(const App::Document& doc) = 0;
|
||||
virtual void onRenameDynamicProperty(const App::Property& prop, const char* oldName) = 0;
|
||||
|
||||
private:
|
||||
static void slotRelabelDocument(const App::Document& doc);
|
||||
static void slotRenameDynamicProperty(const App::Property& prop, const char* oldName);
|
||||
};
|
||||
|
||||
class AppExport PropertyExpressionEngine
|
||||
@@ -117,6 +119,7 @@ public:
|
||||
std::map<App::ObjectIdentifier, const App::Expression*> getExpressions() const override;
|
||||
void setExpressions(std::map<App::ObjectIdentifier, App::ExpressionPtr>&& exprs) override;
|
||||
void onRelabeledDocument(const App::Document& doc) override;
|
||||
void onRenameDynamicProperty(const App::Property& prop, const char* oldName) override;
|
||||
|
||||
void setValue()
|
||||
{} // Dummy
|
||||
|
||||
@@ -1577,6 +1577,17 @@ void PropertySheet::onRelabeledDocument(const App::Document& doc)
|
||||
}
|
||||
}
|
||||
|
||||
void PropertySheet::onRenameDynamicProperty(const App::Property& prop, const char* oldName)
|
||||
{
|
||||
ObjectIdentifier oldNameId = ObjectIdentifier(prop.getContainer(), std::string(oldName));
|
||||
ObjectIdentifier newNameId = ObjectIdentifier(prop);
|
||||
const std::map<ObjectIdentifier, ObjectIdentifier> paths = {
|
||||
{oldNameId, newNameId},
|
||||
};
|
||||
|
||||
renameObjectIdentifiers(paths);
|
||||
}
|
||||
|
||||
void PropertySheet::renameObjectIdentifiers(
|
||||
const std::map<App::ObjectIdentifier, App::ObjectIdentifier>& paths)
|
||||
{
|
||||
|
||||
@@ -51,6 +51,7 @@ public:
|
||||
std::map<App::ObjectIdentifier, const App::Expression*> getExpressions() const override;
|
||||
void setExpressions(std::map<App::ObjectIdentifier, App::ExpressionPtr>&& exprs) override;
|
||||
void onRelabeledDocument(const App::Document& doc) override;
|
||||
void onRenameDynamicProperty(const App::Property& prop, const char* oldName) override;
|
||||
|
||||
void updateElementReference(App::DocumentObject* feature,
|
||||
bool reverse = false,
|
||||
|
||||
Reference in New Issue
Block a user