Allowed to drag&drop items on python groups too in tree
This commit is contained in:
parent
1b70aef0f2
commit
1de458a161
|
@ -440,20 +440,39 @@ void TreeWidget::dropEvent(QDropEvent *event)
|
|||
::getGroupOfObject(obj);
|
||||
if (par) {
|
||||
// allow an object to be in one group only
|
||||
QString cmd = QString::fromAscii("App.getDocument(\"%1\").getObject(\"%2\").removeObject("
|
||||
QString cmd;
|
||||
if (par->getTypeId().isDerivedFrom(App::DocumentObjectGroupPython::getClassTypeId())) {
|
||||
// if this is a python group, call the method of its Proxy
|
||||
cmd = QString::fromAscii("App.getDocument(\"%1\").getObject(\"%2\").Proxy.removeObject("
|
||||
"App.getDocument(\"%1\").getObject(\"%3\"))")
|
||||
.arg(QString::fromAscii(doc->getName()))
|
||||
.arg(QString::fromAscii(par->getNameInDocument()))
|
||||
.arg(QString::fromAscii(obj->getNameInDocument()));
|
||||
} else {
|
||||
cmd = QString::fromAscii("App.getDocument(\"%1\").getObject(\"%2\").removeObject("
|
||||
"App.getDocument(\"%1\").getObject(\"%3\"))")
|
||||
.arg(QString::fromAscii(doc->getName()))
|
||||
.arg(QString::fromAscii(par->getNameInDocument()))
|
||||
.arg(QString::fromAscii(obj->getNameInDocument()));
|
||||
}
|
||||
Gui::Application::Instance->runPythonCode(cmd.toUtf8());
|
||||
}
|
||||
|
||||
// build Python command for execution
|
||||
QString cmd = QString::fromAscii("App.getDocument(\"%1\").getObject(\"%2\").addObject("
|
||||
QString cmd;
|
||||
if (grp->getTypeId().isDerivedFrom(App::DocumentObjectGroupPython::getClassTypeId())) {
|
||||
cmd = QString::fromAscii("App.getDocument(\"%1\").getObject(\"%2\").Proxy.addObject("
|
||||
"App.getDocument(\"%1\").getObject(\"%3\"))")
|
||||
.arg(QString::fromAscii(doc->getName()))
|
||||
.arg(QString::fromAscii(grp->getNameInDocument()))
|
||||
.arg(QString::fromAscii(obj->getNameInDocument()));
|
||||
} else {
|
||||
cmd = QString::fromAscii("App.getDocument(\"%1\").getObject(\"%2\").addObject("
|
||||
"App.getDocument(\"%1\").getObject(\"%3\"))")
|
||||
.arg(QString::fromAscii(doc->getName()))
|
||||
.arg(QString::fromAscii(grp->getNameInDocument()))
|
||||
.arg(QString::fromAscii(obj->getNameInDocument()));
|
||||
}
|
||||
Gui::Application::Instance->runPythonCode(cmd.toUtf8());
|
||||
}
|
||||
gui->commitCommand();
|
||||
|
|
Loading…
Reference in New Issue
Block a user