From 1de458a161a0cea2b28fb65ef9662764f448c2f8 Mon Sep 17 00:00:00 2001 From: Yorik van Havre Date: Sat, 19 May 2012 18:07:09 -0300 Subject: [PATCH] Allowed to drag&drop items on python groups too in tree --- src/Gui/Tree.cpp | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/src/Gui/Tree.cpp b/src/Gui/Tree.cpp index 03ca7cb2f..2c5f0ea15 100644 --- a/src/Gui/Tree.cpp +++ b/src/Gui/Tree.cpp @@ -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();