Skip to content

Commit

Permalink
Gui: improve Std_LinkSelect command
Browse files Browse the repository at this point in the history
Recognize external object brought in by a link to a group. The
Std_LinkSelect will jump into the the owner document of the external
object.
  • Loading branch information
realthunder authored and wwmayer committed Oct 8, 2019
1 parent 9e2bdd6 commit 68a9a84
Showing 1 changed file with 23 additions and 6 deletions.
29 changes: 23 additions & 6 deletions src/Gui/CommandLink.cpp
Expand Up @@ -617,8 +617,8 @@ StdCmdLinkSelectLinked::StdCmdLinkSelectLinked()
: Command("Std_LinkSelectLinked")
{
sGroup = QT_TR_NOOP("Link");
sMenuText = QT_TR_NOOP("Select linked object");
sToolTipText = QT_TR_NOOP("Select the linked object");
sMenuText = QT_TR_NOOP("Go to linked object");
sToolTipText = QT_TR_NOOP("Select the linked object and switch to its owner document");
sWhatsThis = "Std_LinkSelectLinked";
sStatusTip = sToolTipText;
eType = AlterSelection;
Expand All @@ -639,8 +639,25 @@ static App::DocumentObject *getSelectedLink(bool finalLink, std::string *subname
return 0;

auto linkedVp = vp->getLinkedViewProvider(subname,finalLink);
if(!linkedVp || linkedVp==vp)
return 0;
if(!linkedVp || linkedVp==vp) {
if(sobj->getDocument()==sels[0].pObject->getDocument())
return 0;
for(const char *dot=strchr(sels[0].SubName,'.');dot;dot=strchr(dot+1,'.')) {
std::string sub(sels[0].SubName,dot+1-sels[0].SubName);
auto obj = sels[0].pObject->getSubObject(sub.c_str());
if(!obj)
break;
obj = obj->getLinkedObject(true);
if(obj->getDocument()!=sels[0].pObject->getDocument()) {
if(finalLink)
return sobj==obj?0:sobj;
if(subname)
*subname = std::string(dot+1);
return obj;
}
}
return finalLink?0:sobj;
}

if(finalLink && linkedVp == vp->getLinkedViewProvider())
return 0;
Expand Down Expand Up @@ -727,8 +744,8 @@ StdCmdLinkSelectLinkedFinal::StdCmdLinkSelectLinkedFinal()
: Command("Std_LinkSelectLinkedFinal")
{
sGroup = QT_TR_NOOP("Link");
sMenuText = QT_TR_NOOP("Select the deepest linked object");
sToolTipText = QT_TR_NOOP("Select the deepest linked object");
sMenuText = QT_TR_NOOP("Go to the deepest linked object");
sToolTipText = QT_TR_NOOP("Select the deepest linked object and switch to its owner document");
sWhatsThis = "Std_LinkSelectLinkedFinal";
sStatusTip = sToolTipText;
eType = AlterSelection;
Expand Down

0 comments on commit 68a9a84

Please sign in to comment.