Skip to content

Commit

Permalink
DocumentObject: Added getOldLabel() method, preparation for renaming …
Browse files Browse the repository at this point in the history
…of object identifiers.
  • Loading branch information
eivindkv authored and wwmayer committed Sep 21, 2015
1 parent 3f0fc98 commit b052c21
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/App/DocumentObject.cpp
Expand Up @@ -182,6 +182,12 @@ void DocumentObject::setDocument(App::Document* doc)

void DocumentObject::onBeforeChange(const Property* prop)
{

// Store current name in oldLabel, to be able to easily retrieve old name of document object later
// when renaming expressions.
if (prop == &Label)
oldLabel = static_cast<PropertyString*>(&Label)->getStrValue();

if (_pDoc)
_pDoc->onBeforeChangeProperty(this,prop);
}
Expand All @@ -191,6 +197,10 @@ void DocumentObject::onChanged(const Property* prop)
{
if (_pDoc)
_pDoc->onChangedProperty(this,prop);

if (prop == &Label && _pDoc)
_pDoc->signalRenamedObject(*this);

if (prop->getType() & Prop_Output)
return;
// set object touched
Expand Down
5 changes: 5 additions & 0 deletions src/App/DocumentObject.h
Expand Up @@ -160,6 +160,8 @@ class AppExport DocumentObject: public App::PropertyContainer

virtual void Save (Base::Writer &writer) const;

const std::string & getOldLabel() const { return oldLabel; }

protected:
/** get called by the document to recompute this feature
* Normaly this method get called in the processing of
Expand Down Expand Up @@ -205,6 +207,9 @@ class AppExport DocumentObject: public App::PropertyContainer
/// pointer to the document this object belongs to
App::Document* _pDoc;

/// Old label; used for renaming expressions
std::string oldLabel;

// pointer to the document name string (for performance)
const std::string *pcNameInDocument;
};
Expand Down

0 comments on commit b052c21

Please sign in to comment.