Allowed to drag&drop items on python groups too in tree

This commit is contained in:
Yorik van Havre 2012-05-19 18:07:09 -03:00
parent 1b70aef0f2
commit 1de458a161

View File

@ -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();