From 2dac347526933853fbc03b33aadd28b782177f73 Mon Sep 17 00:00:00 2001 From: Abdullah Tahiri Date: Tue, 3 Jan 2023 21:00:07 +0100 Subject: [PATCH] App: DocumentObject - New full label member function ==================================================== Before this commit there is a function getFullName(), which produces a string in the form document#objectname. For "document" the real name of the document is taken, whereas for objectname it is the initial name (Sketch, Sketch001), not the label. The new function fo this commit, getFullLabel(), provides a string documentlabel#documentobjectlabel, that are probably easier to identify for end users. --- src/App/DocumentObject.cpp | 10 ++++++++++ src/App/DocumentObject.h | 2 ++ 2 files changed, 12 insertions(+) diff --git a/src/App/DocumentObject.cpp b/src/App/DocumentObject.cpp index 10b6fccf5e..3ceb7fd4a0 100644 --- a/src/App/DocumentObject.cpp +++ b/src/App/DocumentObject.cpp @@ -282,6 +282,16 @@ std::string DocumentObject::getFullName() const { return name; } +std::string DocumentObject::getFullLabel() const { + if(!getDocument()) + return "?"; + + auto name = getDocument()->Label.getStrValue(); + name += "#"; + name += Label.getStrValue(); + return name; +} + const char *DocumentObject::getNameInDocument() const { // Note: It can happen that we query the internal name of an object even if it is not diff --git a/src/App/DocumentObject.h b/src/App/DocumentObject.h index dee7fff9ad..a6bf95f341 100644 --- a/src/App/DocumentObject.h +++ b/src/App/DocumentObject.h @@ -140,6 +140,8 @@ public: std::string getExportName(bool forced=false) const; /// Return the object full name of the form DocName#ObjName std::string getFullName() const override; + /// Return the object full label in the form DocName#ObjName + std::string getFullLabel() const; bool isAttachedToDocument() const override; const char* detachFromDocument() override; /// gets the document in which this Object is handled