Gui: refactor Object Selection Dialog

It is originally used for dependency selection when copying object.
Modified to improve auto dependency selection, and for use by Link
configuration object setup, which also involves dependency selection.
This commit is contained in:
Zheng, Lei
2022-03-15 21:33:07 +08:00
committed by Chris Hennes
parent c6d87e69b5
commit 5947f91b17
5 changed files with 788 additions and 370 deletions

View File

@@ -283,6 +283,11 @@ SubObjectT::SubObjectT(const DocumentObject *obj, const char *s)
{
}
SubObjectT::SubObjectT(const DocumentObject *obj)
:DocumentObjectT(obj)
{
}
SubObjectT::SubObjectT(const DocumentObjectT& obj, const char *s)
:DocumentObjectT(obj),subname(s?s:"")
{
@@ -327,6 +332,22 @@ SubObjectT &SubObjectT::operator=(SubObjectT &&other)
return *this;
}
SubObjectT &SubObjectT::operator=(const DocumentObjectT &other)
{
if (this == &other)
return *this;
static_cast<DocumentObjectT&>(*this) = other;
subname.clear();
return *this;
}
SubObjectT &SubObjectT::operator=(const DocumentObject *other)
{
static_cast<DocumentObjectT&>(*this) = other;
subname.clear();
return *this;
}
bool SubObjectT::operator==(const SubObjectT &other) const {
return static_cast<const DocumentObjectT&>(*this) == other
&& subname == other.subname;
@@ -398,6 +419,43 @@ std::vector<App::DocumentObject*> SubObjectT::getSubObjectList() const {
return {};
}
std::string SubObjectT::getObjectFullName(const char *docName) const
{
std::ostringstream ss;
if (!docName || getDocumentName() != docName) {
ss << getDocumentName();
if (auto doc = getDocument()) {
if (doc->Label.getStrValue() != getDocumentName())
ss << "(" << doc->Label.getValue() << ")";
}
ss << "#";
}
ss << getObjectName();
if (getObjectLabel().size() && getObjectLabel() != getObjectName())
ss << " (" << getObjectLabel() << ")";
return ss.str();
}
std::string SubObjectT::getSubObjectFullName(const char *docName) const
{
if (subname.empty())
return getObjectFullName(docName);
std::ostringstream ss;
if (!docName || getDocumentName() != docName) {
ss << getDocumentName();
if (auto doc = getDocument()) {
if (doc->Label.getStrValue() != getDocumentName())
ss << "(" << doc->Label.getValue() << ")";
}
ss << "#";
}
ss << getObjectName() << "." << subname;
auto sobj = getSubObject();
if (sobj && sobj->Label.getStrValue() != sobj->getNameInDocument())
ss << " (" << sobj->Label.getValue() << ")";
return ss.str();
}
// -----------------------------------------------------------------------------
PropertyLinkT::PropertyLinkT()