Groups: Handle add and remove object correctly

This commit is contained in:
Stefan Tröger
2017-02-09 19:52:44 +01:00
committed by wmayer
parent 53ff196c2e
commit aa0d25f54f
9 changed files with 32 additions and 187 deletions

View File

@@ -86,13 +86,6 @@ bool ViewProviderGroupExtension::extensionCanDropObject(App::DocumentObject* obj
if (group->hasObject(obj))
return false;
//group into group?
if (obj->hasExtension(App::GroupExtension::getExtensionClassTypeId())) {
if (group->isChildOf(obj->getExtensionByType<App::GroupExtension>()))
return false;
}
//We need to find the correct App extension to ask if this is a supported type, there should only be one
if (group->allowObject(obj))
return true;
@@ -107,18 +100,6 @@ void ViewProviderGroupExtension::extensionDropObject(App::DocumentObject* obj) {
Gui::Document* gui = Gui::Application::Instance->getDocument(doc);
gui->openCommand("Move object");
const App::DocumentObject* par = App::GroupExtension::getGroupOfObject(obj);
if (par) {
// allow an object to be in one group only
QString cmd;
cmd = QString::fromLatin1("App.getDocument(\"%1\").getObject(\"%2\").removeObject("
"App.getDocument(\"%1\").getObject(\"%3\"))")
.arg(QString::fromLatin1(doc->getName()))
.arg(QString::fromLatin1(par->getNameInDocument()))
.arg(QString::fromLatin1(obj->getNameInDocument()));
Gui::Command::doCommand(Gui::Command::App, cmd.toUtf8());
}
// build Python command for execution
QString cmd;
cmd = QString::fromLatin1("App.getDocument(\"%1\").getObject(\"%2\").addObject("